From 3e40a35c1948649125c2e85a37138ada229fa12e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 17 Jun 2025 17:13:11 +0300 Subject: [PATCH] feat(text-snippets): reload when a new template is added --- .../src/widgets/type_widgets/ckeditor/snippets.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/ckeditor/snippets.ts b/apps/client/src/widgets/type_widgets/ckeditor/snippets.ts index f2f747004..2aac02c75 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; }