11import { type Monaco , Editor as MonacoEditor } from "@monaco-editor/react"
22import React from "react"
3+ import { useSnapshot } from "valtio/react"
34
45import { appConfig } from "@/config"
5- import { codeGlueLight } from "@/design/editorThemes"
66import { useCurrentAutomation } from "@/hooks/useAutomation"
77import { store } from "@/store"
8+ import { getUserSettingOrDefault , settingsStore } from "@/store/settings"
89
910import type { editor } from "monaco-editor"
1011
@@ -16,6 +17,13 @@ export const Editor: React.FC = () => {
1617 useCurrentAutomation ( )
1718 const path = automationId ? `/automations/${ automationId } .ts` : undefined
1819
20+ const snap = useSnapshot ( settingsStore )
21+ const theme = getUserSettingOrDefault ( snap , "editor.theme" )
22+ const typeface = getUserSettingOrDefault ( snap , "editor.typeface" )
23+ const fontSize = getUserSettingOrDefault ( snap , "editor.fontSize" )
24+ const fontWidth = getUserSettingOrDefault ( snap , "editor.fontWidth" )
25+ const fontWeight = getUserSettingOrDefault ( snap , "editor.fontWeight" )
26+
1927 /**
2028 * Support for automation draft saving with debounce
2129 */
@@ -74,7 +82,7 @@ export const Editor: React.FC = () => {
7482 < MonacoEditor
7583 { ...{
7684 language : "typescript" ,
77- theme : codeGlueLight . name ,
85+ theme,
7886 defaultValue : automationSnapshot . body ,
7987 beforeMount : handleEditorBeforeMount ,
8088 onChange : handleEditorChange ,
@@ -86,12 +94,11 @@ export const Editor: React.FC = () => {
8694 minimap : { enabled : false } ,
8795 tabSize : appConfig . editor . tabSize ,
8896 rulers : [ appConfig . editor . printWidth ] ,
89- fontSize : appConfig . editor . defaultFontSize ,
90- fontFamily : appConfig . editor . font ,
91- fontWeight : "260" ,
97+ fontSize,
98+ fontFamily : typeface ,
9299 fontLigatures :
93100 "'calt', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'liga'" ,
94- fontVariations : true ,
101+ fontVariations : `'wght' ${ fontWeight } , 'wdth' ${ fontWidth } ` ,
95102 allowVariableFonts : true ,
96103 automaticLayout : true ,
97104 occurrencesHighlight : "off" ,
0 commit comments