Skip to content

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

:sparkles: Add database row shortcuts and restore mobile navigation https://github.com/siyuan-note/siyuan/issues/20407

Danielb5fbde8f7e57
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 2ade992179..9563e91cbe 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "إدخال قاعدة البيانات السابق",
+ "nextDatabaseRow": "إدخال قاعدة البيانات التالي",
"dynamicRefTextRefreshRetry": "تم حفظ تعديلاتك، ولكن تعذر تحديث بعض نصوص المراجع. سيعيد SiYuan المحاولة تلقائيًا.",
"clearingUnusedAssets": "جارٍ تنظيف ملفات الموارد غير المشار إليها...",
"clearingUnusedAttributeViews": "جارٍ تنظيف قواعد البيانات غير المشار إليها...",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 2560042d03..b130ee5ee8 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Vorheriger Datenbankeintrag",
+ "nextDatabaseRow": "Nächster Datenbankeintrag",
"dynamicRefTextRefreshRetry": "Ihre Änderungen wurden gespeichert, aber einige Referenztexte konnten nicht aktualisiert werden. SiYuan versucht es automatisch erneut.",
"clearingUnusedAssets": "Nicht referenzierte Anhänge werden bereinigt...",
"clearingUnusedAttributeViews": "Nicht referenzierte Datenbanken werden bereinigt...",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 9b7b03c338..6e7cee0860 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Previous database entry",
+ "nextDatabaseRow": "Next database entry",
"dynamicRefTextRefreshRetry": "Your edits have been saved, but some reference text could not be refreshed. SiYuan will retry automatically.",
"clearingUnusedAssets": "Cleaning up unreferenced assets...",
"clearingUnusedAttributeViews": "Cleaning up unreferenced databases...",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 3c0d20a2e3..6c3b089124 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Entrada anterior de la base de datos",
+ "nextDatabaseRow": "Siguiente entrada de la base de datos",
"dynamicRefTextRefreshRetry": "Tus cambios se han guardado, pero no se ha podido actualizar parte del texto de las referencias. SiYuan lo intentará de nuevo automáticamente.",
"clearingUnusedAssets": "Limpiando recursos sin referencias...",
"clearingUnusedAttributeViews": "Limpiando bases de datos sin referencias...",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index c6ef84e75a..176b3cee05 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Entrée précédente de la base de données",
+ "nextDatabaseRow": "Entrée suivante de la base de données",
"dynamicRefTextRefreshRetry": "Vos modifications ont été enregistrées, mais certains textes de référence n’ont pas pu être actualisés. SiYuan réessaiera automatiquement.",
"clearingUnusedAssets": "Nettoyage des ressources non référencées...",
"clearingUnusedAttributeViews": "Nettoyage des bases de données non référencées...",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index f621b3756c..b982a2f1ce 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "הרשומה הקודמת במסד הנתונים",
+ "nextDatabaseRow": "הרשומה הבאה במסד הנתונים",
"dynamicRefTextRefreshRetry": "העריכות נשמרו, אך לא ניתן היה לרענן חלק מטקסט ההפניות. SiYuan ינסה שוב אוטומטית.",
"clearingUnusedAssets": "מנקה קובצי משאבים ללא הפניות...",
"clearingUnusedAttributeViews": "מנקה מסדי נתונים ללא הפניות...",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index ddcda61e94..0fd69da625 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "पिछली डेटाबेस प्रविष्टि",
+ "nextDatabaseRow": "अगली डेटाबेस प्रविष्टि",
"dynamicRefTextRefreshRetry": "आपके संपादन सहेज लिए गए हैं, लेकिन कुछ संदर्भ पाठ अपडेट नहीं हो सके। SiYuan अपने आप फिर से प्रयास करेगा।",
"clearingUnusedAssets": "बिना संदर्भ वाली संसाधन फ़ाइलें साफ़ की जा रही हैं...",
"clearingUnusedAttributeViews": "बिना संदर्भ वाले डेटाबेस साफ़ किए जा रहे हैं...",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 4a3f8ede6d..0cad5d28eb 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Entri basis data sebelumnya",
+ "nextDatabaseRow": "Entri basis data berikutnya",
"dynamicRefTextRefreshRetry": "Perubahan Anda telah disimpan, tetapi sebagian teks referensi gagal diperbarui. SiYuan akan mencoba lagi secara otomatis.",
"clearingUnusedAssets": "Membersihkan berkas aset yang tidak dirujuk...",
"clearingUnusedAttributeViews": "Membersihkan basis data yang tidak dirujuk...",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index a0dabea0be..a8374e8260 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Voce precedente del database",
+ "nextDatabaseRow": "Voce successiva del database",
"dynamicRefTextRefreshRetry": "Le modifiche sono state salvate, ma alcuni testi dei riferimenti non sono stati aggiornati. SiYuan riproverà automaticamente.",
"clearingUnusedAssets": "Pulizia delle risorse senza riferimenti...",
"clearingUnusedAttributeViews": "Pulizia dei database senza riferimenti...",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index a81c8b716c..2fdcfbf71f 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "前のデータベース項目",
+ "nextDatabaseRow": "次のデータベース項目",
"dynamicRefTextRefreshRetry": "編集内容は保存されましたが、一部の参照テキストを更新できませんでした。自動的に再試行します。",
"clearingUnusedAssets": "未参照のアセットを削除しています...",
"clearingUnusedAttributeViews": "未参照のデータベースを削除しています...",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index f0b8e8f409..cf36535224 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "이전 데이터베이스 항목",
+ "nextDatabaseRow": "다음 데이터베이스 항목",
"dynamicRefTextRefreshRetry": "편집 내용은 저장되었지만 일부 참조 텍스트를 갱신하지 못했습니다. 자동으로 다시 시도합니다.",
"clearingUnusedAssets": "참조되지 않은 자산 파일을 정리하는 중...",
"clearingUnusedAttributeViews": "참조되지 않은 데이터베이스를 정리하는 중...",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index add3849ab9..8e947dfb22 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Vorige databasevermelding",
+ "nextDatabaseRow": "Volgende databasevermelding",
"dynamicRefTextRefreshRetry": "Uw wijzigingen zijn opgeslagen, maar sommige verwijzingsteksten konden niet worden bijgewerkt. SiYuan probeert het automatisch opnieuw.",
"clearingUnusedAssets": "Niet-verwezen bijlagen opruimen...",
"clearingUnusedAttributeViews": "Niet-verwezen databases opruimen...",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 279c0e5dd3..2858fbad33 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Poprzedni wpis w bazie danych",
+ "nextDatabaseRow": "Następny wpis w bazie danych",
"dynamicRefTextRefreshRetry": "Zmiany zostały zapisane, ale nie udało się odświeżyć części tekstów odwołań. SiYuan automatycznie spróbuje ponownie.",
"clearingUnusedAssets": "Czyszczenie nieużywanych zasobów...",
"clearingUnusedAttributeViews": "Czyszczenie nieużywanych baz danych...",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 6afe5bfaf6..3e866ae737 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Entrada anterior do banco de dados",
+ "nextDatabaseRow": "Próxima entrada do banco de dados",
"dynamicRefTextRefreshRetry": "Suas alterações foram salvas, mas alguns textos de referência não puderam ser atualizados. O SiYuan tentará novamente automaticamente.",
"clearingUnusedAssets": "Limpando recursos sem referências...",
"clearingUnusedAttributeViews": "Limpando bancos de dados sem referências...",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index a19f613a02..1e9beaf765 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Предыдущая запись базы данных",
+ "nextDatabaseRow": "Следующая запись базы данных",
"dynamicRefTextRefreshRetry": "Изменения сохранены, но часть текста ссылок не удалось обновить. SiYuan автоматически повторит попытку.",
"clearingUnusedAssets": "Очистка ресурсов без ссылок...",
"clearingUnusedAttributeViews": "Очистка баз данных без ссылок...",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index df1ea4ac3a..a4762da3c4 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Predchádzajúca položka databázy",
+ "nextDatabaseRow": "Nasledujúca položka databázy",
"dynamicRefTextRefreshRetry": "Vaše zmeny boli uložené, ale niektoré texty odkazov sa nepodarilo aktualizovať. SiYuan to automaticky skúsi znova.",
"clearingUnusedAssets": "Čistenie súborov príloh bez odkazov...",
"clearingUnusedAttributeViews": "Čistenie databáz bez odkazov...",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index 2bd40c4739..bb455b9032 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Претходни унос базе података",
+ "nextDatabaseRow": "Следећи унос базе података",
"dynamicRefTextRefreshRetry": "Измене су сачуване, али део текста референци није ажуриран. SiYuan ће аутоматски покушати поново.",
"clearingUnusedAssets": "Чишћење датотека ресурса без референци...",
"clearingUnusedAttributeViews": "Чишћење база података без референци...",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 26c70fadb5..f48b06c4ae 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "รายการฐานข้อมูลก่อนหน้า",
+ "nextDatabaseRow": "รายการฐานข้อมูลถัดไป",
"dynamicRefTextRefreshRetry": "บันทึกการแก้ไขแล้ว แต่ไม่สามารถอัปเดตข้อความอ้างอิงบางส่วนได้ SiYuan จะลองใหม่โดยอัตโนมัติ",
"clearingUnusedAssets": "กำลังล้างไฟล์ทรัพยากรที่ไม่มีการอ้างอิง...",
"clearingUnusedAttributeViews": "กำลังล้างฐานข้อมูลที่ไม่มีการอ้างอิง...",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index cbc5318bc6..b0caaf2dfa 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Önceki veritabanı kaydı",
+ "nextDatabaseRow": "Sonraki veritabanı kaydı",
"dynamicRefTextRefreshRetry": "Düzenlemeleriniz kaydedildi ancak bazı başvuru metinleri yenilenemedi. SiYuan otomatik olarak yeniden deneyecek.",
"clearingUnusedAssets": "Başvurulmayan kaynak dosyaları temizleniyor...",
"clearingUnusedAttributeViews": "Başvurulmayan veritabanları temizleniyor...",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 52a4ab5ea9..fce1845f38 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "Попередній запис бази даних",
+ "nextDatabaseRow": "Наступний запис бази даних",
"dynamicRefTextRefreshRetry": "Зміни збережено, але частину тексту посилань не вдалося оновити. SiYuan автоматично повторить спробу.",
"clearingUnusedAssets": "Очищення ресурсів без посилань...",
"clearingUnusedAttributeViews": "Очищення баз даних без посилань...",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 3c6e4762e7..417bd474ef 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "上一条数据库条目",
+ "nextDatabaseRow": "下一条数据库条目",
"dynamicRefTextRefreshRetry": "编辑已保存,但部分引用文本刷新失败,思源将自动重试。",
"clearingUnusedAssets": "正在清理未引用的资源文件...",
"clearingUnusedAttributeViews": "正在清理未引用的数据库...",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 2f7c9e62d3..ba76c1eabd 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,6 @@
{
+ "previousDatabaseRow": "上一筆資料庫項目",
+ "nextDatabaseRow": "下一筆資料庫項目",
"dynamicRefTextRefreshRetry": "編輯已儲存,但部分引用文字更新失敗,思源將自動重試。",
"clearingUnusedAssets": "正在清理未引用的資源檔案...",
"clearingUnusedAttributeViews": "正在清理未引用的資料庫...",
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 98d54ce3cb..4352c5aa94 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
@@ -7,7 +7,7 @@
"id": "20200924100950-9op5xi1",
"title": "Shortcuts",
"type": "doc",
- "updated": "20261010202520"
+ "updated": "20261011091952"
},
"Children": [
{
@@ -66,6 +66,47 @@
}
]
},
+ {
+ "ID": "20261011091952-wqpp0rc",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261011091952-wqpp0rc",
+ "updated": "20261011091952"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "In "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Settings"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Keymap"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "General"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ", configure “Previous database entry” and “Next database entry” to switch between entries in the current preview using the source view’s filters and sort order. These shortcuts are unassigned by default and also work with an external keyboard on mobile. Navigation is available when the preview is opened from a database view; it stops at the first and last entries."
+ }
+ ]
+ },
{
"ID": "20261002010621-zd9bn2e",
"Type": "NodeParagraph",
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 63786ccd8a..42c0c8b26c 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
@@ -7,7 +7,7 @@
"id": "20200813004551-gm0pbn1",
"title": "快捷键",
"type": "doc",
- "updated": "20261010202520"
+ "updated": "20261011091952"
},
"Children": [
{
@@ -66,6 +66,47 @@
}
]
},
+ {
+ "ID": "20261011091952-vdfybuu",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261011091952-vdfybuu",
+ "updated": "20261011091952"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "在 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "设置"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "快捷键"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "通用"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 中设置「上一条数据库条目」和「下一条数据库条目」,可在当前预览中按来源视图的筛选和排序切换条目。默认未绑定快捷键,移动端连接外接键盘后也可使用。从数据库视图打开预览时可切换条目,到达首尾后不再继续切换。"
+ }
+ ]
+ },
{
"ID": "20261002010621-3c1s74q",
"Type": "NodeParagraph",
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 bab20f3b63..0a0b745008 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
@@ -7,7 +7,7 @@
"id": "20211226122549-jktxego",
"title": "快捷鍵",
"type": "doc",
- "updated": "20261010202520"
+ "updated": "20261011091952"
},
"Children": [
{
@@ -66,6 +66,47 @@
}
]
},
+ {
+ "ID": "20261011091952-z1utga6",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261011091952-z1utga6",
+ "updated": "20261011091952"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "在 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "設定"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "快速鍵"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "通用"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 中設定「上一筆資料庫項目」和「下一筆資料庫項目」,可在目前預覽中依來源檢視的篩選和排序切換項目。預設未綁定快速鍵,行動裝置連接外接鍵盤後也可使用。從資料庫檢視開啟預覽時可切換項目,到達首尾後不再繼續切換。"
+ }
+ ]
+ },
{
"ID": "20261002010621-im1xicd",
"Type": "NodeParagraph",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
index 61123fc3e7..4a871bd756 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
@@ -9,7 +9,7 @@
"id": "20240530101000-xsbxokr",
"title": "ショートカット",
"type": "doc",
- "updated": "20261010202520"
+ "updated": "20261011091952"
},
"Children": [
{
@@ -64,6 +64,43 @@
}
]
},
+ {
+ "ID": "20261011091952-yanstq2",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261011091952-yanstq2",
+ "updated": "20261011091952"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "設定"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "ショートカット"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "一般"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " で「前のデータベース項目」と「次のデータベース項目」を設定すると、現在のプレビュー内で元のビューの絞り込みと並び順に従って項目を切り替えられます。初期状態ではショートカットは未割り当てです。モバイル端末でも外付けキーボードで利用できます。データベースのビューからプレビューを開いた場合に利用でき、先頭と末尾では切り替えを停止します。"
+ }
+ ]
+ },
{
"ID": "20261002010621-mogxh00",
"Type": "NodeParagraph",
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scss
index 12d5267fe7..72f9d6efaa 100644
--- a/app/src/assets/scss/main/_mobile.scss
+++ b/app/src/assets/scss/main/_mobile.scss
@@ -635,6 +635,24 @@ body.mobile-topbar--merged {
// 绝对定位的主编辑器需继承键盘占位,保持软键盘与工具栏菜单切换时的滚动视口高度。
padding-bottom: inherit;
+ &.protyle--database-row-navigation {
+ --mobile-breadcrumb-height: 86px;
+
+ > .protyle-breadcrumb {
+ flex-wrap: wrap;
+ align-content: start;
+
+ > [data-type="mobile-menu"] {
+ min-height: 42px;
+ }
+ }
+
+ .protyle-breadcrumb__navigation--mobile {
+ flex-basis: 100%;
+ min-height: 44px;
+ }
+ }
+
> .protyle-breadcrumb {
position: absolute;
top: var(--mobile-topbar-height);
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index 6b5352dba4..b0a8361f87 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -45,6 +45,7 @@ import {escapeHtml} from "../../util/escape";
import {syncGuide} from "../../sync/syncGuide";
import {duplicateBlock, getStartEndElement} from "../../protyle/wysiwyg/commonHotkey";
import {handleDocumentBoundaryHotkey} from "../../protyle/util/documentBoundaryHotkey";
+import {handleDatabaseRowShortcut} from "../../command/databaseRowShortcut";
import {getNextFileLi, getPreviousFileLi} from "../../protyle/wysiwyg/getBlock";
import {Backlink} from "../../layout/dock/Backlink";
/// #if !BROWSER
@@ -1333,6 +1334,10 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
return;
}
+ if (handleDatabaseRowShortcut(app, event)) {
+ return;
+ }
+
let readonlyBlockSelection: IProtyle;
if (event.key === "Escape" && !event.isComposing && !event.repeat) {
const selection = getSelection();
diff --git a/app/src/boot/globalEvent/readonlyKeydown.test.ts b/app/src/boot/globalEvent/readonlyKeydown.test.ts
index 6723354e96..1dd47309fb 100644
--- a/app/src/boot/globalEvent/readonlyKeydown.test.ts
+++ b/app/src/boot/globalEvent/readonlyKeydown.test.ts
@@ -3,6 +3,7 @@ import {readFileSync} from "node:fs";
import {test} from "node:test";
import {runInNewContext} from "node:vm";
import {createSourceFile, isVariableStatement, ModuleKind, ScriptTarget, transpileModule} from "typescript";
+import {DATABASE_ROW_COMMANDS} from "../../command/databaseRowNavigation";
const loadFunction = (path: string, name: string, globals: Record<string, unknown>) => {
const source = createSourceFile(path, readFileSync(path, "utf8"), ScriptTarget.ES2021, true);
@@ -14,7 +15,8 @@ const loadFunction = (path: string, name: string, globals: Record<string, unknow
}).outputText;
const exports: any = {};
runInNewContext(compiled, {exports,
- handleDocumentBoundaryHotkey: () => false, ...globals});
+ handleDocumentBoundaryHotkey: () => false, handleDatabaseRowShortcut: () => false,
+ DATABASE_ROW_COMMANDS, ...globals});
return exports.subject;
};
diff --git a/app/src/command/databaseRowNavigation.ts b/app/src/command/databaseRowNavigation.ts
new file mode 100644
index 0000000000..b0282f9cef
--- /dev/null
+++ b/app/src/command/databaseRowNavigation.ts
@@ -0,0 +1,24 @@
+import type {ICommandContextSnapshot} from "./types";
+
+export const DATABASE_ROW_COMMANDS = ["previousDatabaseRow", "nextDatabaseRow"] as const;
+
+export const getDatabaseRowNavigationButton = (context: ICommandContextSnapshot, command: string) => {
+ if (!DATABASE_ROW_COMMANDS.some(item => item === command) ||
+ context.focus === "fileTree" || context.focus === "dock") {
+ return;
+ }
+ const active = context.activeElement;
+ const mobileRow = active?.closest(".protyle-db-row--mobile") ||
+ (context.environment.endsWith("mobile") ? active?.ownerDocument.querySelector(".protyle-db-row--mobile") : undefined);
+ // 字段编辑弹层和其他对话框保持各自的键盘操作,不切换后面的条目。
+ if (active?.closest("input, textarea, select, .av__panel, .b3-menu") ||
+ (active?.closest(".b3-dialog") && !mobileRow?.contains(active))) {
+ return;
+ }
+ const root = mobileRow || context.activeTab?.element || context.protyle?.element;
+ if (!root?.isConnected || root.closest(".fn__none")) {
+ return;
+ }
+ const direction = command === "previousDatabaseRow" ? "previous" : "next";
+ return root.querySelector<HTMLButtonElement>(`[data-database-row-navigation] [data-row-navigation="${direction}"]`) || undefined;
+};
diff --git a/app/src/command/databaseRowShortcut.ts b/app/src/command/databaseRowShortcut.ts
new file mode 100644
index 0000000000..6acf2801b5
--- /dev/null
+++ b/app/src/command/databaseRowShortcut.ts
@@ -0,0 +1,25 @@
+import type {App} from "../index";
+import {matchHotKey} from "../protyle/util/hotKey";
+import {captureCommandContext} from "./context";
+import {execByCommand} from "./executor";
+import {DATABASE_ROW_COMMANDS, getDatabaseRowNavigationButton} from "./databaseRowNavigation";
+
+export const handleDatabaseRowShortcut = (app: App, event: KeyboardEvent) => {
+ if (event.defaultPrevented || event.isComposing) {
+ return false;
+ }
+ const command = DATABASE_ROW_COMMANDS.find(key => matchHotKey(window.siyuan.config.keymap.general[key], event));
+ if (!command) {
+ return false;
+ }
+ const context = captureCommandContext({app, source: "shortcut"});
+ if (!getDatabaseRowNavigationButton(context, command)) {
+ return false;
+ }
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) {
+ void execByCommand({command, app, context});
+ }
+ return true;
+};
diff --git a/app/src/command/nativeCatalog.test.ts b/app/src/command/nativeCatalog.test.ts
index 754ffd3a7f..70f5639bf3 100644
--- a/app/src/command/nativeCatalog.test.ts
+++ b/app/src/command/nativeCatalog.test.ts
@@ -21,14 +21,14 @@ const expectedDesktopGeneralKeys = [
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "switchLeftDock", "switchRightDock", "switchBottomDock",
"tabToWindow", "stickSearch", "toggleDock", "toggleLeftDockPanel", "toggleRightDockPanel",
"toggleBottomDockPanel", "unsplitAll", "unsplit", "recentClosed", "increaseEditorFontSize",
- "decreaseEditorFontSize", "resetEditorFontSize", "toggleWin", "switchTab",
+ "decreaseEditorFontSize", "resetEditorFontSize", "toggleWin", "switchTab", "previousDatabaseRow", "nextDatabaseRow",
];
const expectedMobileGeneralKeys = [
"addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch", "lockScreen", "mainMenu", "move",
"newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow", "increaseEditorFontSize",
- "decreaseEditorFontSize", "resetEditorFontSize",
+ "decreaseEditorFontSize", "resetEditorFontSize", "previousDatabaseRow", "nextDatabaseRow",
];
const getSupportedIds = (environment: TNativeCommandEnvironment) => NATIVE_COMMAND_CATALOG
@@ -40,19 +40,19 @@ describe("native command catalog", () => {
assert.deepEqual([...DESKTOP_COMMAND_PANEL_GENERAL_KEYS], expectedDesktopGeneralKeys);
assert.deepEqual([...MOBILE_COMMAND_PANEL_GENERAL_KEYS], expectedMobileGeneralKeys);
assert.deepEqual([...COMMAND_PANEL_EDITOR_KEYS], ["switchReadonly", "switchAdjust"]);
- assert.equal(DESKTOP_COMMAND_PANEL_GENERAL_KEYS.length, 68);
- assert.equal(MOBILE_COMMAND_PANEL_GENERAL_KEYS.length, 26);
+ assert.equal(DESKTOP_COMMAND_PANEL_GENERAL_KEYS.length, 70);
+ assert.equal(MOBILE_COMMAND_PANEL_GENERAL_KEYS.length, 28);
assert.equal(COMMAND_PANEL_EDITOR_KEYS.length, 2);
- assert.equal(NATIVE_COMMAND_CATALOG.length, 70);
+ assert.equal(NATIVE_COMMAND_CATALOG.length, 72);
assert.equal(new Set(NATIVE_COMMAND_CATALOG.map(item => item.id)).size, NATIVE_COMMAND_CATALOG.length);
});
it("filters all five frontends without exposing desktop-only commands", () => {
- assert.equal(getSupportedIds("desktop").length, 70);
- assert.equal(getSupportedIds("desktop-window").length, 70);
- assert.equal(getSupportedIds("browser-desktop").length, 69);
- assert.equal(getSupportedIds("mobile").length, 28);
- assert.equal(getSupportedIds("browser-mobile").length, 28);
+ assert.equal(getSupportedIds("desktop").length, 72);
+ assert.equal(getSupportedIds("desktop-window").length, 72);
+ assert.equal(getSupportedIds("browser-desktop").length, 71);
+ assert.equal(getSupportedIds("mobile").length, 30);
+ assert.equal(getSupportedIds("browser-mobile").length, 30);
assert.equal(getSupportedIds("browser-desktop").includes("core.general.toggleWin"), false);
assert.equal(getSupportedIds("mobile").includes("core.general.graphView"), false);
assert.equal(getSupportedIds("desktop-window").includes("core.general.switchTab"), true);
diff --git a/app/src/command/nativeCatalog.ts b/app/src/command/nativeCatalog.ts
index 7e8f3f1327..50faaae9fd 100644
--- a/app/src/command/nativeCatalog.ts
+++ b/app/src/command/nativeCatalog.ts
@@ -8,14 +8,14 @@ export const DESKTOP_COMMAND_PANEL_GENERAL_KEYS = [
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "switchLeftDock", "switchRightDock", "switchBottomDock",
"tabToWindow", "stickSearch", "toggleDock", "toggleLeftDockPanel", "toggleRightDockPanel",
"toggleBottomDockPanel", "unsplitAll", "unsplit", "recentClosed", "increaseEditorFontSize",
- "decreaseEditorFontSize", "resetEditorFontSize", "toggleWin", "switchTab",
+ "decreaseEditorFontSize", "resetEditorFontSize", "toggleWin", "switchTab", "previousDatabaseRow", "nextDatabaseRow",
] as const;
export const MOBILE_COMMAND_PANEL_GENERAL_KEYS = [
"addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch", "lockScreen", "mainMenu", "move",
"newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow", "increaseEditorFontSize",
- "decreaseEditorFontSize", "resetEditorFontSize",
+ "decreaseEditorFontSize", "resetEditorFontSize", "previousDatabaseRow", "nextDatabaseRow",
] as const;
export const COMMAND_PANEL_EDITOR_KEYS = ["switchReadonly", "switchAdjust"] as const;
diff --git a/app/src/command/nativeCommands.test.ts b/app/src/command/nativeCommands.test.ts
index 8a04ce0ad2..8810e0f3a3 100644
--- a/app/src/command/nativeCommands.test.ts
+++ b/app/src/command/nativeCommands.test.ts
@@ -49,3 +49,45 @@ it("hides publish write commands and rejects their shortcut execution", async ()
}
}
});
+
+it("database entry commands honor navigation boundaries and loading on every frontend", async () => {
+ const original = Object.getOwnPropertyDescriptor(globalThis, "window");
+ const commands = ["previousDatabaseRow", "nextDatabaseRow"];
+ Object.defineProperty(globalThis, "window", {configurable: true, value: {siyuan: {
+ config: {keymap: {general: Object.fromEntries(commands.map(key => [key, {}])), editor: {general: {}}}},
+ }}});
+ try {
+ const app = {};
+ const executed: string[] = [];
+ const previous = {disabled: true};
+ const next = {disabled: false};
+ const element = {
+ isConnected: true,
+ closest: (): null => null,
+ querySelector: (selector: string) => selector.includes('"previous"') ? previous : next,
+ } as unknown as HTMLElement;
+ ensureNativeCommands(app, command => executed.push(command));
+ const registry = getCommandRegistry(app);
+ for (const environment of ["desktop", "desktop-window", "browser-desktop", "mobile", "browser-mobile"] as const) {
+ const context: ICommandContextSnapshot = {
+ app, source: "shortcut", environment, focus: "editor", selectedBlocks: [], activeTab: {element},
+ };
+ const previousID = getNativeCommandId(commands[0]);
+ const nextID = getNativeCommandId(commands[1]);
+ assert.equal((await registry.execute(previousID, context)).status, "disabled");
+ assert.equal((await registry.execute(nextID, context)).status, "executed");
+ next.disabled = true;
+ assert.equal((await registry.execute(nextID, context)).status, "disabled");
+ next.disabled = false;
+ assert.equal((await registry.execute(nextID, {...context, focus: "fileTree"})).status, "disabled");
+ assert.equal((await registry.execute(nextID, {...context, activeTab: undefined})).status, "disabled");
+ }
+ assert.deepEqual(executed, Array(5).fill("nextDatabaseRow"));
+ } finally {
+ if (original) {
+ Object.defineProperty(globalThis, "window", original);
+ } else {
+ Reflect.deleteProperty(globalThis, "window");
+ }
+ }
+});
diff --git a/app/src/command/nativeCommands.ts b/app/src/command/nativeCommands.ts
index c260185b98..690febc8c9 100644
--- a/app/src/command/nativeCommands.ts
+++ b/app/src/command/nativeCommands.ts
@@ -7,6 +7,7 @@ import {
} from "./nativeCatalog";
import {getCommandRegistry} from "./service";
import type {ICommandContextSnapshot, ICommandDefinition} from "./types";
+import {DATABASE_ROW_COMMANDS, getDatabaseRowNavigationButton} from "./databaseRowNavigation";
export type TNativeCommandExecutor = (
command: string,
@@ -28,6 +29,10 @@ const publishUnavailableCommands = new Set([
]);
const matchesContext = (item: INativeCommandCatalogItem, context: ICommandContextSnapshot) => {
+ if (DATABASE_ROW_COMMANDS.some(command => command === item.legacyId)) {
+ const button = getDatabaseRowNavigationButton(context, item.legacyId);
+ return !!button && !button.disabled;
+ }
// 命令面板和快捷键共用只读限制,文档树操作仍按文档树上下文处理。
if (context.focus !== "fileTree" && context.protyle?.disabled &&
["move", "addToDatabase"].includes(item.legacyId)) {
diff --git a/app/src/command/nativeRuntime.ts b/app/src/command/nativeRuntime.ts
index 9e335c7199..6822194ef3 100644
--- a/app/src/command/nativeRuntime.ts
+++ b/app/src/command/nativeRuntime.ts
@@ -9,6 +9,7 @@ import {fetchSyncPost} from "../util/fetch";
import {globalCommand} from "../boot/globalEvent/command/global";
import {onlyProtyleCommand} from "../boot/globalEvent/command/protyle";
import type {ICommandContextSnapshot} from "./types";
+import {DATABASE_ROW_COMMANDS, getDatabaseRowNavigationButton} from "./databaseRowNavigation";
import {isInIOS} from "../protyle/util/compatibility";
/// #if MOBILE
import {popSearch} from "../mobile/menu/search";
@@ -17,6 +18,10 @@ import {openSearch} from "../search/spread";
/// #endif
export const executeLegacyNativeCommand = async (command: string, context: ICommandContextSnapshot) => {
+ if (DATABASE_ROW_COMMANDS.some(item => item === command)) {
+ getDatabaseRowNavigationButton(context, command)?.click();
+ return;
+ }
const app = context.app as App;
const openOnly = ["shortcut", "editorShortcut", "fileTreeShortcut", "dockShortcut", "globalShortcut", "keymap"]
.includes(context.source);
diff --git a/app/src/constants.ts b/app/src/constants.ts
index e3e92cc7e6..f5be52a630 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -498,6 +498,8 @@ export abstract class Constants {
// "⌥↩" 写死,但可自定义
public static readonly SIYUAN_KEYMAP: Config.IKeymap = {
general: {
+ previousDatabaseRow: {default: "", custom: ""},
+ nextDatabaseRow: {default: "", custom: ""},
openContextMenu: {default: "⌘/", custom: "⌘/"},
mainMenu: {default: "⌥\\", custom: "⌥\\"},
commandPanel: {default: "⌥⇧P", custom: "⌥⇧P"},
diff --git a/app/src/mobile/editor.scroll.test.ts b/app/src/mobile/editor.scroll.test.ts
index 1111a29e7b..8f7e64b9b5 100644
--- a/app/src/mobile/editor.scroll.test.ts
+++ b/app/src/mobile/editor.scroll.test.ts
@@ -60,6 +60,7 @@ const setup = (legacy?: IScrollAttr, encrypted = false) => {
getElementById: (id: string) => id === "toolbarName" ? toolbar : {}};
const noop = () => {};
const makeProtyle = (options: IProtyleOptions) => ({
+ element: {querySelector: (): null => null, classList: {remove: noop}},
options: {mode: "wysiwyg"}, notebookId: options.notebookId, path: "/root.sy",
block: {id: options.blockId, rootID: options.rootId},
title: {element: {removeAttribute: noop}},
@@ -121,6 +122,7 @@ const setup = (legacy?: IScrollAttr, encrypted = false) => {
"../protyle/util/trackedRange": {invalidateTrackedRanges: noop},
"../protyle/undo/globalUndo": {initMirror: noop},
"../protyle/render/av/cellEditor": {closeAVCellEditor: noop},
+ "../protyle/render/av/databaseRowNavigation": execute(compile(read("../protyle/render/av/databaseRowNavigation.ts")), {}),
"../plugin/EventBusCore": {forEachPluginSubscriber: noop},
"./util/setEmpty": {setEditor: noop},
"./util/closePanel": {closePanel: noop},
diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts
index c9a64668b2..7643f9449d 100644
--- a/app/src/mobile/editor.ts
+++ b/app/src/mobile/editor.ts
@@ -26,6 +26,7 @@ import {getActiveMobileSecondaryEditor} from "./util/secondaryEditors";
import {closeMobileEditorSheets} from "./util/MobileEditorDialog";
import {invalidateMobileReferenceOpen} from "./util/openReference";
import {closeAVCellEditor} from "../protyle/render/av/cellEditor";
+import {clearDatabaseRowNavigation} from "../protyle/render/av/databaseRowNavigation";
export const getCurrentEditor = () => {
return getActiveMobileSecondaryEditor() || window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
@@ -94,6 +95,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[
return;
}
completed = true;
+ clearDatabaseRowNavigation(protyle.element);
setEditor();
bindMobileBarsScroll(protyle.contentElement, () => {
// 面包屑位移后同步数据库吸顶位置,避免数据库使用上一帧的面包屑位置
diff --git a/app/src/mobile/util/keydown.ts b/app/src/mobile/util/keydown.ts
index 6000e50e91..87aad56a91 100644
--- a/app/src/mobile/util/keydown.ts
+++ b/app/src/mobile/util/keydown.ts
@@ -5,12 +5,17 @@ import {getCurrentEditor} from "../editor";
import {filterHotkey} from "../../boot/globalEvent/commonHotkey";
import {captureShortcutContext, dispatchPluginShortcut} from "../../command/shortcutRuntime";
import {handleDocumentBoundaryHotkey} from "../../protyle/util/documentBoundaryHotkey";
+import {handleDatabaseRowShortcut} from "../../command/databaseRowShortcut";
+import {DATABASE_ROW_COMMANDS} from "../../command/databaseRowNavigation";
export const mobileKeydown = (app: App, event: KeyboardEvent) => {
// 移动端输入框默认填充无 event.key
if (!event.key || event.defaultPrevented || filterHotkey(event, app)) {
return;
}
+ if (handleDatabaseRowShortcut(app, event)) {
+ return;
+ }
const editor = getCurrentEditor();
if (editor?.protyle.element.contains(event.target as Node) && handleDocumentBoundaryHotkey(editor.protyle, event)) {
return;
@@ -20,8 +25,8 @@ export const mobileKeydown = (app: App, event: KeyboardEvent) => {
if (key === "openContextMenu") {
return false;
}
- // 桌面页签菜单不拦截移动端的键盘输入。
- if (key === "switchTab") {
+ // 跳过桌面页签菜单和已由预览上下文处理的条目导航。
+ if (key === "switchTab" || DATABASE_ROW_COMMANDS.some(command => command === key)) {
return false;
}
if (matchHotKey(window.siyuan.config.keymap.general[key], event)) {
diff --git a/app/src/mobile/util/tabShortcut.test.ts b/app/src/mobile/util/tabShortcut.test.ts
index 7c6c0bab7c..c5345c5f9e 100644
--- a/app/src/mobile/util/tabShortcut.test.ts
+++ b/app/src/mobile/util/tabShortcut.test.ts
@@ -4,6 +4,7 @@ import {runInNewContext} from "node:vm";
import {it} from "node:test";
import * as assert from "node:assert/strict";
import * as ts from "typescript";
+import {DATABASE_ROW_COMMANDS} from "../../command/databaseRowNavigation";
it("does not consume the desktop tab menu binding on mobile", () => {
const calls: string[] = [];
@@ -15,6 +16,8 @@ it("does not consume the desktop tab menu binding on mobile", () => {
"../../boot/globalEvent/commonHotkey": {filterHotkey: () => false},
"../../protyle/util/hotKey": {matchHotKey: () => true},
"../../command/executor": {execByCommand: () => calls.push("native")},
+ "../../command/databaseRowShortcut": {handleDatabaseRowShortcut: () => false},
+ "../../command/databaseRowNavigation": {DATABASE_ROW_COMMANDS},
"../editor": {getCurrentEditor: () => ({protyle: {toolbar: {}, element: {contains: () => false}}})},
"../../command/shortcutRuntime": {dispatchPluginShortcut: () => calls.push("plugin")},
};
diff --git a/app/src/protyle/render/av/databaseRowNavigation.ts b/app/src/protyle/render/av/databaseRowNavigation.ts
index ccd745f2d9..1323040ff9 100644
--- a/app/src/protyle/render/av/databaseRowNavigation.ts
+++ b/app/src/protyle/render/av/databaseRowNavigation.ts
@@ -98,20 +98,34 @@ export const getDatabaseRowNeighbors = async (data: IDatabaseRowOpenData) => {
}));
};
+export const clearDatabaseRowNavigation = (container: Element) => {
+ container.querySelector(":scope > [data-database-row-navigation], :scope > .protyle-breadcrumb > [data-database-row-navigation]")?.remove();
+ container.classList.remove("protyle--database-row-navigation");
+};
+
export const mountDatabaseRowNavigation = (container: Element, data: IDatabaseRowOpenData,
open: (data: IDatabaseRowOpenData) => Promise<boolean>, breadcrumb?: HTMLElement) => {
- container.querySelector(":scope > [data-database-row-navigation], :scope > .protyle-breadcrumb > [data-database-row-navigation]")?.remove();
+ clearDatabaseRowNavigation(container);
if (!data.navigation) {
return;
}
const toolbar = document.createElement("div");
const inline = breadcrumb && container.contains(breadcrumb);
+ const mobileRow = inline && container.id === "editor";
toolbar.className = inline ? "protyle-breadcrumb__navigation fn__flex fn__flex-center fn__flex-shrink" : "block__icons";
+ if (mobileRow) {
+ container.classList.add("protyle--database-row-navigation");
+ toolbar.classList.add("protyle-breadcrumb__navigation--mobile");
+ }
toolbar.setAttribute("data-database-row-navigation", data.itemID);
toolbar.innerHTML = ["previous", "next"].map((name, index) =>
- `<button type="button" disabled class="block__icon block__icon--show block__icon--touch ariaLabel" data-position="8south" aria-label="${escapeAttr(window.siyuan.languages[name])}"><svg><use xlink:href="#${index ? "iconDown" : "iconUp"}"></use></svg></button>`)
+ `<button type="button" data-row-navigation="${name}" disabled class="block__icon block__icon--show block__icon--touch ariaLabel" data-position="8south" aria-label="${escapeAttr(window.siyuan.languages[name])}"><svg><use xlink:href="#${index ? "iconDown" : "iconUp"}"></use></svg></button>`)
.join(inline ? "" : '<span class="fn__space"></span>') + (inline ? '<span class="fn__space"></span>' : "");
- (inline ? breadcrumb : container).prepend(toolbar);
+ if (mobileRow) {
+ breadcrumb.append(toolbar);
+ } else {
+ (inline ? breadcrumb : container).prepend(toolbar);
+ }
const buttons = Array.from(toolbar.querySelectorAll("button"));
let busy = false;
const update = async () => {
diff --git a/app/src/protyle/render/av/openDatabaseRow.ts b/app/src/protyle/render/av/openDatabaseRow.ts
index 129cd31f58..9f2f1eb128 100644
--- a/app/src/protyle/render/av/openDatabaseRow.ts
+++ b/app/src/protyle/render/av/openDatabaseRow.ts
@@ -373,7 +373,8 @@ export const openDatabaseRowByData = async (protyle: Pick<IProtyle, "app">, data
undefined, undefined, (editorProtyle) => {
inheritDatabaseRowReadonly(editorProtyle, protyle);
editorProtyle.element.dataset.databaseRowId = data.boundBlockID;
- mountDatabaseRowNavigation(editorProtyle.element, data, next => openDatabaseRowByData(protyle, next));
+ mountDatabaseRowNavigation(editorProtyle.element, data, next => openDatabaseRowByData(protyle, next),
+ editorProtyle.breadcrumb?.element.parentElement);
editorProtyle.databaseAttributePanel?.expand(data.avID);
editorProtyle.contentElement.scrollTop = 0;
editorProtyle.databaseAttributePanel?.afterRender(() => {
diff --git a/app/src/protyle/util/contextMenuHotkey.test.ts b/app/src/protyle/util/contextMenuHotkey.test.ts
index 86bdee399a..6696435344 100644
--- a/app/src/protyle/util/contextMenuHotkey.test.ts
+++ b/app/src/protyle/util/contextMenuHotkey.test.ts
@@ -110,6 +110,7 @@ test("startup adds context menu defaults and preserves an explicitly empty bindi
test("mobile leaves unhandled context menu shortcuts available to plugin dispatch", () => {
let dispatched = 0;
const mobileKeydown = loadFunction("src/mobile/util/keydown.ts", "mobileKeydown", {
+ handleDatabaseRowShortcut: () => false,
getCurrentEditor: (): undefined => undefined,
window: {siyuan: {config: {keymap: {general: {openContextMenu: {custom: "⌘/"}}}}}},
filterHotkey: () => false,
diff --git a/app/src/protyle/util/documentBoundaryHotkey.test.ts b/app/src/protyle/util/documentBoundaryHotkey.test.ts
index dac0a9381b..aa1b854da5 100644
--- a/app/src/protyle/util/documentBoundaryHotkey.test.ts
+++ b/app/src/protyle/util/documentBoundaryHotkey.test.ts
@@ -121,6 +121,8 @@ test("mobile navigation is limited to the current editor and does not dispatch t
const f = fixture();
keymapBindings.setKeymapBindings(f.general.goToDocumentEnd, ["End"]);
const module = loadModule("src/mobile/util/keydown.ts", {window: f.window}, {
+ "../../command/databaseRowShortcut": {handleDatabaseRowShortcut: () => false},
+ "../../command/databaseRowNavigation": {DATABASE_ROW_COMMANDS: ["previousDatabaseRow", "nextDatabaseRow"]},
"../../protyle/util/documentBoundaryHotkey": f.helper,
"../../boot/globalEvent/commonHotkey": {filterHotkey: () => false},
"../editor": {getCurrentEditor: () => ({protyle: f.protyle})},
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index fc425996cf..f2eb1e8aac 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -1416,6 +1416,8 @@ declare namespace Config {
* SiYuan general shortcut keys
*/
export interface IKeymapGeneral extends IKeys {
+ previousDatabaseRow?: IKey;
+ nextDatabaseRow?: IKey;
/** 打开当前焦点的上下文菜单,默认 ⌘/,支持多绑定和解绑。 */
openContextMenu?: IKey;
mainMenu?: IKey;
diff --git a/app/tests/databaseRowNavigation.test.js b/app/tests/databaseRowNavigation.test.js
new file mode 100644
index 0000000000..390a3e85de
--- /dev/null
+++ b/app/tests/databaseRowNavigation.test.js
@@ -0,0 +1,196 @@
+const assert = require("node:assert/strict");
+const {execFile} = require("node:child_process");
+const fs = require("node:fs");
+const os = require("node:os");
+const path = require("node:path");
+const {test} = require("node:test");
+const {promisify} = require("node:util");
+const {ModuleKind, ScriptTarget, transpileModule} = require("typescript");
+const sass = require("sass");
+
+const runCases = async (sources, css) => {
+ const check = require("node:assert/strict");
+ const load = (source, imports = {}) => {
+ const api = {};
+ new Function("require", "exports", source)(name => {
+ check.ok(name in imports, name);
+ return imports[name];
+ }, api);
+ return api;
+ };
+ document.head.innerHTML = "<style>" + css + "</style>";
+ window.siyuan = {languages: {previous: "Previous", next: "Next"}, config: {keymap: {general: {
+ previousDatabaseRow: "ArrowUp", nextDatabaseRow: "ArrowDown",
+ }}}};
+ let rows = ["previous", "current", "next"];
+ let release;
+ let pending;
+ const opened = [];
+ const navigation = load(sources.navigation, {
+ "../../../util/fetch": {fetchSyncPost: async () => ({code: 0, data: {
+ view: {rows: rows.map(id => ({id, cells: [{id: id + "-value", value: {
+ type: "block", isDetached: true, block: {content: id},
+ }}]})), rowCount: rows.length}, target: {status: "visible"},
+ }})},
+ "../../../util/escape": {escapeAttr: String},
+ "./renderData": {isAVRenderData: value => !!value?.view},
+ "./virtualScroll": {getAVData: () => undefined},
+ });
+ const commands = load(sources.commands);
+ let context;
+ const executed = [];
+ const shortcuts = load(sources.shortcuts, {
+ "../protyle/util/hotKey": {matchHotKey: (key, event) => key === event.key},
+ "./context": {captureCommandContext: () => context},
+ "./databaseRowNavigation": commands,
+ "./executor": {execByCommand: ({command}) => {
+ executed.push(command);
+ commands.getDatabaseRowNavigationButton(context, command)?.click();
+ }},
+ });
+ const tick = () => new Promise(resolve => setTimeout(resolve, 0));
+ const data = {avID: "av", databaseBlockID: "carrier", itemID: "current", navigation: {viewID: "view", query: ""}};
+ const open = async next => { opened.push(next.itemID); await pending; return true; };
+ for (const merged of [false, true]) {
+ document.body.className = merged ? "mobile-topbar--merged" : "";
+ document.body.innerHTML = `<div class="toolbar mobile-topbar">Title</div><div id="editor" class="protyle">
+ <div class="protyle-breadcrumb"><button class="protyle-breadcrumb__icon" data-type="mobile-menu">Breadcrumb</button>
+ <span class="protyle-breadcrumb__space${merged ? " protyle-breadcrumb__space--mobile-title" : ""}"></span>
+ <div class="protyle-breadcrumb__plugin"></div>
+ ${["command-panel", "readonly", "doc", "more"].map(type => `<button class="block__icon fn__flex-center" data-type="${type}"><svg></svg></button>`).join("")}
+ </div><div class="protyle-content"><div class="protyle-wysiwyg" contenteditable="true">Content</div></div></div>`;
+ const editor = document.getElementById("editor");
+ const breadcrumb = editor.firstElementChild;
+ navigation.mountDatabaseRowNavigation(editor, data, open, breadcrumb);
+ await tick();
+ const buttons = Array.from(editor.querySelectorAll("[data-row-navigation]"));
+ const toolbar = buttons[0].parentElement;
+ check.equal(toolbar.parentElement, breadcrumb);
+ const firstRow = breadcrumb.firstElementChild.getBoundingClientRect();
+ for (const button of buttons) {
+ check.equal(button.disabled, false);
+ const rect = button.getBoundingClientRect();
+ check.ok(rect.top >= firstRow.bottom, JSON.stringify({merged, rect, firstRow}));
+ check.ok(rect.right <= window.innerWidth);
+ check.ok(button.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2)), "navigation button must not be covered");
+ }
+ const spacer = parseFloat(getComputedStyle(editor.querySelector(".protyle-content"), "::before").height);
+ check.equal(spacer, merged ? 86 : 134);
+ check.ok(breadcrumb.getBoundingClientRect().bottom <= spacer);
+ editor.style.setProperty("--mobile-bar-translate-y", "calc(-1 * (var(--mobile-topbar-height) + var(--mobile-breadcrumb-height)))");
+ if (merged) {
+ check.equal(getComputedStyle(breadcrumb).transform, "none");
+ } else {
+ check.ok(toolbar.getBoundingClientRect().bottom <= 0, "navigation must hide together with mobile bars");
+ }
+ editor.style.removeProperty("--mobile-bar-translate-y");
+
+ const editable = editor.querySelector("[contenteditable]");
+ context = {environment: "browser-mobile", focus: "editor", activeElement: editable, protyle: {element: editor}};
+ check.equal(commands.getDatabaseRowNavigationButton(context, "previousDatabaseRow"), buttons[0]);
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), buttons[1]);
+ const key = (key, extras = {}) => new KeyboardEvent("keydown", {key, cancelable: true, ...extras});
+ const composing = key("ArrowDown", {isComposing: true});
+ check.equal(shortcuts.handleDatabaseRowShortcut({}, composing), false);
+ check.equal(composing.defaultPrevented, false);
+ const before = executed.length;
+ check.equal(shortcuts.handleDatabaseRowShortcut({}, key("ArrowDown", {repeat: true})), true);
+ check.equal(executed.length, before);
+ pending = new Promise(resolve => { release = resolve; });
+ const next = key("ArrowDown");
+ check.equal(shortcuts.handleDatabaseRowShortcut({}, next), true);
+ check.equal(next.defaultPrevented, true);
+ await tick();
+ check.ok(buttons.every(button => button.disabled));
+ const count = opened.length;
+ shortcuts.handleDatabaseRowShortcut({}, key("ArrowDown"));
+ await tick();
+ check.equal(opened.length, count, "loading must reject another navigation");
+ release();
+ await tick();
+ check.equal(opened.at(-1), "next");
+
+ rows = ["current", "next"];
+ navigation.mountDatabaseRowNavigation(editor, data, open, breadcrumb);
+ await tick();
+ check.ok(editor.querySelector('[data-row-navigation="previous"]').disabled);
+ const input = document.createElement("input");
+ editor.append(input);
+ context.activeElement = input;
+ check.equal(shortcuts.handleDatabaseRowShortcut({}, key("ArrowDown")), false);
+ context.activeElement = editable;
+ context.focus = "dock";
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), undefined);
+ context.focus = "editor";
+ navigation.clearDatabaseRowNavigation(editor);
+ check.equal(editor.querySelector("[data-database-row-navigation]"), null);
+ check.equal(parseFloat(getComputedStyle(editor.querySelector(".protyle-content"), "::before").height), merged ? 42 : 90);
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), undefined);
+ rows = ["previous", "current", "next"];
+
+ const tab = document.createElement("div");
+ tab.innerHTML = '<div class="protyle-db-row"></div>';
+ document.body.append(tab);
+ const row = tab.firstElementChild;
+ navigation.mountDatabaseRowNavigation(row, data, open);
+ await tick();
+ context = {environment: "desktop", focus: "global", activeElement: document.body, activeTab: {element: tab}};
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), row.querySelector('[data-row-navigation="next"]'));
+ tab.classList.add("fn__none");
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), undefined);
+ tab.classList.remove("fn__none");
+ tab.classList.add("b3-dialog");
+ row.classList.add("protyle-db-row--mobile");
+ context = {environment: "mobile", focus: "global", activeElement: document.body, protyle: {element: editor}};
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), row.querySelector('[data-row-navigation="next"]'));
+ const otherDialog = document.createElement("div");
+ otherDialog.className = "b3-dialog";
+ document.body.append(otherDialog);
+ context.activeElement = otherDialog;
+ check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), undefined);
+ otherDialog.remove();
+ tab.remove();
+ }
+ return "Database row navigation cases passed";
+};
+
+test("database row navigation remains visible on mobile and scopes keyboard commands to the current preview", {
+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
+ timeout: 60000,
+}, async () => {
+ const sources = Object.fromEntries(Object.entries({
+ navigation: "protyle/render/av/databaseRowNavigation.ts",
+ commands: "command/databaseRowNavigation.ts",
+ shortcuts: "command/databaseRowShortcut.ts",
+ }).map(([key, file]) => [key, transpileModule(fs.readFileSync(path.join(__dirname, "../src", file), "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText]));
+ const css = sass.compile(path.join(__dirname, "../src/assets/scss/mobile.scss"), {logger: sass.Logger.silent}).css;
+ const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "siyuan-row-navigation-test-"));
+ const script = path.join(temporary, "run.cjs");
+ fs.writeFileSync(script, `const {app, BrowserWindow} = require("electron");
+app.setPath("userData", ${JSON.stringify(path.join(temporary, "profile"))});
+app.commandLine.appendSwitch("disable-gpu");
+app.whenReady().then(async () => {
+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false, offscreen: true}});
+ try {
+ await win.loadURL("data:text/html,<html><body></body></html>");
+ for (const width of [320, 390]) {
+ win.setContentSize(width, 844);
+ console.log(await win.webContents.executeJavaScript(${JSON.stringify("(" + runCases.toString() + ")(" + JSON.stringify(sources) + "," + JSON.stringify(css) + ")")}));
+ }
+ win.destroy(); app.exit(0);
+ } catch (error) { console.error(error); win.destroy(); app.exit(1); }
+});`, "utf8");
+ const env = {...process.env};
+ delete env.ELECTRON_RUN_AS_NODE;
+ try {
+ const result = await promisify(execFile)(require("electron"), [script], {env, timeout: 50000, windowsHide: true});
+ assert.equal(result.stdout.match(/Database row navigation cases passed/g)?.length, 2);
+ } finally {
+ if (path.dirname(path.resolve(temporary)) === path.resolve(os.tmpdir()) &&
+ path.basename(temporary).startsWith("siyuan-row-navigation-test-")) {
+ fs.rmSync(temporary, {recursive: true, force: true, maxRetries: 5});
+ }
+ }
+});
diff --git a/app/tests/shortcutOpenPanels.test.js b/app/tests/shortcutOpenPanels.test.js
index 8c15dc6c62..d770aef317 100644
--- a/app/tests/shortcutOpenPanels.test.js
+++ b/app/tests/shortcutOpenPanels.test.js
@@ -115,6 +115,7 @@ test("native shortcut sources open panels without toggling while menu commands r
const source = sourceFile("command/nativeRuntime.ts");
const calls = [];
const subject = prefix(source, arrow(source, "executeLegacyNativeCommand"), "const isFileFocus", {
+ DATABASE_ROW_COMMANDS: ["previousDatabaseRow", "nextDatabaseRow"],
globalCommand: (...args) => {calls.push(args); return true;},
});
for (const commandSource of ["shortcut", "editorShortcut", "fileTreeShortcut", "dockShortcut", "globalShortcut", "keymap", "menu", "api", "commandPanel"]) {