Prevent tooltips from opening inside code blocks #1180
-
Is there a way to prevent tool tips (https://milkdown.dev/docs/api/plugin-tooltip) from opening when selection is made inside a code block? I know I could probably create something that looks at click event target and then prevents it somehow, but maybe there is a way to do it with existing code? Can I modify the #_shouldShow function in TooltipProvider without having to create my own duplicate plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
A hacky version based on the tooltip plugin example could be modifying the update function of tooltipPluginView like that. Not sure yet how bulletproof this is tho.. update: (updatedView, prevState) => {
const { from } = updatedView.state.selection;
const { path } = updatedView.state.doc.resolve(from);
if (!path.find((node) => typeof node === 'object' && node.type.name === 'code_block')) {
provider.update(updatedView, prevState);
};
} |
Beta Was this translation helpful? Give feedback.
A hacky version based on the tooltip plugin example could be modifying the update function of tooltipPluginView like that. Not sure yet how bulletproof this is tho..