An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Handle invalid image links when exporting documents as images https://github.com/siyuan-note/siyuan/issues/18232
Daniel5887d674dfc9
diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.tsindex 80db1c2f68..d9456d9a10 100644--- a/app/src/protyle/export/util.ts+++ b/app/src/protyle/export/util.ts@@ -13,6 +13,8 @@ import {processRender} from "../util/processCode";import {isIPhone, isSafari, saveExportFile, setStorageVal} from "../util/compatibility";import {useShell} from "../../util/pathName";+const IMAGE_PLACEHOLDER = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";+export const afterExport = (exportPath: string, msgId: string) => {/// #if !BROWSERshowMessage(`${window.siyuan.languages.exported} ${escapeHtml(exportPath)}@@ -91,12 +93,18 @@ export const exportImage = (id: string) => {});setTimeout(() => {addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image").then(async () => {- let blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));+ const options = {+ imagePlaceholder: IMAGE_PLACEHOLDER,+ onImageErrorHandler: (event: Event) => {+ (event.target as HTMLImageElement).src = IMAGE_PLACEHOLDER;+ }+ };+ let blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"), options);if (isIPhone() || isSafari()) {- await window.htmlToImage.toBlob(contentElement);- await window.htmlToImage.toBlob(contentElement);- await window.htmlToImage.toBlob(contentElement);- blob = await window.htmlToImage.toBlob(contentElement);+ await window.htmlToImage.toBlob(contentElement, options);+ await window.htmlToImage.toBlob(contentElement, options);+ await window.htmlToImage.toBlob(contentElement, options);+ blob = await window.htmlToImage.toBlob(contentElement, options);}const formData = new FormData();formData.append("file", blob, btnsElement[1].getAttribute("data-title"));diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex dc372dab0f..8b08ce1d67 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -267,8 +267,8 @@ interface Window {}};htmlToImage: {- toCanvas: (element: Element, options?: Partial<IObject>) => Promise<HTMLCanvasElement>- toBlob: (element: Element, options?: Partial<IObject>) => Promise<Blob>+ toCanvas: (element: Element, options?: IHtmlToImageOptions) => Promise<HTMLCanvasElement>+ toBlob: (element: Element, options?: IHtmlToImageOptions) => Promise<Blob>};siyuan: ISiyuan;JSAndroid: {@@ -678,6 +678,12 @@ interface IObject {[key: string]: string | number | boolean;}+interface IHtmlToImageOptions {+ [key: string]: unknown;+ imagePlaceholder?: string;+ onImageErrorHandler?: (event: Event) => void;+}+interface ILayoutJSON extends ILayoutOptions {scrollAttr?: IScrollAttr,instance?: string,