From 10248924541d7b9414087a7369dad24b24fe9b11 Mon Sep 17 00:00:00 2001 From: Dominik Biedebach Date: Sat, 10 Sep 2022 16:16:21 +0200 Subject: [PATCH] Revert "Merge branch 'add-empty-editor-class-to-root-div'" This reverts commit 1d0158d5c5685c9878c868653322042ffbb28c8a, reversing changes made to bda6e8d3083074337b2d39fbb5d20d02bb942f63. --- .../extension-placeholder/src/placeholder.ts | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/packages/extension-placeholder/src/placeholder.ts b/packages/extension-placeholder/src/placeholder.ts index df52cf1a..b00b6b86 100644 --- a/packages/extension-placeholder/src/placeholder.ts +++ b/packages/extension-placeholder/src/placeholder.ts @@ -32,8 +32,6 @@ export const Placeholder = Extension.create({ }, addProseMirrorPlugins() { - let cachedEmptyTopNode: ProsemirrorNode - return [ new Plugin({ props: { @@ -46,9 +44,6 @@ export const Placeholder = Extension.create({ return null } - cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill() - 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 @@ -56,7 +51,7 @@ export const Placeholder = Extension.create({ if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) { const classes = [this.options.emptyNodeClass] - if (isEditorEmpty) { + if (this.editor.isEmpty) { classes.push(this.options.emptyEditorClass) } @@ -80,29 +75,8 @@ export const Placeholder = Extension.create({ return DecorationSet.create(doc, decorations) }, - - attributes: ({ doc }) => { - cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill() - const isEditorEmpty = cachedEmptyTopNode.sameMarkup(doc) && cachedEmptyTopNode.content.findDiffStart(doc.content) === null - - if (isEditorEmpty) { - return { - class: this.options.emptyEditorClass, - 'data-placeholder': typeof this.options.placeholder === 'function' - ? this.options.placeholder({ - editor: this.editor, - node: doc, - pos: 0, - hasAnchor: true, - }) - : this.options.placeholder, - } - } - }, }, }), ] }, }) - -export default Placeholder