mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
removed last global keyboard handlers
This commit is contained in:
parent
370c63986d
commit
11a61325f9
@ -1,12 +1,8 @@
|
|||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import linkService from "./link.js";
|
|
||||||
import zoomService from "./zoom.js";
|
import zoomService from "./zoom.js";
|
||||||
import protectedSessionService from "./protected_session.js";
|
|
||||||
import searchNotesService from "./search_notes.js";
|
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import dateNoteService from "./date_notes.js";
|
import dateNoteService from "./date_notes.js";
|
||||||
import noteDetailService from "./note_detail.js";
|
import noteDetailService from "./note_detail.js";
|
||||||
import keyboardActionService from "./keyboard_actions.js";
|
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import treeCache from "./tree_cache.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
@ -42,10 +38,12 @@ export default class Entrypoints extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findInTextListener() {
|
findInTextListener() {
|
||||||
if (utils.isElectron()) {
|
if (!utils.isElectron()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const {remote} = require('electron');
|
const {remote} = require('electron');
|
||||||
const {FindInPage} = require('electron-find');
|
const {FindInPage} = require('electron-find');
|
||||||
|
|
||||||
const findInPage = new FindInPage(remote.getCurrentWebContents(), {
|
const findInPage = new FindInPage(remote.getCurrentWebContents(), {
|
||||||
offsetTop: 10,
|
offsetTop: 10,
|
||||||
offsetRight: 10,
|
offsetRight: 10,
|
||||||
@ -58,13 +56,6 @@ export default class Entrypoints extends Component {
|
|||||||
textHoverBgColor: '#555',
|
textHoverBgColor: '#555',
|
||||||
caseSelectedColor: 'var(--main-border-color)'
|
caseSelectedColor: 'var(--main-border-color)'
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboardActionService.setGlobalActionHandler("FindInText", () => {
|
|
||||||
if (!glob.activeDialog || !glob.activeDialog.is(":visible")) {
|
|
||||||
findInPage.openFindWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomOutListener() {
|
zoomOutListener() {
|
||||||
|
@ -29,10 +29,6 @@ server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function setGlobalActionHandler(actionName, handler) {
|
|
||||||
console.log("Useless handler for " + actionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setElementActionHandler($el, actionName, handler) {
|
function setElementActionHandler($el, actionName, handler) {
|
||||||
keyboardActionsLoaded.then(() => {
|
keyboardActionsLoaded.then(() => {
|
||||||
const action = keyboardActionRepo[actionName];
|
const action = keyboardActionRepo[actionName];
|
||||||
@ -103,7 +99,6 @@ function updateDisplayedShortcuts($container) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setGlobalActionHandler,
|
|
||||||
setElementActionHandler,
|
setElementActionHandler,
|
||||||
triggerAction,
|
triggerAction,
|
||||||
getAction,
|
getAction,
|
||||||
|
@ -374,9 +374,6 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
|
|||||||
window.cutToNote.removeSelection();
|
window.cutToNote.removeSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
|
||||||
await noteDetailService.saveNotesIfChanged();
|
|
||||||
|
|
||||||
noteDetailService.addDetailLoadedListener(note.noteId, noteDetailService.focusAndSelectTitle);
|
noteDetailService.addDetailLoadedListener(note.noteId, noteDetailService.focusAndSelectTitle);
|
||||||
|
|
||||||
const noteEntity = await treeCache.getNote(note.noteId);
|
const noteEntity = await treeCache.getNote(note.noteId);
|
||||||
@ -510,32 +507,6 @@ ws.subscribeToOutsideSyncMessages(async syncData => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboardActionService.setGlobalActionHandler('CreateNoteAfter', async () => {
|
|
||||||
const node = appContext.getMainNoteTree().getActiveNode();
|
|
||||||
const parentNoteId = node.data.parentNoteId;
|
|
||||||
const isProtected = await treeUtils.getParentProtectedStatus(node);
|
|
||||||
|
|
||||||
if (node.data.noteId === 'root' || node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await createNote(node, parentNoteId, 'after', {
|
|
||||||
isProtected: isProtected,
|
|
||||||
saveSelection: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
async function createNoteInto(saveSelection = false) {
|
|
||||||
const node = appContext.getMainNoteTree().getActiveNode();
|
|
||||||
|
|
||||||
if (node) {
|
|
||||||
await createNote(node, node.data.noteId, 'into', {
|
|
||||||
isProtected: node.data.isProtected,
|
|
||||||
saveSelection: saveSelection
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function reloadNotes(noteIds, activateNotePath = null) {
|
async function reloadNotes(noteIds, activateNotePath = null) {
|
||||||
if (noteIds.length === 0) {
|
if (noteIds.length === 0) {
|
||||||
return;
|
return;
|
||||||
@ -550,12 +521,6 @@ async function reloadNotes(noteIds, activateNotePath = null) {
|
|||||||
appContext.trigger('notesReloaded', { noteIds, activateNotePath });
|
appContext.trigger('notesReloaded', { noteIds, activateNotePath });
|
||||||
}
|
}
|
||||||
|
|
||||||
window.glob.cutIntoNote = () => createNoteInto(true);
|
|
||||||
|
|
||||||
keyboardActionService.setGlobalActionHandler('CutIntoNote', () => createNoteInto(true));
|
|
||||||
|
|
||||||
keyboardActionService.setGlobalActionHandler('CreateNoteInto', createNoteInto);
|
|
||||||
|
|
||||||
$(window).bind('hashchange', async function() {
|
$(window).bind('hashchange', async function() {
|
||||||
if (isNotePathInAddress()) {
|
if (isNotePathInAddress()) {
|
||||||
const [notePath, tabId] = getHashValueFromAddress();
|
const [notePath, tabId] = getHashValueFromAddress();
|
||||||
|
@ -10,6 +10,8 @@ class BasicWidget extends Component {
|
|||||||
$widget.find("[data-trigger-event]").on('click', e => {
|
$widget.find("[data-trigger-event]").on('click', e => {
|
||||||
const eventName = $(e.target).attr('data-trigger-event');
|
const eventName = $(e.target).attr('data-trigger-event');
|
||||||
|
|
||||||
|
console.log("Triggering " + eventName);
|
||||||
|
|
||||||
this.appContext.trigger(eventName);
|
this.appContext.trigger(eventName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ const TPL = `
|
|||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a class="dropdown-item options-button">
|
<a class="dropdown-item options-button" data-trigger-event="showOptions">
|
||||||
<span class="bx bx-slider"></span>
|
<span class="bx bx-slider"></span>
|
||||||
Options
|
Options
|
||||||
</a>
|
</a>
|
||||||
@ -45,38 +45,38 @@ const TPL = `
|
|||||||
<kbd data-kb-action="OpenDevTools"></kbd>
|
<kbd data-kb-action="OpenDevTools"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item open-sql-console-button" data-trigger-event="showSQLConsole">
|
<a class="dropdown-item" data-trigger-event="showSQLConsole">
|
||||||
<span class="bx bx-data"></span>
|
<span class="bx bx-data"></span>
|
||||||
Open SQL Console
|
Open SQL Console
|
||||||
<kbd data-kb-action="ShowSQLConsole"></kbd>
|
<kbd data-kb-action="ShowSQLConsole"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item show-backend-log-button" data-trigger-event="showBackendLog">
|
<a class="dropdown-item" data-trigger-event="showBackendLog">
|
||||||
<span class="bx bx-empty"></span>
|
<span class="bx bx-empty"></span>
|
||||||
Show backend log
|
Show backend log
|
||||||
<kbd data-kb-action="ShowBackendLog"></kbd>
|
<kbd data-kb-action="ShowBackendLog"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item reload-frontend-button" data-trigger-event="reloadFrontendApp"
|
<a class="dropdown-item" data-trigger-event="reloadFrontendApp"
|
||||||
title="Reload can help with some visual glitches without restarting the whole app.">
|
title="Reload can help with some visual glitches without restarting the whole app.">
|
||||||
<span class="bx bx-empty"></span>
|
<span class="bx bx-empty"></span>
|
||||||
Reload frontend
|
Reload frontend
|
||||||
<kbd data-kb-action="ReloadFrontendApp"></kbd>
|
<kbd data-kb-action="ReloadFrontendApp"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item toggle-zen-mode-button" data-trigger-event="toggleZenMode">
|
<a class="dropdown-item" data-trigger-event="toggleZenMode">
|
||||||
<span class="bx bx-empty"></span>
|
<span class="bx bx-empty"></span>
|
||||||
Toggle Zen mode
|
Toggle Zen mode
|
||||||
<kbd data-kb-action="ToggleZenMode"></kbd>
|
<kbd data-kb-action="ToggleZenMode"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item toggle-fullscreen-button" data-trigger-event="toggleFullscreen">
|
<a class="dropdown-item" data-trigger-event="toggleFullscreen">
|
||||||
<span class="bx bx-empty"></span>
|
<span class="bx bx-empty"></span>
|
||||||
Toggle fullscreen
|
Toggle fullscreen
|
||||||
<kbd data-kb-action="ToggleFullscreen"></kbd>
|
<kbd data-kb-action="ToggleFullscreen"></kbd>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item show-help-button" data-trigger-event="showHelp">
|
<a class="dropdown-item" data-trigger-event="showHelp">
|
||||||
<span class="bx bx-info-circle"></span>
|
<span class="bx bx-info-circle"></span>
|
||||||
Show Help
|
Show Help
|
||||||
<kbd data-kb-action="ShowHelp"></kbd>
|
<kbd data-kb-action="ShowHelp"></kbd>
|
||||||
@ -97,7 +97,7 @@ const TPL = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default class GlobalMenuWidget extends BasicWidget {
|
export default class GlobalMenuWidget extends BasicWidget {
|
||||||
render() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
this.$widget.find(".show-about-dialog-button").on('click',
|
this.$widget.find(".show-about-dialog-button").on('click',
|
||||||
|
@ -17,7 +17,7 @@ const TPL = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default class HistoryNavigationWidget extends BasicWidget {
|
export default class HistoryNavigationWidget extends BasicWidget {
|
||||||
render() {
|
doRender() {
|
||||||
if (!utils.isElectron()) {
|
if (!utils.isElectron()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import BasicWidget from "./basic_widget.js";
|
|
||||||
import hoistedNoteService from "../services/hoisted_note.js";
|
import hoistedNoteService from "../services/hoisted_note.js";
|
||||||
import searchNotesService from "../services/search_notes.js";
|
import searchNotesService from "../services/search_notes.js";
|
||||||
import treeService from "../services/tree.js";
|
import treeService from "../services/tree.js";
|
||||||
@ -34,6 +33,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
constructor(appContext) {
|
constructor(appContext) {
|
||||||
super(appContext);
|
super(appContext);
|
||||||
|
|
||||||
|
window.glob.cutIntoNote = () => this.cutIntoNoteListener();
|
||||||
|
|
||||||
this.tree = null;
|
this.tree = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,4 +454,41 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
treeService.setNodeTitleWithPrefix(node);
|
treeService.setNodeTitleWithPrefix(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createNoteAfterListener() {
|
||||||
|
const node = this.getActiveNode();
|
||||||
|
const parentNoteId = node.data.parentNoteId;
|
||||||
|
const isProtected = await treeUtils.getParentProtectedStatus(node);
|
||||||
|
|
||||||
|
if (node.data.noteId === 'root' || node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await treeService.createNote(node, parentNoteId, 'after', {
|
||||||
|
isProtected: isProtected,
|
||||||
|
saveSelection: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async createNoteIntoListener() {
|
||||||
|
const node = this.getActiveNode();
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
await treeService.createNote(node, node.data.noteId, 'into', {
|
||||||
|
isProtected: node.data.isProtected,
|
||||||
|
saveSelection: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async cutIntoNoteListener() {
|
||||||
|
const node = this.getActiveNode();
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
await treeService.createNote(node, node.data.noteId, 'into', {
|
||||||
|
isProtected: node.data.isProtected,
|
||||||
|
saveSelection: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -64,7 +64,7 @@ const TPL = `
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class StandardTopWidget extends BasicWidget {
|
export default class StandardTopWidget extends BasicWidget {
|
||||||
render() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
const historyNavigationWidget = new HistoryNavigationWidget(this.appContext);
|
const historyNavigationWidget = new HistoryNavigationWidget(this.appContext);
|
||||||
|
@ -18,7 +18,7 @@ const TPL = `
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class TitleBarButtonsWidget extends BasicWidget {
|
export default class TitleBarButtonsWidget extends BasicWidget {
|
||||||
render() {
|
doRender() {
|
||||||
if (!utils.isElectron()) {
|
if (!utils.isElectron()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user