Skip to content

Commit 1d56c40

Browse files
committed
fix(editor): support dark/light theme by inlining themes
1 parent 1de750f commit 1d56c40

File tree

4 files changed

+2418
-6
lines changed

4 files changed

+2418
-6
lines changed

src/app/src/components/content/ContentEditorCode.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ onMounted(async () => {
4848
4949
// create a Monaco editor instance
5050
editor.value = monaco.createEditor(editorRef.value, {
51-
// theme: ui.colorMode.value === 'light' ? 'vs' : 'vs-dark',
51+
theme: ui.colorMode.value === 'light' ? 'vitesse-light' : 'vitesse-dark',
5252
lineNumbers: 'off',
5353
readOnly: props.readOnly,
5454
scrollbar: props.readOnly
@@ -92,11 +92,11 @@ onMounted(async () => {
9292
editor.value.setModel(monaco.editor.createModel(content.value, 'mdc'))
9393
9494
// Set the theme based on the color mode
95-
// watch(ui.colorMode, () => {
96-
// editor.value?.updateOptions({
97-
// theme: ui.colorMode.value === 'light' ? 'vs' : 'vs-dark',
98-
// })
99-
// })
95+
watch(ui.colorMode, () => {
96+
editor.value?.updateOptions({
97+
theme: ui.colorMode.value === 'light' ? 'vitesse-light' : 'vitesse-dark',
98+
})
99+
})
100100
})
101101
102102
function setContent(document: DatabasePageItem) {

src/app/src/utils/monaco/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createSingletonPromise } from '@vueuse/core'
22
import type { editor as Editor } from 'modern-monaco/editor-core'
3+
import themeLight from './theme-light'
4+
import themeDark from './theme-dark'
35

46
export { setupSuggestion } from './mdc-compilation'
57
export type { editor as Editor } from 'modern-monaco/editor-core'
@@ -20,6 +22,8 @@ export const setupMonaco = createSingletonPromise(async () => {
2022
}
2123

2224
const monaco: Monaco = await init()
25+
monaco.editor.defineTheme('vitesse-light', themeLight)
26+
monaco.editor.defineTheme('vitesse-dark', themeDark)
2327

2428
return {
2529
monaco,

0 commit comments

Comments
 (0)