From 0985314fb7f41c4452adf401a89042264fc91fa6 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 30 Nov 2022 16:57:51 +0100 Subject: [PATCH] shortcut improvements --- .../backend_api/becca_entities_branch.js.html | 12 +- docs/frontend_api/FrontendScriptApi.html | 491 +++--------------- docs/frontend_api/NoteShort.html | 114 ++-- docs/frontend_api/entities_note_short.js.html | 12 +- docs/frontend_api/global.html | 2 +- .../services_frontend_script_api.js.html | 60 +-- .../app/services/frontend_script_api.js | 46 +- .../app/widgets/buttons/button_from_note.js | 23 +- .../widgets/containers/shortcut_container.js | 23 +- src/services/special_notes.js | 28 +- 10 files changed, 183 insertions(+), 628 deletions(-) diff --git a/docs/backend_api/becca_entities_branch.js.html b/docs/backend_api/becca_entities_branch.js.html index 5cf5b3d74..f3bfd2fd8 100644 --- a/docs/backend_api/becca_entities_branch.js.html +++ b/docs/backend_api/becca_entities_branch.js.html @@ -221,9 +221,15 @@ class Branch extends AbstractEntity { beforeSaving() { if (this.notePosition === undefined || this.notePosition === null) { - // TODO finding new position can be refactored into becca - const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]); - this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10; + let maxNotePos = 0; + + for (const childBranch of this.parentNote.getChildBranches()) { + if (maxNotePos < childBranch.notePosition && childBranch.branchId !== 'hidden') { + maxNotePos = childBranch.notePosition; + } + } + + this.notePosition = maxNotePos + 10; } if (!this.isExpanded) { diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index 025609d27..b5a58a4fb 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -81,7 +81,7 @@
Source:
@@ -223,7 +223,7 @@
Source:
@@ -329,7 +329,7 @@
Source:
@@ -435,7 +435,7 @@
Source:
@@ -541,329 +541,7 @@
Source:
- - - - - - - - - - - - - - - - -

NoteContextCachingWidget

- - - - - - - - - - -
Properties:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - -NoteContextAwareWidget - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - -

TabAwareWidget

- - - - - - - - - - -
Properties:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - -NoteContextAwareWidget - - - -
- - - - -
- - - - - - - - - - - - - - - - -
Deprecated:
  • use NoteContextAwareWidget instead
- - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - -

TabCachingWidget

- - - - - - - - - - -
Properties:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeDescription
- - -NoteContextCachingWidget - - - -
- - - - -
- - - - - - - - - - - - - - - - -
Deprecated:
  • use NoteContextCachingWidget instead
- - - - - - - - - - - -
Source:
-
@@ -973,7 +651,7 @@
Source:
@@ -1086,7 +764,7 @@
Source:
@@ -1196,7 +874,7 @@
Source:
@@ -1325,7 +1003,7 @@
Source:
@@ -1480,7 +1158,7 @@
Source:
@@ -1534,16 +1212,13 @@ -

addButtonToToolbar(opts)

+

addButtonToToolbar()

-
- Adds new button to the plugin area. -
@@ -1553,56 +1228,6 @@ -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
opts - - -ToolbarButtonOptions - - - -
- - - @@ -1623,6 +1248,8 @@ +
Deprecated:
  • this API has no effect anymore. Use bookmarks or launchpad shortcuts instead.
+ @@ -1635,7 +1262,7 @@
Source:
@@ -1772,7 +1399,7 @@
Source:
@@ -1911,7 +1538,7 @@
Source:
@@ -2067,7 +1694,7 @@
Source:
@@ -2431,7 +2058,7 @@
Source:
@@ -2564,7 +2191,7 @@
Source:
@@ -2674,7 +2301,7 @@
Source:
@@ -2780,7 +2407,7 @@
Source:
@@ -2886,7 +2513,7 @@
Source:
@@ -2996,7 +2623,7 @@
Source:
@@ -3107,7 +2734,7 @@ implementation of actual widget type.
Source:
@@ -3211,7 +2838,7 @@ implementation of actual widget type.
Source:
@@ -3319,7 +2946,7 @@ implementation of actual widget type.
Source:
@@ -3487,7 +3114,7 @@ implementation of actual widget type.
Source:
@@ -3624,7 +3251,7 @@ implementation of actual widget type.
Source:
@@ -3781,7 +3408,7 @@ implementation of actual widget type.
Source:
@@ -3936,7 +3563,7 @@ implementation of actual widget type.
Source:
@@ -4043,7 +3670,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4198,7 +3825,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4354,7 +3981,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4555,7 +4182,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4661,7 +4288,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4816,7 +4443,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4971,7 +4598,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5121,7 +4748,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5281,7 +4908,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5459,7 +5086,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5610,7 +5237,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5718,7 +5345,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5874,7 +5501,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6030,7 +5657,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6167,7 +5794,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6321,7 +5948,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6407,7 +6034,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6544,7 +6171,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6705,7 +6332,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6813,7 +6440,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6951,7 +6578,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7107,7 +6734,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7262,7 +6889,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7413,7 +7040,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7550,7 +7177,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7687,7 +7314,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7847,7 +7474,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -8007,7 +7634,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -8099,7 +7726,7 @@ Typical use case is when new note has been created, we should wait until it is s
Source:
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html index 22a030fdb..2bcc4f67c 100644 --- a/docs/frontend_api/NoteShort.html +++ b/docs/frontend_api/NoteShort.html @@ -167,7 +167,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -267,7 +267,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -335,7 +335,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -403,7 +403,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -471,7 +471,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -543,7 +543,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -611,7 +611,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -679,7 +679,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -747,7 +747,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -815,7 +815,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -883,7 +883,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -955,7 +955,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1103,7 +1103,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1281,7 +1281,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1481,7 +1481,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1589,7 +1589,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1693,7 +1693,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1795,7 +1795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1897,7 +1897,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1999,7 +1999,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2150,7 +2150,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2305,7 +2305,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2472,7 +2472,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2582,7 +2582,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2756,7 +2756,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2934,7 +2934,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3134,7 +3134,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3289,7 +3289,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3444,7 +3444,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3611,7 +3611,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3766,7 +3766,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3921,7 +3921,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4088,7 +4088,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4194,7 +4194,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4296,7 +4296,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4398,7 +4398,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4500,7 +4500,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4651,7 +4651,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4806,7 +4806,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4976,7 +4976,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5127,7 +5127,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5294,7 +5294,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5400,7 +5400,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5513,7 +5513,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5619,7 +5619,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5721,7 +5721,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5895,7 +5895,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6001,7 +6001,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6152,7 +6152,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6330,7 +6330,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6485,7 +6485,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6640,7 +6640,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6795,7 +6795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6903,7 +6903,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6987,7 +6987,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -7093,7 +7093,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -7199,7 +7199,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html index 254372125..abf7ce38c 100644 --- a/docs/frontend_api/entities_note_short.js.html +++ b/docs/frontend_api/entities_note_short.js.html @@ -48,7 +48,9 @@ const NOTE_TYPE_ICONS = { "note-map": "bx bx-map-alt", "mermaid": "bx bx-selection", "canvas": "bx bx-pen", - "web-view": "bx bx-globe-alt" + "web-view": "bx bx-globe-alt", + "shortcut": "bx bx-link", + "doc": "bx bxs-file-doc" }; /** @@ -818,10 +820,10 @@ class NoteShort { if (env === "frontend") { const bundleService = (await import("../services/bundle.js")).default; - await bundleService.getAndExecuteBundle(this.noteId); + return await bundleService.getAndExecuteBundle(this.noteId); } else if (env === "backend") { - await server.post('script/run/' + this.noteId); + return await server.post('script/run/' + this.noteId); } else { throw new Error(`Unrecognized env type ${env} for note ${this.noteId}`); @@ -851,6 +853,10 @@ class NoteShort { isContentAvailable() { return !this.isProtected || protectedSessionHolder.isProtectedSessionAvailable() } + + isLaunchBarConfig() { + return this.type === 'shortcut' || this.noteId.startsWith("lb_"); + } } export default NoteShort; diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html index c988f8be7..8b0eb68af 100644 --- a/docs/frontend_api/global.html +++ b/docs/frontend_api/global.html @@ -395,7 +395,7 @@
Source:
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index 27d8ffe88..fe85e94db 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -39,7 +39,6 @@ import CollapsibleWidget from '../widgets/collapsible_widget.js'; import ws from "./ws.js"; import appContext from "./app_context.js"; import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js"; -import NoteContextCachingWidget from "../widgets/note_context_caching_widget.js"; import BasicWidget from "../widgets/basic_widget.js"; import SpacedUpdate from "./spaced_update.js"; @@ -68,24 +67,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain /** @property {CollapsibleWidget} */ this.CollapsibleWidget = CollapsibleWidget; - /** - * @property {NoteContextAwareWidget} - * @deprecated use NoteContextAwareWidget instead - */ - this.TabAwareWidget = NoteContextAwareWidget; - /** @property {NoteContextAwareWidget} */ this.NoteContextAwareWidget = NoteContextAwareWidget; - /** - * @property {NoteContextCachingWidget} - * @deprecated use NoteContextCachingWidget instead - */ - this.TabCachingWidget = NoteContextCachingWidget; - - /** @property {NoteContextAwareWidget} */ - this.NoteContextCachingWidget = NoteContextCachingWidget; - /** @property {BasicWidget} */ this.BasicWidget = BasicWidget; @@ -159,49 +143,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ /** - * Adds new button to the plugin area. - * - * @param {ToolbarButtonOptions} opts + * @deprecated this API has no effect anymore. Use bookmarks or launchpad shortcuts instead. */ - this.addButtonToToolbar = opts => { - const buttonId = "toolbar-button-" + opts.title.replace(/\s/g, "-"); - - let button; - if (utils.isMobile()) { - $('#plugin-buttons-placeholder').remove(); - button = $('<a class="dropdown-item" href="#">') - .on('click', () => { - setTimeout(() => $pluginButtons.dropdown('hide'), 0); - }); - - if (opts.icon) { - button.append($("<span>").addClass("bx bx-" + opts.icon)) - .append("&nbsp;"); - } - - button.append($("<span>").text(opts.title)); - } else { - button = $('<span class="button-widget icon-action bx" data-toggle="tooltip" title="" data-placement="right"></span>') - .addClass("bx bx-" + (opts.icon || "question-mark")); - - button.attr("title", opts.title); - button.tooltip({html: true}); - } - - button = button.on('click', opts.action); - - button.attr('id', buttonId); - - if ($("#" + buttonId).replaceWith(button).length === 0) { - $pluginButtons.append(button); - } - - if (opts.shortcut) { - utils.bindGlobalShortcut(opts.shortcut, opts.action); - - button.attr("title", "Shortcut " + opts.shortcut); - } - }; + this.addButtonToToolbar = () => console.warn("api.addButtonToToolbar() calls are deprecated and have no effect"); function prepareParams(params) { if (!params) { diff --git a/src/public/app/services/frontend_script_api.js b/src/public/app/services/frontend_script_api.js index 7b32a23ac..0b40b0333 100644 --- a/src/public/app/services/frontend_script_api.js +++ b/src/public/app/services/frontend_script_api.js @@ -21,8 +21,6 @@ import SpacedUpdate from "./spaced_update.js"; * @hideconstructor */ function FrontendScriptApi(startNote, currentNote, originEntity = null, $container = null) { - const $pluginButtons = $("#plugin-buttons"); - /** @property {jQuery} container of all the rendered script content */ this.$container = $container; @@ -115,49 +113,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ /** - * Adds new button to the plugin area. - * - * @param {ToolbarButtonOptions} opts + * @deprecated this API has no effect anymore. Use bookmarks or launchpad shortcuts instead. */ - this.addButtonToToolbar = opts => { - const buttonId = "toolbar-button-" + opts.title.replace(/\s/g, "-"); - - let button; - if (utils.isMobile()) { - $('#plugin-buttons-placeholder').remove(); - button = $('') - .on('click', () => { - setTimeout(() => $pluginButtons.dropdown('hide'), 0); - }); - - if (opts.icon) { - button.append($("").addClass("bx bx-" + opts.icon)) - .append(" "); - } - - button.append($("").text(opts.title)); - } else { - button = $('') - .addClass("bx bx-" + (opts.icon || "question-mark")); - - button.attr("title", opts.title); - button.tooltip({html: true}); - } - - button = button.on('click', opts.action); - - button.attr('id', buttonId); - - if ($("#" + buttonId).replaceWith(button).length === 0) { - $pluginButtons.append(button); - } - - if (opts.shortcut) { - utils.bindGlobalShortcut(opts.shortcut, opts.action); - - button.attr("title", "Shortcut " + opts.shortcut); - } - }; + this.addButtonToToolbar = () => console.warn("api.addButtonToToolbar() calls are deprecated and have no effect"); function prepareParams(params) { if (!params) { diff --git a/src/public/app/widgets/buttons/button_from_note.js b/src/public/app/widgets/buttons/button_from_note.js index f9ac81a6b..e6c021160 100644 --- a/src/public/app/widgets/buttons/button_from_note.js +++ b/src/public/app/widgets/buttons/button_from_note.js @@ -7,7 +7,6 @@ export default class ButtonFromNoteWidget extends ButtonWidget { super(); this.settings.buttonNoteIdProvider = null; - this.settings.defaultIconProvider = null; } buttonNoteIdProvider(provider) { @@ -15,11 +14,6 @@ export default class ButtonFromNoteWidget extends ButtonWidget { return this; } - defaultIconProvider(provider) { - this.settings.defaultIconProvider = provider; - return this; - } - doRender() { super.doRender(); @@ -29,17 +23,16 @@ export default class ButtonFromNoteWidget extends ButtonWidget { updateIcon() { const buttonNoteId = this.settings.buttonNoteIdProvider(); - if (!buttonNoteId && this.settings.defaultIconProvider()) { - this.settings.icon = this.settings.defaultIconProvider(); + if (!buttonNoteId) { + console.error(`buttonNoteId for '${this.componentId}' is not defined.`); + return; + } + + froca.getNote(buttonNoteId).then(note => { + this.settings.icon = note.getIcon(); this.refreshIcon(); - } else { - froca.getNote(buttonNoteId).then(note => { - this.settings.icon = note.getIcon(); - - this.refreshIcon(); - }); - } + }); } entitiesReloadedEvent({loadResults}) { diff --git a/src/public/app/widgets/containers/shortcut_container.js b/src/public/app/widgets/containers/shortcut_container.js index 4215b8ca9..ba2f7a5d2 100644 --- a/src/public/app/widgets/containers/shortcut_container.js +++ b/src/public/app/widgets/containers/shortcut_container.js @@ -10,7 +10,6 @@ import SyncStatusWidget from "../sync_status.js"; import BackInHistoryButtonWidget from "../buttons/history/history_back.js"; import ForwardInHistoryButtonWidget from "../buttons/history/history_forward.js"; import dialogService from "../../services/dialog.js"; -import ButtonFromNoteWidget from "../buttons/button_from_note.js"; export default class ShortcutContainer extends FlexContainer { constructor() { @@ -75,10 +74,16 @@ export default class ShortcutContainer extends FlexContainer { .icon(shortcut.getIcon()) .command(shortcut.getLabelValue("command"))); } else if (shortcutType === 'note') { - this.child(new ButtonFromNoteWidget() + // 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), + // 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) - .buttonNoteIdProvider(() => shortcut.getRelationValue('targetNote')) - .defaultIconProvider(() => shortcut.getIcon()) + .icon(shortcut.getIcon()) .onClick(() => { const targetNoteId = shortcut.getRelationValue('targetNote'); @@ -101,9 +106,11 @@ export default class ShortcutContainer extends FlexContainer { } else if (shortcutType === 'customWidget') { const widget = await shortcut.getRelationTarget('widget'); - const res = await widget.executeScript(); + if (widget) { + const res = await widget.executeScript(); - this.child(res); + this.child(res); + } } else if (shortcutType === 'builtinWidget') { const builtinWidget = shortcut.getLabelValue("builtinWidget"); @@ -116,10 +123,6 @@ export default class ShortcutContainer extends FlexContainer { const growthFactor = parseInt(shortcut.getLabelValue("growthFactor") || "100"); this.child(new SpacerWidget(baseSize, growthFactor)); - } else if (builtinWidget === 'pluginButtons') { - this.child(new FlexContainer("column") - .id("plugin-buttons") - .contentSized()); } else if (builtinWidget === 'bookmarks') { this.child(new BookmarkButtons()); } else if (builtinWidget === 'protectedSession') { diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 37bb6e495..c0087d60c 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -6,6 +6,7 @@ const cls = require("./cls"); 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_SCRIPT = "lbtpl_script"; @@ -336,10 +337,9 @@ const shortcuts = [ { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, { id: 'lb_notemap', targetNoteId: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true }, { id: 'lb_calendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true }, - { id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true }, - { id: 'lb_pluginbuttons', builtinWidget: 'pluginButtons', title: 'Plugin buttons', icon: 'bx bx-extension', isVisible: true }, + { id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: 50, growthFactor: 0 }, { id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true }, - { id: 'lb_spacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true }, + { id: 'lb_spacer2', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: 0, growthFactor: 1 }, { 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 }, @@ -388,6 +388,8 @@ function createMissingSpecialNotes() { } else if (shortcut.builtinWidget) { if (shortcut.builtinWidget === 'spacer') { note.addRelation('template', LBTPL_SPACER); + note.addLabel("baseSize", shortcut.baseSize); + note.addLabel("growthFactor", shortcut.growthFactor); } else { note.addRelation('template', LBTPL_BUILTIN_WIDGET); } @@ -471,6 +473,19 @@ function createShortcutTemplates() { }); } + if (!(LBTPL_BASE in becca.notes)) { + const tpl = noteService.createNewNote({ + branchId: LBTPL_BASE, + noteId: LBTPL_BASE, + title: 'Launch bar base shortcut', + type: 'doc', + content: '', + parentNoteId: getHiddenRoot().noteId + }).note; + + tpl.addLabel('label:keyboardShortcut', 'promoted,text'); + } + if (!(LBTPL_COMMAND in becca.notes)) { const tpl = noteService.createNewNote({ branchId: LBTPL_COMMAND, @@ -481,6 +496,7 @@ function createShortcutTemplates() { parentNoteId: LBTPL_ROOT }).note; + tpl.addRelation('template', LBTPL_BASE); tpl.addLabel('shortcutType', 'command'); } @@ -494,6 +510,7 @@ function createShortcutTemplates() { parentNoteId: LBTPL_ROOT }).note; + tpl.addRelation('template', LBTPL_BASE); tpl.addLabel('shortcutType', 'note'); tpl.addLabel('relation:targetNote', 'promoted'); tpl.addLabel('docName', 'launchbar_note_shortcut'); @@ -509,6 +526,7 @@ function createShortcutTemplates() { parentNoteId: LBTPL_ROOT }).note; + tpl.addRelation('template', LBTPL_BASE); tpl.addLabel('shortcutType', 'script'); tpl.addLabel('relation:script', 'promoted'); tpl.addLabel('docName', 'launchbar_script_shortcut'); @@ -524,6 +542,7 @@ function createShortcutTemplates() { parentNoteId: LBTPL_ROOT }).note; + tpl.addRelation('template', LBTPL_BASE); tpl.addLabel('shortcutType', 'builtinWidget'); } @@ -541,9 +560,7 @@ function createShortcutTemplates() { tpl.addLabel('builtinWidget', 'spacer'); tpl.addLabel('iconClass', 'bx bx-move-vertical'); tpl.addLabel('label:baseSize', 'promoted,number'); - tpl.addLabel('baseSize', '40'); tpl.addLabel('label:growthFactor', 'promoted,number'); - tpl.addLabel('growthFactor', '0'); tpl.addLabel('docName', 'launchbar_spacer'); } @@ -557,6 +574,7 @@ function createShortcutTemplates() { parentNoteId: LBTPL_ROOT }).note; + tpl.addRelation('template', LBTPL_BASE); tpl.addLabel('shortcutType', 'customWidget'); tpl.addLabel('relation:widget', 'promoted'); tpl.addLabel('docName', 'launchbar_widget_shortcut');