From efdb6c6620e9ea7f5861efbef7d3462bf3c7bcd7 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 17 Sep 2021 19:10:19 +0200 Subject: Frontend color theme --- language-web/src/main/js/editor/EditorStore.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'language-web/src/main/js/editor/EditorStore.ts') diff --git a/language-web/src/main/js/editor/EditorStore.ts b/language-web/src/main/js/editor/EditorStore.ts index 3a0c6f87..5da45ac1 100644 --- a/language-web/src/main/js/editor/EditorStore.ts +++ b/language-web/src/main/js/editor/EditorStore.ts @@ -1,4 +1,5 @@ import { Editor, EditorConfiguration } from 'codemirror'; +import 'codemirror/addon/selection/active-line'; import { createAtom, makeAutoObservable, @@ -12,6 +13,8 @@ import { removeServices, } from 'xtext/xtext-codemirror'; +import { ThemeStore } from '../theme/ThemeStore'; + const xtextLang = 'problem'; const xtextOptions: IXtextOptions = { @@ -22,10 +25,12 @@ const xtextOptions: IXtextOptions = { const codeMirrorGlobalOptions: EditorConfiguration = { mode: `xtext/${xtextLang}`, indentUnit: 2, - theme: 'material-darker', + styleActiveLine: true, }; export class EditorStore { + themeStore; + atom; editor?: Editor; @@ -36,9 +41,11 @@ export class EditorStore { showLineNumbers = false; - constructor() { + constructor(themeStore: ThemeStore) { + this.themeStore = themeStore; this.atom = createAtom('EditorStore'); makeAutoObservable(this, { + themeStore: false, atom: false, editor: observable.ref, xtextServices: observable.ref, @@ -65,8 +72,8 @@ export class EditorStore { if (this.editor) { removeServices(this.editor); } - this.editor = undefined; - this.xtextServices = undefined; + delete this.editor; + delete this.xtextServices; } /** @@ -89,6 +96,7 @@ export class EditorStore { get codeMirrorOptions(): EditorConfiguration { return { ...codeMirrorGlobalOptions, + theme: this.themeStore.codeMirrorTheme, lineNumbers: this.showLineNumbers, }; } -- cgit v1.2.3-70-g09d2