|
|
|
|
@ -11,95 +11,72 @@ import hoistedNoteService from "./hoisted_note.js";
|
|
|
|
|
import treeCache from "./tree_cache.js";
|
|
|
|
|
import server from "./server.js";
|
|
|
|
|
import appContext from "./app_context.js";
|
|
|
|
|
import Component from "../widgets/component.js";
|
|
|
|
|
|
|
|
|
|
const NOTE_REVISIONS = "../dialogs/note_revisions.js";
|
|
|
|
|
const OPTIONS = "../dialogs/options.js";
|
|
|
|
|
const ADD_LINK = "../dialogs/add_link.js";
|
|
|
|
|
const JUMP_TO_NOTE = "../dialogs/jump_to_note.js";
|
|
|
|
|
const NOTE_SOURCE = "../dialogs/note_source.js";
|
|
|
|
|
const RECENT_CHANGES = "../dialogs/recent_changes.js";
|
|
|
|
|
const SQL_CONSOLE = "../dialogs/sql_console.js";
|
|
|
|
|
const BACKEND_LOG = "../dialogs/backend_log.js";
|
|
|
|
|
const ATTRIBUTES = "../dialogs/attributes.js";
|
|
|
|
|
const HELP = "../dialogs/help.js";
|
|
|
|
|
const NOTE_INFO = "../dialogs/note_info.js";
|
|
|
|
|
const ABOUT = "../dialogs/about.js";
|
|
|
|
|
const LINK_MAP = "../dialogs/link_map.js";
|
|
|
|
|
const CLONE_TO = "../dialogs/clone_to.js";
|
|
|
|
|
const MOVE_TO = "../dialogs/move_to.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;
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler('SearchNotes', searchNotesService.toggleSearch);
|
|
|
|
|
|
|
|
|
|
const $noteTabContainer = $("#note-tab-container");
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("InsertDateTimeToText", () => {
|
|
|
|
|
const date = new Date();
|
|
|
|
|
const dateString = utils.formatDateTime(date);
|
|
|
|
|
|
|
|
|
|
linkService.addTextToEditor(dateString);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
|
const openDevTools = () => {
|
|
|
|
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
|
|
|
|
export default class Entrypoints extends Component {
|
|
|
|
|
constructor(appContext) {
|
|
|
|
|
super(appContext);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
$("#open-dev-tools-button").on('click', openDevTools);
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("OpenDevTools", openDevTools);
|
|
|
|
|
}
|
|
|
|
|
$(document).on('click', "a[data-action='note-revision']", async event => {
|
|
|
|
|
const linkEl = $(event.target);
|
|
|
|
|
const noteId = linkEl.attr('data-note-path');
|
|
|
|
|
const noteRevisionId = linkEl.attr('data-note-revision-id');
|
|
|
|
|
|
|
|
|
|
let findInPage;
|
|
|
|
|
|
|
|
|
|
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)'
|
|
|
|
|
});
|
|
|
|
|
const attributesDialog = await import("../dialogs/note_revisions.js");
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("FindInText", () => {
|
|
|
|
|
if (!glob.activeDialog || !glob.activeDialog.is(":visible")) {
|
|
|
|
|
findInPage.openFindWindow();
|
|
|
|
|
}
|
|
|
|
|
attributesDialog.showNoteRevisionsDialog(noteId, noteRevisionId);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("ZoomOut", zoomService.decreaseZoomFactor);
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("ZoomIn", zoomService.increaseZoomFactor);
|
|
|
|
|
openDevToolsListener() {
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('click', "a[data-action='note-revision']", async event => {
|
|
|
|
|
const linkEl = $(event.target);
|
|
|
|
|
const noteId = linkEl.attr('data-note-path');
|
|
|
|
|
const noteRevisionId = linkEl.attr('data-note-revision-id');
|
|
|
|
|
|
|
|
|
|
const attributesDialog = await import("../dialogs/note_revisions.js");
|
|
|
|
|
findInTextListener() {
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
|
const {remote} = require('electron');
|
|
|
|
|
const {FindInPage} = require('electron-find');
|
|
|
|
|
|
|
|
|
|
const 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)'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("FindInText", () => {
|
|
|
|
|
if (!glob.activeDialog || !glob.activeDialog.is(":visible")) {
|
|
|
|
|
findInPage.openFindWindow();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
attributesDialog.showNoteRevisionsDialog(noteId, noteRevisionId);
|
|
|
|
|
zoomOutListener() {
|
|
|
|
|
zoomService.decreaseZoomFactor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
zoomInListener() {
|
|
|
|
|
zoomService.increaseZoomFactor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("CreateNoteIntoDayNote", async () => {
|
|
|
|
|
async createNoteIntoDayNoteListener() {
|
|
|
|
|
const todayNote = await dateNoteService.getTodayNote();
|
|
|
|
|
|
|
|
|
|
const {note} = await server.post(`notes/${todayNote.noteId}/children?target=into`, {
|
|
|
|
|
@ -114,9 +91,9 @@ function registerEntrypoints() {
|
|
|
|
|
await noteDetailService.openInTab(note.noteId, true);
|
|
|
|
|
|
|
|
|
|
noteDetailService.focusAndSelectTitle();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("ToggleNoteHoisting", async () => {
|
|
|
|
|
toggleNoteHoistingListener() {
|
|
|
|
|
const node = appContext.getMainNoteTree().getActiveNode();
|
|
|
|
|
|
|
|
|
|
hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {
|
|
|
|
|
@ -131,19 +108,9 @@ function registerEntrypoints() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("SearchInSubtree", () => {
|
|
|
|
|
const node = appContext.getMainNoteTree().getActiveNode();
|
|
|
|
|
|
|
|
|
|
searchNotesService.searchInSubtree(node.data.noteId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler('CollapseTree', () => appContext.getMainNoteTree().collapseTree());
|
|
|
|
|
|
|
|
|
|
keyboardActionService.setGlobalActionHandler("CopyWithoutFormatting", utils.copySelectionToClipboard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
registerEntrypoints
|
|
|
|
|
copyWithoutFormattingListener() {
|
|
|
|
|
utils.copySelectionToClipboard();
|
|
|
|
|
}
|
|
|
|
|
}
|