mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-19 14:53:00 +08:00
fix a bug in bubble menu
This commit is contained in:
parent
df58611810
commit
a90f08fb1c
@ -53,7 +53,8 @@ export class BubbleMenuView {
|
||||
}
|
||||
|
||||
focusHandler = () => {
|
||||
this.update(this.editor.view)
|
||||
// we use `setTimeout` to make sure `selection` is already updated
|
||||
setTimeout(() => this.update(this.editor.view))
|
||||
}
|
||||
|
||||
blurHandler = ({ event }: { event: FocusEvent }) => {
|
||||
@ -76,10 +77,9 @@ export class BubbleMenuView {
|
||||
update(view: EditorView, oldState?: EditorState) {
|
||||
const { state, composing } = view
|
||||
const { doc, selection } = state
|
||||
const docHasChanged = !oldState?.doc.eq(doc)
|
||||
const selectionHasChanged = !oldState?.selection.eq(selection)
|
||||
const isSame = oldState && oldState.doc.eq(doc) && oldState.selection.eq(selection)
|
||||
|
||||
if (composing || (!docHasChanged && !selectionHasChanged)) {
|
||||
if (composing || isSame) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user