diff --git a/app/assets/javascripts/02-editor.js b/app/assets/javascripts/02-editor.js index 5e5b1a0..a6e7254 100644 --- a/app/assets/javascripts/02-editor.js +++ b/app/assets/javascripts/02-editor.js @@ -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) diff --git a/app/assets/stylesheets/editor.scss b/app/assets/stylesheets/editor.scss index cc96492..f2f2eaa 100644 --- a/app/assets/stylesheets/editor.scss +++ b/app/assets/stylesheets/editor.scss @@ -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; }