X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/69d03042c6f40c617ad6ffceb5fdd95f8610d383..refs/pull/5280/head:/resources/js/markdown/shortcuts.js diff --git a/resources/js/markdown/shortcuts.js b/resources/js/markdown/shortcuts.js index c4a86e544..543e6dcdd 100644 --- a/resources/js/markdown/shortcuts.js +++ b/resources/js/markdown/shortcuts.js @@ -7,35 +7,35 @@ function provide(editor) { const shortcuts = {}; // Insert Image shortcut - shortcuts['Shift-Mod-i'] = cm => 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,14 +46,12 @@ 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) => { - return () => { - action(); - return true; - }; + const wrapAction = action => () => { + action(); + return true; }; for (const [shortcut, action] of Object.entries(shortcuts)) { @@ -61,4 +59,4 @@ export function provideKeyBindings(editor) { } return keyBindings; -} \ No newline at end of file +}