@@ -1432,8 +1432,8 @@ const loadConfig = async (
14321432 changingContent = false ;
14331433} ;
14341434
1435- const applyConfig = async ( newConfig : Partial < Config > , reload = false ) => {
1436- const currentConfig = getConfig ( ) ;
1435+ const applyConfig = async ( newConfig : Partial < Config > , reload = false , oldConfig ?: Config ) => {
1436+ const currentConfig = oldConfig || getConfig ( ) ;
14371437 const combinedConfig : Config = { ...currentConfig , ...newConfig } ;
14381438 if ( reload ) {
14391439 await updateEditors ( editors , getConfig ( ) ) ;
@@ -1518,16 +1518,20 @@ const applyConfig = async (newConfig: Partial<Config>, reload = false) => {
15181518 } ) ;
15191519 }
15201520
1521- let shouldReloadEditors = false ;
15221521 const editorConfig = {
15231522 ...getEditorConfig ( newConfig as Config ) ,
15241523 ...getFormatterConfig ( newConfig as Config ) ,
15251524 } ;
15261525
15271526 const hasEditorConfig = Object . keys ( editorConfig ) . some ( ( k ) => k in newConfig ) ;
1528- if ( hasEditorConfig && newConfig . editor && newConfig . editor !== currentEditorConfig . editor ) {
1529- shouldReloadEditors = true ;
1530- }
1527+ let shouldReloadEditors = ( ( ) => {
1528+ if ( newConfig . editor != null && ! ( newConfig . editor in editors . markup ) ) return true ;
1529+ if ( newConfig . mode != null ) {
1530+ if ( newConfig . mode !== 'result' && editors . markup . isFake ) return true ;
1531+ if ( newConfig . mode !== 'codeblock' && editors . markup . codejar ) return true ;
1532+ }
1533+ return false ;
1534+ } ) ( ) ;
15311535 if ( 'configureTailwindcss' in editors . markup ) {
15321536 if ( newConfig . processors ?. includes ( 'tailwindcss' ) ) {
15331537 editors . markup . configureTailwindcss ?.( true ) ;
@@ -5536,14 +5540,6 @@ const createApi = (): API => {
55365540 const shouldRun =
55375541 newConfig . mode != null && newConfig . mode !== 'editor' && newConfig . mode !== 'codeblock' ;
55385542 const shouldReloadCompiler = shouldRun && compiler . isFake ;
5539- const shouldReloadCodeEditors = ( ( ) => {
5540- if ( newConfig . editor != null && ! ( newConfig . editor in editors . markup ) ) return true ;
5541- if ( newConfig . mode != null ) {
5542- if ( newConfig . mode !== 'result' && editors . markup . isFake ) return true ;
5543- if ( newConfig . mode !== 'codeblock' && editors . markup . codejar ) return true ;
5544- }
5545- return false ;
5546- } ) ( ) ;
55475543 const isContentOnlyChange = compareObjects (
55485544 newConfig ,
55495545 currentConfig as Record < string , any > ,
@@ -5568,10 +5564,7 @@ const createApi = (): API => {
55685564 if ( shouldReloadCompiler ) {
55695565 await reloadCompiler ( newAppConfig ) ;
55705566 }
5571- if ( shouldReloadCodeEditors ) {
5572- await createEditors ( newAppConfig ) ;
5573- }
5574- await applyConfig ( newConfig , /* reload = */ true ) ;
5567+ await applyConfig ( newConfig , /* reload = */ true , currentConfig ) ;
55755568 const content = getContentConfig ( newConfig as Config ) ;
55765569 const hasContent = Object . values ( content ) . some ( ( value ) => value != null ) ;
55775570 if ( hasContent ) {
0 commit comments