mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 08:46:43 +01:00
reimplementation of frontend's api.addButtonToToolbar() to smoothen the upgrade
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user