Skip to content

Commit

Permalink
Merge pull request #347 from EnriqueSantos-dev/fix/hide-bubble-menu-i…
Browse files Browse the repository at this point in the history
…f-not-editable

fix: not show bubble menu if editor cannot be editable
  • Loading branch information
andrewdoro authored Mar 15, 2024
2 parents 1441bef + 2aeee1b commit 9008395
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/headless/src/components/editor-bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ export const EditorBubble = forwardRef<HTMLDivElement, EditorBubbleProps>(
const { empty } = selection;

// don't show bubble menu if:
// - the editor is not editable
// - the selected node is an image
// - the selection is empty
// - the selection is a node selection (for drag handles)
if (editor.isActive("image") || empty || isNodeSelection(selection)) {
if (
!editor.isEditable ||
editor.isActive("image") ||
empty ||
isNodeSelection(selection)
) {
return false;
}
return true;
Expand Down Expand Up @@ -58,7 +64,7 @@ export const EditorBubble = forwardRef<HTMLDivElement, EditorBubbleProps>(
</BubbleMenu>
</div>
);
}
},
);

EditorBubble.displayName = "EditorBubble";
Expand Down

0 comments on commit 9008395

Please sign in to comment.