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
7696702a2a
commit
54900b35dc
@ -33,15 +33,15 @@ export default class ShortcutContextMenu {
|
|||||||
const isItem = isVisibleItem || isAvailableItem;
|
const isItem = isVisibleItem || isAvailableItem;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut' } : null,
|
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut', uiIcon: "bx bx-plus" } : null,
|
||||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut' } : null,
|
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut', uiIcon: "bx bx-plus" } : null,
|
||||||
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut' } : null,
|
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut', uiIcon: "bx bx-plus" } : null,
|
||||||
{ title: "----" },
|
(isVisibleRoot || isAvailableRoot) ? { title: "----" } : null,
|
||||||
{ title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash",
|
{ title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash",
|
||||||
enabled: isItem },
|
enabled: isItem },
|
||||||
{ title: "----" },
|
{ title: "----" },
|
||||||
isAvailableItem ? { title: 'Move to visible shortcuts', command: "moveNotesTo", uiIcon: "bx bx-empty", enabled: true } : null,
|
isAvailableItem ? { title: 'Move to visible shortcuts', command: "moveShortcutToVisible", uiIcon: "bx bx-show", enabled: true } : null,
|
||||||
isVisibleItem ? { title: 'Move to available shortcuts', command: "moveNotesTo", uiIcon: "bx bx-empty", enabled: true } : null,
|
isVisibleItem ? { title: 'Move to available shortcuts', command: "moveShortcutToAvailable", uiIcon: "bx bx-hide", enabled: true } : null,
|
||||||
{ title: `Duplicate shortcut <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty",
|
{ title: `Duplicate shortcut <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty",
|
||||||
enabled: isItem }
|
enabled: isItem }
|
||||||
].filter(row => row !== null);
|
].filter(row => row !== null);
|
||||||
|
@ -42,7 +42,11 @@ export default class ShortcutContainer extends FlexContainer {
|
|||||||
if (builtinWidget === 'calendar') {
|
if (builtinWidget === 'calendar') {
|
||||||
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
|
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
|
||||||
} else if (builtinWidget === 'spacer') {
|
} else if (builtinWidget === 'spacer') {
|
||||||
this.child(new SpacerWidget(40, 10));
|
// || has to be inside since 0 is a valid value
|
||||||
|
const baseSize = parseInt(shortcut.getLabelValue("baseSize") || "40");
|
||||||
|
const growthFactor = parseInt(shortcut.getLabelValue("growthFactor") || "100");
|
||||||
|
|
||||||
|
this.child(new SpacerWidget(baseSize, growthFactor));
|
||||||
} else if (builtinWidget === 'pluginButtons') {
|
} else if (builtinWidget === 'pluginButtons') {
|
||||||
this.child(new FlexContainer("column")
|
this.child(new FlexContainer("column")
|
||||||
.id("plugin-buttons")
|
.id("plugin-buttons")
|
||||||
|
@ -47,7 +47,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
getTitle() {
|
getTitle() {
|
||||||
return {
|
return {
|
||||||
show: !this.note.isLaunchBarConfig(),
|
show: true,//!this.note.isLaunchBarConfig(),
|
||||||
title: "Owned attributes",
|
title: "Owned attributes",
|
||||||
icon: "bx bx-list-check"
|
icon: "bx bx-list-check"
|
||||||
};
|
};
|
||||||
|
@ -3,18 +3,17 @@ import BasicWidget from "./basic_widget.js";
|
|||||||
const TPL = `<div class="spacer"></div>`;
|
const TPL = `<div class="spacer"></div>`;
|
||||||
|
|
||||||
export default class SpacerWidget extends BasicWidget {
|
export default class SpacerWidget extends BasicWidget {
|
||||||
constructor(baseSize = 0, growIndex = 1000, shrinkIndex = 1000) {
|
constructor(baseSize = 0, growthFactor = 1000) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.baseSize = baseSize;
|
this.baseSize = baseSize;
|
||||||
this.growIndex = growIndex;
|
this.growthFactor = growthFactor;
|
||||||
this.shrinkIndex = shrinkIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.$widget.css("flex-basis", this.baseSize);
|
this.$widget.css("flex-basis", this.baseSize);
|
||||||
this.$widget.css("flex-grow", this.growIndex);
|
this.$widget.css("flex-grow", this.growthFactor);
|
||||||
this.$widget.css("flex-shrink", this.shrinkIndex);
|
this.$widget.css("flex-shrink", 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,10 +312,16 @@ const shortcuts = [
|
|||||||
{ id: 'lb_notemap', targetNoteId: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
|
{ 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_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_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_spacer1', builtinWidget: 'spacer', title: 'Spacer', icon: 'bx bx-move-vertical', isVisible: true, labels: [
|
||||||
{ id: 'lb_pluginbuttons', builtinWidget: 'pluginButtons', title: 'Plugin buttons', icon: 'bx bx-move-vertical', isVisible: true },
|
{ type: "number", name: "baseSize", value: "40" },
|
||||||
|
{ type: "number", name: "growthFactor", value: "100" },
|
||||||
|
] },
|
||||||
|
{ id: 'lb_pluginbuttons', builtinWidget: 'pluginButtons', title: 'Plugin buttons', icon: 'bx bx-extension', isVisible: true },
|
||||||
{ id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', 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_spacer2', builtinWidget: 'spacer', title: 'Spacer', icon: 'bx bx-move-vertical', isVisible: true, labels: [
|
||||||
|
{ type: "number", name: "baseSize", value: "40" },
|
||||||
|
{ type: "number", name: "growthFactor", value: "100" },
|
||||||
|
] },
|
||||||
{ id: 'lb_protectedsession', builtinWidget: 'protectedSession', title: 'Protected session', icon: 'bx bx bx-shield-quarter', 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 },
|
{ id: 'lb_syncstatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true },
|
||||||
];
|
];
|
||||||
@ -331,30 +337,37 @@ function createMissingSpecialNotes() {
|
|||||||
|
|
||||||
for (const shortcut of shortcuts) {
|
for (const shortcut of shortcuts) {
|
||||||
let note = becca.getNote(shortcut.id);
|
let note = becca.getNote(shortcut.id);
|
||||||
|
|
||||||
|
if (note) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
|
const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
|
||||||
|
note = noteService.createNewNote({
|
||||||
|
branchId: shortcut.id,
|
||||||
|
noteId: shortcut.id,
|
||||||
|
title: shortcut.title,
|
||||||
|
type: 'text',
|
||||||
|
content: '',
|
||||||
|
parentNoteId: parentNoteId
|
||||||
|
}).note;
|
||||||
|
|
||||||
if (!note) {
|
note.addLabel('builtinShortcut');
|
||||||
note = noteService.createNewNote({
|
note.addLabel('iconClass', shortcut.icon);
|
||||||
branchId: shortcut.id,
|
|
||||||
noteId: shortcut.id,
|
|
||||||
title: shortcut.title,
|
|
||||||
type: 'text',
|
|
||||||
content: '',
|
|
||||||
parentNoteId: parentNoteId
|
|
||||||
}).note;
|
|
||||||
|
|
||||||
note.addLabel('builtinShortcut');
|
if (shortcut.command) {
|
||||||
note.addLabel('iconClass', shortcut.icon);
|
note.addLabel('command', shortcut.command);
|
||||||
|
} else if (shortcut.builtinWidget) {
|
||||||
|
note.addLabel('builtinWidget', shortcut.builtinWidget);
|
||||||
|
} else if (shortcut.targetNoteId) {
|
||||||
|
note.addRelation('targetNote', shortcut.targetNoteId);
|
||||||
|
} else {
|
||||||
|
throw new Error(`No action defined for shortcut ${JSON.stringify(shortcut)}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (shortcut.command) {
|
for (const label of shortcut.labels || []) {
|
||||||
note.addLabel('command', shortcut.command);
|
note.addLabel('label:' + label.name, "promoted," + label.type);
|
||||||
} else if (shortcut.builtinWidget) {
|
note.addLabel(label.name, label.value);
|
||||||
note.addLabel('builtinWidget', shortcut.builtinWidget);
|
|
||||||
} else if (shortcut.targetNoteId) {
|
|
||||||
note.addRelation('targetNote', shortcut.targetNoteId);
|
|
||||||
} else {
|
|
||||||
throw new Error(`No action defined for shortcut ${JSON.stringify(shortcut)}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user