style(extension/placeholder): fix linting issues
This commit is contained in:
@@ -32,7 +32,8 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addProseMirrorPlugins() {
|
addProseMirrorPlugins() {
|
||||||
let cachedEmptyTopNode: ProsemirrorNode;
|
let cachedEmptyTopNode: ProsemirrorNode
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new Plugin({
|
new Plugin({
|
||||||
props: {
|
props: {
|
||||||
@@ -46,12 +47,11 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill()
|
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) => {
|
doc.descendants((node, pos) => {
|
||||||
const hasAnchor = anchor >= pos && anchor <= (pos + node.nodeSize)
|
const hasAnchor = anchor >= pos && anchor <= (pos + node.nodeSize)
|
||||||
const isEmpty = !node.isLeaf && !node.childCount
|
const isEmpty = !node.isLeaf && !node.childCount
|
||||||
|
|
||||||
|
|
||||||
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
|
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
|
||||||
const classes = [this.options.emptyNodeClass]
|
const classes = [this.options.emptyNodeClass]
|
||||||
@@ -83,7 +83,8 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
|||||||
|
|
||||||
attributes: ({ doc }) => {
|
attributes: ({ doc }) => {
|
||||||
cachedEmptyTopNode = cachedEmptyTopNode || doc.type.createAndFill()
|
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) {
|
if (isEditorEmpty) {
|
||||||
return {
|
return {
|
||||||
class: this.options.emptyEditorClass,
|
class: this.options.emptyEditorClass,
|
||||||
@@ -95,13 +96,13 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
|||||||
hasAnchor: true,
|
hasAnchor: true,
|
||||||
})
|
})
|
||||||
: this.options.placeholder,
|
: this.options.placeholder,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Placeholder
|
export default Placeholder
|
||||||
|
|||||||
Reference in New Issue
Block a user