mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00
fix: add verification before invoking collapseToEnd function to avoid error (when selection don't exist)
This commit is contained in:
parent
01547d5b2f
commit
422c182290
@ -122,7 +122,11 @@ export const Mention = Node.create<MentionOptions>({
|
||||
.run()
|
||||
|
||||
// get reference to `window` object from editor element, to support cross-frame JS usage
|
||||
editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()
|
||||
const selection = editor.view.dom.ownerDocument.defaultView?.getSelection()
|
||||
|
||||
if (selection && selection.rangeCount > 0) {
|
||||
selection.collapseToEnd()
|
||||
}
|
||||
},
|
||||
allow: ({ state, range }) => {
|
||||
const $from = state.doc.resolve(range.from)
|
||||
|
Loading…
Reference in New Issue
Block a user