diff --git a/packages/extension-placeholder/src/placeholder.ts b/packages/extension-placeholder/src/placeholder.ts index 67185408..df52cf1a 100644 --- a/packages/extension-placeholder/src/placeholder.ts +++ b/packages/extension-placeholder/src/placeholder.ts @@ -32,7 +32,8 @@ export const Placeholder = Extension.create({ }, addProseMirrorPlugins() { - let cachedEmptyTopNode: ProsemirrorNode; + let cachedEmptyTopNode: ProsemirrorNode + return [ new Plugin({ props: { @@ -46,12 +47,11 @@ export const Placeholder = Extension.create({ } cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill() - let isEditorEmpty = cachedEmptyTopNode.sameMarkup(doc) && cachedEmptyTopNode.content.findDiffStart(doc.content) === null + const isEditorEmpty = cachedEmptyTopNode.sameMarkup(doc) && cachedEmptyTopNode.content.findDiffStart(doc.content) === null doc.descendants((node, pos) => { const hasAnchor = anchor >= pos && anchor <= (pos + node.nodeSize) const isEmpty = !node.isLeaf && !node.childCount - if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) { const classes = [this.options.emptyNodeClass] @@ -83,7 +83,8 @@ export const Placeholder = Extension.create({ attributes: ({ doc }) => { cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill() - let isEditorEmpty = cachedEmptyTopNode.sameMarkup(doc) && cachedEmptyTopNode.content.findDiffStart(doc.content) === null + const isEditorEmpty = cachedEmptyTopNode.sameMarkup(doc) && cachedEmptyTopNode.content.findDiffStart(doc.content) === null + if (isEditorEmpty) { return { class: this.options.emptyEditorClass, @@ -95,13 +96,13 @@ export const Placeholder = Extension.create({ hasAnchor: true, }) : this.options.placeholder, - } + } } - } + }, }, }), ] }, }) -export default Placeholder \ No newline at end of file +export default Placeholder