mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-21 21:41:47 +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)) {
|
} else if (!elementIsBlock(child)) {
|
||||||
child.tagName = "P"
|
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á
|
* * Wrappea el contenido de un UL o OL en un LI si no lo está
|
||||||
*/
|
*/
|
||||||
function fixContent (contentEl) {
|
function fixContent (contentEl) {
|
||||||
if (!contentEl.firstChild) {
|
|
||||||
const newEl = document.createElement("p")
|
|
||||||
contentEl.appendChild(newEl)
|
|
||||||
window.getSelection().collapse(newEl)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const child of contentEl.childNodes) {
|
for (const child of contentEl.childNodes) {
|
||||||
if (child.tagName) {
|
if (child.tagName) {
|
||||||
if (elementIsParentBlock(child)) {
|
if (elementIsParentBlock(child)) {
|
||||||
|
|
Loading…
Reference in a new issue