UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

31 lines (28 loc) 753 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isEmptyDocument = isEmptyDocument; exports.isEmptyParagraph = isEmptyParagraph; /** * Temporary file which extracts function from `editor-common`. * * Eventually we will deprecate and delete EditorActions. This is here to * help decouple it from editor-common */ /** * Checks if node is an empty paragraph. */ function isEmptyParagraph(node) { return !!node && node.type.name === 'paragraph' && !node.childCount; } /** * Checks if a node looks like an empty document */ function isEmptyDocument(node) { var nodeChild = node.content.firstChild; if (node.childCount !== 1 || !nodeChild) { return false; } return isEmptyParagraph(nodeChild); }