Skip to content

Commit

Permalink
Revert "Merge branch 'add-empty-editor-class-to-root-div'"
Browse files Browse the repository at this point in the history
This reverts commit 1d0158d, reversing
changes made to bda6e8d.
  • Loading branch information
bdbch committed Sep 10, 2022
1 parent 1d0158d commit 1024892
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions packages/extension-placeholder/src/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
},

addProseMirrorPlugins() {
let cachedEmptyTopNode: ProsemirrorNode

return [
new Plugin({
props: {
Expand All @@ -46,17 +44,14 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
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

if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
const classes = [this.options.emptyNodeClass]

if (isEditorEmpty) {
if (this.editor.isEmpty) {
classes.push(this.options.emptyEditorClass)
}

Expand All @@ -80,29 +75,8 @@ export const Placeholder = Extension.create<PlaceholderOptions>({

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

0 comments on commit 1024892

Please sign in to comment.