diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.js index f81e11cd3..65e752985 100644 --- a/src/public/javascripts/desktop.js +++ b/src/public/javascripts/desktop.js @@ -36,6 +36,7 @@ import hoistedNoteService from './services/hoisted_note.js'; import noteTypeService from './services/note_type.js'; import linkService from './services/link.js'; import noteAutocompleteService from './services/note_autocomplete.js'; +import macInit from './services/mac_init.js'; // required for CKEditor image upload plugin window.glob.getCurrentNode = treeService.getCurrentNode; @@ -110,21 +111,6 @@ if (utils.isElectron()) { }); } -function exec(cmd) { - document.execCommand(cmd); - - return false; -} - -if (utils.isElectron() && utils.isMac()) { - utils.bindShortcut('meta+c', () => exec("copy")); - utils.bindShortcut('meta+v', () => exec('paste')); - utils.bindShortcut('meta+x', () => exec('cut')); - utils.bindShortcut('meta+a', () => exec('selectAll')); - utils.bindShortcut('meta+z', () => exec('undo')); - utils.bindShortcut('meta+y', () => exec('redo')); -} - $("#export-note-button").click(function () { if ($(this).hasClass("disabled")) { return; @@ -133,6 +119,8 @@ $("#export-note-button").click(function () { exportDialog.showDialog('single'); }); +macInit.init(); + treeService.showTree(); entrypoints.registerEntrypoints(); diff --git a/src/public/javascripts/services/mac_init.js b/src/public/javascripts/services/mac_init.js new file mode 100644 index 000000000..11598ecc1 --- /dev/null +++ b/src/public/javascripts/services/mac_init.js @@ -0,0 +1,25 @@ +/** + * Mac specific initialization + */ +import utils from "./utils.js"; + +function init() { + if (utils.isElectron() && utils.isMac()) { + utils.bindShortcut('meta+c', () => exec("copy")); + utils.bindShortcut('meta+v', () => exec('paste')); + utils.bindShortcut('meta+x', () => exec('cut')); + utils.bindShortcut('meta+a', () => exec('selectAll')); + utils.bindShortcut('meta+z', () => exec('undo')); + utils.bindShortcut('meta+y', () => exec('redo')); + } +} + +function exec(cmd) { + document.execCommand(cmd); + + return false; +} + +export default { + init +} \ No newline at end of file diff --git a/src/public/javascripts/setup.js b/src/public/javascripts/setup.js index 3239d8a13..473b80391 100644 --- a/src/public/javascripts/setup.js +++ b/src/public/javascripts/setup.js @@ -1,4 +1,7 @@ import utils from "./services/utils.js"; +import macInit from './services/mac_init.js'; + +macInit.init(); function SetupModel() { if (syncInProgress) {