2018-03-27 10:29:14 +08:00
|
|
|
import utils from "./utils.js";
|
|
|
|
import treeService from "./tree.js";
|
|
|
|
import linkService from "./link.js";
|
2018-06-03 01:02:20 +08:00
|
|
|
import zoomService from "./zoom.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 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";
|
2018-06-05 07:48:02 +08:00
|
|
|
import searchNotesService from "./search_notes.js";
|
2018-08-03 17:11:57 +08:00
|
|
|
import attributesDialog from "../dialogs/attributes.js";
|
2019-02-10 17:38:18 +08:00
|
|
|
import helpDialog from "../dialogs/help.js";
|
2019-02-15 03:56:33 +08:00
|
|
|
import noteInfoDialog from "../dialogs/note_info.js";
|
2019-03-25 06:01:33 +08:00
|
|
|
import aboutDialog from "../dialogs/about.js";
|
2018-06-01 08:00:39 +08:00
|
|
|
import protectedSessionService from "./protected_session.js";
|
2018-03-27 10:29:14 +08:00
|
|
|
|
|
|
|
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);
|
2019-03-26 04:09:15 +08:00
|
|
|
utils.bindShortcut('ctrl+shift+l', addLinkDialog.showDialogForClone);
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2018-06-06 11:28:10 +08:00
|
|
|
$("#jump-to-note-dialog-button").click(jumpToNoteDialog.showDialog);
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog);
|
|
|
|
|
2019-05-06 00:24:59 +08:00
|
|
|
$("#recent-changes-button").click(recentChangesDialog.showDialog);
|
|
|
|
|
|
|
|
$("#enter-protected-session-button").click(protectedSessionService.enterProtectedSession);
|
|
|
|
$("#leave-protected-session-button").click(protectedSessionService.leaveProtectedSession);
|
|
|
|
|
|
|
|
$("#toggle-search-button").click(searchNotesService.toggleSearch);
|
|
|
|
utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch);
|
|
|
|
|
|
|
|
const $noteTabContainer = $("#note-tab-container");
|
|
|
|
$noteTabContainer.on("click", ".show-attributes-button", attributesDialog.showDialog);
|
|
|
|
utils.bindShortcut('alt+a', attributesDialog.showDialog);
|
|
|
|
|
|
|
|
$noteTabContainer.on("click", ".show-note-info-button", noteInfoDialog.showDialog);
|
|
|
|
|
|
|
|
$noteTabContainer.on("click", ".show-note-revisions-button", function() {
|
2018-11-19 16:54:33 +08:00
|
|
|
if ($(this).hasClass("disabled")) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2018-11-19 16:54:33 +08:00
|
|
|
noteRevisionsDialog.showCurrentNoteRevisions();
|
|
|
|
});
|
|
|
|
|
2019-05-06 00:24:59 +08:00
|
|
|
$noteTabContainer.on("click", ".show-source-button", function() {
|
2018-11-19 16:54:33 +08:00
|
|
|
if ($(this).hasClass("disabled")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
noteSourceDialog.showDialog();
|
|
|
|
});
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2018-04-02 05:41:28 +08:00
|
|
|
$("#options-button").click(optionsDialog.showDialog);
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2019-02-10 17:38:18 +08:00
|
|
|
$("#show-help-button").click(helpDialog.showDialog);
|
2019-02-10 19:19:48 +08:00
|
|
|
utils.bindShortcut('f1', helpDialog.showDialog);
|
2019-02-10 17:38:18 +08:00
|
|
|
|
|
|
|
$("#open-sql-console-button").click(sqlConsoleDialog.showDialog);
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog);
|
|
|
|
|
2019-03-25 06:01:33 +08:00
|
|
|
$("#show-about-dialog-button").click(aboutDialog.showDialog);
|
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
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);
|
|
|
|
|
2019-01-24 03:15:33 +08:00
|
|
|
if (utils.isMac()) {
|
|
|
|
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
|
|
|
utils.bindShortcut('meta+left', window.history.back);
|
|
|
|
utils.bindShortcut('meta+right', window.history.forward);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
utils.bindShortcut('alt+left', window.history.back);
|
|
|
|
utils.bindShortcut('alt+right', window.history.forward);
|
|
|
|
}
|
2018-03-27 10:29:14 +08:00
|
|
|
}
|
|
|
|
|
2018-06-10 22:53:39 +08:00
|
|
|
utils.bindShortcut('alt+m', e => {
|
|
|
|
$(".hide-toggle").toggle();
|
2019-04-29 03:24:13 +08:00
|
|
|
$("#container").toggleClass("distraction-free-mode");
|
2018-06-10 22:53:39 +08:00
|
|
|
});
|
2018-03-27 10:29:14 +08:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2019-04-14 18:48:50 +08:00
|
|
|
$("#reload-frontend-button").click(utils.reloadApp);
|
2018-03-27 10:29:14 +08:00
|
|
|
utils.bindShortcut('ctrl+r', utils.reloadApp);
|
|
|
|
|
2019-02-10 02:25:55 +08:00
|
|
|
$("#open-dev-tools-button").toggle(utils.isElectron());
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
const openDevTools = () => {
|
2018-03-27 10:29:14 +08:00
|
|
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
|
|
|
|
|
|
|
return false;
|
2019-02-10 02:25:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
utils.bindShortcut('ctrl+shift+i', openDevTools);
|
|
|
|
$("#open-dev-tools-button").click(openDevTools);
|
|
|
|
}
|
2018-03-27 10:29:14 +08:00
|
|
|
|
2019-04-03 03:44:56 +08:00
|
|
|
let findInPage;
|
2018-11-22 06:39:19 +08:00
|
|
|
|
2019-04-03 03:44:56 +08:00
|
|
|
if (utils.isElectron()) {
|
|
|
|
const { remote } = require('electron');
|
|
|
|
const { FindInPage } = require('electron-find');
|
|
|
|
|
|
|
|
findInPage = new FindInPage(remote.getCurrentWebContents(), {
|
|
|
|
offsetTop: 10,
|
|
|
|
offsetRight: 10,
|
|
|
|
boxBgColor: 'var(--main-background-color)',
|
|
|
|
boxShadowColor: '#000',
|
|
|
|
inputColor: 'var(--input-text-color)',
|
|
|
|
inputBgColor: 'var(--input-background-color)',
|
|
|
|
inputFocusColor: '#555',
|
|
|
|
textColor: 'var(--main-text-color)',
|
|
|
|
textHoverBgColor: '#555',
|
|
|
|
caseSelectedColor: 'var(--main-border-color)'
|
|
|
|
});
|
|
|
|
}
|
2018-11-22 06:39:19 +08:00
|
|
|
|
2019-04-10 03:16:18 +08:00
|
|
|
if (utils.isElectron()) {
|
|
|
|
utils.bindShortcut('ctrl+f', () => {
|
2019-04-03 03:44:56 +08:00
|
|
|
findInPage.openFindWindow();
|
2018-03-27 10:29:14 +08:00
|
|
|
|
|
|
|
return false;
|
2019-04-10 03:16:18 +08:00
|
|
|
});
|
2018-12-11 03:44:50 +08:00
|
|
|
}
|
|
|
|
|
2019-04-29 03:52:25 +08:00
|
|
|
if (utils.isElectron()) {
|
2019-04-29 03:59:29 +08:00
|
|
|
const toggleFullscreen = function() {
|
2019-04-29 03:52:25 +08:00
|
|
|
const win = require('electron').remote.getCurrentWindow();
|
|
|
|
|
|
|
|
if (win.isFullScreenable()) {
|
|
|
|
win.setFullScreen(!win.isFullScreen());
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-04-29 03:59:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$("#toggle-fullscreen-button").click(toggleFullscreen);
|
|
|
|
|
|
|
|
utils.bindShortcut('f11', toggleFullscreen);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// outside of electron this is handled by the browser
|
|
|
|
$("#toggle-fullscreen-button").hide();
|
2019-04-29 03:52:25 +08:00
|
|
|
}
|
|
|
|
|
2018-06-03 01:02:20 +08:00
|
|
|
if (utils.isElectron()) {
|
2019-01-14 01:57:46 +08:00
|
|
|
utils.bindShortcut('ctrl+-', zoomService.decreaseZoomFactor);
|
|
|
|
utils.bindShortcut('ctrl+=', zoomService.increaseZoomFactor);
|
2018-06-03 01:02:20 +08:00
|
|
|
}
|
2018-03-27 10:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
registerEntrypoints
|
|
|
|
}
|