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,8 +1116,9 @@ 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 => {
renderElement.style.display = "";
const formData = new FormData(); const formData = new FormData();
formData.append("file", blob); formData.append("file", blob);
formData.append("type", "image/png"); formData.append("type", "image/png");
@ -1127,7 +1128,6 @@ export class Toolbar {
}); });
}); });
}); });
});
}, Constants.TIMEOUT_LOAD); }, Constants.TIMEOUT_LOAD);
}; };
const textElement = this.subElement.querySelector(".b3-text-field") as HTMLTextAreaElement; const textElement = this.subElement.querySelector(".b3-text-field") as HTMLTextAreaElement;