]> BookStack Code Mirror - bookstack/blobdiff - resources/js/markdown/shortcuts.js
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / resources / js / markdown / shortcuts.js
index 08841e6c231593d2d6e265e42a91988c660b637f..543e6dcdde67dd26ab8beb8f2987a71932151fbc 100644 (file)
@@ -7,35 +7,35 @@ function provide(editor) {
     const shortcuts = {};
 
     // Insert Image shortcut
-    shortcuts['Mod-Alt-i'] = () => editor.actions.insertImage();
+    shortcuts['Shift-Mod-i'] = () => editor.actions.insertImage();
 
     // Save draft
-    shortcuts['Mod-s'] = cm => window.$events.emit('editor-save-draft');
+    shortcuts['Mod-s'] = () => window.$events.emit('editor-save-draft');
 
     // Save page
-    shortcuts['Mod-Enter'] = cm => window.$events.emit('editor-save-page');
+    shortcuts['Mod-Enter'] = () => window.$events.emit('editor-save-page');
 
     // Show link selector
-    shortcuts['Shift-Mod-k'] = cm => editor.actions.showLinkSelector();
+    shortcuts['Shift-Mod-k'] = () => editor.actions.showLinkSelector();
 
     // Insert Link
-    shortcuts['Mod-k'] = cm => editor.actions.insertLink();
+    shortcuts['Mod-k'] = () => editor.actions.insertLink();
 
     // FormatShortcuts
-    shortcuts['Mod-1'] = cm => editor.actions.replaceLineStart('##');
-    shortcuts['Mod-2'] = cm => editor.actions.replaceLineStart('###');
-    shortcuts['Mod-3'] = cm => editor.actions.replaceLineStart('####');
-    shortcuts['Mod-4'] = cm => editor.actions.replaceLineStart('#####');
-    shortcuts['Mod-5'] = cm => editor.actions.replaceLineStart('');
-    shortcuts['Mod-d'] = cm => editor.actions.replaceLineStart('');
-    shortcuts['Mod-6'] = cm => editor.actions.replaceLineStart('>');
-    shortcuts['Mod-q'] = cm => editor.actions.replaceLineStart('>');
-    shortcuts['Mod-7'] = cm => editor.actions.wrapSelection('\n```\n', '\n```');
-    shortcuts['Mod-8'] = cm => editor.actions.wrapSelection('`', '`');
-    shortcuts['Shift-Mod-e'] = cm => editor.actions.wrapSelection('`', '`');
-    shortcuts['Mod-9'] = cm => editor.actions.cycleCalloutTypeAtSelection();
-    shortcuts['Mod-p'] = cm => editor.actions.replaceLineStart('-')
-    shortcuts['Mod-o'] = cm => editor.actions.replaceLineStartForOrderedList()
+    shortcuts['Mod-1'] = () => editor.actions.replaceLineStart('##');
+    shortcuts['Mod-2'] = () => editor.actions.replaceLineStart('###');
+    shortcuts['Mod-3'] = () => editor.actions.replaceLineStart('####');
+    shortcuts['Mod-4'] = () => editor.actions.replaceLineStart('#####');
+    shortcuts['Mod-5'] = () => editor.actions.replaceLineStart('');
+    shortcuts['Mod-d'] = () => editor.actions.replaceLineStart('');
+    shortcuts['Mod-6'] = () => editor.actions.replaceLineStart('>');
+    shortcuts['Mod-q'] = () => editor.actions.replaceLineStart('>');
+    shortcuts['Mod-7'] = () => editor.actions.wrapSelection('\n```\n', '\n```');
+    shortcuts['Mod-8'] = () => editor.actions.wrapSelection('`', '`');
+    shortcuts['Shift-Mod-e'] = () => editor.actions.wrapSelection('`', '`');
+    shortcuts['Mod-9'] = () => editor.actions.cycleCalloutTypeAtSelection();
+    shortcuts['Mod-p'] = () => editor.actions.replaceLineStart('-');
+    shortcuts['Mod-o'] = () => editor.actions.replaceLineStartForOrderedList();
 
     return shortcuts;
 }
@@ -46,12 +46,17 @@ function provide(editor) {
  * @return {{key: String, run: function, preventDefault: boolean}[]}
  */
 export function provideKeyBindings(editor) {
-    const shortcuts= provide(editor);
+    const shortcuts = provide(editor);
     const keyBindings = [];
 
+    const wrapAction = action => () => {
+        action();
+        return true;
+    };
+
     for (const [shortcut, action] of Object.entries(shortcuts)) {
-        keyBindings.push({key: shortcut, run: action, preventDefault: true});
+        keyBindings.push({key: shortcut, run: wrapAction(action), preventDefault: true});
     }
 
     return keyBindings;
-}
\ No newline at end of file
+}