Explorar o código

HUE-8621 [editor] Add ace option to toggle dark mode

This also persists the setting in total storage
Johan Ahlen %!s(int64=7) %!d(string=hai) anos
pai
achega
79b63e4
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 10 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -4865,7 +4865,8 @@
         aceErrorsSub.dispose();
       });
 
-      editor.setTheme($.totalStorage("hue.ace.theme") || "ace/theme/hue");
+      var darkThemeEnabled = ApiHelper.getInstance().getFromTotalStorage('ace', 'dark.theme.enabled', false);
+      editor.setTheme(darkThemeEnabled ? 'ace/theme/hue_dark' : 'ace/theme/hue');
 
       var editorOptions = {
         enableSnippets: true,
@@ -4884,6 +4885,14 @@
       };
 
       editor.customMenuOptions = {
+        setEnableDarkTheme: function (enabled) {
+          darkThemeEnabled = enabled;
+          ApiHelper.getInstance().setInTotalStorage('ace', 'dark.theme.enabled', darkThemeEnabled);
+          editor.setTheme(darkThemeEnabled ? 'ace/theme/hue_dark' : 'ace/theme/hue');
+        },
+        getEnableDarkTheme: function () {
+          return darkThemeEnabled;
+        },
         setEnableAutocompleter: function (enabled) {
           editor.setOption('enableBasicAutocompletion', enabled);
           snippet.getApiHelper().setInTotalStorage('hue.ace', 'enableBasicAutocompletion', enabled);