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
client/text editor/canvas: rename the attachment
Adorian Doran73c0e40e7a64
diff --git a/apps/client/src/widgets/type_widgets/text/attachment_saves.spec.ts b/apps/client/src/widgets/type_widgets/text/attachment_saves.spec.tsindex 633104d44f..5abba4dad0 100644--- a/apps/client/src/widgets/type_widgets/text/attachment_saves.spec.ts+++ b/apps/client/src/widgets/type_widgets/text/attachment_saves.spec.ts@@ -8,7 +8,7 @@ const drawing = {ownerId: "note1",role: "file",mime: "application/vnd.excalidraw+json",- title: "canvas.json"+ title: "Canvas.excalidraw"} as FAttachment;function setUp() {@@ -42,7 +42,7 @@ describe("AttachmentSaves", () => {attachmentId: "drawing1",role: "file",mime: "application/vnd.excalidraw+json",- title: "canvas.json",+ title: "Canvas.excalidraw",content: "second"} ]);});diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.htmlindex 0ff3ffc5cf..df9585d507 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.html@@ -76,8 +76,8 @@in a text note being edited and select <em>Convert link to an embed</em>,at the end of the menu.</li><li>A drawing canvas, inserted with the <span class="tn-icon bx bx-pen"></span> <em>Insert drawing canvas</em> button,- is an embed of a <code>canvas.json</code> attachment that can be drawn on- in place (see <em>Drawing canvases</em> in <a class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a>).</li>+ is an embed of a <code>Canvas.excalidraw</code> attachment that can be drawn+ on in place (see <em>Drawing canvases</em> in <a class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a>).</li><li>An embed gets the box size that suits the attachment, as a new includednote does (see <em>Box sizes</em> there). To change its size, select theembed and use the box size menu in its toolbar, or the <em>Size</em> submenudiff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Include Note.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Include Note.htmlindex cb24b95740..61339864c9 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Include Note.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Include Note.html@@ -136,7 +136,7 @@<h2>Drawing canvases</h2><p>A drawing canvas is an Excalidraw canvas, like the one of a <a class="reference-link"href="#root/_help_grjYqerjn243">Canvas</a> note, drawn directly in the text- note. It is not a note of its own: the drawing is kept in a <code>canvas.json</code> <a+ note. It is not a note of its own: the drawing is kept in a <code>Canvas.excalidraw</code> <ahref="#root/_help_0vhv7lsOLy82">attachment</a> of the text note and is savedtogether with the text.</p><ul>@@ -165,7 +165,7 @@<li>The Excalidraw shape library is not saved for a drawing canvas.</li><li>Outside the editor, for example in a tooltip, when printing or in thelist of attachments, the drawing is shown as a picture. On a <a href="#root/_help_R9pX4DGra2Vt">shared page</a>,- it appears as a link to download <code>canvas.json</code>.</li>+ it appears as a link to download <code>Canvas.excalidraw</code>.</li><li>A copy of a drawing canvas pasted in the same note shares the drawingwith the original, so a change to one shows in the other only after thenote is opened again. A copy pasted in another note gets a drawing of itsdiff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.mdindex a49f3f87e4..bd944d558a 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md@@ -41,7 +41,7 @@ An attachment can be shown in the text instead of linked, the way <a class="ref* To attach files and embed them straight away, select _Attach and embed file_ from the arrow beside the <span class="tn-icon cke cke-paper-clip"></span> _Attach file_ button. Each file gets an embed of its own, which shows the file name while the file uploads.* To embed an attachment that is already linked, right-click a link to it in a text note being edited and select _Convert link to an embed_, at the end of the menu.-* A drawing canvas, inserted with the <span class="tn-icon bx bx-pen"></span> _Insert drawing canvas_ button, is an embed of a `canvas.json` attachment that can be drawn on in place (see _Drawing canvases_ in <a class="reference-link" href="../../Note%20Types/Text/Include%20Note.md">Include Note</a>).+* A drawing canvas, inserted with the <span class="tn-icon bx bx-pen"></span> _Insert drawing canvas_ button, is an embed of a `Canvas.excalidraw` attachment that can be drawn on in place (see _Drawing canvases_ in <a class="reference-link" href="../../Note%20Types/Text/Include%20Note.md">Include Note</a>).* An embed gets the box size that suits the attachment, as a new included note does (see _Box sizes_ there). To change its size, select the embed and use the box size menu in its toolbar, or the _Size_ submenu of its <span class="tn-icon bx bx-dots-vertical-rounded"></span> _More actions_ menu.* An embed can have a caption, as an included note can (see _Caption_ there).* To show only the attachment, select the embed and press the <span class="tn-icon bx bx-window-alt"></span> _Show title_ button in its toolbar, as for an included note (see _Title_ there).diff --git a/docs/User Guide/User Guide/Note Types/Text/Include Note.md b/docs/User Guide/User Guide/Note Types/Text/Include Note.mdindex e3c27c1721..b7cebb442f 100644--- a/docs/User Guide/User Guide/Note Types/Text/Include Note.md+++ b/docs/User Guide/User Guide/Note Types/Text/Include Note.md@@ -91,7 +91,7 @@ In a _Small_ or _Medium_ box, the image is scaled down to fit the height of the## Drawing canvases-A drawing canvas is an Excalidraw canvas, like the one of a <a class="reference-link" href="../Canvas.md">Canvas</a> note, drawn directly in the text note. It is not a note of its own: the drawing is kept in a `canvas.json` [attachment](../../Basic%20Concepts%20and%20Features/Notes/Attachments.md) of the text note and is saved together with the text.+A drawing canvas is an Excalidraw canvas, like the one of a <a class="reference-link" href="../Canvas.md">Canvas</a> note, drawn directly in the text note. It is not a note of its own: the drawing is kept in a `Canvas.excalidraw` [attachment](../../Basic%20Concepts%20and%20Features/Notes/Attachments.md) of the text note and is saved together with the text.* To insert a drawing canvas, press the <span class="tn-icon bx bx-pen"></span> _Insert drawing canvas_ button in the <a class="reference-link" href="Formatting%20toolbar.md">Formatting toolbar</a>, next to the <span class="tn-icon cke cke-paper-clip"></span> _Attach file_ button. The canvas is added empty, in a _Medium_ box with its title hidden, and takes the focus, ready for drawing.* To draw on a canvas that does not have the focus, click it first. Until then, the mouse wheel and touch gestures scroll the note. The canvas then has the tools, menus and keyboard shortcuts of a Canvas note. The toolbars, the menus and the properties of the selected shapes show only while the canvas has the focus, so elsewhere the drawing reads like a picture in the text.@@ -103,5 +103,5 @@ A drawing canvas is an Excalidraw canvas, like the one of a <a class="reference-### Limitations* The Excalidraw shape library is not saved for a drawing canvas.-* Outside the editor, for example in a tooltip, when printing or in the list of attachments, the drawing is shown as a picture. On a [shared page](../../Advanced%20Usage/Sharing.md), it appears as a link to download `canvas.json`.+* Outside the editor, for example in a tooltip, when printing or in the list of attachments, the drawing is shown as a picture. On a [shared page](../../Advanced%20Usage/Sharing.md), it appears as a link to download `Canvas.excalidraw`.* A copy of a drawing canvas pasted in the same note shares the drawing with the original, so a change to one shows in the other only after the note is opened again. A copy pasted in another note gets a drawing of its own.\ No newline at end of filediff --git a/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.ts b/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.tsindex 1d4f71b55c..a979697981 100644--- a/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.ts+++ b/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.ts@@ -170,7 +170,7 @@ describe("FileUploadUI", () => {});const [ file ] = (execute.mock.calls[0][1] as { file: File[] }).file;expect([ file.name, file.type ])- .toEqual([ "canvas.json", "application/vnd.excalidraw+json" ]);+ .toEqual([ "Canvas.excalidraw", "application/vnd.excalidraw+json" ]);expect(JSON.parse(await file.text())).toEqual({type: "excalidraw", version: 2, elements: [], files: {}, appState: {}});diff --git a/packages/ckeditor5/src/plugins/file_upload/fileuploadcommand.spec.ts b/packages/ckeditor5/src/plugins/file_upload/fileuploadcommand.spec.tsindex 4bb83d6af8..7f686c053e 100644--- a/packages/ckeditor5/src/plugins/file_upload/fileuploadcommand.spec.ts+++ b/packages/ckeditor5/src/plugins/file_upload/fileuploadcommand.spec.ts@@ -190,14 +190,17 @@ describe("FileUploadCommand", () => {setModelData(editor.model, "<paragraph>[]</paragraph>");editor.execute("fileUpload", {- file: [ new File(["{}"], "canvas.json", { type: "application/vnd.excalidraw+json" }) ],+ file: [+ new File(["{}"], "Canvas.excalidraw", { type: "application/vnd.excalidraw+json" })+ ],asEmbed: true,boxSize: "medium",hideTitle: true});expect(getModelData(editor.model)).toMatch(new RegExp(- "^<contentEmbed boxSize=\"medium\" hideTitle=\"true\" uploadFileName=\"canvas.json\""+ "^<contentEmbed boxSize=\"medium\" hideTitle=\"true\" " ++ "uploadFileName=\"Canvas.excalidraw\""));expect(getEmbedBoxSize).not.toHaveBeenCalled();});diff --git a/packages/ckeditor5/src/plugins/file_upload/fileuploadediting.spec.ts b/packages/ckeditor5/src/plugins/file_upload/fileuploadediting.spec.tsindex 1a23dc872c..ea0d89ce70 100644--- a/packages/ckeditor5/src/plugins/file_upload/fileuploadediting.spec.ts+++ b/packages/ckeditor5/src/plugins/file_upload/fileuploadediting.spec.ts@@ -266,7 +266,8 @@ describe("FileUploadEditing", () => {editor.plugins.get(FileUploadEditing).on<FileUploadEvent>("upload", announced);setModelData(editor.model, "<paragraph>[]</paragraph>");- editor.execute("fileUpload", { file: [ new File(["{}"], "canvas.json") ], quiet: true });+ const file = new File(["{}"], "Canvas.excalidraw");+ editor.execute("fileUpload", { file: [ file ], quiet: true });await waitFor(() => controls.uploadCalled());expect(announced).not.toHaveBeenCalled();@@ -648,7 +649,7 @@ describe("FileUploadEditing with embeds", () => {const controls = installUploadAdapter(editor);setModelData(editor.model, "<paragraph>[]</paragraph>");- const file = new File(["{}"], "canvas.json");+ const file = new File(["{}"], "Canvas.excalidraw");editor.execute("fileUpload", { file: [ file ], asEmbed: true, focusEmbed: true });await waitFor(() => controls.uploadCalled());controls.resolveUpload({ default: "#root/owner?viewMode=attachments&attachmentId=att1" });diff --git a/packages/commons/src/lib/notes.ts b/packages/commons/src/lib/notes.tsindex 135dcc9d55..2259cd2cd4 100644--- a/packages/commons/src/lib/notes.ts+++ b/packages/commons/src/lib/notes.ts@@ -59,7 +59,7 @@ export function getImageAttachmentTitle(type: NoteType | null | undefined): striexport const CANVAS_ATTACHMENT_MIME = "application/vnd.excalidraw+json";/** The title of the attachment a new canvas drawing is saved in. */-export const CANVAS_ATTACHMENT_TITLE = "canvas.json";+export const CANVAS_ATTACHMENT_TITLE = "Canvas.excalidraw";/** The content of a new, empty canvas drawing. */export const EMPTY_CANVAS_CONTENT = JSON.stringify({