An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support configuring the global default font https://github.com/siyuan-note/siyuan/issues/19148
Danielba30b2a789f9
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 96b7a1bcbe..1bfad1b42b 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "الخط الافتراضي العام",+ "globalDefaultFontTip": "يُستخدم للواجهة والمحتوى الذي لم يُحدَّد له خط منفصل؛ اترك الاختيار فارغًا لاستخدام الخط الافتراضي للسمة","mobileMultiSelectTip": "اضغط على الكتل لتحديدها أو إلغاء تحديدها","headingBatchWithSubheadingsTip": "تغيير مستويات العناوين الفرعية بالمقدار نفسه؛ تُحصر المستويات خارج النطاق من H1 إلى H6 في H1 أو H6","newSiblingDoc": "إنشاء مستند جديد في المستوى نفسه",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex acffc35555..8fdf716793 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Globale Standardschrift",+ "globalDefaultFontTip": "Für die Oberfläche und Inhalte ohne eigene Schrifteinstellung; ohne Auswahl wird die Standardschrift des Designs verwendet","mobileMultiSelectTip": "Tippe auf Blöcke, um sie auszuwählen oder die Auswahl aufzuheben","headingBatchWithSubheadingsTip": "Unterüberschriften um denselben Abstand verschieben; Ebenen außerhalb von H1 bis H6 werden auf H1 oder H6 begrenzt","newSiblingDoc": "Neues Dokument auf gleicher Ebene",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 7a9ea9871c..b5efea15e1 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Global Default Font",+ "globalDefaultFontTip": "Used for the interface and content without a separate font setting; leave empty to use the theme's default font","mobileMultiSelectTip": "Tap blocks to select or deselect them","headingBatchWithSubheadingsTip": "Shift subheadings by the same amount; levels outside H1 to H6 are limited to H1 or H6","newSiblingDoc": "New sibling document",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 32574363cb..eac924d691 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Fuente predeterminada global",+ "globalDefaultFontTip": "Se usa en la interfaz y en el contenido sin una fuente específica; deja la selección vacía para usar la fuente predeterminada del tema","mobileMultiSelectTip": "Toca los bloques para seleccionarlos o deseleccionarlos","headingBatchWithSubheadingsTip": "Cambiar los subencabezados en la misma cantidad de niveles; los niveles fuera de H1 a H6 se limitan a H1 o H6","newSiblingDoc": "Nuevo documento del mismo nivel",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 1e9bc362f4..946593ce5f 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Police globale par défaut",+ "globalDefaultFontTip": "Utilisée pour l'interface et le contenu sans police spécifique ; ne sélectionnez aucune police pour utiliser celle du thème","mobileMultiSelectTip": "Touchez les blocs pour les sélectionner ou les désélectionner","headingBatchWithSubheadingsTip": "Décaler les sous-titres du même nombre de niveaux ; les niveaux hors de H1 à H6 sont limités à H1 ou H6","newSiblingDoc": "Nouveau document de même niveau",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 3876914656..e7b90c955c 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "גופן ברירת מחדל כללי",+ "globalDefaultFontTip": "משמש לממשק ולתוכן ללא הגדרת גופן נפרדת; יש להשאיר את הבחירה ריקה כדי להשתמש בגופן ברירת המחדל של ערכת הנושא","mobileMultiSelectTip": "הקישו על בלוקים כדי לבחור אותם או לבטל את בחירתם","headingBatchWithSubheadingsTip": "שינוי רמות כותרות המשנה באותו הפרש; רמות מחוץ לטווח H1 עד H6 יוגבלו ל־H1 או H6","newSiblingDoc": "מסמך חדש באותה רמה",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 3be1d1ec7c..3baf433adb 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "वैश्विक डिफ़ॉल्ट फ़ॉन्ट",+ "globalDefaultFontTip": "इंटरफ़ेस और अलग फ़ॉन्ट सेटिंग के बिना सामग्री के लिए उपयोग किया जाता है; थीम का डिफ़ॉल्ट फ़ॉन्ट उपयोग करने के लिए चयन खाली छोड़ें","mobileMultiSelectTip": "ब्लॉक चुनने या उनका चयन हटाने के लिए उन पर टैप करें","headingBatchWithSubheadingsTip": "उपशीर्षकों के स्तर समान अंतर से बदलें; H1 से H6 की सीमा से बाहर के स्तर H1 या H6 तक सीमित रहेंगे","newSiblingDoc": "समान स्तर पर नया दस्तावेज़",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex a4b81def93..312bb6aafe 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Font Default Global",+ "globalDefaultFontTip": "Digunakan untuk antarmuka dan konten tanpa pengaturan font tersendiri; biarkan pilihan kosong untuk menggunakan font default tema","mobileMultiSelectTip": "Ketuk blok untuk memilih atau membatalkan pilihan","headingBatchWithSubheadingsTip": "Geser subjudul dengan selisih tingkat yang sama; tingkat di luar H1 hingga H6 dibatasi ke H1 atau H6","newSiblingDoc": "Dokumen baru pada tingkat yang sama",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 89aae88653..fce87de2b7 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Carattere predefinito globale",+ "globalDefaultFontTip": "Usato per l'interfaccia e i contenuti senza un carattere specifico; lascia vuota la selezione per usare il carattere predefinito del tema","mobileMultiSelectTip": "Tocca i blocchi per selezionarli o deselezionarli","headingBatchWithSubheadingsTip": "Sposta i sottotitoli dello stesso numero di livelli; i livelli al di fuori di H1–H6 vengono limitati a H1 o H6","newSiblingDoc": "Nuovo documento allo stesso livello",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex db4833ca86..0ead3f0e1b 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "全体の既定フォント",+ "globalDefaultFontTip": "インターフェースとフォントを個別に設定していないコンテンツに使用します。何も選択しない場合はテーマの既定フォントを使用します","mobileMultiSelectTip": "ブロックをタップして選択または選択解除","headingBatchWithSubheadingsTip": "子見出しも同じレベル差で変更し、H1 から H6 の範囲を超える場合は H1 または H6 に制限します","newSiblingDoc": "同じ階層に新規ドキュメントを作成",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 96cc58bac5..ebaa6220e0 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "전역 기본 글꼴",+ "globalDefaultFontTip": "인터페이스와 글꼴을 별도로 설정하지 않은 콘텐츠에 사용하며, 글꼴을 선택하지 않으면 테마의 기본 글꼴을 사용합니다","mobileMultiSelectTip": "블록을 탭하여 선택하거나 선택 해제하세요","headingBatchWithSubheadingsTip": "하위 제목도 같은 수준 차이만큼 변경하며 H1부터 H6까지의 범위를 벗어나면 H1 또는 H6으로 제한합니다","newSiblingDoc": "같은 수준에 새 문서 만들기",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 451ebb7913..b13cd240c9 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Globaal standaardlettertype",+ "globalDefaultFontTip": "Voor de interface en inhoud zonder afzonderlijk ingesteld lettertype; laat de selectie leeg om het standaardlettertype van het thema te gebruiken","mobileMultiSelectTip": "Tik op blokken om ze te selecteren of te deselecteren","headingBatchWithSubheadingsTip": "Verschuif subkoppen met hetzelfde aantal niveaus; niveaus buiten H1 tot H6 worden begrensd op H1 of H6","newSiblingDoc": "Nieuw document op hetzelfde niveau",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex b20d7a5392..4347516a36 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Globalna czcionka domyślna",+ "globalDefaultFontTip": "Używana w interfejsie i treści bez osobnego ustawienia czcionki; pozostaw pusty wybór, aby użyć domyślnej czcionki motywu","mobileMultiSelectTip": "Dotknij bloków, aby je zaznaczyć lub odznaczyć","headingBatchWithSubheadingsTip": "Przesuń podnagłówki o tę samą liczbę poziomów; poziomy poza zakresem H1–H6 zostaną ograniczone do H1 lub H6","newSiblingDoc": "Nowy dokument na tym samym poziomie",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex abfc57100e..73fdcd6d8a 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Fonte padrão global",+ "globalDefaultFontTip": "Usada na interface e no conteúdo sem uma fonte específica; deixe a seleção vazia para usar a fonte padrão do tema","mobileMultiSelectTip": "Toque nos blocos para selecioná-los ou desmarcá-los","headingBatchWithSubheadingsTip": "Deslocar os subtítulos pela mesma diferença de níveis; níveis fora de H1 a H6 são limitados a H1 ou H6","newSiblingDoc": "Novo documento no mesmo nível",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex cbc57efb64..87d0211aa1 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Глобальный шрифт по умолчанию",+ "globalDefaultFontTip": "Используется для интерфейса и содержимого без отдельной настройки шрифта; если ничего не выбрано, используется шрифт темы по умолчанию","mobileMultiSelectTip": "Нажимайте на блоки, чтобы выделить их или снять выделение","headingBatchWithSubheadingsTip": "Сдвинуть подзаголовки на такое же число уровней; уровни за пределами H1–H6 ограничиваются H1 или H6","newSiblingDoc": "Новый документ на том же уровне",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex a4612e41b8..d0da9d8398 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Globálne predvolené písmo",+ "globalDefaultFontTip": "Používa sa pre rozhranie a obsah bez samostatného nastavenia písma; bez výberu sa použije predvolené písmo témy","mobileMultiSelectTip": "Ťuknutím na bloky ich vyberiete alebo zrušíte ich výber","headingBatchWithSubheadingsTip": "Posunúť podnadpisy o rovnaký počet úrovní; úrovne mimo rozsahu H1 až H6 sa obmedzia na H1 alebo H6","newSiblingDoc": "Nový dokument na rovnakej úrovni",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 4d7a3a426c..f31845b8bd 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "แบบอักษรเริ่มต้นส่วนกลาง",+ "globalDefaultFontTip": "ใช้กับส่วนติดต่อและเนื้อหาที่ไม่ได้ตั้งค่าแบบอักษรแยกไว้ หากไม่เลือกแบบอักษรจะใช้แบบอักษรเริ่มต้นของธีม","mobileMultiSelectTip": "แตะบล็อกเพื่อเลือกหรือยกเลิกการเลือก","headingBatchWithSubheadingsTip": "ปรับหัวเรื่องย่อยด้วยผลต่างระดับเดียวกัน โดยระดับที่เกินช่วง H1 ถึง H6 จะถูกจำกัดไว้ที่ H1 หรือ H6","newSiblingDoc": "สร้างเอกสารใหม่ในระดับเดียวกัน",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 85274f509c..228e06ba6c 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Genel Varsayılan Yazı Tipi",+ "globalDefaultFontTip": "Arayüz ve ayrı bir yazı tipi ayarı olmayan içerik için kullanılır; temanın varsayılan yazı tipini kullanmak için seçimi boş bırakın","mobileMultiSelectTip": "Blokları seçmek veya seçimlerini kaldırmak için dokunun","headingBatchWithSubheadingsTip": "Alt başlıkları aynı düzey farkıyla kaydır; H1 ile H6 aralığının dışındaki düzeyler H1 veya H6 ile sınırlandırılır","newSiblingDoc": "Aynı düzeyde yeni belge",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex d82ef0b8a1..c52ac36081 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "Глобальний типовий шрифт",+ "globalDefaultFontTip": "Використовується для інтерфейсу та вмісту без окремого налаштування шрифту; якщо нічого не вибрано, використовується типовий шрифт теми","mobileMultiSelectTip": "Торкайтеся блоків, щоб вибрати їх або скасувати вибір","headingBatchWithSubheadingsTip": "Зсунути підзаголовки на таку саму кількість рівнів; рівні поза межами H1–H6 обмежуються H1 або H6","newSiblingDoc": "Новий документ на тому самому рівні",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 49b0be90c6..d0ec2f7f92 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "全局默认字体",+ "globalDefaultFontTip": "用于界面和未单独设置字体的内容,不选择任何字体时使用主题默认字体","mobileMultiSelectTip": "轻点块以选中或取消选中","headingBatchWithSubheadingsTip": "子标题按相同级差升降,超出 H1 至 H6 的级别按 H1 或 H6 处理","newSiblingDoc": "新建同级文档",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 4ac4b7d0e6..bd0dd14f1b 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,6 @@{+ "globalDefaultFont": "全域預設字型",+ "globalDefaultFontTip": "用於介面和未個別設定字型的內容,未選擇任何字型時使用佈景主題的預設字型","mobileMultiSelectTip": "輕點區塊以選取或取消選取","headingBatchWithSubheadingsTip": "子標題依相同層級差升降,超出 H1 至 H6 的層級以 H1 或 H6 處理","newSiblingDoc": "新增同級文件",diff --git a/app/appearance/themes/daylight/theme.css b/app/appearance/themes/daylight/theme.cssindex f3b4e28bd7..aca35b1d83 100644--- a/app/appearance/themes/daylight/theme.css+++ b/app/appearance/themes/daylight/theme.css@@ -25,7 +25,8 @@/* 字体 *//* "Segoe UI" 和 Noto-COLRv1-2.047 冲突,故移除 */--b3-font-family-emoji-reset: "Emojis Additional", "Emojis Reset";- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", arial, sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", arial, sans-serif, emojis;+ --b3-font-family: var(--b3-font-family-default);--b3-font-family-protyle: var(--b3-font-family);--b3-font-family-code: var(--b3-font-family-emoji-reset), "JetBrainsMono-Regular", mononoki, Consolas, "Liberation Mono", var(--b3-font-family);--b3-font-family-graph: arial;@@ -228,15 +229,15 @@/* 微软字体斜体会被相邻背景遮挡,将 arial 放置其前 https://github.com/siyuan-note/siyuan/issues/11841 */:root:lang(zh-CN) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang SC", "Luxi Sans", "DejaVu Sans", arial, "Microsoft Yahei", "Hiragino Sans GB", "Source Han Sans SC", sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang SC", "Luxi Sans", "DejaVu Sans", arial, "Microsoft Yahei", "Hiragino Sans GB", "Source Han Sans SC", sans-serif, emojis;}:root:lang(zh-TW) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang TC", "Luxi Sans", "DejaVu Sans", arial, "Microsoft JhengHei", "Hiragino Sans TC", "Source Han Sans TC", sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang TC", "Luxi Sans", "DejaVu Sans", arial, "Microsoft JhengHei", "Hiragino Sans TC", "Source Han Sans TC", sans-serif, emojis;}:root:lang(ja) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", "Yu Gothic UI", arial, sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", "Yu Gothic UI", arial, sans-serif, emojis;}.b3-typography .code-block, .protyle-wysiwyg .code-block {diff --git a/app/appearance/themes/midnight/theme.css b/app/appearance/themes/midnight/theme.cssindex 1cbc8b743e..8c3fec5dc7 100644--- a/app/appearance/themes/midnight/theme.css+++ b/app/appearance/themes/midnight/theme.css@@ -24,7 +24,8 @@/* 字体 */--b3-font-family-emoji-reset: "Emojis Additional", "Emojis Reset";- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", arial, sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", arial, sans-serif, emojis;+ --b3-font-family: var(--b3-font-family-default);--b3-font-family-protyle: var(--b3-font-family);--b3-font-family-code: var(--b3-font-family-emoji-reset), "JetBrainsMono-Regular", mononoki, Consolas, "Liberation Mono", var(--b3-font-family);--b3-font-family-graph: arial;@@ -227,15 +228,15 @@/* 微软字体斜体会被相邻背景遮挡,将 arial 放置其前 https://github.com/siyuan-note/siyuan/issues/11841;"Segoe UI" 和 Noto-COLRv1-2.047 冲突,故移除。 */:root:lang(zh-CN) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang SC", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Source Han Sans SC", arial, "Microsoft Yahei", sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang SC", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Source Han Sans SC", arial, "Microsoft Yahei", sans-serif, emojis;}:root:lang(zh-TW) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang TC", "Luxi Sans", "DejaVu Sans", "Hiragino Sans TC", "Source Han Sans TC", "Microsoft JhengHei", arial, sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "PingFang TC", "Luxi Sans", "DejaVu Sans", "Hiragino Sans TC", "Source Han Sans TC", "Microsoft JhengHei", arial, sans-serif, emojis;}:root:lang(ja) {- --b3-font-family: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", "Yu Gothic UI", arial, sans-serif, emojis;+ --b3-font-family-default: var(--b3-font-family-emoji-reset), BlinkMacSystemFont, Helvetica, "Luxi Sans", "DejaVu Sans", "Yu Gothic UI", arial, sans-serif, emojis;}.b3-text-field::-webkit-calendar-picker-indicator {diff --git a/app/src/config/tabs/appearanceRuntime.ts b/app/src/config/tabs/appearanceRuntime.tsindex d0ae0b8d57..5f3cc9ec10 100644--- a/app/src/config/tabs/appearanceRuntime.ts+++ b/app/src/config/tabs/appearanceRuntime.ts@@ -6,7 +6,7 @@ import {exportLayout} from "../../layout/util";import {syncHideToolbarLayout, updateBarModeIcon} from "../../layout/topBar";/// #endifimport {fetchPost} from "../../util/fetch";-import {loadAssets, unloadThemeScript} from "../../util/assets";+import {loadAssets, refreshHeadingNumberMeasurements, setInlineStyle, unloadThemeScript} from "../../util/assets";import {getFrontend} from "../../util/functions";import {shouldUnloadThemeScript} from "../../util/themeCompatibility";import {remountOpenSettingTab} from "../setting/mount";@@ -79,6 +79,10 @@ const applyAppearanceConfig = async (data: Config.IAppearance) => {/// #endifloadAssets(data);+ if (JSON.stringify(data.globalFontFamilies) !== JSON.stringify(prevAppearance.globalFontFamilies)) {+ await setInlineStyle();+ refreshHeadingNumberMeasurements();+ }/// #if !MOBILEvoid remountOpenSettingTab("appearance");/// #endifdiff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.tsindex e72b107696..59c1ab178d 100644--- a/app/src/config/tabs/appearanceTab.ts+++ b/app/src/config/tabs/appearanceTab.ts@@ -24,7 +24,7 @@ import {genListSwitchItemHtml} from "../render/fragments";import {genStackHtml} from "../render/render";import {controlBoolean} from "../setting/control";import {editorConfigApi} from "./editorRuntime";-import {appearanceThemeModeValue, saveThemeMode} from "./appearanceRuntime";+import {appearanceConfigApi, appearanceThemeModeValue, saveThemeMode} from "./appearanceRuntime";import {upDownHint} from "../../util/upDownHint";import {isThemeFrontendSupported} from "../../util/themeCompatibility";import {setEditorFontSize} from "../../util/editorFontSize";@@ -37,7 +37,7 @@ import {unregisterCustomFont} from "../../util/customFont";import {showMessage} from "../../dialog/message";-import {IFontItem, loadSystemFonts} from "../../util/systemFont";+import {getUniqueFontFamilies, IFontItem, loadSystemFonts} from "../../util/systemFont";import {shouldShowBootAppearanceSetting,type IBootAppearanceListItem,@@ -56,10 +56,21 @@ interface IBootAppearanceListData {current: IBootAppearanceSelection;}-type FontFamiliesConfigKey = "fontFamilies" | "codeFontFamilies";+type FontFamiliesConfigKey = "globalFontFamilies" | "fontFamilies" | "codeFontFamilies";+type FontConfig = Pick<Config.IEditor, "fontFamilies" | "codeFontFamilies"> &+ Pick<Config.IAppearance, "globalFontFamilies">;-const getEditorFonts = (editor: Config.IEditor, configKey: FontFamiliesConfigKey): IFontItem[] =>- editor[configKey] || [];+const getFontConfig = (): FontConfig => ({+ fontFamilies: window.siyuan.config.editor.fontFamilies,+ codeFontFamilies: window.siyuan.config.editor.codeFontFamilies,+ globalFontFamilies: window.siyuan.config.appearance.globalFontFamilies,+});++const getFontConfigPath = (configKey: FontFamiliesConfigKey) =>+ `${configKey === "globalFontFamilies" ? "appearance" : "editor"}.${configKey}`;++const getConfiguredFonts = (config: FontConfig, configKey: FontFamiliesConfigKey): IFontItem[] =>+ config[configKey] || [];const getEditorFontDisplay = (fonts: IFontItem[]) =>fonts.map((font) => font.displayName || font.family).join(", ");@@ -81,7 +92,7 @@ const loadAvailableFonts = async () => {};const genFontConfigHtml = (configKey: FontFamiliesConfigKey, title: string, description: string) => {- const fonts = getEditorFonts(window.siyuan.config.editor, configKey);+ const fonts = getConfiguredFonts(getFontConfig(), configKey);return `<div class="fn__flex b3-label config-item" data-font-config-key="${configKey}"><div class="fn__flex-1 config-item__main"><div class="config-name">${title}</div>@@ -92,7 +103,7 @@ const genFontConfigHtml = (configKey: FontFamiliesConfigKey, title: string, desc<span class="fn__space"></span><inputclass="b3-select fn__flex-center fn__size200"- id="editor.${configKey}"+ id="${getFontConfigPath(configKey)}"value="${escapeAttr(getEditorFontDisplay(fonts) || window.siyuan.languages.default)}"readonly>@@ -103,6 +114,13 @@ const registerAppearanceContentGroup = (tab: SettingTabBuilder) => {const group = tab.group("content", window.siyuan.languages.configGroupContent);if (getHostCapabilities().customAppearance) {+ group.slot({+ key: "globalFontFamilies",+ keywords: [window.siyuan.languages.globalDefaultFont, window.siyuan.languages.globalDefaultFontTip],+ html: () => genFontConfigHtml("globalFontFamilies", window.siyuan.languages.globalDefaultFont,+ window.siyuan.languages.globalDefaultFontTip),+ afterMount: (root) => mountAppearanceFontFamily(root, "globalFontFamilies"),+ });group.slot({key: "fontFamilies",keywords: [window.siyuan.languages.font, window.siyuan.languages.font1],@@ -268,17 +286,17 @@ const bindSelectedFontList = (element: HTMLElement, getFonts: () => IFontItem[],});};-const mountedFontConfigUpdaters = new WeakMap<HTMLElement, (editor: Config.IEditor) => void>();+const mountedFontConfigUpdaters = new WeakMap<HTMLElement, (config: FontConfig) => void>();const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesConfigKey) => {const fontConfigElement = root.querySelector<HTMLElement>(`[data-font-config-key="${configKey}"]`);const fontFamiliesElement = fontConfigElement?.querySelector<HTMLInputElement>(- `#${CSS.escape(`editor.${configKey}`)}`);+ `#${CSS.escape(getFontConfigPath(configKey))}`);const selectedListElement = fontConfigElement?.querySelector<HTMLElement>('[data-type="selected-fonts"]');if (!fontConfigElement || !fontFamiliesElement || !selectedListElement) {return;}- let selectedFonts = getEditorFonts(window.siyuan.config.editor, configKey);+ let selectedFonts = getConfiguredFonts(getFontConfig(), configKey);let refreshOpenMenu: (() => void) | undefined;const renderSelectedFonts = () => {selectedListElement.innerHTML = genSelectedFontListHtml(selectedFonts);@@ -292,11 +310,12 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon});fontFamiliesElement.value = getEditorFontDisplay(selectedFonts) || window.siyuan.languages.default;};- const persistEditorFonts = (fonts: IFontItem[]) => {+ const persistFonts = (fonts: IFontItem[]) => {+ const globalFont = configKey === "globalFontFamilies";fetchPost(- "/api/setting/setEditor",+ globalFont ? "/api/setting/setAppearance" : "/api/setting/setEditor",{- ...window.siyuan.config.editor,+ ...(globalFont ? window.siyuan.config.appearance : window.siyuan.config.editor),[configKey]: fonts.map((font) => ({family: font.family,weight: font.weight,@@ -304,20 +323,26 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon})),},(response) => {- const data = response.data as Config.IEditor;- selectedFonts = getEditorFonts(data, configKey);- editorConfigApi.apply(data);+ if (globalFont) {+ appearanceConfigApi.apply(response.data);+ } else {+ editorConfigApi.apply(response.data);+ }+ const config = getFontConfig();+ selectedFonts = getConfiguredFonts(config, configKey);renderSelectedFonts();- refreshMountedFontConfigs(data, fontConfigElement);+ refreshMountedFontConfigs(config, fontConfigElement);refreshOpenMenu?.();});};- bindSelectedFontList(selectedListElement, () => selectedFonts, persistEditorFonts, (chip, index, event) => {- openFontWeightMenu(chip, index, event);+ bindSelectedFontList(selectedListElement, () => selectedFonts, persistFonts, (chip, index, event) => {+ if (configKey !== "globalFontFamilies") {+ openFontWeightMenu(chip, index, event);+ }});mountedFontConfigUpdaters.set(fontConfigElement, updateFontInput);- updateFontInput(window.siyuan.config.editor);+ updateFontInput(getFontConfig());fontFamiliesElement.addEventListener("click", async () => {let availableFonts: Awaited<ReturnType<typeof loadAvailableFonts>>;try {@@ -326,8 +351,10 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesConconsole.warn("load font list failed", error);return;}- const {nativeMobile, customFonts, fontItems} = availableFonts;- selectedFonts = getEditorFonts(window.siyuan.config.editor, configKey).map((selectedFont) =>+ const {nativeMobile, customFonts} = availableFonts;+ const fontItems = configKey === "globalFontFamilies" ?+ getUniqueFontFamilies(availableFonts.fontItems) : availableFonts.fontItems;+ selectedFonts = getConfiguredFonts(getFontConfig(), configKey).map((selectedFont) =>fontItems.find((font) => font.family === selectedFont.family && font.weight === selectedFont.weight) ||selectedFont);renderSelectedFonts();@@ -479,7 +506,7 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesConconst font = response.data as ICustomFont;invalidateCustomFonts();registerCustomFont(font);- persistEditorFonts([...selectedFonts.filter((item) => item.family !== font.family), font]);+ persistFonts([...selectedFonts.filter((item) => item.family !== font.family), font]);showMessage(window.siyuan.languages.imported);});});@@ -500,11 +527,14 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesConfetchPost("/api/system/removeCustomFont", {id}, (response) => {unregisterCustomFont(id);invalidateCustomFonts();+ if (response.data.appearance) {+ appearanceConfigApi.apply(response.data.appearance);+ }if (response.data.editor) {editorConfigApi.apply(response.data.editor);- updateFontInput(response.data.editor);- refreshMountedFontConfigs(response.data.editor, fontConfigElement);}+ updateFontInput(getFontConfig());+ refreshMountedFontConfigs(getFontConfig(), fontConfigElement);fontMenu.close();});},@@ -521,7 +551,7 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesConconst fonts = selected ? selectedFonts.filter((font) =>font.family !== item.family || font.weight !== item.weight) :[...selectedFonts.filter((font) => font.family !== item.family), item];- persistEditorFonts(fonts);+ persistFonts(fonts);}}});@@ -585,36 +615,36 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon}const fonts = [...selectedFonts];fonts[index] = font;- persistEditorFonts(fonts);+ persistFonts(fonts);}});});weightMenu.open({x: event.clientX, y: event.clientY, target: chipElement});}- function updateFontInput(data: Config.IEditor) {- selectedFonts = getEditorFonts(data, configKey);+ function updateFontInput(data: FontConfig) {+ selectedFonts = getConfiguredFonts(data, configKey);fontFamiliesElement.style.removeProperty("font-family");fontFamiliesElement.style.removeProperty("font-weight");renderSelectedFonts();}};-const refreshMountedFontConfigs = (editor: Config.IEditor, currentElement?: HTMLElement) => {+const refreshMountedFontConfigs = (config: FontConfig, currentElement?: HTMLElement) => {document.querySelectorAll<HTMLElement>("[data-font-config-key]").forEach((fontConfigElement) => {if (fontConfigElement === currentElement) {return;}const updateMountedFontConfig = mountedFontConfigUpdaters.get(fontConfigElement);if (updateMountedFontConfig) {- updateMountedFontConfig(editor);+ updateMountedFontConfig(config);return;}const configKey = fontConfigElement.dataset.fontConfigKey as FontFamiliesConfigKey;- const fonts = getEditorFonts(editor, configKey);+ const fonts = getConfiguredFonts(config, configKey);const selectedListElement = fontConfigElement.querySelector<HTMLElement>('[data-type="selected-fonts"]');const fontFamiliesElement = fontConfigElement.querySelector<HTMLInputElement>(- `#${CSS.escape(`editor.${configKey}`)}`);+ `#${CSS.escape(getFontConfigPath(configKey))}`);if (!selectedListElement || !fontFamiliesElement) {return;}diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex d5ca67c30c..6e54311f43 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -299,6 +299,8 @@ declare namespace Config {* SiYuan appearance related configuration*/export interface IAppearance {+ /** 全局默认字体,按优先级从高到低排列 */+ globalFontFamilies: IEditor["fontFamilies"];/*** Close button behavior* - `0`: Exit applicationdiff --git a/app/src/util/assets.ts b/app/src/util/assets.tsindex fa1bdd5215..f683f2d279 100644--- a/app/src/util/assets.ts+++ b/app/src/util/assets.ts@@ -21,7 +21,8 @@ import {import {setCodeTheme} from "../protyle/render/util";import {getBackend, getFrontend} from "./functions";import {getWorkspaceName} from "./processTitle";-import {ensureSelectedCustomFonts} from "./customFont";+import {ensureSelectedCustomFonts, getExportCustomFontStyle} from "./customFont";+import {getGlobalFontStyle} from "./globalFont";import {isCurrentThemeSupported, shouldUnloadThemeScript} from "./themeCompatibility";import {getInlineStylesCSS,@@ -293,6 +294,7 @@ export const initAssets = () => {export const setInlineStyle = async (set = true, servePath = "../../../") => {const allowCustomAppearance = getHostCapabilities().customAppearance;+ const globalFonts = allowCustomAppearance ? window.siyuan.config.appearance.globalFontFamilies || [] : [];const editorFonts = allowCustomAppearance ? window.siyuan.config.editor.fontFamilies || [] : [];const codeFonts = allowCustomAppearance ? window.siyuan.config.editor.codeFontFamilies || [] : [];let inlineStylesCSS = "";@@ -306,7 +308,7 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {}}if (set && allowCustomAppearance) {- await ensureSelectedCustomFonts([...editorFonts, ...codeFonts]);+ await ensureSelectedCustomFonts([...globalFonts, ...editorFonts, ...codeFonts]);}let style;// Emojis Reset: 字体中包含了 emoji,需重置@@ -386,6 +388,10 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {size-adjust: 92%;}`;}+ style += getGlobalFontStyle(globalFonts);+ if (!set && globalFonts.length > 0) {+ style += "\n" + await getExportCustomFontStyle([...globalFonts, ...editorFonts, ...codeFonts]);+ }const editorFontFamilies = editorFonts.map((font) => CSS.escape(font.family)).join(", ");const editorFontWeight = editorFonts[0]?.weight;const codeFontFamilies = codeFonts.map((font) => CSS.escape(font.family)).join(", ");diff --git a/app/src/util/customFont.ts b/app/src/util/customFont.tsindex 4707d4a85c..2141efbbe2 100644--- a/app/src/util/customFont.ts+++ b/app/src/util/customFont.ts@@ -107,6 +107,30 @@ export const ensureSelectedCustomFonts = async (fonts: Array<{ family: string; wawait Promise.all(fonts.map((font) => ensureSelectedCustomFont(font.family, font.weight)));};+export const getExportCustomFontStyle = async (fonts: Array<{family: string}>) => {+ const families = new Set(fonts.map((font) => font.family).filter((family) =>+ family.startsWith(CUSTOM_FONT_FAMILY_PREFIX)));+ if (window.siyuan.config.system.safeMode || families.size === 0) {+ return "";+ }+ const customFonts = (await loadCustomFonts()).filter((font) => isValidCustomFont(font) && families.has(font.family));+ const styles = await Promise.all(customFonts.map(async (font) => {+ const response = await fetch(`/custom-fonts/${font.id}`);+ if (!response.ok) {+ throw new Error(`export custom font failed: ${response.status}`);+ }+ const blob = await response.blob();+ const dataURL = await new Promise<string>((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = () => resolve(reader.result as string);+ reader.onerror = () => reject(reader.error);+ reader.readAsDataURL(blob);+ });+ return `@font-face { font-family: "${font.family}"; src: url("${dataURL}"); font-style: normal; font-weight: ${Math.max(1, Math.min(1000, font.weight || 400))}; }`;+ }));+ return styles.join("\n");+};+const setCustomFontStyle = (font: ICustomFont) => {let styleElement = document.getElementById(`customFontStyle-${font.id}`) as HTMLStyleElement;if (!styleElement) {diff --git a/app/src/util/globalFont.ts b/app/src/util/globalFont.tsnew file mode 100644index 0000000000..70042457a6--- /dev/null+++ b/app/src/util/globalFont.ts@@ -0,0 +1,4 @@+export const getGlobalFontStyle = (fonts: Array<{family: string}>) => {+ const families = fonts.map((font) => CSS.escape(font.family)).join(", ");+ return families ? `\n:root:root { --b3-font-family: var(--b3-font-family-emoji-reset), ${families}, var(--b3-font-family-default, sans-serif) }` : "";+};diff --git a/kernel/api/setting.go b/kernel/api/setting.goindex 06234af15e..ba8ebb0bd0 100644--- a/kernel/api/setting.go+++ b/kernel/api/setting.go@@ -821,6 +821,10 @@ func setAppearance(c *gin.Context) {if nil == appearance.EntryVisibility {appearance.EntryVisibility = model.Conf.Appearance.EntryVisibility}+ if _, exists := arg["globalFontFamilies"]; !exists {+ appearance.GlobalFontFamilies = model.Conf.Appearance.GlobalFontFamilies+ }+ appearance.NormalizeGlobalFontFamilies()appearance.StatusBar = util.NormalizeStatusBar(appearance.StatusBar, util.IsMobileContainer())model.Conf.Appearance = appearanceutil.StatusBarCfg = model.Conf.Appearance.StatusBardiff --git a/kernel/api/system.go b/kernel/api/system.goindex 672904d624..ba6802c030 100644--- a/kernel/api/system.go+++ b/kernel/api/system.go@@ -517,6 +517,13 @@ func exportConf(c *gin.Context) {clonedConf.Appearance.DarkThemes = nilclonedConf.Appearance.LightThemes = nilclonedConf.Appearance.Icons = nil+ fonts := make([]*conf.EditorFont, 0, len(clonedConf.Appearance.GlobalFontFamilies))+ for _, font := range clonedConf.Appearance.GlobalFontFamilies {+ if nil != font && !strings.HasPrefix(font.Family, util.CustomFontFamilyPrefix) {+ fonts = append(fonts, font)+ }+ }+ clonedConf.Appearance.GlobalFontFamilies = fonts}if nil != clonedConf.Editor {clonedConf.Editor.Emoji = []string{}@@ -1161,6 +1168,17 @@ func removeCustomFont(c *gin.Context) {}var editor *conf.Editor+ var appearance *conf.Appearance+ globalFonts := make([]*conf.EditorFont, 0, len(model.Conf.Appearance.GlobalFontFamilies))+ for _, selectedFont := range model.Conf.Appearance.GlobalFontFamilies {+ if nil != selectedFont && selectedFont.Family != font.Family {+ globalFonts = append(globalFonts, selectedFont)+ }+ }+ if len(globalFonts) != len(model.Conf.Appearance.GlobalFontFamilies) {+ model.Conf.Appearance.GlobalFontFamilies = globalFonts+ appearance = model.Conf.Appearance+ }fonts := make([]*conf.EditorFont, 0, len(model.Conf.Editor.FontFamilies))for _, selectedFont := range model.Conf.Editor.FontFamilies {if nil != selectedFont && selectedFont.Family != font.Family {@@ -1181,12 +1199,18 @@ func removeCustomFont(c *gin.Context) {model.Conf.Editor.FontWeight = 400model.Conf.Editor.FontFamilyDisplay = ""model.Conf.Editor.NormalizeFontFamilies()- model.Conf.Save()editor = model.Conf.Editor}+ if nil != editor || nil != appearance {+ model.Conf.Save()+ }+ if nil != appearance {+ util.BroadcastByType("main", "setAppearance", 0, "", appearance)+ }ret.Data = map[string]any{- "font": font,- "editor": editor,+ "font": font,+ "editor": editor,+ "appearance": appearance,}}diff --git a/kernel/conf/appearance.go b/kernel/conf/appearance.goindex a1df13d221..4d07efaeed 100644--- a/kernel/conf/appearance.go+++ b/kernel/conf/appearance.go@@ -19,6 +19,7 @@ package confimport "github.com/siyuan-note/siyuan/kernel/util"type Appearance struct {+ GlobalFontFamilies []*EditorFont `json:"globalFontFamilies"` // 按优先级排列的全局默认字体Mode int `json:"mode"` // 模式:0:明亮,1:暗黑ModeOS bool `json:"modeOS"` // 模式是否跟随系统DarkThemes []*AppearanceTheme `json:"darkThemes"` // 暗黑模式外观主题列表@@ -43,6 +44,7 @@ type Appearance struct {func NewAppearance() *Appearance {return &Appearance{+ GlobalFontFamilies: []*EditorFont{},Mode: 0,ModeOS: true,ThemeDark: "midnight",@@ -60,6 +62,11 @@ func NewAppearance() *Appearance {}}+// NormalizeGlobalFontFamilies 清理全局默认字体并保留用户指定的顺序。+func (appearance *Appearance) NormalizeGlobalFontFamilies() {+ appearance.GlobalFontFamilies = normalizeEditorFontFamilies(appearance.GlobalFontFamilies)+}+const (EntryVisibilityVersion = 4EntryVisibilityProfileSimple = "simple"diff --git a/kernel/conf/appearance_test.go b/kernel/conf/appearance_test.goindex fd91205117..c82944c646 100644--- a/kernel/conf/appearance_test.go+++ b/kernel/conf/appearance_test.go@@ -22,6 +22,46 @@ import ("testing")+func TestGlobalFontFamiliesCompatibility(t *testing.T) {+ for _, source := range []string{`{}`, `{"globalFontFamilies":null}`, `{"globalFontFamilies":[]}`} {+ appearance := NewAppearance()+ if err := json.Unmarshal([]byte(source), appearance); err != nil {+ t.Fatal(err)+ }+ appearance.NormalizeGlobalFontFamilies()+ if nil == appearance.GlobalFontFamilies || 0 != len(appearance.GlobalFontFamilies) {+ t.Fatalf("expected theme defaults for %s, got %+v", source, appearance.GlobalFontFamilies)+ }+ }+}++func TestGlobalFontFamiliesPreservesPriority(t *testing.T) {+ appearance := NewAppearance()+ appearance.GlobalFontFamilies = []*EditorFont{+ nil,+ {Family: ""},+ {Family: "Example Sans", Weight: 0, DisplayName: "Example"},+ {Family: "Fallback Sans", Weight: 400},+ {Family: "Example Sans", Weight: 700},+ }+ appearance.NormalizeGlobalFontFamilies()+ if len(appearance.GlobalFontFamilies) != 2 || appearance.GlobalFontFamilies[0].Family != "Example Sans" ||+ appearance.GlobalFontFamilies[1].Family != "Fallback Sans" || appearance.GlobalFontFamilies[0].Weight != 400 {+ t.Fatalf("unexpected normalized fonts: %+v", appearance.GlobalFontFamilies)+ }+ data, err := json.Marshal(appearance)+ if err != nil {+ t.Fatal(err)+ }+ loaded := &Appearance{}+ if err = json.Unmarshal(data, loaded); err != nil {+ t.Fatal(err)+ }+ if len(loaded.GlobalFontFamilies) != 2 || loaded.GlobalFontFamilies[0].DisplayName != "Example" {+ t.Fatalf("font preferences did not survive round trip: %+v", loaded.GlobalFontFamilies)+ }+}+func TestNormalizeEntryVisibilityDefaults(t *testing.T) {entryVisibility := NormalizeEntryVisibility(nil, EntryVisibilityProfileSimple)if entryVisibility.Version != EntryVisibilityVersion || entryVisibility.Active != EntryVisibilityProfileSimple {diff --git a/kernel/model/conf.go b/kernel/model/conf.goindex b950c68fe0..c08af145e3 100644--- a/kernel/model/conf.go+++ b/kernel/model/conf.go@@ -469,6 +469,7 @@ func InitConf() {}Conf.Editor.AssetOpen = conf.NormalizeAssetOpen(Conf.Editor.AssetOpen)Conf.Editor.NormalizeFontFamilies()+ Conf.Appearance.NormalizeGlobalFontFamilies()Conf.Editor.Emoji = util.FilterRecentIconValues(Conf.Editor.Emoji)if 9 > Conf.Editor.FontSize || 72 < Conf.Editor.FontSize {Conf.Editor.FontSize = 16