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/16300

Vanessa0361599aba79
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 241590b242..a2c96ae0c3 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -117,13 +117,23 @@ export const saveExport = (option: IExportOptions) => {
const getSnippetCSS = () => {
let snippetCSS = "";
document.querySelectorAll("style").forEach((item) => {
- if (item.id.startsWith("snippet")) {
+ if (item.id.startsWith("snippetCSS")) {
snippetCSS += item.outerHTML;
}
});
return snippetCSS;
};
+const getSnippetJS = () => {
+ let snippetScript = "";
+ document.querySelectorAll("script").forEach((item) => {
+ if (item.id.startsWith("snippetJS")) {
+ snippetScript += item.outerHTML;
+ }
+ });
+ return snippetScript;
+};
+
/// #if !BROWSER
const renderPDF = async (id: string) => {
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
@@ -624,7 +634,9 @@ ${getIconScript(servePath)}
}
})
});
-</script></body></html>`;
+</script>
+${getSnippetJS()}
+</body></html>`;
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
ipcRenderer.send(Constants.SIYUAN_EXPORT_NEWWINDOW, response.data.url);
});
@@ -776,7 +788,8 @@ ${getIconScript(servePath)}
event.stopPropagation();
})
});
-</script></body></html>`;
+</script>
+${getSnippetJS()}</body></html>`;
// 移动端导出 pdf、浏览器导出 HTML
if (typeof filePath === "undefined") {
return html;