launchbar WIP

This commit is contained in:
zadam 2022-08-06 13:47:27 +02:00
parent 7696702a2a
commit 54900b35dc
5 changed files with 52 additions and 36 deletions

View File

@ -33,15 +33,15 @@ export default class ShortcutContextMenu {
const isItem = isVisibleItem || isAvailableItem;
return [
(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: "----" },
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: "----" } : null,
{ title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash",
enabled: isItem },
{ title: "----" },
isAvailableItem ? { title: 'Move to visible shortcuts', command: "moveNotesTo", uiIcon: "bx bx-empty", enabled: true } : null,
isVisibleItem ? { title: 'Move to available 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: "moveShortcutToAvailable", uiIcon: "bx bx-hide", enabled: true } : null,
{ title: `Duplicate shortcut <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty",
enabled: isItem }
].filter(row => row !== null);

View File

@ -42,7 +42,11 @@ export default class ShortcutContainer extends FlexContainer {
if (builtinWidget === 'calendar') {
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
} 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') {
this.child(new FlexContainer("column")
.id("plugin-buttons")

View File

@ -47,7 +47,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
getTitle() {
return {
show: !this.note.isLaunchBarConfig(),
show: true,//!this.note.isLaunchBarConfig(),
title: "Owned attributes",
icon: "bx bx-list-check"
};

View File

@ -3,18 +3,17 @@ import BasicWidget from "./basic_widget.js";
const TPL = `<div class="spacer"></div>`;
export default class SpacerWidget extends BasicWidget {
constructor(baseSize = 0, growIndex = 1000, shrinkIndex = 1000) {
constructor(baseSize = 0, growthFactor = 1000) {
super();
this.baseSize = baseSize;
this.growIndex = growIndex;
this.shrinkIndex = shrinkIndex;
this.growthFactor = growthFactor;
}
doRender() {
this.$widget = $(TPL);
this.$widget.css("flex-basis", this.baseSize);
this.$widget.css("flex-grow", this.growIndex);
this.$widget.css("flex-shrink", this.shrinkIndex);
this.$widget.css("flex-grow", this.growthFactor);
this.$widget.css("flex-shrink", 1000);
}
}

View File

@ -312,10 +312,16 @@ 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_spacer1', 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_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_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_syncstatus', builtinWidget: 'syncStatus', title: 'Sync status', icon: 'bx bx-wifi', isVisible: true },
];
@ -331,30 +337,37 @@ function createMissingSpecialNotes() {
for (const shortcut of shortcuts) {
let note = becca.getNote(shortcut.id);
if (note) {
continue;
}
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 = noteService.createNewNote({
branchId: shortcut.id,
noteId: shortcut.id,
title: shortcut.title,
type: 'text',
content: '',
parentNoteId: parentNoteId
}).note;
note.addLabel('builtinShortcut');
note.addLabel('iconClass', shortcut.icon);
note.addLabel('builtinShortcut');
note.addLabel('iconClass', shortcut.icon);
if (shortcut.command) {
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) {
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)}`);
}
for (const label of shortcut.labels || []) {
note.addLabel('label:' + label.name, "promoted," + label.type);
note.addLabel(label.name, label.value);
}
}