Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(text-snippets): reload when a new template is added
Elian Doran3e40a35c1948
diff --git a/apps/client/src/widgets/type_widgets/ckeditor/snippets.ts b/apps/client/src/widgets/type_widgets/ckeditor/snippets.tsindex f2f747004f..2aac02c750 100644--- a/apps/client/src/widgets/type_widgets/ckeditor/snippets.ts+++ b/apps/client/src/widgets/type_widgets/ckeditor/snippets.ts@@ -36,6 +36,11 @@ export default async function getTemplates() {return definitions;}+function handleFullReload() {+ console.warn("Full text editor reload needed");+ appContext.triggerCommand("reloadTextEditor");+}+async function handleContentUpdate(affectedNoteIds: string[]) {const updatedNoteIds = new Set(affectedNoteIds);const templateNoteIds = new Set(templateCache.keys());@@ -66,8 +71,7 @@ async function handleContentUpdate(affectedNoteIds: string[]) {}if (fullReloadNeeded) {- console.warn("Full text editor reload needed");- appContext.triggerCommand("reloadTextEditor");+ handleFullReload();}}@@ -77,6 +81,11 @@ export function updateTemplateCache(loadResults: LoadResults): boolean {debouncedHandleContentUpdate(affectedNoteIds);}+ if (loadResults.getAttributeRows().find((attr) =>+ attr.type === "label" &&+ attr.name === "textSnippet")) {+ handleFullReload();+ }return false;}