Make `HTMLEditor` stop deleting inline elements when they become empty as far as possible especially in `contenteditable=plaintext-only`
Categories
(Core :: DOM: Editor, enhancement)
Tracking
()
People
(Reporter: masayuki, Unassigned)
References
(Blocks 1 open bug)
Details
New tests which will be added in bug 1921723 won't pass on Firefox and Chrome in the following case and similar cases.
<p><b>[a]</b></p>
Delete the selection, then, the DOM becomes:
<p><br></p>
So, <b>
is deleted. However, the builtin editors cache the bold style. Therefore, when you type "c", then, <b>
is restored.
<p><b>c</b><br></p>
However, the <br>
is put stays outside of the <b>
. Additionally, if you type "c" after moving caret, the cache may be discarded. Then, you'll see
<p>c<br></p>
In contenteditable=plaintext-only
, document.execCommand("bold")
does not work. So, even the web app cannot restore the bold style with keeping the undo transactions.
So, I think that when the paragraph becomes empty, the DOM should become:
<p><b><br></b></p>
Then, typing new character at the <br>
will be in <b>
consistently.
Reporter | ||
Comment 1•25 days ago
|
||
Unfortunately, our HTMLEditor
puts the <br>
for empty paragraph in OnEndHandlingTopLevelEditSubActionInternal()
(by AdjustCaretPositionAndEnsurePaddingBRElement
) after removing the <b>
(by RemoveEmptyNodesIn
). So perhaps, we need to make the delete handlers put <br>
elements before OnEndHandlingTopLevelEditSubActionInternal
runs.
Description
•