📱 export

This commit is contained in:
Vanessa 2022-11-14 17:50:54 +08:00
parent 26881d906e
commit 55558d0a77

View file

@ -1,3 +1,8 @@
/// #if !BROWSER
import {escapeHtml} from "../../util/escape";
import {shell} from "electron";
import * as path from "path";
/// #endif
import {hideMessage, showMessage} from "../../dialog/message"; import {hideMessage, showMessage} from "../../dialog/message";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {Dialog} from "../../dialog"; import {Dialog} from "../../dialog";
@ -13,12 +18,10 @@ import {chartRender} from "../markdown/chartRender";
import {mindmapRender} from "../markdown/mindmapRender"; import {mindmapRender} from "../markdown/mindmapRender";
import {abcRender} from "../markdown/abcRender"; import {abcRender} from "../markdown/abcRender";
import {plantumlRender} from "../markdown/plantumlRender"; import {plantumlRender} from "../markdown/plantumlRender";
/// #if !BROWSER
import {escapeHtml} from "../../util/escape";
import {shell} from "electron";
import * as path from "path";
declare const html2canvas: (element: Element) => Promise<any>;
export const afterExport = (exportPath: string, msgId: string) => { export const afterExport = (exportPath: string, msgId: string) => {
/// #if !BROWSER
showMessage(`${window.siyuan.languages.exported}${escapeHtml(exportPath)} showMessage(`${window.siyuan.languages.exported}${escapeHtml(exportPath)}
<div class="fn__space"></div> <div class="fn__space"></div>
<button class="b3-button b3-button--white">${window.siyuan.languages.showInFolder}</button>`, 6000, "info", msgId); <button class="b3-button b3-button--white">${window.siyuan.languages.showInFolder}</button>`, 6000, "info", msgId);
@ -26,20 +29,15 @@ export const afterExport = (exportPath: string, msgId: string) => {
shell.showItemInFolder(path.join(exportPath)); shell.showItemInFolder(path.join(exportPath));
hideMessage(msgId); hideMessage(msgId);
}); });
};
/// #endif /// #endif
};
declare const html2canvas: (element: Element) => Promise<any>;
export const exportImage = (id: string) => { export const exportImage = (id: string) => {
const exportDialog = new Dialog({ const exportDialog = new Dialog({
title: window.siyuan.languages.exportAsImage, title: window.siyuan.languages.exportAsImage,
content: `<div class="b3-dialog__content" style="max-height: 70vh;overflow: auto"> content: `<div class="b3-dialog__content" style="max-height: 70vh;overflow: auto;${isMobile()?"padding:8px;":""}">
<div style="padding: 48px; <div style="${isMobile()?"padding: 16px;margin: 16px 0":"padding: 48px;margin: 8px 0 24px"};border: 1px solid var(--b3-border-color);border-radius: 10px;" class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}" id="preview">
border: 1px solid var(--b3-border-color); <div class="fn__loading" style="left:0"><img height="128px" width="128px" src="stage/loading-pure.svg"></div>
border-radius: 10px;
margin: 8px 0 24px;" class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}" id="preview">
<div class="fn__loading" style="left:0"><img height="48px" width="48px" src="stage/loading-pure.svg"></div>
</div> </div>
<div class="ft__smaller ft__on-surface fn__flex"><img style="height: 18px;margin: 0 8px" src="stage/icon.png">${window.siyuan.languages.exportBySiYuan}</div> <div class="ft__smaller ft__on-surface fn__flex"><img style="height: 18px;margin: 0 8px" src="stage/icon.png">${window.siyuan.languages.exportBySiYuan}</div>
<div class="fn__hr--b"></div> <div class="fn__hr--b"></div>