mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
small fixes
This commit is contained in:
parent
e7af24c139
commit
f2cf361acf
@ -45,14 +45,14 @@ class AppContext extends Component {
|
|||||||
this.triggerEvent(eventName);
|
this.triggerEvent(eventName);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.children = [ rootWidget ];
|
|
||||||
|
|
||||||
this.executors = [
|
this.executors = [
|
||||||
this.tabManager,
|
this.tabManager,
|
||||||
new DialogCommandExecutor(this),
|
new DialogCommandExecutor(this),
|
||||||
new Entrypoints(this)
|
new Entrypoints(this)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.children = [ rootWidget, ...this.executors ];
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
this.children.push(new ZoomService(this));
|
this.children.push(new ZoomService(this));
|
||||||
|
|
||||||
@ -75,7 +75,9 @@ class AppContext extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(`Unhandled command ${name}`);
|
console.debug(`Unhandled command ${name}, converting to event.`);
|
||||||
|
|
||||||
|
await this.triggerEvent(name, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
getComponentByEl(el) {
|
getComponentByEl(el) {
|
||||||
|
@ -60,18 +60,15 @@ async function pasteInto(parentNoteId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy(nodes) {
|
function copy(branchIds) {
|
||||||
clipboardBranchIds = nodes.map(node => node.data.branchId);
|
clipboardBranchIds = branchIds;
|
||||||
clipboardMode = 'copy';
|
clipboardMode = 'copy';
|
||||||
|
|
||||||
toastService.showMessage("Note(s) have been copied into clipboard.");
|
toastService.showMessage("Note(s) have been copied into clipboard.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function cut(nodes) {
|
function cut(branchIds) {
|
||||||
clipboardBranchIds = nodes
|
clipboardBranchIds = branchIds;
|
||||||
.filter(node => node.data.noteId !== hoistedNoteService.getHoistedNoteId())
|
|
||||||
.filter(node => node.getParent().data.noteType !== 'search')
|
|
||||||
.map(node => node.key);
|
|
||||||
|
|
||||||
if (clipboardBranchIds.length > 0) {
|
if (clipboardBranchIds.length > 0) {
|
||||||
clipboardMode = 'cut';
|
clipboardMode = 'cut';
|
||||||
|
@ -621,22 +621,26 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
// after opening context menu, standard shortcuts don't work, but they are detected here
|
// after opening context menu, standard shortcuts don't work, but they are detected here
|
||||||
// so we essentially takeover the standard handling with our implementation.
|
// so we essentially takeover the standard handling with our implementation.
|
||||||
"left": node => {
|
"left": node => {
|
||||||
node.navigate($.ui.keyCode.LEFT, true).then(this.clearSelectedNodes);
|
node.navigate($.ui.keyCode.LEFT, true);
|
||||||
|
this.clearSelectedNodes();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
"right": node => {
|
"right": node => {
|
||||||
node.navigate($.ui.keyCode.RIGHT, true).then(this.clearSelectedNodes);
|
node.navigate($.ui.keyCode.RIGHT, true);
|
||||||
|
this.clearSelectedNodes();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
"up": node => {
|
"up": node => {
|
||||||
node.navigate($.ui.keyCode.UP, true).then(this.clearSelectedNodes);
|
node.navigate($.ui.keyCode.UP, true);
|
||||||
|
this.clearSelectedNodes();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
"down": node => {
|
"down": node => {
|
||||||
node.navigate($.ui.keyCode.DOWN, true).then(this.clearSelectedNodes);
|
node.navigate($.ui.keyCode.DOWN, true);
|
||||||
|
this.clearSelectedNodes();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -647,6 +651,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
hotKeyMap[shortcut] = node => this.triggerCommand(action.actionName, {node});
|
hotKeyMap[shortcut] = node => this.triggerCommand(action.actionName, {node});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hotKeyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +167,7 @@ export default class SearchBoxWidget extends BasicWidget {
|
|||||||
this.$searchInput.val("");
|
this.$searchInput.val("");
|
||||||
}
|
}
|
||||||
|
|
||||||
searchInSubtreeCommand({noteId}) {
|
searchInSubtreeEvent({noteId}) {
|
||||||
noteId = noteId || appContext.tabManager.getActiveTabNoteId();
|
noteId = noteId || appContext.tabManager.getActiveTabNoteId();
|
||||||
|
|
||||||
this.toggle(true);
|
this.toggle(true);
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
const sql = require('../../services/sql');
|
const sql = require('../../services/sql');
|
||||||
const utils = require('../../services/utils');
|
const utils = require('../../services/utils');
|
||||||
const syncTableService = require('../../services/sync_table');
|
const syncTableService = require('../../services/sync_table');
|
||||||
const tree = require('../../services/tree');
|
const treeService = require('../../services/tree');
|
||||||
const notes = require('../../services/notes');
|
const noteService = require('../../services/notes');
|
||||||
const repository = require('../../services/repository');
|
const repository = require('../../services/repository');
|
||||||
const TaskContext = require('../../services/task_context');
|
const TaskContext = require('../../services/task_context');
|
||||||
|
|
||||||
@ -16,13 +16,13 @@ const TaskContext = require('../../services/task_context');
|
|||||||
async function moveBranchToParent(req) {
|
async function moveBranchToParent(req) {
|
||||||
const {branchId, parentNoteId} = req.params;
|
const {branchId, parentNoteId} = req.params;
|
||||||
|
|
||||||
const branchToMove = await tree.getBranch(branchId);
|
const branchToMove = await repository.getBranch(branchId);
|
||||||
|
|
||||||
if (branchToMove.parentNoteId === parentNoteId) {
|
if (branchToMove.parentNoteId === parentNoteId) {
|
||||||
return { success: true }; // no-op
|
return { success: true }; // no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationResult = await tree.validateParentChild(parentNoteId, branchToMove.noteId, branchId);
|
const validationResult = await treeService.validateParentChild(parentNoteId, branchToMove.noteId, branchId);
|
||||||
|
|
||||||
if (!validationResult.success) {
|
if (!validationResult.success) {
|
||||||
return [200, validationResult];
|
return [200, validationResult];
|
||||||
@ -43,10 +43,10 @@ async function moveBranchToParent(req) {
|
|||||||
async function moveBranchBeforeNote(req) {
|
async function moveBranchBeforeNote(req) {
|
||||||
const {branchId, beforeBranchId} = req.params;
|
const {branchId, beforeBranchId} = req.params;
|
||||||
|
|
||||||
const branchToMove = await tree.getBranch(branchId);
|
const branchToMove = await repository.getBranch(branchId);
|
||||||
const beforeNote = await tree.getBranch(beforeBranchId);
|
const beforeNote = await repository.getBranch(beforeBranchId);
|
||||||
|
|
||||||
const validationResult = await tree.validateParentChild(beforeNote.parentNoteId, branchToMove.noteId, branchId);
|
const validationResult = await treeService.validateParentChild(beforeNote.parentNoteId, branchToMove.noteId, branchId);
|
||||||
|
|
||||||
if (!validationResult.success) {
|
if (!validationResult.success) {
|
||||||
return [200, validationResult];
|
return [200, validationResult];
|
||||||
@ -77,10 +77,10 @@ async function moveBranchBeforeNote(req) {
|
|||||||
async function moveBranchAfterNote(req) {
|
async function moveBranchAfterNote(req) {
|
||||||
const {branchId, afterBranchId} = req.params;
|
const {branchId, afterBranchId} = req.params;
|
||||||
|
|
||||||
const branchToMove = await tree.getBranch(branchId);
|
const branchToMove = await repository.getBranch(branchId);
|
||||||
const afterNote = await tree.getBranch(afterBranchId);
|
const afterNote = await repository.getBranch(afterBranchId);
|
||||||
|
|
||||||
const validationResult = await tree.validateParentChild(afterNote.parentNoteId, branchToMove.noteId, branchId);
|
const validationResult = await treeService.validateParentChild(afterNote.parentNoteId, branchToMove.noteId, branchId);
|
||||||
|
|
||||||
if (!validationResult.success) {
|
if (!validationResult.success) {
|
||||||
return [200, validationResult];
|
return [200, validationResult];
|
||||||
@ -123,7 +123,7 @@ async function deleteBranch(req) {
|
|||||||
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
||||||
|
|
||||||
const deleteId = utils.randomString(10);
|
const deleteId = utils.randomString(10);
|
||||||
const noteDeleted = await notes.deleteBranch(branch, deleteId, taskContext);
|
const noteDeleted = await noteService.deleteBranch(branch, deleteId, taskContext);
|
||||||
|
|
||||||
if (last) {
|
if (last) {
|
||||||
taskContext.taskSucceeded();
|
taskContext.taskSucceeded();
|
||||||
|
@ -70,7 +70,7 @@ async function toggleNoteInParent(present, noteId, parentNoteId, prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function cloneNoteAfter(noteId, afterBranchId) {
|
async function cloneNoteAfter(noteId, afterBranchId) {
|
||||||
const afterNote = await treeService.getBranch(afterBranchId);
|
const afterNote = await repository.getBranch(afterBranchId);
|
||||||
|
|
||||||
if (await isNoteDeleted(noteId) || await isNoteDeleted(afterNote.parentNoteId)) {
|
if (await isNoteDeleted(noteId) || await isNoteDeleted(afterNote.parentNoteId)) {
|
||||||
return { success: false, message: 'Note is deleted.' };
|
return { success: false, message: 'Note is deleted.' };
|
||||||
|
@ -99,10 +99,6 @@ async function checkTreeCycle(parentNoteId, childNoteId) {
|
|||||||
return await checkTreeCycleInner(parentNoteId);
|
return await checkTreeCycleInner(parentNoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBranch(branchId) {
|
|
||||||
return sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadSubtreeNoteIds(parentNoteId, subtreeNoteIds) {
|
async function loadSubtreeNoteIds(parentNoteId, subtreeNoteIds) {
|
||||||
subtreeNoteIds.push(parentNoteId);
|
subtreeNoteIds.push(parentNoteId);
|
||||||
|
|
||||||
@ -199,7 +195,6 @@ async function setNoteToParent(noteId, prefix, parentNoteId) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getNotes,
|
getNotes,
|
||||||
validateParentChild,
|
validateParentChild,
|
||||||
getBranch,
|
|
||||||
sortNotesAlphabetically,
|
sortNotesAlphabetically,
|
||||||
setNoteToParent
|
setNoteToParent
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user