mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 Document supports copying as Markdown (#15397)
* ✨ Document supports copying standard Markdown * ✨ Document supports copying as Markdown
This commit is contained in:
parent
77ead023f8
commit
9a89a0eb4c
15 changed files with 43 additions and 4 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue