renamed shortcuts to launchers

This commit is contained in:
zadam 2022-12-01 10:16:57 +01:00
parent b55c2d3dbc
commit 1a6c9be065
16 changed files with 164 additions and 164 deletions

View File

@ -21,7 +21,7 @@ const NOTE_TYPE_ICONS = {
"mermaid": "bx bx-selection",
"canvas": "bx bx-pen",
"web-view": "bx bx-globe-alt",
"shortcut": "bx bx-link",
"launcher": "bx bx-link",
"doc": "bx bxs-file-doc"
};
@ -827,7 +827,7 @@ class NoteShort {
}
isLaunchBarConfig() {
return this.type === 'shortcut' || this.noteId.startsWith("lb_");
return this.type === 'launcher' || this.noteId.startsWith("lb_");
}
}

View File

@ -72,7 +72,7 @@ import OptionsDialog from "../widgets/dialogs/options.js";
import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js";
import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.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 EditableCodeButtonsWidget from "../widgets/type_widgets/editable_code_buttons.js";
import ApiLogWidget from "../widgets/api_log.js";
@ -104,7 +104,7 @@ export default class DesktopLayout {
.id("launcher-pane")
.css("width", "53px")
.child(new GlobalMenuWidget())
.child(new ShortcutContainer())
.child(new LauncherContainer())
.child(new LeftPaneToggleWidget())
)
.child(new LeftPaneContainer()

View File

@ -4,7 +4,7 @@ import contextMenu from "./context_menu.js";
import dialogService from "../services/dialog.js";
import server from "../services/server.js";
export default class ShortcutContextMenu {
export default class LauncherContextMenu {
/**
* @param {NoteTreeWidget} treeWidget
* @param {FancytreeNode} node
@ -27,38 +27,38 @@ export default class ShortcutContextMenu {
const note = await froca.getNote(this.node.data.noteId);
const parentNoteId = this.node.getParent().data.noteId;
const isVisibleRoot = note.noteId === 'lb_visibleshortcuts';
const isAvailableRoot = note.noteId === 'lb_availableshortcuts';
const isVisibleItem = parentNoteId === 'lb_visibleshortcuts';
const isAvailableItem = parentNoteId === 'lb_availableshortcuts';
const isVisibleRoot = note.noteId === 'lb_visiblelaunchers';
const isAvailableRoot = note.noteId === 'lb_availablelaunchers';
const isVisibleItem = parentNoteId === 'lb_visiblelaunchers';
const isAvailableItem = parentNoteId === 'lb_availablelaunchers';
const isItem = isVisibleItem || isAvailableItem;
const canBeDeleted = !note.noteId.startsWith("lb_");
const canBeReset = note.noteId.startsWith("lb_");
return [
(isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add script shortcut', command: 'addScriptShortcut', 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: 'Add note launcher', command: 'addNoteLauncher', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add script launcher', command: 'addScriptLauncher', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add widget launcher', command: 'addWidgetLauncher', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerLauncher', uiIcon: "bx bx-plus" } : null,
(isVisibleRoot || isAvailableRoot) ? { title: "----" } : null,
{ 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: "----" },
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",
isAvailableItem ? { title: 'Move to visible launchers', command: "moveLauncherToVisible", uiIcon: "bx bx-show", enabled: true } : null,
isVisibleItem ? { title: 'Move to available launchers', command: "moveLauncherToAvailable", uiIcon: "bx bx-hide", enabled: true } : null,
{ title: `Duplicate launcher <kbd data-command="duplicateSubtree">`, command: "duplicateSubtree", uiIcon: "bx bx-empty",
enabled: isItem }
].filter(row => row !== null);
}
async selectMenuItemHandler({command}) {
if (command === 'resetShortcut') {
if (command === 'resetLauncher') {
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
and the shortcut will be returned to its original location.`);
All data / settings in this launcher (and its children) will be lost
and the launcher will be returned to its original location.`);
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;

View File

@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterRootNote(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.');
return;
}
@ -35,8 +35,8 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
'root',
hoistedNoteService.getHoistedNoteId(),
'lb_root',
'lb_availableshortcuts',
'lb_visibleshortcuts'
'lb_availablelaunchers',
'lb_visiblelaunchers'
];
if (forbiddenNoteIds.includes(afterNote.noteId)) {

View File

@ -11,6 +11,6 @@ export default class NoteRevisionsButton extends ButtonWidget {
}
isEnabled() {
return super.isEnabled() && !['shortcut', 'doc'].includes(this.note?.type);
return super.isEnabled() && !['launcher', 'doc'].includes(this.note?.type);
}
}
}

View File

@ -11,11 +11,11 @@ import BackInHistoryButtonWidget from "../buttons/history/history_back.js";
import ForwardInHistoryButtonWidget from "../buttons/history/history_forward.js";
import dialogService from "../../services/dialog.js";
export default class ShortcutContainer extends FlexContainer {
export default class LauncherContainer extends FlexContainer {
constructor() {
super('column');
this.id('shortcut-container');
this.id('launcher-container');
this.css('height', '100%');
this.filling();
@ -25,17 +25,17 @@ export default class ShortcutContainer extends FlexContainer {
async load() {
this.children = [];
const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts', true);
const visibleLaunchersRoot = await froca.getNote('lb_visiblelaunchers', true);
if (!visibleShortcutsRoot) {
console.log("Visible shortcuts root note doesn't exist.");
if (!visibleLaunchersRoot) {
console.log("Visible launchers root note doesn't exist.");
return;
}
await Promise.allSettled(
(await visibleShortcutsRoot.getChildNotes())
.map(shortcut => this.initShortcut(shortcut))
(await visibleLaunchersRoot.getChildNotes())
.map(launcher => this.initLauncher(launcher))
);
this.$widget.empty();
@ -59,68 +59,68 @@ export default class ShortcutContainer extends FlexContainer {
}
}
async initShortcut(shortcut) {
async initLauncher(launcher) {
try {
if (shortcut.type !== 'shortcut') {
console.warn(`Note ${shortcut.noteId} is not a shortcut even though it's in shortcut subtree`);
if (launcher.type !== 'launcher') {
console.warn(`Note ${launcher.noteId} is not a launcher even though it's in launcher subtree`);
return;
}
const shortcutType = shortcut.getLabelValue("shortcutType");
const launcherType = launcher.getLabelValue("launcherType");
if (shortcutType === 'command') {
if (launcherType === 'command') {
this.child(new ButtonWidget()
.title(shortcut.title)
.icon(shortcut.getIcon())
.command(shortcut.getLabelValue("command")));
} else if (shortcutType === 'note') {
// we're intentionally displaying the shortcut title and icon instead of the target
// e.g. you want to make shortcuts to 2 mermaid diagrams which both have mermaid icon (ok),
.title(launcher.title)
.icon(launcher.getIcon())
.command(launcher.getLabelValue("command")));
} else if (launcherType === 'note') {
// we're intentionally displaying the launcher title and icon instead of the target
// 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.
// 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).
// 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()
.title(shortcut.title)
.icon(shortcut.getIcon())
.title(launcher.title)
.icon(launcher.getIcon())
.onClick(() => {
const targetNoteId = shortcut.getRelationValue('targetNote');
const targetNoteId = launcher.getRelationValue('targetNote');
if (!targetNoteId) {
dialogService.info("This shortcut doesn't define target note.");
dialogService.info("This launcher doesn't define target note.");
return;
}
appContext.tabManager.openTabWithNoteWithHoisting(targetNoteId, true)
}));
} else if (shortcutType === 'script') {
} else if (launcherType === 'script') {
this.child(new ButtonWidget()
.title(shortcut.title)
.icon(shortcut.getIcon())
.title(launcher.title)
.icon(launcher.getIcon())
.onClick(async () => {
const script = await shortcut.getRelationTarget('script');
const script = await launcher.getRelationTarget('script');
await script.executeScript();
}));
} else if (shortcutType === 'customWidget') {
const widget = await shortcut.getRelationTarget('widget');
} else if (launcherType === 'customWidget') {
const widget = await launcher.getRelationTarget('widget');
if (widget) {
const res = await widget.executeScript();
this.child(res);
}
} else if (shortcutType === 'builtinWidget') {
const builtinWidget = shortcut.getLabelValue("builtinWidget");
} else if (launcherType === 'builtinWidget') {
const builtinWidget = launcher.getLabelValue("builtinWidget");
if (builtinWidget) {
if (builtinWidget === 'calendar') {
this.child(new CalendarWidget(shortcut.title, shortcut.getIcon()));
this.child(new CalendarWidget(launcher.title, launcher.getIcon()));
} else if (builtinWidget === 'spacer') {
// || has to be inside since 0 is a valid value
const baseSize = parseInt(shortcut.getLabelValue("baseSize") || "40");
const growthFactor = parseInt(shortcut.getLabelValue("growthFactor") || "100");
const baseSize = parseInt(launcher.getLabelValue("baseSize") || "40");
const growthFactor = parseInt(launcher.getLabelValue("growthFactor") || "100");
this.child(new SpacerWidget(baseSize, growthFactor));
} else if (builtinWidget === 'bookmarks') {
@ -134,15 +134,15 @@ export default class ShortcutContainer extends FlexContainer {
} else if (builtinWidget === 'forwardInHistoryButton') {
this.child(new ForwardInHistoryButtonWidget());
} 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 {
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) {
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}`);
}
}

View File

@ -197,7 +197,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
type = 'editable-code';
}
if (type === 'shortcut') {
if (type === 'launcher') {
type = 'doc';
}

View File

@ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
this.$noteTitle.val(note.title);
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);
}

View File

@ -397,7 +397,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
autoExpandMS: 600,
preventLazyParents: false,
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;
}
@ -427,7 +427,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
return false;
} else if (node.data.noteId === 'lb_root') {
return false;
} else if (node.data.noteType === 'shortcut') {
} else if (node.data.noteType === 'launcher') {
return ['before', 'after'];
} else {
return true;
@ -564,7 +564,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
$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>');
$span.append($createChildNoteButton);
@ -604,8 +604,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
const node = $.ui.fancytree.getNode(e);
if (hoistedNoteService.getHoistedNoteId() === 'lb_root') {
import("../menus/shortcut_context_menu.js").then(({default: ShortcutContextMenu}) => {
const shortcutContextMenu = new ShortcutContextMenu(this, node);
import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => {
const shortcutContextMenu = new LauncherContextMenu(this, node);
shortcutContextMenu.show(e);
});
} else {
@ -1551,11 +1551,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visibleshortcuts');
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visiblelaunchers');
}
moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availableshortcuts');
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availablelaunchers');
}
addNoteShortcutCommand({node}) {
@ -1574,8 +1574,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
this.createShortcutNote(node, 'spacer');
}
async createShortcutNote(node, shortcutType) {
const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${shortcutType}`);
async createShortcutNote(node, launcherType) {
const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${launcherType}`);
if (!resp.success) {
alert(resp.message);

View File

@ -8,7 +8,7 @@ const NOTE_TYPES = [
{ type: "image", title: "Image", selectable: false },
{ type: "search", title: "Saved Search", 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: "text", mime: "text/html", title: "Text", selectable: true },

View File

@ -66,12 +66,12 @@ function getHoistedNote() {
return becca.getNote(cls.getHoistedNoteId());
}
function createShortcut(req) {
return specialNotesService.createShortcut(req.params.parentNoteId, req.params.shortcutType);
function createLauncher(req) {
return specialNotesService.createLauncher(req.params.parentNoteId, req.params.launcherType);
}
function resetShortcut(req) {
return specialNotesService.resetShortcut(req.params.noteId);
function resetLauncher(req) {
return specialNotesService.resetLauncher(req.params.noteId);
}
module.exports = {
@ -85,6 +85,6 @@ module.exports = {
saveSqlConsole,
createSearchNote,
saveSearchNote,
createShortcut,
resetShortcut
createLauncher,
resetLauncher
};

View File

@ -326,8 +326,8 @@ function register(app) {
apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);
apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
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/shortcuts/:parentNoteId/:shortcutType', specialNotesRoute.createShortcut);
apiRoute(POST, '/api/special-notes/launchers/:noteId/reset', specialNotesRoute.resetLauncher);
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
route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);

View File

@ -11,6 +11,6 @@ module.exports = [
'mermaid',
'canvas',
'web-view',
'shortcut',
'launcher',
'doc'
];

View File

@ -110,16 +110,16 @@ function getAndValidateParent(params) {
throw new Error(`Parent note "${params.parentNoteId}" not found.`);
}
if (parentNote.type === 'shortcut') {
throw new Error(`Shortcuts should not have child notes.`);
if (parentNote.type === 'launcher') {
throw new Error(`Launchers should not have child notes.`);
}
if (!params.ignoreForbiddenParents && ['lb_root'].includes(parentNote.noteId)) {
throw new Error(`Creating child notes into '${parentNote.noteId}' is not allowed.`);
}
if (['lb_availableshortcuts', 'lb_visibleshortcuts'].includes(parentNote.noteId) && params.type !== 'shortcut') {
throw new Error(`Creating child notes into '${parentNote.noteId}' is only possible for 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 'launcher'.`);
}
return parentNote;

View File

@ -8,7 +8,7 @@ const dateUtils = require("./date_utils");
const LBTPL_ROOT = "lbtpl_root";
const LBTPL_BASE = "lbtpl_base";
const LBTPL_COMMAND = "lbtpl_command";
const LBTPL_NOTE_SHORTCUT = "lbtpl_noteshortcut";
const LBTPL_NOTE_LAUNCHER = "lbtpl_notelauncher";
const LBTPL_SCRIPT = "lbtpl_script";
const LBTPL_BUILTIN_WIDGET = "lbtpl_builtinwidget";
const LBTPL_SPACER = "lbtpl_spacer";
@ -276,14 +276,14 @@ function getLaunchBarRoot() {
return note;
}
function getLaunchBarAvailableShortcutsRoot() {
let note = becca.getNote('lb_availableshortcuts');
function getLaunchBarAvailableLaunchersRoot() {
let note = becca.getNote('lb_availablelaunchers');
if (!note) {
note = noteService.createNewNote({
branchId: 'lb_availableshortcuts',
noteId: 'lb_availableshortcuts',
title: 'Available shortcuts',
branchId: 'lb_availablelaunchers',
noteId: 'lb_availablelaunchers',
title: 'Available launchers',
type: 'doc',
content: '',
parentNoteId: getLaunchBarRoot().noteId,
@ -294,7 +294,7 @@ function getLaunchBarAvailableShortcutsRoot() {
note.addLabel("docName", "launchbar_intro");
}
const branch = becca.getBranch('lb_availableshortcuts');
const branch = becca.getBranch('lb_availablelaunchers');
if (!branch.isExpanded) {
branch.isExpanded = true;
branch.save();
@ -303,14 +303,14 @@ function getLaunchBarAvailableShortcutsRoot() {
return note;
}
function getLaunchBarVisibleShortcutsRoot() {
let note = becca.getNote('lb_visibleshortcuts');
function getLaunchBarVisibleLaunchersRoot() {
let note = becca.getNote('lb_visiblelaunchers');
if (!note) {
note = noteService.createNewNote({
branchId: 'lb_visibleshortcuts',
noteId: 'lb_visibleshortcuts',
title: 'Visible shortcuts',
branchId: 'lb_visiblelaunchers',
noteId: 'lb_visiblelaunchers',
title: 'Visible launchers',
type: 'doc',
content: '',
parentNoteId: getLaunchBarRoot().noteId,
@ -321,7 +321,7 @@ function getLaunchBarVisibleShortcutsRoot() {
note.addLabel("docName", "launchbar_intro");
}
const branch = becca.getBranch('lb_visibleshortcuts');
const branch = becca.getBranch('lb_visiblelaunchers');
if (!branch.isExpanded) {
branch.isExpanded = true;
branch.save();
@ -330,8 +330,8 @@ function getLaunchBarVisibleShortcutsRoot() {
return note;
}
const shortcuts = [
// visible shortcuts:
const launchers = [
// visible launchers:
{ 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_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_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_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 },
@ -353,53 +353,53 @@ function createMissingSpecialNotes() {
getSqlConsoleRoot();
getGlobalNoteMap();
getBulkActionNote();
createShortcutTemplates();
createLauncherTemplates();
getLaunchBarRoot();
getLaunchBarAvailableShortcutsRoot();
getLaunchBarVisibleShortcutsRoot();
getLaunchBarAvailableLaunchersRoot();
getLaunchBarVisibleLaunchersRoot();
getShareRoot();
for (const shortcut of shortcuts) {
let note = becca.getNote(shortcut.id);
for (const launcher of launchers) {
let note = becca.getNote(launcher.id);
if (note) {
continue;
}
const parentNoteId = shortcut.isVisible
? getLaunchBarVisibleShortcutsRoot().noteId
: getLaunchBarAvailableShortcutsRoot().noteId;
const parentNoteId = launcher.isVisible
? getLaunchBarVisibleLaunchersRoot().noteId
: getLaunchBarAvailableLaunchersRoot().noteId;
note = noteService.createNewNote({
noteId: shortcut.id,
title: shortcut.title,
type: 'shortcut',
noteId: launcher.id,
title: launcher.title,
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
if (shortcut.icon) {
note.addLabel('iconClass', shortcut.icon);
if (launcher.icon) {
note.addLabel('iconClass', launcher.icon);
}
if (shortcut.command) {
if (launcher.command) {
note.addRelation('template', LBTPL_COMMAND);
note.addLabel('command', shortcut.command);
} else if (shortcut.builtinWidget) {
if (shortcut.builtinWidget === 'spacer') {
note.addLabel('command', launcher.command);
} else if (launcher.builtinWidget) {
if (launcher.builtinWidget === 'spacer') {
note.addRelation('template', LBTPL_SPACER);
note.addLabel("baseSize", shortcut.baseSize);
note.addLabel("growthFactor", shortcut.growthFactor);
note.addLabel("baseSize", launcher.baseSize);
note.addLabel("growthFactor", launcher.growthFactor);
} else {
note.addRelation('template', LBTPL_BUILTIN_WIDGET);
}
note.addLabel('builtinWidget', shortcut.builtinWidget);
} else if (shortcut.targetNoteId) {
note.addRelation('template', LBTPL_NOTE_SHORTCUT);
note.addRelation('targetNote', shortcut.targetNoteId);
note.addLabel('builtinWidget', launcher.builtinWidget);
} else if (launcher.targetNoteId) {
note.addRelation('template', LBTPL_NOTE_LAUNCHER);
note.addRelation('targetNote', launcher.targetNoteId);
} 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;
if (shortcutType === 'note') {
if (launcherType === 'note') {
note = noteService.createNewNote({
title: "Note shortcut",
type: 'shortcut',
title: "Note launcher",
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', LBTPL_NOTE_SHORTCUT);
} else if (shortcutType === 'script') {
note.addRelation('template', LBTPL_NOTE_LAUNCHER);
} else if (launcherType === 'script') {
note = noteService.createNewNote({
title: "Script shortcut",
type: 'shortcut',
title: "Script launcher",
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', LBTPL_SCRIPT);
} else if (shortcutType === 'customWidget') {
} else if (launcherType === 'customWidget') {
note = noteService.createNewNote({
title: "Widget shortcut",
type: 'shortcut',
title: "Widget launcher",
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', LBTPL_CUSTOM_WIDGET);
} else if (shortcutType === 'spacer') {
} else if (launcherType === 'spacer') {
note = noteService.createNewNote({
title: "Spacer",
type: 'shortcut',
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', LBTPL_SPACER);
} else {
throw new Error(`Unrecognized shortcut type ${shortcutType}`);
throw new Error(`Unrecognized launcher type ${launcherType}`);
}
return {
@ -461,7 +461,7 @@ function createShortcut(parentNoteId, shortcutType) {
};
}
function createShortcutTemplates() {
function createLauncherTemplates() {
if (!(LBTPL_ROOT in becca.notes)) {
noteService.createNewNote({
branchId: LBTPL_ROOT,
@ -477,43 +477,43 @@ function createShortcutTemplates() {
const tpl = noteService.createNewNote({
branchId: LBTPL_BASE,
noteId: LBTPL_BASE,
title: 'Launch bar base shortcut',
title: 'Launch bar base launcher',
type: 'doc',
content: '',
parentNoteId: getHiddenRoot().noteId
}).note;
tpl.addLabel('label:keyboardShortcut', 'promoted,text');
tpl.addLabel('label:keyboardLauncher', 'promoted,text');
}
if (!(LBTPL_COMMAND in becca.notes)) {
const tpl = noteService.createNewNote({
branchId: LBTPL_COMMAND,
noteId: LBTPL_COMMAND,
title: 'Command shortcut',
title: 'Command launcher',
type: 'doc',
content: '',
parentNoteId: LBTPL_ROOT
}).note;
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({
branchId: LBTPL_NOTE_SHORTCUT,
noteId: LBTPL_NOTE_SHORTCUT,
title: 'Note shortcut',
branchId: LBTPL_NOTE_LAUNCHER,
noteId: LBTPL_NOTE_LAUNCHER,
title: 'Note launcher',
type: 'doc',
content: '',
parentNoteId: LBTPL_ROOT
}).note;
tpl.addRelation('template', LBTPL_BASE);
tpl.addLabel('shortcutType', 'note');
tpl.addLabel('launcherType', 'note');
tpl.addLabel('relation:targetNote', 'promoted');
tpl.addLabel('docName', 'launchbar_note_shortcut');
tpl.addLabel('docName', 'launchbar_note_launcher');
}
if (!(LBTPL_SCRIPT in becca.notes)) {
@ -527,9 +527,9 @@ function createShortcutTemplates() {
}).note;
tpl.addRelation('template', LBTPL_BASE);
tpl.addLabel('shortcutType', 'script');
tpl.addLabel('launcherType', 'script');
tpl.addLabel('relation:script', 'promoted');
tpl.addLabel('docName', 'launchbar_script_shortcut');
tpl.addLabel('docName', 'launchbar_script_launcher');
}
if (!(LBTPL_BUILTIN_WIDGET in becca.notes)) {
@ -543,7 +543,7 @@ function createShortcutTemplates() {
}).note;
tpl.addRelation('template', LBTPL_BASE);
tpl.addLabel('shortcutType', 'builtinWidget');
tpl.addLabel('launcherType', 'builtinWidget');
}
if (!(LBTPL_SPACER in becca.notes)) {
@ -575,13 +575,13 @@ function createShortcutTemplates() {
}).note;
tpl.addRelation('template', LBTPL_BASE);
tpl.addLabel('shortcutType', 'customWidget');
tpl.addLabel('launcherType', 'customWidget');
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_')) {
const note = becca.getNote(noteId);
@ -598,7 +598,7 @@ function resetShortcut(noteId) {
log.info(`Note ${noteId} has not been found and cannot be reset.`);
}
} else {
log.info(`Note ${noteId} is not a resettable shortcut note.`);
log.info(`Note ${noteId} is not a resettable launcher note.`);
}
createMissingSpecialNotes();
@ -614,6 +614,6 @@ module.exports = {
getShareRoot,
getHiddenRoot,
getBulkActionNote,
createShortcut,
resetShortcut
createLauncher,
resetLauncher
};

View File

@ -30,7 +30,7 @@ function getNotes(noteIds) {
}
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.`};
}
@ -58,10 +58,10 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
};
}
if (becca.getNote(parentNoteId).type === 'shortcut') {
if (becca.getNote(parentNoteId).type === 'launcher') {
return {
success: false,
message: 'Shortcut note cannot have any children.'
message: 'Launcher note cannot have any children.'
};
}