mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
api method to detect navigation away from current page
This commit is contained in:
parent
f6db9a50ab
commit
89299f865c
@ -203,6 +203,19 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
|
||||
*/
|
||||
this.getCurrentNoteContent = noteDetailService.getCurrentNoteContent;
|
||||
|
||||
/**
|
||||
* This method checks whether user navigated away from the note from which the scripts has been started.
|
||||
* This is necessary because script execution is async and by the time it is finished, the user might have
|
||||
* already navigated away from this page - the end result would be that script might return data for the wrong
|
||||
* note.
|
||||
*
|
||||
* @method
|
||||
* @return {boolean} returns true if the original note is still loaded, false if user switched to another
|
||||
*/
|
||||
this.isNoteStillLoaded = () => {
|
||||
return this.originEntity.noteId === noteDetailService.getCurrentNoteId();
|
||||
};
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {function} func - callback called on note change as user is typing (not necessarily tied to save event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user