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
}
if (!tr.selection.empty) {
tr.deleteRange(range.from, range.to)
if (range.from !== range.to) {
tr.delete(range.from, range.to)
}
tr.insert(range.from, content)

View File

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