mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
fix: call onExit hook when editor is destroyed, fix #1645
This commit is contained in:
parent
80c2f85838
commit
5d2ef71d33
@ -67,6 +67,7 @@ export function Suggestion({
|
||||
allow = () => true,
|
||||
}: SuggestionOptions) {
|
||||
|
||||
let props: SuggestionProps | undefined
|
||||
const renderer = render?.()
|
||||
|
||||
return new Plugin({
|
||||
@ -96,7 +97,8 @@ export function Suggestion({
|
||||
? prev
|
||||
: next
|
||||
const decorationNode = document.querySelector(`[data-decoration-id="${state.decorationId}"]`)
|
||||
const props: SuggestionProps = {
|
||||
|
||||
props = {
|
||||
editor,
|
||||
range: state.range,
|
||||
query: state.query,
|
||||
@ -141,6 +143,14 @@ export function Suggestion({
|
||||
renderer?.onStart?.(props)
|
||||
}
|
||||
},
|
||||
|
||||
destroy: () => {
|
||||
if (!props) {
|
||||
return
|
||||
}
|
||||
|
||||
renderer?.onExit?.(props)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user