add editor to placeholder props
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
"@tiptap/core": "^2.0.0-beta.1"
|
"@tiptap/core": "^2.0.0-beta.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"prosemirror-model": "^1.13.3",
|
||||||
"prosemirror-state": "^1.3.4",
|
"prosemirror-state": "^1.3.4",
|
||||||
"prosemirror-view": "^1.18.1"
|
"prosemirror-view": "^1.18.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { Extension, isNodeEmpty } from '@tiptap/core'
|
import { Editor, Extension, isNodeEmpty } from '@tiptap/core'
|
||||||
|
import { Node as ProsemirrorNode } from 'prosemirror-model'
|
||||||
import { Decoration, DecorationSet } from 'prosemirror-view'
|
import { Decoration, DecorationSet } from 'prosemirror-view'
|
||||||
import { Plugin } from 'prosemirror-state'
|
import { Plugin } from 'prosemirror-state'
|
||||||
|
|
||||||
export interface PlaceholderOptions {
|
export interface PlaceholderOptions {
|
||||||
emptyEditorClass: string,
|
emptyEditorClass: string,
|
||||||
emptyNodeClass: string,
|
emptyNodeClass: string,
|
||||||
placeholder: string | Function,
|
placeholder: ((PlaceholderProps: {
|
||||||
|
editor: Editor,
|
||||||
|
node: ProsemirrorNode,
|
||||||
|
}) => string) | string,
|
||||||
showOnlyWhenEditable: boolean,
|
showOnlyWhenEditable: boolean,
|
||||||
showOnlyCurrent: boolean,
|
showOnlyCurrent: boolean,
|
||||||
}
|
}
|
||||||
@@ -48,7 +52,10 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
|||||||
const decoration = Decoration.node(pos, pos + node.nodeSize, {
|
const decoration = Decoration.node(pos, pos + node.nodeSize, {
|
||||||
class: classes.join(' '),
|
class: classes.join(' '),
|
||||||
'data-placeholder': typeof this.options.placeholder === 'function'
|
'data-placeholder': typeof this.options.placeholder === 'function'
|
||||||
? this.options.placeholder(node)
|
? this.options.placeholder({
|
||||||
|
editor: this.editor,
|
||||||
|
node,
|
||||||
|
})
|
||||||
: this.options.placeholder,
|
: this.options.placeholder,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user