From 56ad3251fdd35fc7c2893c4ce25ed0f8ba460287 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Fri, 14 Apr 2017 22:25:39 +0800 Subject: [PATCH] Add keyboard shorts dialog and enable Ctrl+S in the editor --- .../gollum/javascript/editor/gollum.editor.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/gollum/public/gollum/javascript/editor/gollum.editor.js b/lib/gollum/public/gollum/javascript/editor/gollum.editor.js index 1b03b61e..8c213749 100755 --- a/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +++ b/lib/gollum/public/gollum/javascript/editor/gollum.editor.js @@ -64,6 +64,29 @@ editor.getSession().on('change', function(){ textarea.val(editor.getSession().getValue()); }); + + editor.commands.addCommand({ + name: "showKeyboardShortcuts", + bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"}, + exec: function(editor) { + ace.config.loadModule("ace/ext/keybinding_menu", function(module) { + module.init(editor); + editor.showKeyboardShortcuts(); + }); + } + }); + + // Ace editor seems to capture all keyboard events so gollum's global + // shortcuts does not work in the editor area. So we add them back in + // the editor as commands. These commands are added back on-demand since + // not all gollum shortcuts are necessary in the presence of Ace editor. + editor.commands.addCommand({ + name: "saveContents", + bindKey: {win: "Ctrl-s", mac: "Command-s"}, + exec: function(editor) { + $('#gollum-editor form[name="gollum-editor"]').submit(); + } + }); }); $("#gollum-editor-body-ace").resize(function(){