mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	renamed shortcuts to launchers
This commit is contained in:
		
							parent
							
								
									b55c2d3dbc
								
							
						
					
					
						commit
						1a6c9be065
					
				| @ -21,7 +21,7 @@ const NOTE_TYPE_ICONS = { | |||||||
|     "mermaid": "bx bx-selection", |     "mermaid": "bx bx-selection", | ||||||
|     "canvas": "bx bx-pen", |     "canvas": "bx bx-pen", | ||||||
|     "web-view": "bx bx-globe-alt", |     "web-view": "bx bx-globe-alt", | ||||||
|     "shortcut": "bx bx-link", |     "launcher": "bx bx-link", | ||||||
|     "doc": "bx bxs-file-doc" |     "doc": "bx bxs-file-doc" | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -827,7 +827,7 @@ class NoteShort { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     isLaunchBarConfig() { |     isLaunchBarConfig() { | ||||||
|         return this.type === 'shortcut' || this.noteId.startsWith("lb_"); |         return this.type === 'launcher' || this.noteId.startsWith("lb_"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -72,7 +72,7 @@ import OptionsDialog from "../widgets/dialogs/options.js"; | |||||||
| import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js"; | import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js"; | ||||||
| import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js"; | import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js"; | ||||||
| import MermaidExportButton from "../widgets/floating_buttons/mermaid_export_button.js"; | import MermaidExportButton from "../widgets/floating_buttons/mermaid_export_button.js"; | ||||||
| import ShortcutContainer from "../widgets/containers/shortcut_container.js"; | import LauncherContainer from "../widgets/containers/launcher_container.js"; | ||||||
| import NoteRevisionsButton from "../widgets/buttons/note_revisions_button.js"; | import NoteRevisionsButton from "../widgets/buttons/note_revisions_button.js"; | ||||||
| import EditableCodeButtonsWidget from "../widgets/type_widgets/editable_code_buttons.js"; | import EditableCodeButtonsWidget from "../widgets/type_widgets/editable_code_buttons.js"; | ||||||
| import ApiLogWidget from "../widgets/api_log.js"; | import ApiLogWidget from "../widgets/api_log.js"; | ||||||
| @ -104,7 +104,7 @@ export default class DesktopLayout { | |||||||
|                 .id("launcher-pane") |                 .id("launcher-pane") | ||||||
|                 .css("width", "53px") |                 .css("width", "53px") | ||||||
|                 .child(new GlobalMenuWidget()) |                 .child(new GlobalMenuWidget()) | ||||||
|                 .child(new ShortcutContainer()) |                 .child(new LauncherContainer()) | ||||||
|                 .child(new LeftPaneToggleWidget()) |                 .child(new LeftPaneToggleWidget()) | ||||||
|             ) |             ) | ||||||
|             .child(new LeftPaneContainer() |             .child(new LeftPaneContainer() | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import contextMenu from "./context_menu.js"; | |||||||
| import dialogService from "../services/dialog.js"; | import dialogService from "../services/dialog.js"; | ||||||
| import server from "../services/server.js"; | import server from "../services/server.js"; | ||||||
| 
 | 
 | ||||||
| export default class ShortcutContextMenu { | export default class LauncherContextMenu { | ||||||
|     /** |     /** | ||||||
|      * @param {NoteTreeWidget} treeWidget |      * @param {NoteTreeWidget} treeWidget | ||||||
|      * @param {FancytreeNode} node |      * @param {FancytreeNode} node | ||||||
| @ -27,38 +27,38 @@ export default class ShortcutContextMenu { | |||||||
|         const note = await froca.getNote(this.node.data.noteId); |         const note = await froca.getNote(this.node.data.noteId); | ||||||
|         const parentNoteId = this.node.getParent().data.noteId; |         const parentNoteId = this.node.getParent().data.noteId; | ||||||
| 
 | 
 | ||||||
|         const isVisibleRoot = note.noteId === 'lb_visibleshortcuts'; |         const isVisibleRoot = note.noteId === 'lb_visiblelaunchers'; | ||||||
|         const isAvailableRoot = note.noteId === 'lb_availableshortcuts'; |         const isAvailableRoot = note.noteId === 'lb_availablelaunchers'; | ||||||
|         const isVisibleItem = parentNoteId === 'lb_visibleshortcuts'; |         const isVisibleItem = parentNoteId === 'lb_visiblelaunchers'; | ||||||
|         const isAvailableItem = parentNoteId === 'lb_availableshortcuts'; |         const isAvailableItem = parentNoteId === 'lb_availablelaunchers'; | ||||||
|         const isItem = isVisibleItem || isAvailableItem; |         const isItem = isVisibleItem || isAvailableItem; | ||||||
|         const canBeDeleted = !note.noteId.startsWith("lb_"); |         const canBeDeleted = !note.noteId.startsWith("lb_"); | ||||||
|         const canBeReset = note.noteId.startsWith("lb_"); |         const canBeReset = note.noteId.startsWith("lb_"); | ||||||
| 
 | 
 | ||||||
|         return [ |         return [ | ||||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut', uiIcon: "bx bx-plus" } : null, |             (isVisibleRoot || isAvailableRoot) ? { title: 'Add note launcher', command: 'addNoteLauncher', uiIcon: "bx bx-plus" } : null, | ||||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add script shortcut', command: 'addScriptShortcut', uiIcon: "bx bx-plus" } : null, |             (isVisibleRoot || isAvailableRoot) ? { title: 'Add script launcher', command: 'addScriptLauncher', uiIcon: "bx bx-plus" } : null, | ||||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut', uiIcon: "bx bx-plus" } : null, |             (isVisibleRoot || isAvailableRoot) ? { title: 'Add widget launcher', command: 'addWidgetLauncher', uiIcon: "bx bx-plus" } : null, | ||||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut', uiIcon: "bx bx-plus" } : null, |             (isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerLauncher', uiIcon: "bx bx-plus" } : null, | ||||||
|             (isVisibleRoot || isAvailableRoot) ? { title: "----" } : null, |             (isVisibleRoot || isAvailableRoot) ? { title: "----" } : null, | ||||||
|             { title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash", enabled: canBeDeleted }, |             { title: 'Delete <kbd data-command="deleteNotes"></kbd>', command: "deleteNotes", uiIcon: "bx bx-trash", enabled: canBeDeleted }, | ||||||
|             { title: 'Reset', command: "resetShortcut", uiIcon: "bx bx-empty", enabled: canBeReset}, |             { title: 'Reset', command: "resetLauncher", uiIcon: "bx bx-empty", enabled: canBeReset}, | ||||||
|             { title: "----" }, |             { title: "----" }, | ||||||
|             isAvailableItem ? { title: 'Move to visible shortcuts', command: "moveShortcutToVisible", uiIcon: "bx bx-show", enabled: true } : null, |             isAvailableItem ? { title: 'Move to visible launchers', command: "moveLauncherToVisible", uiIcon: "bx bx-show", enabled: true } : null, | ||||||
|             isVisibleItem ? { title: 'Move to available shortcuts', command: "moveShortcutToAvailable", uiIcon: "bx bx-hide", enabled: true } : null, |             isVisibleItem ? { title: 'Move to available launchers', command: "moveLauncherToAvailable", uiIcon: "bx bx-hide", enabled: true } : null, | ||||||
|             { title: `Duplicate shortcut <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty", |             { title: `Duplicate launcher <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty", | ||||||
|                 enabled: isItem } |                 enabled: isItem } | ||||||
|         ].filter(row => row !== null); |         ].filter(row => row !== null); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async selectMenuItemHandler({command}) { |     async selectMenuItemHandler({command}) { | ||||||
|         if (command === 'resetShortcut') { |         if (command === 'resetLauncher') { | ||||||
|             const confirmed = await dialogService.confirm(`Do you really want to reset "${this.node.title}"? 
 |             const confirmed = await dialogService.confirm(`Do you really want to reset "${this.node.title}"? 
 | ||||||
|                        All data / settings in this shortcut (and its children) will be lost  |                        All data / settings in this launcher (and its children) will be lost  | ||||||
|                        and the shortcut will be returned to its original location.`);
 |                        and the launcher will be returned to its original location.`);
 | ||||||
| 
 | 
 | ||||||
|             if (confirmed) { |             if (confirmed) { | ||||||
|                 await server.post(`special-notes/shortcuts/${this.node.data.noteId}/reset`); |                 await server.post(`special-notes/launchers/${this.node.data.noteId}/reset`); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
| @ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { | |||||||
|     branchIdsToMove = filterRootNote(branchIdsToMove); |     branchIdsToMove = filterRootNote(branchIdsToMove); | ||||||
|     branchIdsToMove = filterSearchBranches(branchIdsToMove); |     branchIdsToMove = filterSearchBranches(branchIdsToMove); | ||||||
| 
 | 
 | ||||||
|     if (['root', 'lb_root', 'lb_availableshortcuts', 'lb_visibleshortcuts'].includes(beforeBranchId)) { |     if (['root', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(beforeBranchId)) { | ||||||
|         toastService.showError('Cannot move notes here.'); |         toastService.showError('Cannot move notes here.'); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @ -35,8 +35,8 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { | |||||||
|         'root', |         'root', | ||||||
|         hoistedNoteService.getHoistedNoteId(), |         hoistedNoteService.getHoistedNoteId(), | ||||||
|         'lb_root', |         'lb_root', | ||||||
|         'lb_availableshortcuts', |         'lb_availablelaunchers', | ||||||
|         'lb_visibleshortcuts' |         'lb_visiblelaunchers' | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     if (forbiddenNoteIds.includes(afterNote.noteId)) { |     if (forbiddenNoteIds.includes(afterNote.noteId)) { | ||||||
|  | |||||||
| @ -11,6 +11,6 @@ export default class NoteRevisionsButton extends ButtonWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() && !['shortcut', 'doc'].includes(this.note?.type); |         return super.isEnabled() && !['launcher', 'doc'].includes(this.note?.type); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -11,11 +11,11 @@ import BackInHistoryButtonWidget from "../buttons/history/history_back.js"; | |||||||
| import ForwardInHistoryButtonWidget from "../buttons/history/history_forward.js"; | import ForwardInHistoryButtonWidget from "../buttons/history/history_forward.js"; | ||||||
| import dialogService from "../../services/dialog.js"; | import dialogService from "../../services/dialog.js"; | ||||||
| 
 | 
 | ||||||
| export default class ShortcutContainer extends FlexContainer { | export default class LauncherContainer extends FlexContainer { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super('column'); |         super('column'); | ||||||
| 
 | 
 | ||||||
|         this.id('shortcut-container'); |         this.id('launcher-container'); | ||||||
|         this.css('height', '100%'); |         this.css('height', '100%'); | ||||||
|         this.filling(); |         this.filling(); | ||||||
| 
 | 
 | ||||||
| @ -25,17 +25,17 @@ export default class ShortcutContainer extends FlexContainer { | |||||||
|     async load() { |     async load() { | ||||||
|         this.children = []; |         this.children = []; | ||||||
| 
 | 
 | ||||||
|         const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts', true); |         const visibleLaunchersRoot = await froca.getNote('lb_visiblelaunchers', true); | ||||||
| 
 | 
 | ||||||
|         if (!visibleShortcutsRoot) { |         if (!visibleLaunchersRoot) { | ||||||
|             console.log("Visible shortcuts root note doesn't exist."); |             console.log("Visible launchers root note doesn't exist."); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         await Promise.allSettled( |         await Promise.allSettled( | ||||||
|             (await visibleShortcutsRoot.getChildNotes()) |             (await visibleLaunchersRoot.getChildNotes()) | ||||||
|                 .map(shortcut => this.initShortcut(shortcut)) |                 .map(launcher => this.initLauncher(launcher)) | ||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         this.$widget.empty(); |         this.$widget.empty(); | ||||||
| @ -59,68 +59,68 @@ export default class ShortcutContainer extends FlexContainer { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async initShortcut(shortcut) { |     async initLauncher(launcher) { | ||||||
|         try { |         try { | ||||||
|             if (shortcut.type !== 'shortcut') { |             if (launcher.type !== 'launcher') { | ||||||
|                 console.warn(`Note ${shortcut.noteId} is not a shortcut even though it's in shortcut subtree`); |                 console.warn(`Note ${launcher.noteId} is not a launcher even though it's in launcher subtree`); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             const shortcutType = shortcut.getLabelValue("shortcutType"); |             const launcherType = launcher.getLabelValue("launcherType"); | ||||||
| 
 | 
 | ||||||
|             if (shortcutType === 'command') { |             if (launcherType === 'command') { | ||||||
|                 this.child(new ButtonWidget() |                 this.child(new ButtonWidget() | ||||||
|                     .title(shortcut.title) |                     .title(launcher.title) | ||||||
|                     .icon(shortcut.getIcon()) |                     .icon(launcher.getIcon()) | ||||||
|                     .command(shortcut.getLabelValue("command"))); |                     .command(launcher.getLabelValue("command"))); | ||||||
|             } else if (shortcutType === 'note') { |             } else if (launcherType === 'note') { | ||||||
|                 // we're intentionally displaying the shortcut title and icon instead of the target
 |                 // we're intentionally displaying the launcher title and icon instead of the target
 | ||||||
|                 // e.g. you want to make shortcuts to 2 mermaid diagrams which both have mermaid icon (ok),
 |                 // e.g. you want to make launchers to 2 mermaid diagrams which both have mermaid icon (ok),
 | ||||||
|                 // but on the launchpad you want them distinguishable.
 |                 // but on the launchpad you want them distinguishable.
 | ||||||
|                 // for titles, the note titles may follow a different scheme than maybe desirable on the launchpad
 |                 // for titles, the note titles may follow a different scheme than maybe desirable on the launchpad
 | ||||||
|                 // another reason is the discrepancy between what user sees on the launchpad and in the config (esp. icons).
 |                 // another reason is the discrepancy between what user sees on the launchpad and in the config (esp. icons).
 | ||||||
|                 // The only (but major) downside is more work in setting up the typical case where you actually want to have both title and icon in sync.
 |                 // The only (but major) downside is more work in setting up the typical case where you actually want to have both title and icon in sync.
 | ||||||
| 
 | 
 | ||||||
|                 this.child(new ButtonWidget() |                 this.child(new ButtonWidget() | ||||||
|                     .title(shortcut.title) |                     .title(launcher.title) | ||||||
|                     .icon(shortcut.getIcon()) |                     .icon(launcher.getIcon()) | ||||||
|                     .onClick(() => { |                     .onClick(() => { | ||||||
|                         const targetNoteId = shortcut.getRelationValue('targetNote'); |                         const targetNoteId = launcher.getRelationValue('targetNote'); | ||||||
| 
 | 
 | ||||||
|                         if (!targetNoteId) { |                         if (!targetNoteId) { | ||||||
|                             dialogService.info("This shortcut doesn't define target note."); |                             dialogService.info("This launcher doesn't define target note."); | ||||||
|                             return; |                             return; | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                         appContext.tabManager.openTabWithNoteWithHoisting(targetNoteId, true) |                         appContext.tabManager.openTabWithNoteWithHoisting(targetNoteId, true) | ||||||
|                     })); |                     })); | ||||||
|             } else if (shortcutType === 'script') { |             } else if (launcherType === 'script') { | ||||||
|                 this.child(new ButtonWidget() |                 this.child(new ButtonWidget() | ||||||
|                     .title(shortcut.title) |                     .title(launcher.title) | ||||||
|                     .icon(shortcut.getIcon()) |                     .icon(launcher.getIcon()) | ||||||
|                     .onClick(async () => { |                     .onClick(async () => { | ||||||
|                         const script = await shortcut.getRelationTarget('script'); |                         const script = await launcher.getRelationTarget('script'); | ||||||
| 
 | 
 | ||||||
|                         await script.executeScript(); |                         await script.executeScript(); | ||||||
|                     })); |                     })); | ||||||
|             } else if (shortcutType === 'customWidget') { |             } else if (launcherType === 'customWidget') { | ||||||
|                 const widget = await shortcut.getRelationTarget('widget'); |                 const widget = await launcher.getRelationTarget('widget'); | ||||||
| 
 | 
 | ||||||
|                 if (widget) { |                 if (widget) { | ||||||
|                     const res = await widget.executeScript(); |                     const res = await widget.executeScript(); | ||||||
| 
 | 
 | ||||||
|                     this.child(res); |                     this.child(res); | ||||||
|                 } |                 } | ||||||
|             } else if (shortcutType === 'builtinWidget') { |             } else if (launcherType === 'builtinWidget') { | ||||||
|                 const builtinWidget = shortcut.getLabelValue("builtinWidget"); |                 const builtinWidget = launcher.getLabelValue("builtinWidget"); | ||||||
| 
 | 
 | ||||||
|                 if (builtinWidget) { |                 if (builtinWidget) { | ||||||
|                     if (builtinWidget === 'calendar') { |                     if (builtinWidget === 'calendar') { | ||||||
|                         this.child(new CalendarWidget(shortcut.title, shortcut.getIcon())); |                         this.child(new CalendarWidget(launcher.title, launcher.getIcon())); | ||||||
|                     } else if (builtinWidget === 'spacer') { |                     } else if (builtinWidget === 'spacer') { | ||||||
|                         // || has to be inside since 0 is a valid value
 |                         // || has to be inside since 0 is a valid value
 | ||||||
|                         const baseSize = parseInt(shortcut.getLabelValue("baseSize") || "40"); |                         const baseSize = parseInt(launcher.getLabelValue("baseSize") || "40"); | ||||||
|                         const growthFactor = parseInt(shortcut.getLabelValue("growthFactor") || "100"); |                         const growthFactor = parseInt(launcher.getLabelValue("growthFactor") || "100"); | ||||||
| 
 | 
 | ||||||
|                         this.child(new SpacerWidget(baseSize, growthFactor)); |                         this.child(new SpacerWidget(baseSize, growthFactor)); | ||||||
|                     } else if (builtinWidget === 'bookmarks') { |                     } else if (builtinWidget === 'bookmarks') { | ||||||
| @ -134,15 +134,15 @@ export default class ShortcutContainer extends FlexContainer { | |||||||
|                     } else if (builtinWidget === 'forwardInHistoryButton') { |                     } else if (builtinWidget === 'forwardInHistoryButton') { | ||||||
|                         this.child(new ForwardInHistoryButtonWidget()); |                         this.child(new ForwardInHistoryButtonWidget()); | ||||||
|                     } else { |                     } else { | ||||||
|                         console.warn(`Unrecognized builtin widget ${builtinWidget} for shortcut ${shortcut.noteId} "${shortcut.title}"`); |                         console.warn(`Unrecognized builtin widget ${builtinWidget} for launcher ${launcher.noteId} "${launcher.title}"`); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 console.warn(`Unrecognized shortcut type ${shortcutType} for shortcut '${shortcut.noteId}' title ${shortcut.title}`); |                 console.warn(`Unrecognized launcher type ${launcherType} for launcher '${launcher.noteId}' title ${launcher.title}`); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         catch (e) { |         catch (e) { | ||||||
|             console.error(`Initialization of shortcut '${shortcut.noteId}' with title '${shortcut.title}' failed with error: ${e.message} ${e.stack}`); |             console.error(`Initialization of launcher '${launcher.noteId}' with title '${launcher.title}' failed with error: ${e.message} ${e.stack}`); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -197,7 +197,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { | |||||||
|             type = 'editable-code'; |             type = 'editable-code'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (type === 'shortcut') { |         if (type === 'launcher') { | ||||||
|             type = 'doc'; |             type = 'doc'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget { | |||||||
|         this.$noteTitle.val(note.title); |         this.$noteTitle.val(note.title); | ||||||
| 
 | 
 | ||||||
|         this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) |         this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) | ||||||
|                                         || ["lb_root", "lb_availableshortcuts", "lb_visibleshortcuts"].includes(note.noteId)); |                                         || ["lb_root", "lb_availablelaunchers", "lb_visiblelaunchers"].includes(note.noteId)); | ||||||
| 
 | 
 | ||||||
|         this.setProtectedStatus(note); |         this.setProtectedStatus(note); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -397,7 +397,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                 autoExpandMS: 600, |                 autoExpandMS: 600, | ||||||
|                 preventLazyParents: false, |                 preventLazyParents: false, | ||||||
|                 dragStart: (node, data) => { |                 dragStart: (node, data) => { | ||||||
|                     if (['root', 'hidden', 'lb_root', 'lb_availableshortcuts', 'lb_visibleshortcuts'].includes(node.data.noteId)) { |                     if (['root', 'hidden', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(node.data.noteId)) { | ||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
| @ -427,7 +427,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                         return false; |                         return false; | ||||||
|                     } else if (node.data.noteId === 'lb_root') { |                     } else if (node.data.noteId === 'lb_root') { | ||||||
|                         return false; |                         return false; | ||||||
|                     } else if (node.data.noteType === 'shortcut') { |                     } else if (node.data.noteType === 'launcher') { | ||||||
|                         return ['before', 'after']; |                         return ['before', 'after']; | ||||||
|                     } else { |                     } else { | ||||||
|                         return true; |                         return true; | ||||||
| @ -564,7 +564,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                     $span.append($refreshSearchButton); |                     $span.append($refreshSearchButton); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (!['search', 'shortcut'].includes(note.type)) { |                 if (!['search', 'launcher'].includes(note.type)) { | ||||||
|                     const $createChildNoteButton = $('<span class="tree-item-button add-note-button bx bx-plus" title="Create child note"></span>'); |                     const $createChildNoteButton = $('<span class="tree-item-button add-note-button bx bx-plus" title="Create child note"></span>'); | ||||||
| 
 | 
 | ||||||
|                     $span.append($createChildNoteButton); |                     $span.append($createChildNoteButton); | ||||||
| @ -604,8 +604,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|             const node = $.ui.fancytree.getNode(e); |             const node = $.ui.fancytree.getNode(e); | ||||||
| 
 | 
 | ||||||
|             if (hoistedNoteService.getHoistedNoteId() === 'lb_root') { |             if (hoistedNoteService.getHoistedNoteId() === 'lb_root') { | ||||||
|                 import("../menus/shortcut_context_menu.js").then(({default: ShortcutContextMenu}) => { |                 import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => { | ||||||
|                     const shortcutContextMenu = new ShortcutContextMenu(this, node); |                     const shortcutContextMenu = new LauncherContextMenu(this, node); | ||||||
|                     shortcutContextMenu.show(e); |                     shortcutContextMenu.show(e); | ||||||
|                 }); |                 }); | ||||||
|             } else { |             } else { | ||||||
| @ -1551,11 +1551,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) { |     moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) { | ||||||
|         branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visibleshortcuts'); |         branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visiblelaunchers'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) { |     moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) { | ||||||
|         branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availableshortcuts'); |         branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availablelaunchers'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     addNoteShortcutCommand({node}) { |     addNoteShortcutCommand({node}) { | ||||||
| @ -1574,8 +1574,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|         this.createShortcutNote(node, 'spacer'); |         this.createShortcutNote(node, 'spacer'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createShortcutNote(node, shortcutType) { |     async createShortcutNote(node, launcherType) { | ||||||
|         const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${shortcutType}`); |         const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${launcherType}`); | ||||||
| 
 | 
 | ||||||
|         if (!resp.success) { |         if (!resp.success) { | ||||||
|             alert(resp.message); |             alert(resp.message); | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ const NOTE_TYPES = [ | |||||||
|     { type: "image", title: "Image", selectable: false }, |     { type: "image", title: "Image", selectable: false }, | ||||||
|     { type: "search", title: "Saved Search", selectable: false }, |     { type: "search", title: "Saved Search", selectable: false }, | ||||||
|     { type: "note-map", mime: '', title: "Note Map", selectable: false }, |     { type: "note-map", mime: '', title: "Note Map", selectable: false }, | ||||||
|     { type: "shortcut", mime: '', title: "Shortcut", selectable: false }, |     { type: "launcher", mime: '', title: "Launcher", selectable: false }, | ||||||
|     { type: "doc", mime: '', title: "Doc", selectable: false }, |     { type: "doc", mime: '', title: "Doc", selectable: false }, | ||||||
| 
 | 
 | ||||||
|     { type: "text", mime: "text/html", title: "Text", selectable: true }, |     { type: "text", mime: "text/html", title: "Text", selectable: true }, | ||||||
|  | |||||||
| @ -66,12 +66,12 @@ function getHoistedNote() { | |||||||
|     return becca.getNote(cls.getHoistedNoteId()); |     return becca.getNote(cls.getHoistedNoteId()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function createShortcut(req) { | function createLauncher(req) { | ||||||
|     return specialNotesService.createShortcut(req.params.parentNoteId, req.params.shortcutType); |     return specialNotesService.createLauncher(req.params.parentNoteId, req.params.launcherType); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function resetShortcut(req) { | function resetLauncher(req) { | ||||||
|     return specialNotesService.resetShortcut(req.params.noteId); |     return specialNotesService.resetLauncher(req.params.noteId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
| @ -85,6 +85,6 @@ module.exports = { | |||||||
|     saveSqlConsole, |     saveSqlConsole, | ||||||
|     createSearchNote, |     createSearchNote, | ||||||
|     saveSearchNote, |     saveSearchNote, | ||||||
|     createShortcut, |     createLauncher, | ||||||
|     resetShortcut |     resetLauncher | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -326,8 +326,8 @@ function register(app) { | |||||||
|     apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole); |     apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole); | ||||||
|     apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote); |     apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote); | ||||||
|     apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote); |     apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote); | ||||||
|     apiRoute(POST, '/api/special-notes/shortcuts/:noteId/reset', specialNotesRoute.resetShortcut); |     apiRoute(POST, '/api/special-notes/launchers/:noteId/reset', specialNotesRoute.resetLauncher); | ||||||
|     apiRoute(POST, '/api/special-notes/shortcuts/:parentNoteId/:shortcutType', specialNotesRoute.createShortcut); |     apiRoute(POST, '/api/special-notes/launchers/:parentNoteId/:launcherType', specialNotesRoute.createLauncher); | ||||||
| 
 | 
 | ||||||
|     // :filename is not used by trilium, but instead used for "save as" to assign a human-readable filename
 |     // :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); |     route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage); | ||||||
|  | |||||||
| @ -11,6 +11,6 @@ module.exports = [ | |||||||
|     'mermaid', |     'mermaid', | ||||||
|     'canvas', |     'canvas', | ||||||
|     'web-view', |     'web-view', | ||||||
|     'shortcut', |     'launcher', | ||||||
|     'doc' |     'doc' | ||||||
| ]; | ]; | ||||||
|  | |||||||
| @ -110,16 +110,16 @@ function getAndValidateParent(params) { | |||||||
|         throw new Error(`Parent note "${params.parentNoteId}" not found.`); |         throw new Error(`Parent note "${params.parentNoteId}" not found.`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (parentNote.type === 'shortcut') { |     if (parentNote.type === 'launcher') { | ||||||
|         throw new Error(`Shortcuts should not have child notes.`); |         throw new Error(`Launchers should not have child notes.`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!params.ignoreForbiddenParents && ['lb_root'].includes(parentNote.noteId)) { |     if (!params.ignoreForbiddenParents && ['lb_root'].includes(parentNote.noteId)) { | ||||||
|         throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`); |         throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (['lb_availableshortcuts', 'lb_visibleshortcuts'].includes(parentNote.noteId) && params.type !== 'shortcut') { |     if (['lb_availablelaunchers', 'lb_visiblelaunchers'].includes(parentNote.noteId) && params.type !== 'launcher') { | ||||||
|         throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for type 'shortcut'.`); |         throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for type 'launcher'.`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return parentNote; |     return parentNote; | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ const dateUtils = require("./date_utils"); | |||||||
| const LBTPL_ROOT = "lbtpl_root"; | const LBTPL_ROOT = "lbtpl_root"; | ||||||
| const LBTPL_BASE = "lbtpl_base"; | const LBTPL_BASE = "lbtpl_base"; | ||||||
| const LBTPL_COMMAND = "lbtpl_command"; | const LBTPL_COMMAND = "lbtpl_command"; | ||||||
| const LBTPL_NOTE_SHORTCUT = "lbtpl_noteshortcut"; | const LBTPL_NOTE_LAUNCHER = "lbtpl_notelauncher"; | ||||||
| const LBTPL_SCRIPT = "lbtpl_script"; | const LBTPL_SCRIPT = "lbtpl_script"; | ||||||
| const LBTPL_BUILTIN_WIDGET = "lbtpl_builtinwidget"; | const LBTPL_BUILTIN_WIDGET = "lbtpl_builtinwidget"; | ||||||
| const LBTPL_SPACER = "lbtpl_spacer"; | const LBTPL_SPACER = "lbtpl_spacer"; | ||||||
| @ -276,14 +276,14 @@ function getLaunchBarRoot() { | |||||||
|     return note; |     return note; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getLaunchBarAvailableShortcutsRoot() { | function getLaunchBarAvailableLaunchersRoot() { | ||||||
|     let note = becca.getNote('lb_availableshortcuts'); |     let note = becca.getNote('lb_availablelaunchers'); | ||||||
| 
 | 
 | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             branchId: 'lb_availableshortcuts', |             branchId: 'lb_availablelaunchers', | ||||||
|             noteId: 'lb_availableshortcuts', |             noteId: 'lb_availablelaunchers', | ||||||
|             title: 'Available shortcuts', |             title: 'Available launchers', | ||||||
|             type: 'doc', |             type: 'doc', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: getLaunchBarRoot().noteId, |             parentNoteId: getLaunchBarRoot().noteId, | ||||||
| @ -294,7 +294,7 @@ function getLaunchBarAvailableShortcutsRoot() { | |||||||
|         note.addLabel("docName", "launchbar_intro"); |         note.addLabel("docName", "launchbar_intro"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const branch = becca.getBranch('lb_availableshortcuts'); |     const branch = becca.getBranch('lb_availablelaunchers'); | ||||||
|     if (!branch.isExpanded) { |     if (!branch.isExpanded) { | ||||||
|         branch.isExpanded = true; |         branch.isExpanded = true; | ||||||
|         branch.save(); |         branch.save(); | ||||||
| @ -303,14 +303,14 @@ function getLaunchBarAvailableShortcutsRoot() { | |||||||
|     return note; |     return note; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getLaunchBarVisibleShortcutsRoot() { | function getLaunchBarVisibleLaunchersRoot() { | ||||||
|     let note = becca.getNote('lb_visibleshortcuts'); |     let note = becca.getNote('lb_visiblelaunchers'); | ||||||
| 
 | 
 | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             branchId: 'lb_visibleshortcuts', |             branchId: 'lb_visiblelaunchers', | ||||||
|             noteId: 'lb_visibleshortcuts', |             noteId: 'lb_visiblelaunchers', | ||||||
|             title: 'Visible shortcuts', |             title: 'Visible launchers', | ||||||
|             type: 'doc', |             type: 'doc', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: getLaunchBarRoot().noteId, |             parentNoteId: getLaunchBarRoot().noteId, | ||||||
| @ -321,7 +321,7 @@ function getLaunchBarVisibleShortcutsRoot() { | |||||||
|         note.addLabel("docName", "launchbar_intro"); |         note.addLabel("docName", "launchbar_intro"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const branch = becca.getBranch('lb_visibleshortcuts'); |     const branch = becca.getBranch('lb_visiblelaunchers'); | ||||||
|     if (!branch.isExpanded) { |     if (!branch.isExpanded) { | ||||||
|         branch.isExpanded = true; |         branch.isExpanded = true; | ||||||
|         branch.save(); |         branch.save(); | ||||||
| @ -330,8 +330,8 @@ function getLaunchBarVisibleShortcutsRoot() { | |||||||
|     return note; |     return note; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const shortcuts = [ | const launchers = [ | ||||||
|     // visible shortcuts:
 |     // visible launchers:
 | ||||||
|     { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true }, |     { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true }, | ||||||
|     { id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true }, |     { id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true }, | ||||||
|     { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, |     { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, | ||||||
| @ -343,7 +343,7 @@ const shortcuts = [ | |||||||
|     { 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 }, | ||||||
| 
 | 
 | ||||||
|     // available shortcuts:
 |     // available launchers:
 | ||||||
|     { 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_backinhistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false }, |     { id: 'lb_backinhistory', builtinWidget: 'backInHistoryButton', title: 'Back in history', icon: 'bx bxs-left-arrow-square', isVisible: false }, | ||||||
|     { id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false }, |     { id: 'lb_forwardinhistory', builtinWidget: 'forwardInHistoryButton', title: 'Forward in history', icon: 'bx bxs-right-arrow-square', isVisible: false }, | ||||||
| @ -353,53 +353,53 @@ function createMissingSpecialNotes() { | |||||||
|     getSqlConsoleRoot(); |     getSqlConsoleRoot(); | ||||||
|     getGlobalNoteMap(); |     getGlobalNoteMap(); | ||||||
|     getBulkActionNote(); |     getBulkActionNote(); | ||||||
|     createShortcutTemplates(); |     createLauncherTemplates(); | ||||||
|     getLaunchBarRoot(); |     getLaunchBarRoot(); | ||||||
|     getLaunchBarAvailableShortcutsRoot(); |     getLaunchBarAvailableLaunchersRoot(); | ||||||
|     getLaunchBarVisibleShortcutsRoot(); |     getLaunchBarVisibleLaunchersRoot(); | ||||||
|     getShareRoot(); |     getShareRoot(); | ||||||
| 
 | 
 | ||||||
|     for (const shortcut of shortcuts) { |     for (const launcher of launchers) { | ||||||
|         let note = becca.getNote(shortcut.id); |         let note = becca.getNote(launcher.id); | ||||||
| 
 | 
 | ||||||
|         if (note) { |         if (note) { | ||||||
|             continue; |             continue; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const parentNoteId = shortcut.isVisible |         const parentNoteId = launcher.isVisible | ||||||
|             ? getLaunchBarVisibleShortcutsRoot().noteId |             ? getLaunchBarVisibleLaunchersRoot().noteId | ||||||
|             : getLaunchBarAvailableShortcutsRoot().noteId; |             : getLaunchBarAvailableLaunchersRoot().noteId; | ||||||
| 
 | 
 | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             noteId: shortcut.id, |             noteId: launcher.id, | ||||||
|             title: shortcut.title, |             title: launcher.title, | ||||||
|             type: 'shortcut', |             type: 'launcher', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: parentNoteId |             parentNoteId: parentNoteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         if (shortcut.icon) { |         if (launcher.icon) { | ||||||
|             note.addLabel('iconClass', shortcut.icon); |             note.addLabel('iconClass', launcher.icon); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (shortcut.command) { |         if (launcher.command) { | ||||||
|             note.addRelation('template', LBTPL_COMMAND); |             note.addRelation('template', LBTPL_COMMAND); | ||||||
|             note.addLabel('command', shortcut.command); |             note.addLabel('command', launcher.command); | ||||||
|         } else if (shortcut.builtinWidget) { |         } else if (launcher.builtinWidget) { | ||||||
|             if (shortcut.builtinWidget === 'spacer') { |             if (launcher.builtinWidget === 'spacer') { | ||||||
|                 note.addRelation('template', LBTPL_SPACER); |                 note.addRelation('template', LBTPL_SPACER); | ||||||
|                 note.addLabel("baseSize", shortcut.baseSize); |                 note.addLabel("baseSize", launcher.baseSize); | ||||||
|                 note.addLabel("growthFactor", shortcut.growthFactor); |                 note.addLabel("growthFactor", launcher.growthFactor); | ||||||
|             } else { |             } else { | ||||||
|                 note.addRelation('template', LBTPL_BUILTIN_WIDGET); |                 note.addRelation('template', LBTPL_BUILTIN_WIDGET); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             note.addLabel('builtinWidget', shortcut.builtinWidget); |             note.addLabel('builtinWidget', launcher.builtinWidget); | ||||||
|         } else if (shortcut.targetNoteId) { |         } else if (launcher.targetNoteId) { | ||||||
|             note.addRelation('template', LBTPL_NOTE_SHORTCUT); |             note.addRelation('template', LBTPL_NOTE_LAUNCHER); | ||||||
|             note.addRelation('targetNote', shortcut.targetNoteId); |             note.addRelation('targetNote', launcher.targetNoteId); | ||||||
|         } else { |         } else { | ||||||
|             throw new Error(`No action defined for shortcut ${JSON.stringify(shortcut)}`); |             throw new Error(`No action defined for launcher ${JSON.stringify(launcher)}`); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -412,47 +412,47 @@ function createMissingSpecialNotes() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function createShortcut(parentNoteId, shortcutType) { | function createLauncher(parentNoteId, launcherType) { | ||||||
|     let note; |     let note; | ||||||
| 
 | 
 | ||||||
|     if (shortcutType === 'note') { |     if (launcherType === 'note') { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             title: "Note shortcut", |             title: "Note launcher", | ||||||
|             type: 'shortcut', |             type: 'launcher', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: parentNoteId |             parentNoteId: parentNoteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         note.addRelation('template', LBTPL_NOTE_SHORTCUT); |         note.addRelation('template', LBTPL_NOTE_LAUNCHER); | ||||||
|     } else if (shortcutType === 'script') { |     } else if (launcherType === 'script') { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             title: "Script shortcut", |             title: "Script launcher", | ||||||
|             type: 'shortcut', |             type: 'launcher', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: parentNoteId |             parentNoteId: parentNoteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         note.addRelation('template', LBTPL_SCRIPT); |         note.addRelation('template', LBTPL_SCRIPT); | ||||||
|     } else if (shortcutType === 'customWidget') { |     } else if (launcherType === 'customWidget') { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             title: "Widget shortcut", |             title: "Widget launcher", | ||||||
|             type: 'shortcut', |             type: 'launcher', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: parentNoteId |             parentNoteId: parentNoteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         note.addRelation('template', LBTPL_CUSTOM_WIDGET); |         note.addRelation('template', LBTPL_CUSTOM_WIDGET); | ||||||
|     } else if (shortcutType === 'spacer') { |     } else if (launcherType === 'spacer') { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             title: "Spacer", |             title: "Spacer", | ||||||
|             type: 'shortcut', |             type: 'launcher', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: parentNoteId |             parentNoteId: parentNoteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         note.addRelation('template', LBTPL_SPACER); |         note.addRelation('template', LBTPL_SPACER); | ||||||
|     } else { |     } else { | ||||||
|         throw new Error(`Unrecognized shortcut type ${shortcutType}`); |         throw new Error(`Unrecognized launcher type ${launcherType}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
| @ -461,7 +461,7 @@ function createShortcut(parentNoteId, shortcutType) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function createShortcutTemplates() { | function createLauncherTemplates() { | ||||||
|     if (!(LBTPL_ROOT in becca.notes)) { |     if (!(LBTPL_ROOT in becca.notes)) { | ||||||
|         noteService.createNewNote({ |         noteService.createNewNote({ | ||||||
|             branchId: LBTPL_ROOT, |             branchId: LBTPL_ROOT, | ||||||
| @ -477,43 +477,43 @@ function createShortcutTemplates() { | |||||||
|         const tpl = noteService.createNewNote({ |         const tpl = noteService.createNewNote({ | ||||||
|             branchId: LBTPL_BASE, |             branchId: LBTPL_BASE, | ||||||
|             noteId: LBTPL_BASE, |             noteId: LBTPL_BASE, | ||||||
|             title: 'Launch bar base shortcut', |             title: 'Launch bar base launcher', | ||||||
|             type: 'doc', |             type: 'doc', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: getHiddenRoot().noteId |             parentNoteId: getHiddenRoot().noteId | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addLabel('label:keyboardShortcut', 'promoted,text'); |         tpl.addLabel('label:keyboardLauncher', 'promoted,text'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(LBTPL_COMMAND in becca.notes)) { |     if (!(LBTPL_COMMAND in becca.notes)) { | ||||||
|         const tpl = noteService.createNewNote({ |         const tpl = noteService.createNewNote({ | ||||||
|             branchId: LBTPL_COMMAND, |             branchId: LBTPL_COMMAND, | ||||||
|             noteId: LBTPL_COMMAND, |             noteId: LBTPL_COMMAND, | ||||||
|             title: 'Command shortcut', |             title: 'Command launcher', | ||||||
|             type: 'doc', |             type: 'doc', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: LBTPL_ROOT |             parentNoteId: LBTPL_ROOT | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addRelation('template', LBTPL_BASE); |         tpl.addRelation('template', LBTPL_BASE); | ||||||
|         tpl.addLabel('shortcutType', 'command'); |         tpl.addLabel('launcherType', 'command'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(LBTPL_NOTE_SHORTCUT in becca.notes)) { |     if (!(LBTPL_NOTE_LAUNCHER in becca.notes)) { | ||||||
|         const tpl = noteService.createNewNote({ |         const tpl = noteService.createNewNote({ | ||||||
|             branchId: LBTPL_NOTE_SHORTCUT, |             branchId: LBTPL_NOTE_LAUNCHER, | ||||||
|             noteId: LBTPL_NOTE_SHORTCUT, |             noteId: LBTPL_NOTE_LAUNCHER, | ||||||
|             title: 'Note shortcut', |             title: 'Note launcher', | ||||||
|             type: 'doc', |             type: 'doc', | ||||||
|             content: '', |             content: '', | ||||||
|             parentNoteId: LBTPL_ROOT |             parentNoteId: LBTPL_ROOT | ||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addRelation('template', LBTPL_BASE); |         tpl.addRelation('template', LBTPL_BASE); | ||||||
|         tpl.addLabel('shortcutType', 'note'); |         tpl.addLabel('launcherType', 'note'); | ||||||
|         tpl.addLabel('relation:targetNote', 'promoted'); |         tpl.addLabel('relation:targetNote', 'promoted'); | ||||||
|         tpl.addLabel('docName', 'launchbar_note_shortcut'); |         tpl.addLabel('docName', 'launchbar_note_launcher'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(LBTPL_SCRIPT in becca.notes)) { |     if (!(LBTPL_SCRIPT in becca.notes)) { | ||||||
| @ -527,9 +527,9 @@ function createShortcutTemplates() { | |||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addRelation('template', LBTPL_BASE); |         tpl.addRelation('template', LBTPL_BASE); | ||||||
|         tpl.addLabel('shortcutType', 'script'); |         tpl.addLabel('launcherType', 'script'); | ||||||
|         tpl.addLabel('relation:script', 'promoted'); |         tpl.addLabel('relation:script', 'promoted'); | ||||||
|         tpl.addLabel('docName', 'launchbar_script_shortcut'); |         tpl.addLabel('docName', 'launchbar_script_launcher'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(LBTPL_BUILTIN_WIDGET in becca.notes)) { |     if (!(LBTPL_BUILTIN_WIDGET in becca.notes)) { | ||||||
| @ -543,7 +543,7 @@ function createShortcutTemplates() { | |||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addRelation('template', LBTPL_BASE); |         tpl.addRelation('template', LBTPL_BASE); | ||||||
|         tpl.addLabel('shortcutType', 'builtinWidget'); |         tpl.addLabel('launcherType', 'builtinWidget'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(LBTPL_SPACER in becca.notes)) { |     if (!(LBTPL_SPACER in becca.notes)) { | ||||||
| @ -575,13 +575,13 @@ function createShortcutTemplates() { | |||||||
|         }).note; |         }).note; | ||||||
| 
 | 
 | ||||||
|         tpl.addRelation('template', LBTPL_BASE); |         tpl.addRelation('template', LBTPL_BASE); | ||||||
|         tpl.addLabel('shortcutType', 'customWidget'); |         tpl.addLabel('launcherType', 'customWidget'); | ||||||
|         tpl.addLabel('relation:widget', 'promoted'); |         tpl.addLabel('relation:widget', 'promoted'); | ||||||
|         tpl.addLabel('docName', 'launchbar_widget_shortcut'); |         tpl.addLabel('docName', 'launchbar_widget_launcher'); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function resetShortcut(noteId) { | function resetLauncher(noteId) { | ||||||
|     if (noteId.startsWith('lb_')) { |     if (noteId.startsWith('lb_')) { | ||||||
|         const note = becca.getNote(noteId); |         const note = becca.getNote(noteId); | ||||||
| 
 | 
 | ||||||
| @ -598,7 +598,7 @@ function resetShortcut(noteId) { | |||||||
|             log.info(`Note ${noteId} has not been found and cannot be reset.`); |             log.info(`Note ${noteId} has not been found and cannot be reset.`); | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         log.info(`Note ${noteId} is not a resettable shortcut note.`); |         log.info(`Note ${noteId} is not a resettable launcher note.`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     createMissingSpecialNotes(); |     createMissingSpecialNotes(); | ||||||
| @ -614,6 +614,6 @@ module.exports = { | |||||||
|     getShareRoot, |     getShareRoot, | ||||||
|     getHiddenRoot, |     getHiddenRoot, | ||||||
|     getBulkActionNote, |     getBulkActionNote, | ||||||
|     createShortcut, |     createLauncher, | ||||||
|     resetShortcut |     resetLauncher | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ function getNotes(noteIds) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function validateParentChild(parentNoteId, childNoteId, branchId = null) { | function validateParentChild(parentNoteId, childNoteId, branchId = null) { | ||||||
|     if (['root', 'hidden', 'share', 'lb_root', 'lb_availableshortcuts', 'lb_visibleshortcuts'].includes(childNoteId)) { |     if (['root', 'hidden', 'share', 'lb_root', 'lb_availablelaunchers', 'lb_visiblelaunchers'].includes(childNoteId)) { | ||||||
|         return { success: false, message: `Cannot change this note's location.`}; |         return { success: false, message: `Cannot change this note's location.`}; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -58,10 +58,10 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { | |||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (becca.getNote(parentNoteId).type === 'shortcut') { |     if (becca.getNote(parentNoteId).type === 'launcher') { | ||||||
|         return { |         return { | ||||||
|             success: false, |             success: false, | ||||||
|             message: 'Shortcut note cannot have any children.' |             message: 'Launcher note cannot have any children.' | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam