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/8036 fix https://ld246.com/article/1698243367105

Vanessae50f23ba0216
diff --git a/app/src/assets/scss/export.scss b/app/src/assets/scss/export.scss
index 72d96f6d66..07c0c98c14 100644
--- a/app/src/assets/scss/export.scss
+++ b/app/src/assets/scss/export.scss
@@ -11,10 +11,6 @@
@import "component/slider";
@import "component/text-field";
-.protyle-wysiwyg {
- font-family: var(--b3-font-family);
-}
-
.protyle-wysiwyg a,
.b3-typography a {
color: var(--b3-protyle-inline-link-color);
diff --git a/app/src/assets/scss/protyle/_content.scss b/app/src/assets/scss/protyle/_content.scss
index aa0ba9966e..570a6b551a 100644
--- a/app/src/assets/scss/protyle/_content.scss
+++ b/app/src/assets/scss/protyle/_content.scss
@@ -1,5 +1,4 @@
.protyle {
- font-family: var(--b3-font-family);
overflow-x: hidden;
background-color: var(--b3-theme-background);
position: relative;
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 9f36405e06..2d78e09a09 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -68,6 +68,16 @@ export const saveExport = (option: IExportOptions) => {
/// #endif
};
+const getSnippetCSS = () => {
+ let snippetCSS = "";
+ document.querySelectorAll("style").forEach((item) => {
+ if (item.id.startsWith("snippet")) {
+ snippetCSS += item.innerHTML;
+ }
+ });
+ return snippetCSS;
+};
+
/// #if !BROWSER
const renderPDF = (id: string) => {
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
@@ -78,12 +88,6 @@ const renderPDF = (id: string) => {
themeStyle = `<link rel="stylesheet" type="text/css" id="themeStyle" href="${servePath}/appearance/themes/${window.siyuan.config.appearance.themeLight}/theme.css?${Constants.SIYUAN_VERSION}"/>`;
}
// data-theme-mode="light" https://github.com/siyuan-note/siyuan/issues/7379
- let snippetCSS = "";
- document.querySelectorAll("style").forEach((item) => {
- if (item.id.startsWith("snippet")) {
- snippetCSS += item.innerHTML;
- }
- });
const html = `<!DOCTYPE html>
<html lang="${window.siyuan.config.appearance.lang}" data-theme-mode="light" data-light-theme="${window.siyuan.config.appearance.themeLight}" data-dark-theme="${window.siyuan.config.appearance.themeDark}">
<head>
@@ -101,6 +105,7 @@ const renderPDF = (id: string) => {
<style>
body {
margin: 0;
+ font-family: var(--b3-font-family);
}
#action {
@@ -152,10 +157,8 @@ const renderPDF = (id: string) => {
margin-bottom: 12px;
}
${setInlineStyle(false)}
- </style>
- <style>
${document.getElementById("pluginsStyle").innerHTML}
- ${snippetCSS}
+ ${getSnippetCSS()}
</style>
</head>
<body>
@@ -617,8 +620,10 @@ const onExport = (data: IWebSocketData, filePath: string, exportOption: IExportO
${themeStyle}
<title>${pathPosix().basename(filePath)} - ${window.siyuan.languages.siyuanNote} v${Constants.SIYUAN_VERSION}</title>
<style>
- body {background-color: var(--b3-theme-background);color: var(--b3-theme-on-background)}
+ body {font-family: var(--b3-font-family);background-color: var(--b3-theme-background);color: var(--b3-theme-on-background)}
${setInlineStyle(false)}
+ ${document.getElementById("pluginsStyle").innerHTML}
+ ${getSnippetCSS()}
</style>
</head>
<body>
diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts
index a38aa880b0..1b4a71b6cc 100644
--- a/app/src/util/assets.ts
+++ b/app/src/util/assets.ts
@@ -218,7 +218,7 @@ export const setInlineStyle = (set = true) => {
.protyle-wysiwyg .h5 img.emoji, .b3-typography h5 img.emoji {width:${Math.floor(window.siyuan.config.editor.fontSize * 1.13 * 1.25)}px}
.protyle-wysiwyg .h6 img.emoji, .b3-typography h6 img.emoji {width:${Math.floor(window.siyuan.config.editor.fontSize * 1.25)}px}`;
if (window.siyuan.config.editor.fontFamily) {
- style += `\n.b3-typography:not(.b3-typography--default), .protyle {font-family: "${window.siyuan.config.editor.fontFamily}", var(--b3-font-family)}`;
+ style += `\n.b3-typography:not(.b3-typography--default), .protyle-wysiwyg, .protyle-title {font-family: "${window.siyuan.config.editor.fontFamily}", var(--b3-font-family)}`;
}
// pad 端菜单移除显示,如工作空间
if ("ontouchend" in document) {