@@ -15,6 +15,7 @@ import {
15
15
highlightActiveLine ,
16
16
lineNumbers ,
17
17
highlightActiveLineGutter ,
18
+ tooltips ,
18
19
EditorView ,
19
20
} from '@codemirror/view' ;
20
21
import {
@@ -184,6 +185,11 @@ export const editorPalette = {
184
185
} ,
185
186
} as const ;
186
187
188
+ const cmFontStyles = {
189
+ fontSize : '13px' ,
190
+ fontFamily : fontFamilies . code ,
191
+ } ;
192
+
187
193
function getStylesForTheme ( theme : CodemirrorThemeType ) {
188
194
return EditorView . theme (
189
195
{
@@ -192,10 +198,7 @@ function getStylesForTheme(theme: CodemirrorThemeType) {
192
198
backgroundColor : editorPalette [ theme ] . backgroundColor ,
193
199
maxHeight : '100%' ,
194
200
} ,
195
- '& .cm-scroller' : {
196
- fontSize : '13px' ,
197
- fontFamily : fontFamilies . code ,
198
- } ,
201
+ '& .cm-scroller' : cmFontStyles ,
199
202
'&.cm-editor.cm-focused' : {
200
203
outline : 'none' ,
201
204
} ,
@@ -289,6 +292,7 @@ function getStylesForTheme(theme: CodemirrorThemeType) {
289
292
marginLeft : '-1px' ,
290
293
} ,
291
294
'& .cm-tooltip' : {
295
+ ...cmFontStyles ,
292
296
color : editorPalette [ theme ] . autocompleteColor ,
293
297
backgroundColor : editorPalette [ theme ] . autocompleteBackgroundColor ,
294
298
border : `1px solid ${ editorPalette [ theme ] . autocompleteBorderColor } ` ,
@@ -886,6 +890,12 @@ const BaseEditor = React.forwardRef<EditorRef, EditorProps>(function BaseEditor(
886
890
...completionKeymap ,
887
891
...tabKeymap ,
888
892
] ) ,
893
+ // Supply the document body as the tooltip parent
894
+ // because we are using containment contexts for container
895
+ // queries which offset things otherwise.
896
+ tooltips ( {
897
+ parent : document . body ,
898
+ } ) ,
889
899
readOnlyExtension ,
890
900
EditorView . updateListener . of ( ( update ) => {
891
901
updateEditorContentHeight ( ) ;
0 commit comments