UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

31 lines 913 B
/** * Checks if node is an empty paragraph. */ export function isEmptyParagraph(node) { return !node || (node.type.name === 'paragraph' && !node.textContent && !node.childCount); } /** * Checks if a node has any significant content. */ export function isEmpty(node) { if (node && node.textContent) { return false; } if (!node || !node.childCount || (node.childCount === 1 && isEmptyParagraph(node.firstChild))) { return true; } var block = []; var nonBlock = []; node.forEach(function (child) { child.isInline ? nonBlock.push(child) : block.push(child); }); return !nonBlock.length && !block.filter(function (childNode) { return !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)); }).length; } //# sourceMappingURL=document.js.map