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

Vanessa15e40d2c2b30
diff --git a/app/src/assets/template/app/index.tpl b/app/src/assets/template/app/index.tpl
index cbd8c95daa..e1c19c4954 100644
--- a/app/src/assets/template/app/index.tpl
+++ b/app/src/assets/template/app/index.tpl
@@ -4,7 +4,6 @@
<meta charset="UTF-8">
<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag
<meta http-equiv="Content-Security-Policy" content="script-src 'self'"/>-->
- <style id="editorFontSize" type="text/css"></style>
<style id="editorAttr" type="text/css"></style>
</head>
<body class="fn__flex-column">
diff --git a/app/src/assets/template/app/window.tpl b/app/src/assets/template/app/window.tpl
index 1fa9943955..035aa33592 100644
--- a/app/src/assets/template/app/window.tpl
+++ b/app/src/assets/template/app/window.tpl
@@ -7,7 +7,6 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="apple-touch-icon" href="../../icon.png">
- <style id="editorFontSize" type="text/css"></style>
<style id="editorAttr" type="text/css"></style>
</head>
<body class="fn__flex-column body--window">
diff --git a/app/src/assets/template/desktop/index.tpl b/app/src/assets/template/desktop/index.tpl
index 255a0e4e99..cbbe239bc1 100644
--- a/app/src/assets/template/desktop/index.tpl
+++ b/app/src/assets/template/desktop/index.tpl
@@ -8,7 +8,6 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="apple-touch-icon" href="../../icon.png">
- <style id="editorFontSize" type="text/css"></style>
<style id="editorAttr" type="text/css"></style>
</head>
<body class="fn__flex-column">
diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl
index fe62694545..28f4d4b7d6 100644
--- a/app/src/assets/template/mobile/index.tpl
+++ b/app/src/assets/template/mobile/index.tpl
@@ -4,7 +4,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover">
<link rel="manifest" href="/manifest.webmanifest">
- <style id="editorFontSize" type="text/css"></style>
</head>
<body class="fn__flex-column">
<div id="loading" class="b3-dialog b3-dialog--open">
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 1ce2270f46..11f09b2525 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -29,10 +29,12 @@ export const loadPlugins = async (app: App) => {
loadPluginJS(app, item);
css += item.css || "" + "\n";
});
- const styleElement = document.createElement("style");
- styleElement.id = "pluginsStyle";
- styleElement.textContent = css;
- document.head.append(styleElement);
+ const pluginsStyle = document.getElementById("pluginsStyle")
+ if (pluginsStyle) {
+ pluginsStyle.innerHTML = css;
+ } else {
+ document.head.insertAdjacentHTML("beforeend", `<style id="pluginsStyle">${css}</style>`);
+ }
};
const loadPluginJS = async (app: App, item: IPluginData) => {
diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts
index 6347475198..ff9a422078 100644
--- a/app/src/util/assets.ts
+++ b/app/src/util/assets.ts
@@ -218,14 +218,19 @@ 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-wysiwyg, .protyle-title, .protyle-title__input{font-family: "${window.siyuan.config.editor.fontFamily}", "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols" !important;}`;
+ style += `\n.b3-typography:not(.b3-typography--default), .protyle {font-family: "${window.siyuan.config.editor.fontFamily}", var(--b3-font-family)}`;
}
// pad 端菜单移除显示,如工作空间
if ("ontouchend" in document) {
style += "\n.b3-menu .b3-menu__action {opacity: 0.68;}";
}
if (set) {
- document.getElementById("editorFontSize").innerHTML = style;
+ const siyuanStyle = document.getElementById("siyuanStyle")
+ if (siyuanStyle) {
+ siyuanStyle.innerHTML = style;
+ } else {
+ document.head.insertAdjacentHTML("beforeend", `<style id="siyuanStyle">${style}</style>`);
+ }
}
return style;
};