5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 06:51:42 +00:00

apretar dos enters para salir de una lista

This commit is contained in:
void 2020-11-06 11:26:58 -03:00
parent c926dcfe8f
commit a0e48a0cca
2 changed files with 13 additions and 6 deletions

View file

@ -322,16 +322,21 @@ function setupEditor (editorEl) {
switch (parentEl.tagName) {
case "UL":
case "OL":
newEl = document.createElement("li")
let itemEl = sel.anchorNode
while (itemEl.tagName !== "LI" && parentEl.contains(itemEl)) itemEl = itemEl.parentElement
while (itemEl.tagName !== "LI" && parentEl.contains(itemEl))
itemEl = itemEl.parentElement
parentEl.insertBefore(newEl, itemEl && parentEl.contains(itemEl) && itemEl.nextSibling || null)
break
if (!parentEl.contains(itemEl)) itemEl = null
if (itemEl && hasContent(itemEl)) {
newEl = document.createElement("li")
parentEl.insertBefore(newEl, itemEl && itemEl.nextSibling)
break
}
// Fallthrough si es un li sin contenido, así salís de la lista
default:
newEl = document.createElement("p")
contentEl.insertBefore(newEl, parentEl.nextSibling || null)
contentEl.insertBefore(newEl, parentEl.nextSibling)
}
sel.collapse(newEl)

View file

@ -25,6 +25,8 @@
margin: 0 auto;
}
ol, ul { margin: 0; }
.editor-content {
div[data-align="left"] { text-align: left; }
div[data-align="center"] { text-align: center; }