mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 11:56:01 +01:00 
			
		
		
		
	api method to detect navigation away from current page
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user