add editor to suggestion command props
This commit is contained in:
@@ -15,6 +15,14 @@ export const Mention = Node.create({
|
|||||||
HTMLAttributes: {},
|
HTMLAttributes: {},
|
||||||
suggestionOptions: {
|
suggestionOptions: {
|
||||||
char: '@',
|
char: '@',
|
||||||
|
command: ({ editor, range, attributes }) => {
|
||||||
|
editor
|
||||||
|
.chain()
|
||||||
|
.focus()
|
||||||
|
.replace(range, 'mention', attributes)
|
||||||
|
.insertText(' ')
|
||||||
|
.run()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -69,14 +77,6 @@ export const Mention = Node.create({
|
|||||||
Suggestion({
|
Suggestion({
|
||||||
editor: this.editor,
|
editor: this.editor,
|
||||||
...this.options.suggestionOptions,
|
...this.options.suggestionOptions,
|
||||||
command: ({ range, attributes }) => {
|
|
||||||
this.editor
|
|
||||||
.chain()
|
|
||||||
.focus()
|
|
||||||
.replace(range, 'mention', attributes)
|
|
||||||
.insertText(' ')
|
|
||||||
.run()
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ export interface SuggestionOptions {
|
|||||||
allowSpaces?: boolean,
|
allowSpaces?: boolean,
|
||||||
startOfLine?: boolean,
|
startOfLine?: boolean,
|
||||||
suggestionClass?: string,
|
suggestionClass?: string,
|
||||||
command?: (props: { range: Range, attributes: AnyObject }) => void,
|
command?: (props: {
|
||||||
|
editor: Editor,
|
||||||
|
range: Range,
|
||||||
|
attributes: AnyObject
|
||||||
|
}) => void,
|
||||||
items?: (query: string) => any[],
|
items?: (query: string) => any[],
|
||||||
render?: () => {
|
render?: () => {
|
||||||
onStart?: (props: SuggestionProps) => void,
|
onStart?: (props: SuggestionProps) => void,
|
||||||
@@ -83,7 +87,11 @@ export function Suggestion({
|
|||||||
? await items(state.query)
|
? await items(state.query)
|
||||||
: [],
|
: [],
|
||||||
command: attributes => {
|
command: attributes => {
|
||||||
command({ range: state.range, attributes })
|
command({
|
||||||
|
editor,
|
||||||
|
range: state.range,
|
||||||
|
attributes,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
decorationNode,
|
decorationNode,
|
||||||
// virtual node for popper.js or tippy.js
|
// virtual node for popper.js or tippy.js
|
||||||
|
|||||||
Reference in New Issue
Block a user