fix: codemirror theme not changing when color mode is updated
This commit is contained in:
parent
639a629809
commit
4c55b9c304
1 changed files with 5 additions and 1 deletions
|
|
@ -57,6 +57,8 @@ export function useCodemirror(
|
|||
value: Ref<string>,
|
||||
options: CodeMirrorOptions
|
||||
) {
|
||||
const { $colorMode } = useContext() as any
|
||||
|
||||
const cm = ref<CodeMirror.Editor | null>(null)
|
||||
|
||||
const updateEditorConfig = () => {
|
||||
|
|
@ -135,7 +137,6 @@ export function useCodemirror(
|
|||
})
|
||||
|
||||
const setTheme = () => {
|
||||
const { $colorMode } = useContext() as any
|
||||
if (cm.value) {
|
||||
cm.value?.setOption("theme", getThemeName($colorMode.value))
|
||||
}
|
||||
|
|
@ -175,6 +176,9 @@ export function useCodemirror(
|
|||
}
|
||||
})
|
||||
|
||||
// Watch color mode updates and update theme
|
||||
watch(() => $colorMode.value, setTheme)
|
||||
|
||||
return {
|
||||
cm,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue