Closed Bug 1940653 Opened 1 year ago Closed 1 year ago

Pasting plaintext into the filed in discussions.apple.com gets lost the containg line breaks

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

VERIFIED FIXED
136 Branch
Tracking Status
firefox-esr128 --- unaffected
firefox134 --- unaffected
firefox135 --- fixed
firefox136 --- verified

People

(Reporter: masayuki, Assigned: masayuki)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

##STR

  1. Load https://discussions.apple.com/community/macos/sequoia
  2. Go to an article
  3. Press "reply" button
  4. Paste multi-line text into the field (use Ctrl/Cmd - Shift - V to paste rich text as plaintext)

##AR
multiple lines are pasted as single line text

##ER
each line should be pasted as within its owning line

First, it seems that the web app itself removes the pasted new lines which are preformatted by white-space: pre-wrap.

However, before bug 1921180, we pasted the pasted text as HTML. So, we should revert the code partially for contenteditable="true" cases.

Oh, wait, but Chrome also using preformatted linefeeds in <div contenteditable style="white-space:pre-wrap"><p><br></p></div>. So, partially reverting our behavior causes incompatible with Chrome in the other web apps in the same situation.

If I disable the paste event listener of the editing host in Chrome, the form will have the plaintext as-is, so, they handle paste by themselves only for Chrome. (I verified that our editor inserts text when I paste plaintext on debug build.)

Ah, okay, I got it.

Chrome inserts only a preformatted linefeed Text when Shift + Enter, etc. However, pasting plaintext inserts only one Text node, i.e., it may contain multiple preformatted linefeeds.

Firefox keeps the consistency with any insertions, Firefox inserts multiple Text for string containing multiple linefeeds.

Once I make HTMLEditor::HandleInsertText inserts only one Text, the form works as expected.

Set release status flags based on info from the regressing bug 1921180

The form of https://discussions.apple.com/ handles newly inserted Text nodes
asynchronously after pasted. Then, the text will be wrapped into <p>
elements. However, the handler does not assume that multiple and consecutive
Text nodes are inserted by a pasting. Therefore, they fail handling our
pasted text which was split to each line and each preformatted linefeed.

Chrome puts only one Text node at pasting multiline plaintext and following
this behavior fixes the issue in the form. Therefore, we should follow the
behavior at least for now.

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/e3417a5f4b06 Make `HTMLEditor::HandlerInsertText` insert one `Text` when linefeeds are preformatted r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/50021 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
Upstream PR merged by moz-wptsync-bot

Comment on attachment 9446471 [details]
Bug 1940653 - Make HTMLEditor::HandlerInsertText insert one Text when linefeeds are preformatted r=m_kato!

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Cannot paste multiline plaintext in the Apple's forum.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce: 1. Load https://discussions.apple.com/community/macos/sequoia
  1. Go to an article
  2. Press "reply" button
  3. Paste multi-line text into the field (use Ctrl/Cmd - Shift - V to paste rich text as plaintext)
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): We started using preformatted linefeed instead of <br> as same as Chrome. Chrome inserts a linefeed with new Text node when insert a linebreak (like Shift-Enter). Therefore, we follow this behavior in any cases, but Chrome does not do it when inserting multiline text once. This difference caused the issue on the web site. Therefore, this patch makes us follow the Chrome about the multiline text insertion too. Finnaly, the new path is really simple.
  • String changes made/needed: none
  • Is Android affected?: Yes
Attachment #9446471 - Flags: approval-mozilla-beta?

Calling VERIFIED based on bug 1938542 comment 21.

Status: RESOLVED → VERIFIED
Flags: in-testsuite+

Comment on attachment 9446471 [details]
Bug 1940653 - Make HTMLEditor::HandlerInsertText insert one Text when linefeeds are preformatted r=m_kato!

Approved for 135.0b5.

Attachment #9446471 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
See Also: 1938542
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: