2018-03-26 22:29:14 -04:00
|
|
|
import utils from "./utils.js";
|
|
|
|
import linkService from "./link.js";
|
2018-06-02 13:02:20 -04:00
|
|
|
import zoomService from "./zoom.js";
|
2018-05-31 20:00:39 -04:00
|
|
|
import protectedSessionService from "./protected_session.js";
|
2019-08-20 21:40:47 +02:00
|
|
|
import searchNotesService from "./search_notes.js";
|
2019-11-10 22:19:22 +01:00
|
|
|
import treeService from "./tree.js";
|
2019-11-21 21:12:07 +01:00
|
|
|
import dateNoteService from "./date_notes.js";
|
|
|
|
import noteDetailService from "./note_detail.js";
|
|
|
|
import keyboardActionService from "./keyboard_actions.js";
|
2019-11-23 23:06:25 +01:00
|
|
|
import hoistedNoteService from "./hoisted_note.js";
|
|
|
|
import treeCache from "./tree_cache.js";
|
2019-12-20 20:13:21 +01:00
|
|
|
import server from "./server.js";
|
2020-01-12 11:15:23 +01:00
|
|
|
import appContext from "./app_context.js";
|
2020-01-21 22:54:16 +01:00
|
|
|
import Component from "../widgets/component.js";
|
2019-08-20 21:40:47 +02:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
export default class Entrypoints extends Component {
|
|
|
|
constructor(appContext) {
|
|
|
|
super(appContext);
|
2018-03-26 22:29:14 -04:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
// 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;
|
2019-02-09 19:25:55 +01:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
$(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');
|
2018-03-26 22:29:14 -04:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
const attributesDialog = await import("../dialogs/note_revisions.js");
|
2018-03-26 22:29:14 -04:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
attributesDialog.showNoteRevisionsDialog(noteId, noteRevisionId);
|
|
|
|
|
|
|
|
return false;
|
2019-11-20 22:48:32 +01:00
|
|
|
});
|
2018-12-10 20:44:50 +01:00
|
|
|
}
|
2019-04-28 21:52:25 +02:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
openDevToolsListener() {
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
|
|
|
}
|
2018-06-02 13:02:20 -04:00
|
|
|
}
|
2019-10-10 20:00:06 +02:00
|
|
|
|
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-10-10 20:00:06 +02:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
zoomOutListener() {
|
|
|
|
zoomService.decreaseZoomFactor();
|
|
|
|
}
|
2019-10-10 20:00:06 +02:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
zoomInListener() {
|
|
|
|
zoomService.increaseZoomFactor();
|
|
|
|
}
|
2019-11-10 22:19:22 +01:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
async createNoteIntoDayNoteListener() {
|
2019-11-24 21:40:50 +01:00
|
|
|
const todayNote = await dateNoteService.getTodayNote();
|
2019-11-19 20:53:04 +01:00
|
|
|
|
2019-12-20 20:13:21 +01:00
|
|
|
const {note} = await server.post(`notes/${todayNote.noteId}/children?target=into`, {
|
|
|
|
title: 'new note',
|
|
|
|
content: '',
|
|
|
|
type: 'text',
|
|
|
|
isProtected: todayNote.isProtected
|
2019-11-21 21:12:07 +01:00
|
|
|
});
|
2019-11-24 21:40:50 +01:00
|
|
|
|
2019-12-20 20:13:21 +01:00
|
|
|
await treeService.expandToNote(note.noteId);
|
|
|
|
|
2019-11-24 21:40:50 +01:00
|
|
|
await noteDetailService.openInTab(note.noteId, true);
|
2019-12-28 10:28:12 +01:00
|
|
|
|
|
|
|
noteDetailService.focusAndSelectTitle();
|
2020-01-21 22:54:16 +01:00
|
|
|
}
|
2019-11-23 23:06:25 +01:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
toggleNoteHoistingListener() {
|
2020-01-12 11:15:23 +01:00
|
|
|
const node = appContext.getMainNoteTree().getActiveNode();
|
2019-11-23 23:06:25 +01:00
|
|
|
|
|
|
|
hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {
|
|
|
|
if (node.data.noteId === hoistedNoteId) {
|
|
|
|
hoistedNoteService.unhoist();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const note = await treeCache.getNote(node.data.noteId);
|
|
|
|
|
|
|
|
if (note.type !== 'search') {
|
|
|
|
hoistedNoteService.setHoistedNoteId(node.data.noteId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-01-21 22:54:16 +01:00
|
|
|
}
|
2019-11-19 23:02:54 +01:00
|
|
|
|
2020-01-21 22:54:16 +01:00
|
|
|
copyWithoutFormattingListener() {
|
|
|
|
utils.copySelectionToClipboard();
|
|
|
|
}
|
2018-03-26 22:29:14 -04:00
|
|
|
}
|