You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem I am facing
In both the FloatingMenu and BubbleMenu, I wish I could customize the logic for when the menu displays.
Two specific use cases:
In BubbleMenu, I want to trigger even when the selection is empty if you click inside a link
In FloatingMenu, I want to trigger at depth 2 instead of depth 1 because my schema is a document with multiple sections
The solution I would like
An optional shouldShow function I can pass in the options to these menus where I can write my own logic. This would be consumed in the update method of each plugin. If you don't provide your own, it would use the default. Ideally, you could also access the default method from your custom one to do an OR.
Alternatives I have considered
Right now I've forked both menus just to change 1 line of logic in each one, which means it's hard to stay up to date with future improvements.
bubble-menu-plugin:
if (empty || isEmptyTextBlock) {
// OUR CUSTOM LOGIC STARTS HERE
const isLink = selection.$anchor
.marks()
.some((mark) => mark.type.name === 'link')
if (!isLink) {
this.hide()
return
}
// END OUR CUSTOM LOGIC
}
floating-menu-plugin:
const isRootDepth = $anchor.depth === 2 // Was 1
The text was updated successfully, but these errors were encountered:
…1043, fix #1268, fix#1503)
* add key option to bubble menu
* ignore react for now
* add shouldShow option to bubble menu extension
* improve types
* remove BubbleMenuPluginKey
* add key and shouldShow option to floating menu extension
* fix: don’t show floating menu within code block
* docs: add new menu options
andrewlu0
pushed a commit
to trybaseplate/tiptap
that referenced
this issue
Oct 20, 2023
, fixueberdosis#1043, fix ueberdosis#1268, fixueberdosis#1503)
* add key option to bubble menu
* ignore react for now
* add shouldShow option to bubble menu extension
* improve types
* remove BubbleMenuPluginKey
* add key and shouldShow option to floating menu extension
* fix: don’t show floating menu within code block
* docs: add new menu options
The problem I am facing
In both the FloatingMenu and BubbleMenu, I wish I could customize the logic for when the menu displays.
Two specific use cases:
The solution I would like
An optional
shouldShow
function I can pass in the options to these menus where I can write my own logic. This would be consumed in theupdate
method of each plugin. If you don't provide your own, it would use the default. Ideally, you could also access the default method from your custom one to do an OR.Alternatives I have considered
Right now I've forked both menus just to change 1 line of logic in each one, which means it's hard to stay up to date with future improvements.
bubble-menu-plugin:
floating-menu-plugin:
The text was updated successfully, but these errors were encountered: