mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 04:21:41 +00:00
prevenir loop infinito arreglando poner párrafos automágicamente cuando no los hay
This commit is contained in:
parent
4107267e5b
commit
c646ad3fe0
1 changed files with 8 additions and 6 deletions
|
@ -236,6 +236,14 @@ function cleanContent (contentEl) {
|
|||
} else if (!elementIsBlock(child)) {
|
||||
child.tagName = "P"
|
||||
}
|
||||
} else if (child.nodeType === Node.TEXT_NODE) {
|
||||
const wasSelected = sel.getRangeAt(0).intersectsNode(child)
|
||||
|
||||
const el = document.createElement("p")
|
||||
el.appendChild(child)
|
||||
contentEl.insertBefore(el, child.nextSibling)
|
||||
|
||||
if (wasSelected) sel.collapse(el, child.data.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,12 +254,6 @@ function cleanContent (contentEl) {
|
|||
* * Wrappea el contenido de un UL o OL en un LI si no lo está
|
||||
*/
|
||||
function fixContent (contentEl) {
|
||||
if (!contentEl.firstChild) {
|
||||
const newEl = document.createElement("p")
|
||||
contentEl.appendChild(newEl)
|
||||
window.getSelection().collapse(newEl)
|
||||
}
|
||||
|
||||
for (const child of contentEl.childNodes) {
|
||||
if (child.tagName) {
|
||||
if (elementIsParentBlock(child)) {
|
||||
|
|
Loading…
Reference in a new issue