Skip to content

feat(client/menus): add Copy as Markdown#8808

Draft
yzx9 wants to merge 2 commits intoTriliumNext:mainfrom
yzx9:copy-as-md-context-menu
Draft

feat(client/menus): add Copy as Markdown#8808
yzx9 wants to merge 2 commits intoTriliumNext:mainfrom
yzx9:copy-as-md-context-menu

Conversation

@yzx9
Copy link
Contributor

@yzx9 yzx9 commented Feb 23, 2026

Summary

  • Add tree context menu option for copying note content as markdown
  • Add desktop context menu option for copying selected content as markdown
  • Includes translations for 16 languages

Screenshots

tree context menu, electron:

image

tree context menu, web:

image

electron context menu:

image

cc @eliandoran

close #5645 #8009

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 23, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yzx9, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature that enhances user productivity by allowing them to easily copy the content of a note as Markdown directly from the tree context menu. This streamlines the process of sharing or reusing note content in Markdown-compatible applications, improving the overall user experience.

Highlights

  • New Command Added: A new copyAsMarkdown command has been introduced to the application's command mappings, enabling new functionality.
  • Context Menu Integration: The 'Copy as markdown' option has been added to the tree context menu, providing users with a direct way to copy note content in Markdown format.
  • Markdown Copy Logic: The copyAsMarkdownCommand has been implemented in NoteTreeWidget, which fetches the note's content as Markdown via an API endpoint and copies it to the clipboard, providing user feedback through toast notifications.
  • Internationalization Support: Translations for the new 'Copy as markdown' menu item have been added across 16 different language files, ensuring broad accessibility.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • apps/client/src/components/app_context.ts
    • Added copyAsMarkdown to the CommandMappings type.
  • apps/client/src/menus/tree_context_menu.ts
    • Added a new menu item for "Copy as markdown" with its associated command and icon.
  • apps/client/src/translations/ar/translation.json
    • Added the Arabic translation for "copy-as-markdown".
  • apps/client/src/translations/cn/translation.json
    • Added the Chinese (Simplified) translation for "copy-as-markdown".
  • apps/client/src/translations/de/translation.json
    • Added the German translation for "copy-as-markdown".
  • apps/client/src/translations/en/translation.json
    • Added the English translation for "copy-as-markdown".
  • apps/client/src/translations/es/translation.json
    • Added the Spanish translation for "copy-as-markdown".
  • apps/client/src/translations/fr/translation.json
    • Added the French translation for "copy-as-markdown".
  • apps/client/src/translations/ga/translation.json
    • Added the Irish translation for "copy-as-markdown".
  • apps/client/src/translations/hi/translation.json
    • Added the Hindi translation for "copy-as-markdown".
  • apps/client/src/translations/it/translation.json
    • Added the Italian translation for "copy-as-markdown".
  • apps/client/src/translations/ja/translation.json
    • Added the Japanese translation for "copy-as-markdown".
  • apps/client/src/translations/pl/translation.json
    • Added the Polish translation for "copy-as-markdown".
  • apps/client/src/translations/pt/translation.json
    • Added the Portuguese translation for "copy-as-markdown".
  • apps/client/src/translations/pt_br/translation.json
    • Added the Brazilian Portuguese translation for "copy-as-markdown".
  • apps/client/src/translations/ro/translation.json
    • Added the Romanian translation for "copy-as-markdown".
  • apps/client/src/translations/ru/translation.json
    • Added the Russian translation for "copy-as-markdown".
  • apps/client/src/translations/tw/translation.json
    • Added the Chinese (Traditional) translation for "copy-as-markdown".
  • apps/client/src/translations/uk/translation.json
    • Added the Ukrainian translation for "copy-as-markdown".
  • apps/client/src/widgets/note_tree.ts
    • Imported clipboardExt for extended clipboard functionality.
    • Implemented the copyAsMarkdownCommand to fetch and copy note content as Markdown.
Activity
  • No specific review comments or activities have been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully adds the "Copy as markdown" feature to the tree context menu, providing a convenient way to export note content. The implementation is consistent with existing context menu actions and includes comprehensive translations for 17 languages. Note that there is a small typo in the PR title ("meun" instead of "menu"). The main area for improvement is the use of the native fetch API instead of the internal server service for the network request, which ensures proper header handling (e.g., CSRF tokens).

@yzx9 yzx9 force-pushed the copy-as-md-context-menu branch from fb34274 to 5ed6282 Compare February 23, 2026 15:20
@yzx9 yzx9 changed the title feat(tree_context_meun): add Copy as markdown feat(client/menus): add Copy as Markdown Feb 23, 2026
@yzx9 yzx9 force-pushed the copy-as-md-context-menu branch from 5ed6282 to a240c40 Compare February 23, 2026 15:28
Copy link
Contributor

@eliandoran eliandoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the implementation, it better aligns with our functional expectations, but I still have a few topics that need addressing.


{ title: t("tree-context-menu.export"), command: "exportNote", uiIcon: "bx bx-export", enabled: notSearch && noSelectedNotes && notOptionsOrHelp },

{ title: t("tree-context-menu.copy-as-markdown"), command: "copyAsMarkdown", uiIcon: "bx bx-copy-alt", enabled: notSearch && noSelectedNotes && notOptionsOrHelp },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I don't see the point in having the option to copy as markdown as part of the tree. It's not a general editing pattern.

Let's keep the only the context menu implementation for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context menu is only available in the Electron version, whereas the tree context menu works in both the web and Electron versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yzx9 , I understand your concern but the fact remains that tree is for note-related options, there are no other content-copy operations in it.

My suggestion is to only keep the Electron variant for now. Should you wish to implement it for desktop as well, we can go for:

  1. Making the context menu available on the browser.
  2. Making it as a keyboard shortcut.

Either way, I would treat those as a separate PR to unblock this one. But removing it from the tree is necessary, regardless.

Comment on lines 71 to 82
const html = await webContents.executeJavaScript(`
(function() {
const selection = window.getSelection();
if (!selection.rangeCount) return '';

const range = selection.getRangeAt(0);
const div = document.createElement('div');
div.appendChild(range.cloneContents());
return div.innerHTML;
})()
`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified, why is executeJavaScript required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I overlooked the fact that this script runs in the Renderer process.

@eliandoran eliandoran marked this pull request as draft February 23, 2026 18:08
@yzx9 yzx9 force-pushed the copy-as-md-context-menu branch from a240c40 to 15961cc Compare February 24, 2026 02:26
@yzx9 yzx9 requested a review from eliandoran February 26, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy as Markdown

2 participants