add frontend API method openTabWithNote, #1645

This commit is contained in:
zadam
2021-02-17 23:55:51 +01:00
parent 600a312b2a
commit 8e730c6ecf
24 changed files with 855 additions and 387 deletions

View File

@@ -71,6 +71,23 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
appContext.triggerEvent('focusAndSelectTitle');
};
/**
* Open a note in a new tab.
*
* @param {string} notePath (or noteId)
* @param {boolean} activate - set to true to activate the new tab, false to stay on the current tab
* @return {Promise<void>}
*/
this.openTabWithNote = async (notePath, activate) => {
await ws.waitForMaxKnownEntityChangeId();
await appContext.tabManager.openTabWithNote(notePath, activate);
if (activate) {
appContext.triggerEvent('focusAndSelectTitle');
}
};
/**
* @typedef {Object} ToolbarButtonOptions
* @property {string} title