@@ -13,7 +13,7 @@ import {
1313import { Popover , PopoverProps } from '@patternfly/react-core/dist/esm/components/Popover' ;
1414import { TooltipPosition } from '@patternfly/react-core/dist/esm/components/Tooltip' ;
1515import { 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' ;
1717import type { editor } from 'monaco-editor' ;
1818import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon' ;
1919import 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';
2323import Dropzone , { FileRejection } from 'react-dropzone' ;
2424import { CodeEditorContext } from './CodeEditorUtils' ;
2525import { CodeEditorControl } from './CodeEditorControl' ;
26+ import { defineThemes } from './CodeEditorTheme' ;
2627
2728export type ChangeHandler = ( value : string , event : editor . IModelContentChangedEvent ) => void ;
2829export type EditorDidMount = ( editor : editor . IStandaloneCodeEditor , monaco : Monaco ) => void ;
@@ -366,13 +367,19 @@ export const CodeEditor = ({
366367 } ;
367368 } , [ ] ) ;
368369
370+ const editorBeforeMount : BeforeMount = ( monaco ) => {
371+ defineThemes ( monaco . editor ) ;
372+ editorProps ?. beforeMount ?.( monaco ) ;
373+ } ;
374+
369375 const editorDidMount : EditorDidMount = ( editor , monaco ) => {
370376 // eslint-disable-next-line no-bitwise
371377 editor . addCommand ( monaco . KeyMod . Shift | monaco . KeyCode . Tab , ( ) => wrapperRef . current . focus ( ) ) ;
372378 Array . from ( document . getElementsByClassName ( 'monaco-editor' ) ) . forEach ( ( editorElement ) =>
373379 editorElement . removeAttribute ( 'role' )
374380 ) ;
375381 onEditorDidMount ( editor , monaco ) ;
382+ editorProps ?. onMount ?.( editor , monaco ) ;
376383 editorRef . current = editor ;
377384 if ( height === 'sizeToFit' ) {
378385 setHeightToFitContent ( ) ;
@@ -428,6 +435,7 @@ export const CodeEditor = ({
428435 } ;
429436
430437 const editorOptions : editor . IStandaloneEditorConstructionOptions = {
438+ fontFamily : 'var(--pf-t--global--font--family--mono)' ,
431439 scrollBeyondLastLine : height !== 'sizeToFit' ,
432440 readOnly : isReadOnly ,
433441 cursorStyle : 'line' ,
@@ -570,8 +578,9 @@ export const CodeEditor = ({
570578 overrideServices = { overrideServices }
571579 onChange = { onModelChange }
572580 onMount = { editorDidMount }
581+ beforeMount = { editorBeforeMount }
573582 loading = { loading }
574- theme = { isDarkTheme ? 'vs- dark' : 'vs -light' }
583+ theme = { isDarkTheme ? 'pf-v6-theme- dark' : 'pf-v6-theme -light' }
575584 { ...editorProps }
576585 />
577586 </ div >
0 commit comments