@atlaskit/editor-plugin-synced-block
Version:
SyncedBlock plugin for @atlaskit/editor-core
23 lines (22 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmptySourceSyncBlock = void 0;
/**
* A source synced block counts as "empty" when it holds exactly one paragraph and that paragraph
* has no content. This is the only state in which the source placeholder should be shown.
*
* Emptiness is deliberately derived from the ProseMirror node rather than the rendered DOM.
* ProseMirror and other plugins inject non-content children into the paragraph element — the
* selection marker's cursor widget (`.ProseMirror-widget`), ProseMirror's `.ProseMirror-separator`
* hack node, and the `.ProseMirror-trailingBreak` — so DOM shape is not a reliable signal of
* whether the user has typed anything. See EDITOR-8327.
*/
var isEmptySourceSyncBlock = exports.isEmptySourceSyncBlock = function isEmptySourceSyncBlock(node) {
if (node.childCount !== 1) {
return false;
}
var firstChild = node.firstChild;
return (firstChild === null || firstChild === void 0 ? void 0 : firstChild.type.name) === 'paragraph' && firstChild.content.size === 0;
};