Skip to content

Build your personal knowledge base with Trilium Notes

refactor(server): use different mechanism for detecting if note is templateable

Elian Doran8576eebff0d3
diff --git a/apps/server/src/services/handlers.ts b/apps/server/src/services/handlers.ts
index 64e143bd9f..04135ba6a0 100644
--- a/apps/server/src/services/handlers.ts
+++ b/apps/server/src/services/handlers.ts
@@ -105,7 +105,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
const content = note.getContent();
if (
- ["text", "code", "mermaid", "canvas", "relationMap", "mindMap", "webView", "spreadsheet"].includes(note.type) &&
+ note.hasStringContent() &&
typeof content === "string" &&
// if the note has already content we're not going to overwrite it with template's one
(!content || content.trim().length === 0) &&
diff --git a/apps/server/src/services/utils.ts b/apps/server/src/services/utils.ts
index 59771a1d37..aeb89ffa6e 100644
--- a/apps/server/src/services/utils.ts
+++ b/apps/server/src/services/utils.ts
@@ -177,7 +177,7 @@ export function getContentDisposition(filename: string) {
}
// render and book are string note in the sense that they are expected to contain empty string
-const STRING_NOTE_TYPES = new Set(["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas", "webView"]);
+const STRING_NOTE_TYPES = new Set(["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas", "webView", "spreadsheet"]);
const STRING_MIME_TYPES = new Set(["application/javascript", "application/x-javascript", "application/json", "application/x-sql", "image/svg+xml"]);
export function isStringNote(type: string | undefined, mime: string) {