@@ -13,7 +13,7 @@ import {
13
13
import { Popover , PopoverProps } from '@patternfly/react-core/dist/esm/components/Popover' ;
14
14
import { TooltipPosition } from '@patternfly/react-core/dist/esm/components/Tooltip' ;
15
15
import { getResizeObserver } from '@patternfly/react-core/dist/esm/helpers/resizeObserver' ;
16
- import Editor , { EditorProps , Monaco } from '@monaco-editor/react' ;
16
+ import Editor , { BeforeMount , EditorProps , Monaco } from '@monaco-editor/react' ;
17
17
import type { editor } from 'monaco-editor' ;
18
18
import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon' ;
19
19
import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon' ;
@@ -23,6 +23,7 @@ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
23
23
import Dropzone , { FileRejection } from 'react-dropzone' ;
24
24
import { CodeEditorContext } from './CodeEditorUtils' ;
25
25
import { CodeEditorControl } from './CodeEditorControl' ;
26
+ import { defineThemes } from './CodeEditorTheme' ;
26
27
27
28
export type ChangeHandler = ( value : string , event : editor . IModelContentChangedEvent ) => void ;
28
29
export type EditorDidMount = ( editor : editor . IStandaloneCodeEditor , monaco : Monaco ) => void ;
@@ -366,13 +367,19 @@ export const CodeEditor = ({
366
367
} ;
367
368
} , [ ] ) ;
368
369
370
+ const editorBeforeMount : BeforeMount = ( monaco ) => {
371
+ defineThemes ( monaco . editor ) ;
372
+ editorProps ?. beforeMount ?.( monaco ) ;
373
+ } ;
374
+
369
375
const editorDidMount : EditorDidMount = ( editor , monaco ) => {
370
376
// eslint-disable-next-line no-bitwise
371
377
editor . addCommand ( monaco . KeyMod . Shift | monaco . KeyCode . Tab , ( ) => wrapperRef . current . focus ( ) ) ;
372
378
Array . from ( document . getElementsByClassName ( 'monaco-editor' ) ) . forEach ( ( editorElement ) =>
373
379
editorElement . removeAttribute ( 'role' )
374
380
) ;
375
381
onEditorDidMount ( editor , monaco ) ;
382
+ editorProps ?. onMount ?.( editor , monaco ) ;
376
383
editorRef . current = editor ;
377
384
if ( height === 'sizeToFit' ) {
378
385
setHeightToFitContent ( ) ;
@@ -428,6 +435,7 @@ export const CodeEditor = ({
428
435
} ;
429
436
430
437
const editorOptions : editor . IStandaloneEditorConstructionOptions = {
438
+ fontFamily : 'var(--pf-t--global--font--family--mono)' ,
431
439
scrollBeyondLastLine : height !== 'sizeToFit' ,
432
440
readOnly : isReadOnly ,
433
441
cursorStyle : 'line' ,
@@ -570,8 +578,9 @@ export const CodeEditor = ({
570
578
overrideServices = { overrideServices }
571
579
onChange = { onModelChange }
572
580
onMount = { editorDidMount }
581
+ beforeMount = { editorBeforeMount }
573
582
loading = { loading }
574
- theme = { isDarkTheme ? 'vs- dark' : 'vs -light' }
583
+ theme = { isDarkTheme ? 'pf-v6-theme- dark' : 'pf-v6-theme -light' }
575
584
{ ...editorProps }
576
585
/>
577
586
</ div >
0 commit comments