1
1
import {
2
2
component$ ,
3
- type NoSerialize ,
4
- type QRL ,
5
- useVisibleTask$ ,
6
- useContext ,
7
3
useSignal ,
8
4
useStore ,
9
5
useTask$ ,
6
+ useVisibleTask$ ,
7
+ type NoSerialize ,
8
+ type QRL ,
10
9
} from '@qwik.dev/core' ;
10
+ import { getThemeSignal } from '../../components/theme-toggle/theme-toggle' ;
11
+ import type { ReplAppInput , ReplStore } from '../types' ;
11
12
import type { IStandaloneCodeEditor } from './monaco' ;
12
13
import {
13
14
addQwikLibs ,
14
15
getEditorTheme ,
15
- type ICodeEditorViewState ,
16
16
initMonacoEditor ,
17
17
updateMonacoEditor ,
18
+ type ICodeEditorViewState ,
18
19
} from './monaco' ;
19
- import type { ReplAppInput , ReplStore } from '../types' ;
20
- import { GlobalStore } from '../../context' ;
21
20
22
21
export const Editor = component$ ( ( props : EditorProps ) => {
23
22
const hostRef = useSignal < Element > ( ) ;
@@ -29,8 +28,6 @@ export const Editor = component$((props: EditorProps) => {
29
28
viewStates : { } ,
30
29
} ) ;
31
30
32
- const globalStore = useContext ( GlobalStore ) ;
33
-
34
31
useVisibleTask$ ( async ( ) => {
35
32
if ( ! store . editor ) {
36
33
await initMonacoEditor ( hostRef . value , props , store , props . store ) ;
@@ -43,12 +40,10 @@ export const Editor = component$((props: EditorProps) => {
43
40
} ) ;
44
41
45
42
useVisibleTask$ ( ( { track } ) => {
46
- track ( ( ) => globalStore . theme ) ;
47
- if ( globalStore . theme !== 'auto' ) {
48
- store . editor ?. updateOptions ( {
49
- theme : getEditorTheme ( globalStore . theme === 'dark' ) ,
50
- } ) ;
51
- }
43
+ const theme = track ( getThemeSignal ( ) ) ;
44
+ store . editor ?. updateOptions ( {
45
+ theme : getEditorTheme ( theme === 'dark' ) ,
46
+ } ) ;
52
47
} ) ;
53
48
54
49
useTask$ ( async ( { track } ) => {
0 commit comments