Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(templates): rename the instance-gathering relation
Elian Doran0ecd3203e5a0
diff --git a/apps/client/src/services/note_create.spec.ts b/apps/client/src/services/note_create.spec.tsindex 40c3291820..96475d12d7 100644--- a/apps/client/src/services/note_create.spec.ts+++ b/apps/client/src/services/note_create.spec.ts@@ -322,14 +322,15 @@ describe("chooseNoteType", () => {await expect(noteCreateService.chooseNoteType()).resolves.toEqual(payload);});- describe("template inbox", () => {- // A template whose ~inbox points at a note reachable from root, so that it has a note path.+ describe("template default parent", () => {+ // A template whose ~template:newNoteDefaultParent points at a note reachable from root, so+ // that it has a note path.const root = buildNote({id: "root",title: "root",children: [{ id: "people", title: "People" },- { id: "person-tpl", title: "Person", "#template": "", "~inbox": "people" },+ { id: "person-tpl", title: "Person", "#template": "", "~template:newNoteDefaultParent": "people" },{ id: "plain-tpl", title: "Plain", "#template": "" }]});@@ -340,27 +341,27 @@ describe("chooseNoteType", () => {return noteCreateService.chooseNoteType();}- it("routes a template without an explicit parent into the template's inbox", async () => {+ it("routes a template without an explicit parent into the template's default parent", async () => {await expect(choose({ success: true, noteType: "text", templateNoteId: "person-tpl" })).resolves.toEqual({success: true, noteType: "text", templateNoteId: "person-tpl", notePath: "root/people"});});- it("keeps a parent the user picked over the template's inbox", async () => {+ it("keeps a parent the user picked over the template's default parent", async () => {await expect(choose({success: true, noteType: "text", templateNoteId: "person-tpl", notePath: "root/elsewhere"})).resolves.toMatchObject({ notePath: "root/elsewhere" });});- it("leaves the path unset without a template or without an inbox on it", async () => {+ it("leaves the path unset without a template or without a default parent on it", async () => {await expect(choose({ success: true, noteType: "text" })).resolves.toEqual({ success: true, noteType: "text" });await expect(choose({ success: true, noteType: "text", templateNoteId: "plain-tpl" })).resolves.not.toHaveProperty("notePath", expect.any(String));});- it("creates the note in the inbox when the chooser is used through createNoteWithTypePrompt", async () => {+ it("creates the note in the default parent when the chooser is used through createNoteWithTypePrompt", async () => {setActiveContext(true);triggerCommand.mockImplementation((_name: string, data: any) => {data.callback({ success: true, noteType: "text", templateNoteId: "person-tpl" });diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.tsindex 57ea4f4f22..cf959c0fdf 100644--- a/apps/client/src/services/note_create.ts+++ b/apps/client/src/services/note_create.ts@@ -119,8 +119,8 @@ async function createNote(parentNotePath: string | undefined, options: CreateNot/*** Prompts for the type / template of a new note and, optionally, a parent. When the user picks a- * template without picking a parent, the template's own `~inbox` (if any) is returned as the- * `notePath` instead, so a template gathers the notes created from it in one place.+ * template without picking a parent, the template's own `~template:newNoteDefaultParent` (if any)+ * is returned as the `notePath` instead, so a template gathers the notes created from it in one place.*/async function chooseNoteType() {const response = await new Promise<ChooseNoteTypeResponse>((res) => {@@ -128,7 +128,7 @@ async function chooseNoteType() {});if (response.success && !response.notePath && response.templateNoteId) {- response.notePath = await getTemplateInboxNotePath(response.templateNoteId);+ response.notePath = await getTemplateDefaultParentNotePath(response.templateNoteId);}return response;@@ -148,15 +148,16 @@ async function createNoteWithTypePrompt(parentNotePath: string, options: CreateN}/**- * Resolves the path of the note the template's `~inbox` relation points at, relative to the current- * hoisting. Undefined when the template has no inbox, or the inbox has no visible path.+ * Resolves the path of the note the template's `~template:newNoteDefaultParent` relation points at,+ * relative to the current hoisting. Undefined when the template has no such relation, or its target+ * has no visible path.*/-async function getTemplateInboxNotePath(templateNoteId: string) {+async function getTemplateDefaultParentNotePath(templateNoteId: string) {const templateNote = await froca.getNote(templateNoteId);- const inboxNote = await templateNote?.getRelationTarget("inbox");+ const defaultParentNote = await templateNote?.getRelationTarget("template:newNoteDefaultParent");const hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId;- return inboxNote?.getBestNotePathString(hoistedNoteId);+ return defaultParentNote?.getBestNotePathString(hoistedNoteId);}/* If the first element is heading, parse it out and use it as a new heading. */diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex bcdd641d19..e4361d3029 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -633,7 +633,7 @@"run_on_attribute_creation": "Executes when new attribute is created for the note which defines this relation.","run_on_attribute_change": "Executes when the attribute is changed of a note which defines this relation. This is triggered also when the attribute is deleted.","relation_template": "Note's attributes will be inherited even without a parent-child relationship, note's content and subtree will be added to instance notes if empty. See documentation for details.",- "relation_inbox": "Set on a template note: notes created from the template (e.g. via @-completion) are created under the target note, unless another location is picked explicitly.",+ "template_new_note_default_parent": "Set on a template note: notes created from the template (e.g. via @-completion) are placed under the target note, unless another location is picked explicitly.","inherit": "Note's attributes will be inherited even without a parent-child relationship. See template relation for a similar concept. See attribute inheritance in the documentation.","render_note": "Notes of type \"render HTML note\" will be rendered using a code note (HTML or script) and it is necessary to point using this relation to which note should be rendered.","widget_relation": "Target of this relation will be executed and rendered as a widget in the sidebar.",diff --git a/apps/client/src/widgets/attribute_widgets/attr_help.ts b/apps/client/src/widgets/attribute_widgets/attr_help.tsindex 7da869bbd7..759cc8c682 100644--- a/apps/client/src/widgets/attribute_widgets/attr_help.ts+++ b/apps/client/src/widgets/attribute_widgets/attr_help.ts@@ -200,7 +200,7 @@ export const ATTR_HELP: AttrHelpMap = {runOnAttributeCreation: t("attribute_detail.run_on_attribute_creation"),runOnAttributeChange: t("attribute_detail.run_on_attribute_change"),template: t("attribute_detail.relation_template"),- inbox: t("attribute_detail.relation_inbox"),+ "template:newNoteDefaultParent": t("attribute_detail.template_new_note_default_parent"),inherit: t("attribute_detail.inherit"),renderNote: t("attribute_detail.render_note"),widget: t("attribute_detail.widget_relation"),diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes/Relations.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes/Relations.htmlindex d3b5b64d96..cb5ea367fd 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes/Relations.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes/Relations.html@@ -82,10 +82,10 @@ class="table">documentation for details.</td></tr><tr>- <td><code spellcheck="false">inbox</code>+ <td><code spellcheck="false">template:newNoteDefaultParent</code></td><td>set on a template note, points to the note under which notes created- from the template are gathered when no other location is picked. See + from the template are placed when no other location is picked. See <aclass="reference-link" href="#root/_help_KC1HB96bqqHX">Templates</a>.</td></tr>diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Templates.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Templates.htmlindex 4af7223fe0..e68b38a129 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Templates.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Templates.html@@ -57,23 +57,24 @@will not automatically apply the new template to the grandchild notes.Only the structure present at the time of note creation is considered.</p></aside>-<h2>Template inbox</h2>+<h2>Default parent for new notes</h2><p>A template can gather the notes created from it in one place, instead- of having them land wherever they happen to be created. To do so, add an+ of having them land wherever they happen to be created. To do so, add a<code- spellcheck="false">~inbox</code>relation to the template note, pointing at the note that should- hold the instances — for example a <em>Person</em> template with <code spellcheck="false">~inbox</code> pointing- to a <em>People</em> note.</p>-<p>The inbox is used whenever a note is created from the template through- the <em>Choose note type</em> dialog — for example via <code spellcheck="false">@</code>-completion+ spellcheck="false">~template:newNoteDefaultParent</code>relation to the template note, pointing+ at the note that should hold the instances — for example a <em>Person</em> template+ pointing to a <em>People</em> note.</p>+<p>The default parent is used whenever a note is created from the template+ through the <em>Choose note type</em> dialog — for example via <code spellcheck="false">@</code>-completionin a <a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a> note,or the <em>Create and link child note</em> option of the note search — andno other location is picked in that dialog. Creating an instance note fromthe <a class="reference-link" href="#root/_help_oPVyFC7WL2Lp">Note Tree</a> contextmenu (<em>Insert child note</em>, <em>Insert note after</em>) still createsit at the chosen place.</p>-<p>See <a class="reference-link" href="#root/_help_S0Fos78ZfcY7">Note Inbox</a> for- the inbox used by notes created without a template.</p>+<p>Unlike the <a class="reference-link" href="#root/_help_S0Fos78ZfcY7">Note Inbox</a>,+ which holds quickly captured notes until they are sorted, the default parent+ is meant as the instances' permanent location.</p><h2>Regarding note types</h2><p>By default, newly created notes are <a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a> notes.If a parent note defines a <code spellcheck="false">child:template</code> pointingdiff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.htmlindex 1786f90c60..68de24d038 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.html@@ -27,12 +27,4 @@in that workspace.</li><li>A note carrying the <code spellcheck="false">#inbox</code> within that workspace.</li><li>The workspace root note itself.</li>-</ul>-<h2>Template inboxes</h2>-<p>A <a href="#root/_help_KC1HB96bqqHX">template</a> can have an inbox of its- own, set via an <code spellcheck="false">~inbox</code> relation on the template- note pointing at the destination. Notes created from that template through- the <em>Choose note type</em> dialog (e.g. <code spellcheck="false">@</code>-completion- in a text note) land there instead of under the current note, unless another- location is picked in the dialog. See <a class="reference-link" href="#root/_help_KC1HB96bqqHX">Templates</a> for- details.</p>\ No newline at end of file+</ul>\ No newline at end of filediff --git a/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md b/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.mdindex 13d60901ac..1652982ae4 100644--- a/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md+++ b/docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md@@ -42,7 +42,7 @@ These relations are supported and used internally by Trilium.| --- | --- || `runOn*` | See <a class="reference-link" href="../../Scripting/Backend%20scripts/Backend%20Events.md">Events</a> || `template` | note's attributes will be inherited even without a parent-child relationship, note's content and subtree will be added to instance notes if empty. See documentation for details. |-| `inbox` | set on a template note, points to the note under which notes created from the template are gathered when no other location is picked. See <a class="reference-link" href="../Templates.md">Templates</a>. |+| `template:newNoteDefaultParent` | set on a template note, points to the note under which notes created from the template are placed when no other location is picked. See <a class="reference-link" href="../Templates.md">Templates</a>. || `inherit` | note's attributes will be inherited even without a parent-child relationship. See <a class="reference-link" href="../Templates.md">Templates</a> for a similar concept. See <a class="reference-link" href="Attribute%20Inheritance.md">Attribute Inheritance</a> in the documentation. || `renderNote` | notes of type <a class="reference-link" href="../../Note%20Types/Render%20Note.md">Render Note</a> will be rendered using a code note (HTML or script) and it is necessary to point using this relation to which note should be rendered || `widget` | Used in the context of custom <a class="reference-link" href="../../Scripting/Frontend%20Basics/Launch%20Bar%20Widgets.md">Launch Bar Widgets</a>, to refer to the widget that will be rendered. |diff --git a/docs/User Guide/User Guide/Advanced Usage/Templates.md b/docs/User Guide/User Guide/Advanced Usage/Templates.mdindex 338a0f0dd4..971c279ea5 100644--- a/docs/User Guide/User Guide/Advanced Usage/Templates.md+++ b/docs/User Guide/User Guide/Advanced Usage/Templates.md@@ -33,13 +33,13 @@ To specify a template for child notes, you can use a `~child:template` relation> Changing the template hierarchy after the parent note is created will not retroactively apply to newly created child notes.> For example, if you initially use `~child:template` and later switch to `~child:child:template`, it will not automatically apply the new template to the grandchild notes. Only the structure present at the time of note creation is considered.-## Template inbox+## Default parent for new notes-A template can gather the notes created from it in one place, instead of having them land wherever they happen to be created. To do so, add an `~inbox` relation to the template note, pointing at the note that should hold the instances — for example a _Person_ template with `~inbox` pointing to a _People_ note.+A template can gather the notes created from it in one place, instead of having them land wherever they happen to be created. To do so, add a `~template:newNoteDefaultParent` relation to the template note, pointing at the note that should hold the instances — for example a _Person_ template pointing to a _People_ note.-The inbox is used whenever a note is created from the template through the _Choose note type_ dialog — for example via `@`-completion in a <a class="reference-link" href="../Note%20Types/Text.md">Text</a> note, or the _Create and link child note_ option of the note search — and no other location is picked in that dialog. Creating an instance note from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a> context menu (_Insert child note_, _Insert note after_) still creates it at the chosen place.+The default parent is used whenever a note is created from the template through the _Choose note type_ dialog — for example via `@`-completion in a <a class="reference-link" href="../Note%20Types/Text.md">Text</a> note, or the _Create and link child note_ option of the note search — and no other location is picked in that dialog. Creating an instance note from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a> context menu (_Insert child note_, _Insert note after_) still creates it at the chosen place.-See <a class="reference-link" href="../Basic%20Concepts%20and%20Features/Notes/Note%20Inbox.md">Note Inbox</a> for the inbox used by notes created without a template.+Unlike the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/Notes/Note%20Inbox.md">Note Inbox</a>, which holds quickly captured notes until they are sorted, the default parent is meant as the instances' permanent location.## Regarding note typesdiff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.md b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.mdindex 03e21d8940..ebf7f88e16 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Note Inbox.md@@ -25,8 +25,4 @@ When a new note is created while hoisted in a workspace, the location is determi* A note carrying the `#workspaceInbox` label in that workspace.* A note carrying the `#inbox` within that workspace.-* The workspace root note itself.--## Template inboxes--A [template](../../Advanced%20Usage/Templates.md) can have an inbox of its own, set via an `~inbox` relation on the template note pointing at the destination. Notes created from that template through the _Choose note type_ dialog (e.g. `@`-completion in a text note) land there instead of under the current note, unless another location is picked in the dialog. See <a class="reference-link" href="../../Advanced%20Usage/Templates.md">Templates</a> for details.\ No newline at end of file+* The workspace root note itself.\ No newline at end of filediff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.tsindex 536f58ffc4..875903a2f3 100644--- a/packages/commons/src/lib/builtin_attributes.ts+++ b/packages/commons/src/lib/builtin_attributes.ts@@ -339,7 +339,7 @@ const BUILTIN_ATTRIBUTES = [{ type: "relation", name: "runOnAttributeChange", isDangerous: true },{ type: "relation", name: "template" },// Set on a template: where a note created from it goes when no parent is picked explicitly.- { type: "relation", name: "inbox" },+ { type: "relation", name: "template:newNoteDefaultParent" },{ type: "relation", name: "inherit" },// Set on a journal root, to be applied as `~template` on each note the period generates.{ type: "relation", name: "dateTemplate" },