@@ -19,9 +19,6 @@ export type YamlEditorProps = Omit<ComponentProps<typeof Editor>, 'language'> &
1919 schema ?: JSONSchema4 ;
2020} ;
2121
22- // Track if monaco-yaml has been configured globally
23- let monacoYamlConfigured = false ;
24-
2522export const YamlEditor = ( props : YamlEditorProps ) => {
2623 const { isDarkTheme } = useTheme ( ) ;
2724 const { t } = useTranslation ( ) ;
@@ -47,26 +44,24 @@ export const YamlEditor = (props: YamlEditorProps) => {
4744 const wrapperRef = useRef < HTMLDivElement | null > ( null ) ;
4845
4946 useEffect ( ( ) => {
50- // Configure YAML validation with schema only once
5147 if ( window . Cypress ) return ;
52- if ( ! monacoYamlConfigured ) {
53- monacoYamlConfigured = true ;
54- configureMonacoYaml ( monaco , {
55- isKubernetes : true ,
56- enableSchemaRequest : true ,
57- hover : true ,
58- completion : true ,
59- validate : true ,
60- format : true ,
61- schemas : [
62- {
63- schema : schema as JSONSchema ,
64- fileMatch : [ '*' ] ,
65- uri : 'http://kubernetesjsonschema.dev/master-standalone/all.json' ,
66- } ,
67- ] ,
68- } ) ;
69- }
48+
49+ const { dispose } = configureMonacoYaml ( monaco , {
50+ isKubernetes : true ,
51+ enableSchemaRequest : true ,
52+ hover : true ,
53+ completion : true ,
54+ validate : true ,
55+ format : true ,
56+ schemas : [
57+ {
58+ schema : schema as JSONSchema ,
59+ fileMatch : [ '*' ] ,
60+ uri : 'http://kubernetesjsonschema.dev/master-standalone/all.json' ,
61+ } ,
62+ ] ,
63+ } ) ;
64+ return ( ) => dispose ( ) ;
7065 } , [ schema ] ) ;
7166
7267 // Capture Space at the window level before document-level handlers and stop propagation if inside editor
0 commit comments