diff --git a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts index 6b86f925..7be1f810 100644 --- a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts +++ b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts @@ -40,7 +40,12 @@ export class BubbleMenuView { public tippyOptions?: Partial - public shouldShow: Exclude = ({ state, from, to }) => { + public shouldShow: Exclude = ({ + view, + state, + from, + to, + }) => { const { doc, selection } = state const { empty } = selection @@ -50,7 +55,11 @@ export class BubbleMenuView { const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection) - if (empty || isEmptyTextBlock) { + if ( + !view.hasFocus() + || empty + || isEmptyTextBlock + ) { return false } diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index fce0ff52..d1503f9b 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -33,7 +33,7 @@ export class FloatingMenuView { public tippyOptions?: Partial - public shouldShow: Exclude = ({ state, view }) => { + public shouldShow: Exclude = ({ view, state }) => { const { selection } = state const { $anchor, empty } = selection const isRootDepth = $anchor.depth === 1 @@ -41,11 +41,12 @@ export class FloatingMenuView { && !$anchor.parent.type.spec.code && !$anchor.parent.textContent - if (!view.hasFocus()) { - return false - } - - if (!empty || !isRootDepth || !isEmptyTextBlock) { + if ( + !view.hasFocus() + || !empty + || !isRootDepth + || !isEmptyTextBlock + ) { return false }