Skip to content

Build your personal knowledge base with Trilium Notes

feat(collection/presentation): add default content to the two slides

Elian Dorand801d8a05324
diff --git a/apps/server/src/services/hidden_subtree.ts b/apps/server/src/services/hidden_subtree.ts
index 5d8854aaa5..5472518182 100644
--- a/apps/server/src/services/hidden_subtree.ts
+++ b/apps/server/src/services/hidden_subtree.ts
@@ -345,17 +345,24 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
let branch;
if (!note) {
+ // Missing item, add it.
({ note, branch } = noteService.createNewNote({
noteId: item.id,
title: item.title,
type: item.type,
parentNoteId: parentNoteId,
- content: "",
+ content: item.content ?? "",
ignoreForbiddenParents: true
}));
} else {
+ // Existing item, check if it's in the right state.
branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId);
+ if (item.content && note.getContent() !== item.content) {
+ console.log(`Updating content of ${item.id}.`);
+ note.setContent(item.content);
+ }
+
// Clean up any branches that shouldn't exist according to the meta definition
// For hidden subtree notes, we want to ensure they only exist in their designated locations
if (item.enforceBranches || item.id.startsWith("_help")) {
diff --git a/apps/server/src/services/hidden_subtree_templates.ts b/apps/server/src/services/hidden_subtree_templates.ts
index 5b887978c8..d85fb5546d 100644
--- a/apps/server/src/services/hidden_subtree_templates.ts
+++ b/apps/server/src/services/hidden_subtree_templates.ts
@@ -264,6 +264,7 @@ export default function buildHiddenSubtreeTemplates() {
id: "_template_presentation_first",
type: "text",
title: t("hidden_subtree_templates.presentation_slide_first"),
+ content: t("hidden_subtree_templates.presentation_slide_first"),
attributes: [
{
name: "template",
@@ -276,6 +277,7 @@ export default function buildHiddenSubtreeTemplates() {
id: "_template_presentation_second",
type: "text",
title: t("hidden_subtree_templates.presentation_slide_second"),
+ content: t("hidden_subtree_templates.presentation_slide_second"),
attributes: [
{
name: "template",
diff --git a/packages/commons/src/lib/hidden_subtree.ts b/packages/commons/src/lib/hidden_subtree.ts
index c86dd6b899..0d23f0805c 100644
--- a/packages/commons/src/lib/hidden_subtree.ts
+++ b/packages/commons/src/lib/hidden_subtree.ts
@@ -54,4 +54,10 @@ export interface HiddenSubtreeItem {
* definitions will be removed.
*/
enforceAttributes?: boolean;
+ /**
+ * Optionally, a content to be set in the hidden note. If undefined, an empty string will be set instead.
+ *
+ * The value is also checked at every startup to ensure that it's kept up to date according to the definition.
+ */
+ content?: string;
}