2018-03-27 10:29:14 +08:00
|
|
|
import utils from "./utils.js";
|
|
|
|
import treeService from "./tree.js";
|
|
|
|
import linkService from "./link.js";
|
2018-03-28 10:11:06 +08:00
|
|
|
import fileService from "./file.js";
|
2018-03-27 10:29:14 +08:00
|
|
|
import noteRevisionsDialog from "../dialogs/note_revisions.js";
|
2018-04-02 05:41:28 +08:00
|
|
|
import optionsDialog from "../dialogs/options.js";
|
2018-03-27 10:29:14 +08:00
|
|
|
import addLinkDialog from "../dialogs/add_link.js";
|
|
|
|
import recentNotesDialog from "../dialogs/recent_notes.js";
|
|
|
|
import jumpToNoteDialog from "../dialogs/jump_to_note.js";
|
|
|
|
import noteSourceDialog from "../dialogs/note_source.js";
|
|
|
|
import recentChangesDialog from "../dialogs/recent_changes.js";
|
|
|
|
import sqlConsoleDialog from "../dialogs/sql_console.js";
|
|
|
|
import searchTreeService from "./search_tree.js";
|
|
|
|
import labelsDialog from "../dialogs/labels.js";
|
|
|
|
|
|
|
|
function registerEntrypoints() {
|
|
|
|
// hot keys are active also inside inputs and content editables
|
|
|
|
jQuery.hotkeys.options.filterInputAcceptingElements = false;
|
|
|
|
jQuery.hotkeys.options.filterContentEditable = false;
|
|
|
|
jQuery.hotkeys.options.filterTextInputs = false;
|
|
|
|
|
|
|
|
utils.bindShortcut('ctrl+l', addLinkDialog.showDialog);
|
|
|
|
|
|
|
|
$("#jump-to-note-button").click(jumpToNoteDialog.showDialog);
|
|
|
|
utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog);
|
|
|
|
|
|
|
|
$("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions);
|
|
|
|
|
|
|
|
$("#show-source-button").click(noteSourceDialog.showDialog);
|
|
|
|
utils.bindShortcut('ctrl+u', noteSourceDialog.showDialog);
|
|
|
|
|
|
|
|
$("#recent-changes-button").click(recentChangesDialog.showDialog);
|
|
|
|
|
|
|
|
$("#recent-notes-button").click(recentNotesDialog.showDialog);
|
|
|
|
utils.bindShortcut('ctrl+e', recentNotesDialog.showDialog);
|
|
|
|
|
|
|
|
$("#toggle-search-button").click(searchTreeService.toggleSearch);
|
|
|
|
utils.bindShortcut('ctrl+s', searchTreeService.toggleSearch);
|
|
|
|
|
|
|
|
$(".show-labels-button").click(labelsDialog.showDialog);
|
|
|
|
utils.bindShortcut('alt+l', labelsDialog.showDialog);
|
|
|
|
|
2018-04-02 05:41:28 +08:00
|
|
|
$("#options-button").click(optionsDialog.showDialog);
|
2018-03-27 10:29:14 +08:00
|
|
|
|
|
|
|
utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog);
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
2018-05-27 10:54:06 +08:00
|
|
|
$("#history-navigation").show();
|
|
|
|
$("#history-back-button").click(window.history.back);
|
|
|
|
$("#history-forward-button").click(window.history.forward);
|
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut('alt+left', window.history.back);
|
|
|
|
utils.bindShortcut('alt+right', window.history.forward);
|
|
|
|
}
|
|
|
|
|
|
|
|
utils.bindShortcut('alt+m', e => $(".hide-toggle").toggleClass("suppressed"));
|
|
|
|
|
|
|
|
// hide (toggle) everything except for the note content for distraction free writing
|
|
|
|
utils.bindShortcut('alt+t', e => {
|
|
|
|
const date = new Date();
|
|
|
|
const dateString = utils.formatDateTime(date);
|
|
|
|
|
|
|
|
linkService.addTextToEditor(dateString);
|
|
|
|
});
|
|
|
|
|
|
|
|
utils.bindShortcut('f5', utils.reloadApp);
|
|
|
|
|
|
|
|
utils.bindShortcut('ctrl+r', utils.reloadApp);
|
|
|
|
|
|
|
|
$(document).bind('keydown', 'ctrl+shift+i', () => {
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('keydown', 'ctrl+f', () => {
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
const searchInPage = require('electron-in-page-search').default;
|
|
|
|
const remote = require('electron').remote;
|
|
|
|
|
|
|
|
const inPageSearch = searchInPage(remote.getCurrentWebContents());
|
|
|
|
|
|
|
|
inPageSearch.openSearchWindow();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-27 11:48:45 +08:00
|
|
|
// FIXME: do we really need these at this point?
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut("ctrl+shift+up", () => {
|
|
|
|
const node = treeService.getCurrentNode();
|
|
|
|
node.navigate($.ui.keyCode.UP, true);
|
|
|
|
|
2018-03-27 11:48:45 +08:00
|
|
|
$("#note-detail-text").focus();
|
2018-03-27 10:29:14 +08:00
|
|
|
});
|
|
|
|
|
2018-03-27 11:48:45 +08:00
|
|
|
|
|
|
|
// FIXME: do we really need these at this point?
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut("ctrl+shift+down", () => {
|
|
|
|
const node = treeService.getCurrentNode();
|
|
|
|
node.navigate($.ui.keyCode.DOWN, true);
|
|
|
|
|
2018-03-27 11:48:45 +08:00
|
|
|
$("#note-detail-text").focus();
|
2018-03-27 10:29:14 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('keydown', 'ctrl+-', () => {
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
|
|
|
|
if (webFrame.getZoomFactor() > 0.2) {
|
|
|
|
webFrame.setZoomFactor(webFrame.getZoomFactor() - 0.1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('keydown', 'ctrl+=', () => {
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
|
|
|
|
webFrame.setZoomFactor(webFrame.getZoomFactor() + 0.1);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-27 11:48:45 +08:00
|
|
|
$("#note-title").bind('keydown', 'return', () => $("#note-detail-text").focus());
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2018-03-28 10:11:06 +08:00
|
|
|
$("#upload-file-button").click(fileService.uploadFile);
|
2018-03-27 10:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
registerEntrypoints
|
|
|
|
}
|