fix: codemirror theme not changing when color mode is updated

This commit is contained in:
Andrew Bastin
2021-09-08 06:00:23 +05:30
committed by liyasthomas
parent 639a629809
commit 4c55b9c304

View File

@@ -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,
}