An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support customizable document boundary shortcuts https://github.com/siyuan-note/siyuan/issues/20202
Daniel4b10638cabc4
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex ebbb69fe25..8ae2a2dca4 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "الانتقال إلى بداية المستند",+ "goToDocumentEnd": "الانتقال إلى نهاية المستند","agentBuiltinPluginDevelopmentDescription": "سير العمل الرسمي لتطوير إضافات الواجهة الأمامية: بعد موافقتك الصريحة، تُستوضح المتطلبات الناقصة وتُعتمد خطة موجزة ثم يُنفّذ العمل في نسخة مُدارة ويُتحقّق منه وتُجهّز الحزمة؛ يتطلب التثبيت والتفعيل إذنًا منفصلًا","agentPluginRecoveryQuestion": "هل تريد استعادة نقطة حفظ الشفرة المصدرية للمقترح المعتمد سابقًا فقط؟ لا تتراجع الاستعادة عن الملاحظات أو بيانات وقت التشغيل أو الإعدادات الأخرى، ولا تسمح بإجراء تغييرات إضافية على الشفرة المصدرية.","agentPluginFlowQuestion": "هل تريد استخدام سير العمل الرسمي لتطوير الإضافات؟",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex d6e8dff05c..5e8e4350aa 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Zum Dokumentanfang springen",+ "goToDocumentEnd": "Zum Dokumentende springen","agentBuiltinPluginDevelopmentDescription": "Offizieller Ablauf zur Entwicklung von Frontend-Plugins: Nach deiner ausdrücklichen Zustimmung werden fehlende Anforderungen geklärt, ein kurzer Plan bestätigt und die Umsetzung in einer verwalteten Kopie geprüft und paketiert; Installation und Aktivierung erfordern eine separate Genehmigung","agentPluginRecoveryQuestion": "Nur den Quellcode-Prüfpunkt des zuvor genehmigten Vorschlags wiederherstellen? Die Wiederherstellung setzt weder Notizen noch Laufzeitdaten oder andere Einstellungen zurück und erlaubt keine weiteren Quellcodeänderungen.","agentPluginFlowQuestion": "Den offiziellen Ablauf zur Plugin-Entwicklung verwenden?",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 9a206c5843..05f056cbb5 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Go to document start",+ "goToDocumentEnd": "Go to document end","agentBuiltinPluginDevelopmentDescription": "Official frontend plugin development workflow: after you explicitly opt in, clarify missing requirements, confirm a brief plan, implement in a managed copy, validate, and package; installation and activation require separate authorization","agentPluginRecoveryQuestion": "Restore only the source checkpoint of the previously approved proposal? Recovery will not roll back notes, runtime data, or other settings, and does not authorize further source changes.","agentPluginFlowQuestion": "Use the official plugin development workflow?",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 466baef888..f7d9e7cd56 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Ir al inicio del documento",+ "goToDocumentEnd": "Ir al final del documento","agentBuiltinPluginDevelopmentDescription": "Flujo oficial de desarrollo de plugins de interfaz: tras tu aceptación explícita, se aclaran los requisitos pendientes, se confirma un plan breve y se implementa, valida y empaqueta en una copia gestionada; la instalación y la activación requieren autorización por separado","agentPluginRecoveryQuestion": "¿Restaurar solo el punto de control del código de la propuesta aprobada anteriormente? La recuperación no revierte notas, datos de ejecución ni otros ajustes, y no autoriza más cambios en el código.","agentPluginFlowQuestion": "¿Usar el flujo oficial de desarrollo de plugins?",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 154de65fcf..a60e1508f0 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Aller au début du document",+ "goToDocumentEnd": "Aller à la fin du document","agentBuiltinPluginDevelopmentDescription": "Processus officiel de développement de plugins d’interface : après votre accord explicite, clarifier les exigences manquantes, confirmer un plan succinct, réaliser le développement dans une copie gérée, valider et préparer le paquet ; l’installation et l’activation nécessitent une autorisation distincte","agentPluginRecoveryQuestion": "Restaurer uniquement le point de contrôle du code de la proposition précédemment approuvée ? La restauration ne rétablit ni les notes, ni les données d’exécution, ni les autres paramètres, et n’autorise aucune modification supplémentaire du code.","agentPluginFlowQuestion": "Utiliser le processus officiel de développement de plugins ?",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 936e7bbdc7..2da1700f3f 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "מעבר לתחילת המסמך",+ "goToDocumentEnd": "מעבר לסוף המסמך","agentBuiltinPluginDevelopmentDescription": "תהליך העבודה הרשמי לפיתוח תוספי ממשק: לאחר הסכמתך המפורשת, מבררים דרישות חסרות, מאשרים תוכנית קצרה, מממשים בעותק מנוהל, מאמתים ואורזים; התקנה והפעלה דורשות הרשאה נפרדת","agentPluginRecoveryQuestion": "לשחזר רק את נקודת הביקורת של קוד המקור מההצעה שאושרה קודם? השחזור אינו מחזיר לאחור הערות, נתוני זמן ריצה או הגדרות אחרות, ואינו מאשר שינויים נוספים בקוד המקור.","agentPluginFlowQuestion": "להשתמש בתהליך הרשמי לפיתוח תוספים?",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 4f49826f29..857dcc3a05 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "दस्तावेज़ की शुरुआत पर जाएँ",+ "goToDocumentEnd": "दस्तावेज़ के अंत पर जाएँ","agentBuiltinPluginDevelopmentDescription": "फ़्रंटएंड प्लगइन विकास की आधिकारिक प्रक्रिया: आपकी स्पष्ट सहमति के बाद अधूरी आवश्यकताओं को स्पष्ट करना, संक्षिप्त योजना की पुष्टि करना, प्रबंधित प्रति में कार्यान्वयन करना, जाँचना और पैकेज बनाना; स्थापना और सक्रियण के लिए अलग अनुमति आवश्यक है","agentPluginRecoveryQuestion": "क्या पहले मंज़ूर किए गए प्रस्ताव के केवल स्रोत कोड चेकपॉइंट को पुनर्स्थापित करें? पुनर्स्थापन नोट्स, रनटाइम डेटा या अन्य सेटिंग्स को वापस नहीं करेगा और स्रोत कोड में आगे बदलाव की अनुमति नहीं देता है।","agentPluginFlowQuestion": "क्या आधिकारिक प्लगइन विकास प्रक्रिया का उपयोग करें?",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 1e03690305..9a28bd7c58 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Ke awal dokumen",+ "goToDocumentEnd": "Ke akhir dokumen","agentBuiltinPluginDevelopmentDescription": "Alur kerja resmi pengembangan plugin antarmuka: setelah Anda menyetujuinya secara eksplisit, perjelas kebutuhan yang belum lengkap, konfirmasi rencana singkat, implementasikan dalam salinan terkelola, validasi, dan kemas; pemasangan dan pengaktifan memerlukan izin terpisah","agentPluginRecoveryQuestion": "Pulihkan hanya titik pemeriksaan kode sumber dari usulan yang sebelumnya disetujui? Pemulihan tidak mengembalikan catatan, data runtime, atau pengaturan lain, dan tidak mengizinkan perubahan kode sumber lebih lanjut.","agentPluginFlowQuestion": "Gunakan alur pengembangan plugin resmi?",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex a301cd2769..524d73fafb 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Vai all'inizio del documento",+ "goToDocumentEnd": "Vai alla fine del documento","agentBuiltinPluginDevelopmentDescription": "Procedura ufficiale per lo sviluppo di plugin frontend: dopo il tuo consenso esplicito, chiarire i requisiti mancanti, confermare un piano sintetico, implementare in una copia gestita, verificare e creare il pacchetto; l’installazione e l’attivazione richiedono un’autorizzazione separata","agentPluginRecoveryQuestion": "Ripristinare solo il punto di controllo del codice della proposta approvata in precedenza? Il ripristino non annulla le modifiche a note, dati di esecuzione o altre impostazioni e non autorizza ulteriori modifiche al codice.","agentPluginFlowQuestion": "Usare il flusso ufficiale di sviluppo dei plugin?",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 629d4a1aa9..dfae92c5e0 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "ドキュメントの先頭へ移動",+ "goToDocumentEnd": "ドキュメントの末尾へ移動","agentBuiltinPluginDevelopmentDescription": "公式フロントエンドプラグイン開発フロー:ユーザーが明示的に選択した後、不足している要件を確認し、簡潔な計画に合意したうえで、管理対象のコピーで実装・検証・パッケージ化を行います。インストールと有効化には別途許可が必要です","agentPluginRecoveryQuestion": "以前に承認した提案のソースチェックポイントのみを復元しますか?復元してもノート、実行時データ、その他の設定は元に戻らず、ソースの追加変更も許可されません。","agentPluginFlowQuestion": "公式プラグイン開発フローを使用しますか?",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 25c5383bc0..eebcfea890 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "문서 시작으로 이동",+ "goToDocumentEnd": "문서 끝으로 이동","agentBuiltinPluginDevelopmentDescription": "공식 프런트엔드 플러그인 개발 절차: 사용자가 명시적으로 선택한 후 누락된 요구 사항을 확인하고 간단한 계획에 합의한 뒤 관리되는 사본에서 구현, 검증 및 패키징을 수행하며, 설치와 활성화에는 별도의 승인이 필요합니다","agentPluginRecoveryQuestion": "이전에 승인한 제안의 소스 체크포인트만 복원할까요? 복원해도 노트, 런타임 데이터 또는 기타 설정은 되돌아가지 않으며 추가 소스 변경이 허용되지 않습니다.","agentPluginFlowQuestion": "공식 플러그인 개발 절차를 사용할까요?",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 962d236be6..2cf03f1864 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Naar het begin van het document",+ "goToDocumentEnd": "Naar het einde van het document","agentBuiltinPluginDevelopmentDescription": "Officiële werkwijze voor frontend-pluginontwikkeling: na je uitdrukkelijke toestemming worden ontbrekende vereisten verduidelijkt, wordt een kort plan bevestigd en wordt de plugin in een beheerde kopie geïmplementeerd, gevalideerd en verpakt; installatie en activering vereisen afzonderlijke toestemming","agentPluginRecoveryQuestion": "Alleen het broncodecontrolepunt van het eerder goedgekeurde voorstel herstellen? Het herstel draait geen notities, runtimegegevens of andere instellingen terug en geeft geen toestemming voor verdere broncodewijzigingen.","agentPluginFlowQuestion": "De officiële workflow voor pluginontwikkeling gebruiken?",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 867f1b1c47..4ad47b8786 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Przejdź do początku dokumentu",+ "goToDocumentEnd": "Przejdź do końca dokumentu","agentBuiltinPluginDevelopmentDescription": "Oficjalny proces tworzenia wtyczek interfejsu: po wyraźnej zgodzie użytkownika następuje doprecyzowanie brakujących wymagań, zatwierdzenie krótkiego planu, implementacja w zarządzanej kopii, weryfikacja i przygotowanie pakietu; instalacja i aktywacja wymagają osobnej zgody","agentPluginRecoveryQuestion": "Przywrócić tylko punkt kontrolny kodu wcześniej zatwierdzonego planu? Odzyskiwanie nie cofa notatek, danych wykonania ani innych ustawień i nie zezwala na dalsze zmiany kodu.","agentPluginFlowQuestion": "Użyć oficjalnego procesu tworzenia wtyczek?",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 3083bd1e99..f45c9f1c0b 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Ir para o início do documento",+ "goToDocumentEnd": "Ir para o fim do documento","agentBuiltinPluginDevelopmentDescription": "Fluxo oficial de desenvolvimento de plugins de interface: após sua aceitação explícita, esclarecer os requisitos pendentes, confirmar um plano breve, implementar em uma cópia gerenciada, validar e empacotar; a instalação e a ativação exigem autorização separada","agentPluginRecoveryQuestion": "Restaurar apenas o ponto de controle do código da proposta aprovada anteriormente? A recuperação não reverte notas, dados de execução ou outras configurações e não autoriza novas alterações no código.","agentPluginFlowQuestion": "Usar o fluxo oficial de desenvolvimento de plugins?",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex b63d620767..0c4d54ddb2 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Перейти к началу документа",+ "goToDocumentEnd": "Перейти к концу документа","agentBuiltinPluginDevelopmentDescription": "Официальный процесс разработки плагинов интерфейса: после явного согласия пользователя уточняются недостающие требования, утверждается краткий план, выполняются реализация в управляемой копии, проверка и упаковка; установка и активация требуют отдельного разрешения","agentPluginRecoveryQuestion": "Восстановить только контрольную точку исходного кода ранее одобренного плана? Восстановление не откатывает заметки, данные выполнения или другие настройки и не разрешает дальнейшие изменения исходного кода.","agentPluginFlowQuestion": "Использовать официальный процесс разработки плагинов?",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex 9c1441991b..347d9dc801 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Prejsť na začiatok dokumentu",+ "goToDocumentEnd": "Prejsť na koniec dokumentu","agentBuiltinPluginDevelopmentDescription": "Oficiálny postup vývoja doplnkov rozhrania: po výslovnom súhlase používateľa sa objasnia chýbajúce požiadavky, potvrdí stručný plán a v spravovanej kópii sa vykoná implementácia, overenie a vytvorenie balíka; inštalácia a aktivácia vyžadujú samostatné povolenie","agentPluginRecoveryQuestion": "Obnoviť iba kontrolný bod zdrojového kódu predtým schváleného návrhu? Obnova nevráti poznámky, údaje za behu ani iné nastavenia a nepovoľuje ďalšie zmeny zdrojového kódu.","agentPluginFlowQuestion": "Použiť oficiálny postup vývoja doplnkov?",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex 69c5244285..480e21a2f9 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Иди на почетак документа",+ "goToDocumentEnd": "Иди на крај документа","agentBuiltinPluginDevelopmentDescription": "Званични поступак развоја додатака за кориснички интерфејс: након изричите сагласности корисника разјашњавају се недостајући захтеви, потврђује кратак план и у управљаној копији спроводе израда, провера и паковање; инсталација и активирање захтевају посебно одобрење","agentPluginRecoveryQuestion": "Вратити само контролну тачку изворног кода претходно одобреног предлога? Опоравак не враћа белешке, податке извршавања или друга подешавања и не одобрава даље измене изворног кода.","agentPluginFlowQuestion": "Користити званични поступак развоја додатака?",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 48eadbeb90..ece493c8fa 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "ไปยังจุดเริ่มต้นของเอกสาร",+ "goToDocumentEnd": "ไปยังจุดสิ้นสุดของเอกสาร","agentBuiltinPluginDevelopmentDescription": "ขั้นตอนการพัฒนาปลั๊กอินส่วนหน้าทางการ: หลังจากผู้ใช้ยินยอมอย่างชัดเจน จึงชี้แจงข้อกำหนดที่ยังขาด ยืนยันแผนโดยย่อ พัฒนาในสำเนาที่จัดการให้ ตรวจสอบ และจัดแพ็กเกจ โดยการติดตั้งและเปิดใช้งานต้องได้รับอนุญาตแยกต่างหาก","agentPluginRecoveryQuestion": "กู้คืนเฉพาะจุดตรวจสอบซอร์สโค้ดของข้อเสนอที่อนุมัติไว้ก่อนหน้านี้หรือไม่? การกู้คืนจะไม่ย้อนคืนบันทึก ข้อมูลขณะทำงาน หรือการตั้งค่าอื่น และไม่อนุญาตให้แก้ไขซอร์สโค้ดเพิ่มเติม","agentPluginFlowQuestion": "ใช้ขั้นตอนการพัฒนาปลั๊กอินอย่างเป็นทางการหรือไม่?",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex b7adbbeb0b..dd07427e1a 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Belgenin başına git",+ "goToDocumentEnd": "Belgenin sonuna git","agentBuiltinPluginDevelopmentDescription": "Resmî ön yüz eklentisi geliştirme süreci: açık onayınızın ardından eksik gereksinimler netleştirilir, kısa bir plan onaylanır ve yönetilen bir kopyada geliştirme, doğrulama ve paketleme yapılır; yükleme ve etkinleştirme için ayrı izin gerekir","agentPluginRecoveryQuestion": "Yalnızca daha önce onaylanan önerinin kaynak kodu kontrol noktası geri yüklensin mi? Kurtarma; notları, çalışma zamanı verilerini veya diğer ayarları geri almaz ve kaynak kodunda başka değişikliklere izin vermez.","agentPluginFlowQuestion": "Resmî eklenti geliştirme iş akışı kullanılsın mı?",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex d1c88a5069..a3ec937385 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "Перейти на початок документа",+ "goToDocumentEnd": "Перейти в кінець документа","agentBuiltinPluginDevelopmentDescription": "Офіційний процес розробки плагінів інтерфейсу: після явної згоди користувача уточнюються відсутні вимоги, затверджується стислий план, виконуються реалізація в керованій копії, перевірка та пакування; установлення й активація потребують окремого дозволу","agentPluginRecoveryQuestion": "Відновити лише контрольну точку вихідного коду раніше схваленого плану? Відновлення не відкочує нотатки, дані виконання чи інші налаштування та не дозволяє подальших змін вихідного коду.","agentPluginFlowQuestion": "Використовувати офіційний процес розробки плагінів?",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 75b42d0ab6..67ab2387e9 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "跳到文档开头",+ "goToDocumentEnd": "跳到文档结尾","agentBuiltinPluginDevelopmentDescription": "官方前端插件开发流程:在用户明确选择后澄清缺失要求、确认简短方案、使用受管副本实现、验证和打包;安装与启用另行授权","agentPluginRecoveryQuestion": "是否只恢复此前已确认方案的源码检查点?恢复不会回退笔记、运行时数据或其他配置,也不授权继续修改源码。","agentPluginFlowQuestion": "是否使用官方插件开发流程?",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex e572ea41b1..057f7eb72d 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,6 @@{+ "goToDocumentStart": "跳到文件開頭",+ "goToDocumentEnd": "跳到文件結尾","agentBuiltinPluginDevelopmentDescription": "官方前端外掛開發流程:在使用者明確選擇後釐清缺漏需求、確認簡短方案、使用受管理的副本實作、驗證及封裝;安裝與啟用須另行授權","agentPluginRecoveryQuestion": "是否僅還原先前已確認方案的原始碼檢查點?還原不會回復筆記、執行階段資料或其他設定,也不授權繼續修改原始碼。","agentPluginFlowQuestion": "是否使用官方外掛開發流程?",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.syindex bbc870d57f..17b1c4321b 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": "20261007111840"+ "updated": "20261008101123"},"Children": [{@@ -4293,7 +4293,7 @@"HeadingLevel": 3,"Properties": {"id": "20210106154319-v9tt3e2",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -4313,7 +4313,7 @@"Properties": {"colgroup": "||","id": "20240112150534-wiik5sl",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -7477,7 +7477,7 @@"Children": [{"Type": "NodeText",- "Data": "Scroll to the top"+ "Data": "Move the cursor to the beginning of the document"}]},@@ -7520,7 +7520,58 @@},{"Type": "NodeTableCell",- "Data": "td"+ "Data": "td",+ "Children": [+ {+ "Type": "NodeText",+ "Data": "Customize in "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Settings"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Keymap"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Editor"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "General"+ },+ {+ "Type": "NodeText",+ "Data": "; add "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Home"+ },+ {+ "Type": "NodeText",+ "Data": " or replace the default shortcut. Binding this key overrides its line navigation"+ }+ ]}]},@@ -7534,7 +7585,7 @@"Children": [{"Type": "NodeText",- "Data": "Scroll to the bottom"+ "Data": "Move the cursor to the end of the document"}]},@@ -7581,7 +7632,58 @@},{"Type": "NodeTableCell",- "Data": "td"+ "Data": "td",+ "Children": [+ {+ "Type": "NodeText",+ "Data": "Customize in "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Settings"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Keymap"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Editor"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "General"+ },+ {+ "Type": "NodeText",+ "Data": "; add "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "End"+ },+ {+ "Type": "NodeText",+ "Data": " or replace the default shortcut. Binding this key overrides its line navigation"+ }+ ]}]},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.syindex 52c3c1333a..ef47761b90 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": "20261007111840"+ "updated": "20261008101123"},"Children": [{@@ -4287,7 +4287,7 @@"HeadingLevel": 3,"Properties": {"id": "20201227133317-kazyttz",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -4311,7 +4311,7 @@"Properties": {"colgroup": "||","id": "20201227133317-vopotjc",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -7433,7 +7433,7 @@"Children": [{"Type": "NodeText",- "Data": "滚动到顶部"+ "Data": "光标移动到文档开头"}]},@@ -7479,8 +7479,53 @@"Data": "td","Children": [{- "Type": "NodeBr",- "Data": "br"+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " 中追加 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Home"+ },+ {+ "Type": "NodeText",+ "Data": " 或替换默认快捷键;绑定该键后将覆盖其行内导航行为"}]}@@ -7496,7 +7541,7 @@"Children": [{"Type": "NodeText",- "Data": "滚动到底部"+ "Data": "光标移动到文档结尾"}]},@@ -7542,8 +7587,53 @@"Data": "td","Children": [{- "Type": "NodeBr",- "Data": "br"+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " 中追加 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "End"+ },+ {+ "Type": "NodeText",+ "Data": " 或替换默认快捷键;绑定该键后将覆盖其行内导航行为"}]}diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.syindex e92804f283..04e451ee33 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": "20261007111840"+ "updated": "20261008101123"},"Children": [{@@ -4281,7 +4281,7 @@"HeadingLevel": 3,"Properties": {"id": "20211226122652-xp1hi60",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -4301,7 +4301,7 @@"Properties": {"colgroup": "||","id": "20240112151141-ggglv0f",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -7446,7 +7446,7 @@"Children": [{"Type": "NodeText",- "Data": "滾動到頂部"+ "Data": "游標移動到文件開頭"}]},@@ -7492,8 +7492,53 @@"Data": "td","Children": [{- "Type": "NodeBr",- "Data": "br"+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " 中新增 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Home"+ },+ {+ "Type": "NodeText",+ "Data": " 或取代預設快捷鍵;綁定該鍵後將覆蓋其行內導覽行為"}]}@@ -7509,7 +7554,7 @@"Children": [{"Type": "NodeText",- "Data": "滾動到底部"+ "Data": "游標移動到文件結尾"}]},@@ -7555,8 +7600,53 @@"Data": "td","Children": [{- "Type": "NodeBr",- "Data": "br"+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " 中新增 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "End"+ },+ {+ "Type": "NodeText",+ "Data": " 或取代預設快捷鍵;綁定該鍵後將覆蓋其行內導覽行為"}]}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.syindex 7a67e47397..93fa809a2e 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": "20261007111840"+ "updated": "20261008101123"},"Children": [{@@ -4254,7 +4254,7 @@"Properties": {"ID": "20240530101000-tkbdrth","id": "20240530101000-9wkmh8w",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -4274,7 +4274,7 @@"Properties": {"colgroup": "||","id": "20240530101000-1isfzez",- "updated": "20261002202032"+ "updated": "20261008101123"},"Children": [{@@ -7456,7 +7456,7 @@"Children": [{"Type": "NodeText",- "Data": "一番上までスクロール"+ "Data": "カーソルをドキュメントの先頭へ移動"}]},@@ -7499,7 +7499,54 @@},{"Type": "NodeTableCell",- "Data": "td"+ "Data": "td",+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "一般"+ },+ {+ "Type": "NodeText",+ "Data": " で設定できます。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Home"+ },+ {+ "Type": "NodeText",+ "Data": " を追加するか、既定のショートカットを置き換えます。このキーを割り当てると、行内の移動動作が置き換わります"+ }+ ]}]},@@ -7513,7 +7560,7 @@"Children": [{"Type": "NodeText",- "Data": "一番下までスクロール"+ "Data": "カーソルをドキュメントの末尾へ移動"}]},@@ -7560,7 +7607,54 @@},{"Type": "NodeTableCell",- "Data": "td"+ "Data": "td",+ "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": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "一般"+ },+ {+ "Type": "NodeText",+ "Data": " で設定できます。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "End"+ },+ {+ "Type": "NodeText",+ "Data": " を追加するか、既定のショートカットを置き換えます。このキーを割り当てると、行内の移動動作が置き換わります"+ }+ ]}]},diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 62b0fcac4b..409d8c67ee 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -6,7 +6,6 @@ import {copyPlainText,isMac,isNotCtrl,- isOnlyMeta,updateHotkeyTip,writeText} from "../../protyle/util/compatibility";@@ -44,7 +43,8 @@ import {getFileTreeIconHTML} from "../../emoji/fileTreeIcon";import {deleteFiles} from "../../editor/deleteFile";import {escapeHtml} from "../../util/escape";import {syncGuide} from "../../sync/syncGuide";-import {duplicateBlock, getStartEndElement, goEnd, goHome} from "../../protyle/wysiwyg/commonHotkey";+import {duplicateBlock, getStartEndElement} from "../../protyle/wysiwyg/commonHotkey";+import {handleDocumentBoundaryHotkey} from "../../protyle/util/documentBoundaryHotkey";import {getNextFileLi, getPreviousFileLi} from "../../protyle/wysiwyg/getBlock";import {Backlink} from "../../layout/dock/Backlink";/// #if !BROWSER@@ -536,21 +536,8 @@ const editKeydown = (app: App, event: KeyboardEvent) => {if (target.tagName !== "TABLE" && ["INPUT", "TEXTAREA"].includes(target.tagName)) {return false;}- // ctrl+home 光标移动到顶- if (!event.altKey && !event.shiftKey && isOnlyMeta(event) && event.key === "Home") {- goHome(protyle);- hideElements(["select"], protyle);- event.stopPropagation();- event.preventDefault();- return;- }- // ctrl+end 光标移动到尾- if (!event.altKey && !event.shiftKey && isOnlyMeta(event) && event.key === "End") {- goEnd(protyle);- hideElements(["select"], protyle);- event.stopPropagation();- event.preventDefault();- return;+ if (handleDocumentBoundaryHotkey(protyle, event)) {+ return true;}if (range && matchHotKey(window.siyuan.config.keymap.editor.general.focusBreadcrumb, event)) {if (protyle.breadcrumb?.focus(range)) {diff --git a/app/src/config/tabs/keymapRuntime.ts b/app/src/config/tabs/keymapRuntime.tsindex 032c2d0d7b..3b904d1ed8 100644--- a/app/src/config/tabs/keymapRuntime.ts+++ b/app/src/config/tabs/keymapRuntime.ts@@ -2,6 +2,7 @@ import {sendGlobalShortcut, sendUnregisterGlobalShortcut} from "../../boot/globaimport {updateDockHotkeys} from "../../layout/dock/util";import {syncAppMenuShortcuts} from "../../boot/globalEvent/commonHotkey";import {isSettingsWindow} from "../setting/windowContext";+import {getAllEditor} from "../../layout/getAll";export const applyKeymap = (data: Config.IKeymap) => {window.siyuan.config.keymap = data;@@ -15,6 +16,7 @@ export const applyKeymap = (data: Config.IKeymap) => {});});updateDockHotkeys();+ getAllEditor().forEach(editor => editor.protyle.scroll?.updateHotkeyLabels());sendGlobalShortcut(window.siyuan.ws.app);syncAppMenuShortcuts(Boolean(document.activeElement?.matches(".config-keymap__record, #searchByKey")));};diff --git a/app/src/constants.ts b/app/src/constants.tsindex 93193676ca..d30d445430 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -610,6 +610,8 @@ export abstract class Constants {jumpToParent: {default: "⇧⌘J", custom: "⇧⌘J"},moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"},+ goToDocumentStart: {default: "⌘Home", custom: "⌘Home"},+ goToDocumentEnd: {default: "⌘End", custom: "⌘End"},selectToPageStart: {default: "⇧Home", custom: "⇧Home"},selectToPageEnd: {default: "⇧End", custom: "⇧End"},scrollPageUpWithoutMovingCaret: {default: "⌥PageUp", custom: "⌥PageUp"},diff --git a/app/src/mobile/util/keydown.ts b/app/src/mobile/util/keydown.tsindex 1525d34159..8c6e4a75a5 100644--- a/app/src/mobile/util/keydown.ts+++ b/app/src/mobile/util/keydown.ts@@ -5,6 +5,7 @@ import {getCurrentEditor} from "../editor";import {filterHotkey} from "../../boot/globalEvent/commonHotkey";import {captureShortcutContext, dispatchPluginShortcut} from "../../command/shortcutRuntime";import {logKeyboardDiagnostic} from "../../util/keyboardDiagnostic";+import {handleDocumentBoundaryHotkey} from "../../protyle/util/documentBoundaryHotkey";export const mobileKeydown = (app: App, event: KeyboardEvent) => {logKeyboardDiagnostic("mobile-enter", event);@@ -14,6 +15,10 @@ export const mobileKeydown = (app: App, event: KeyboardEvent) => {event.defaultPrevented ? "default-prevented" : "filtered");return;}+ const editor = getCurrentEditor();+ if (editor?.protyle.element.contains(event.target as Node) && handleDocumentBoundaryHotkey(editor.protyle, event)) {+ return;+ }const matchGeneral = Object.keys(window.siyuan.config.keymap.general).sort().find((key) => {// 上下文菜单由当前编辑器或数据库处理,未处理时继续分发快捷键。if (key === "openContextMenu") {diff --git a/app/src/mobile/util/tabShortcut.test.ts b/app/src/mobile/util/tabShortcut.test.tsindex 0471aa5f66..6050c36e10 100644--- a/app/src/mobile/util/tabShortcut.test.ts+++ b/app/src/mobile/util/tabShortcut.test.ts@@ -16,7 +16,7 @@ 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")},- "../editor": {getCurrentEditor: () => ({protyle: {toolbar: {}}})},+ "../editor": {getCurrentEditor: () => ({protyle: {toolbar: {}, element: {contains: () => false}}})},"../../command/shortcutRuntime": {dispatchPluginShortcut: () => calls.push("plugin")},};runInNewContext(source, {diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.tsindex 588be80b2e..ccf350c2d6 100644--- a/app/src/protyle/scroll/index.ts+++ b/app/src/protyle/scroll/index.ts@@ -20,6 +20,7 @@ import {saveScroll} from "./saveScroll";import {getScrollIndexFromPointer} from "./slider";import {refreshSyntheticDragTarget} from "../../util/touchDragBridge";import {waitForPendingTransactions} from "../util/transactionQueue";+import {getKeymapBindings} from "../../util/keymapBindings";export class Scroll {public element: HTMLElement;@@ -37,15 +38,16 @@ export class Scroll {constructor(protyle: IProtyle) {this.parentElement = document.createElement("div");this.parentElement.classList.add("protyle-scroll", "fn__none");- this.parentElement.innerHTML = `<div class="protyle-scroll__up ariaLabel" data-position="north" aria-label="${updateHotkeyTip("⌘Home")}">+ this.parentElement.innerHTML = `<div class="protyle-scroll__up ariaLabel" data-position="north"><svg><use xlink:href="#iconUp"></use></svg></div><div class="protyle-scroll__bar ariaLabel" data-position="2west" aria-label="Blocks 1/1"><input class="b3-slider" type="range" max="1" min="1" step="1" value="1" /></div>-<div class="protyle-scroll__down ariaLabel" aria-label="${updateHotkeyTip("⌘End")}">+<div class="protyle-scroll__down ariaLabel"><svg><use xlink:href="#iconDown"></use></svg></div>`;+ this.updateHotkeyLabels();this.element = this.parentElement.querySelector(".protyle-scroll__bar");this.element.classList.add("fn__none");@@ -335,6 +337,18 @@ export class Scroll {});}+ public updateHotkeyLabels() {+ const keymap = window.siyuan.config.keymap.editor.general;+ [+ {selector: ".protyle-scroll__up", key: "goToDocumentStart"},+ {selector: ".protyle-scroll__down", key: "goToDocumentEnd"},+ ].forEach(({selector, key}) => {+ const hotkeys = getKeymapBindings(keymap[key]).map(updateHotkeyTip).join(" / ");+ this.parentElement.querySelector(selector).setAttribute("aria-label",+ window.siyuan.languages[key] + (hotkeys ? " " + hotkeys : ""));+ });+ }+public update(protyle: IProtyle) {if (typeof protyle.block.blockCount === "number") {this.inputElement.setAttribute("max", protyle.block.blockCount.toString());diff --git a/app/src/protyle/util/documentBoundaryHotkey.test.ts b/app/src/protyle/util/documentBoundaryHotkey.test.tsnew file mode 100644index 0000000000..d6650f6cd7--- /dev/null+++ b/app/src/protyle/util/documentBoundaryHotkey.test.ts@@ -0,0 +1,155 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {test} from "node:test";+import {runInNewContext} from "node:vm";+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";+import * as keymapBindings from "../../util/keymapBindings";++const compiled = new Map<string, string>();+const loadModule = (path: string, globals: Record<string, unknown>, dependencies: Record<string, object>) => {+ if (!compiled.has(path)) {+ compiled.set(path, transpileModule(readFileSync(path, "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+ }).outputText);+ }+ const exports: any = {};+ runInNewContext(compiled.get(path), {exports, ...globals, require: (name: string) => dependencies[name] || {}});+ return exports;+};++const fixture = (mac = false) => {+ const calls: string[] = [];+ const general: Record<string, keymapBindings.IShortcutKeymap> = {+ goToDocumentStart: {default: "⌘Home", custom: "⌘Home"},+ goToDocumentEnd: {default: "⌘End", custom: "⌘End"},+ };+ const window = {siyuan: {config: {keymap: {editor: {general}, general: {}}}, languages: {+ goToDocumentStart: "Document start", goToDocumentEnd: "Document end",+ }}};+ const hotKey = loadModule("src/protyle/util/hotKey.ts", {window}, {+ "../../util/keymapBindings": keymapBindings,+ "../../constants": {Constants: {KEYCODELIST: {36: "Home", 35: "End", 65: "A"}}},+ "./compatibility": {+ isMac: () => mac,+ isNotCtrl: (event: KeyboardEvent) => !event.ctrlKey && !event.metaKey,+ isOnlyMeta: (event: KeyboardEvent) => mac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey,+ },+ });+ const helper = loadModule("src/protyle/util/documentBoundaryHotkey.ts", {window}, {+ "./hotKey": hotKey,+ "../wysiwyg/commonHotkey": {goHome: () => calls.push("home"), goEnd: () => calls.push("end")},+ "../ui/hideElements": {hideElements: () => calls.push("hide")},+ });+ const protyle = {element: {contains: (target: any) => !target.outside}, wysiwyg: {element: {firstElementChild: {}}}};+ const event = (key: string, overrides: Record<string, unknown> = {}) => ({+ key, keyCode: key === "Home" ? 36 : key === "End" ? 35 : 65,+ ctrlKey: false, metaKey: false, altKey: false, shiftKey: false, isComposing: false,+ target: {localName: "div", closest: (): unknown => null},+ defaultPrevented: false,+ preventDefault() { this.defaultPrevented = true; },+ stopPropagation: () => calls.push("stop"),+ ...overrides,+ });+ return {window, calls, general, helper, protyle, event};+};++test("document boundary defaults retain platform modifiers and native plain and Shift keys", () => {+ for (const mac of [false, true]) {+ const f = fixture(mac);+ for (const key of ["Home", "End"]) {+ for (const overrides of [{}, {shiftKey: true}, mac ? {ctrlKey: true} : {metaKey: true}]) {+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, f.event(key, overrides)), false);+ }+ const event = f.event(key, mac ? {metaKey: true} : {ctrlKey: true});+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, event), true);+ assert.equal(event.defaultPrevented, true);+ }+ assert.deepEqual(f.calls, ["home", "hide", "stop", "end", "hide", "stop"]);+ }+});++test("document boundary bindings can be added, replaced and cleared without a default fallback", () => {+ const f = fixture();+ keymapBindings.setKeymapBindings(f.general.goToDocumentStart, ["Home", "⌘Home"]);+ keymapBindings.setKeymapBindings(f.general.goToDocumentEnd, ["End"]);+ for (const event of [f.event("Home"), f.event("Home", {ctrlKey: true}), f.event("End")]) {+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, event), true);+ }+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, f.event("End", {ctrlKey: true})), false);+ keymapBindings.setKeymapBindings(f.general.goToDocumentStart, []);+ for (const event of [f.event("Home"), f.event("Home", {ctrlKey: true})]) {+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, event), false);+ }+ assert.deepEqual(f.calls.filter(call => call === "home" || call === "end"), ["home", "home", "end"]);+});++test("document navigation preserves controls, composition and already handled events", () => {+ const f = fixture();+ keymapBindings.setKeymapBindings(f.general.goToDocumentStart, ["Home"]);+ for (const overrides of [{isComposing: true}, {defaultPrevented: true},+ {target: {closest: () => ({})}}]) {+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, f.event("Home", overrides)), false);+ }+ f.protyle.wysiwyg.element.firstElementChild = null;+ assert.equal(f.helper.handleDocumentBoundaryHotkey(f.protyle, f.event("Home")), false);+ assert.deepEqual(f.calls, []);+});++test("editable and readonly bodies handle configured navigation before local caret processing", async () => {+ const f = fixture();+ keymapBindings.setKeymapBindings(f.general.goToDocumentStart, ["Home"]);+ let handle: (event: unknown) => Promise<void>;+ const body = {firstElementChild: {}, addEventListener: (_type: string, callback: typeof handle) => handle = callback};+ const editor = {...f.protyle, disabled: false, wysiwyg: {element: body}};+ const module = loadModule("src/protyle/wysiwyg/keydown.ts", {window: f.window}, {+ "../util/documentBoundaryHotkey": f.helper,+ "../../util/keyboardDiagnostic": {logKeyboardDiagnostic: (): void => undefined},+ "./verticalNavigation": {bindVerticalNavigationReset: (): void => undefined},+ "../util/hasClosest": {hasClosestByAttribute: () => false},+ "../render/av/attributeValue": {getAVTemplateInteractiveElement: () => false},+ });+ module.keydown(editor, body);+ for (const readonly of [false, true]) {+ editor.disabled = readonly;+ const event = f.event("Home");+ await handle(event);+ assert.equal(event.defaultPrevented, true);+ }+ assert.deepEqual(f.calls, ["home", "hide", "stop", "home", "hide", "stop"]);+});++test("mobile navigation is limited to the current editor and does not dispatch twice", () => {+ const f = fixture();+ keymapBindings.setKeymapBindings(f.general.goToDocumentEnd, ["End"]);+ const module = loadModule("src/mobile/util/keydown.ts", {window: f.window}, {+ "../../protyle/util/documentBoundaryHotkey": f.helper,+ "../../util/keyboardDiagnostic": {logKeyboardDiagnostic: (): void => undefined},+ "../../boot/globalEvent/commonHotkey": {filterHotkey: () => false},+ "../editor": {getCurrentEditor: () => ({protyle: f.protyle})},+ "../../command/shortcutRuntime": {dispatchPluginShortcut: () => f.calls.push("plugin")},+ });+ const event = f.event("End");+ module.mobileKeydown({}, event);+ assert.equal(event.defaultPrevented, true);+ module.mobileKeydown({}, event);+ module.mobileKeydown({}, f.event("End", {target: {outside: true}}));+ assert.deepEqual(f.calls, ["end", "hide", "stop", "plugin"]);+});++test("scroll button labels follow multiple bindings and retain the action when cleared", () => {+ const f = fixture();+ const labels: Record<string, string> = {};+ const module = loadModule("src/protyle/scroll/index.ts", {window: f.window}, {+ "../../util/keymapBindings": keymapBindings,+ "../util/compatibility": {updateHotkeyTip: (key: string) => key.replace("⌘", "Ctrl+")},+ });+ const scroll = Object.create(module.Scroll.prototype);+ scroll.parentElement = {querySelector: (selector: string) => ({setAttribute: (_name: string, value: string) => labels[selector] = value})};+ scroll.updateHotkeyLabels();+ assert.equal(labels[".protyle-scroll__up"], "Document start Ctrl+Home");+ keymapBindings.setKeymapBindings(f.general.goToDocumentStart, ["Home", "⌘Home"]);+ keymapBindings.setKeymapBindings(f.general.goToDocumentEnd, []);+ scroll.updateHotkeyLabels();+ assert.equal(labels[".protyle-scroll__up"], "Document start Home / Ctrl+Home");+ assert.equal(labels[".protyle-scroll__down"], "Document end");+});diff --git a/app/src/protyle/util/documentBoundaryHotkey.ts b/app/src/protyle/util/documentBoundaryHotkey.tsnew file mode 100644index 0000000000..992907662d--- /dev/null+++ b/app/src/protyle/util/documentBoundaryHotkey.ts@@ -0,0 +1,24 @@+import {matchHotKey} from "./hotKey";+import {goEnd, goHome} from "../wysiwyg/commonHotkey";+import {hideElements} from "../ui/hideElements";++export const handleDocumentBoundaryHotkey = (protyle: IProtyle, event: KeyboardEvent) => {+ const target = event.target as HTMLElement;+ if (event.defaultPrevented || event.isComposing ||+ target.closest("input, textarea, select, button, [role=\"tab\"], [role=\"checkbox\"], .tabs-header, .protyle-action") ||+ !protyle.wysiwyg.element.firstElementChild) {+ return false;+ }+ const keymap = window.siyuan.config.keymap.editor.general;+ if (matchHotKey(keymap.goToDocumentStart, event)) {+ goHome(protyle);+ } else if (matchHotKey(keymap.goToDocumentEnd, event)) {+ goEnd(protyle);+ } else {+ return false;+ }+ hideElements(["hint", "select"], protyle);+ event.stopPropagation();+ event.preventDefault();+ return true;+};diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex ebc4f27d89..8063f2d4f8 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -4,6 +4,7 @@ import {isProtyleListItemFragment} from "../runtimeCapabilities";import {toggleListMindmap} from "../render/listMindmap";import {hideElements} from "../ui/hideElements";import {isTabTextBoundary} from "./tabsBoundary";+import {handleDocumentBoundaryHotkey} from "../util/documentBoundaryHotkey";import {getBlockInsertionContext} from "./blockInsertion";import {isNotCtrl, isOnlyMeta, updateHotkeyTip, writeText} from "../util/compatibility";import {@@ -325,6 +326,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.stopPropagation();return;}+ if (handleDocumentBoundaryHotkey(protyle, event)) {+ return;+ }// 只读正文和页签标题不执行正文编辑逻辑,保留默认行为并交给全局快捷键处理器。if (protyle.disabled || event.target.closest(".tabs-header")) {return;diff --git a/app/src/protyle/wysiwyg/listShortcut.dom.test.ts b/app/src/protyle/wysiwyg/listShortcut.dom.test.tsindex 7c91db6cc3..5e33f777dc 100644--- a/app/src/protyle/wysiwyg/listShortcut.dom.test.ts+++ b/app/src/protyle/wysiwyg/listShortcut.dom.test.ts@@ -25,6 +25,7 @@ const browserCases = async (source: string) => {Constants: {KEYCODELIST: {27: "Escape", 38: "↑", 74: "J", 76: "L"}, MENU_BLOCK_MULTI: "multi",CUSTOM_SY_LIST_MINDMAP: "custom-sy-list-mindmap"},bindVerticalNavigationReset: noop, logKeyboardDiagnostic: noop, getAVTemplateInteractiveElement: noop,+ handleDocumentBoundaryHotkey: noop,prepareVerticalNavigation: noop, avKeydown: noop, fixTable: noop, commonHotkey: noop,countBlockWord: noop, clearAtomicFocus: noop,setInsertWbrHTML: noop, getAtomicVerticalNavigationOwner: noop, revealTabsForTarget: noop,diff --git a/app/src/protyle/wysiwyg/menuKeyboardLifecycle.test.ts b/app/src/protyle/wysiwyg/menuKeyboardLifecycle.test.tsindex c3e2368943..fdae107bb8 100644--- a/app/src/protyle/wysiwyg/menuKeyboardLifecycle.test.ts+++ b/app/src/protyle/wysiwyg/menuKeyboardLifecycle.test.ts@@ -199,6 +199,7 @@ const historyFixture = (menuHidden = false) => {};const bind = compile(`${keydownDeclaration.getText(keydownSource)}\nexports.subject = keydown;`, {bindVerticalNavigationReset: (): void => undefined,+ handleDocumentBoundaryHotkey: () => false,logKeyboardDiagnostic: (): void => undefined,getAVTemplateInteractiveElement: () => false,hasClosestByAttribute: () => false,diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex 5493ddcf11..707044ea6b 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -1300,6 +1300,8 @@ declare namespace Config {scrollPageUpWithoutMovingCaret?: IKey;selectToPageEnd?: IKey;selectToPageStart?: IKey;+ goToDocumentStart?: IKey;+ goToDocumentEnd?: IKey;showInFolder?: IKey;spaceRepetition?: IKey;switchReadonly?: IKey;diff --git a/app/src/util/hotKeyPolicy.test.ts b/app/src/util/hotKeyPolicy.test.tsindex da0902c553..a1346ebac0 100644--- a/app/src/util/hotKeyPolicy.test.ts+++ b/app/src/util/hotKeyPolicy.test.ts@@ -40,6 +40,14 @@ describe("text input hotkey policy", () => {assert.equal(isReservedKeymap("⇧↩", ["general", "agentSend"]), true);});+ it("allows configurable document boundary shortcuts", () => {+ ["Home", "End", "⌘Home", "⌘End"].forEach(hotkey => {+ assert.equal(isReservedKeymap(hotkey, ["editor", "general", "goToDocumentStart"]), false);+ assert.equal(isDisallowedTextInputHotkey(hotkey), false);+ });+ assert.equal(isReservedKeymap("PageUp", ["editor", "general", "goToDocumentStart"]), true);+ });+it("clears only disallowed text input hotkeys", () => {assert.equal(clearDisallowedTextInputHotkey("⇧S"), "");assert.equal(clearDisallowedTextInputHotkey("⇧F1"), "⇧F1");diff --git a/app/src/util/hotKeyPolicy.ts b/app/src/util/hotKeyPolicy.tsindex 0a6ad48341..93344c2c8c 100644--- a/app/src/util/hotKeyPolicy.ts+++ b/app/src/util/hotKeyPolicy.ts@@ -3,7 +3,7 @@ import {getKeymapBindings, IShortcutKeymap, setKeymapBindings} from "./keymapBinconst MODIFIER_KEYS = "⌃⌥⇧⌘";const NON_CHARACTER_KEYS = new Set(["←", "↑", "→", "↓", "⇥", "⌫", "⌦", "↩"]);const RESERVED_KEYMAPS = new Set(["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥",- "⌃D", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape"]);+ "⌃D", "⇧⌘→", "⇧⌘←", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape"]);export const isReservedKeymap = (hotkey: string, keyPath: string[]) =>RESERVED_KEYMAPS.has(hotkey) && !(hotkey === "↩" && keyPath[0] === "general" && keyPath[1] === "agentSend");