mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 11:49:02 +08:00
feat: Add onBeforeStart
and onBeforeUpdate
handlers to the render function
This commit is contained in:
parent
9a207969f6
commit
70cb809702
@ -22,7 +22,9 @@ export interface SuggestionOptions {
|
||||
editor: Editor,
|
||||
}) => any[] | Promise<any[]>,
|
||||
render?: () => {
|
||||
onBeforeStart?: (props: SuggestionProps) => void
|
||||
onStart?: (props: SuggestionProps) => void,
|
||||
onBeforeUpdate?: (props: SuggestionProps) => void
|
||||
onUpdate?: (props: SuggestionProps) => void,
|
||||
onExit?: (props: SuggestionProps) => void,
|
||||
onKeyDown?: (props: SuggestionKeyDownProps) => boolean,
|
||||
@ -104,12 +106,7 @@ export function Suggestion({
|
||||
range: state.range,
|
||||
query: state.query,
|
||||
text: state.text,
|
||||
items: (handleChange || handleStart)
|
||||
? await items({
|
||||
editor,
|
||||
query: state.query,
|
||||
})
|
||||
: [],
|
||||
items: [],
|
||||
command: commandProps => {
|
||||
command({
|
||||
editor,
|
||||
@ -132,6 +129,21 @@ export function Suggestion({
|
||||
: null,
|
||||
}
|
||||
|
||||
if (handleStart) {
|
||||
renderer?.onBeforeStart?.(props)
|
||||
}
|
||||
|
||||
if (handleChange) {
|
||||
renderer?.onBeforeUpdate?.(props)
|
||||
}
|
||||
|
||||
if (handleChange || handleStart) {
|
||||
props.items = await items({
|
||||
editor,
|
||||
query: state.query,
|
||||
})
|
||||
}
|
||||
|
||||
if (handleExit) {
|
||||
renderer?.onExit?.(props)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user