sjdemartini / mui-tiptap

A Material UI (MUI) styled WYSIWYG rich text editor, using Tiptap
MIT License
320 stars 44 forks source link

Anchor link bubble menu to link button when opening via button #63

Closed sjdemartini closed 1 year ago

sjdemartini commented 1 year ago

Resolves https://github.com/sjdemartini/mui-tiptap/issues/53 (see comment here https://github.com/sjdemartini/mui-tiptap/issues/53#issuecomment-1595937019)

Now, the openLinkBubbleMenu editor command takes an optional anchorEl option. If the anchorEl is provided, it's used to override the anchor point for positioning the bubble menu. Each call to openLinkBubbleMenu will reset the anchor based on the provided argument. If not provided, the bubble menu will be anchored to the location in the editor content where the link appears or will appear (as was previously always the case, with out the ability to override).

Now the MenuButtonEditLink uses the anchorEl option to anchor the menu button to the MenuButtonEditLink, so that when clicking to open the menu, it appears right next to where you clicked:

Screenshots

Clicking the button:

Screenshot 2023-06-23 at 9 39 57 AM

Clicking an existing link directly (or using the shortcut key to open the menu):

Screenshot 2023-06-23 at 9 40 15 AM