From 3d1c93e58c19089466a5c2d820dbcadc70ef0168 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 7 Jan 2026 12:07:49 +0200 Subject: [PATCH] fix(client/lightweight): note content not rendering --- .../src/widgets/type_widgets/text/config.ts | 11 +++---- .../src/widgets/type_widgets/text/snippets.ts | 30 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts index 445705927..2e61c3952 100644 --- a/apps/client/src/widgets/type_widgets/text/config.ts +++ b/apps/client/src/widgets/type_widgets/text/config.ts @@ -134,11 +134,12 @@ export async function buildConfig(opts: BuildEditorOptions): Promise { await ensureMimeTypesForHighlighting(); diff --git a/apps/client/src/widgets/type_widgets/text/snippets.ts b/apps/client/src/widgets/type_widgets/text/snippets.ts index 4a1479c3d..a791dd75b 100644 --- a/apps/client/src/widgets/type_widgets/text/snippets.ts +++ b/apps/client/src/widgets/type_widgets/text/snippets.ts @@ -3,7 +3,6 @@ import froca from "../../../services/froca.js"; import type LoadResults from "../../../services/load_results.js"; import search from "../../../services/search.js"; import type { TemplateDefinition } from "@triliumnext/ckeditor5"; -import appContext from "../../../components/app_context.js"; import type FNote from "../../../entities/fnote.js"; interface TemplateData { @@ -21,20 +20,25 @@ const debouncedHandleContentUpdate = debounce(handleContentUpdate, 1000); * @returns the list of templates. */ export default async function getTemplates() { - // Build the definitions and populate the cache. - const snippets = await search.searchForNotes("#textSnippet"); - const definitions: TemplateDefinition[] = []; - for (const snippet of snippets) { - const { description } = await invalidateCacheFor(snippet); + try { + // Build the definitions and populate the cache. + const snippets = await search.searchForNotes("#textSnippet"); + const definitions: TemplateDefinition[] = []; + for (const snippet of snippets) { + const { description } = await invalidateCacheFor(snippet); - definitions.push({ - title: snippet.title, - data: () => templateCache.get(snippet.noteId)?.content ?? "", - icon: buildIcon(snippet), - description - }); + definitions.push({ + title: snippet.title, + data: () => templateCache.get(snippet.noteId)?.content ?? "", + icon: buildIcon(snippet), + description + }); + } + return definitions; + } catch (e) { + logError("Error while building text snippet templates: ", e); + return []; } - return definitions; } async function invalidateCacheFor(snippet: FNote) {