Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Support copying any content block as a PNG image https://github.com/siyuan-note/siyuan/issues/18927

Daniel2add7ec78696
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index 596ed945e1..573aee970d 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -689,12 +689,24 @@ test("HTML file insertion follows general asset insertion", () => {
assert.equal(children[insertAssetIndex + 1]?.key, "insertHTMLFile");
});
+test("copy as PNG is available for documents and single blocks", () => {
+ const documentCopy = getEntryCatalogChildren("document.title.copy").map((item) => item.key);
+ const blockCopy = getEntryCatalogChildren("gutter.single.copy").map((item) => item.key);
+ assert.ok(getEntryCatalogNode("document.title.copy.copyAsPNG"));
+ assert.ok(getEntryCatalogNode("gutter.single.copy.copyAsPNG"));
+ assert.equal(getEntryCatalogNode("gutter.multi.copy.copyAsPNG"), undefined);
+ assert.equal(documentCopy[documentCopy.indexOf("copyMarkdown") + 1], "copyAsPNG");
+ assert.equal(blockCopy[blockCopy.indexOf("copyPlainText") + 1], "copyAsPNG");
+});
+
test("simple profile follows the reviewed defaults", () => {
const shown = [
"document.title.copy.copyBlockEmbed",
+ "document.title.copy.copyAsPNG",
"document.title.export.exportTemplate",
"document.title.export.exportImage",
"gutter.single.addToAgent",
+ "gutter.single.copy.copyAsPNG",
"gutter.single.turnInto.code",
"gutter.single.layout.alignTop",
"gutter.single.layout.alignMiddle",
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index 4c0a436f0f..d6da9b49ef 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -173,10 +173,11 @@ const docTreeMultiple = () => {
separator("separator_2"), openBy, exportEntry];
};
-const gutterCopyChildren = () => [
+const gutterCopyChildren = (includeCopyAsPNG = false) => [
...copyChildren(),
node("copyRichText", lang("copyRichText")),
node("copyPlainText", lang("copyPlainText")),
+ ...(includeCopyAsPNG ? [node("copyAsPNG", lang("copyAsPNG"))] : []),
node("copyText", lang("copyText")),
node("copy", lang("copy")),
node("copyAVID", lang("copyAVID")),
@@ -309,7 +310,7 @@ const gutterBase = (multi: boolean) => [
node("vLayout", lang("vLayout")),
])] : []),
node("ai", lang("aiEdit")),
- node("copy", lang("copy"), true, gutterCopyChildren()),
+ node("copy", lang("copy"), true, gutterCopyChildren(!multi)),
node("cut", lang("cut")),
node("move", lang("move")),
node("addToDatabase", lang("addToDatabase"), false),
@@ -632,7 +633,8 @@ export const entryCatalog: IEntryCatalogSection[] = [
key: "document.title",
label: location(lang("editor"), lang("entryDocumentMenu")),
children: [
- node("copy", lang("copy"), true, [...copyChildren(), node("copyMarkdown", lang("copyMarkdown")), node("copyDoc", lang("copyDoc"), false)]),
+ node("copy", lang("copy"), true, [...copyChildren(), node("copyMarkdown", lang("copyMarkdown")),
+ node("copyAsPNG", lang("copyAsPNG")), node("copyDoc", lang("copyDoc"), false)]),
node("move", lang("move")),
node("addToDatabase", lang("addToDatabase"), false),
node("delete", lang("delete")),
diff --git a/app/src/menus/util.ts b/app/src/menus/util.ts
index 59762cffe5..8a6291fff2 100644
--- a/app/src/menus/util.ts
+++ b/app/src/menus/util.ts
@@ -208,6 +208,24 @@ export const openEditorTab = (app: App, ids: string[], notebookId?: string, path
/// #endif
};
+export const writePNGBlob = async (blob: Blob): Promise<boolean> => {
+ try {
+ if (!navigator.clipboard?.write || typeof ClipboardItem === "undefined") {
+ throw new Error("image clipboard is unavailable");
+ }
+ await navigator.clipboard.write([
+ new ClipboardItem({
+ // @ts-ignore
+ ["image/png"]: blob
+ })
+ ]);
+ return true;
+ } catch (e) {
+ showMessage(window.siyuan.languages.clipboardPermissionDenied);
+ return false;
+ }
+};
+
export const copyPNGByLink = (link: string) => {
if (isInAndroid()) {
window.JSAndroid.writeImageClipboard(link);
@@ -215,21 +233,6 @@ export const copyPNGByLink = (link: string) => {
}
// 通过 fetch 拿到 blob 后再写入剪贴板,避免跨域图片直接 drawImage 污染 canvas 导致 toBlob 失败
// (浏览器访问 Docker 部署时常见,报错:Tainted canvases may not be exported)
- const writePNGBlob = (blob: Blob) => {
- try {
- navigator.clipboard.write([
- new ClipboardItem({
- // @ts-ignore
- ["image/png"]: blob
- })
- ]).catch(() => {
- showMessage(window.siyuan.languages.clipboardPermissionDenied);
- });
- } catch (e) {
- // http 等非安全上下文下 navigator.clipboard 可能为 undefined,这里会同步抛错
- showMessage(window.siyuan.languages.clipboardPermissionDenied);
- }
- };
// 把任意图片 blob 画进 canvas 再导出为 PNG;blob URL 为同源,不会污染 canvas
const blobToPNGClipboard = (blob: Blob) => {
if (blob.type === "image/png") {
diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.ts
index 0a534b51d5..8cf8417e3a 100644
--- a/app/src/protyle/export/util.ts
+++ b/app/src/protyle/export/util.ts
@@ -10,8 +10,9 @@ import {isMobile} from "../../util/functions";
import {Constants} from "../../constants";
import {highlightRender, lineNumberRender} from "../render/highlightRender";
import {processRender} from "../util/processCode";
-import {isIPad, isIPhone, isSafari, saveExportFile, setStorageVal} from "../util/compatibility";
+import {isInAndroid, isIPad, isIPhone, isSafari, saveExportFile, setStorageVal} from "../util/compatibility";
import {useShell} from "../../util/pathName";
+import {copyPNGByLink, writePNGBlob} from "../../menus/util";
// WebKit/Chromium 会拒绝宽度或高度超过此限制的 canvas,导致生成空白图像。
// html-to-image 默认会进行限制,而 modern-screenshot 不会(maximumCanvasSize
@@ -32,10 +33,10 @@ export const afterExport = (exportPath: string, msgId: string) => {
/// #endif
};
-export const exportImage = (id: string) => {
+export const exportImage = (id: string, copyOnly = false) => {
const exportDialog = new Dialog({
disableAnimation: true,
- title: window.siyuan.languages.exportAsImage,
+ title: copyOnly ? window.siyuan.languages.copyAsPNG : window.siyuan.languages.exportAsImage,
content: `<div class="b3-dialog__content" style="${isMobile() ? "padding:8px;" : ""};background-color: var(--b3-theme-background)">
<div style="${isMobile() ? "margin: 8px 0" : "padding: 48px;margin: 8px 0"}" class="export-img">
<div ${isMobile() ? 'style="padding:8px"' : ""} class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"></div>
@@ -43,19 +44,20 @@ export const exportImage = (id: string) => {
</div>
</div>
<div class="b3-dialog__action">
- <label class="fn__flex">
+ <label class="fn__flex${copyOnly ? " fn__none" : ""}">
${window.siyuan.languages.exportPDF5}
<span class="fn__space"></span>
- <input id="keepFold" class="b3-switch fn__flex-center" type="checkbox" ${window.siyuan.storage[Constants.LOCAL_EXPORTIMG].keepFold ? "checked" : ""}>
+ <input id="keepFold" class="b3-switch fn__flex-center" type="checkbox" ${!copyOnly && window.siyuan.storage[Constants.LOCAL_EXPORTIMG].keepFold ? "checked" : ""}>
</label>
- <label class="fn__flex" style="margin-left: 24px">
+ <label class="fn__flex${copyOnly ? " fn__none" : ""}" style="margin-left: 24px">
${window.siyuan.languages.export30}
<span class="fn__space"></span>
<input id="watermark" class="b3-switch fn__flex-center" type="checkbox" ${window.siyuan.storage[Constants.LOCAL_EXPORTIMG].watermark ? "checked" : ""}>
</label>
<span class="fn__flex-1 export-img__space"></span>
- <button disabled class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
- <button disabled class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
+ <button data-type="cancel" disabled class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
+ <button data-type="copy" disabled class="b3-button b3-button--text${copyOnly ? " fn__none" : ""}">${window.siyuan.languages.copyAsPNG}</button><div class="fn__space${copyOnly ? " fn__none" : ""}"></div>
+ <button data-type="export" disabled class="b3-button b3-button--text${copyOnly ? " fn__none" : ""}">${window.siyuan.languages.confirm}</button>
</div>
<div class="fn__loading"><img height="128px" width="128px" src="stage/loading-pure.svg"></div>`,
width: isMobile() ? "92vw" : "990px",
@@ -69,20 +71,31 @@ export const exportImage = (id: string) => {
}
});
exportDialog.element.setAttribute("data-key", Constants.DIALOG_EXPORTIMAGE);
- const btnsElement = exportDialog.element.querySelectorAll(".b3-button");
- btnsElement[0].addEventListener("click", () => {
- exportDialog.destroy();
- });
- btnsElement[1].addEventListener("click", async () => {
- const msgId = showMessage(window.siyuan.languages.exporting, 0);
- const containerElement = exportDialog.element.querySelector(".b3-dialog__container") as HTMLElement;
- containerElement.style.height = "";
- /// #if MOBILE
- containerElement.style.width = "100vw";
- /// #endif
- const contentElement = exportDialog.element.querySelector(".b3-dialog__content") as HTMLElement;
- contentElement.style.overflow = "hidden";
- setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]);
+ const cancelButton = exportDialog.element.querySelector('[data-type="cancel"]') as HTMLButtonElement;
+ const copyButton = exportDialog.element.querySelector('[data-type="copy"]') as HTMLButtonElement;
+ const exportButton = exportDialog.element.querySelector('[data-type="export"]') as HTMLButtonElement;
+ const previewElement = exportDialog.element.querySelector(".protyle-wysiwyg") as HTMLElement;
+ const foldElement = exportDialog.element.querySelector("#keepFold") as HTMLInputElement;
+ const watermarkElement = exportDialog.element.querySelector("#watermark") as HTMLInputElement;
+ let imageName = "image.png";
+ let outputting = false;
+
+ const setActionDisabled = (disabled: boolean) => {
+ cancelButton.disabled = disabled;
+ copyButton.disabled = disabled;
+ exportButton.disabled = disabled;
+ };
+ const uploadImageBlob = (blob: Blob) => {
+ const formData = new FormData();
+ formData.append("file", blob, imageName);
+ formData.append("type", "image/png");
+ return new Promise<IWebSocketData>((resolve) => {
+ fetchPost("/api/export/exportAsFile", formData, (response) => {
+ resolve(response);
+ });
+ });
+ };
+ const renderImageBlob = async () => {
const plantumlElements = previewElement.querySelectorAll("[data-subtype='plantuml']");
for (let i = 0; i < plantumlElements.length; i++) {
const objectElement = plantumlElements[i].querySelector("object");
@@ -99,45 +112,104 @@ export const exportImage = (id: string) => {
item.textContent = (index + 1).toString();
});
});
- const exportBlob = (blob: Blob) => {
- const formData = new FormData();
- formData.append("file", blob, btnsElement[1].getAttribute("data-title"));
- formData.append("type", "image/png");
- fetchPost("/api/export/exportAsFile", formData, (response) => {
- saveExportFile(response.data.file, msgId);
- });
- exportDialog.destroy();
- };
- setTimeout(() => {
- if (isIPhone() || isIPad() || isSafari()) {
- // modern-screenshot 通过缓存默认样式提高 WebKit/WKWebView 环境下的导出性能。
- addScript(`${Constants.PROTYLE_CDN}/js/modern-screenshot.min.js?v=4.6.6`, "protyleModernScreenshot").then(async () => {
- exportBlob(await window.modernScreenshot.domToBlob(contentElement, {
- type: "image/png",
- // 默认为 1,会导致高清屏上导出的图片比 html-to-image 模糊
- scale: window.devicePixelRatio || 1,
- maximumCanvasSize: MAX_CANVAS_SIZE,
- fetch: {placeholderImage: IMAGE_PLACEHOLDER}
- }));
+ await new Promise((resolve) => {
+ setTimeout(resolve, Constants.TIMEOUT_LOAD);
+ });
+ if (isIPhone() || isIPad() || isSafari()) {
+ // modern-screenshot 通过缓存默认样式提高 WebKit/WKWebView 环境下的导出性能。
+ await addScript(`${Constants.PROTYLE_CDN}/js/modern-screenshot.min.js?v=4.6.6`, "protyleModernScreenshot");
+ return window.modernScreenshot.domToBlob(
+ exportDialog.element.querySelector(".b3-dialog__content") as HTMLElement, {
+ type: "image/png",
+ // 默认为 1,会导致高清屏上导出的图片比 html-to-image 模糊
+ scale: window.devicePixelRatio || 1,
+ maximumCanvasSize: MAX_CANVAS_SIZE,
+ fetch: {placeholderImage: IMAGE_PLACEHOLDER}
});
- return;
+ }
+ await addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image");
+ return window.htmlToImage.toBlob(
+ exportDialog.element.querySelector(".b3-dialog__content") as HTMLElement, {
+ imagePlaceholder: IMAGE_PLACEHOLDER,
+ onImageErrorHandler: (event: Event) => {
+ (event.target as HTMLImageElement).src = IMAGE_PLACEHOLDER;
+ }
+ });
+ };
+ const outputImage = async (type: "copy" | "export") => {
+ if (outputting) {
+ return;
+ }
+ outputting = true;
+ setActionDisabled(true);
+ const msgId = showMessage(window.siyuan.languages.exporting, 0);
+ const containerElement = exportDialog.element.querySelector(".b3-dialog__container") as HTMLElement;
+ const oldHeight = containerElement.style.height;
+ containerElement.style.height = "";
+ /// #if MOBILE
+ containerElement.style.width = "100vw";
+ /// #endif
+ const contentElement = exportDialog.element.querySelector(".b3-dialog__content") as HTMLElement;
+ const oldOverflow = contentElement.style.overflow;
+ contentElement.style.overflow = "hidden";
+ if (!copyOnly) {
+ setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]);
+ }
+ try {
+ const blob = await renderImageBlob();
+ if (!blob) {
+ throw new Error(window.siyuan.languages.exportFileSaveFailed);
}
- addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image").then(async () => {
- exportBlob(await window.htmlToImage.toBlob(contentElement, {
- imagePlaceholder: IMAGE_PLACEHOLDER,
- onImageErrorHandler: (event: Event) => {
- (event.target as HTMLImageElement).src = IMAGE_PLACEHOLDER;
+ if (type === "copy") {
+ let copied: boolean;
+ if (isInAndroid()) {
+ const response = await uploadImageBlob(blob);
+ copied = response.code === 0;
+ if (copied) {
+ copyPNGByLink(response.data.file);
}
- }));
- });
- }, Constants.TIMEOUT_LOAD);
+ } else {
+ copied = await writePNGBlob(blob);
+ }
+ hideMessage(msgId);
+ if (!copied) {
+ return;
+ }
+ showMessage(window.siyuan.languages.copied);
+ } else {
+ const response = await uploadImageBlob(blob);
+ if (response.code !== 0) {
+ throw new Error(response.msg);
+ }
+ await saveExportFile(response.data.file, msgId);
+ }
+ exportDialog.destroy();
+ } catch (e) {
+ hideMessage(msgId);
+ console.error("Export image error:", e);
+ showMessage(e instanceof Error ? e.message : window.siyuan.languages.exportFileSaveFailed, 7000, "error");
+ } finally {
+ outputting = false;
+ if (document.body.contains(exportDialog.element)) {
+ containerElement.style.height = oldHeight;
+ contentElement.style.overflow = oldOverflow;
+ setActionDisabled(false);
+ }
+ }
+ };
+
+ cancelButton.addEventListener("click", () => {
+ exportDialog.destroy();
+ });
+ copyButton.addEventListener("click", () => {
+ outputImage("copy");
+ });
+ exportButton.addEventListener("click", () => {
+ outputImage("export");
});
- const previewElement = exportDialog.element.querySelector(".protyle-wysiwyg") as HTMLElement;
- const foldElement = (exportDialog.element.querySelector("#keepFold") as HTMLInputElement);
foldElement.addEventListener("change", () => {
- btnsElement[0].setAttribute("disabled", "disabled");
- btnsElement[1].setAttribute("disabled", "disabled");
- btnsElement[1].parentElement.insertAdjacentHTML("afterend", '<div class="fn__loading"><img height="128px" width="128px" src="stage/loading-pure.svg"></div>');
+ setActionDisabled(true);
+ exportButton.parentElement.insertAdjacentHTML("afterend", '<div class="fn__loading"><img height="128px" width="128px" src="stage/loading-pure.svg"></div>');
window.siyuan.storage[Constants.LOCAL_EXPORTIMG].keepFold = foldElement.checked;
fetchPost("/api/export/exportPreviewHTML", {
id,
@@ -147,12 +219,11 @@ export const exportImage = (id: string) => {
refreshPreview(response);
});
});
- const watermarkElement = (exportDialog.element.querySelector("#watermark") as HTMLInputElement);
watermarkElement.addEventListener("change", () => {
window.siyuan.storage[Constants.LOCAL_EXPORTIMG].watermark = watermarkElement.checked;
updateWatermark();
});
- const updateWatermark = () => {
+ const updateWatermark = async () => {
const watermarkPreviewElement = exportDialog.element.querySelector(".export-img__watermark") as HTMLElement;
watermarkPreviewElement.innerHTML = "";
if (watermarkElement.checked) {
@@ -162,22 +233,20 @@ export const exportImage = (id: string) => {
if (window.siyuan.config.export.imageWatermarkStr.startsWith("http")) {
watermarkPreviewElement.setAttribute("style", `background-image: url(${window.siyuan.config.export.imageWatermarkStr});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`);
} else {
- addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image").then(() => {
- const width = Math.max(exportDialog.element.querySelector(".export-img").clientWidth / 3, 150);
- watermarkPreviewElement.setAttribute("style", `width: ${width}px;height: ${width}px;display: flex;justify-content: center;align-items: center;color: var(--b3-border-color);font-size: 14px;`);
- watermarkPreviewElement.innerHTML = `<div style="transform: rotate(-45deg)">${window.siyuan.config.export.imageWatermarkStr}</div>`;
- window.htmlToImage.toCanvas(watermarkPreviewElement).then((canvas) => {
- watermarkPreviewElement.innerHTML = "";
- watermarkPreviewElement.setAttribute("style", `background-image: url(${canvas.toDataURL("image/png")});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`);
- });
- });
+ await addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image");
+ const width = Math.max(exportDialog.element.querySelector(".export-img").clientWidth / 3, 150);
+ watermarkPreviewElement.setAttribute("style", `width: ${width}px;height: ${width}px;display: flex;justify-content: center;align-items: center;color: var(--b3-border-color);font-size: 14px;`);
+ watermarkPreviewElement.innerHTML = `<div style="transform: rotate(-45deg)">${window.siyuan.config.export.imageWatermarkStr}</div>`;
+ const canvas = await window.htmlToImage.toCanvas(watermarkPreviewElement);
+ watermarkPreviewElement.innerHTML = "";
+ watermarkPreviewElement.setAttribute("style", `background-image: url(${canvas.toDataURL("image/png")});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`);
}
}
} else {
watermarkPreviewElement.removeAttribute("style");
}
};
- const refreshPreview = (response: IWebSocketData) => {
+ const refreshPreview = async (response: IWebSocketData) => {
previewElement.innerHTML = response.data.content;
previewElement.setAttribute("data-doc-type", response.data.type || "NodeDocument");
Object.keys(response.data.attrs).forEach(key => {
@@ -195,17 +264,20 @@ export const exportImage = (id: string) => {
}
});
- updateWatermark();
- btnsElement[0].removeAttribute("disabled");
- btnsElement[1].removeAttribute("disabled");
- exportDialog.element.querySelector(".fn__loading").remove();
+ await updateWatermark();
+ exportDialog.element.querySelector(".fn__loading")?.remove();
+ if (copyOnly) {
+ await outputImage("copy");
+ } else {
+ setActionDisabled(false);
+ }
};
fetchPost("/api/export/exportPreviewHTML", {
id,
keepFold: foldElement.checked,
image: true,
}, (response) => {
+ imageName = response.data.name + ".png";
refreshPreview(response);
- btnsElement[1].setAttribute("data-title", response.data.name + ".png");
});
};
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 2d51d458d1..fa2f5d7158 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -114,6 +114,7 @@ import {getBacklinkGutterContentTop, getFixedGutterPosition, getGutterMarginHeig
import {closeSubElement} from "../toolbar/subElementLifecycle";
import {canShowGutterInsert, genGutterBlockButtonHTML} from "./button";
import {getViewFoldOccurrenceID, hasViewFoldContext, setViewFold} from "../util/viewFold";
+import {exportImage} from "../export/util";
// 块类型 data-type 到本地化名称键的映射,用于块标提示中的 ${x}
const BLOCK_TYPE_LANG_KEYS: { [key: string]: string } = {
@@ -3377,6 +3378,13 @@ export class Gutter {
copyPlainText(getPlainText(nodeElement as HTMLElement).trimEnd());
focusBlock(nodeElement);
}
+ }, {
+ id: "copyAsPNG",
+ iconHTML: "",
+ label: window.siyuan.languages.copyAsPNG,
+ click() {
+ exportImage(id, true);
+ }
}, {
id: type === "NodeAttributeView" ? "copyMirror" : "copy",
iconHTML: "",
diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.ts
index 12f1bad5aa..3633ded8a1 100644
--- a/app/src/protyle/header/openTitleMenu.ts
+++ b/app/src/protyle/header/openTitleMenu.ts
@@ -28,6 +28,7 @@ import {hasTopClosestByClassName} from "../util/hasClosest";
import {showMessage} from "../../dialog/message";
import {buildBlockDOMClipboardRichData} from "../util/blockDOMClipboard";
import {buildWebClipboardHTML} from "../util/clipboardData";
+import {exportImage} from "../export/util";
export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: string) => {
hideTooltip();
@@ -49,6 +50,14 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: stri
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover-" + from : "app-" + from);
const submenu = copySubMenu([protyle.block.rootID], true, undefined, protyle.block.showAll ? protyle.block.id : protyle.block.rootID);
+ submenu.push({
+ id: "copyAsPNG",
+ iconHTML: "",
+ label: window.siyuan.languages.copyAsPNG,
+ click() {
+ exportImage(protyle.block.showAll ? protyle.block.id : protyle.block.rootID, true);
+ }
+ });
submenu.push({
id: "copyDoc",
iconHTML: "",