Skip to content

Commit 43d585c

Browse files
committed
fix(editor): watch for colorMode change on diff-editor
1 parent 4f3f078 commit 43d585c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/app/src/components/content/ContentCardReview.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function initializeEditor() {
6363
original: gitHubOriginal!,
6464
modified: modified!,
6565
language: language.value,
66-
colorMode: ui.colorMode.value,
66+
colorMode: ui.colorMode,
6767
editorOptions: {
6868
// hide unchanged regions
6969
hideUnchangedRegions: {

src/app/src/components/content/ContentEditorConflict.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ useMonacoDiff(diffEditorRef, {
3939
original: conflict.value?.githubContent || '',
4040
modified: conflict.value?.localContent || '',
4141
language: language.value,
42-
colorMode: ui.colorMode.value,
42+
colorMode: ui.colorMode,
4343
})
4444
</script>
4545

src/app/src/composables/useMonacoDiff.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface UseMonacoDiffOptions {
66
original: string
77
modified: string
88
language: string
9-
colorMode?: 'light' | 'dark'
9+
colorMode: Ref<'light' | 'dark'>
1010
editorOptions?: Editor.IStandaloneDiffEditorConstructionOptions
1111
}
1212

@@ -23,9 +23,10 @@ export function useMonacoDiff(target: Ref, options: UseMonacoDiffOptions) {
2323
if (!el || isInitialized) return
2424

2525
const monaco = await setupMonaco()
26+
const colorMode = unref(options.colorMode) || 'dark'
2627

2728
editor = monaco.createDiffEditor(el, {
28-
theme: getTheme(options.colorMode),
29+
theme: getTheme(colorMode),
2930
lineNumbers: 'off',
3031
readOnly: true,
3132
renderSideBySide: true,
@@ -36,6 +37,14 @@ export function useMonacoDiff(target: Ref, options: UseMonacoDiffOptions) {
3637
...options.editorOptions,
3738
})
3839

40+
// Watch for color mode changes
41+
watch(options.colorMode, (newMode) => {
42+
editor?.updateOptions({
43+
// @ts-expect-error -- theme is missing from IDiffEditorOptions
44+
theme: getTheme(newMode),
45+
})
46+
})
47+
3948
editor.setModel({
4049
original: monaco.editor.createModel(options.original, options.language),
4150
modified: monaco.editor.createModel(options.modified, options.language),

0 commit comments

Comments
 (0)