@atlaskit/editor-plugin-synced-block
Version:
SyncedBlock plugin for @atlaskit/editor-core
17 lines • 921 B
JavaScript
/**
* 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.
*/
export const isEmptySourceSyncBlock = node => {
if (node.childCount !== 1) {
return false;
}
const firstChild = node.firstChild;
return (firstChild === null || firstChild === void 0 ? void 0 : firstChild.type.name) === 'paragraph' && firstChild.content.size === 0;
};