mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat(text-snippets): reload when a new template is added
This commit is contained in:
parent
97799bfacc
commit
3e40a35c19
@ -36,6 +36,11 @@ export default async function getTemplates() {
|
|||||||
return definitions;
|
return definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFullReload() {
|
||||||
|
console.warn("Full text editor reload needed");
|
||||||
|
appContext.triggerCommand("reloadTextEditor");
|
||||||
|
}
|
||||||
|
|
||||||
async function handleContentUpdate(affectedNoteIds: string[]) {
|
async function handleContentUpdate(affectedNoteIds: string[]) {
|
||||||
const updatedNoteIds = new Set(affectedNoteIds);
|
const updatedNoteIds = new Set(affectedNoteIds);
|
||||||
const templateNoteIds = new Set(templateCache.keys());
|
const templateNoteIds = new Set(templateCache.keys());
|
||||||
@ -66,8 +71,7 @@ async function handleContentUpdate(affectedNoteIds: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fullReloadNeeded) {
|
if (fullReloadNeeded) {
|
||||||
console.warn("Full text editor reload needed");
|
handleFullReload();
|
||||||
appContext.triggerCommand("reloadTextEditor");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +81,11 @@ export function updateTemplateCache(loadResults: LoadResults): boolean {
|
|||||||
debouncedHandleContentUpdate(affectedNoteIds);
|
debouncedHandleContentUpdate(affectedNoteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadResults.getAttributeRows().find((attr) =>
|
||||||
|
attr.type === "label" &&
|
||||||
|
attr.name === "textSnippet")) {
|
||||||
|
handleFullReload();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user