File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/extensions/behavior/SelectionContext Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 6
6
type PluginSpec ,
7
7
TextSelection ,
8
8
} from 'prosemirror-state' ;
9
+ import { hasParentNode } from 'prosemirror-utils' ;
9
10
import type { EditorProps , EditorView } from 'prosemirror-view' ;
10
11
11
12
import type { ActionStorage , ExtensionAuto } from '../../../core' ;
@@ -137,8 +138,13 @@ class SelectionTooltip implements PluginSpec<unknown> {
137
138
return ;
138
139
}
139
140
140
- // Hide the tooltip when one side of selection inside codeblock
141
- if ( isCodeBlock ( selection . $from . parent ) || isCodeBlock ( selection . $to . parent ) ) {
141
+ if (
142
+ // Hide tooltip when one side of selection is inside a codeblock
143
+ isCodeBlock ( selection . $from . parent ) ||
144
+ isCodeBlock ( selection . $to . parent ) ||
145
+ // or when selection is inside node where context menu is disabled
146
+ hasParentNode ( ( node ) => node . type . spec . selectionContext === false ) ( selection )
147
+ ) {
142
148
this . tooltip . hide ( view ) ;
143
149
return ;
144
150
}
@@ -166,3 +172,10 @@ class SelectionTooltip implements PluginSpec<unknown> {
166
172
}
167
173
}
168
174
}
175
+
176
+ declare module 'prosemirror-model' {
177
+ interface NodeSpec {
178
+ /** Set false to disable the selection-context menu within this node */
179
+ selectionContext ?: boolean | undefined ;
180
+ }
181
+ }
You can’t perform that action at this time.
0 commit comments