1- import React , { createRef , useRef } from 'react' ;
1+ import React from 'react' ;
22import ReactDOM from "react-dom/client" ;
33import './App.css' ;
44
55import * as monaco from 'monaco-editor' ;
6- import { loader } from '@monaco-editor/react' ;
76import { MonacoLogController , FileInfo } from '../monaco/MonacoLogController' ;
87import { EventCallback , emit , listen } from '@tauri-apps/api/event'
98import { useEffect } from 'react' ;
109import Editor from "@monaco-editor/react" ;
1110import { TextZone } from '../monaco/ViewZones' ;
1211import { addSetLanguageActions } from '../monaco/SetLanguage' ;
1312import { addSetThemeActions , getBackgroundColor } from '../monaco/Themes' ;
14- import { customThemes } from '../main' ;
15-
16- loader . config ( { monaco } ) ;
13+ import { currentTheme , customThemes , onUpdateTheme } from '../main' ;
1714
1815function listenReact < T > ( name : string , fun : EventCallback < T > ) {
1916 useEffect ( ( ) => {
@@ -39,7 +36,8 @@ function createPatchEditor(language: string, textZone: TextZone) {
3936
4037 const secondEditor = < Editor
4138 onMount = { handleEditorDidMount }
42- theme = "vs-dark-modern"
39+
40+ theme = { currentTheme }
4341
4442 // language / value inputs are tracked, "default" versions are only for the initial value
4543 defaultLanguage = { language }
@@ -93,20 +91,23 @@ function App() {
9391 } ) ;
9492
9593 async function handleEditorDidMount ( editor : monaco . editor . IStandaloneCodeEditor , monaco : any ) {
96- document . body . style . backgroundColor = getBackgroundColor ( editor ) ;
94+ // This shouldnt be needed, but it needs to be run once to update the background color for the first time.
95+ onUpdateTheme ( currentTheme , editor ) ;
9796
9897 let logController_ = new MonacoLogController ( editor , createPatchEditor ) ;
9998 logController = logController_ ;
10099
101100 addSetLanguageActions ( editor ) ;
102- addSetThemeActions ( editor , customThemes , ( ) => document . body . style . backgroundColor = getBackgroundColor ( editor ) ) ;
101+ addSetThemeActions ( editor , customThemes , onUpdateTheme ) ;
103102 }
104103
105104 return < Editor
106105 height = "calc(100vh - 30px)" // TODO This shouldn't be here but otherwise the size is 5px
107106 width = "calc(100vw - 30px)"
107+
108+ theme = { currentTheme }
109+
108110 onMount = { handleEditorDidMount }
109- theme = "vs-dark-modern"
110111 options = { {
111112 minimap : { enabled : false } ,
112113 renderLineHighlight : "none" ,
0 commit comments