Vanessa 2025-04-21 11:47:59 +08:00
parent 217a4e2a0a
commit 55f8c8bb38

View File

@ -12,7 +12,7 @@ import {
setFirstNodeRange, setFirstNodeRange,
setLastNodeRange setLastNodeRange
} from "../util/selection"; } from "../util/selection";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest"; import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByTag} from "../util/hasClosest";
import {Link} from "./Link"; import {Link} from "./Link";
import {setPosition} from "../../util/setPosition"; import {setPosition} from "../../util/setPosition";
import {updateTransaction} from "../wysiwyg/transaction"; import {updateTransaction} from "../wysiwyg/transaction";
@ -946,7 +946,7 @@ export class Toolbar {
} }
} }
public showRender(protyle: IProtyle, renderElement: Element, updateElements?: Element[], oldHTML?: string) { public showRender(protyle: IProtyle, renderElement: HTMLElement, updateElements?: Element[], oldHTML?: string) {
const nodeElement = hasClosestBlock(renderElement); const nodeElement = hasClosestBlock(renderElement);
if (!nodeElement) { if (!nodeElement) {
return; return;
@ -1116,15 +1116,15 @@ export class Toolbar {
} }
setTimeout(() => { setTimeout(() => {
addScript("/stage/protyle/js/html-to-image.min.js?v=1.11.13", "protyleHtml2image").then(() => { addScript("/stage/protyle/js/html-to-image.min.js?v=1.11.13", "protyleHtml2image").then(() => {
window.htmlToImage.toCanvas(renderElement).then((canvas) => { renderElement.style.display = "inline-block";
canvas.toBlob((blob: Blob) => { window.htmlToImage.toBlob(renderElement).then(blob => {
const formData = new FormData(); renderElement.style.display = "";
formData.append("file", blob); const formData = new FormData();
formData.append("type", "image/png"); formData.append("file", blob);
fetchPost("/api/export/exportAsFile", formData, (response) => { formData.append("type", "image/png");
openByMobile(response.data.file); fetchPost("/api/export/exportAsFile", formData, (response) => {
hideMessage(msgId); openByMobile(response.data.file);
}); hideMessage(msgId);
}); });
}); });
}); });