Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Enable rich text editing in table cells by default https://github.com/siyuan-note/siyuan/issues/19188

Danielef7da835a3aa
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 4076437fa1..b8cbab4de5 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "جارٍ التحقق من الاتصال...",
"remoteKernelVersionMismatch": "يجب أن يتطابق إصدار النواة البعيدة مع إصدار العميل",
"remoteKernelConnectionFailed": "تعذر الاتصال؛ تحقق من العنوان والشبكة وشهادة TLS",
- "tableCellRichEnable": "تحويل إلى نص منسق",
- "tableCellRichEdit": "تحرير النص المنسق",
- "tableCellRichDisable": "تحويل إلى محتوى ضمن السطر",
"tableCellRichInvalid": "تنسيق النص المنسق للخلية غير مدعوم أو تالف؛ تم الاحتفاظ بالمحتوى الأصلي",
"templateSearch": "البحث عن القوالب بالاسم أو المسار",
"templateContextSearch": "البحث عن مستندات السياق",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 391c36f159..edb20fa5eb 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Verbindung wird geprüft...",
"remoteKernelVersionMismatch": "Die Version des entfernten Kernels muss mit der Client-Version übereinstimmen",
"remoteKernelConnectionFailed": "Verbindung fehlgeschlagen; Adresse, Netzwerk und TLS-Zertifikat prüfen",
- "tableCellRichEnable": "In Rich Text umwandeln",
- "tableCellRichEdit": "Rich Text bearbeiten",
- "tableCellRichDisable": "In Inline-Inhalt umwandeln",
"tableCellRichInvalid": "Nicht unterstütztes oder beschädigtes Rich-Text-Format der Zelle; Originalinhalt beibehalten",
"templateSearch": "Vorlagen nach Name oder Pfad suchen",
"templateContextSearch": "Kontextdokumente suchen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 686a383ac1..c36eb96d11 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Checking connection...",
"remoteKernelVersionMismatch": "The remote kernel version must match the client",
"remoteKernelConnectionFailed": "Unable to connect; check the address, network, and TLS certificate",
- "tableCellRichEnable": "Convert to rich text",
- "tableCellRichEdit": "Edit rich text",
- "tableCellRichDisable": "Convert to inline content",
"tableCellRichInvalid": "Unsupported or damaged cell rich text; original content preserved",
"templateSearch": "Search templates by name or path",
"templateContextSearch": "Search context documents",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index bb9647a289..e1888d927c 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Comprobando conexión...",
"remoteKernelVersionMismatch": "La versión del núcleo remoto debe coincidir con la del cliente",
"remoteKernelConnectionFailed": "No se puede conectar; comprueba la dirección, la red y el certificado TLS",
- "tableCellRichEnable": "Convertir a texto enriquecido",
- "tableCellRichEdit": "Editar texto enriquecido",
- "tableCellRichDisable": "Convertir a contenido en línea",
"tableCellRichInvalid": "Formato de texto enriquecido de celda no compatible o dañado; se conserva el contenido original",
"templateSearch": "Buscar plantillas por nombre o ruta",
"templateContextSearch": "Buscar documentos de contexto",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 7116de4f93..fbc81c528a 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Vérification de la connexion...",
"remoteKernelVersionMismatch": "La version du noyau distant doit correspondre à celle du client",
"remoteKernelConnectionFailed": "Connexion impossible ; vérifiez l’adresse, le réseau et le certificat TLS",
- "tableCellRichEnable": "Convertir en texte enrichi",
- "tableCellRichEdit": "Modifier le texte enrichi",
- "tableCellRichDisable": "Convertir en contenu en ligne",
"tableCellRichInvalid": "Format de texte enrichi de cellule non pris en charge ou endommagé ; contenu original conservé",
"templateSearch": "Rechercher des modèles par nom ou chemin",
"templateContextSearch": "Rechercher des documents de contexte",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index fb48def24d..a1a48a7c49 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "בודק חיבור...",
"remoteKernelVersionMismatch": "גרסת הליבה המרוחקת חייבת להתאים לגרסת הלקוח",
"remoteKernelConnectionFailed": "לא ניתן להתחבר; יש לבדוק את הכתובת, הרשת ותעודת TLS",
- "tableCellRichEnable": "המרה לטקסט עשיר",
- "tableCellRichEdit": "עריכת טקסט עשיר",
- "tableCellRichDisable": "המרה לתוכן בתוך השורה",
"tableCellRichInvalid": "פורמט הטקסט העשיר בתא אינו נתמך או פגום; התוכן המקורי נשמר",
"templateSearch": "חיפוש תבניות לפי שם או נתיב",
"templateContextSearch": "חיפוש מסמכי הקשר",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 194e64b9c0..ed7c287a3f 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "कनेक्शन जाँचा जा रहा है...",
"remoteKernelVersionMismatch": "दूरस्थ कर्नेल का संस्करण क्लाइंट से मेल खाना चाहिए",
"remoteKernelConnectionFailed": "कनेक्ट नहीं हो सका; पता, नेटवर्क और TLS प्रमाणपत्र जाँचें",
- "tableCellRichEnable": "रिच टेक्स्ट में बदलें",
- "tableCellRichEdit": "रिच टेक्स्ट संपादित करें",
- "tableCellRichDisable": "इनलाइन सामग्री में बदलें",
"tableCellRichInvalid": "सेल के रिच टेक्स्ट का प्रारूप असमर्थित या क्षतिग्रस्त है; मूल सामग्री सुरक्षित रखी गई है",
"templateSearch": "नाम या पथ से टेम्पलेट खोजें",
"templateContextSearch": "संदर्भ दस्तावेज़ खोजें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index dbf519455a..aad2832232 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Memeriksa koneksi...",
"remoteKernelVersionMismatch": "Versi kernel jarak jauh harus sama dengan klien",
"remoteKernelConnectionFailed": "Tidak dapat terhubung; periksa alamat, jaringan, dan sertifikat TLS",
- "tableCellRichEnable": "Ubah menjadi teks kaya",
- "tableCellRichEdit": "Edit teks kaya",
- "tableCellRichDisable": "Ubah menjadi konten sebaris",
"tableCellRichInvalid": "Format teks kaya sel tidak didukung atau rusak; konten asli dipertahankan",
"templateSearch": "Cari templat berdasarkan nama atau jalur",
"templateContextSearch": "Cari dokumen konteks",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 371e8ce9ca..f037b64682 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Verifica della connessione...",
"remoteKernelVersionMismatch": "La versione del kernel remoto deve corrispondere a quella del client",
"remoteKernelConnectionFailed": "Connessione impossibile; controlla indirizzo, rete e certificato TLS",
- "tableCellRichEnable": "Converti in testo formattato",
- "tableCellRichEdit": "Modifica testo formattato",
- "tableCellRichDisable": "Converti in contenuto in linea",
"tableCellRichInvalid": "Formato del testo della cella non supportato o danneggiato; contenuto originale conservato",
"templateSearch": "Cerca modelli per nome o percorso",
"templateContextSearch": "Cerca documenti di contesto",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 9c71aad5f8..dfd9922576 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "接続を確認中...",
"remoteKernelVersionMismatch": "リモートカーネルとクライアントのバージョンを一致させてください",
"remoteKernelConnectionFailed": "接続できません。アドレス、ネットワーク、TLS 証明書を確認してください",
- "tableCellRichEnable": "リッチテキストに変換",
- "tableCellRichEdit": "リッチテキストを編集",
- "tableCellRichDisable": "インラインコンテンツに変換",
"tableCellRichInvalid": "セルのリッチテキスト形式が未対応または破損しています。元の内容は保持されています",
"templateSearch": "テンプレート名またはパスを検索",
"templateContextSearch": "コンテキスト用ドキュメントを検索",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index c800be2e05..f190904909 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "연결 확인 중...",
"remoteKernelVersionMismatch": "원격 커널과 클라이언트의 버전이 일치해야 합니다",
"remoteKernelConnectionFailed": "연결할 수 없습니다. 주소, 네트워크 및 TLS 인증서를 확인하세요",
- "tableCellRichEnable": "서식 있는 텍스트로 변환",
- "tableCellRichEdit": "서식 있는 텍스트 편집",
- "tableCellRichDisable": "인라인 콘텐츠로 변환",
"tableCellRichInvalid": "셀의 서식 있는 텍스트 형식이 지원되지 않거나 손상되었습니다. 원본 콘텐츠는 보존됩니다",
"templateSearch": "템플릿 이름 또는 경로 검색",
"templateContextSearch": "컨텍스트 문서 검색",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index db3f81ae01..191acb3b43 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Verbinding controleren...",
"remoteKernelVersionMismatch": "De versie van de externe kernel moet overeenkomen met die van de client",
"remoteKernelConnectionFailed": "Verbinding mislukt; controleer het adres, het netwerk en het TLS-certificaat",
- "tableCellRichEnable": "Omzetten naar opgemaakte tekst",
- "tableCellRichEdit": "Opgemaakte tekst bewerken",
- "tableCellRichDisable": "Omzetten naar inline-inhoud",
"tableCellRichInvalid": "Niet-ondersteunde of beschadigde tekstopmaak in de cel; oorspronkelijke inhoud behouden",
"templateSearch": "Sjablonen zoeken op naam of pad",
"templateContextSearch": "Contextdocumenten zoeken",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index c360526279..b772ddf6f9 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Sprawdzanie połączenia...",
"remoteKernelVersionMismatch": "Wersja zdalnego jądra musi odpowiadać wersji klienta",
"remoteKernelConnectionFailed": "Nie można połączyć; sprawdź adres, sieć i certyfikat TLS",
- "tableCellRichEnable": "Konwertuj na tekst sformatowany",
- "tableCellRichEdit": "Edytuj tekst sformatowany",
- "tableCellRichDisable": "Konwertuj na treść w wierszu",
"tableCellRichInvalid": "Nieobsługiwany lub uszkodzony format tekstu komórki; oryginalna treść została zachowana",
"templateSearch": "Szukaj szablonów według nazwy lub ścieżki",
"templateContextSearch": "Szukaj dokumentów kontekstowych",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 7861a29e1e..02141ca5d3 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Verificando conexão...",
"remoteKernelVersionMismatch": "A versão do kernel remoto deve corresponder à do cliente",
"remoteKernelConnectionFailed": "Não foi possível conectar; verifique o endereço, a rede e o certificado TLS",
- "tableCellRichEnable": "Converter em texto formatado",
- "tableCellRichEdit": "Editar texto formatado",
- "tableCellRichDisable": "Converter em conteúdo em linha",
"tableCellRichInvalid": "Formato de texto da célula não suportado ou danificado; conteúdo original preservado",
"templateSearch": "Pesquisar modelos por nome ou caminho",
"templateContextSearch": "Pesquisar documentos de contexto",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index f1148968d7..a050f59282 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Проверка подключения...",
"remoteKernelVersionMismatch": "Версия удалённого ядра должна совпадать с версией клиента",
"remoteKernelConnectionFailed": "Не удалось подключиться; проверьте адрес, сеть и сертификат TLS",
- "tableCellRichEnable": "Преобразовать в форматированный текст",
- "tableCellRichEdit": "Редактировать форматированный текст",
- "tableCellRichDisable": "Преобразовать в строчное содержимое",
"tableCellRichInvalid": "Формат текста ячейки не поддерживается или повреждён; исходное содержимое сохранено",
"templateSearch": "Поиск шаблонов по имени или пути",
"templateContextSearch": "Поиск документов контекста",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index ea57eb3580..7897de5169 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Kontroluje sa pripojenie...",
"remoteKernelVersionMismatch": "Verzia vzdialeného jadra sa musí zhodovať s verziou klienta",
"remoteKernelConnectionFailed": "Nedá sa pripojiť; skontrolujte adresu, sieť a certifikát TLS",
- "tableCellRichEnable": "Previesť na formátovaný text",
- "tableCellRichEdit": "Upraviť formátovaný text",
- "tableCellRichDisable": "Previesť na obsah v riadku",
"tableCellRichInvalid": "Nepodporovaný alebo poškodený formát textu bunky; pôvodný obsah bol zachovaný",
"templateSearch": "Hľadať šablóny podľa názvu alebo cesty",
"templateContextSearch": "Hľadať kontextové dokumenty",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 7db0cf122c..809f422392 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "กำลังตรวจสอบการเชื่อมต่อ...",
"remoteKernelVersionMismatch": "เวอร์ชันเคอร์เนลระยะไกลต้องตรงกับไคลเอนต์",
"remoteKernelConnectionFailed": "เชื่อมต่อไม่ได้ โปรดตรวจสอบที่อยู่ เครือข่าย และใบรับรอง TLS",
- "tableCellRichEnable": "แปลงเป็นข้อความแบบมีรูปแบบ",
- "tableCellRichEdit": "แก้ไขข้อความแบบมีรูปแบบ",
- "tableCellRichDisable": "แปลงเป็นเนื้อหาในบรรทัด",
"tableCellRichInvalid": "ไม่รองรับรูปแบบข้อความของเซลล์หรือข้อมูลเสียหาย โดยยังคงเก็บเนื้อหาต้นฉบับไว้",
"templateSearch": "ค้นหาเทมเพลตตามชื่อหรือเส้นทาง",
"templateContextSearch": "ค้นหาเอกสารบริบท",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 7ca982e1fd..3456d97bbd 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Bağlantı denetleniyor...",
"remoteKernelVersionMismatch": "Uzak çekirdek sürümü istemci sürümüyle eşleşmelidir",
"remoteKernelConnectionFailed": "Bağlanılamadı; adresi, ağı ve TLS sertifikasını denetleyin",
- "tableCellRichEnable": "Zengin metne dönüştür",
- "tableCellRichEdit": "Zengin metni düzenle",
- "tableCellRichDisable": "Satır içi içeriğe dönüştür",
"tableCellRichInvalid": "Hücrenin zengin metin biçimi desteklenmiyor veya bozuk; özgün içerik korundu",
"templateSearch": "Şablonları ada veya yola göre ara",
"templateContextSearch": "Bağlam belgelerini ara",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 85e72a00d8..7ba73aba87 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "Перевірка підключення...",
"remoteKernelVersionMismatch": "Версія віддаленого ядра має збігатися з версією клієнта",
"remoteKernelConnectionFailed": "Не вдалося підключитися; перевірте адресу, мережу та сертифікат TLS",
- "tableCellRichEnable": "Перетворити на форматований текст",
- "tableCellRichEdit": "Редагувати форматований текст",
- "tableCellRichDisable": "Перетворити на вміст у рядку",
"tableCellRichInvalid": "Формат тексту комірки не підтримується або пошкоджений; початковий вміст збережено",
"templateSearch": "Пошук шаблонів за назвою або шляхом",
"templateContextSearch": "Пошук документів контексту",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 39396c793a..f84df6142a 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "正在检查连接...",
"remoteKernelVersionMismatch": "远程内核版本必须与客户端一致",
"remoteKernelConnectionFailed": "无法连接,请检查地址、网络和 TLS 证书",
- "tableCellRichEnable": "转换为富文本",
- "tableCellRichEdit": "编辑富文本",
- "tableCellRichDisable": "转换为行级内容",
"tableCellRichInvalid": "单元格富文本格式不受支持或已损坏,原始内容已保留",
"templateSearch": "搜索模板名称或路径",
"templateContextSearch": "搜索上下文文档",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index feb452229f..d4b24b576e 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -9,9 +9,6 @@
"checkingRemoteKernel": "正在檢查連線...",
"remoteKernelVersionMismatch": "遠端核心版本必須與用戶端一致",
"remoteKernelConnectionFailed": "無法連線,請檢查網址、網路和 TLS 憑證",
- "tableCellRichEnable": "轉換為富文字",
- "tableCellRichEdit": "編輯富文字",
- "tableCellRichDisable": "轉換為行內內容",
"tableCellRichInvalid": "儲存格富文字格式不受支援或已損壞,原始內容已保留",
"templateSearch": "搜尋範本名稱或路徑",
"templateContextSearch": "搜尋上下文文件",
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.sy
index f7bc8f3d22..79621a6858 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
@@ -2567,16 +2567,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Right-click a cell and choose "
- },
- {
- "Type": "NodeTextMark",
- "TextMarkType": "kbd",
- "TextMarkTextContent": "Convert to rich text"
- },
- {
- "Type": "NodeText",
- "Data": " to edit paragraphs, headings, lists, blockquotes, code, and math directly inside it. Existing cells require explicit conversion; Markdown-looking text keeps its literal meaning."
+ "Data": "Table cells support paragraphs, headings, lists, blockquotes, code, and math without manual conversion. Existing Markdown-looking text stays literal, and existing bold text, links, and other inline formatting are preserved."
}
]
},
@@ -2590,7 +2581,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Click a rich text cell, or place the caret in it and press "
+ "Data": "Click a cell, or place the caret in it and press "
},
{
"Type": "NodeTextMark",
@@ -2599,7 +2590,7 @@
},
{
"Type": "NodeText",
- "Data": " to edit. While editing, "
+ "Data": " to edit. Ordinary content keeps table navigation: "
},
{
"Type": "NodeTextMark",
@@ -2608,7 +2599,7 @@
},
{
"Type": "NodeText",
- "Data": " creates a paragraph or list item inside the fragment; "
+ "Data": " moves to the next row, "
},
{
"Type": "NodeTextMark",
@@ -2617,16 +2608,16 @@
},
{
"Type": "NodeText",
- "Data": " and "
+ "Data": " switches cells, and "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Tab"
+ "TextMarkTextContent": "Shift+Enter"
},
{
"Type": "NodeText",
- "Data": " control indentation. Close any suggestion first, then press "
+ "Data": " inserts a line break within the cell. Lists and code blocks use their own line-break and indentation behavior. Close suggestions, then press "
},
{
"Type": "NodeTextMark",
@@ -2635,7 +2626,7 @@
},
{
"Type": "NodeText",
- "Data": " or click outside to finish. Changes are saved automatically, and table navigation resumes."
+ "Data": " or click outside the cell to finish editing and save automatically."
}
]
},
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
index 22d954ccd2..efe45bc06a 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
@@ -12981,7 +12981,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Edit a rich text cell"
+ "Data": "Edit a table cell"
}
]
},
@@ -13005,7 +13005,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Finish rich text cell editing (close suggestions first)"
+ "Data": "Finish table cell editing (close suggestions first)"
}
]
},
@@ -13029,7 +13029,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Rich text cell editing: new paragraph or list item"
+ "Data": "Ordinary cell content: next row; lists or code: new item or line"
}
]
},
@@ -13053,7 +13053,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Rich text cell editing: indent or outdent"
+ "Data": "Ordinary cell content: switch cells; lists or code: indent or outdent"
}
]
},
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.sy
index ae4a4911da..42cfd677e2 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
@@ -2559,16 +2559,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "右击单元格,选择 "
- },
- {
- "Type": "NodeTextMark",
- "TextMarkType": "kbd",
- "TextMarkTextContent": "转换为富文本"
- },
- {
- "Type": "NodeText",
- "Data": " 后可直接在单元格内编辑段落、标题、列表、引述、代码和公式。原有单元格需手动转换,内容中的 Markdown 标记保持原样。"
+ "Data": "单元格默认支持编辑段落、标题、列表、引述、代码和公式,无需手动转换。已有文字中的 Markdown 标记保持原样,原有加粗、链接等格式也会保留。"
}
]
},
@@ -2582,7 +2573,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "点击富文本单元格,或将光标移入后按 "
+ "Data": "点击单元格,或将光标移入后按 "
},
{
"Type": "NodeTextMark",
@@ -2591,7 +2582,7 @@
},
{
"Type": "NodeText",
- "Data": " 开始编辑。编辑时 "
+ "Data": " 开始编辑。普通内容保持表格导航:"
},
{
"Type": "NodeTextMark",
@@ -2600,7 +2591,7 @@
},
{
"Type": "NodeText",
- "Data": " 创建片段内的新段落或列表项,"
+ "Data": " 移到下一行,"
},
{
"Type": "NodeTextMark",
@@ -2609,16 +2600,16 @@
},
{
"Type": "NodeText",
- "Data": " 和 "
+ "Data": " 切换单元格,"
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Tab"
+ "TextMarkTextContent": "Shift+Enter"
},
{
"Type": "NodeText",
- "Data": " 用于缩进。关闭提示后按 "
+ "Data": " 在单元格内换行。列表和代码块内使用对应的换行和缩进操作。关闭提示后按 "
},
{
"Type": "NodeTextMark",
@@ -2627,7 +2618,7 @@
},
{
"Type": "NodeText",
- "Data": " 或点击单元格外结束编辑,内容自动保存,随后恢复表格导航。"
+ "Data": " 或点击单元格外结束编辑,内容自动保存。"
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
index 5bd4285df5..74caaefc78 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
@@ -12967,7 +12967,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "编辑富文本单元格"
+ "Data": "编辑单元格"
}
]
},
@@ -12991,7 +12991,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "结束单元格富文本编辑(先关闭提示)"
+ "Data": "结束单元格编辑(先关闭提示)"
}
]
},
@@ -13015,7 +13015,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "单元格富文本编辑:新段落或列表项"
+ "Data": "单元格普通内容:下一行;列表或代码:新列表项或换行"
}
]
},
@@ -13039,7 +13039,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "单元格富文本编辑:缩进或取消缩进"
+ "Data": "单元格普通内容:切换单元格;列表或代码:缩进或取消缩进"
}
]
},
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.sy
index 97a944a2e9..25d7115bb6 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
@@ -2557,16 +2557,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "以滑鼠右鍵點選儲存格,選擇 "
- },
- {
- "Type": "NodeTextMark",
- "TextMarkType": "kbd",
- "TextMarkTextContent": "轉換為富文字"
- },
- {
- "Type": "NodeText",
- "Data": " 後即可直接在儲存格內編輯段落、標題、清單、引述、程式碼和公式。既有儲存格需手動轉換,內容中的 Markdown 標記保持原樣。"
+ "Data": "儲存格預設支援編輯段落、標題、列表、引述、程式碼和公式,無需手動轉換。既有文字中的 Markdown 標記保持原樣,原有粗體、連結等格式也會保留。"
}
]
},
@@ -2580,7 +2571,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "點選富文字儲存格,或將游標移入後按 "
+ "Data": "點擊儲存格,或將游標移入後按 "
},
{
"Type": "NodeTextMark",
@@ -2589,7 +2580,7 @@
},
{
"Type": "NodeText",
- "Data": " 開始編輯。編輯時 "
+ "Data": " 開始編輯。一般內容維持表格導覽:"
},
{
"Type": "NodeTextMark",
@@ -2598,7 +2589,7 @@
},
{
"Type": "NodeText",
- "Data": " 建立片段內的新段落或清單項目,"
+ "Data": " 移到下一列,"
},
{
"Type": "NodeTextMark",
@@ -2607,16 +2598,16 @@
},
{
"Type": "NodeText",
- "Data": " 和 "
+ "Data": " 切換儲存格,"
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Tab"
+ "TextMarkTextContent": "Shift+Enter"
},
{
"Type": "NodeText",
- "Data": " 用於縮排。關閉提示後按 "
+ "Data": " 在儲存格內換行。列表和程式碼區塊內使用對應的換行與縮排操作。關閉提示後按 "
},
{
"Type": "NodeTextMark",
@@ -2625,7 +2616,7 @@
},
{
"Type": "NodeText",
- "Data": " 或點選儲存格外結束編輯,內容自動儲存,隨後恢復表格導覽。"
+ "Data": " 或點擊儲存格外結束編輯,內容自動儲存。"
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
index b2fac08976..9402f3d8c0 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
@@ -12973,7 +12973,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "編輯富文字儲存格"
+ "Data": "編輯儲存格"
}
]
},
@@ -12997,7 +12997,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "結束儲存格富文字編輯(先關閉提示)"
+ "Data": "結束儲存格編輯(先關閉提示)"
}
]
},
@@ -13021,7 +13021,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "儲存格富文字編輯:新段落或清單項目"
+ "Data": "儲存格一般內容:下一列;列表或程式碼:新項目或換行"
}
]
},
@@ -13045,7 +13045,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "儲存格富文字編輯:縮排或取消縮排"
+ "Data": "儲存格一般內容:切換儲存格;列表或程式碼:縮排或取消縮排"
}
]
},
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 596a841ed7..270967c6e0 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -8,7 +8,6 @@ import {
} from "../protyle/util/hasClosest";
import {MenuItem} from "./Menu";
import {getTableCellVerticalAlignmentMenus, setTableCellStyle} from "../protyle/util/tableControl";
-import {getTableCellRichMenus} from "../protyle/toolbar/tableCellRich";
import {focusBlock, focusByOffset, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection";
import {getViewFoldOccurrenceID, hasViewFoldContext, setViewFoldTransient} from "../protyle/util/viewFold";
import {
@@ -2250,7 +2249,7 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLTableCellElement, range: Range,
alignWholeTable = false) => {
- const otherMenus: IMenu[] = alignWholeTable ? [] : getTableCellRichMenus(protyle, [cellElement]);
+ const otherMenus: IMenu[] = [];
const colIndex = getColIndex(cellElement);
const tableElement = nodeElement.querySelector("table");
if (cellElement.rowSpan > 1 || cellElement.colSpan > 1) {
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 4ba5d0a7fc..4304b2e939 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -3603,6 +3603,20 @@ export class Gutter {
}
public render(protyle: IProtyle, element: Element, target?: Element) {
+ const cellFragment = element.closest(".table__cell-rich, .table__cell-editor") ||
+ target?.closest(".table__cell-rich, .table__cell-editor");
+ if (cellFragment) {
+ if (cellFragment.classList.contains("table__cell-editor")) {
+ hideElements(["gutter"], protyle);
+ return;
+ }
+ // 单元格预览中的片段不提供块级操作,块标始终定位到所属表格。
+ const table = cellFragment.closest('[data-type="NodeTable"][data-node-id]');
+ if (!table) {
+ return;
+ }
+ element = table;
+ }
// https://github.com/siyuan-note/siyuan/issues/4659
if (protyle.title && protyle.title.element.getAttribute("data-render") !== "true") {
return;
@@ -3713,6 +3727,7 @@ export class Gutter {
listItem = tabsHeader ? undefined : topElement.querySelector(".li") || topElement.querySelector(".list");
// 嵌入块中有列表时块标显示位置错误 https://github.com/siyuan-note/siyuan/issues/6254
if ((!embedContext && isInEmbedBlock(listItem)) || isInAVBlock(listItem) ||
+ listItem?.closest(".table__cell-rich, .table__cell-editor") ||
hasClosestByClassName(nodeElement, "callout")) {
listItem = undefined;
}
diff --git a/app/src/protyle/render/tableCellRichEditor.ts b/app/src/protyle/render/tableCellRichEditor.ts
index 0f2709b6a9..4bccf5ee53 100644
--- a/app/src/protyle/render/tableCellRichEditor.ts
+++ b/app/src/protyle/render/tableCellRichEditor.ts
@@ -9,8 +9,10 @@ import {configureAVRichTextLute, getAVRichTextLute, sanitizeAVRichTextBlockDOM}
import {highlightRender} from "./highlightRender";
import {mathRender} from "./mathRender";
import {renderTableCellRichElements} from "./tableCellRich";
-import {cleanTableCellRichHTML, getTableCellRichBlockDOM, renderTableCellRich, serializeTableCellRich, setTableCellRich} from "../util/tableCellRich";
-import {decodeTableCellRich, encodeTableCellRich, TABLE_CELL_RICH_ATTRIBUTE, TABLE_RICH_ATTRIBUTE} from "../util/tableCellRichValue";
+import {cleanTableCellRichHTML, getTableCellInlineHTML, getTableCellRichBlockDOM, renderTableCellRich, serializeTableCellRich, setTableCellRich, TABLE_CELL_INLINE_ATTRIBUTE, updateTableCellEditingValue} from "../util/tableCellRich";
+import {TABLE_CELL_RICH_ATTRIBUTE} from "../util/tableCellRichValue";
+import {focusByOffset, getSelectionOffset} from "../util/selection";
+import {fixTable} from "../util/table";
const SAFE_SLASH_IDS = new Set([
"ref", "heading1", "heading2", "heading3", "heading4", "heading5", "heading6", "list", "orderedList", "check",
@@ -81,8 +83,10 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElem
return;
}
let initialBlockHTML: string;
+ let source: string;
try {
initialBlockHTML = getTableCellRichBlockDOM(cell);
+ source = serializeTableCellRich(initialBlockHTML).markdown;
} catch (error) {
console.error(error);
showMessage(window.siyuan.languages.tableCellRichInvalid);
@@ -91,14 +95,14 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElem
owner.wysiwyg.tableControl?.clear();
owner.wysiwyg.tableControl?.setHidden(true);
hideElements(["gutter"], owner);
- table.setAttribute(TABLE_RICH_ATTRIBUTE, "1");
- const initialHTML = table.outerHTML;
+ const selection = getSelection();
+ const initialRange = selection.rangeCount ? selection.getRangeAt(0) : undefined;
+ const initialOffset = !cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE) && initialRange &&
+ cell.contains(initialRange.startContainer) && cell.contains(initialRange.endContainer) ?
+ getSelectionOffset(cell, owner.wysiwyg.element, initialRange) : undefined;
if (!cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE)) {
- cell.setAttribute(TABLE_CELL_RICH_ATTRIBUTE, encodeTableCellRich(serializeTableCellRich(initialBlockHTML).markdown));
- table.setAttribute(TABLE_RICH_ATTRIBUTE, "1");
- updateTransaction(owner, table, initialHTML);
+ cell.setAttribute(TABLE_CELL_INLINE_ATTRIBUTE, cell.innerHTML);
}
- let source = decodeTableCellRich(cell.getAttribute(TABLE_CELL_RICH_ATTRIBUTE)).content;
const host = document.createElement("div");
host.className = "table__cell-editor";
host.dataset.protyleLiteRender = "safe";
@@ -162,7 +166,7 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElem
}
const oldHTML = cleanTableCellRichHTML(table.outerHTML);
source = serialized.markdown;
- cell.setAttribute(TABLE_CELL_RICH_ATTRIBUTE, encodeTableCellRich(source));
+ updateTableCellEditingValue(cell, serialized);
updateTransaction(owner, table, oldHTML);
} catch (error) {
console.error(error);
@@ -223,6 +227,33 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElem
}
}, {signal});
host.addEventListener("keydown", event => {
+ if (!event.isComposing && !composing && !event.ctrlKey && !event.metaKey && !event.altKey &&
+ fragment.hintElement.classList.contains("fn__none") &&
+ fragment.protyle.toolbar.subElement.classList.contains("fn__none")) {
+ const range = getSelection().rangeCount ? getSelection().getRangeAt(0) : undefined;
+ const target = range?.startContainer instanceof Element ? range.startContainer : range?.startContainer.parentElement;
+ const inListOrCode = target?.closest('[data-type="NodeList"], [data-type="NodeCodeBlock"]');
+ const navigate = !inListOrCode && (event.key === "Tab" ||
+ (event.key === "Enter" && !event.shiftKey && getTableCellInlineHTML(fragment.getBlockHTML()) !== null));
+ if (navigate) {
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ finish();
+ const tableRange = document.createRange();
+ tableRange.selectNodeContents(cell);
+ tableRange.collapse(true);
+ getSelection().removeAllRanges();
+ getSelection().addRange(tableRange);
+ fixTable(owner, event, tableRange);
+ const next = getSelection().focusNode;
+ const nextElement = next instanceof Element ? next : next?.parentElement;
+ const nextCell = nextElement?.closest<HTMLTableCellElement>("td, th");
+ if (nextCell && nextCell !== cell && nextCell.closest(".protyle-wysiwyg") === owner.wysiwyg.element) {
+ openTableCellRichEditor(owner, nextCell);
+ }
+ return;
+ }
+ }
if (event.key === "Escape" && !event.isComposing &&
fragment.hintElement.classList.contains("fn__none") &&
fragment.protyle.toolbar.subElement.classList.contains("fn__none")) {
@@ -240,4 +271,10 @@ export const openTableCellRichEditor = (owner: IProtyle, cell: HTMLTableCellElem
}, {capture: true, signal});
observer.observe(owner.element, {childList: true, subtree: true});
fragment.focus(true);
+ if (initialOffset) {
+ const edit = fragment.wysiwyg.querySelector('[contenteditable="true"]');
+ if (edit) {
+ focusByOffset(edit, initialOffset.start, initialOffset.end);
+ }
+ }
};
diff --git a/app/src/protyle/toolbar/tableCellRich.ts b/app/src/protyle/toolbar/tableCellRich.ts
deleted file mode 100644
index 13bde56d86..0000000000
--- a/app/src/protyle/toolbar/tableCellRich.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import {showMessage} from "../../dialog/message";
-import {getTableCellRichInline} from "../util/tableCellRich";
-import {TABLE_CELL_RICH_ATTRIBUTE} from "../util/tableCellRichValue";
-import {updateTransaction} from "../wysiwyg/transaction";
-
-export const getTableCellRichMenus = (protyle: IProtyle, cells: HTMLTableCellElement[]): IMenu[] => {
- if (protyle.disabled || cells.length !== 1) {
- return [];
- }
- const cell = cells[0];
- const rich = cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE);
- const menus: IMenu[] = [{
- id: "tableCellRichEdit",
- icon: "iconEdit",
- label: window.siyuan.languages[rich ? "tableCellRichEdit" : "tableCellRichEnable"],
- click: () => {
- void import("../render/tableCellRichEditor").then(module => module.openTableCellRichEditor(protyle, cell));
- },
- }];
- if (rich) {
- menus.push({
- id: "tableCellRichDisable",
- icon: "iconFont",
- label: window.siyuan.languages.tableCellRichDisable,
- click: () => {
- try {
- const inline = getTableCellRichInline(cell);
- const table = cell.closest('[data-type="NodeTable"]');
- const oldHTML = table.outerHTML;
- cell.removeAttribute(TABLE_CELL_RICH_ATTRIBUTE);
- cell.removeAttribute("contenteditable");
- cell.removeAttribute("tabindex");
- cell.innerHTML = inline;
- updateTransaction(protyle, table, oldHTML);
- } catch (error) {
- console.error(error);
- showMessage(window.siyuan.languages.tableCellRichInvalid);
- }
- },
- });
- }
- return menus;
-};
diff --git a/app/src/protyle/util/tableCellRich.ts b/app/src/protyle/util/tableCellRich.ts
index 0160d95557..cf997f38c8 100644
--- a/app/src/protyle/util/tableCellRich.ts
+++ b/app/src/protyle/util/tableCellRich.ts
@@ -1,18 +1,119 @@
-import {getAVRichTextBlockDOM, getAVRichTextLute, serializeAVRichTextBlockDOM} from "../render/av/richText";
+import {getAVRichTextBlockDOM, getAVRichTextLute, sanitizeAVRichTextBlockDOM, serializeAVRichTextBlockDOM} from "../render/av/richText";
import {decodeTableCellRich, encodeTableCellRich, TABLE_CELL_RICH_ATTRIBUTE, TABLE_RICH_ATTRIBUTE} from "./tableCellRichValue";
+export const TABLE_CELL_INLINE_ATTRIBUTE = "data-sy-table-cell-inline";
+
+export const getTableCellInlineHTML = (blockDOM: string): string | null => {
+ const template = document.createElement("template");
+ template.innerHTML = blockDOM;
+ const blocks = Array.from(template.content.children);
+ if (blocks.length === 0) {
+ return "";
+ }
+ if (blocks.length !== 1 || blocks[0].getAttribute("data-type") !== "NodeParagraph" ||
+ blocks[0].querySelector('[data-type^="Node"]')) {
+ return null;
+ }
+ const content = blocks[0].querySelector(':scope > [contenteditable="true"]');
+ if (!content) {
+ return null;
+ }
+ content.querySelectorAll('span[data-type="text"]:not([style])').forEach(span => span.replaceWith(...Array.from(span.childNodes)));
+ // 表格的行级内容使用 br 保存软换行,片段编辑器使用文本换行。
+ const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT);
+ const texts: Text[] = [];
+ while (walker.nextNode()) {
+ texts.push(walker.currentNode as Text);
+ }
+ texts.forEach(text => {
+ if (text.data.includes("\n")) {
+ const lines = text.data.split("\n");
+ text.replaceWith(...lines.flatMap((line, index) => index === 0 ? [line] : [document.createElement("br"), line]));
+ }
+ });
+ return content.innerHTML;
+};
+
export const getTableCellRichBlockDOM = (cell: Element) => {
const encoded = cell.getAttribute(TABLE_CELL_RICH_ATTRIBUTE);
- if (encoded !== null) {
- return getAVRichTextBlockDOM(decodeTableCellRich(encoded).content, true);
- }
// 普通单元格先转换已有的行级 DOM,文字中的 Markdown 标记保持字面含义。
- return `<div data-type="NodeParagraph" data-node-id="${Lute.NewNodeID()}"><div contenteditable="true">` +
- `${cell.innerHTML}</div></div>`;
+ const blockDOM = encoded !== null ? getAVRichTextBlockDOM(decodeTableCellRich(encoded).content, true) :
+ `<div class="p" data-type="NodeParagraph" data-node-id="${Lute.NewNodeID()}"><div contenteditable="true">` +
+ `${(cell.getAttribute(TABLE_CELL_INLINE_ATTRIBUTE) ?? cell.innerHTML) || "\u200b"}</div></div>`;
+ const template = document.createElement("template");
+ template.innerHTML = blockDOM;
+ const walker = document.createTreeWalker(template.content, NodeFilter.SHOW_TEXT);
+ const texts: Text[] = [];
+ while (walker.nextNode()) {
+ const text = walker.currentNode as Text;
+ if (text.parentElement?.closest('[contenteditable="true"]') &&
+ !text.parentElement.closest('span[data-type], [data-type="NodeCodeBlock"], [data-type="NodeMathBlock"], .img') &&
+ /[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/.test(text.data)) {
+ texts.push(text);
+ }
+ }
+ // 已有标记符作为字面文本参与编辑,避免输入其他字符时被即时 Markdown 解析重新解释。
+ texts.forEach(text => {
+ const span = document.createElement("span");
+ span.dataset.type = "text";
+ text.replaceWith(span);
+ span.appendChild(text);
+ });
+ return template.innerHTML;
};
-export const serializeTableCellRich = (blockDOM: string) =>
- serializeAVRichTextBlockDOM(blockDOM, getAVRichTextLute(), true);
+export const serializeTableCellRich = (blockDOM: string) => {
+ const template = document.createElement("template");
+ template.innerHTML = sanitizeAVRichTextBlockDOM(blockDOM, true);
+ let prefix = "SYTABLECELLWHITESPACE";
+ while (template.innerHTML.includes(prefix)) {
+ prefix += "X";
+ }
+ const whitespace: string[] = [];
+ const protectWhitespace = (value: string) => {
+ const token = `${prefix}${whitespace.length}END`;
+ whitespace.push(value.replace(/ /g, "&#32;").replace(/\t/g, "&#9;").replace(/\n/g, "<br />"));
+ return token;
+ };
+ template.content.querySelectorAll("br").forEach(br => {
+ if (!br.closest('[data-type="NodeCodeBlock"], [data-type="NodeMathBlock"], .img')) {
+ br.replaceWith(protectWhitespace("\n"));
+ }
+ });
+ // 只转义正文文本中的 Markdown 标记,实际行级格式和代码、公式的源内容保持原样。
+ const walker = document.createTreeWalker(template.content, NodeFilter.SHOW_TEXT);
+ while (walker.nextNode()) {
+ const text = walker.currentNode as Text;
+ if (text.parentElement?.closest('[contenteditable="true"]') &&
+ !text.parentElement.closest('[data-type="NodeCodeBlock"], [data-type="NodeMathBlock"], .img')) {
+ if (!text.parentElement.closest("span[data-type]")) {
+ text.data = text.data.replace(/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/g, "\\$&");
+ }
+ // 软换行不能变成段落分隔,段首和段尾空白不能被 Markdown 格式化移除。
+ text.data = text.data.replace(/^[ \t]+|[ \t]+$|\n/g, protectWhitespace);
+ }
+ }
+ const lute = getAVRichTextLute();
+ const value = serializeAVRichTextBlockDOM(template.innerHTML, lute, true);
+ if (whitespace.length === 0) {
+ return value;
+ }
+ const markdown = value.markdown.replace(new RegExp(`${prefix}(\\d+)END`, "g"),
+ (_token, index) => whitespace[Number(index)]);
+ const normalizedBlockDOM = getAVRichTextBlockDOM(markdown, true);
+ return {blockDOM: normalizedBlockDOM, markdown, plainText: lute.BlockDOM2Content(normalizedBlockDOM)};
+};
+
+export const updateTableCellEditingValue = (cell: Element, value: {blockDOM: string, markdown: string}) => {
+ const inline = getTableCellInlineHTML(value.blockDOM);
+ if (cell.hasAttribute(TABLE_CELL_RICH_ATTRIBUTE) || inline === null) {
+ cell.removeAttribute(TABLE_CELL_INLINE_ATTRIBUTE);
+ cell.setAttribute(TABLE_CELL_RICH_ATTRIBUTE, encodeTableCellRich(value.markdown));
+ cell.closest('[data-type="NodeTable"]')?.setAttribute(TABLE_RICH_ATTRIBUTE, "1");
+ } else {
+ cell.setAttribute(TABLE_CELL_INLINE_ATTRIBUTE, inline);
+ }
+};
export const getTableCellRichInline = (cell: Element) => {
const encoded = cell.getAttribute(TABLE_CELL_RICH_ATTRIBUTE);
@@ -32,8 +133,14 @@ export const getTableCellRichPlainText = (cell: Element) => {
export const renderTableCellRich = (cell: Element) => {
const encoded = cell.getAttribute(TABLE_CELL_RICH_ATTRIBUTE);
if (encoded === null) {
+ const inline = cell.getAttribute(TABLE_CELL_INLINE_ATTRIBUTE);
+ if (inline !== null) {
+ cell.innerHTML = inline;
+ cell.removeAttribute(TABLE_CELL_INLINE_ATTRIBUTE);
+ }
return;
}
+ cell.removeAttribute(TABLE_CELL_INLINE_ATTRIBUTE);
decodeTableCellRich(encoded);
const template = document.createElement("template");
// 由 Lute 从源数据产生预览,事务、剪贴板和静态渲染使用同一套单元格协议。
@@ -87,12 +194,13 @@ export const copyTableCellContent = (target: Element, source: Element) => {
};
export const cleanTableCellRichHTML = (html: string) => {
- if (!html.includes(TABLE_CELL_RICH_ATTRIBUTE)) {
+ if (!html.includes(TABLE_CELL_RICH_ATTRIBUTE) && !html.includes(TABLE_CELL_INLINE_ATTRIBUTE)) {
return html;
}
const template = document.createElement("template");
template.innerHTML = html;
- template.content.querySelectorAll(`th[${TABLE_CELL_RICH_ATTRIBUTE}], td[${TABLE_CELL_RICH_ATTRIBUTE}]`)
+ template.content.querySelectorAll(`th[${TABLE_CELL_RICH_ATTRIBUTE}], td[${TABLE_CELL_RICH_ATTRIBUTE}], ` +
+ `th[${TABLE_CELL_INLINE_ATTRIBUTE}], td[${TABLE_CELL_INLINE_ATTRIBUTE}]`)
.forEach(cell => renderTableCellRich(cell));
return template.innerHTML;
};
diff --git a/app/src/protyle/util/tableControl.ts b/app/src/protyle/util/tableControl.ts
index d5ca448ae1..c791a1e79d 100644
--- a/app/src/protyle/util/tableControl.ts
+++ b/app/src/protyle/util/tableControl.ts
@@ -1,6 +1,5 @@
import {MenuItem} from "../../menus/Menu";
import {clearTableCellContent, getTableCellRichPlainText, mergeTableCellContents} from "./tableCellRich";
-import {getTableCellRichMenus} from "../toolbar/tableCellRich";
import {updateTransaction} from "../wysiwyg/transaction";
import {copyPlainText, encodeBase64, isMac, readClipboard} from "./compatibility";
import {removeZWJ} from "./normalizeText";
@@ -1738,9 +1737,6 @@ export class TableControl {
private appendCellMenus(rectangle: boolean) {
const cells = this.getSelectedCells();
- getTableCellRichMenus(this.protyle, cells).forEach(menu => {
- window.siyuan.menus.menu.append(new MenuItem(menu).element);
- });
this.appendAlignmentMenu();
const cellSelection = getTableCellSelectionIndexes(this.selection.table, cells);
if (cellSelection.rowIndexes.length > 0 || cellSelection.columnIndexes.length > 0) {
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 2e067074ba..ede055ff47 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -35,7 +35,6 @@ import {
} from "../util/selection";
import {Constants} from "../../constants";
import {mergeTableCellContents} from "../util/tableCellRich";
-import {TABLE_CELL_RICH_ATTRIBUTE} from "../util/tableCellRichValue";
import {isMobile} from "../../util/functions";
import {previewDocImage} from "../preview/image";
import {getDiagramBlock, previewDiagram} from "../preview/diagram";
@@ -3883,7 +3882,7 @@ export class WYSIWYG {
const selection = getSelection();
const target = selection?.focusNode;
const element = target instanceof Element ? target : target?.parentElement;
- const cell = element?.closest<HTMLTableCellElement>(`th[${TABLE_CELL_RICH_ATTRIBUTE}], td[${TABLE_CELL_RICH_ATTRIBUTE}]`);
+ const cell = element?.closest<HTMLTableCellElement>("th, td");
if (cell && cell.closest(".protyle-wysiwyg") === this.element) {
event.preventDefault();
event.stopPropagation();
@@ -4460,7 +4459,7 @@ export class WYSIWYG {
this.preventClick = false;
return;
}
- const richCell = event.target.closest<HTMLTableCellElement>(`th[${TABLE_CELL_RICH_ATTRIBUTE}], td[${TABLE_CELL_RICH_ATTRIBUTE}]`);
+ const richCell = event.target.closest<HTMLTableCellElement>("th, td");
if (richCell && !event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey && !protyle.disabled &&
richCell.closest(".protyle-wysiwyg") === this.element &&
!event.target.closest("a, [data-type~='block-ref'], [data-type~='a'], img")) {
diff --git a/docs/SY-FORMAT.md b/docs/SY-FORMAT.md
index ea93525559..c7b0f900f5 100644
--- a/docs/SY-FORMAT.md
+++ b/docs/SY-FORMAT.md
@@ -414,11 +414,11 @@ Notes:
- A table's optional `Properties.caption` stores its caption HTML.
- A `NodeTableCell` may carry `Properties.colspan`, `Properties.rowspan`, and `Properties.style` for merged-cell and cell-style state.
-An explicitly converted rich text cell additionally carries `"TableCellRich": {"spec": 1, "format": "kramdown", "content": "- first\n- second"}`. This source is authoritative; `Children` remains an inline projection with readable list markers and line breaks. Internal paragraphs, lists, code, and math do not become document blocks and have no persistent block IDs. Images, references to existing blocks, and supported inline formatting remain in the projection for indexing and resource handling. A rich table retains `Properties.custom-sy-table-rich = "1"`; BlockDOM updates must retain this marker even after converting all cells back to inline content, so a writer that omits the source cannot silently replace a rich table.
+A cell with rich block content additionally carries `"TableCellRich": {"spec": 1, "format": "kramdown", "content": "- first\n- second"}`. This source is authoritative; `Children` remains an inline projection with readable list markers and line breaks. Internal paragraphs, lists, code, and math do not become document blocks and have no persistent block IDs. Images, references to existing blocks, and supported inline formatting remain in the projection for indexing and resource handling. A rich table retains `Properties.custom-sy-table-rich = "1"`; BlockDOM updates must retain this marker even when all rich cells become inline-only or empty, so a writer that omits the source cannot silently replace a rich table.
Only paragraphs, headings, lists, blockquotes, ordinary code, and math are supported inside the fragment. Nested tables, databases, superblocks, tabs, callouts, query embeds, executable diagrams, media, widgets, and HTML blocks are rejected. BlockDOM stores the source envelope as UTF-8 JSON encoded with unpadded URL-safe Base64 in the cell's `data-sy-table-cell-rich` attribute. Internal Kramdown uses the corresponding `table-cell-rich` cell IAL; neither representation is a standard Markdown interchange format.
-Readers validate the source version and content before rebuilding the projection. Missing, null, unknown, or malformed envelope fields are errors, and unsupported input must remain unchanged. Ordinary cells have no envelope and are never reinterpreted as Markdown. The first explicit conversion raises the document `Spec` to `4`; removing the feature does not lower it. Standard Markdown uses a readable inline projection, while HTML, PDF, and Word exports expand the fragment only in a transient export tree. Encrypted notebooks authenticate the existing document envelope before parsing this same JSON; key derivation, AAD, and recovery material are unchanged.
+Readers validate the source version and content before rebuilding the projection. Missing, null, unknown, or malformed envelope fields are errors, and unsupported input must remain unchanged. Ordinary cells have no envelope and are never reinterpreted as Markdown. Opening a cell or editing only ordinary inline content preserves its existing representation. Adding block content for the first time creates the rich envelope and raises the document `Spec` to `4`. Existing rich envelopes remain present when their content becomes inline-only or empty; the document version is never lowered. Standard Markdown uses a readable inline projection, while HTML, PDF, and Word exports expand the fragment only in a transient export tree. Encrypted notebooks authenticate the existing document envelope before parsing this same JSON; key derivation, AAD, and recovery material are unchanged.
### 5.14 AttributeView block (database; leaf)