add appendText option for suggestions
This commit is contained in:
@@ -55,6 +55,7 @@ export default class MentionNode extends Node {
|
|||||||
return [
|
return [
|
||||||
SuggestionsPlugin({
|
SuggestionsPlugin({
|
||||||
command: ({ range, attrs, schema }) => replaceText(range, schema.nodes.mention, attrs),
|
command: ({ range, attrs, schema }) => replaceText(range, schema.nodes.mention, attrs),
|
||||||
|
appendText: ' ',
|
||||||
matcher: this.options.matcher,
|
matcher: this.options.matcher,
|
||||||
items: this.options.items,
|
items: this.options.items,
|
||||||
onEnter: this.options.onEnter,
|
onEnter: this.options.onEnter,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Plugin, PluginKey } from 'prosemirror-state'
|
import { Plugin, PluginKey } from 'prosemirror-state'
|
||||||
import { Decoration, DecorationSet } from 'prosemirror-view'
|
import { Decoration, DecorationSet } from 'prosemirror-view'
|
||||||
|
import { insertText } from 'tiptap-commands'
|
||||||
|
|
||||||
// Create a matcher that matches when a specific character is typed. Useful for @mentions and #tags.
|
// Create a matcher that matches when a specific character is typed. Useful for @mentions and #tags.
|
||||||
function triggerCharacter({
|
function triggerCharacter({
|
||||||
@@ -61,6 +62,7 @@ export default function SuggestionsPlugin({
|
|||||||
allowSpaces: false,
|
allowSpaces: false,
|
||||||
startOfLine: false,
|
startOfLine: false,
|
||||||
},
|
},
|
||||||
|
appendText = null,
|
||||||
suggestionClass = 'suggestion',
|
suggestionClass = 'suggestion',
|
||||||
command = () => false,
|
command = () => false,
|
||||||
items = [],
|
items = [],
|
||||||
@@ -127,6 +129,10 @@ export default function SuggestionsPlugin({
|
|||||||
attrs,
|
attrs,
|
||||||
schema: view.state.schema,
|
schema: view.state.schema,
|
||||||
})(view.state, view.dispatch, view)
|
})(view.state, view.dispatch, view)
|
||||||
|
|
||||||
|
if (appendText) {
|
||||||
|
insertText(appendText)(view.state, view.dispatch, view)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user