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 automatic RTL/LTR text direction https://github.com/siyuan-note/siyuan/issues/19915
Daniel0f1d5adf4005
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 6810d01822..ddb7f50bb8 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,6 @@{+ "autoDirection": "اتجاه النص التلقائي",+ "autoDirectionTip": "تحديد اتجاه الفقرات والعناوين تلقائيًا حسب أول حرف ذي اتجاه قوي، مع إعطاء الأولوية للاتجاه المحدد يدويًا","cardFullRowTip": "يشغل الحقل الأساسي صفًا كاملًا دائمًا؛ أوقف عرض أسماء الحقول لترتيب الحقول الأخرى بشكل مضغوط","searchFileOrSnapshot": "ابحث باسم الملف أو معرّف اللقطة","calendarWeekLabel": "أ",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 8461732a67..9d61182461 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,6 @@{+ "autoDirection": "Automatische Textrichtung",+ "autoDirectionTip": "Richtung von Absätzen und Überschriften anhand des ersten Zeichens mit starker Schreibrichtung automatisch bestimmen; manuelle Einstellungen haben Vorrang","cardFullRowTip": "Das Primärfeld belegt immer eine ganze Zeile; blende die Feldnamen aus, um andere Felder kompakt anzuordnen","searchFileOrSnapshot": "Dateiname oder Snapshot-ID suchen","calendarWeekLabel": "KW",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex b2e21367da..4280e80b51 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,6 @@{+ "autoDirection": "Automatic text direction",+ "autoDirectionTip": "Detect paragraph and heading direction from the first strong directional character; manual direction takes priority","cardFullRowTip": "The primary field always occupies a full row; hide field names to arrange other fields compactly","searchFileOrSnapshot": "Search file name or snapshot ID","calendarWeekLabel": "W",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 6bc0be4894..6fb1e1b353 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,6 @@{+ "autoDirection": "Dirección automática del texto",+ "autoDirectionTip": "Detectar la dirección de párrafos y encabezados a partir del primer carácter direccional fuerte; la dirección manual tiene prioridad","cardFullRowTip": "El campo principal siempre ocupa una fila completa; oculta los nombres de los campos para distribuir los demás de forma compacta","searchFileOrSnapshot": "Buscar nombre de archivo o ID de instantánea","calendarWeekLabel": "S",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex f5d01cb8ed..813a076d3f 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,6 @@{+ "autoDirection": "Direction automatique du texte",+ "autoDirectionTip": "Détecter la direction des paragraphes et des titres à partir du premier caractère directionnel fort ; la direction manuelle est prioritaire","cardFullRowTip": "Le champ principal occupe toujours une ligne entière ; masquez les noms des champs pour disposer les autres de façon compacte","searchFileOrSnapshot": "Rechercher un nom de fichier ou un ID d’instantané","calendarWeekLabel": "S",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 25279d8778..cdd55bb352 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,6 @@{+ "autoDirection": "כיוון טקסט אוטומטי",+ "autoDirectionTip": "זיהוי כיוון הפסקאות והכותרות לפי התו הראשון בעל כיווניות חזקה; כיוון שהוגדר ידנית מקבל עדיפות","cardFullRowTip": "השדה הראשי תמיד תופס שורה שלמה; יש להסתיר את שמות השדות כדי לסדר את שאר השדות בצפיפות","searchFileOrSnapshot": "חיפוש שם קובץ או מזהה תמונת מצב","calendarWeekLabel": "ש",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex ba7ed71b86..915e9f58d8 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,6 @@{+ "autoDirection": "स्वचालित पाठ दिशा",+ "autoDirectionTip": "पहले प्रबल दिशात्मक वर्ण से अनुच्छेद और शीर्षक की दिशा पहचानें; मैन्युअल दिशा को प्राथमिकता दी जाती है","cardFullRowTip": "मुख्य फ़ील्ड हमेशा पूरी पंक्ति घेरता है; अन्य फ़ील्ड को सघन रूप से व्यवस्थित करने के लिए फ़ील्ड के नाम छिपाएँ","searchFileOrSnapshot": "फ़ाइल नाम या स्नैपशॉट ID खोजें","calendarWeekLabel": "स.",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex a277c93bd1..f0ad8b6088 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,6 @@{+ "autoDirection": "Arah teks otomatis",+ "autoDirectionTip": "Deteksi arah paragraf dan judul dari karakter pertama dengan arah kuat; arah yang diatur secara manual diutamakan","cardFullRowTip": "Kolom utama selalu menempati satu baris penuh; sembunyikan nama kolom untuk menata kolom lain secara ringkas","searchFileOrSnapshot": "Cari nama berkas atau ID snapshot","calendarWeekLabel": "M",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex f1a4e77edd..b7b5d07588 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,6 @@{+ "autoDirection": "Direzione automatica del testo",+ "autoDirectionTip": "Rileva la direzione di paragrafi e titoli dal primo carattere direzionale forte; la direzione manuale ha la priorità","cardFullRowTip": "Il campo principale occupa sempre un'intera riga; nascondi i nomi dei campi per disporre gli altri in modo compatto","searchFileOrSnapshot": "Cerca nome file o ID snapshot","calendarWeekLabel": "S",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex e0b78bfb93..edd0e74fd8 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,6 @@{+ "autoDirection": "テキスト方向の自動判定",+ "autoDirectionTip": "最初の強い方向性を持つ文字に基づいて段落と見出しの方向を自動判定し、手動で指定した方向を優先します","cardFullRowTip": "主キーフィールドは常に行全体を占有します。他のフィールドをコンパクトに配置するには、フィールド名の表示をオフにしてください","searchFileOrSnapshot": "ファイル名またはスナップショット ID を検索","calendarWeekLabel": "週",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 27928752f4..1ff73ebaf0 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,6 @@{+ "autoDirection": "자동 텍스트 방향",+ "autoDirectionTip": "첫 번째 강한 방향성 문자를 기준으로 문단과 제목의 방향을 감지하며, 수동으로 지정한 방향을 우선 적용","cardFullRowTip": "기본 필드는 항상 한 행 전체를 차지합니다. 다른 필드를 조밀하게 배치하려면 필드 이름을 숨기세요","searchFileOrSnapshot": "파일 이름 또는 스냅샷 ID 검색","calendarWeekLabel": "주",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex d333284918..43d90ff888 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,6 @@{+ "autoDirection": "Automatische tekstrichting",+ "autoDirectionTip": "Bepaal de richting van alinea’s en koppen op basis van het eerste teken met een sterke schrijfrichting; handmatige instellingen hebben voorrang","cardFullRowTip": "Het primaire veld neemt altijd een volledige rij in beslag; verberg veldnamen om andere velden compact te rangschikken","searchFileOrSnapshot": "Bestandsnaam of snapshot-ID zoeken","calendarWeekLabel": "W",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex a6deadcfea..05f6f8f404 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,6 @@{+ "autoDirection": "Automatyczny kierunek tekstu",+ "autoDirectionTip": "Wykrywaj kierunek akapitów i nagłówków na podstawie pierwszego znaku o silnej kierunkowości; kierunek ustawiony ręcznie ma pierwszeństwo","cardFullRowTip": "Pole główne zawsze zajmuje cały wiersz; ukryj nazwy pól, aby rozmieścić pozostałe pola w sposób zwarty","searchFileOrSnapshot": "Szukaj nazwy pliku lub ID migawki","calendarWeekLabel": "T",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex dadf8d6fbc..e0104e86e5 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,6 @@{+ "autoDirection": "Direção automática do texto",+ "autoDirectionTip": "Detectar a direção de parágrafos e títulos pelo primeiro caractere direcional forte; a direção manual tem prioridade","cardFullRowTip": "O campo principal sempre ocupa uma linha inteira; oculte os nomes dos campos para organizar os demais de forma compacta","searchFileOrSnapshot": "Pesquisar nome de arquivo ou ID do instantâneo","calendarWeekLabel": "S",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 389e4f7c16..645cba00cb 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,6 @@{+ "autoDirection": "Автоматическое направление текста",+ "autoDirectionTip": "Определять направление абзацев и заголовков по первому символу с сильной направленностью; ручная настройка имеет приоритет","cardFullRowTip": "Основное поле всегда занимает всю строку; скройте названия полей, чтобы расположить остальные поля компактно","searchFileOrSnapshot": "Поиск по имени файла или ID снимка","calendarWeekLabel": "Н",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex 17c797500b..fc1570638a 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,6 @@{+ "autoDirection": "Automatický smer textu",+ "autoDirectionTip": "Určiť smer odsekov a nadpisov podľa prvého znaku so silnou smerovosťou; ručné nastavenie má prednosť","cardFullRowTip": "Primárne pole vždy zaberá celý riadok; skryte názvy polí, aby sa ostatné polia usporiadali kompaktne","searchFileOrSnapshot": "Hľadať názov súboru alebo ID snímky","calendarWeekLabel": "T",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex 06b765f57d..078296695b 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,4 +1,6 @@{+ "autoDirection": "Аутоматски смер текста",+ "autoDirectionTip": "Одреди смер пасуса и наслова према првом знаку са јаком усмереношћу; ручно подешен смер има предност","cardFullRowTip": "Примарно поље увек заузима цео ред; сакријте називе поља да бисте остала поља распоредили компактно","searchFileOrSnapshot": "Претражи назив датотеке или ID снимка","calendarWeekLabel": "Н",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 56bc28a66d..3279f45735 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,6 @@{+ "autoDirection": "ทิศทางข้อความอัตโนมัติ",+ "autoDirectionTip": "ตรวจจับทิศทางของย่อหน้าและหัวเรื่องจากอักขระตัวแรกที่มีทิศทางชัดเจน โดยให้ความสำคัญกับทิศทางที่กำหนดด้วยตนเอง","cardFullRowTip": "ฟิลด์หลักจะใช้พื้นที่เต็มแถวเสมอ ซ่อนชื่อฟิลด์เพื่อจัดเรียงฟิลด์อื่นให้กระชับ","searchFileOrSnapshot": "ค้นหาชื่อไฟล์หรือ ID สแนปช็อต","calendarWeekLabel": "สัป.",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 682b36580f..7651e3858a 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,6 @@{+ "autoDirection": "Otomatik metin yönü",+ "autoDirectionTip": "Paragraf ve başlık yönünü güçlü yönlülüğe sahip ilk karakterden algıla; elle ayarlanan yön önceliklidir","cardFullRowTip": "Birincil alan her zaman tam bir satır kaplar; diğer alanları sıkışık yerleştirmek için alan adlarını gizleyin","searchFileOrSnapshot": "Dosya adı veya anlık görüntü kimliği ara","calendarWeekLabel": "H",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 94ce646da0..8ea7acf29f 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,6 @@{+ "autoDirection": "Автоматичний напрямок тексту",+ "autoDirectionTip": "Визначати напрямок абзаців і заголовків за першим символом із сильною спрямованістю; ручне налаштування має пріоритет","cardFullRowTip": "Основне поле завжди займає весь рядок; приховайте назви полів, щоб розташувати інші поля компактно","searchFileOrSnapshot": "Пошук за назвою файлу або ID знімка","calendarWeekLabel": "Т",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex b138b46c20..2d6b0f4ce5 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,6 @@{+ "autoDirection": "自动文本方向",+ "autoDirectionTip": "根据首个具有强方向性的字符自动判定段落和标题的方向,手动设置的方向优先","cardFullRowTip": "主键字段始终独占整行;关闭「显示字段名称」后,其他字段才能紧凑排列","searchFileOrSnapshot": "搜索文件名或快照 ID","calendarWeekLabel": "周",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 9b826fa1be..4c19617728 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,6 @@{+ "autoDirection": "自動文字方向",+ "autoDirectionTip": "根據首個具有強方向性的字元自動判定段落和標題的方向,手動設定的方向優先","cardFullRowTip": "主鍵欄位始終獨佔整列;關閉「顯示欄位名稱」後,其他欄位才能緊湊排列","searchFileOrSnapshot": "搜尋檔案名稱或快照 ID","calendarWeekLabel": "週",diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.syindex cdbe335b58..516c9c9587 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy@@ -8,7 +8,7 @@"title": "Formatting elements","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20260923221935"+ "updated": "20260928090424"},"Children": [{@@ -5336,6 +5336,62 @@"Data": " for the syntax."}]+ },+ {+ "ID": "20260928090424-08cios0",+ "Type": "NodeHeading",+ "HeadingLevel": 2,+ "Properties": {+ "id": "20260928090424-08cios0",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "Automatic text direction"+ }+ ]+ },+ {+ "ID": "20260928090424-voiqqta",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260928090424-voiqqta",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "On desktop and mobile, enable "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Settings"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Appearance"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Automatic text direction"+ },+ {+ "Type": "NodeText",+ "Data": " below Right to Left (RTL). This option is off by default. Paragraphs and headings use their first strong directional character to choose RTL or LTR; numbers, punctuation, and emoji at the beginning do not decide the direction. Manual block and inline directions take priority. List marker positions and table column order keep their existing settings. Preview and HTML/PDF export also use automatic text direction."+ }+ ]}]}diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.syindex c17a08f479..f1cdc11413 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20260923221935"+ "updated": "20260928090424"},"Children": [{@@ -5338,6 +5338,62 @@"Data": "。"}]+ },+ {+ "ID": "20260928090424-99e4469",+ "Type": "NodeHeading",+ "HeadingLevel": 2,+ "Properties": {+ "id": "20260928090424-99e4469",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "自动文本方向"+ }+ ]+ },+ {+ "ID": "20260928090424-i3j9suz",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260928090424-i3j9suz",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "桌面端和移动端均可在 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "设置"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "外观"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "自动文本方向"+ },+ {+ "Type": "NodeText",+ "Data": " 中启用该功能,开关位于「从右到左(RTL)」下方,默认关闭。段落和标题根据首个具有强方向性的字符自动选择从右到左或从左到右,开头的数字、标点和表情不决定方向。手动设置的块级和行内方向优先。列表标记位置和表格列顺序保持原有设置。预览及 HTML、PDF 导出也会应用自动文本方向。"+ }+ ]}]}diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.syindex 95b7496285..e1b7475d7a 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20260923221935"+ "updated": "20260928090424"},"Children": [{@@ -5314,6 +5314,62 @@"id": "20211226122008-jaxlknv","updated": "20211226002103"}+ },+ {+ "ID": "20260928090424-g7ra222",+ "Type": "NodeHeading",+ "HeadingLevel": 2,+ "Properties": {+ "id": "20260928090424-g7ra222",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "自動文字方向"+ }+ ]+ },+ {+ "ID": "20260928090424-testof8",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260928090424-testof8",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "桌面端和行動端均可在 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "設定"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "外觀"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "自動文字方向"+ },+ {+ "Type": "NodeText",+ "Data": " 中啟用此功能,開關位於「從右到左(RTL)」下方,預設關閉。段落和標題根據首個具有強方向性的字元自動選擇從右到左或從左到右,開頭的數字、標點和表情不決定方向。手動設定的區塊層級和行內方向優先。清單標記位置和表格欄位順序維持原有設定。預覽及 HTML、PDF 匯出也會套用自動文字方向。"+ }+ ]}]}diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.syindex b431194c83..4a3f828ac6 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy@@ -9,7 +9,7 @@"title": "書式要素","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20260923221935"+ "updated": "20260928090424"},"Children": [{@@ -5574,6 +5574,62 @@"ID": "20240530101000-54uew8g","id": "20240530101000-qa9slig"}+ },+ {+ "ID": "20260928090424-7oo5lua",+ "Type": "NodeHeading",+ "HeadingLevel": 2,+ "Properties": {+ "id": "20260928090424-7oo5lua",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "テキスト方向の自動判定"+ }+ ]+ },+ {+ "ID": "20260928090424-8to4vwd",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260928090424-8to4vwd",+ "updated": "20260928090424"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "デスクトップ版とモバイル版では、"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "設定"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "外観"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "テキスト方向の自動判定"+ },+ {+ "Type": "NodeText",+ "Data": " で有効にできます。スイッチは「右から左へ(RTL)」の下にあり、初期状態では無効です。段落と見出しの最初の強い方向性を持つ文字に基づいて、右から左または左から右を自動判定します。先頭の数字、句読点、絵文字は方向を決定しません。手動で指定したブロック単位とインラインの方向が優先されます。リスト記号の位置と表の列順序は従来の設定を維持します。プレビューおよび HTML・PDF エクスポートにも自動判定が適用されます。"+ }+ ]}]}diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.tsindex ecb4f35fad..d3fe131eb7 100644--- a/app/src/config/tabs/appearanceTab.ts+++ b/app/src/config/tabs/appearanceTab.ts@@ -166,6 +166,11 @@ const registerAppearanceContentGroup = (tab: SettingTabBuilder) => {desc: window.siyuan.languages.rtlTip,save: (value) => editorConfigApi.patch("editor.rtl", value),});+ group.switch("editor.autoDirection", {+ title: window.siyuan.languages.autoDirection,+ desc: window.siyuan.languages.autoDirectionTip,+ save: (value) => editorConfigApi.patch("editor.autoDirection", value),+ });};const genFontListItemHtml = (item: IFontItem, checked: boolean) => {diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.tsindex a9dc782852..2987cd7ceb 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -665,6 +665,7 @@ ${getIconScript(servePath)}Object.keys(data.attrs).forEach(key => {wysElement.setAttribute(key, data.attrs[key]);})+ Protyle.setAutoDirection(previewElement, ${!!window.siyuan.config.editor.autoDirection});await Protyle.renderExportJSEmbeds(wysElement, {disabled: ${window.siyuan.config.system.safeMode || getHostCapabilities().remoteKernel},disabledTip: decodeURIComponent(${JSON.stringify(encodeURIComponent(window.siyuan.languages.safeModeJSTip))}),@@ -1171,6 +1172,7 @@ ${getIconScript(servePath)}};const previewElement = document.getElementById('preview');Protyle.highlightRender(previewElement, "stage/protyle");+ Protyle.setAutoDirection(previewElement, ${!!window.siyuan.config.editor.autoDirection});Protyle.mathRender(previewElement, "stage/protyle", ${exportOption.type === "pdf"});Protyle.mermaidRender(previewElement, "stage/protyle");Protyle.flowchartRender(previewElement, "stage/protyle");diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex 78c1aa20cf..204e624332 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -15,6 +15,7 @@ import {genUUID} from "../util/genID";import {WYSIWYG} from "./wysiwyg";import {Toolbar} from "./toolbar";import {Gutter} from "./gutter";+import {setAutoDirection} from "./render/autoDirection";import {Breadcrumb} from "./breadcrumb";import {onTransaction,@@ -209,6 +210,7 @@ export class Protyle {// lite 模式用前端操作日志 undo(不依赖 kernel),其余走 kernel 的 GlobalUndoLog。this.protyle.undo = this.protyle.lite ? new LocalUndo() : new Undo();this.protyle.wysiwyg = new WYSIWYG(this.protyle);+ setAutoDirection(this.protyle.wysiwyg.element, window.siyuan.config.editor.autoDirection);initEditorTabs(this.protyle);initListMindmaps(this.protyle);if (isProtyleCustomBlockRenderEnabled(this.protyle)) {diff --git a/app/src/protyle/method.ts b/app/src/protyle/method.tsindex c9d8cf6bcc..ca38d3e4b0 100644--- a/app/src/protyle/method.ts+++ b/app/src/protyle/method.ts@@ -1,4 +1,5 @@import {tabsRender} from "./render/tabsRender";+import {setAutoDirection} from "./render/autoDirection";import {renderExportJSEmbeds} from "./export/jsEmbed";import { graphvizRender } from "./render/graphvizRender";import { highlightRender } from "./render/highlightRender";@@ -13,6 +14,7 @@ import { plantumlRender } from "./render/plantumlRender";import "../assets/scss/export.scss";class Protyle {+ public static setAutoDirection = setAutoDirection;public static renderExportJSEmbeds = renderExportJSEmbeds;public static tabsRender = tabsRender;/** 对 graphviz 进行渲染 */diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.tsindex 901d221288..b657b57238 100644--- a/app/src/protyle/preview/index.ts+++ b/app/src/protyle/preview/index.ts@@ -29,6 +29,7 @@ import {hasTopClosestByAttribute} from "../util/hasClosest";import {addScriptSync} from "../util/addScript";import {prepareWechatCopy, prepareZhihuCopy} from "./platformCopy";import {getHostCapabilities} from "../../util/hostCapabilities";+import {destroyAutoDirection, setAutoDirection} from "../render/autoDirection";export class Preview {public element: HTMLElement;@@ -227,6 +228,7 @@ export class Preview {}public destroy() {+ destroyAutoDirection(this.previewElement);destroyTabsRender(this.previewElement);window.clearTimeout(this.mdTimeoutId);/// #if !BROWSER@@ -275,6 +277,7 @@ export class Preview {?.classList.add("protyle-preview__title");/// #endifprocessRender(protyle.preview.previewElement);+ setAutoDirection(protyle.preview.previewElement, window.siyuan.config.editor.autoDirection);tabsRender(protyle.preview.previewElement, {label: window.siyuan.languages.tabItem,shown: item => processRender(item)});highlightRender(protyle.preview.previewElement);diff --git a/app/src/protyle/render/autoDirection.ts b/app/src/protyle/render/autoDirection.tsnew file mode 100644index 0000000000..8dcfcc58e2--- /dev/null+++ b/app/src/protyle/render/autoDirection.ts@@ -0,0 +1,108 @@+const textSelector = '[data-type="NodeParagraph"] > div[contenteditable]:not(.protyle-attr), ' ++ '[data-type="NodeHeading"] > div[contenteditable]:not(.protyle-attr), p, h1, h2, h3, h4, h5, h6';+const excludedSelector = 'pre, code, .render-node, [data-type="NodeCodeBlock"], ' ++ '[data-type="NodeMathBlock"], [data-type="NodeHTMLBlock"], [data-type="NodeAttributeView"], protyle-html';+const disposers = new WeakMap<HTMLElement, () => void>();+const directionAttribute = "data-auto-direction";++const clearDirection = (element: HTMLElement) => {+ if (element.dir === element.getAttribute(directionAttribute)) {+ element.removeAttribute("dir");+ }+ element.removeAttribute(directionAttribute);+};++export const destroyAutoDirection = (root: HTMLElement) => {+ disposers.get(root)?.();+ disposers.delete(root);+};++/** 自动方向只作用于正文,不改变容器布局或持久化手动方向。 */+export const setAutoDirection = (root: HTMLElement, enabled: boolean) => {+ destroyAutoDirection(root);+ const managed = new Set<HTMLElement>();+ const getExplicitDirection = (element: HTMLElement) => {+ for (let current = element; current; current = current.parentElement) {+ if (current.style.direction) {+ return getComputedStyle(current).direction;+ }+ if (current.dir !== current.getAttribute(directionAttribute) &&+ (current.dir === "ltr" || current.dir === "rtl")) {+ return current.dir;+ }+ if (current === root) {+ break;+ }+ }+ return "auto";+ };+ const update = (scope: HTMLElement) => {+ if (!enabled) {+ scope.querySelectorAll<HTMLElement>(`[${directionAttribute}]`).forEach(clearDirection);+ clearDirection(scope);+ return;+ }+ const elements = Array.from(scope.querySelectorAll<HTMLElement>(textSelector));+ if (scope.matches(textSelector)) {+ elements.push(scope);+ }+ elements.forEach(element => {+ if (!root.contains(element)) {+ return;+ }+ if (element.closest(excludedSelector)) {+ clearDirection(element);+ managed.delete(element);+ } else if (!element.dir || element.dir === "auto" ||+ element.dir === element.getAttribute(directionAttribute)) {+ managed.add(element);+ const direction = getExplicitDirection(element);+ if (element.getAttribute(directionAttribute) !== direction) {+ element.setAttribute(directionAttribute, direction);+ }+ if (element.dir !== direction) {+ element.dir = direction;+ }+ } else {+ element.removeAttribute(directionAttribute);+ managed.delete(element);+ }+ });+ };+ update(root);+ // 浏览器负责随正文变化重新判定方向,只监听结构和手动样式变化。+ const observer = new MutationObserver(records => {+ const scopes = new Set<HTMLElement>();+ records.forEach(record => {+ if (record.type === "attributes") {+ scopes.add(record.target as HTMLElement);+ } else {+ record.addedNodes.forEach(node => {+ if (node.nodeType === 1) {+ scopes.add(node as HTMLElement);+ }+ });+ record.removedNodes.forEach(node => {+ if (node.nodeType !== 1 || root.contains(node)) {+ return;+ }+ const element = node as HTMLElement;+ clearDirection(element);+ managed.delete(element);+ element.querySelectorAll<HTMLElement>(`[${directionAttribute}]`).forEach(child => {+ clearDirection(child);+ managed.delete(child);+ });+ });+ }+ });+ scopes.forEach(update);+ });+ observer.observe(root, {subtree: true, childList: true, ...(enabled ? {+ attributes: true, attributeFilter: ["style", "dir", "contenteditable", "data-type"],+ } : {})});+ disposers.set(root, () => {+ observer.disconnect();+ managed.forEach(clearDirection);+ });+};diff --git a/app/src/protyle/util/destroy.ts b/app/src/protyle/util/destroy.tsindex b6276de105..926c0ceaf0 100644--- a/app/src/protyle/util/destroy.ts+++ b/app/src/protyle/util/destroy.ts@@ -12,6 +12,7 @@ import {destroyTrackedRanges} from "./trackedRange";import {areProtylePluginExtensionsEnabled} from "../runtimeCapabilities";import {invalidateFocusFoldRequests} from "./focusFold";import {unregisterViewFoldContext} from "./viewFold";+import {destroyAutoDirection} from "../render/autoDirection";export const destroy = (protyle: IProtyle) => {if (!protyle) {@@ -39,6 +40,7 @@ export const destroy = (protyle: IProtyle) => {protyle.element.classList.remove("protyle");protyle.element.removeAttribute("style");if (protyle.wysiwyg) {+ destroyAutoDirection(protyle.wysiwyg.element);unregisterCustomBlockRoot(protyle.wysiwyg.element);destroyTabsRender(protyle.wysiwyg.element);protyle.wysiwyg.destroy();diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.tsindex dbdcaf033d..611c5d9e89 100644--- a/app/src/protyle/util/reload.ts+++ b/app/src/protyle/util/reload.ts@@ -12,12 +12,14 @@ import {restoreLuteMarkdownSyntax} from "./paste";import {invalidateTrackedRanges} from "./trackedRange";import {updateBacklinkReferenceVisibility} from "../wysiwyg/backlinkReference";import {shouldReloadProtyle} from "./reloadState";+import {setAutoDirection} from "../render/autoDirection";export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?: boolean) => {if (!shouldReloadProtyle(protyle)) {return;}updateBacklinkReferenceVisibility(protyle);+ setAutoDirection(protyle.wysiwyg.element, window.siyuan.config.editor.autoDirection);protyle.wysiwyg.element.setAttribute("spellcheck", window.siyuan.config.editor.spellcheck.toString());invalidateTrackedRanges(protyle);/// #if MOBILEdiff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.tsindex 67e9e5124b..eb6924f5a6 100644--- a/app/src/types/api/index.d.ts+++ b/app/src/types/api/index.d.ts@@ -1764,7 +1764,7 @@ export type SetCriterionRequestInput = { "criterion": CriterionInput | null; };export type SetDatabaseBlockViewRequestInput = { "avID": string; "id": string; "viewID": string; };-export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };+export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };export type SetEntryVisibilityRequestInput = { "active"?: string | null; "profiles"?: Array<SettingEntryVisibilityProfileInput | null> | null; "version"?: number | null; };@@ -1890,7 +1890,7 @@ export type SettingEditing = { "maxCompletionTokens": number; "maxHistoryMessageexport type SettingEditingInput = { "maxCompletionTokens"?: number | null; "maxHistoryMessages"?: number | null; "modelId"?: string | null; "temperature"?: number | null; };-export type SettingEditor = { "allowHTMLBLockScript": boolean; "allowSVGScript": boolean; "assetOpen": SettingAssetOpen | null; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockRefDynamicAnchorTextMaxLen": number; "checkBlockRef": boolean | null; "codeFontFamilies": Array<SettingEditorFont | null> | null; "codeLigatures": boolean; "codeLineWrap": boolean; "codeSyntaxHighlightLineNum": boolean; "codeTabSpaces": number; "cursorSurroundingLines": number; "databaseAttrClickMode": number; "databaseAttrHideEmpty": boolean; "databaseAttrShow": boolean | null; "databaseAttrUseTabs": boolean | null; "databaseAttrViewMode": number; "displayBookmarkIcon": boolean; "displayNetImgMark": boolean; "dragHTMLFileToIframe": boolean; "dynamicLoadBlocks": number; "embedBlockBreadcrumb": boolean; "emoji": Array<string> | null; "floatWindowDelay": number | null; "floatWindowMode": number; "fontFamilies": Array<SettingEditorFont | null> | null; "fontFamily": string; "fontFamilyDisplay": string; "fontSize": number; "fontSizeScrollZoom": boolean; "fontWeight": number; "fullWidth": boolean; "generateHistoryInterval": number; "hashTagSearch": boolean | null; "headingEmbedMode": number; "headingNumber": boolean; "headingNumberFormat": string; "historyRetentionDays": number; "justify": boolean; "katexMacros": string; "keepLoadedContent": boolean; "listItemDotNumberClickFocus": boolean; "listLogicalOutdent": boolean; "markdown": SettingMarkdown | null; "onlySearchForDoc": boolean; "pasteURLAutoConvert": boolean; "plantUMLServePath": string; "readOnly": boolean; "rtl": boolean; "spellcheck": boolean; "spellcheckLanguages": Array<string> | null; "virtualBlockRef": boolean; "virtualBlockRefExclude": string; "virtualBlockRefInclude": string; };+export type SettingEditor = { "allowHTMLBLockScript": boolean; "allowSVGScript": boolean; "assetOpen": SettingAssetOpen | null; "autoDirection": boolean; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockRefDynamicAnchorTextMaxLen": number; "checkBlockRef": boolean | null; "codeFontFamilies": Array<SettingEditorFont | null> | null; "codeLigatures": boolean; "codeLineWrap": boolean; "codeSyntaxHighlightLineNum": boolean; "codeTabSpaces": number; "cursorSurroundingLines": number; "databaseAttrClickMode": number; "databaseAttrHideEmpty": boolean; "databaseAttrShow": boolean | null; "databaseAttrUseTabs": boolean | null; "databaseAttrViewMode": number; "displayBookmarkIcon": boolean; "displayNetImgMark": boolean; "dragHTMLFileToIframe": boolean; "dynamicLoadBlocks": number; "embedBlockBreadcrumb": boolean; "emoji": Array<string> | null; "floatWindowDelay": number | null; "floatWindowMode": number; "fontFamilies": Array<SettingEditorFont | null> | null; "fontFamily": string; "fontFamilyDisplay": string; "fontSize": number; "fontSizeScrollZoom": boolean; "fontWeight": number; "fullWidth": boolean; "generateHistoryInterval": number; "hashTagSearch": boolean | null; "headingEmbedMode": number; "headingNumber": boolean; "headingNumberFormat": string; "historyRetentionDays": number; "justify": boolean; "katexMacros": string; "keepLoadedContent": boolean; "listItemDotNumberClickFocus": boolean; "listLogicalOutdent": boolean; "markdown": SettingMarkdown | null; "onlySearchForDoc": boolean; "pasteURLAutoConvert": boolean; "plantUMLServePath": string; "readOnly": boolean; "rtl": boolean; "spellcheck": boolean; "spellcheckLanguages": Array<string> | null; "virtualBlockRef": boolean; "virtualBlockRefExclude": string; "virtualBlockRefInclude": string; };export type SettingEditorFont = { "displayName": string; "family": string; "weight": number; };diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex 58496d4d00..3c80f65871 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -761,6 +761,8 @@ declare namespace Config {* Whether to enable RTL (left-to-right chirography) mode*/rtl: boolean;+ /** 默认关闭;自动判定段落和标题的文本方向,手动方向优先,不改变列表和表格布局 */+ autoDirection: boolean;/*** Whether to enable spell checking*/diff --git a/app/tests/autoDirection.test.js b/app/tests/autoDirection.test.jsnew file mode 100644index 0000000000..4b42239aec--- /dev/null+++ b/app/tests/autoDirection.test.js@@ -0,0 +1,175 @@+const assert = require("node:assert/strict");+const {readFileSync, mkdtempSync, rmSync} = require("node:fs");+const path = require("node:path");+const os = require("node:os");++const runCases = async () => {+ const assert = require("node:assert/strict");+ const settle = () => new Promise(resolve => setTimeout(resolve, 0));+ const lute = window.Lute.New();+ lute.SetProtyleWYSIWYG(true);+ const container = document.createElement("div");+ container.className = "protyle rtl";+ const root = document.createElement("div");+ root.className = "protyle-wysiwyg";+ container.append(root);+ document.body.append(container);+ root.innerHTML = lute.Md2BlockDOM("# عنوان English\n\nسلام world\n\nEnglish سلام\n\n- שלום world\n\n```\nسلام\n```\n");+ const original = root.innerHTML;+ const markdown = lute.BlockDOM2StdMd(original);+ const {destroyAutoDirection, setAutoDirection} = window.direction;+ const text = element => element.querySelector("[contenteditable]");+ const heading = text(root.querySelector('[data-type="NodeHeading"]'));+ const paragraphs = root.querySelectorAll('[data-type="NodeParagraph"]');+ const persian = text(paragraphs[0]);+ const english = text(paragraphs[1]);+ const hebrew = text(paragraphs[2]);+ const direction = element => getComputedStyle(element).direction;+ setAutoDirection(root, false);+ assert.equal(root.innerHTML, original);+ assert.equal(direction(english), "rtl");+ setAutoDirection(root, true);+ assert.equal(direction(heading), "rtl");+ assert.equal(direction(persian), "rtl");+ assert.equal(direction(english), "ltr");+ assert.equal(direction(hebrew), "rtl");+ assert.equal(root.querySelector('[data-type="NodeCodeBlock"] [dir]'), null);+ assert.equal(root.querySelector(".protyle-attr[dir]"), null);+ assert.equal(root.querySelector('[data-type="NodeListItem"]').hasAttribute("dir"), false);+ assert.equal(lute.BlockDOM2StdMd(root.innerHTML), markdown, "automatic direction must not change stored content");+ assert.doesNotMatch(lute.SpinBlockDOM(root.innerHTML), /data-auto-direction|dir="auto"/);++ const range = document.createRange();+ range.setStart(persian.firstChild, 2);+ range.collapse(true);+ getSelection().removeAllRanges();+ getSelection().addRange(range);+ persian.dispatchEvent(new CompositionEvent("compositionstart", {bubbles: true}));+ persian.firstChild.data = "English سلام";+ assert.equal(direction(persian), "ltr");+ assert.equal(getSelection().anchorNode, persian.firstChild);+ persian.firstChild.data = "123 😀 (سلام world)";+ assert.equal(direction(persian), "rtl");+ persian.dispatchEvent(new CompositionEvent("compositionend", {bubbles: true}));+ persian.textContent = "https://example.com سلام";+ assert.equal(direction(persian), "ltr");+ persian.textContent = "";+ assert.equal(persian.dir, "auto");+ persian.innerHTML = '<span data-type="text" style="direction: rtl; unicode-bidi: isolate">שלום</span>English';+ assert.equal(direction(persian.querySelector("span")), "rtl");++ english.parentElement.style.direction = "rtl";+ await settle();+ assert.equal(english.dir, "rtl");+ assert.equal(direction(english), "rtl");+ assert.doesNotMatch(lute.SpinBlockDOM(root.innerHTML), /data-auto-direction|dir="rtl"/);+ english.parentElement.style.direction = "ltr";+ await settle();+ assert.equal(direction(english), "ltr");+ english.parentElement.style.direction = "";+ await settle();+ assert.equal(english.dir, "auto");+ const list = hebrew.closest('[data-type="NodeList"]');+ list.style.direction = "ltr";+ await settle();+ assert.equal(hebrew.dir, "ltr");+ assert.equal(direction(hebrew), "ltr");+ list.style.direction = "";+ await settle();+ assert.equal(direction(hebrew), "rtl");++ root.innerHTML = original;+ await settle();+ assert.equal(direction(text(root.querySelectorAll('[data-type="NodeParagraph"]')[1])), "ltr");+ const appended = document.createElement("div");+ appended.innerHTML = lute.Md2BlockDOM("مرحبا English\n");+ root.append(appended);+ await settle();+ assert.equal(direction(text(appended)), "rtl");+ const cached = appended.innerHTML;+ appended.remove();+ await settle();+ assert.equal(appended.querySelector("[data-auto-direction]"), null);+ setAutoDirection(root, false);+ assert.equal(root.querySelector("[dir=auto]"), null);+ root.insertAdjacentHTML("beforeend", cached);+ await settle();+ assert.equal(root.querySelector("[data-auto-direction]"), null);+ root.append(appended);+ appended.innerHTML = lute.Md2BlockDOM("English\n");+ await settle();+ assert.equal(appended.querySelector("[dir]"), null);++ // 预览及标准 HTML 导出与编辑器共用规则,显式对齐和方向保持不变。+ root.innerHTML = '<h2>שלום</h2><p>سلام English</p><p style="text-align:center">English سلام</p>' ++ '<blockquote style="direction:ltr"><p>سلام</p></blockquote>' ++ "<pre><code>سلام</code></pre><table><tbody><tr><td><p>שלום</p></td><td>English</td></tr></tbody></table>";+ setAutoDirection(root, true);+ assert.equal(direction(root.querySelector("h2")), "rtl");+ assert.equal(direction(root.querySelector("p")), "rtl");+ assert.equal(getComputedStyle(root.querySelector('[style="text-align:center"]')).textAlign, "center");+ assert.equal(direction(root.querySelector("blockquote p")), "ltr");+ assert.equal(root.querySelector("pre [dir]"), null);+ assert.equal(root.querySelector("table").hasAttribute("dir"), false);+ assert.equal(direction(root.querySelector("td p")), "rtl");+ destroyAutoDirection(root);+ assert.equal(root.querySelector("[data-auto-direction]"), null);+};++const runElectron = async () => {+ const {app, BrowserWindow} = require("electron");+ app.setPath("userData", process.argv[2]);+ app.commandLine.appendSwitch("disable-gpu");+ await app.whenReady();+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false}});+ let exitCode = 0;+ try {+ const ts = require("typescript");+ const source = readFileSync(path.join(__dirname, "../src/protyle/render/autoDirection.ts"), "utf8");+ const compiled = ts.transpileModule(source, {+ compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020},+ }).outputText;+ await win.loadURL("data:text/html,<html><body></body></html>");+ await win.webContents.insertCSS(require("sass").compile(+ path.join(__dirname, "../src/assets/scss/protyle/_content.scss")).css);+ await win.webContents.executeJavaScript(readFileSync(path.join(__dirname, "../stage/protyle/js/lute/lute.min.js"), "utf8"));+ await win.webContents.executeJavaScript(`(() => {+ const exports = {};+ ${compiled}+ window.direction = exports;+ })()`);+ await win.webContents.executeJavaScript(`(${runCases.toString()})()`);+ console.log("Automatic direction cases passed");+ } catch (error) {+ console.error(error);+ exitCode = 1;+ } finally {+ win.destroy();+ app.exit(exitCode);+ }+};++if (process.versions.electron && process.type === "browser") {+ runElectron().catch(error => {+ console.error(error);+ require("electron").app.exit(1);+ });+} else {+ require("node:test").it("detects text direction while preserving manual settings, content and structural layout", {+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,+ timeout: 45000,+ }, async () => {+ const env = {...process.env};+ delete env.ELECTRON_RUN_AS_NODE;+ const profile = mkdtempSync(path.join(os.tmpdir(), "siyuan-auto-direction-"));+ try {+ const {stdout} = await require("node:util").promisify(require("node:child_process").execFile)(+ require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 40000});+ assert.match(stdout, /Automatic direction cases passed/);+ } finally {+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));+ assert.ok(path.basename(profile).startsWith("siyuan-auto-direction-"));+ rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});+ }+ });+}diff --git a/kernel/api/contract_auto_direction_test.go b/kernel/api/contract_auto_direction_test.gonew file mode 100644index 0000000000..14026623c3--- /dev/null+++ b/kernel/api/contract_auto_direction_test.go@@ -0,0 +1,41 @@+package api++import (+ "encoding/json"+ "strings"+ "testing"++ "github.com/siyuan-note/siyuan/kernel/apicontract"+ "github.com/siyuan-note/siyuan/kernel/conf"+)++func TestAPIContractSettingAutoDirection(t *testing.T) {+ compareSettingConfig(t, apicontract.SetEditor, conf.NewEditor, []string{+ `{}`, `{"autoDirection":true}`, `{"autoDirection":false}`, `{"autoDirection":null}`,+ `{"autoDirection":"true"}`, `{"autoDirection":1}`, `{"rtl":true,"autoDirection":true}`,+ })+ for _, enabled := range []bool{false, true} {+ editor := conf.NewEditor()+ if editor.AutoDirection {+ t.Fatal("automatic direction must default to disabled")+ }+ editor.AutoDirection = enabled+ editor.RTL = true+ encoded, err := json.Marshal(editor)+ if err != nil {+ t.Fatal(err)+ }+ restored := conf.NewEditor()+ if err = json.Unmarshal(encoded, restored); err != nil {+ t.Fatal(err)+ }+ payload := settingEditorPayload(restored)+ if payload.AutoDirection != enabled || !payload.RTL {+ t.Fatalf("direction preferences were not preserved: %+v", payload)+ }+ request, err := apicontract.SetEditor.Decode(strings.NewReader(string(encoded)))+ if err != nil || request.ConfigError() != nil || request.AutoDirection != enabled {+ t.Fatalf("direction input changed: %+v, %v", request, err)+ }+ }+}diff --git a/kernel/api/setting_contract.go b/kernel/api/setting_contract.goindex 332d8dd351..863e731f06 100644--- a/kernel/api/setting_contract.go+++ b/kernel/api/setting_contract.go@@ -374,6 +374,7 @@ func settingEditorPayload(value *conf.Editor) *apicontract.SettingEditor {result.DynamicLoadBlocks = value.DynamicLoadBlocksresult.Justify = value.Justifyresult.RTL = value.RTL+ result.AutoDirection = value.AutoDirectionresult.Spellcheck = value.Spellcheckresult.SpellcheckLanguages = value.SpellcheckLanguagesresult.HashTagSearch = value.HashTagSearchdiff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.jsonindex 2b708e3212..0af80d8a09 100644--- a/kernel/apicontract/schema.json+++ b/kernel/apicontract/schema.json@@ -38062,6 +38062,16 @@}]},+ "autoDirection": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ]+ },"backlinkBlockSort": {"anyOf": [{@@ -41639,6 +41649,9 @@}]},+ "autoDirection": {+ "type": "boolean"+ },"backlinkBlockSort": {"type": "integer"},@@ -41934,6 +41947,7 @@"allowHTMLBLockScript","allowSVGScript","assetOpen",+ "autoDirection","backlinkBlockSort","backlinkContainChildren","backlinkExpandCount",diff --git a/kernel/apicontract/setting.go b/kernel/apicontract/setting.goindex cf528266c4..0344bbbca9 100644--- a/kernel/apicontract/setting.go+++ b/kernel/apicontract/setting.go@@ -218,26 +218,28 @@ type SettingEditor struct {DynamicLoadBlocks int `json:"dynamicLoadBlocks" api:"optional,nullable"`Justify bool `json:"justify" api:"optional,nullable"`RTL bool `json:"rtl" api:"optional,nullable"`- Spellcheck bool `json:"spellcheck" api:"optional,nullable"`- SpellcheckLanguages []string `json:"spellcheckLanguages" api:"optional,nullable"`- HashTagSearch *bool `json:"hashTagSearch" api:"optional,nullable"`- OnlySearchForDoc bool `json:"onlySearchForDoc" api:"optional,nullable"`- BacklinkExpandCount int `json:"backlinkExpandCount" api:"optional,nullable"`- BackmentionExpandCount int `json:"backmentionExpandCount" api:"optional,nullable"`- BacklinkMentionExclude string `json:"backlinkMentionExclude" api:"optional,nullable"`- BacklinkContainChildren bool `json:"backlinkContainChildren" api:"optional,nullable"`- BacklinkHideReference bool `json:"backlinkHideReference" api:"optional,nullable"`- BacklinkShowBottom bool `json:"backlinkShowBottom" api:"optional,nullable"`- BacklinkSort *int `json:"backlinkSort" api:"optional,nullable"`- BacklinkGlobalSort int `json:"backlinkGlobalSort" api:"optional,nullable"`- BacklinkBlockSort int `json:"backlinkBlockSort" api:"optional,nullable"`- BackmentionSort *int `json:"backmentionSort" api:"optional,nullable"`- HeadingNumber bool `json:"headingNumber" api:"optional,nullable"`- HeadingNumberFormat string `json:"headingNumberFormat" api:"optional,nullable"`- HeadingEmbedMode int `json:"headingEmbedMode" api:"optional,nullable"`- PasteURLAutoConvert bool `json:"pasteURLAutoConvert" api:"optional,nullable"`- DragHTMLFileToIframe bool `json:"dragHTMLFileToIframe" api:"optional,nullable"`- Markdown *SettingMarkdown `json:"markdown" api:"optional,nullable"`+ // AutoDirection 默认关闭;启用后段落和标题按首个强方向字符排版,手动方向优先,不改变列表和表格布局。+ AutoDirection bool `json:"autoDirection" api:"optional,nullable"`+ Spellcheck bool `json:"spellcheck" api:"optional,nullable"`+ SpellcheckLanguages []string `json:"spellcheckLanguages" api:"optional,nullable"`+ HashTagSearch *bool `json:"hashTagSearch" api:"optional,nullable"`+ OnlySearchForDoc bool `json:"onlySearchForDoc" api:"optional,nullable"`+ BacklinkExpandCount int `json:"backlinkExpandCount" api:"optional,nullable"`+ BackmentionExpandCount int `json:"backmentionExpandCount" api:"optional,nullable"`+ BacklinkMentionExclude string `json:"backlinkMentionExclude" api:"optional,nullable"`+ BacklinkContainChildren bool `json:"backlinkContainChildren" api:"optional,nullable"`+ BacklinkHideReference bool `json:"backlinkHideReference" api:"optional,nullable"`+ BacklinkShowBottom bool `json:"backlinkShowBottom" api:"optional,nullable"`+ BacklinkSort *int `json:"backlinkSort" api:"optional,nullable"`+ BacklinkGlobalSort int `json:"backlinkGlobalSort" api:"optional,nullable"`+ BacklinkBlockSort int `json:"backlinkBlockSort" api:"optional,nullable"`+ BackmentionSort *int `json:"backmentionSort" api:"optional,nullable"`+ HeadingNumber bool `json:"headingNumber" api:"optional,nullable"`+ HeadingNumberFormat string `json:"headingNumberFormat" api:"optional,nullable"`+ HeadingEmbedMode int `json:"headingEmbedMode" api:"optional,nullable"`+ PasteURLAutoConvert bool `json:"pasteURLAutoConvert" api:"optional,nullable"`+ DragHTMLFileToIframe bool `json:"dragHTMLFileToIframe" api:"optional,nullable"`+ Markdown *SettingMarkdown `json:"markdown" api:"optional,nullable"`}type SettingEditorFont struct {diff --git a/kernel/conf/editor.go b/kernel/conf/editor.goindex 7121197ce7..6ee4e7ff35 100644--- a/kernel/conf/editor.go+++ b/kernel/conf/editor.go@@ -87,6 +87,7 @@ type Editor struct {DynamicLoadBlocks int `json:"dynamicLoadBlocks"` // 块动态数,下限 48Justify bool `json:"justify"` // 是否两端对齐RTL bool `json:"rtl"` // 是否从右到左显示+ AutoDirection bool `json:"autoDirection"` // 是否自动判定段落和标题的文本方向Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查SpellcheckLanguages []string `json:"spellcheckLanguages"` // 拼写检查语言HashTagSearch *bool `json:"hashTagSearch"` // 输入 # 时是否进行标签搜索