Use parent window for cross-frame instantiation (#5534)

* Add cross-iframe JS support to mention extension

* added changeset

---------

Co-authored-by: Taylor Ermolov <taylor@nermolov.com>
This commit is contained in:
bdbch 2024-08-21 14:51:32 +02:00 committed by GitHub
parent 07fa49d026
commit da8fcf373e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-mention": patch
---
Add support for cross-window institation with mentions

View File

@ -119,7 +119,8 @@ export const Mention = Node.create<MentionOptions>({
])
.run()
window.getSelection()?.collapseToEnd()
// get reference to `window` object from editor element, to support cross-frame JS usage
editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()
},
allow: ({ state, range }) => {
const $from = state.doc.resolve(range.from)