Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to congifgure Bubble Menu in React so that it doesn't pop up over an image? #1487

Closed
planktonrobo opened this issue Jun 17, 2021 · 3 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@planktonrobo
Copy link

The Bubble Menu pops up when an image is selected and has options for styling text. I'm not sure it's considered a bug, but it does look a little silly since you can't take those actions on an image (bold, italicize, strike, etc). I'm using it through the StarterKit module. Is there a way to hide it when an image is selected? Thanks

@planktonrobo planktonrobo added Type: Bug The issue or pullrequest is related to a bug v2 labels Jun 17, 2021
@philippkuehn
Copy link
Contributor

There are usecase for it: #1313
But there is a plan to make this configurable: #1480

@thatsjonsense
Copy link
Contributor

You can hide the content of the menu, which will make it invisible. We use this to check:

  const selection = editor.state.selection
  const isTextSelection = selection instanceof TextSelection

@planktonrobo
Copy link
Author

planktonrobo commented Jun 18, 2021

You can hide the content of the menu, which will make it invisible. We use this to check:

  const selection = editor.state.selection
  const isTextSelection = selection instanceof TextSelection

There is no TextSelection in tiptap/react. There is an isTextSelection function you can import. So here's what I figured out with your help:

`{editor && (

      <BubbleMenu editor={editor}>
        {isTextSelection(editor.state.selection) && <> <button
          onClick={() => editor.chain().focus().toggleBold().run()}
          className={editor.isActive("bold") ? "is-active" : ""}
        >
          bold
        </button>
        <button
          onClick={() => editor.chain().focus().toggleItalic().run()}
          className={editor.isActive("italic") ? "is-active" : ""}
        >
          italic
        </button>
        <button
          onClick={() => editor.chain().focus().toggleStrike().run()}
          className={editor.isActive("strike") ? "is-active" : ""}
        >
          strike
        </button> </> }
       
      </BubbleMenu>`)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

3 participants