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

This commit is contained in:
Elian Doran 2025-10-16 11:06:47 +03:00
parent f9a24bf601
commit d801d8a053
No known key found for this signature in database
3 changed files with 16 additions and 1 deletions

View File

@ -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")) {

View File

@ -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",

View File

@ -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;
}