mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 17:38:47 +02:00
launchbar WIP
This commit is contained in:
parent
42cade17cb
commit
7696702a2a
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,7 +5,6 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trilium",
|
||||
"version": "0.54.1-beta",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
|
@ -817,6 +817,12 @@ class NoteShort {
|
||||
isContentAvailable() {
|
||||
return !this.isProtected || protectedSessionHolder.isProtectedSessionAvailable()
|
||||
}
|
||||
|
||||
isLaunchBarConfig() {
|
||||
// launch bar config should be max 2 levels deep
|
||||
return this.noteId.startsWith("lb_")
|
||||
|| this.getParentBranchIds().find(branchId => branchId.startsWith("lb_"));
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteShort;
|
||||
|
@ -33,9 +33,9 @@ export default class ShortcutContextMenu {
|
||||
const isItem = isVisibleItem || isAvailableItem;
|
||||
|
||||
return [
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut' } : null,
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut' } : null,
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer' } : null,
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut' } : null,
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut' } : null,
|
||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut' } : null,
|
||||
{ title: "----" },
|
||||
{ title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash",
|
||||
enabled: isItem },
|
||||
|
@ -36,7 +36,7 @@ const TPL = `
|
||||
|
||||
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
isEnabled() {
|
||||
return true;
|
||||
return !this.note?.isLaunchBarConfig();
|
||||
}
|
||||
|
||||
doRender() {
|
||||
|
@ -3,6 +3,10 @@ import froca from "../../services/froca.js";
|
||||
import ButtonWidget from "../buttons/button_widget.js";
|
||||
import CalendarWidget from "../buttons/calendar.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
import SpacerWidget from "../spacer.js";
|
||||
import BookmarkButtons from "../bookmark_buttons.js";
|
||||
import ProtectedSessionStatusWidget from "../buttons/protected_session_status.js";
|
||||
import SyncStatusWidget from "../sync_status.js";
|
||||
|
||||
export default class ShortcutContainer extends FlexContainer {
|
||||
constructor() {
|
||||
@ -37,6 +41,18 @@ export default class ShortcutContainer extends FlexContainer {
|
||||
if (builtinWidget) {
|
||||
if (builtinWidget === 'calendar') {
|
||||
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
|
||||
} else if (builtinWidget === 'spacer') {
|
||||
this.child(new SpacerWidget(40, 10));
|
||||
} else if (builtinWidget === 'pluginButtons') {
|
||||
this.child(new FlexContainer("column")
|
||||
.id("plugin-buttons")
|
||||
.contentSized());
|
||||
} else if (builtinWidget === 'bookmarks') {
|
||||
this.child(new BookmarkButtons());
|
||||
} else if (builtinWidget === 'protectedSession') {
|
||||
this.child(new ProtectedSessionStatusWidget());
|
||||
} else if (builtinWidget === 'syncStatus') {
|
||||
this.child(new SyncStatusWidget());
|
||||
} else {
|
||||
console.log(`Unrecognized builtin widget ${builtinWidget} for shortcut ${shortcut.noteId} "${shortcut.title}"`);
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
|
||||
const note = await froca.getNote(node.data.noteId, true);
|
||||
|
||||
if (!note || note.isDeleted) {
|
||||
if (!note || note.isDeleted || note.isLaunchBarConfig()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -68,13 +68,9 @@ export default class BasicPropertiesWidget extends NoteContextAwareWidget {
|
||||
return "toggleRibbonBasicProperties";
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return this.note;
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
return {
|
||||
show: this.isEnabled(),
|
||||
show: !this.note.isLaunchBarConfig(),
|
||||
title: 'Basic Properties',
|
||||
icon: 'bx bx-slider'
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ export default class InheritedAttributesWidget extends NoteContextAwareWidget {
|
||||
|
||||
getTitle() {
|
||||
return {
|
||||
show: true,
|
||||
show: !this.note.isLaunchBarConfig(),
|
||||
title: "Inherited attributes",
|
||||
icon: "bx bx-list-plus"
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
|
||||
|
||||
getTitle() {
|
||||
return {
|
||||
show: true,
|
||||
show: !this.note.isLaunchBarConfig(),
|
||||
title: "Owned attributes",
|
||||
icon: "bx bx-list-check"
|
||||
};
|
||||
|
@ -248,6 +248,8 @@ function getLaunchBarRoot() {
|
||||
content: '',
|
||||
parentNoteId: getHiddenRoot().noteId
|
||||
}).note;
|
||||
|
||||
note.addLabel("iconClass", "bx bx-sidebar");
|
||||
}
|
||||
|
||||
return note;
|
||||
@ -265,6 +267,8 @@ function getLaunchBarAvailableShortcutsRoot() {
|
||||
content: '',
|
||||
parentNoteId: getLaunchBarRoot().noteId
|
||||
}).note;
|
||||
|
||||
note.addLabel("iconClass", "bx bx-hide");
|
||||
}
|
||||
|
||||
const branch = becca.getBranch('lb_availableshortcuts');
|
||||
@ -288,6 +292,8 @@ function getLaunchBarVisibleShortcutsRoot() {
|
||||
content: '',
|
||||
parentNoteId: getLaunchBarRoot().noteId
|
||||
}).note;
|
||||
|
||||
note.addLabel("iconClass", "bx bx-show");
|
||||
}
|
||||
|
||||
const branch = becca.getBranch('lb_visibleshortcuts');
|
||||
@ -306,6 +312,12 @@ const shortcuts = [
|
||||
{ id: 'lb_notemap', targetNoteId: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
|
||||
{ id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Recent changes', icon: 'bx bx-history', isVisible: false },
|
||||
{ id: 'lb_calendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true },
|
||||
{ id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', icon: 'bx bx-move-vertical', isVisible: true },
|
||||
{ id: 'lb_pluginbuttons', builtinWidget: 'pluginButtons', title: 'Plugin buttons', icon: 'bx bx-move-vertical', isVisible: true },
|
||||
{ id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true },
|
||||
{ id: 'lb_spacer2', builtinWidget: 'spacer', title: 'Spacer', icon: 'bx bx-move-vertical', isVisible: true },
|
||||
{ id: 'lb_protectedsession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', isVisible: true },
|
||||
{ id: 'lb_syncstatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true },
|
||||
];
|
||||
|
||||
function createMissingSpecialNotes() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user