@@ -15,6 +15,7 @@ import {
1515 highlightActiveLine ,
1616 lineNumbers ,
1717 highlightActiveLineGutter ,
18+ tooltips ,
1819 EditorView ,
1920} from '@codemirror/view' ;
2021import {
@@ -184,6 +185,11 @@ export const editorPalette = {
184185 } ,
185186} as const ;
186187
188+ const cmFontStyles = {
189+ fontSize : '13px' ,
190+ fontFamily : fontFamilies . code ,
191+ } ;
192+
187193function getStylesForTheme ( theme : CodemirrorThemeType ) {
188194 return EditorView . theme (
189195 {
@@ -192,10 +198,7 @@ function getStylesForTheme(theme: CodemirrorThemeType) {
192198 backgroundColor : editorPalette [ theme ] . backgroundColor ,
193199 maxHeight : '100%' ,
194200 } ,
195- '& .cm-scroller' : {
196- fontSize : '13px' ,
197- fontFamily : fontFamilies . code ,
198- } ,
201+ '& .cm-scroller' : cmFontStyles ,
199202 '&.cm-editor.cm-focused' : {
200203 outline : 'none' ,
201204 } ,
@@ -289,6 +292,7 @@ function getStylesForTheme(theme: CodemirrorThemeType) {
289292 marginLeft : '-1px' ,
290293 } ,
291294 '& .cm-tooltip' : {
295+ ...cmFontStyles ,
292296 color : editorPalette [ theme ] . autocompleteColor ,
293297 backgroundColor : editorPalette [ theme ] . autocompleteBackgroundColor ,
294298 border : `1px solid ${ editorPalette [ theme ] . autocompleteBorderColor } ` ,
@@ -886,6 +890,12 @@ const BaseEditor = React.forwardRef<EditorRef, EditorProps>(function BaseEditor(
886890 ...completionKeymap ,
887891 ...tabKeymap ,
888892 ] ) ,
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+ } ) ,
889899 readOnlyExtension ,
890900 EditorView . updateListener . of ( ( update ) => {
891901 updateEditorContentHeight ( ) ;
0 commit comments