🎨 Document supports copying as Markdown (#15397)

*  Document supports copying standard Markdown

*  Document supports copying as Markdown
This commit is contained in:
Jeffrey Chen 2025-08-02 09:38:43 +08:00 committed by GitHub
parent 77ead023f8
commit 9a89a0eb4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 43 additions and 4 deletions

View file

@ -1180,6 +1180,7 @@
"newFileTip": "الرجاء فتح دفتر الملاحظات أولاً",
"copyBlockRef": "نسخ كمرجع كتلة",
"copyBlockEmbed": "نسخ ككتلة تضمين",
"copyMarkdown": "نسخ كـ Markdown",
"linkLevel": "العمق",
"mark": "تمييز",
"splitLR": "تقسيم لليمين",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Bitte öffnen Sie zuerst ein Notizbuch",
"copyBlockRef": "Blockreferenz kopieren",
"copyBlockEmbed": "Blockeinbettung kopieren",
"copyMarkdown": "Als Markdown kopieren",
"linkLevel": "Tiefe",
"mark": "Markieren",
"splitLR": "Rechts aufteilen",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Please open a notebook first",
"copyBlockRef": "Copy block ref",
"copyBlockEmbed": "Copy block embed",
"copyMarkdown": "Copy as Markdown",
"linkLevel": "Depth",
"mark": "Mark",
"splitLR": "Split Right",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Por favor, abra primero un cuaderno de notas",
"copyBlockRef": "Copiar bloque referencia",
"copyBlockEmbed": "Copiar bloque incrustado",
"copyMarkdown": "Copiar como Markdown",
"linkLevel": "Profundidad",
"mark": "Marca",
"splitLR": "Dividir a la derecha",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Veuillez d'abord ouvrir un carnet de notes",
"copyBlockRef": "Copier bloc réf",
"copyBlockEmbed": "Copier le bloc en tant que bloc incorporé",
"copyMarkdown": "Copier comme Markdown",
"linkLevel": "Niveaux",
"mark": "Mark",
"splitLR": "Split Droit",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "אנא פתח מחברת קודם",
"copyBlockRef": "העתק הפניה לבלוק",
"copyBlockEmbed": "העתק הטמעה לבלוק",
"copyMarkdown": "העתק כ-Markdown",
"linkLevel": "עומק",
"mark": "סמן",
"splitLR": "חלק ימינה",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Si prega di aprire prima un taccuino",
"copyBlockRef": "Copia riferimento blocco",
"copyBlockEmbed": "Copia incorporamento blocco",
"copyMarkdown": "Copia come Markdown",
"linkLevel": "Profondità",
"mark": "Segna",
"splitLR": "Dividi a destra",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "最初にノートブックを開いてください",
"copyBlockRef": "ブロック参照としてコピー",
"copyBlockEmbed": "埋め込みブロックとしてコピー",
"copyMarkdown": "Markdown としてコピー",
"linkLevel": "深さ",
"mark": "ハイライト",
"splitLR": "右に分割",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Proszę najpierw otworzyć notes",
"copyBlockRef": "Skopiuj odniesienie do bloku",
"copyBlockEmbed": "Skopiuj blok osadzony",
"copyMarkdown": "Skopiuj jako Markdown",
"linkLevel": "Głębokość",
"mark": "Zaznacz",
"splitLR": "Podziel w prawo",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Por favor, abra um bloco de notas primeiro",
"copyBlockRef": "Copiar referência de bloco",
"copyBlockEmbed": "Copiar bloco incorporado",
"copyMarkdown": "Copiar como Markdown",
"linkLevel": "Profundidade",
"mark": "Marca",
"splitLR": "Dividir à Direita",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "Пожалуйста, сначала откройте блокнот",
"copyBlockRef": "Скопировать ссылку на блок",
"copyBlockEmbed": "Скопировать встроенный блок",
"copyMarkdown": "Скопировать как Markdown",
"linkLevel": "Глубина",
"mark": "Значить",
"splitLR": "Разделить направо",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "請先打開一個筆記本",
"copyBlockRef": "複製為塊引用",
"copyBlockEmbed": "複製為嵌入塊",
"copyMarkdown": "複製為 Markdown",
"linkLevel": "層級",
"mark": "標記",
"splitLR": "向右並排顯示",

View file

@ -1180,6 +1180,7 @@
"newFileTip": "请先打开一个笔记本",
"copyBlockRef": "复制为块引用",
"copyBlockEmbed": "复制为嵌入块",
"copyMarkdown": "复制为 Markdown",
"linkLevel": "层级",
"mark": "标记",
"splitLR": "向右分屏",

View file

@ -6,7 +6,7 @@ import {getSearch, isMobile, isValidAttrName} from "../util/functions";
import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName";
import {MenuItem} from "./Menu";
import {saveExport} from "../protyle/export";
import {isInAndroid, isInHarmony, openByMobile} from "../protyle/util/compatibility";
import {isInAndroid, isInHarmony, openByMobile, writeText} from "../protyle/util/compatibility";
import {fetchPost, fetchSyncPost} from "../util/fetch";
import {hideMessage, showMessage} from "../dialog/message";
import {Dialog} from "../dialog";
@ -380,8 +380,8 @@ export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle?:
});
};
export const copySubMenu = (ids: string[], accelerator = true, focusElement?: Element) => {
return [{
export const copySubMenu = (ids: string[], accelerator = true, focusElement?: Element, stdMarkdownId?: string) => {
const menuItems = [{
id: "copyBlockRef",
iconHTML: "",
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockRef.custom : undefined,
@ -448,6 +448,32 @@ export const copySubMenu = (ids: string[], accelerator = true, focusElement?: El
}
}
}];
if (stdMarkdownId) {
menuItems.push({
id: "copyMarkdown",
iconHTML: "",
label: window.siyuan.languages.copyMarkdown,
accelerator: undefined,
click: async () => {
const response = await fetchSyncPost("/api/export/exportMdContent", {
id: stdMarkdownId,
refMode: 3,
embedMode: 1,
yfm: false,
fillCSSVar: false,
adjustHeadingLevel: false
});
const text = response.data.content;
writeText(text);
if (focusElement) {
focusBlock(focusElement);
}
}
});
}
return menuItems;
};
export const exportMd = (id: string) => {

View file

@ -42,7 +42,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
type: "submenu",
submenu: copySubMenu([protyle.block.rootID])
submenu: copySubMenu([protyle.block.rootID], true, undefined, protyle.block.showAll ? protyle.block.id : protyle.block.rootID)
}).element);
if (!protyle.disabled) {
window.siyuan.menus.menu.append(movePathToMenu([protyle.path]));