editor: mantener text nodes solo cuando tienen texto

This commit is contained in:
void 2021-03-26 15:57:07 +00:00
parent 117fa84cc4
commit 2d8507369b

View file

@ -62,7 +62,7 @@ export function getValidChildren (node: Element, type: EditorNode): Node[] {
return [...node.childNodes].filter(n => {
// si permite texto y esto es un texto, es válido
if (n.nodeType === Node.TEXT_NODE)
return type.allowedChildren.includes('text')
return type.allowedChildren.includes('text') && n.textContent?.length
// si no es un elemento, no es válido
if (!(n instanceof Element))