mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
API docs
This commit is contained in:
@@ -53,9 +53,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
/** @property {jQuery} container of all the rendered script content */
|
||||
this.$container = $container;
|
||||
|
||||
/** @property {object} note where script started executing */
|
||||
/** @property {object} note where the script started executing */
|
||||
this.startNote = startNote;
|
||||
/** @property {object} note where script is currently executing */
|
||||
/** @property {object} note where the script is currently executing */
|
||||
this.currentNote = currentNote;
|
||||
/** @property {object|null} entity whose event triggered this execution */
|
||||
this.originEntity = originEntity;
|
||||
@@ -192,7 +192,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
params: prepareParams(params),
|
||||
startNoteId: startNote.noteId,
|
||||
currentNoteId: currentNote.noteId,
|
||||
originEntityName: "notes", // currently there's no other entity on frontend which can trigger event
|
||||
originEntityName: "notes", // currently there's no other entity on the frontend which can trigger event
|
||||
originEntityId: originEntity ? originEntity.noteId : null
|
||||
}, "script");
|
||||
|
||||
@@ -233,7 +233,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns note by given noteId. If note is missing from cache, it's loaded.
|
||||
* Returns note by given noteId. If note is missing from the cache, it's loaded.
|
||||
**
|
||||
* @method
|
||||
* @param {string} noteId
|
||||
@@ -242,10 +242,10 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.getNote = async noteId => await froca.getNote(noteId);
|
||||
|
||||
/**
|
||||
* Returns list of notes. If note is missing from cache, it's loaded.
|
||||
* Returns list of notes. If note is missing from the cache, it's loaded.
|
||||
*
|
||||
* This is often used to bulk-fill the cache with notes which would have to be picked one by one
|
||||
* otherwise (by e.g. createNoteLink())
|
||||
* otherwise (by e.g. createLink())
|
||||
*
|
||||
* @method
|
||||
* @param {string[]} noteIds
|
||||
@@ -286,7 +286,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.parseDate = utils.parseDate;
|
||||
|
||||
/**
|
||||
* Show info message to the user.
|
||||
* Show an info message to the user.
|
||||
*
|
||||
* @method
|
||||
* @param {string} message
|
||||
@@ -294,7 +294,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.showMessage = toastService.showMessage;
|
||||
|
||||
/**
|
||||
* Show error message to the user.
|
||||
* Show an error message to the user.
|
||||
*
|
||||
* @method
|
||||
* @param {string} message
|
||||
@@ -302,7 +302,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.showError = toastService.showError;
|
||||
|
||||
/**
|
||||
* Trigger command.
|
||||
* Trigger command. This is a very low-level API which should be avoided if possible.
|
||||
*
|
||||
* @method
|
||||
* @param {string} name
|
||||
@@ -311,7 +311,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.triggerCommand = (name, data) => appContext.triggerCommand(name, data);
|
||||
|
||||
/**
|
||||
* Trigger event.
|
||||
* Trigger event. This is a very low-level API which should be avoided if possible.
|
||||
*
|
||||
* @method
|
||||
* @param {string} name
|
||||
@@ -320,7 +320,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.triggerEvent = (name, data) => appContext.triggerEvent(name, data);
|
||||
|
||||
/**
|
||||
* Create note link (jQuery object) for given note.
|
||||
* Create a note link (jQuery object) for given note.
|
||||
*
|
||||
* @method
|
||||
* @param {string} notePath (or noteId)
|
||||
@@ -330,7 +330,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
* @param {boolean} [params.showNoteIcon=false] - show also note icon before the title
|
||||
* @param {string} [params.title=] - custom link tile with note's title as default
|
||||
*/
|
||||
this.createNoteLink = linkService.createNoteLink;
|
||||
this.createLink = linkService.createLink;
|
||||
|
||||
/**
|
||||
* Adds given text to the editor cursor
|
||||
@@ -347,10 +347,10 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.getActiveContextNote = () => appContext.tabManager.getActiveContextNote();
|
||||
|
||||
/**
|
||||
* See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance.
|
||||
* See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for documentation on the returned instance.
|
||||
*
|
||||
* @method
|
||||
* @returns {Promise<CKEditor>} instance of CKEditor
|
||||
* @returns {Promise<BalloonEditor>} instance of CKEditor
|
||||
*/
|
||||
this.getActiveContextTextEditor = () => appContext.tabManager.getActiveContext()?.getTextEditor();
|
||||
|
||||
@@ -373,12 +373,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @returns {Promise<string|null>} returns note path of active note or null if there isn't active note
|
||||
* @returns {Promise<string|null>} returns a note path of active note or null if there isn't active note
|
||||
*/
|
||||
this.getActiveContextNotePath = () => appContext.tabManager.getActiveContextNotePath();
|
||||
|
||||
/**
|
||||
* Returns component which owns given DOM element (the nearest parent component in DOM tree)
|
||||
* Returns component which owns the given DOM element (the nearest parent component in DOM tree)
|
||||
*
|
||||
* @method
|
||||
* @param {Element} el - DOM element
|
||||
@@ -483,11 +483,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
this.bindGlobalShortcut = shortcutService.bindGlobalShortcut;
|
||||
|
||||
/**
|
||||
* Trilium runs in backend and frontend process, when something is changed on the backend from script,
|
||||
* Trilium runs in a backend and frontend process, when something is changed on the backend from a script,
|
||||
* frontend will get asynchronously synchronized.
|
||||
*
|
||||
* This method returns a promise which resolves once all the backend -> frontend synchronization is finished.
|
||||
* Typical use case is when new note has been created, we should wait until it is synced into frontend and only then activate it.
|
||||
* Typical use case is when a new note has been created, we should wait until it is synced into frontend and only then activate it.
|
||||
*
|
||||
* @method
|
||||
* @returns {Promise<void>}
|
||||
@@ -506,11 +506,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
||||
* Return randomly generated string of given length. This random string generation is NOT cryptographically secure.
|
||||
*
|
||||
* @method
|
||||
* @param {number} length of the string
|
||||
* @param {integer} length of the string
|
||||
* @returns {string} random string
|
||||
*/
|
||||
this.randomString = utils.randomString;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {int} size in bytes
|
||||
* @return {string} formatted string
|
||||
*/
|
||||
this.formatNoteSize = utils.formatNoteSize;
|
||||
|
||||
this.logMessages = {};
|
||||
this.logSpacedUpdates = {};
|
||||
|
||||
@@ -551,7 +558,7 @@ export default FrontendScriptApi;
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FNoteComplement.html">FNoteComplement</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
Reference in New Issue
Block a user