Is there a way to decorate the appearance of (Custom)LineBreakNode? #5329
-
|
I am creating a CustomLineBreakNode class that inherits from LineBreakNode because I need to convert the createDOM() {
let fragment = document.createDocumentFragment()
let span = document.createElement('span')
span.innerHTML= '⏎'
fragment.appendChild(span)
fragment.appendChild(document.createElement('br'))
return fragment
}If I make this work, I seem to lose control of the cursor in the text editor. The cursor is lost when I make a line break, and even if I click again to bring the cursor out, the cursor is lost again when I move across the Is it legal to return DocumentFragment in createDOM? Or is there a correct way to decorate |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
No, createDOM returns an HTMLElement, which is not compatible with DocumentFragment
Fortunately you can insert createDOM() {
const span = document.createElement('span');
span.innerHTML = '⏎';
span.appendChild(document.createElement('br'));
return span;
}Screen.Recording.2023-12-05.at.17.05.20.movI am not so sure because an additional issue appear: you can see the |
Beta Was this translation helpful? Give feedback.
Okay. Finally, by returning an empty <span> in CustomLineBreakNode's createDOM and applying the CSS I wrote above, I was able to display the RETURN mark while simulating the behavior of the <br> tag. Thanks a lot for your advice.