Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/src/components/content/ContentCardReview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function initializeEditor() {
original: gitHubOriginal!,
modified: modified!,
language: language.value,
colorMode: ui.colorMode.value,
colorMode: ui.colorMode,
editorOptions: {
// hide unchanged regions
hideUnchangedRegions: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/src/components/content/ContentEditorConflict.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ useMonacoDiff(diffEditorRef, {
original: conflict.value?.githubContent || '',
modified: conflict.value?.localContent || '',
language: language.value,
colorMode: ui.colorMode.value,
colorMode: ui.colorMode,
})
</script>

Expand Down
13 changes: 11 additions & 2 deletions src/app/src/composables/useMonacoDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface UseMonacoDiffOptions {
original: string
modified: string
language: string
colorMode?: 'light' | 'dark'
colorMode: Ref<'light' | 'dark'>
editorOptions?: Editor.IStandaloneDiffEditorConstructionOptions
}

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

const monaco = await setupMonaco()
const colorMode = unref(options.colorMode) || 'dark'

editor = monaco.createDiffEditor(el, {
theme: getTheme(options.colorMode),
theme: getTheme(colorMode),
lineNumbers: 'off',
readOnly: true,
renderSideBySide: true,
Expand All @@ -36,6 +37,14 @@ export function useMonacoDiff(target: Ref, options: UseMonacoDiffOptions) {
...options.editorOptions,
})

// Watch for color mode changes
watch(options.colorMode, (newMode) => {
editor?.updateOptions({
// @ts-expect-error -- theme is missing from IDiffEditorOptions
theme: getTheme(newMode),
})
})

editor.setModel({
original: monaco.editor.createModel(options.original, options.language),
modified: monaco.editor.createModel(options.modified, options.language),
Expand Down
Loading