From 4c55b9c304da75c84cec78db17bb8426a1ad55c6 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 8 Sep 2021 06:00:23 +0530 Subject: [PATCH] fix: codemirror theme not changing when color mode is updated --- helpers/editor/codemirror.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/editor/codemirror.ts b/helpers/editor/codemirror.ts index 3e9fe5d33..bd5e8a991 100644 --- a/helpers/editor/codemirror.ts +++ b/helpers/editor/codemirror.ts @@ -57,6 +57,8 @@ export function useCodemirror( value: Ref, options: CodeMirrorOptions ) { + const { $colorMode } = useContext() as any + const cm = ref(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, }