diff --git a/src/public/app/doc_notes/launchbar_note_shortcut.html b/src/public/app/doc_notes/launchbar_note_shortcut.html new file mode 100644 index 000000000..055bca59e --- /dev/null +++ b/src/public/app/doc_notes/launchbar_note_shortcut.html @@ -0,0 +1,3 @@ +
Please define the target note in the promoted attributes.
+ +Launchbar displays the title / icon from the shortcut which does not necessarily mirrors those of the target note.
diff --git a/src/public/app/doc_notes/launchbar_script_shortcut.html b/src/public/app/doc_notes/launchbar_script_shortcut.html new file mode 100644 index 000000000..2bad3c1ea --- /dev/null +++ b/src/public/app/doc_notes/launchbar_script_shortcut.html @@ -0,0 +1,3 @@ +Please define the target script note in the promoted attributes. This script will be executed immediately upon clicking the launchbar icon.
+ +Launchbar displays the title / icon from the shortcut which does not necessarily mirrors those of the target script note.
diff --git a/src/public/app/doc_notes/launchbar_spacer.html b/src/public/app/doc_notes/launchbar_spacer.html new file mode 100644 index 000000000..3390763ca --- /dev/null +++ b/src/public/app/doc_notes/launchbar_spacer.html @@ -0,0 +1,6 @@ +Spacer allows you to visually group shortcuts. You can configure it in the promoted attributes:
+ +baseSize
- defines size in pixels (if there's enough space)growthFactor
- set to 0 if you want the spacer to be of constant baseSize
, with positive value it will grow.Please define the target widget note in the promoted attributes. The widget will be used to render the launchbar icon.
diff --git a/src/public/app/menus/shortcut_context_menu.js b/src/public/app/menus/shortcut_context_menu.js index 6750e5737..74b05f072 100644 --- a/src/public/app/menus/shortcut_context_menu.js +++ b/src/public/app/menus/shortcut_context_menu.js @@ -1,8 +1,6 @@ import treeService from '../services/tree.js'; import froca from "../services/froca.js"; -import noteCreateService from "../services/note_create.js"; import contextMenu from "./context_menu.js"; -import appContext from "../services/app_context.js"; export default class ShortcutContextMenu { /** @@ -36,6 +34,7 @@ export default class ShortcutContextMenu { 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: "----" } : null, diff --git a/src/public/app/services/clipboard.js b/src/public/app/services/clipboard.js index 235fe8381..3ee16b68a 100644 --- a/src/public/app/services/clipboard.js +++ b/src/public/app/services/clipboard.js @@ -54,10 +54,10 @@ async function pasteInto(parentBranchId) { await branchService.cloneNoteToBranch(clipboardNote.noteId, parentBranchId); } - // copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places + // copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places } else { - toastService.throwError("Unrecognized clipboard mode=" + mode); + toastService.throwError("Unrecognized clipboard mode=" + clipboardMode); } } diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 3da0c0eab..7a263cd87 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -1521,6 +1521,10 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { this.createShortcutNote(node, 'note'); } + addScriptShortcutCommand({node}) { + this.createShortcutNote(node, 'script'); + } + addWidgetShortcutCommand({node}) { this.createShortcutNote(node, 'widget'); } diff --git a/src/services/branches.js b/src/services/branches.js index c18ee8b32..f35db98df 100644 --- a/src/services/branches.js +++ b/src/services/branches.js @@ -1,5 +1,5 @@ -const treeService = require("./tree.js"); -const sql = require("./sql.js"); +const treeService = require("./tree"); +const sql = require("./sql"); function moveBranchToNote(sourceBranch, targetParentNoteId) { if (sourceBranch.parentNoteId === targetParentNoteId) { diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 93ef52e8e..d24772184 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -394,6 +394,17 @@ function createShortcut(parentNoteId, type) { }).note; note.addLabel('relation:targetNote', 'promoted'); + note.addLabel('docName', 'launchbar_note_shortcut'); + } else if (type === 'script') { + note = noteService.createNewNote({ + title: "Script shortcut", + type: 'shortcut', + content: '', + parentNoteId: parentNoteId + }).note; + + note.addLabel('relation:script', 'promoted'); + note.addLabel('docName', 'launchbar_script_shortcut'); } else if (type === 'widget') { note = noteService.createNewNote({ title: "Widget shortcut", @@ -403,6 +414,7 @@ function createShortcut(parentNoteId, type) { }).note; note.addLabel('relation:widget', 'promoted'); + note.addLabel('docName', 'launchbar_widget_shortcut'); } else if (type === 'spacer') { note = noteService.createNewNote({ title: "Spacer", @@ -417,6 +429,7 @@ function createShortcut(parentNoteId, type) { note.addLabel('baseSize', '40'); note.addLabel('label:growthFactor', 'promoted,number'); note.addLabel('growthFactor', '0'); + note.addLabel('docName', 'launchbar_spacer'); } else { throw new Error(`Unrecognized shortcut type ${type}`); } diff --git a/src/services/tree.js b/src/services/tree.js index 218777183..b231c6038 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -58,6 +58,16 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { }; } + const parentNoteIsShortcut = becca.getNote(parentNoteId).type === 'shortcut'; + const childNoteIsShortcut = becca.getNote(childNoteId).type === 'shortcut'; + + if (parentNoteIsShortcut !== childNoteIsShortcut) { + return { + success: false, + message: 'Moving/cloning is not possible between shortcuts / normal notes.' + }; + } + return { success: true }; }