mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	add API method to force refresh of included notes, closes #1106
This commit is contained in:
		| @@ -403,6 +403,13 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | ||||
|      * @method | ||||
|      */ | ||||
|     this.waitUntilSynced = ws.waitForMaxKnownSyncId; | ||||
|  | ||||
|     /** | ||||
|      * This will refresh all currently opened notes which have included note specified in the parameter | ||||
|      * | ||||
|      * @param includedNoteId - noteId of the included note | ||||
|      */ | ||||
|     this.refreshIncludedNote = includedNoteId => appContext.triggerEvent('refreshIncludedNote', {noteId: includedNoteId}); | ||||
| } | ||||
|  | ||||
| export default FrontendScriptApi; | ||||
| @@ -62,4 +62,12 @@ export default class AbstractTextTypeWidget extends TypeWidget { | ||||
|  | ||||
|         $el.text(title); | ||||
|     } | ||||
|  | ||||
|     refreshIncludedNote($container, noteId) { | ||||
|         if ($container) { | ||||
|             $container.find(`section[data-note-id="${noteId}"]`).each((_, el) => { | ||||
|                 this.loadIncludedNote(noteId, $(el)); | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -257,4 +257,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { | ||||
|             this.textEditor.model.insertContent(imageElement, this.textEditor.model.document.selection); | ||||
|         } ); | ||||
|     } | ||||
|  | ||||
|     async refreshIncludedNoteEvent({noteId}) { | ||||
|         this.refreshIncludedNote(this.$editor, noteId); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -81,4 +81,8 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { | ||||
|             this.loadIncludedNote(noteId, $(el)); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     async refreshIncludedNoteEvent({noteId}) { | ||||
|         this.refreshIncludedNote(this.$content, noteId); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user