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
fix(calendar): does not respect protected note of parent
Elian Doranb06cdd442d36
diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.tsindex 00ae717d21..c4441e8692 100644--- a/apps/client/src/services/note_create.ts+++ b/apps/client/src/services/note_create.ts@@ -1,15 +1,17 @@+import type { CKTextEditor } from "@triliumnext/ckeditor5";+import { AttributeRow } from "@triliumnext/commons";+import appContext from "../components/app_context.js";+import type FBranch from "../entities/fbranch.js";+import type FNote from "../entities/fnote.js";+import type { ChooseNoteTypeResponse } from "../widgets/dialogs/note_type_chooser.js";+import froca from "./froca.js";+import { t } from "./i18n.js";import protectedSessionHolder from "./protected_session_holder.js";import server from "./server.js";-import ws from "./ws.js";-import froca from "./froca.js";-import treeService from "./tree.js";import toastService from "./toast.js";-import { t } from "./i18n.js";-import type FNote from "../entities/fnote.js";-import type FBranch from "../entities/fbranch.js";-import type { ChooseNoteTypeResponse } from "../widgets/dialogs/note_type_chooser.js";-import type { CKTextEditor } from "@triliumnext/ckeditor5";+import treeService from "./tree.js";+import ws from "./ws.js";export interface CreateNoteOpts {isProtected?: boolean;@@ -24,6 +26,8 @@ export interface CreateNoteOpts {target?: string;targetBranchId?: string;textEditor?: CKTextEditor;+ /** Attributes to be set on the note. These are set atomically on note creation, so entity changes are not sent for attributes defined here. */+ attributes?: Omit<AttributeRow, "noteId" | "attributeId">[];}interface Response {@@ -37,7 +41,7 @@ interface DuplicateResponse {note: FNote;}-async function createNote(parentNotePath: string | undefined, options: CreateNoteOpts = {}) {+async function createNote(parentNotePath: string | undefined, options: CreateNoteOpts = {}, componentId?: string) {options = Object.assign({activate: true,@@ -77,8 +81,9 @@ async function createNote(parentNotePath: string | undefined, options: CreateNotisProtected: options.isProtected,type: options.type,mime: options.mime,- templateNoteId: options.templateNoteId- });+ templateNoteId: options.templateNoteId,+ attributes: options.attributes+ }, componentId);if (options.saveSelection) {// we remove the selection only after it was saved to server to make sure we don't lose anything@@ -140,9 +145,8 @@ function parseSelectedHtml(selectedHtml: string) {const content = selectedHtml.replace(dom[0].outerHTML, "");return [title, content];- } else {- return [null, selectedHtml];}+ return [null, selectedHtml];}async function duplicateSubtree(noteId: string, parentNotePath: string) {diff --git a/apps/client/src/widgets/collections/calendar/api.ts b/apps/client/src/widgets/collections/calendar/api.tsindex 79df65e4c1..b74f5047b6 100644--- a/apps/client/src/widgets/collections/calendar/api.ts+++ b/apps/client/src/widgets/collections/calendar/api.ts@@ -1,8 +1,8 @@-import { AttributeRow, CreateChildrenResponse } from "@triliumnext/commons";+import { AttributeRow } from "@triliumnext/commons";import FNote from "../../../entities/fnote";import { setAttribute, setLabel } from "../../../services/attributes";-import server from "../../../services/server";+import note_create from "../../../services/note_create";interface NewEventOpts {title: string;@@ -51,11 +51,13 @@ export async function newEvent(parentNote: FNote, { title, startDate, endDate, s}// Create the note.- await server.post<CreateChildrenResponse>(`notes/${parentNote.noteId}/children?target=into`, {+ await note_create.createNote(parentNote.noteId, {title,+ isProtected: parentNote.isProtected,content: "",type: "text",- attributes+ attributes,+ activate: false}, componentId);}