Просмотр исходного кода

HUE-7168 [editor] Add keyboard shortcut for presentation mode and make esc work all the time

Enrico Berti 8 лет назад
Родитель
Сommit
e341dd0666

+ 8 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -4534,6 +4534,14 @@
         }
       });
 
+      editor.commands.addCommand({
+        name: "esc",
+        bindKey: {win: "Ctrl-Shift-p", mac: "Ctrl-Shift-p|Command-Shift-p"},
+        exec: function () {
+          huePubSub.publish('editor.presentation.toggle');
+        }
+      });
+
       editor.commands.bindKey("Ctrl-P", "golineup");
 
       editor.commands.addCommand({

+ 3 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -280,7 +280,9 @@ var EditorViewModel = (function() {
     // Ace stuff
     self.ace = ko.observable(null);
     self.ace.subscribe(function () {
-      self.ace().focus();
+      if (!vm.isPresentationMode()) {
+        self.ace().focus();
+      }
     });
     self.errors = ko.observableArray([]);
 

+ 10 - 0
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -3279,6 +3279,16 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
         return false;
       });
 
+      huePubSub.subscribe('editor.presentation.toggle', function () {
+        viewModel.isPresentationMode(!viewModel.isPresentationMode());
+      }, HUE_PUB_SUB_EDITOR_ID);
+
+      $(window).bind("keydown", "ctrl+shift+p alt+shift+p meta+shift+p", function (e) {
+        e.preventDefault();
+        huePubSub.publish('editor.presentation.toggle');
+        return false;
+      });
+
       huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
 
       $(document).bind('keyup', function (e) {