fix: codemirror theme not changing when color mode is updated
This commit is contained in:
committed by
liyasthomas
parent
639a629809
commit
4c55b9c304
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user