remove replaceRange from mention node

This commit is contained in:
Philipp Kühn
2021-05-05 13:49:32 +02:00
parent ec838a11f2
commit 63902d4bdb
2 changed files with 7 additions and 4 deletions

View File

@@ -26,8 +26,8 @@ export const insertContentAt: RawCommands['insertContentAt'] = (range, value) =>
return true return true
} }
if (!tr.selection.empty) { if (range.from !== range.to) {
tr.deleteRange(range.from, range.to) tr.delete(range.from, range.to)
} }
tr.insert(range.from, content) tr.insert(range.from, content)

View File

@@ -17,12 +17,15 @@ export const Mention = Node.create<MentionOptions>({
editor editor
.chain() .chain()
.focus() .focus()
.replaceRange(range, 'mention', props) .insertContentAt(range, {
type: 'mention',
attrs: props,
})
.insertContent(' ') .insertContent(' ')
.run() .run()
}, },
allow: ({ editor, range }) => { allow: ({ editor, range }) => {
return editor.can().replaceRange(range, 'mention') return editor.can().insertContentAt(range, { type: 'mention' })
}, },
}, },
}, },