Closed Bug 1921180 Opened 1 year ago Closed 1 year ago

Use `U+000A`(`LF`) instead of `<br>` when `contenteditable=plaintext-only` and the line breakers are preformatted by `white-space`

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

(Keywords: parity-chrome, parity-safari, webcompat:platform-bug)

Attachments

(3 files)

Chrome loves linefeed characters instead of <br> in contenteditable. Changing the behavior for contenteditable=true might be risky. I think that we should change our behavior only for contenteditable=plaintext-only first.

However, probably we need to change the behavior of inserting padding <br> for empty editor and last line since web apps do not assume linefeed and <br>s are mixed in same editing host.

Ah, textContent does not convert <br> to \n. So, it might be important to support this.

It seems that it's okay to use <br> for empty paragraph. It's same as Chrome and Safari. However, they delete the padding <br> at typing something. We should follow it.

When inserting a preformatted linefeed, Chrome inserts a Text which has only
a linefeed instead of inserting the linefeed to existing Text. This allows
to keep Text smaller. So, let's follow the behavior.

Depends on D231663

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

Currently, only the "insert line break" handler uses a preformatted linefeed
instead of <br> if it's better. However, in contenteditable="plaintext-only", we should use preformatted linefeeds in most cases. Therefore, we should make them call the inserters with the GetPreferredLineBreak` result.

Depends on D231665

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/3c5c29d73626 part 1: Make `HTMLEditor` do not update nor join `Text` node if it has only one preformatted linefeed r=m_kato https://hg.mozilla.org/integration/autoland/rev/e2ea5020019f part 2: Make `HTMLEditor::HandleInsertLinefeed` use `InsertLineBreak` with `LineBreakType::Linefeed` r=m_kato https://hg.mozilla.org/integration/autoland/rev/f1683312c60f part 3: Make `HTMLEditor` use preformatted linefeeds if it's preferred r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: