An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lipstick: Align mobile table controls with desktop https://github.com/siyuan-note/siyuan/issues/20635
Daniel38850660452e
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 8dc3e083d0..5c962df06c 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "تنظيف الموارد غير المشار إليها","tableSelectRange": "تحديد نطاق خلايا",- "tableSelectionDone": "تم","listMindmapConnectors": "خطوط التوصيل","listMindmapDefaultConnectorStyle": "نمط التوصيل الافتراضي للخرائط الجديدة","listMindmapConnectorStyle": "نمط خطوط الربط",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex f9a1f5fe45..e45c4381b2 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Nicht referenzierte Ressourcen bereinigen","tableSelectRange": "Zellbereich auswählen",- "tableSelectionDone": "Fertig","listMindmapConnectors": "Verbindungslinien","listMindmapDefaultConnectorStyle": "Standard-Verbindungsstil für neue Mindmaps","listMindmapConnectorStyle": "Linienstil",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex ec53387105..8ab6ac4ea0 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Clean up unreferenced assets","tableSelectRange": "Select cell range",- "tableSelectionDone": "Done","listMindmapConnectors": "Connectors","listMindmapDefaultConnectorStyle": "Default connector style for new maps","listMindmapConnectorStyle": "Connector style",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 85688d894b..36723b88b1 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Limpiar recursos sin referencias","tableSelectRange": "Seleccionar rango de celdas",- "tableSelectionDone": "Listo","listMindmapConnectors": "Conectores","listMindmapDefaultConnectorStyle": "Estilo de conexión predeterminado para mapas nuevos","listMindmapConnectorStyle": "Estilo de conexión",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 24fc25c612..5faff3d935 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Nettoyer les ressources non référencées","tableSelectRange": "Sélectionner une plage de cellules",- "tableSelectionDone": "Terminé","listMindmapConnectors": "Connecteurs","listMindmapDefaultConnectorStyle": "Style de connexion par défaut des nouvelles cartes","listMindmapConnectorStyle": "Style des connexions",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 5d86908236..86628ce9a3 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "ניקוי משאבים ללא הפניות","tableSelectRange": "בחירת טווח תאים",- "tableSelectionDone": "סיום","listMindmapConnectors": "קווי חיבור","listMindmapDefaultConnectorStyle": "סגנון חיבור ברירת מחדל למפות חדשות","listMindmapConnectorStyle": "סגנון קווי חיבור",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex f74929367e..3f9ac1547b 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "असंदर्भित संसाधनों को साफ़ करें","tableSelectRange": "सेल श्रेणी चुनें",- "tableSelectionDone": "पूर्ण","listMindmapConnectors": "कनेक्टर","listMindmapDefaultConnectorStyle": "नए मानचित्रों के लिए डिफ़ॉल्ट कनेक्टर शैली","listMindmapConnectorStyle": "जोड़ने वाली रेखा की शैली",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex b63a8f3ca0..05900e7e29 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Bersihkan aset tanpa referensi","tableSelectRange": "Pilih rentang sel",- "tableSelectionDone": "Selesai","listMindmapConnectors": "Penghubung","listMindmapDefaultConnectorStyle": "Gaya penghubung bawaan untuk peta baru","listMindmapConnectorStyle": "Gaya garis penghubung",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex cdd1654ed7..e6b3b71b49 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Pulisci le risorse senza riferimenti","tableSelectRange": "Seleziona intervallo di celle",- "tableSelectionDone": "Fine","listMindmapConnectors": "Collegamenti","listMindmapDefaultConnectorStyle": "Stile dei collegamenti predefinito per le nuove mappe","listMindmapConnectorStyle": "Stile dei collegamenti",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 3145143b16..18d0344cdf 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "未参照のリソースをクリーンアップ","tableSelectRange": "セル範囲を選択",- "tableSelectionDone": "完了","listMindmapConnectors": "接続線","listMindmapDefaultConnectorStyle": "新規マップの既定の接続線スタイル","listMindmapConnectorStyle": "接続線のスタイル",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 8791b6ca3c..ca42f1c585 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "참조되지 않은 리소스 정리","tableSelectRange": "셀 범위 선택",- "tableSelectionDone": "완료","listMindmapConnectors": "연결선","listMindmapDefaultConnectorStyle": "새 지도의 기본 연결선 스타일","listMindmapConnectorStyle": "연결선 스타일",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex bf43a0bcf1..9727158570 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Niet-verwezen bronnen opruimen","tableSelectRange": "Celbereik selecteren",- "tableSelectionDone": "Gereed","listMindmapConnectors": "Verbindingslijnen","listMindmapDefaultConnectorStyle": "Standaard verbindingsstijl voor nieuwe mindmaps","listMindmapConnectorStyle": "Verbindingsstijl",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 9694259e0b..ee21b6dbc0 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Usuń nieużywane zasoby","tableSelectRange": "Wybierz zakres komórek",- "tableSelectionDone": "Gotowe","listMindmapConnectors": "Łączniki","listMindmapDefaultConnectorStyle": "Domyślny styl połączeń nowych map","listMindmapConnectorStyle": "Styl połączeń",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 4570069d22..846741f0cd 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Limpar recursos sem referências","tableSelectRange": "Selecionar intervalo de células",- "tableSelectionDone": "Concluído","listMindmapConnectors": "Conectores","listMindmapDefaultConnectorStyle": "Estilo de conexão padrão para novos mapas","listMindmapConnectorStyle": "Estilo das conexões",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex ecf5a970aa..670a2ea6e1 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Очистить ресурсы без ссылок","tableSelectRange": "Выбрать диапазон ячеек",- "tableSelectionDone": "Готово","listMindmapConnectors": "Соединительные линии","listMindmapDefaultConnectorStyle": "Стиль соединений по умолчанию для новых карт","listMindmapConnectorStyle": "Стиль соединительных линий",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex fc05f41a60..2384718816 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Vyčistiť neodkazované zdroje","tableSelectRange": "Vybrať rozsah buniek",- "tableSelectionDone": "Hotovo","listMindmapConnectors": "Spojnice","listMindmapDefaultConnectorStyle": "Predvolený štýl spojníc pre nové mapy","listMindmapConnectorStyle": "Štýl spojníc",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex 0940a9363f..8a126a4ccb 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Очисти ресурсе без референци","tableSelectRange": "Изабери опсег ћелија",- "tableSelectionDone": "Готово","listMindmapConnectors": "Линије повезивања","listMindmapDefaultConnectorStyle": "Подразумевани стил веза за нове мапе","listMindmapConnectorStyle": "Стил спојних линија",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 7c5e070aae..283149bd0d 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "ล้างทรัพยากรที่ไม่มีการอ้างอิง","tableSelectRange": "เลือกช่วงเซลล์",- "tableSelectionDone": "เสร็จสิ้น","listMindmapConnectors": "เส้นเชื่อม","listMindmapDefaultConnectorStyle": "รูปแบบเส้นเชื่อมเริ่มต้นสำหรับแผนผังใหม่","listMindmapConnectorStyle": "รูปแบบเส้นเชื่อม",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 8becfc1324..77185a39c3 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Başvurulmayan kaynakları temizle","tableSelectRange": "Hücre aralığı seç",- "tableSelectionDone": "Bitti","listMindmapConnectors": "Bağlantı çizgileri","listMindmapDefaultConnectorStyle": "Yeni haritalar için varsayılan bağlantı stili","listMindmapConnectorStyle": "Bağlantı çizgisi stili",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 3e3bd082b2..49aa760a67 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "Очистити ресурси без посилань","tableSelectRange": "Вибрати діапазон клітинок",- "tableSelectionDone": "Готово","listMindmapConnectors": "З’єднувальні лінії","listMindmapDefaultConnectorStyle": "Типовий стиль з’єднань для нових карт","listMindmapConnectorStyle": "Стиль сполучних ліній",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex a4393a5e09..ed10ff21e1 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "清理未引用资源","tableSelectRange": "选择区域",- "tableSelectionDone": "完成","listMindmapConnectors": "连线","listMindmapDefaultConnectorStyle": "新建默认连线样式","listMindmapConnectorStyle": "连线样式",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 3fad90499d..97bf1b3ea1 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,7 +1,6 @@{"cleanUnusedAssets": "清理未引用資源","tableSelectRange": "選取區域",- "tableSelectionDone": "完成","listMindmapConnectors": "連線","listMindmapDefaultConnectorStyle": "新建預設連線樣式","listMindmapConnectorStyle": "連線樣式",diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.syindex a87213ba3a..8d9be62143 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy@@ -6,7 +6,7 @@"id": "20200924101225-k254i8g","title": "Content Block Type","type": "doc",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{@@ -1474,7 +1474,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091538-a55chyw",- "updated": "20261016202856"+ "updated": "20261017151154"},"Children": [{@@ -1746,7 +1746,7 @@"HeadingLevel": 3,"Properties": {"id": "20210104091538-38bsz5r",- "updated": "20260222162325"+ "updated": "20261017151154"},"Children": [{@@ -1957,12 +1957,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017142635-d2uc99x",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{"Type": "NodeText",- "Data": "Tap a handle above a column or beside a row to select that column or row. Enable Multi-select in the bottom toolbar to add or remove nonadjacent cells, rows, or columns. Use More to merge cells, set styles and alignment, or operate on selected rows and columns. Tap Done to leave selection mode."+ "Data": "Tap a handle above a column or beside a row to select that column or row. Enable Multi-select in the top toolbar to add or remove nonadjacent cells, rows, or columns. Use More to merge cells, set styles and alignment, or operate on selected rows and columns. Tap Close to leave selection mode."}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.syindex ee9649173f..ca09143c26 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy@@ -6,7 +6,7 @@"id": "20200905090211-2vixtlf","title": "内容块类型","type": "doc",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{@@ -1507,7 +1507,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104090624-9qgquxh",- "updated": "20261016111305"+ "updated": "20261017151154"},"Children": [{@@ -1782,7 +1782,7 @@"HeadingLevel": 3,"Properties": {"id": "20210104090624-erf17it",- "updated": "20260425180351"+ "updated": "20261017151154"},"Children": [{@@ -1997,12 +1997,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017142635-bcg68ni",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{"Type": "NodeText",- "Data": "点击列上方或行左侧的手柄可选中整列或整行。在底部工具栏开启「多选」后,可点选增减不连续的单元格、行或列。通过「更多」可合并单元格、设置样式和对齐,或批量操作所选行列;点击「完成」退出选择。"+ "Data": "点击列上方或行左侧的手柄可选中整列或整行。在顶部工具栏开启「多选」后,可点选增减不连续的单元格、行或列。通过「更多」可合并单元格、设置样式和对齐,或批量操作所选行列;点击「关闭」退出选择。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.syindex 16240a8871..6091431929 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy@@ -6,7 +6,7 @@"id": "20211226120147-ib6yy3i","title": "內容區塊類型","type": "doc",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{@@ -1503,7 +1503,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226120227-esm6f20",- "updated": "20261016111305"+ "updated": "20261017151154"},"Children": [{@@ -1767,7 +1767,7 @@"HeadingLevel": 3,"Properties": {"id": "20211226120227-fe8klj7",- "updated": "20260730184353"+ "updated": "20261017151154"},"Children": [{@@ -1984,12 +1984,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017142635-qpn3xky",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{"Type": "NodeText",- "Data": "點選欄上方或列左側的控點可選取整欄或整列。在底部工具列開啟「多選」後,可點選增減不連續的儲存格、列或欄。透過「更多」可合併儲存格、設定樣式和對齊,或批次操作所選列欄;點選「完成」退出選取。"+ "Data": "點選欄上方或列左側的控點可選取整欄或整列。在頂部工具列開啟「多選」後,可點選增減不連續的儲存格、列或欄。透過「更多」可合併儲存格、設定樣式和對齊,或批次操作所選列欄;點選「關閉」退出選取。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.syindex 79697afb7b..c9b4b742ca 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy@@ -7,7 +7,7 @@"id": "20240530101000-35bbvcx","title": "コンテンツブロックの種類","type": "doc",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{@@ -1564,7 +1564,7 @@"Properties": {"ID": "20240530101000-rjjxxn8","id": "20240530101000-p035stn",- "updated": "20261016202856"+ "updated": "20261017151154"},"Children": [{@@ -1788,7 +1788,7 @@"HeadingLevel": 3,"Properties": {"id": "20240530101000-riwihza",- "updated": "20260222162348"+ "updated": "20261017151154"},"Children": [{@@ -2015,12 +2015,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017142635-udb0p1z",- "updated": "20261017142635"+ "updated": "20261017151154"},"Children": [{"Type": "NodeText",- "Data": "列の上または行の左にあるハンドルをタップすると、列全体または行全体を選択できます。下部ツールバーで複数選択を有効にすると、離れたセル、行、列をタップして選択に追加したり、選択から外したりできます。「詳細」からセルの結合、スタイルや配置の設定、選択した行や列の一括操作を行えます。「完了」をタップすると選択を終了します。"+ "Data": "列の上または行の左にあるハンドルをタップすると、列全体または行全体を選択できます。上部ツールバーで複数選択を有効にすると、離れたセル、行、列をタップして選択に追加したり、選択から外したりできます。「詳細」からセルの結合、スタイルや配置の設定、選択した行や列の一括操作を行えます。「閉じる」をタップすると選択を終了します。"}]},diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scssindex 7d934c3a29..69273413d7 100644--- a/app/src/assets/scss/protyle/_protyle.scss+++ b/app/src/assets/scss/protyle/_protyle.scss@@ -1249,7 +1249,6 @@ table + .protyle-action__table {html[data-frontend="mobile"] .protyle-wysiwyg [data-type="NodeTable"] > div:first-child,html[data-frontend="browser-mobile"] .protyle-wysiwyg [data-type="NodeTable"] > div:first-child {padding-top: 16px;- padding-left: 16px;}.protyle-table-control {@@ -1300,7 +1299,8 @@ html[data-frontend="browser-mobile"] .protyle-wysiwyg [data-type="NodeTable"] >transition: opacity 150ms linear;}- &:hover {+ &:hover,+ &--active {&::before {opacity: 0;}@@ -1473,21 +1473,32 @@ html[data-frontend="browser-mobile"] .protyle-wysiwyg [data-type="NodeTable"] >}&__toolbar {- position: fixed;left: 8px;right: 8px;- bottom: max(8px, env(safe-area-inset-bottom));- z-index: 5;- display: flex;- align-items: center;- justify-content: space-around;- gap: 4px;- padding: 8px;- background-color: var(--b3-theme-background);- border-radius: var(--b3-border-radius);- box-shadow: var(--b3-point-shadow);+ top: 8px;+ width: auto;pointer-events: auto;}++ &__touch-add {+ touch-action: none;++ &::before {+ content: "";+ position: absolute;+ inset: -6px;+ }+ }++ &__touch-handle {+ width: 28px;+ height: 28px;+ touch-action: none;++ &:not(:hover):not(.protyle-table-control__handle--active)::before {+ opacity: 1;+ }+ }}.image-ocr {display: flex;diff --git a/app/src/mobile/util/mobileBars.test.ts b/app/src/mobile/util/mobileBars.test.tsindex 40bc93d7b6..819d2f13e2 100644--- a/app/src/mobile/util/mobileBars.test.ts+++ b/app/src/mobile/util/mobileBars.test.ts@@ -46,6 +46,7 @@ class TestBreadcrumbElement {class TestScrollElement {public scrollTop = 0;public onScroll: () => void;+ public parent: HTMLElement;public addEventListener(_name: string, callback: () => void): void {this.onScroll = callback;@@ -55,8 +56,8 @@ class TestScrollElement {// 测试无需触发滚动事件}- public closest(): undefined {- return undefined;+ public closest(): HTMLElement {+ return this.parent;}}@@ -70,6 +71,11 @@ describe("mobile bars", () => {const breadcrumbElement = new TestBreadcrumbElement();const bottomBarElement = new TestBreadcrumbElement();const scrollElement = new TestScrollElement();+ const selectionToolbars = [{hidden: true}, {hidden: true}];+ const selectionObservers = new Map<object, () => void>();+ scrollElement.parent = {querySelectorAll: (selector: string) => selector.includes("exitMultiSelectMode") ?+ selectionToolbars.map(toolbar => ({closest: () => toolbar.hidden ? toolbar : null})) : selectionToolbars,+ } as unknown as HTMLElement;let frame: FrameRequestCallback;let finishScroll: () => void;const mockDocument = {@@ -113,12 +119,28 @@ describe("mobile bars", () => {cancelAnimationFrame: () => {},getSelection: (): undefined => undefined,MutationObserver: class {- observe(): void {}+ constructor(private callback: () => void) {}+ observe(element: object): void {+ selectionObservers.set(element, this.callback);+ }disconnect(): void {}},});moduleExports.initMobileBars();moduleExports.bindMobileBarsScroll(scrollElement as unknown as HTMLElement);+ for (const toolbar of selectionToolbars) {+ assert.equal(selectionObservers.has(toolbar), true);+ toolbar.hidden = false;+ selectionObservers.get(toolbar)();+ assert.equal(moduleExports.isMobileBlockSelecting(), true);+ assert.equal(classes.has("mobile-selection--active"), true);+ assert.equal(bottomBarElement.attributes.has("inert"), true);+ toolbar.hidden = true;+ selectionObservers.get(toolbar)();+ assert.equal(moduleExports.isMobileBlockSelecting(), false);+ assert.equal(classes.has("mobile-selection--active"), false);+ assert.equal(bottomBarElement.attributes.has("inert"), false);+ }const changeKeyboard = (open: boolean) => windowListeners.get("siyuan-mobile-keyboard-change")({detail: open});const assertTitleVisible = () => {assert.equal(topbarElement.style.getPropertyValue("--mobile-bar-translate-y"),diff --git a/app/src/mobile/util/mobileBars.ts b/app/src/mobile/util/mobileBars.tsindex 2e62fdfdd3..3b3298bec9 100644--- a/app/src/mobile/util/mobileBars.ts+++ b/app/src/mobile/util/mobileBars.ts@@ -28,9 +28,9 @@ const hasTextSelection = () => {};export const isMobileBlockSelecting = () => {- const multiSelectElement = scrollElement?.closest(".protyle")- ?.querySelector(".protyle-util--mobile [data-type='exitMultiSelectMode']");- return Boolean(multiSelectElement && !multiSelectElement.closest(".fn__none"));+ const multiSelectElements = scrollElement?.closest(".protyle")+ ?.querySelectorAll(".protyle-util--mobile [data-type='exitMultiSelectMode']");+ return Array.from(multiSelectElements || []).some(element => !element.closest(".fn__none"));};const isPanelOpen = () => PANEL_IDS.some((id) => Boolean(document.getElementById(id)?.style.transform));@@ -146,15 +146,15 @@ export const bindMobileBarsScroll = (element: HTMLElement, onBreadcrumbPositionCselectionObserver = undefined;scrollElement = element;scrollElement.addEventListener("scroll", onScroll, {passive: true});- const selectionElement = element.closest(".protyle")?.querySelector(".protyle-util--mobile");- if (selectionElement) {+ const selectionElements = element.closest(".protyle")?.querySelectorAll(".protyle-util--mobile");+ if (selectionElements?.length) {selectionObserver = new MutationObserver(updateSelectionState);- selectionObserver.observe(selectionElement, {+ selectionElements.forEach(selectionElement => selectionObserver.observe(selectionElement, {attributes: true,attributeFilter: ["class"],childList: true,subtree: true,- });+ }));}resetMobileBars(element.scrollTop);updateSelectionState();diff --git a/app/src/mobile/util/multiSelectToolbar.ts b/app/src/mobile/util/multiSelectToolbar.tsindex 3a247bde2d..4a35ddb236 100644--- a/app/src/mobile/util/multiSelectToolbar.ts+++ b/app/src/mobile/util/multiSelectToolbar.ts@@ -1,4 +1,12 @@import {toggleMenu} from "../../menus/menuToggle";+import {escapeAttr} from "../../util/escape";++interface IMultiSelectToolbarAction {+ type: string;+ icon: string;+ label: string;+ click: () => void;+}export const insertMobileMultiSelectMenu = (itemsElement: Element, menuItem: HTMLElement) => {const openInNewTab = Array.from(itemsElement.children).find(item => item.getAttribute("data-id") === "openInNewTab");@@ -15,7 +23,7 @@ export const updateMultiSelectToolbar = (element: HTMLElement, count: number) =>};export const renderMultiSelectToolbar = (element: HTMLElement, count: number, onMenu: () => void, onExit: () => void,- onSelectAll?: () => void) => {+ onSelectAll?: () => void, actions: IMultiSelectToolbarAction[] = []) => {element.style.padding = "0";element.innerHTML = `<div class="block__icons"><div class="block__logo">@@ -23,6 +31,7 @@ export const renderMultiSelectToolbar = (element: HTMLElement, count: number, on<span class="multiSelectCount"></span></div><span class="fn__flex-1"></span>+ ${actions.map(action => `<button class="block__icon block__icon--show" data-type="${escapeAttr(action.type)}" aria-label="${escapeAttr(action.label)}"><svg><use xlink:href="#${escapeAttr(action.icon)}"></use></svg></button><span class="fn__space"></span>`).join("")}${onSelectAll ? `<button class="block__icon block__icon--show" data-type="selectAll" aria-label="${window.siyuan.languages.selectAll}"><svg><use xlink:href="#iconSelectAll"></use></svg></button><span class="fn__space"></span>` : ""}<button class="block__icon block__icon--show" data-type="menu" data-menu="true" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></button><span class="fn__space"></span>@@ -38,6 +47,8 @@ export const renderMultiSelectToolbar = (element: HTMLElement, count: number, ononExit();} else if (button.dataset.type === "selectAll") {onSelectAll?.();+ } else {+ actions.find(action => action.type === button.dataset.type)?.click();}}event.preventDefault();diff --git a/app/src/protyle/util/tableControl.ts b/app/src/protyle/util/tableControl.tsindex 1d0d0e5864..08aa8efef4 100644--- a/app/src/protyle/util/tableControl.ts+++ b/app/src/protyle/util/tableControl.ts@@ -29,6 +29,8 @@ import {getTableResizeCount,isTableCellContentEmpty,isTableResizeControlVisible,+ TABLE_ADD_CONTROL_GAP,+ TABLE_ADD_CONTROL_THICKNESS,} from "./tableResize";import {applyTableCellStyleHotkey, getTableCellTextStyleMenus} from "../toolbar/tableCell";import {getTableCellsInRectangle, getTableDragEdge} from "./tableSelection";@@ -325,8 +327,6 @@ export const getTableCellVerticalAlignmentMenus = (};const TABLE_HANDLE_THICKNESS = 16;-const TABLE_ADD_CONTROL_THICKNESS = 16;-const TABLE_ADD_CONTROL_GAP = 10;const TABLE_EDGE_CONTROL_TRIGGER_SIZE = 8;const TABLE_RESIZE_DRAG_THRESHOLD = 4;const TABLE_NON_TEXT_CONTENT_SELECTOR = "img, audio, video, iframe, canvas, svg, math, input, textarea, select, button, object, embed";@@ -427,6 +427,13 @@ export class TableControl {},width: (event, cell, column) => this.startColumnResize(event, cell, column),menu: () => this.openMenu(0, 0),+ selectAll: () => {+ const state = this.getTouchState();+ if (state?.selection) {+ const {grid} = state;+ this.selectCellRange(grid.grid[0][0], grid.grid[grid.rowCount - 1][grid.columnCount - 1]);+ }+ },copy: () => this.execClipboardCommand("copy"),clear: () => this.clearCells(),finish: () => this.clear(),@@ -556,7 +563,7 @@ export class TableControl {viewport.right = Math.min(viewport.right, window.innerWidth);viewport.top = Math.max(viewport.top, visualViewport?.offsetTop || 0);viewport.bottom = Math.min(viewport.bottom, (visualViewport?.height || window.innerHeight) +- (visualViewport?.offsetTop || 0), window.innerHeight - (this.selection ? 64 : 0));+ (visualViewport?.offsetTop || 0), window.innerHeight);return {cell, table, viewport, grid: this.selectionGrid || this.gridCache.get(table).grid,selection: this.selection ? {mode: this.selection.mode,@@ -789,8 +796,9 @@ export class TableControl {}return;}- if (this.element.contains(target) || this.selection.node.contains(target) ||- document.getElementById("commonMenu")?.contains(target)) {+ if (this.element.contains(target) || this.touch?.containsToolbar(target) || this.selection.node.contains(target) ||+ document.getElementById("commonMenu")?.contains(target) ||+ this.touch && document.getElementById("commonMenuScrim")?.contains(target)) {return;}this.clear();diff --git a/app/src/protyle/util/tableResize.ts b/app/src/protyle/util/tableResize.tsindex 170533d3dd..9a2481be35 100644--- a/app/src/protyle/util/tableResize.ts+++ b/app/src/protyle/util/tableResize.ts@@ -1,3 +1,6 @@+export const TABLE_ADD_CONTROL_THICKNESS = 16;+export const TABLE_ADD_CONTROL_GAP = 10;+export const isTableCellContentEmpty = (text: string, hasNonTextContent: boolean) => {return !hasNonTextContent && text.replace(/[\u200B-\u200D\uFEFF]/g, "").trim() === "";};diff --git a/app/src/protyle/util/tableTouch.test.ts b/app/src/protyle/util/tableTouch.test.tsindex f16307b61b..618e5ff3bc 100644--- a/app/src/protyle/util/tableTouch.test.ts+++ b/app/src/protyle/util/tableTouch.test.ts@@ -11,8 +11,15 @@ const browserCases = async (sources: Record<string, string>) => {const check: typeof assert = require("node:assert/strict");const nodePath: typeof path = require("node:path");const noop = () => {};+ const fixtureStyle = document.createElement("style");+ fixtureStyle.textContent = ".protyle-util{position:fixed;top:8px;left:8px;right:8px}.block__icons{display:flex;height:42px}" ++ ".block__icons svg,.protyle-table-control svg{width:16px;height:16px}.fn__none{display:none}" ++ ".protyle-table-control__handle,.protyle-table-control__add,.protyle-table-control__touch-button{" ++ "position:fixed;width:28px;height:28px;transform:translate(-50%,-50%)}";+ document.head.append(fixtureStyle);const transactions: {before: string, after: string}[] = [];- const clipboard: {textPlain: string, textHTML?: string}[] = [];+ const clipboard: {textPlain: string, textHTML?: string, textSiyuan?: string}[] = [];+ const pasted: {target: HTMLTableCellElement, textPlain: string}[] = [];const items: IMenu[] = [];let mobile = true;let clipboardFailure = false;@@ -20,13 +27,16 @@ const browserCases = async (sources: Record<string, string>) => {const menuElement = document.createElement("div");menuElement.id = "commonMenu";document.body.append(menuElement);+ const menuScrim = document.createElement("div");+ menuScrim.id = "commonMenuScrim";+ document.body.append(menuScrim);const menu = {element: menuElement, append: (element: HTMLElement) => menuElement.append(element),remove: () => { items.length = 0; menuElement.replaceChildren(); }, fullscreen: noop, popup: noop};const languages = new Proxy({}, {get: (_target, key: string) => key === "insertRowBefore" ||key === "insertRowAfter" || key === "insertColumnLeft1" || key === "insertColumnRight1" ? "${x}" : key});const hotkeys = new Proxy({}, {get: () => ({custom: ""})});Object.assign(window, {Lute: {NewNodeID: () => "20261017120000-newnode", Caret: ""},- siyuan: {languages, menus: {menu}, config: {editor: {fontSize: 16},+ siyuan: {languages, zIndex: 10, menus: {menu}, config: {editor: {fontSize: 16},keymap: {editor: {general: hotkeys, table: hotkeys, insert: hotkeys}}}}});const focusByRange = (range: Range) => {getSelection().removeAllRanges();@@ -72,13 +82,18 @@ const browserCases = async (sources: Record<string, string>) => {}},"src/protyle/util/selectionOffsets.ts": {focusByRange},"src/protyle/util/compatibility.ts": {isMac: () => false, encodeBase64: (value: string) => Buffer.from(value, "utf8").toString("base64"),- copyPlainText: noop, readClipboard: async () => ({textPlain: "pasted"}),+ copyPlainText: noop, readClipboard: async () => {+ await clipboardWait;+ return {textPlain: "pasted"};+ },writeClipboardData: async (value: {textPlain: string}) => {await clipboardWait;clipboard.push(value);return {status: clipboardFailure ? "failed" : "rich"};}},"src/protyle/util/normalizeText.ts": {removeZWJ: (value: string) => value},+ "src/protyle/util/paste.ts": {paste: (_protyle: object, value: {target: HTMLTableCellElement, textPlain: string}) =>+ pasted.push(value)},"src/protyle/util/inlineElementMarker.ts": {getTextWithoutSemanticMarkers: (node: Node) => node.textContent},"src/protyle/toolbar/tableCell.ts": {getTableCellTextStyleMenus: (): IMenu[] => [], applyTableCellStyleHotkey: () => false},"src/protyle/toolbar/inlineStyle.ts": {getInlineStylesCache: () => ({}), getVisibleOrderedStyleKeys: (): string[] => [],@@ -132,33 +147,47 @@ const browserCases = async (sources: Record<string, string>) => {wysiwyg: {element: editor}, lute: {}, block: {rootID: "root"}} as unknown as IProtyle;const core = new TableControl(owner, editor);owner.wysiwyg.tableControl = core;- const table = editor.querySelector("table");- const cell = (row: number, col: number) => table.rows[row].cells[col];+ const cell = (row: number, col: number) => editor.querySelector("table").rows[row].cells[col];const render = () => Reflect.get(core, "render").call(core);const invoke = (name: string, ...args: unknown[]) => Reflect.get(core, name).apply(core, args);- const touch = (selector: string) => root.querySelector<HTMLElement>(".protyle-table-control " + selector);+ const touch = (selector: string) => root.querySelector<HTMLElement>(selector);const dispose = () => { core.destroy(); root.remove(); getSelection().removeAllRanges(); };- return {root, editor, owner, core, table, cell, render, invoke, touch, dispose};+ return {root, editor, owner, core, get table() { return editor.querySelector("table"); }, cell, render, invoke, touch, dispose};};{const f = fixture();check.equal(f.core.startTouchSelection(f.cell(1, 0)), true);f.render();- check.equal(f.touch("[data-action='done']").textContent, "tableSelectionDone");+ const toolbar = f.touch(".protyle-table-control__toolbar");+ check.equal(toolbar.querySelector(".multiSelectCount").textContent, "1");+ check.equal(toolbar.classList.contains("protyle-util--mobile"), true);const active = f.core.getSelectedCells()[0];pointer(f.cell(2, 2), "pointerdown", 210, 150);pointer(f.cell(2, 2), "pointermove", 200, 100);pointer(f.cell(2, 2), "pointercancel", 200, 100);check.equal(f.core.getSelectedCells()[0], active, "scroll gestures preserve the selection");- f.touch("[data-action='multi']").click();+ const multi = f.touch("[data-type='multi']");+ pointer(multi, "pointerdown");+ check.equal(f.core.hasTouchSelection(), true, "touching the top toolbar retains the table selection");+ pointer(multi, "pointerup");+ multi.click();f.cell(2, 2).click();f.render();check.equal(f.core.getSelectedCells().length, 2);- check.equal((f.touch("[data-action='copy']") as HTMLButtonElement).disabled, true, "nonrectangular copying stays disabled");+ check.equal(toolbar.querySelector(".multiSelectCount").textContent, "2");+ check.equal((f.touch("[data-type='copy']") as HTMLButtonElement).disabled, true, "nonrectangular copying stays disabled");f.cell(2, 2).click();check.equal(f.core.getSelectedCells().length, 1);- f.touch("[data-action='done']").click();+ f.touch("[data-type='selectAll']").click();+ check.equal(f.core.getSelectedCells().length, 12);+ f.touch("[data-type='menu']").click();+ check.equal(items.some(item => item.label === "mergeCell"), true, "the shared menu button opens table operations");+ pointer(menuScrim, "pointerdown");+ check.equal(f.core.hasTouchSelection(), true, "dismissing the menu sheet preserves the selection");+ f.touch("[data-type='exitMultiSelectMode']").click();check.equal(f.core.hasTouchSelection(), false);+ f.render();+ check.equal(toolbar.classList.contains("fn__none"), true);check.equal(f.table.rows.length, 4);f.dispose();}@@ -245,17 +274,20 @@ const browserCases = async (sources: Record<string, string>) => {check.equal(f.table.rows.length, 3, "shrinking preserves all nonempty rows");f.dispose();}- {+ for (const mode of ["row", "column"] as const) {const f = fixture();- f.core.startTouchSelection(f.cell(1, 0), "row");+ f.core.startTouchSelection(f.cell(1, 0), mode);f.render();- const handle = f.touch("[data-mode='row'][aria-pressed='true']");+ const handle = f.touch(`[data-mode='${mode}'][aria-pressed='true']`);const rect = handle.getBoundingClientRect();pointer(handle, "pointerdown", rect.left + rect.width / 2, rect.top + rect.height / 2);- pointer(document, "pointermove", rect.left, 490);- pointer(document, "pointerup", rect.left, 490);+ const x = mode === "row" ? rect.left : 350;+ const y = mode === "row" ? 490 : rect.top;+ pointer(document, "pointermove", x, y);+ pointer(document, "pointerup", x, y);await tick();- check.equal(f.table.rows[3].textContent, "A1A2A3", "row drag uses the shared reorder transaction");+ check.equal(mode === "row" ? f.table.rows[3].textContent : f.table.rows[1].textContent,+ mode === "row" ? "A1A2A3" : "A2A3A1", "touch row and column dragging uses the shared reorder transaction");f.dispose();}{@@ -305,6 +337,71 @@ const browserCases = async (sources: Record<string, string>) => {check.equal(f.cell(2, 2).textContent, "B3", "disabled editors reject stale toolbar actions");f.dispose();}+ {+ const f = fixture();+ f.core.startTouchSelection(f.cell(1, 0));+ f.core.selectCellRange(f.cell(1, 0), f.cell(2, 1));+ const selected = f.core.getSelectedCells();+ f.invoke("setCellStyle", "background-color", "rgb(255, 0, 0)");+ f.invoke("setCellStyle", "text-align", "center");+ f.invoke("setCellStyle", "vertical-align", "bottom");+ check.equal(selected.every(cell => cell.style.backgroundColor === "rgb(255, 0, 0)" &&+ cell.style.textAlign === "center" && cell.style.verticalAlign === "bottom"), true);+ check.equal(f.cell(1, 2).getAttribute("style").includes("text-align"), false, "batch styles preserve other cells");+ await f.invoke("writeTouchClipboard", false, true);+ check.equal(clipboard.at(-1).textSiyuan, undefined, "rich text copying uses standard HTML");+ check.match(clipboard.at(-1).textHTML, /A1.*A2.*B1.*B2/);+ await f.invoke("writeTouchClipboard", true);+ check.equal(selected.every(cell => cell.textContent === ""), true, "successful cutting clears only the selected cells");+ check.equal(f.cell(1, 2).textContent, "A3");+ f.dispose();+ }+ {+ const f = fixture();+ f.core.startTouchSelection(f.cell(1, 0));+ await f.invoke("paste");+ check.equal(pasted.at(-1).target, f.cell(1, 0), "touch paste targets the selection's first cell");+ check.equal(pasted.at(-1).textPlain, "pasted");+ const count = pasted.length;+ let release: () => void;+ clipboardWait = new Promise(resolve => { release = resolve; });+ const pending = f.invoke("paste");+ f.core.startTouchSelection(f.cell(2, 2));+ release();+ await pending;+ check.equal(pasted.length, count, "a delayed clipboard read cannot paste into a changed selection");+ clipboardWait = undefined;+ f.dispose();+ }+ for (const mode of ["row", "column"] as const) {+ const f = fixture();+ f.core.startTouchSelection(f.cell(1, 1), mode);+ f.invoke("duplicateRowsOrColumns");+ check.equal(mode === "row" ? f.table.rows.length : f.table.rows[1].cells.length, mode === "row" ? 5 : 4);+ f.invoke("deleteSelection", false);+ check.equal(f.table.rows.length, 4);+ check.equal(f.table.rows[1].cells.length, 3);+ check.equal(f.cell(1, 1).textContent, "A2", "deleting duplicates preserves the original row or column");+ f.core.startTouchSelection(f.cell(1, 1), mode);+ await f.invoke("writeTouchClipboard", true);+ check.equal(mode === "row" ? f.table.rows.length : f.table.rows[1].cells.length, mode === "row" ? 3 : 2);+ check.equal(f.cell(0, 0).textContent, "H1", "cutting a body row or column preserves the header");+ f.dispose();+ }+ {+ const f = fixture();+ f.core.startTouchSelection(f.cell(1, 0));+ f.render();+ f.touch("[data-action='add-column']").click();+ check.equal(f.table.rows[1].cells.length, 4);+ f.core.startTouchSelection(f.cell(1, 0));+ f.render();+ f.touch("[data-action='add-both']").click();+ check.equal(f.table.rows.length, 5);+ check.equal(f.table.rows[1].cells.length, 5);+ check.equal(f.cell(1, 0).textContent, "A1");+ f.dispose();+ }{const f = fixture();const detached = Array.from(f.table.tBodies[0].rows).slice(1);@@ -346,6 +443,8 @@ const browserCases = async (sources: Record<string, string>) => {f.dispose();}menuElement.remove();+ menuScrim.remove();+ fixtureStyle.remove();return "Mobile table interaction cases passed";};@@ -354,9 +453,11 @@ test("mobile table selection, editing handoff, operations and gesture cancellatitimeout: 45000,}, async () => {const files = ["tableControl", "tableTouch", "table", "tableSelection", "tableResize", "tableColumnWidth", "tableGridCache",- "tableCellRich", "tableCellRichValue", "tableCellRichContext", "tableVirtualizationDOM"];- const sources = Object.fromEntries(files.map(file => ["src/protyle/util/" + file + ".ts", transpileModule(- readFileSync(path.join(__dirname, file + ".ts"), "utf8"),+ "tableCellRich", "tableCellRichValue", "tableCellRichContext", "tableVirtualizationDOM"]+ .map(file => "src/protyle/util/" + file + ".ts");+ files.push("src/mobile/util/multiSelectToolbar.ts");+ const sources = Object.fromEntries(files.map(file => [file, transpileModule(+ readFileSync(path.resolve(process.cwd(), file), "utf8"),{compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022}}).outputText]));const temporary = mkdtempSync(path.join(tmpdir(), "siyuan-table-touch-test-"));const script = path.join(temporary, "run.cjs");diff --git a/app/src/protyle/util/tableTouch.ts b/app/src/protyle/util/tableTouch.tsindex 71e0b6a600..eeac69c65b 100644--- a/app/src/protyle/util/tableTouch.ts+++ b/app/src/protyle/util/tableTouch.ts@@ -1,6 +1,7 @@import type {ITableGrid} from "./table";-import {escapeAttr} from "../../util/escape";import {TABLE_VIRTUAL_ROWS} from "./tableVirtualizationDOM";+import {renderMultiSelectToolbar, updateMultiSelectToolbar} from "../../mobile/util/multiSelectToolbar";+import {TABLE_ADD_CONTROL_GAP, TABLE_ADD_CONTROL_THICKNESS} from "./tableResize";type SelectionMode = "cell" | "row" | "column";@@ -26,6 +27,7 @@ interface ITableTouchActions {add: (cell: HTMLTableCellElement, type: "add-row" | "add-column" | "add-both") => void;width: (event: PointerEvent, cell: HTMLTableCellElement, column: number) => void;menu: () => void;+ selectAll: () => void;copy: () => void;clear: () => void;finish: () => void;@@ -48,12 +50,27 @@ export class TableTouchControl {container.classList.add("protyle-table-control--touch");container.dataset.preventSwipe = "true";this.controls.dataset.tableTouchControls = "true";- this.toolbar.className = "protyle-table-control__toolbar fn__none";- this.toolbar.innerHTML = `<button class="block__icon block__icon--show block__icon--touch" data-action="multi" aria-label="${escapeAttr(window.siyuan.languages.multiSelect)}"><svg><use xlink:href="#iconSelect"></use></svg></button>-<button class="block__icon block__icon--show block__icon--touch" data-action="copy" aria-label="${escapeAttr(window.siyuan.languages.copy)}"><svg><use xlink:href="#iconCopy"></use></svg></button>-<button class="block__icon block__icon--show block__icon--touch" data-action="clear" aria-label="${escapeAttr(window.siyuan.languages.clear)}"><svg><use xlink:href="#iconClear"></use></svg></button>-<button class="block__icon block__icon--show block__icon--touch" data-action="more" aria-label="${escapeAttr(window.siyuan.languages.more)}"><svg><use xlink:href="#iconMore"></use></svg></button>-<button class="b3-button b3-button--text" data-action="done">${window.siyuan.languages.tableSelectionDone}</button>`;+ this.toolbar.className = "protyle-util protyle-util--mobile protyle-table-control__toolbar fn__none";+ this.toolbar.dataset.preventSwipe = "true";+ renderMultiSelectToolbar(this.toolbar, 0, actions.menu, actions.finish, actions.selectAll, [{+ type: "multi",+ icon: "iconSelect",+ label: window.siyuan.languages.multiSelect,+ click: () => {+ this.multiSelect = !this.multiSelect;+ this.actions.render();+ },+ }, {+ type: "copy",+ icon: "iconCopy",+ label: window.siyuan.languages.copy,+ click: actions.copy,+ }, {+ type: "clear",+ icon: "iconClear",+ label: window.siyuan.languages.clear,+ click: actions.clear,+ }]);this.toolbar.setAttribute("role", "toolbar");this.toolbar.setAttribute("aria-label", window.siyuan.languages.table);this.endpoints = ["start", "end"].map(endpoint => {@@ -64,29 +81,15 @@ export class TableTouchControl {button.setAttribute("aria-label", window.siyuan.languages.tableSelectRange);return button;});- container.append(this.controls, ...this.endpoints, this.toolbar);+ container.append(this.controls, ...this.endpoints);+ container.after(this.toolbar);const signal = this.controller.signal;this.toolbar.addEventListener("pointerdown", event => event.preventDefault(), {signal});- this.toolbar.addEventListener("click", event => {- const action = (event.target as Element).closest<HTMLElement>("[data-action]")?.dataset.action;- if (action === "multi") {- this.multiSelect = !this.multiSelect;- this.actions.render();- } else if (action === "copy") {- this.actions.copy();- } else if (action === "clear") {- this.actions.clear();- } else if (action === "more") {- this.actions.menu();- } else if (action === "done") {- this.actions.finish();- }- }, {signal});this.endpoints.forEach(button => button.addEventListener("pointerdown", event =>this.startRangeDrag(event, button.dataset.endpoint === "start"), {signal}));// 点击改变选区,滑动内容仍交给浏览器滚动,不在 pointerdown 阶段阻止默认行为。editor.addEventListener("click", event => {- const state = this.actions.state();+ const state = this.getState();const cell = (event.target as Element).closest<HTMLTableCellElement>("th, td");if (!state?.selection || !cell || cell.closest("table") !== state.table) {return;@@ -108,6 +111,10 @@ export class TableTouchControl {this.cancelGesture();}+ public containsToolbar(target: Node) {+ return this.toolbar.contains(target);+ }+public destroy() {this.reset();this.controller.abort();@@ -117,12 +124,18 @@ export class TableTouchControl {}public render() {- const state = this.actions.state();- this.toolbar.classList.toggle("fn__none", !state?.selection);- const multi = this.toolbar.querySelector('[data-action="multi"]');+ const wasHidden = this.toolbar.classList.contains("fn__none");+ const selecting = !!this.actions.state()?.selection;+ this.toolbar.classList.toggle("fn__none", !selecting);+ if (selecting && wasHidden) {+ this.toolbar.style.zIndex = (++window.siyuan.zIndex).toString();+ }+ const state = this.getState();+ updateMultiSelectToolbar(this.toolbar, state?.selection?.cells.length || 0);+ const multi = this.toolbar.querySelector('[data-type="multi"]');multi.setAttribute("aria-pressed", String(this.multiSelect));multi.classList.toggle("block__icon--active", this.multiSelect);- const copy = this.toolbar.querySelector<HTMLButtonElement>('[data-action="copy"]');+ const copy = this.toolbar.querySelector<HTMLButtonElement>('[data-type="copy"]');copy.disabled = !!state?.selection && state.selection.mode === "cell" && !state.selection.rectangle;if (this.dragging) {this.renderEndpoints(state);@@ -148,9 +161,11 @@ export class TableTouchControl {rows.add(info.row);const row = this.button(window.siyuan.languages.row, "iconDrag", viewport.left - 14,(Math.max(rect.top, viewport.top) + Math.min(rect.bottom, viewport.bottom)) / 2);+ row.className = "protyle-table-control__handle protyle-table-control__handle--row protyle-table-control__touch-handle";+ row.style.height = `${Math.min(rect.bottom, viewport.bottom) - Math.max(rect.top, viewport.top)}px`;row.dataset.mode = "row";row.setAttribute("aria-pressed", String(selection?.mode === "row" && selection.indexes.has(info.row)));- row.classList.toggle("block__icon--active", selection?.mode === "row" && selection.indexes.has(info.row));+ row.classList.toggle("protyle-table-control__handle--active", selection?.mode === "row" && selection.indexes.has(info.row));row.addEventListener("pointerdown", event => this.selectHandle(event, info.cell, "row", row));}// 列控件只按逻辑列创建一次,支持没有表头的表格。@@ -158,9 +173,11 @@ export class TableTouchControl {columns.add(info.col);const column = this.button(window.siyuan.languages.column, "iconDrag",(Math.max(rect.left, viewport.left) + Math.min(rect.right, viewport.right)) / 2, viewport.top - 14);+ column.className = "protyle-table-control__handle protyle-table-control__handle--column protyle-table-control__touch-handle";+ column.style.width = `${Math.min(rect.right, viewport.right) - Math.max(rect.left, viewport.left)}px`;column.dataset.mode = "column";column.setAttribute("aria-pressed", String(selection?.mode === "column" && selection.indexes.has(info.col)));- column.classList.toggle("block__icon--active", selection?.mode === "column" && selection.indexes.has(info.col));+ column.classList.toggle("protyle-table-control__handle--active", selection?.mode === "column" && selection.indexes.has(info.col));column.addEventListener("pointerdown", event => this.selectHandle(event, info.cell, "column", column));}});@@ -188,14 +205,18 @@ export class TableTouchControl {});}const tableRect = table.getBoundingClientRect();+ const addOffset = TABLE_ADD_CONTROL_GAP + TABLE_ADD_CONTROL_THICKNESS / 2;if (tableRect.bottom <= viewport.bottom + 1) {- this.addResize(cell, "add-row", viewport.left + (viewport.right - viewport.left) / 2, tableRect.bottom + 14);+ this.addResize(cell, "add-row", viewport.left + (viewport.right - viewport.left) / 2,+ tableRect.bottom + addOffset, viewport.right - viewport.left, TABLE_ADD_CONTROL_THICKNESS);}if (tableRect.right <= viewport.right + 1) {- this.addResize(cell, "add-column", tableRect.right + 14, viewport.top + (viewport.bottom - viewport.top) / 2);+ this.addResize(cell, "add-column", tableRect.right + addOffset,+ viewport.top + (viewport.bottom - viewport.top) / 2, TABLE_ADD_CONTROL_THICKNESS, viewport.bottom - viewport.top);}if (tableRect.bottom <= viewport.bottom + 1 && tableRect.right <= viewport.right + 1) {- this.addResize(cell, "add-both", tableRect.right + 14, tableRect.bottom + 14);+ this.addResize(cell, "add-both", tableRect.right + addOffset, tableRect.bottom + addOffset,+ TABLE_ADD_CONTROL_THICKNESS, TABLE_ADD_CONTROL_THICKNESS);}this.renderEndpoints(state);}@@ -238,13 +259,21 @@ export class TableTouchControl {return button;}+ private getState() {+ const state = this.actions.state();+ if (state?.selection && !this.toolbar.classList.contains("fn__none")) {+ state.viewport.top = Math.max(state.viewport.top, this.toolbar.getBoundingClientRect().bottom + 28);+ }+ return state;+ }+private selectHandle(event: PointerEvent, cell: HTMLTableCellElement, mode: "row" | "column", handle: HTMLElement) {if (event.button !== 0) {return;}event.preventDefault();event.stopPropagation();- const state = this.actions.state();+ const state = this.getState();// 拖动已选行列时保留整个选区,多选开关开启后点击手柄切换选中状态。const selected = state?.selection?.mode === mode && state.selection.cells.includes(cell);if ((!selected || this.multiSelect) && !this.actions.select(cell, mode, this.multiSelect)) {@@ -256,12 +285,17 @@ export class TableTouchControl {}}- private addResize(cell: HTMLTableCellElement, type: "add-row" | "add-column" | "add-both", x: number, y: number) {+ private addResize(cell: HTMLTableCellElement, type: "add-row" | "add-column" | "add-both",+ x: number, y: number, width: number, height: number) {const button = this.button(type === "add-column" ? window.siyuan.languages.tableAddColumnTip :window.siyuan.languages.tableAddRowTip, type === "add-both" ? "iconMove" : "iconAdd", x, y);button.dataset.action = type;+ button.className = `protyle-table-control__add protyle-table-control__add--${type.substring(4)} protyle-table-control__touch-add`;+ button.style.width = `${width}px`;+ button.style.height = `${height}px`;button.addEventListener("pointerdown", event => {event.preventDefault();+ button.classList.add("protyle-table-control__add--active");this.holdControls(event);this.actions.resize(event, cell, type);});@@ -283,7 +317,7 @@ export class TableTouchControl {}private startRangeDrag(event: PointerEvent, start: boolean) {- const state = this.actions.state();+ const state = this.getState();if (event.button !== 0 || !state?.selection?.cells.length) {return;}@@ -306,7 +340,7 @@ export class TableTouchControl {const signal = controller.signal;let point = {clientX: event.clientX, clientY: event.clientY};const update = () => {- const current = this.actions.state();+ const current = this.getState();if (!current?.selection) {this.cancelGesture();return;@@ -342,7 +376,7 @@ export class TableTouchControl {document.addEventListener("pointerup", end, {signal});document.addEventListener("pointercancel", end, {signal});const scroll = () => {- const current = this.actions.state();+ const current = this.getState();if (!this.gesture || !current?.selection) {return;}