fix: prevent multiple space characters after mention node, fix #1703
This commit is contained in:
@@ -26,6 +26,17 @@ export const Mention = Node.create<MentionOptions>({
|
||||
char: '@',
|
||||
pluginKey: MentionPluginKey,
|
||||
command: ({ editor, range, props }) => {
|
||||
// increase range.to by one when the next node is of type "text"
|
||||
// and starts with a space character
|
||||
const nodeAfter = editor.view.state.selection.$to.nodeAfter
|
||||
const overrideSpace = nodeAfter?.text
|
||||
? /^\s/.test(nodeAfter.text)
|
||||
: false
|
||||
|
||||
if (overrideSpace) {
|
||||
range.to += 1
|
||||
}
|
||||
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
|
||||
Reference in New Issue
Block a user