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
feat(calendar): pick the template a new event is made from
Elian Doran69e23aaf4f4b
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5afe5ffffe..0029ec2fd6 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3691,7 +3691,9 @@"properties": "Calendar properties","event_templates": "Event templates","event_templates_hint": "Choose what note types and note templates you would like to use when creating new calendar events.",- "new_template_name": "New event template"+ "new_template_name": "New event template",+ "event_template": "Select an event template",+ "more_templates": "More templates…"},"ocr": {"extracted_text": "Extracted Text (OCR)",diff --git a/apps/client/src/widgets/collections/calendar/GhostPopover.css b/apps/client/src/widgets/collections/calendar/GhostPopover.cssindex 68616209b1..9d288ec698 100644--- a/apps/client/src/widgets/collections/calendar/GhostPopover.css+++ b/apps/client/src/widgets/collections/calendar/GhostPopover.css@@ -20,7 +20,13 @@.calendar-ghost-actions {display: flex;- justify-content: flex-end;+ justify-content: space-between;+ align-items: center;+ gap: 8px;+ }++ .calendar-ghost-actions .template-pill {+ min-width: 0;}}diff --git a/apps/client/src/widgets/collections/calendar/GhostPopover.spec.tsx b/apps/client/src/widgets/collections/calendar/GhostPopover.spec.tsxindex c7294c3249..30d6fd9572 100644--- a/apps/client/src/widgets/collections/calendar/GhostPopover.spec.tsx+++ b/apps/client/src/widgets/collections/calendar/GhostPopover.spec.tsx@@ -2,6 +2,8 @@ import { render } from "preact";import { act } from "preact/test-utils";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { type NoteTypeOption } from "../../../services/note_types";+import { type TemplateChoice } from "../../react/TemplatePill";import GhostPopover from "./GhostPopover";import { EventDraft } from "./selection";@@ -26,13 +28,21 @@ describe("GhostPopover", () => {});const draft: EventDraft = { startDate: "2026-06-05" };-- function mount(onCommit: (title: string) => Promise<void> | void) {+ const TEXT: NoteTypeOption = {+ id: "type:text:text/html", title: "Text", icon: "bx bx-note", group: "type",+ options: { type: "text", mime: "text/html" }+ };++ function mount(+ onCommit: (title: string) => Promise<void> | void,+ templates: TemplateChoice = { offered: [ TEXT ], current: TEXT, onSelect() {}, onMore() {} }+ ) {act(() => render(<GhostPopoverdraft={draft}anchor={{ x: 10, y: 10 }}container={container}+ templates={templates}onCommit={onCommit}onCancel={() => {}}onDismiss={() => {}}@@ -40,8 +50,8 @@ describe("GhostPopover", () => {container));}- /** The form's only button, which is the one that asks for the note. */- const createButton = () => document.querySelector<HTMLButtonElement>(".calendar-ghost-actions button");+ /** The button that asks for the note, beside the template pill. */+ const createButton = () => document.querySelector<HTMLButtonElement>(".calendar-ghost-actions .btn-primary");const titleInput = () => document.querySelector<HTMLInputElement>(".calendar-ghost-body input");const timeInputs = () => [ ...document.querySelectorAll<HTMLInputElement>(".calendar-ghost-body input[type=time]") ];const dateInputs = () => [ ...document.querySelectorAll<HTMLInputElement>(".calendar-ghost-body input[type=date]") ];@@ -85,7 +95,7 @@ describe("GhostPopover", () => {// And a second try really does ask again.await act(async () => { createButton()?.click(); });expect(onCommit).toHaveBeenCalledTimes(2);- expect(onCommit).toHaveBeenLastCalledWith("Fair", draft);+ expect(onCommit).toHaveBeenLastCalledWith("Fair", draft, TEXT);});it("focuses the title field once the popover is shown", async () => {@@ -113,7 +123,27 @@ describe("GhostPopover", () => {await act(async () => { createButton()?.click(); });// Committing blank is meaningful: the note is then named by the calendar's #titleTemplate.- expect(onCommit).toHaveBeenCalledWith("", draft);+ expect(onCommit).toHaveBeenCalledWith("", draft, TEXT);+ });++ it("names the template the event is made from, and makes it from the one shown at the commit", async () => {+ const canvas: NoteTypeOption = {+ ...TEXT, id: "type:canvas:application/json", title: "Canvas",+ options: { type: "canvas", mime: "application/json" }+ };+ const onCommit = vi.fn().mockResolvedValue(undefined);+ const choice = { offered: [ TEXT, canvas ], onSelect() {}, onMore() {} };+ const pillName = () => document.querySelector(".calendar-ghost-actions .template-pill-name");++ mount(onCommit, { ...choice, current: TEXT });+ expect(pillName()?.textContent).toBe("Text");++ // A pick is stored by the calendar, which hands the ghost the new choice.+ mount(onCommit, { ...choice, current: canvas });+ expect(pillName()?.textContent).toBe("Canvas");++ await act(async () => { createButton()?.click(); });+ expect(onCommit).toHaveBeenCalledWith("", draft, canvas);});it("lets a whole-day draft be given hours before it is created", async () => {@@ -144,7 +174,7 @@ describe("GhostPopover", () => {expect(onCommit).toHaveBeenCalledWith("", {startDate: "2026-06-05", startTime: "14:00", endTime: "15:30"- });+ }, TEXT);});it("lets the days of a draft be changed before it is created", async () => {@@ -155,7 +185,8 @@ describe("GhostPopover", () => {commitValue(dateInputs()[1], "2026-06-10");await act(async () => { createButton()?.click(); });- expect(onCommit).toHaveBeenCalledWith("", { startDate: "2026-06-08", endDate: "2026-06-10" });+ expect(onCommit).toHaveBeenCalledWith(+ "", { startDate: "2026-06-08", endDate: "2026-06-10" }, TEXT);});it("leaves the end date empty for a slot within a single day", () => {@@ -165,6 +196,7 @@ describe("GhostPopover", () => {draft={{ startDate: "2026-06-05", endDate: "2026-06-05", startTime: "09:00", endTime: "09:30" }}anchor={null}container={container}+ templates={{ offered: [ TEXT ], current: TEXT, onSelect() {}, onMore() {} }}onCommit={vi.fn()}onCancel={() => {}}onDismiss={() => {}}@@ -184,6 +216,7 @@ describe("GhostPopover", () => {expect(timeInputs()).toHaveLength(0);expect(document.activeElement).toBe(document.querySelector(".calendar-event-add-time"));await act(async () => { createButton()?.click(); });- expect(onCommit).toHaveBeenCalledWith("", { startDate: "2026-06-05", startTime: null, endTime: null });+ expect(onCommit).toHaveBeenCalledWith(+ "", { startDate: "2026-06-05", startTime: null, endTime: null }, TEXT);});});diff --git a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx b/apps/client/src/widgets/collections/calendar/GhostPopover.tsxindex 5861e3386d..0faa7d53c6 100644--- a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx+++ b/apps/client/src/widgets/collections/calendar/GhostPopover.tsx@@ -3,12 +3,14 @@ import "./GhostPopover.css";import { useCallback, useEffect, useRef, useState } from "preact/hooks";import { t } from "../../../services/i18n";+import { type NoteTypeOption } from "../../../services/note_types";import { isMobile } from "../../../services/utils";import ActionButton from "../../react/ActionButton";import Button from "../../react/Button";import FormTextBox from "../../react/FormTextBox";import Modal from "../../react/Modal";import Popover from "../../react/Popover";+import TemplatePill, { type TemplateChoice } from "../../react/TemplatePill";import { EventDatesFields } from "./EventDatesEditor";import { AnchorPoint, EventDraft, narrowAnchorRect, normalizeEventDates } from "./selection";@@ -26,16 +28,20 @@ import { AnchorPoint, EventDraft, narrowAnchorRect, normalizeEventDates } from "* calendar's own `#titleTemplate` where one is set (see getNewNoteTitle in trilium-core), which* the old title prompt used to override with whatever stood in its box.*/-export default function GhostPopover({ draft: initialDraft, anchor, container, onCommit, onCancel, onDismiss }: {+export default function GhostPopover({+ draft: initialDraft, anchor, container, templates, onCommit, onCancel, onDismiss+}: {draft: EventDraft;/** Where the drag ended, in viewport coordinates — which of the shading's pieces to stand by,* and the anchor of last resort when the shading cannot be found at all. */anchor: AnchorPoint | null;/** The calendar the range's shading is read out of (see {@link ghostAnchorRect}). */container: HTMLElement | null;+ /** What the event is made from, picked with the pill beside the create button. */+ templates: TemplateChoice;/** Answers when the note has been made, or rejects having failed to make one — the ghost stays* up for a second try either way it is told (see {@link commit}). */- onCommit(title: string, draft: EventDraft): Promise<void> | void;+ onCommit(title: string, draft: EventDraft, template: NoteTypeOption | undefined): Promise<void> | void;/** The draft given up on: Escape, or the close button. */onCancel(): void;/**@@ -77,7 +83,7 @@ export default function GhostPopover({ draft: initialDraft, anchor, container, oif (committing) return;setCommitting(true);try {- await onCommit(title, draft);+ await onCommit(title, draft, templates.current);} catch {setCommitting(false);}@@ -111,6 +117,11 @@ export default function GhostPopover({ draft: initialDraft, anchor, container, o</div><div className="calendar-ghost-actions">+ <TemplatePill+ {...templates}+ title={t("calendar_view.event_template")}+ moreText={t("calendar_view.more_templates")}+ /><Buttonkind="primary"text={t("calendar_view.create_event")}diff --git a/apps/client/src/widgets/collections/calendar/api.spec.ts b/apps/client/src/widgets/collections/calendar/api.spec.tsindex 91d3453f09..554693ab7c 100644--- a/apps/client/src/widgets/collections/calendar/api.spec.ts+++ b/apps/client/src/widgets/collections/calendar/api.spec.ts@@ -141,6 +141,26 @@ describe("newEvent", () => {// The note is not switched to: the pane opens on it where the calendar stands.expect(opts.activate).toBe(false);});++ it("makes the note from the template it is given, and a text note without one", async () => {+ const calendar = buildNote({ title: "Calendar" });++ await newEvent(calendar, {+ startDate: "2026-06-05",+ template: {+ id: "template:meeting", title: "Meeting", icon: "bx bx-group", group: "user",+ options: { type: "canvas", mime: "application/json", templateNoteId: "meeting" }+ }+ });+ expect(creationRequest().opts).toMatchObject({+ type: "canvas", mime: "application/json", templateNoteId: "meeting"+ });++ vi.mocked(note_create.createNote).mockClear();+ await newEvent(calendar, { startDate: "2026-06-05" });+ expect(creationRequest().opts.type).toBe("text");+ expect(creationRequest().opts.templateNoteId).toBeUndefined();+ });});describe("removeFromCalendar", () => {diff --git a/apps/client/src/widgets/collections/calendar/api.ts b/apps/client/src/widgets/collections/calendar/api.tsindex 37d87c07ad..58ef58d149 100644--- a/apps/client/src/widgets/collections/calendar/api.ts+++ b/apps/client/src/widgets/collections/calendar/api.ts@@ -6,6 +6,7 @@ import dialog from "../../../services/dialog";import { t } from "../../../services/i18n";import note_create from "../../../services/note_create";import { deleteNoteOrBranch } from "../../../services/note_deletion";+import { type NoteTypeOption } from "../../../services/note_types";import { type TemplateChoiceConfig } from "../../react/TemplatePill";import { EventLabelName } from "./utils";@@ -24,6 +25,8 @@ interface NewEventOpts {startTime?: string | null;endTime?: string | null;componentId?: string;+ /** What the note is made from, a text note where absent. */+ template?: NoteTypeOption;}interface ChangeEventOpts {@@ -34,7 +37,9 @@ interface ChangeEventOpts {componentId?: string;}-export async function newEvent(parentNote: FNote, { title, startDate, endDate, startTime, endTime, componentId }: NewEventOpts) {+export async function newEvent(parentNote: FNote, {+ title, startDate, endDate, startTime, endTime, componentId, template+}: NewEventOpts) {const attributes: Omit<AttributeRow, "noteId" | "attributeId">[] = [];attributes.push({type: "label",@@ -69,6 +74,7 @@ export async function newEvent(parentNote: FNote, { title, startDate, endDate, sisProtected: parentNote.isProtected,content: "",type: "text",+ ...(template?.options ?? {}),attributes,activate: false}, componentId);diff --git a/apps/client/src/widgets/collections/calendar/event_builder.spec.ts b/apps/client/src/widgets/collections/calendar/event_builder.spec.tsindex 18ead04688..40b161a7ef 100644--- a/apps/client/src/widgets/collections/calendar/event_builder.spec.ts+++ b/apps/client/src/widgets/collections/calendar/event_builder.spec.ts@@ -34,6 +34,16 @@ describe("Building events", () => {expect(events).toHaveLength(0);});+ it("leaves out template notes, but not the events made from them", async () => {+ const noteIds = buildNotes([+ { id: "meeting", title: "Meeting", "#template": "", "#startDate": "2025-05-05" },+ { title: "Standup", "~template": "meeting", "#startDate": "2025-05-07" }+ ]);+ const events = await buildEvents(noteIds);++ expect(events.map((event) => event.title)).toEqual([ "Standup" ]);+ });+it("supports both start date and end date", async () => {const noteIds = buildNotes([{ title: "Note 1", "#startDate": "2025-05-05", "#endDate": "2025-05-05" },diff --git a/apps/client/src/widgets/collections/calendar/event_builder.ts b/apps/client/src/widgets/collections/calendar/event_builder.tsindex 36daf032e9..3a6c8d898d 100644--- a/apps/client/src/widgets/collections/calendar/event_builder.ts+++ b/apps/client/src/widgets/collections/calendar/event_builder.ts@@ -24,6 +24,11 @@ export async function buildEvents(noteIds: string[]) {const events: EventSourceInput = [];for (const note of notes) {+ // An event template created from `CalendarProperties` is a child of the calendar, not an event.+ if (note.hasLabel("template")) {+ continue;+ }+const startDate = getCustomisableLabel(note, "startDate", "calendar:startDate");if (!startDate) {diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsxindex f514c30888..4f087b5439 100644--- a/apps/client/src/widgets/collections/calendar/index.tsx+++ b/apps/client/src/widgets/collections/calendar/index.tsx@@ -20,6 +20,7 @@ import contextMenu from "../../../menus/context_menu";import date_notes from "../../../services/date_notes";import froca from "../../../services/froca";import { t } from "../../../services/i18n";+import { type NoteTypeOption } from "../../../services/note_types";import note_tooltip from "../../../services/note_tooltip";import { isMobile } from "../../../services/utils";import CollectionProperties from "../../note_bars/CollectionProperties";@@ -28,10 +29,11 @@ import Button, { ButtonGroup } from "../../react/Button";import CollapseOnOverflow from "../../react/CollapseOnOverflow";import Dropdown from "../../react/Dropdown";import { FormListItem } from "../../react/FormList";-import { useEffectiveReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useSpacedUpdate, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks";+import { useEffectiveReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteTypeOptions, useSpacedUpdate, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks";import { ParentComponent } from "../../react/react_utils";+import { offeredTemplateIds, useTemplateChoice } from "../../react/TemplatePill";import { ViewModeProps } from "../interface";-import { type CalendarViewData, changeEvent, newEvent } from "./api";+import { type CalendarViewData, changeEvent, DEFAULT_EVENT_TEMPLATES, newEvent } from "./api";import Calendar from "./calendar";import { openCalendarContextMenu } from "./context_menu";import { CalendarSelection, EventDraft } from "./selection";@@ -179,12 +181,15 @@ export default function CalendarView({* could be dragged out beside it. Whatever else the note may hold is a click on its chip away* — which is where such a surface would have opened anyway.*/- const commitDraft = useCallback(async (title: string, draft: EventDraft) => {+ const commitDraft = useCallback(async (+ title: string, draft: EventDraft, template: NoteTypeOption | undefined+ ) => {if (!selection || !("draft" in selection)) return;await newEvent(note, {title: title.trim() || undefined,...draft,+ template,componentId: parentComponent?.componentId});@@ -204,6 +209,25 @@ export default function CalendarView({setSelection(null);}, []);+ const availableTemplates = useNoteTypeOptions(isEditable);+ const selectEventTemplate = useCallback((template: NoteTypeOption) => {+ if (template.id !== viewConfig?.template) {+ saveConfig({ ...viewConfig, template: template.id });+ }+ }, [ viewConfig, saveConfig ]);+ // The draft is let go first: on a phone it is a dialog itself, and Bootstrap does not stack two.+ const editEventTemplates = useCallback(() => {+ cancelDraft();+ setIsEditingProperties(true);+ }, [ cancelDraft ]);+ const eventTemplates = useTemplateChoice({+ ids: offeredTemplateIds(viewConfig, DEFAULT_EVENT_TEMPLATES),+ lastUsedId: viewConfig?.template,+ available: availableTemplates,+ onSelect: selectEventTemplate,+ onMore: editEventTemplates+ });+/*** The ghost pressed away from, which is a different thing: the press itself settles what* becomes of the shading, and saying anything here would be saying it too early. A press on the@@ -407,6 +431,7 @@ export default function CalendarView({draft={selection.draft}anchor={selection.anchor}container={containerRef.current}+ templates={eventTemplates}/* Handed over whole rather than fired and forgotten: a creation that fails hasto reach the ghost, which is what opens its form again for another try. */onCommit={commitDraft}diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.htmlindex 5949ca944a..ed067bd6d0 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.html@@ -153,6 +153,9 @@<li><span class="tn-icon bx bx-cog"></span><em>Board properties</em> appearson a <a class="reference-link" href="#root/_help_CtBQqbwXDx1w">Kanban Board</a>,and configures its columns, card attributes and card templates.</li>+ <li><span class="tn-icon bx bx-cog"></span><em>Calendar properties</em> appears+ on a <a class="reference-link" href="#root/_help_xWbu3jpNWapp">Calendar</a> that+ creates events, and configures its event templates.</li></ul><h2>Advanced</h2><p>The <span class="tn-icon bx bx-wrench"></span><em>Advanced</em> submenudiff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.htmlindex 3959380658..dcc69f8986 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Calendar.html@@ -38,6 +38,11 @@clicks. Add a title optionally and press the <em>Create</em> button. If notitle is provided, the event will follow the <a class="reference-link"href="#root/_help_47ZrP6FNuoG8">Default Note Title</a> rules.</p>+<p>The template the event's note is made from is shown at the bottom of the+ popup, next to the <em>Create</em> button. To make the event from another+ note type or template, press it and select one from the list; the calendar+ remembers the choice for the next event. Select <em>More templates…</em> to+ change which templates are listed (see <a href="#event-templates">Event templates</a>).</p><p>To give the event a time before creating it (for example, after clickinga day in the month view), press <em>Add time</em> and set the start and endtime; the duration is shown to the right of them. To make the event all-day@@ -148,6 +153,32 @@<li>Set the slot label interval (how often time labels appear on the axisin day/week view).</li></ul>+<h3>Event templates</h3>+<p>By default, a new event is a <a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a> note.+ To make events from other note types, or from <a class="reference-link"+ href="#root/_help_KC1HB96bqqHX">Templates</a> with predefined content and+ attributes (such as a color), open the <span class="tn-icon bx bx-cog"></span> <em>Calendar properties</em> dialog+ from the <a class="reference-link" href="#root/_help_8YBEPzcpUgxw">Note menu</a> or+ from the settings menu of the <a class="reference-link" href="#root/_help_CssoWBu8I7jF">Collection Properties</a>,+ and find <em>Event templates</em>. Here you can:</p>+<ul>+ <li>Include a note type or note template already created in your knowledge+ base by pressing the <span class="tn-icon bx bx-list-plus"></span> <em>Add existing template</em> button+ and then selecting the desired note type or template.</li>+ <li>Create a new template by pressing the <span class="tn-icon bx bx-plus"></span> <em>Create a new template</em> button.+ The template is created as a child of the calendar, and is not shown as+ an event.</li>+ <li>Press the <span class="tn-icon bx bx-x"></span> button to remove a template+ from the list. The template is removed only from the list, not deleted.</li>+ <li>Press the <span class="tn-icon bx bx-dots-vertical-rounded"></span> button+ of a custom template to edit, open in a new window, duplicate, or delete+ it.</li>+ <li>Drag a template by its handle to reorder the list shown when creating+ an event.</li>+</ul>+<p>The dialog is not available on a read-only calendar, or on a calendar+ marked with <code>#calendarRoot</code> or <code>#workspaceCalendarRoot</code> (see <a+ href="#using-with-the-journal--calendar">Using with the Journal / calendar</a>).</p><h2>Configuring the calendar using attributes</h2><p>The following attributes can be added to the Collection type:</p><figurediff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.mdindex d9c8bd4300..a0b1fd210b 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md@@ -63,6 +63,7 @@ The following entries only appear on some notes:* <span class="tn-icon bx bx-paperclip"></span>_Convert into attachment_ appears on an image note that has no children and a single parent which is a <a class="reference-link" href="../../Note%20Types/Text.md">Text</a> note. After a confirmation, it turns the image into an attachment of its parent note and opens it there. See <a class="reference-link" href="../Notes/Attachments.md">Attachments</a>.* <span class="tn-icon bx bx-extension"></span>_Re-render note_ appears on a <a class="reference-link" href="../../Note%20Types/Render%20Note.md">Render Note</a>, and runs its script again to refresh the output.* <span class="tn-icon bx bx-cog"></span>_Board properties_ appears on a <a class="reference-link" href="../../Collections/Kanban%20Board.md">Kanban Board</a>, and configures its columns, card attributes and card templates.+* <span class="tn-icon bx bx-cog"></span>_Calendar properties_ appears on a <a class="reference-link" href="../../Collections/Calendar.md">Calendar</a> that creates events, and configures its event templates.## Advanceddiff --git a/docs/User Guide/User Guide/Collections/Calendar.md b/docs/User Guide/User Guide/Collections/Calendar.mdindex 4346575901..4edffb6fa7 100644--- a/docs/User Guide/User Guide/Collections/Calendar.md+++ b/docs/User Guide/User Guide/Collections/Calendar.md@@ -28,6 +28,8 @@ In either cases, a small popup will show with a prompt for a title and the dateAt this point, the event hasn't been created yet to protect against accidental clicks. Add a title optionally and press the _Create_ button. If no title is provided, the event will follow the <a class="reference-link" href="../Advanced%20Usage/Default%20Note%20Title.md">Default Note Title</a> rules.+The template the event's note is made from is shown at the bottom of the popup, next to the _Create_ button. To make the event from another note type or template, press it and select one from the list; the calendar remembers the choice for the next event. Select _More templates…_ to change which templates are listed (see [Event templates](#event-templates)).+To give the event a time before creating it (for example, after clicking a day in the month view), press _Add time_ and set the start and end time; the duration is shown to the right of them. To make the event all-day again, press the <span class="tn-icon bx bx-x"></span> button at the end of the row. Adding or removing a time keeps the dates, so an event can start at a time on one day and end at a time on another (for example, a night shift). Changing the start date or time moves the end by the same amount, keeping the duration. An empty end date means the event ends on the day it starts; setting the end time before the start time moves the end date to the next day.After creating the event, it will show up on the calendar. To edit the content of the event (including recurrence), click on it to bring it into the popup view.@@ -95,6 +97,18 @@ In the <a class="reference-link" href="Collection%20Properties.md">Collection P* Set the slot duration (the length of each time row in day/week view).* Set the slot label interval (how often time labels appear on the axis in day/week view).+### Event templates++By default, a new event is a <a class="reference-link" href="../Note%20Types/Text.md">Text</a> note. To make events from other note types, or from <a class="reference-link" href="../Advanced%20Usage/Templates.md">Templates</a> with predefined content and attributes (such as a color), open the <span class="tn-icon bx bx-cog"></span> _Calendar properties_ dialog from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> or from the settings menu of the <a class="reference-link" href="Collection%20Properties.md">Collection Properties</a>, and find _Event templates_. Here you can:++* Include a note type or note template already created in your knowledge base by pressing the <span class="tn-icon bx bx-list-plus"></span> _Add existing template_ button and then selecting the desired note type or template.+* Create a new template by pressing the <span class="tn-icon bx bx-plus"></span> _Create a new template_ button. The template is created as a child of the calendar, and is not shown as an event.+* Press the <span class="tn-icon bx bx-x"></span> button to remove a template from the list. The template is removed only from the list, not deleted.+* Press the <span class="tn-icon bx bx-dots-vertical-rounded"></span> button of a custom template to edit, open in a new window, duplicate, or delete it.+* Drag a template by its handle to reorder the list shown when creating an event.++The dialog is not available on a read-only calendar, or on a calendar marked with `#calendarRoot` or `#workspaceCalendarRoot` (see [Using with the Journal / calendar](#using-with-the-journal--calendar)).+## Configuring the calendar using attributesThe following attributes can be added to the Collection type: