mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 11:56:01 +01:00 
			
		
		
		
	launchbar WIP
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
        };
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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,9 +337,12 @@ function createMissingSpecialNotes() {
 | 
			
		||||
 | 
			
		||||
    for (const shortcut of shortcuts) {
 | 
			
		||||
        let note = becca.getNote(shortcut.id);
 | 
			
		||||
        const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
 | 
			
		||||
 | 
			
		||||
        if (!note) {
 | 
			
		||||
        if (note) {
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
 | 
			
		||||
        note = noteService.createNewNote({
 | 
			
		||||
            branchId: shortcut.id,
 | 
			
		||||
            noteId: shortcut.id,
 | 
			
		||||
@@ -355,6 +364,10 @@ function createMissingSpecialNotes() {
 | 
			
		||||
        } 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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user