Skip to content

Commit b717efc

Browse files
committed
fix(Config): fix changing editor config from SDK
1 parent 98837f6 commit b717efc

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/livecodes/core.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,18 +1523,10 @@ const applyConfig = async (newConfig: Partial<Config>, reload = false) => {
15231523
...getEditorConfig(newConfig as Config),
15241524
...getFormatterConfig(newConfig as Config),
15251525
};
1526+
15261527
const hasEditorConfig = Object.values(editorConfig).some((value) => value != null);
1527-
if (hasEditorConfig) {
1528-
for (const key in editorConfig) {
1529-
if (
1530-
key in newConfig &&
1531-
(editorConfig as any)[key] !== (currentEditorConfig as any)[key] &&
1532-
!key.toLowerCase().includes('theme')
1533-
) {
1534-
shouldReloadEditors = true;
1535-
break;
1536-
}
1537-
}
1528+
if (hasEditorConfig && newConfig.editor && newConfig.editor !== currentEditorConfig.editor) {
1529+
shouldReloadEditors = true;
15381530
}
15391531
if ('configureTailwindcss' in editors.markup) {
15401532
if (newConfig.processors?.includes('tailwindcss')) {
@@ -1550,6 +1542,12 @@ const applyConfig = async (newConfig: Partial<Config>, reload = false) => {
15501542
}
15511543
if (shouldReloadEditors) {
15521544
await reloadEditors(combinedConfig);
1545+
} else if (hasEditorConfig) {
1546+
currentEditorConfig = {
1547+
...getEditorConfig(combinedConfig),
1548+
...getFormatterConfig(combinedConfig),
1549+
};
1550+
getAllEditors().forEach((editor) => editor.changeSettings(currentEditorConfig));
15531551
}
15541552

15551553
parent.dispatchEvent(new Event(customEvents.ready));

0 commit comments

Comments
 (0)