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

fix: Allow tippyOptions.getReferenceClientRect in bubble menu to be overridden #2668

Merged
merged 3 commits into from
Apr 10, 2022

Conversation

fleon
Copy link
Contributor

@fleon fleon commented Mar 31, 2022

Problem: The bubble menu's position currently depends on prosemirror selection, which works well for inline elements. But for block level elements, like code blocks, if we want to show a bubble menu to do things like change the language of the code block or to delete the code block, it would be ideal to have the bubble menu stick to the top left of the code block, for example.

Solution: Allowing overriding getReferenceClientRect along with other tippyOptions solves this problem and allows customizing the position of tippy outside of the plugin.

Prefer using getReferenceClientRect in tippyOptions if available.
This allows modifying the position of the bubble menu in a different
location for block level elements, like above a table cell or a code block.
@netlify
Copy link

netlify bot commented Mar 31, 2022

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 70dc4fc
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/62460ca8a7a1d50008bbf25c
😎 Deploy Preview https://deploy-preview-2668--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@fleon fleon changed the title feat: Allow getReferenceClientRect to be overridden feat: Allow getReferenceClientRect in bubble menu to be overridden Mar 31, 2022
@fleon fleon changed the title feat: Allow getReferenceClientRect in bubble menu to be overridden fix: Allow getReferenceClientRect in bubble menu to be overridden Mar 31, 2022
@bdbch
Copy link
Contributor

bdbch commented Apr 9, 2022

Nice idea @fleon. Can you please add your change to the documentation as well so users understand how to use this option?

https://github.com/ueberdosis/tiptap/blob/main/docs/api/extensions/bubble-menu.md

@bdbch bdbch self-assigned this Apr 9, 2022
@fleon
Copy link
Contributor Author

fleon commented Apr 9, 2022

@bdbch I don't think this needs to be added to the documentation. The docs already have tippyOptions described, where this option could've gone, but due to the current implementation, passing getReferenceClientRect in there would not have worked. After this PR is merged, it will work. So its more of a bug fix.

@fleon fleon changed the title fix: Allow getReferenceClientRect in bubble menu to be overridden fix: Allow tippyOptions.getReferenceClientRect in bubble menu to be overridden Apr 9, 2022
@bdbch
Copy link
Contributor

bdbch commented Apr 10, 2022

Thats true! Thanks for correcting me there.

@bdbch
Copy link
Contributor

bdbch commented Apr 10, 2022

I'll merge this PR even though the build/test task failed - it seems to be an unrelated timeout issue on the Savvy demo.

@bdbch bdbch merged commit a8f094a into ueberdosis:main Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants