Skip to content

Build your personal knowledge base with Trilium Notes

feat(attributes): recognise the journal and calendar attributes as system ones

Elian Doranecad0d02efbc
diff --git a/apps/client/src/services/attributes.spec.ts b/apps/client/src/services/attributes.spec.ts
index 8a2013ab2a..6c09e69dd9 100644
--- a/apps/client/src/services/attributes.spec.ts
+++ b/apps/client/src/services/attributes.spec.ts
@@ -386,6 +386,15 @@ describe("isBuiltinAttribute", () => {
expect(isBuiltinAttribute("relation", "widget")).toBe(true);
});
+ it("recognizes the journal and calendar names, which the list long omitted", () => {
+ expect(isBuiltinAttribute("label", "yearNote")).toBe(true);
+ expect(isBuiltinAttribute("relation", "dateTemplate")).toBe(true);
+ expect(isBuiltinAttribute("label", "calendar:view")).toBe(true);
+ // An event reads its dates from these by default, so the names are Trilium's, not the user's.
+ expect(isBuiltinAttribute("label", "startDate")).toBe(true);
+ expect(isBuiltinAttribute("label", "calendar:startDate")).toBe(true);
+ });
+
it("matches exactly, so prefixed names are not built-ins", () => {
// A definition describes a built-in without being one, and a disabled one is inert.
expect(isBuiltinAttribute("label", "label:archived")).toBe(false);
diff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.ts
index 81427e8e82..3504413f43 100644
--- a/packages/commons/src/lib/builtin_attributes.ts
+++ b/packages/commons/src/lib/builtin_attributes.ts
@@ -82,7 +82,12 @@ const BUILTIN_ATTRIBUTES = [
{ type: "label", name: "quarterPattern", valueType: "string" },
{ type: "label", name: "yearPattern", valueType: "string" },
{ type: "label", name: "enableQuarterNote", valueType: "boolean" },
+ // Stamped onto each generated journal note, holding the period it stands for.
{ type: "label", name: "dateNote", valueType: "string", hasUserValue: true },
+ { type: "label", name: "weekNote", valueType: "string", hasUserValue: true },
+ { type: "label", name: "monthNote", valueType: "string", hasUserValue: true },
+ { type: "label", name: "quarterNote", valueType: "string", hasUserValue: true },
+ { type: "label", name: "yearNote", valueType: "string", hasUserValue: true },
{ type: "label", name: "pageSize", valueType: "number" },
{ type: "label", name: "viewType", valueType: "string" },
{ type: "label", name: "mapRootNoteId", valueType: "string" },
@@ -157,6 +162,19 @@ const BUILTIN_ATTRIBUTES = [
{ type: "label", name: "calendar:weekNumbers", valueType: "boolean", hasUserValue: true },
{ type: "label", name: "calendar:slotDuration", valueType: "string", hasUserValue: true },
{ type: "label", name: "calendar:slotLabelInterval", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:title", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:displayedAttributes", valueType: "string", hasUserValue: true },
+ // Each names the label an event reads a given field from, overriding the default listed after it.
+ { type: "label", name: "calendar:startDate", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:endDate", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:startTime", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:endTime", valueType: "string", hasUserValue: true },
+ { type: "label", name: "calendar:recurrence", valueType: "string", hasUserValue: true },
+ { type: "label", name: "startDate", valueType: "string", hasUserValue: true },
+ { type: "label", name: "endDate", valueType: "string", hasUserValue: true },
+ { type: "label", name: "startTime", valueType: "string", hasUserValue: true },
+ { type: "label", name: "endTime", valueType: "string", hasUserValue: true },
+ { type: "label", name: "recurrence", valueType: "string", hasUserValue: true },
{ type: "label", name: "geolocation", valueType: "string", hasUserValue: true },
{ type: "label", name: "mapType", valueType: "string", hasUserValue: true },
{ type: "label", name: "map:style", valueType: "string", hasUserValue: true },
@@ -194,6 +212,12 @@ const BUILTIN_ATTRIBUTES = [
{ type: "relation", name: "runOnAttributeChange", isDangerous: true },
{ type: "relation", name: "template" },
{ type: "relation", name: "inherit" },
+ // Set on a journal root, to be applied as `~template` on each note the period generates.
+ { type: "relation", name: "dateTemplate" },
+ { type: "relation", name: "weekTemplate" },
+ { type: "relation", name: "monthTemplate" },
+ { type: "relation", name: "quarterTemplate" },
+ { type: "relation", name: "yearTemplate" },
{ type: "relation", name: "widget", isDangerous: true },
{ type: "relation", name: "renderNote", isDangerous: true },
{ type: "relation", name: "searchScript" },