mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 23:35:50 +01:00
create new runOnNoteContentChange event, #3436
This commit is contained in:
@@ -245,7 +245,8 @@ const ATTR_HELP = {
|
||||
"runOnNoteCreation": "executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.",
|
||||
"runOnChildNoteCreation": "executes when new note is created under the note where this relation is defined",
|
||||
"runOnNoteTitleChange": "executes when note title is changed (includes note creation as well)",
|
||||
"runOnNoteChange": "executes when note is changed (includes note creation as well)",
|
||||
"runOnNoteContentChange": "executes when note content is changed (includes note creation as well).",
|
||||
"runOnNoteChange": "executes when note is changed (includes note creation as well). Does not include content changes",
|
||||
"runOnNoteDeletion": "executes when note is being deleted",
|
||||
"runOnBranchCreation": "executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.",
|
||||
"runOnBranchDeletion": "executes when a branch is deleted. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).",
|
||||
|
||||
@@ -19,6 +19,7 @@ export default class ClosePaneButton extends OnClickButtonWidget {
|
||||
e.stopPropagation();
|
||||
|
||||
widget.triggerCommand("closeThisNoteSplit", { ntxId: widget.getClosestNtxId() });
|
||||
});
|
||||
})
|
||||
.class("icon-action");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,12 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
|
||||
}
|
||||
});
|
||||
|
||||
eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
|
||||
if (entityName === 'note_contents') {
|
||||
runAttachedRelations(entity, 'runOnNoteContentChange', entity);
|
||||
}
|
||||
});
|
||||
|
||||
eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) => {
|
||||
if (entityName === 'attributes') {
|
||||
runAttachedRelations(entity.getNote(), 'runOnAttributeCreation', entity);
|
||||
|
||||
@@ -204,6 +204,11 @@ function createNewNote(params) {
|
||||
entity: note
|
||||
});
|
||||
|
||||
eventService.emit(eventService.ENTITY_CREATED, {
|
||||
entityName: 'note_contents',
|
||||
entity: note
|
||||
});
|
||||
|
||||
eventService.emit(eventService.ENTITY_CREATED, {
|
||||
entityName: 'branches',
|
||||
entity: branch
|
||||
@@ -444,7 +449,7 @@ function downloadImages(noteId, content) {
|
||||
// which will get asynchronously downloaded, during that time they keep editing the note
|
||||
// once the download is finished, the image note representing downloaded image will be used
|
||||
// to replace the IMG link.
|
||||
// However there's another flow where user pastes the image and leaves the note before the images
|
||||
// However, there's another flow where user pastes the image and leaves the note before the images
|
||||
// are downloaded and the IMG references are not updated. For this occassion we have this code
|
||||
// which upon the download of all the images will update the note if the links have not been fixed before
|
||||
|
||||
@@ -475,6 +480,11 @@ function downloadImages(noteId, content) {
|
||||
|
||||
scanForLinks(origNote);
|
||||
|
||||
eventService.emit(eventService.ENTITY_CHANGED, {
|
||||
entityName: 'note_contents',
|
||||
entity: origNote
|
||||
});
|
||||
|
||||
console.log(`Fixed the image links for note '${noteId}' to the offline saved.`);
|
||||
}
|
||||
});
|
||||
@@ -580,6 +590,11 @@ function updateNoteContent(noteId, content) {
|
||||
content = saveLinks(note, content);
|
||||
|
||||
note.setContent(content);
|
||||
|
||||
eventService.emit(eventService.ENTITY_CHANGED, {
|
||||
entityName: 'note_contents',
|
||||
entity: note
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user