mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
launchbar WIP
This commit is contained in:
parent
8d608c3c1c
commit
fc920becac
@ -25,11 +25,13 @@ export default class ShortcutContextMenu {
|
||||
|
||||
async getMenuItems() {
|
||||
const note = await froca.getNote(this.node.data.noteId);
|
||||
const parentNoteId = this.node.getParent().data.noteId;
|
||||
|
||||
const isLbRoot = note.noteId === 'lb_root';
|
||||
const isVisibleRoot = note.noteId === 'lb_visibleshortcuts';
|
||||
const isAvailableRoot = note.noteId === 'lb_availableshortcuts';
|
||||
const isVisibleItem = this.node.getParent().data.noteId === 'lb_visibleshortcuts';
|
||||
const isAvailableItem = this.node.getParent().data.noteId === 'lb_availableshortcuts';
|
||||
const isVisibleItem = parentNoteId === 'lb_visibleshortcuts';
|
||||
const isAvailableItem = parentNoteId === 'lb_availableshortcuts';
|
||||
const isItem = isVisibleItem || isAvailableItem;
|
||||
|
||||
return [
|
||||
|
@ -124,7 +124,10 @@ async function moveNodeUpInHierarchy(node) {
|
||||
return;
|
||||
}
|
||||
|
||||
const resp = await server.put('branches/' + node.data.branchId + '/move-after/' + node.getParent().data.branchId);
|
||||
const targetBranchId = node.getParent().data.branchId;
|
||||
const branchIdToMove = node.data.branchId;
|
||||
|
||||
const resp = await server.put(`branches/${branchIdToMove}/move-after/${targetBranchId}`);
|
||||
|
||||
if (!resp.success) {
|
||||
alert(resp.message);
|
||||
|
@ -1508,4 +1508,32 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
noteCreateService.duplicateSubtree(nodeToDuplicate.data.noteId, branch.parentNoteId);
|
||||
}
|
||||
}
|
||||
|
||||
moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {
|
||||
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visibleshortcuts');
|
||||
}
|
||||
|
||||
moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {
|
||||
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availableshortcuts');
|
||||
}
|
||||
|
||||
addNoteShortcutCommand({node}) {
|
||||
this.createShortcutNote(node, 'note');
|
||||
}
|
||||
|
||||
addWidgetShortcutCommand({node}) {
|
||||
this.createShortcutNote(node, 'widget');
|
||||
}
|
||||
|
||||
addSpacerShortcutCommand({node}) {
|
||||
this.createShortcutNote(node, 'spacer');
|
||||
}
|
||||
|
||||
async createShortcutNote(node, type) {
|
||||
const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${type}`);
|
||||
|
||||
if (!resp.success) {
|
||||
alert(resp.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,10 @@ function getHoistedNote() {
|
||||
return becca.getNote(cls.getHoistedNoteId());
|
||||
}
|
||||
|
||||
function createShortcut(req) {
|
||||
return specialNotesService.createShortcut(req.params.parentNoteId, req.params.type);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getInboxNote,
|
||||
getDayNote,
|
||||
@ -76,5 +80,6 @@ module.exports = {
|
||||
createSqlConsole,
|
||||
saveSqlConsole,
|
||||
createSearchNote,
|
||||
saveSearchNote
|
||||
saveSearchNote,
|
||||
createShortcut
|
||||
};
|
||||
|
@ -293,6 +293,7 @@ function register(app) {
|
||||
apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);
|
||||
apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
|
||||
apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
|
||||
apiRoute(POST, '/api/special-notes/shortcuts/:parentNoteId/:type', specialNotesRoute.createShortcut);
|
||||
|
||||
// :filename is not used by trilium, but instead used for "save as" to assign a human readable filename
|
||||
route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
|
||||
|
@ -347,7 +347,6 @@ function createMissingSpecialNotes() {
|
||||
|
||||
const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
|
||||
note = noteService.createNewNote({
|
||||
branchId: shortcut.id,
|
||||
noteId: shortcut.id,
|
||||
title: shortcut.title,
|
||||
type: 'shortcut',
|
||||
@ -383,6 +382,12 @@ function createMissingSpecialNotes() {
|
||||
}
|
||||
}
|
||||
|
||||
function createShortcut(parentNoteId, type) {
|
||||
if (type === 'note') {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getInboxNote,
|
||||
createSqlConsole,
|
||||
@ -392,4 +397,5 @@ module.exports = {
|
||||
createMissingSpecialNotes,
|
||||
getShareRoot,
|
||||
getBulkActionNote,
|
||||
createShortcut
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user