Skip to content

Build your personal knowledge base with Trilium Notes

client/text editor/canvas: relocate the "Insert drawing canvas" button

Adorian Doran5c761de3b451
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 57786d779a..b79e8b44b8 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4417,7 +4417,7 @@
"tiny": "Tiny",
"show-title": "Show title",
"more-actions": "More actions",
- "insert-drawing-canvas": "Insert drawing canvas",
+ "drawing-canvas": "Drawing canvas",
"editable": "Editable"
},
"task-state-dropped-title": "Invalid task states",
diff --git a/apps/client/src/widgets/type_widgets/text/toolbar.spec.ts b/apps/client/src/widgets/type_widgets/text/toolbar.spec.ts
index f40c9d3bae..d169e9c87f 100644
--- a/apps/client/src/widgets/type_widgets/text/toolbar.spec.ts
+++ b/apps/client/src/widgets/type_widgets/text/toolbar.spec.ts
@@ -53,6 +53,23 @@ describe("CKEditor config", () => {
});
});
+describe("the Insert group", () => {
+ it("offers the drawing canvas above the Mermaid diagram, on both toolbars", () => {
+ const toolbars = [
+ buildClassicToolbar(false, true).toolbar.items,
+ buildFloatingToolbar(true).blockToolbar
+ ];
+ for (const items of toolbars) {
+ const group = items.find((item) => typeof item === "object"
+ && "label" in item && item.label === "text-editor.toolbar-groups.insert");
+ const groupItems = (group as { items: string[] } | undefined)?.items ?? [];
+ const index = groupItems.indexOf("drawingCanvas");
+ expect(groupItems.slice(index, index + 2)).toEqual([ "drawingCanvas", "mermaid" ]);
+ expect(items).not.toContain("drawingCanvas");
+ }
+ });
+});
+
describe("buildClassicToolbar", () => {
it("reflects the multiline flag via shouldNotGroupWhenFull", () => {
expect(buildClassicToolbar(false, true).toolbar.shouldNotGroupWhenFull).toBe(false);
diff --git a/apps/client/src/widgets/type_widgets/text/toolbar.ts b/apps/client/src/widgets/type_widgets/text/toolbar.ts
index f4d611037f..9b52b57389 100644
--- a/apps/client/src/widgets/type_widgets/text/toolbar.ts
+++ b/apps/client/src/widgets/type_widgets/text/toolbar.ts
@@ -95,7 +95,6 @@ export function buildClassicToolbar(multilineToolbar: boolean, aiAssistant: bool
...(aiAssistant ? ["aiAssistant"] : []),
"imageUpload",
"fileUpload",
- "drawingCanvas",
"blockQuote",
"admonition",
"insertTable",
@@ -106,7 +105,7 @@ export function buildClassicToolbar(multilineToolbar: boolean, aiAssistant: bool
"footnote",
{
...buildInsertGroup(),
- items: ["link", "linkEmbed", "bookmark", "internallink", "contentEmbed", "|", "collapsible", "math", "mermaid", "horizontalLine", "pageBreak", "|", "dateTime", "specialCharacters", "emoji", "insertIcon"]
+ items: ["link", "linkEmbed", "bookmark", "internallink", "contentEmbed", "|", "collapsible", "math", "drawingCanvas", "mermaid", "horizontalLine", "pageBreak", "|", "dateTime", "specialCharacters", "emoji", "insertIcon"]
},
"|",
buildAlignmentToolbar(),
@@ -170,7 +169,6 @@ export function buildFloatingToolbar(aiAssistant: boolean) {
"|",
"imageUpload",
"fileUpload",
- "drawingCanvas",
"blockQuote",
"admonition",
"codeBlock",
@@ -178,7 +176,7 @@ export function buildFloatingToolbar(aiAssistant: boolean) {
"footnote",
{
...buildInsertGroup(),
- items: ["link", "linkEmbed", "bookmark", "internallink", "contentEmbed", "|", "collapsible", "math", "mermaid", "horizontalLine", "pageBreak", "dateTime"]
+ items: ["link", "linkEmbed", "bookmark", "internallink", "contentEmbed", "|", "collapsible", "math", "drawingCanvas", "mermaid", "horizontalLine", "pageBreak", "dateTime"]
},
"|",
buildAlignmentToolbar(),
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.html
index da8e6ae7f3..320b29ee67 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
@@ -75,9 +75,10 @@
<li>To embed an attachment that is already linked, right-click a link to it
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.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>A drawing canvas, inserted with <span class="tn-icon bx bx-pen"></span> <em>Drawing canvas</em> in
+ the <span class="tn-icon cke cke-plus"></span> <em>Insert</em> menu, 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 included
note does (see <em>Box sizes</em> there). To change its size, select the
embed and use the box size menu in its toolbar, or the <em>Size</em> submenu
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Canvas.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Canvas.html
index e812b866b3..2ec75c6ed1 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Canvas.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Canvas.html
@@ -28,6 +28,6 @@
href="#root/_help_GTwFsgaA0lCt">Collections</a>.</p>
<h2>Drawing in a text note</h2>
<p>To draw inside a <a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a> note
- instead of in a note of its own, insert a drawing canvas with the <span
- class="tn-icon bx bx-pen"></span> <em>Insert drawing canvas</em> button.
- See <em>Drawing canvases</em> in <a class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a>.</p>
\ No newline at end of file
+ instead of in a note of its own, insert a drawing canvas with <span class="tn-icon bx bx-pen"></span> <em>Drawing canvas</em> in
+ the <span class="tn-icon cke cke-plus"></span> <em>Insert</em> menu. See <em>Drawing canvases</em> in <a
+ class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a>.</p>
\ No newline at end of file
diff --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.html
index 1a95844fb3..5d270e08f7 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
@@ -166,9 +166,9 @@
href="#root/_help_0vhv7lsOLy82">attachment</a> of the text note and is saved
together with the text.</p>
<ul>
- <li>To insert a drawing canvas, press the <span class="tn-icon bx bx-pen"></span> <em>Insert drawing canvas</em> button
- in the <a class="reference-link" href="#root/_help_nRhnJkTT8cPs">Formatting toolbar</a>,
- next to the <span class="tn-icon cke cke-paper-clip"></span> <em>Attach file</em> button.
+ <li>To insert a drawing canvas, open the <span class="tn-icon cke cke-plus"></span> <em>Insert</em> menu
+ of the <a class="reference-link" href="#root/_help_nRhnJkTT8cPs">Formatting toolbar</a> and
+ choose <span class="tn-icon bx bx-pen"></span> <em>Drawing canvas</em>, above <em>Mermaid diagram</em>.
The canvas is added empty and editable, in a <em>Medium</em> box with its
title hidden, and takes the focus, ready for drawing.</li>
<li>To draw on a canvas that does not have the focus, click it first. Until
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Insert buttons.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Insert buttons.html
index 4ec6ddae29..a776bbff31 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Insert buttons.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Insert buttons.html
@@ -36,6 +36,10 @@ src="1_Insert buttons_plus.png" width="272" height="187">
</ul>
<h2>Math equations</h2>
<p>See the dedicated&nbsp;<a class="reference-link" href="#root/_help_YfYAtQBcfo5V">Math Equations</a>&nbsp;page.</p>
+<h2>Drawing canvas</h2>
+<p>Choose <span class="tn-icon bx bx-pen"></span> <em>Drawing canvas</em> to
+ draw on an Excalidraw canvas inside the text. See <em>Drawing canvases</em> in <a
+ class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a>.</p>
<h2>Mermaid diagram</h2>
<p>Press the&nbsp;<span class="tn-icon cke cke-trilium-mermaid-insert"></span> button
to create an inline Mermaid diagram.</p>
diff --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.md
index e6df92ca43..e1e742e3dd 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.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>).
+* A drawing canvas, inserted with <span class="tn-icon bx bx-pen"></span> _Drawing canvas_ in the <span class="tn-icon cke cke-plus"></span> _Insert_ menu, 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. A _Small_, _Medium_ or _Expandable_ embed can also be resized by dragging its handles (see _Resizing_ there).
* 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/Canvas.md b/docs/User Guide/User Guide/Note Types/Canvas.md
index 279ffa1b5d..984c7c5c1e 100644
--- a/docs/User Guide/User Guide/Note Types/Canvas.md
+++ b/docs/User Guide/User Guide/Note Types/Canvas.md
@@ -22,4 +22,4 @@ Embedding notes in the canvas follows the same rules as <a class="reference-lin
## Drawing in a text note
-To draw inside a <a class="reference-link" href="Text.md">Text</a> note instead of in a note of its own, insert a drawing canvas with the <span class="tn-icon bx bx-pen"></span> _Insert drawing canvas_ button. See _Drawing canvases_ in <a class="reference-link" href="Text/Include%20Note.md">Include Note</a>.
\ No newline at end of file
+To draw inside a <a class="reference-link" href="Text.md">Text</a> note instead of in a note of its own, insert a drawing canvas with <span class="tn-icon bx bx-pen"></span> _Drawing canvas_ in the <span class="tn-icon cke cke-plus"></span> _Insert_ menu. See _Drawing canvases_ in <a class="reference-link" href="Text/Include%20Note.md">Include Note</a>.
\ No newline at end of file
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.md
index d5c1a426b1..913a1b040f 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
@@ -106,7 +106,7 @@ In a _Small_ or _Medium_ box, the image is scaled down to fit the height of the
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 and editable, in a _Medium_ box with its title hidden, and takes the focus, ready for drawing.
+* To insert a drawing canvas, open the <span class="tn-icon cke cke-plus"></span> _Insert_ menu of the <a class="reference-link" href="Formatting%20toolbar.md">Formatting toolbar</a> and choose <span class="tn-icon bx bx-pen"></span> _Drawing canvas_, above _Mermaid diagram_. The canvas is added empty and editable, 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.
* A new drawing has the background color of the note. A background chosen from the Excalidraw menu replaces it.
* To protect a finished drawing from accidental changes, select it and turn off the <span class="tn-icon bx bx-edit-alt"></span> _Editable_ button at the start of its toolbar, or uncheck _Editable_ in its <span class="tn-icon cke cke-three-vertical-dots"></span> _More actions_ menu. The drawing can then be panned and zoomed but not changed, and its toolbar holds only the zoom buttons. To draw again, turn _Editable_ back on.
diff --git a/docs/User Guide/User Guide/Note Types/Text/Insert buttons.md b/docs/User Guide/User Guide/Note Types/Text/Insert buttons.md
index 037d375af2..7d099886ef 100644
--- a/docs/User Guide/User Guide/Note Types/Text/Insert buttons.md
+++ b/docs/User Guide/User Guide/Note Types/Text/Insert buttons.md
@@ -33,6 +33,10 @@ Interaction:
See the dedicated <a class="reference-link" href="Math%20Equations.md">Math Equations</a> page.
+## Drawing canvas
+
+Choose <span class="tn-icon bx bx-pen"></span> _Drawing canvas_ to draw on an Excalidraw canvas inside the text. See _Drawing canvases_ in <a class="reference-link" href="Include%20Note.md">Include Note</a>.
+
## Mermaid diagram
Press the <span class="tn-icon cke cke-trilium-mermaid-insert"></span> button to create an inline Mermaid diagram.
diff --git a/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.ts b/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.spec.ts
index 663cadf009..bc1459a5d9 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
@@ -156,7 +156,7 @@ describe("FileUploadUI", () => {
const focus = vi.spyOn(editor.editing.view, "focus");
expect([ button.label, button.icon, button.tooltip ])
- .toEqual([ "Insert drawing canvas", bxPen, true ]);
+ .toEqual([ "Drawing canvas", bxPen, true ]);
button.fire("execute");
diff --git a/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.ts b/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.ts
index 557f7e7a6b..597740a43e 100644
--- a/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.ts
+++ b/packages/ckeditor5/src/plugins/file_upload/file_upload_ui.ts
@@ -85,7 +85,7 @@ export default class FileUploadUI extends Plugin {
editor.ui.componentFactory.add("drawingCanvas", (locale) => {
const button = new ButtonView(locale);
- button.set({ label: t("Insert drawing canvas"), icon: bxPen, tooltip: true });
+ button.set({ label: t("Drawing canvas"), icon: bxPen, tooltip: true });
const uploadCommand = editor.commands.get("fileUpload");
const embedCommand = editor.commands.get("insertContentEmbed");