Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/16152

Vanessa5c79a0c3870c
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index 47c9aecd82..623718ef1f 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -766,8 +766,16 @@ export const exportMd = (id: string) => {
keepFold: localData.keepFold,
merge: localData.mergeSubdocs,
}, async response => {
+ const htmlElement = document.createElement("template");
+ htmlElement.innerHTML = response.data.content;
+ htmlElement.content.querySelectorAll("svg > use").forEach(item => {
+ const symbolElement = document.querySelector(`symbol${item.getAttribute("xlink:href")}`);
+ item.parentElement.setAttribute("viewBox", symbolElement.getAttribute("viewBox"));
+ item.outerHTML = symbolElement.innerHTML;
+ });
+ response.data.content = htmlElement.innerHTML
const html = await onExport(response, undefined, {type: "pdf", id});
- window.JSAndroid.exportPDF(html.replace('<use xlink:href="#iconDot"></use>', '<path d="M5.501 9.999c0 2.485 2.016 4.499 4.501 4.499s4.497-2.016 4.497-4.499c0-2.485-2.012-4.497-4.497-4.497s-4.501 2.012-4.501 4.497z"></path>'));
+ window.JSAndroid.exportPDF(html);
});
}
},
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 1d5ff61312..a9fadc5fbe 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -651,6 +651,7 @@ export const onExport = async (data: IWebSocketData, filePath: string, exportOpt
const html = `<!DOCTYPE html>
<html lang="${window.siyuan.config.appearance.lang}" data-theme-mode="${getThemeMode()}" data-light-theme="${window.siyuan.config.appearance.themeLight}" data-dark-theme="${window.siyuan.config.appearance.themeDark}">
<head>
+ <base href="${window.location.protocol}//${window.location.host}">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
@@ -671,8 +672,7 @@ export const onExport = async (data: IWebSocketData, filePath: string, exportOpt
</head>
<body>
<div class="${["htmlmd", "word"].includes(exportOption.type) ? "b3-typography" : "protyle-wysiwyg" + (window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : "")}"
-style="max-width: 800px;margin: 0 auto;"
-id="preview">${data.data.content}</div>
+style="max-width: 800px;margin: 0 auto;" id="preview">${data.data.content}</div>
<script src="appearance/icons/${window.siyuan.config.appearance.icon}/icon.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="stage/build/export/protyle-method.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="stage/protyle/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}"></script>