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/block references: rename the context menu item used to convert links to excerpts
Adorian Doran915bb08e67e4
diff --git a/apps/client/src/menus/link_context_menu.spec.ts b/apps/client/src/menus/link_context_menu.spec.tsindex 6343557ae3..8946435733 100644--- a/apps/client/src/menus/link_context_menu.spec.ts+++ b/apps/client/src/menus/link_context_menu.spec.ts@@ -379,6 +379,29 @@ describe("openContextMenu", () => {expect(mocks.show.mock.calls[1][0].items).toHaveLength(4);});+ it("offers converting a link to blocks of a note to an excerpt", async () => {+ mocks.getTextEditorContaining.mockResolvedValue({+ commands: { get: () => ({ isEnabled: true }) },+ plugins: { get: () => ({ canConvertLinkToEmbed: () => true }) },+ execute: vi.fn()+ });+ const editable = document.createElement("div");+ editable.className = "ck-editor__editable";+ editable.setAttribute("contenteditable", "true");+ editable.innerHTML = `<p><a class="reference-link" href="#root/n1?block=b1">Note</a></p>`;+ const link = editable.querySelector("a");+ expect(link).not.toBeNull();++ await linkContextMenu.openContextMenu(+ "root/n1", contextMenuEvent(link ?? undefined), { block: "b1" }+ );++ expect(mocks.show.mock.calls[0][0].items.at(-1)).toMatchObject({+ title: "link_context_menu.convert_link_to_note_excerpt",+ uiIcon: "bx bx-window-alt"+ });+ });+describe("opened on an embed in a note being edited", () => {const CHECK = "bx bx-check";const execute = vi.fn();diff --git a/apps/client/src/menus/link_context_menu.ts b/apps/client/src/menus/link_context_menu.tsindex 5fc30c3d12..54d7822221 100644--- a/apps/client/src/menus/link_context_menu.ts+++ b/apps/client/src/menus/link_context_menu.ts@@ -43,7 +43,7 @@ async function openContextMenu(const embed = editor && getMenuEmbed(e, editor);const ownItems = viewScope.viewMode === "attachments" && viewScope.attachmentId? await getAttachmentItems(noteId, viewScope.attachmentId, e, editor, embed)- : await getNoteItems(noteId, e, editor, embed);+ : await getNoteItems(noteId, e, editor, embed, !!viewScope.block);// A later right-click opened its own menu while this one waited for the editor or the// attachment.if (request !== lastMenuRequest) {@@ -195,17 +195,21 @@ async function getAttachmentItems(/*** The commands of an embedded note that the menu is opened on, in a group of their own, and- * converting it in another. A menu opened on a link to the note offers converting the link.+ * converting it in another. A menu opened on a link to the note offers converting the link, to an+ * excerpt for a link to blocks of the note.*/async function getNoteItems(noteId: string,e: LinkMenuOrigin,editor: CKTextEditor | null,- embed: MenuEmbed | null+ embed: MenuEmbed | null,+ isBlockReference: boolean): Promise<MenuItem<CommandNames>[]> {if (!embed) {const embedItem = await getConvertToEmbedItem(- e, editor, t("link_context_menu.convert_link_to_included_note"),+ e, editor, isBlockReference+ ? t("link_context_menu.convert_link_to_note_excerpt")+ : t("link_context_menu.convert_link_to_included_note"),() => froca.getNote(noteId));return embedItem ? [ { kind: "separator" }, embedItem ] : [];diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 470a895bd8..463a2cf8be 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3095,6 +3095,7 @@"open_note_in_popup": "Quick edit","convert_link_to_embed": "Convert link to an embed","convert_link_to_included_note": "Convert link to an included note",+ "convert_link_to_note_excerpt": "Convert link to note excerpt","convert_embed_to_link": "Convert to link","include_size": "Size","show_title": "Show title",diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Block references.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Block references.htmlindex 2fffe2269f..dee5bfcfce 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Block references.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Block references.html@@ -22,7 +22,7 @@shown instead, along with the blocks of the range that still exist.</p><h2>Including the referenced blocks</h2><p>To show the referenced blocks inside another note, right-click the link- in a note being edited and select <em>Convert link to an included note</em>.+ in a note being edited and select <em>Convert link to note excerpt</em>.The include shows only the referenced blocks, not the rest of the note,and marks them with an <em>Excerpt</em> badge in its title. To see the wholenote, press the <span class="tn-icon bx bx-link-external"></span> buttondiff --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 9e7b39b7a7..c27f3eff3e 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@@ -13,8 +13,9 @@as one added from the button does.</p><p>An <a href="#root/_help_0vhv7lsOLy82">attachment</a> can be included thesame way, from the context menu of a link to it (see <em>Embedding an attachment</em> there).</p>-<p>A link to blocks of a text note is converted the same way, and the include- then shows only those blocks. See <a class="reference-link" href="#root/_help_klC3ilXa9kUE">Block references</a>.</p>+<p>A link to blocks of a text note is converted the same way, with <em>Convert link to note excerpt</em>,+ and the include then shows only those blocks. See <a class="reference-link"+ href="#root/_help_klC3ilXa9kUE">Block references</a>.</p><h2>Box sizes</h2><p>The box size sets how much of the included note is shown.</p><ul>diff --git a/docs/User Guide/User Guide/Note Types/Text/Block references.md b/docs/User Guide/User Guide/Note Types/Text/Block references.mdindex 3c31ea667c..c7e5c39202 100644--- a/docs/User Guide/User Guide/Note Types/Text/Block references.md+++ b/docs/User Guide/User Guide/Note Types/Text/Block references.md@@ -16,7 +16,7 @@ Clicking a block reference opens the note, scrolls to the referenced blocks and## Including the referenced blocks-To show the referenced blocks inside another note, right-click the link in a note being edited and select _Convert link to an included note_. The include shows only the referenced blocks, not the rest of the note, and marks them with an _Excerpt_ badge in its title. To see the whole note, press the <span class="tn-icon bx bx-link-external"></span> button in the same title, which opens the note in a new tab. Converting the include back to a link keeps the reference.+To show the referenced blocks inside another note, right-click the link in a note being edited and select _Convert link to note excerpt_. The include shows only the referenced blocks, not the rest of the note, and marks them with an _Excerpt_ badge in its title. To see the whole note, press the <span class="tn-icon bx bx-link-external"></span> button in the same title, which opens the note in a new tab. Converting the include back to a link keeps the reference.To edit the referenced blocks without leaving the note, turn on _Editable_ in the toolbar of the include, as for any <a class="reference-link" href="Include%20Note.md">Include Note</a>. The changes are saved to the referenced blocks, and the rest of the note stays as it is.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 47640caa6a..f60ad7e631 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@@ -11,7 +11,7 @@ To include a note that is already linked, right-click a reference link to it inAn [attachment](../../Basic%20Concepts%20and%20Features/Notes/Attachments.md) can be included the same way, from the context menu of a link to it (see _Embedding an attachment_ there).-A link to blocks of a text note is converted the same way, and the include then shows only those blocks. See <a class="reference-link" href="Block%20references.md">Block references</a>.+A link to blocks of a text note is converted the same way, with _Convert link to note excerpt_, and the include then shows only those blocks. See <a class="reference-link" href="Block%20references.md">Block references</a>.## Box sizes