reimplementation of frontend's api.addButtonToToolbar() to smoothen the upgrade

This commit is contained in:
zadam
2022-12-17 21:46:51 +01:00
parent 967919b400
commit 5af506e268
14 changed files with 382 additions and 161 deletions

View File

@@ -134,7 +134,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
};
/**
* @typedef {Object} ToolbarButtonOptions
* @typedef {Object} CreateOrUpdateLauncherOptions
* @property {string} [id] - id of the button, used to identify the old instances of this button to be replaced
* ID is optional because of BC, but not specifying it is deprecated. ID can be alphanumeric only.
* @property {string} title
* @property {string} [icon] - name of the boxicon to be used (e.g. "time" for "bx-time" icon)
* @property {function} action - callback handling the click on the button
@@ -142,9 +144,17 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
/**
* @deprecated this API has no effect anymore. Use bookmarks or launchpad shortcuts instead.
* Adds a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
*
* @deprecated you can now create/modify launchers in the
* @param {CreateOrUpdateLauncherOptions} opts
*/
this.addButtonToToolbar = () => console.warn("api.addButtonToToolbar() calls are deprecated and have no effect");
this.addButtonToToolbar = async opts => {
const {action, ...reqBody} = opts;
reqBody.action = action.toString();
await server.put('special-notes/api-script-launcher', reqBody);
};
function prepareParams(params) {
if (!params) {