An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Simplify shortcut configuration and execution priority https://github.com/siyuan-note/siyuan/issues/19136
Vanessaded366c39cc4
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 4856f342e9..c1744ab682 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "مُعيَّن",+ "keymapCustomized": "مخصص بواسطتي",+ "keymapUnassigned": "غير مُعيَّن",+ "keymapAdd": "إضافة اختصار لوحة مفاتيح","keymapUnset": "غير معيّن","keymapPrimary": "تعيين كاختصار رئيسي","keymapRecording": "اضغط اختصارًا...",- "keymapShared": "اختصار مشترك",- "keymapSharedTip": "تُعطى الأولوية للأوامر المحلية. في كل سياق تُجرَّب الأوامر بالترتيب المعروض؛ بعد بدء أمر لا يُنفَّذ أي أمر آخر",- "keymapLegacyConflict": "يتعارض هذا الاختصار مع إجراء لا يدعم الاختصارات المشتركة بعد","keymapSystemScope": "على مستوى النظام","keymapSaveFailed": "تعذر حفظ الاختصارات","connect": "اتصال",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 1686342616..37a2666f00 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Zugewiesen",+ "keymapCustomized": "Von mir angepasst",+ "keymapUnassigned": "Nicht zugewiesen",+ "keymapAdd": "Tastenkürzel hinzufügen","keymapUnset": "Nicht festgelegt","keymapPrimary": "Als primäres Tastenkürzel festlegen","keymapRecording": "Tastenkürzel drücken...",- "keymapShared": "Gemeinsames Tastenkürzel",- "keymapSharedTip": "Lokale Befehle haben Vorrang. Pro Kontext werden Befehle in der angezeigten Reihenfolge geprüft; sobald ein Befehl startet, wird kein weiterer ausgeführt",- "keymapLegacyConflict": "Dieses Tastenkürzel steht im Konflikt mit einer Aktion, die gemeinsame Belegungen noch nicht unterstützt","keymapSystemScope": "Systemweit","keymapSaveFailed": "Tastenkürzel konnten nicht gespeichert werden","connect": "Verbinden",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 7fadfc9c26..48c8646ad9 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Assigned",+ "keymapCustomized": "Customized by me",+ "keymapUnassigned": "Unassigned",+ "keymapAdd": "Add shortcut","keymapUnset": "Not set","keymapPrimary": "Set as primary shortcut","keymapRecording": "Press shortcut...",- "keymapShared": "Shared shortcut",- "keymapSharedTip": "Local commands take priority. Within each context, commands are tried in the displayed order; once a command starts, no other command runs",- "keymapLegacyConflict": "This shortcut conflicts with an action that does not support shared bindings yet","keymapSystemScope": "System-wide","keymapSaveFailed": "Unable to save shortcuts","connect": "Connect",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 98b08536fa..9709dcab13 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Asignados",+ "keymapCustomized": "Personalizados por mí",+ "keymapUnassigned": "Sin asignar",+ "keymapAdd": "Añadir atajo de teclado","keymapUnset": "Sin asignar","keymapPrimary": "Establecer como atajo principal","keymapRecording": "Pulsa un atajo...",- "keymapShared": "Atajo compartido",- "keymapSharedTip": "Los comandos locales tienen prioridad. En cada contexto se prueban en el orden mostrado; una vez iniciado un comando, no se ejecuta ningún otro",- "keymapLegacyConflict": "Este atajo entra en conflicto con una acción que aún no admite asignaciones compartidas","keymapSystemScope": "En todo el sistema","keymapSaveFailed": "No se pudieron guardar los atajos","connect": "Conectar",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex b456ad4629..7099876acc 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Attribués",+ "keymapCustomized": "Personnalisés par moi",+ "keymapUnassigned": "Non attribués",+ "keymapAdd": "Ajouter un raccourci clavier","keymapUnset": "Non défini","keymapPrimary": "Définir comme raccourci principal","keymapRecording": "Appuyez sur un raccourci...",- "keymapShared": "Raccourci partagé",- "keymapSharedTip": "Les commandes locales sont prioritaires. Dans chaque contexte, les commandes sont examinées dans l’ordre affiché ; dès qu’une commande démarre, aucune autre n’est exécutée",- "keymapLegacyConflict": "Ce raccourci entre en conflit avec une action qui ne prend pas encore en charge les raccourcis partagés","keymapSystemScope": "À l’échelle du système","keymapSaveFailed": "Impossible d’enregistrer les raccourcis","connect": "Se connecter",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 01cd65f49b..d3ff507011 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "מוקצים",+ "keymapCustomized": "מותאמים אישית על ידי",+ "keymapUnassigned": "לא מוקצים",+ "keymapAdd": "הוספת קיצור מקשים","keymapUnset": "לא הוגדר","keymapPrimary": "הגדר כקיצור ראשי","keymapRecording": "הקש קיצור מקשים...",- "keymapShared": "קיצור משותף",- "keymapSharedTip": "לפקודות מקומיות יש עדיפות. בכל הקשר הפקודות נבדקות בסדר המוצג; לאחר שפקודה מתחילה, לא מופעלת פקודה נוספת",- "keymapLegacyConflict": "קיצור זה מתנגש עם פעולה שעדיין אינה תומכת בקיצורים משותפים","keymapSystemScope": "כלל המערכת","keymapSaveFailed": "לא ניתן לשמור את קיצורי המקשים","connect": "התחבר",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 31e1c736b8..1a52dbfe88 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "असाइन किए गए",+ "keymapCustomized": "मेरे द्वारा अनुकूलित",+ "keymapUnassigned": "असाइन नहीं किए गए",+ "keymapAdd": "कीबोर्ड शॉर्टकट जोड़ें","keymapUnset": "सेट नहीं है","keymapPrimary": "मुख्य शॉर्टकट बनाएँ","keymapRecording": "शॉर्टकट दबाएँ...",- "keymapShared": "साझा शॉर्टकट",- "keymapSharedTip": "स्थानीय कमांड को प्राथमिकता मिलती है। हर संदर्भ में कमांड दिखाए गए क्रम में जाँचे जाते हैं; एक कमांड शुरू होने के बाद कोई दूसरा नहीं चलता",- "keymapLegacyConflict": "यह शॉर्टकट ऐसी क्रिया से टकराता है जो अभी साझा शॉर्टकट का समर्थन नहीं करती","keymapSystemScope": "पूरे सिस्टम में","keymapSaveFailed": "शॉर्टकट सहेजे नहीं जा सके","connect": "कनेक्ट करें",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 32e755f634..5d74f76abf 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Ditetapkan",+ "keymapCustomized": "Disesuaikan oleh saya",+ "keymapUnassigned": "Belum ditetapkan",+ "keymapAdd": "Tambah pintasan keyboard","keymapUnset": "Belum diatur","keymapPrimary": "Jadikan pintasan utama","keymapRecording": "Tekan pintasan...",- "keymapShared": "Pintasan bersama",- "keymapSharedTip": "Perintah lokal diprioritaskan. Dalam setiap konteks, perintah dicoba sesuai urutan yang ditampilkan; setelah satu perintah dimulai, perintah lain tidak dijalankan",- "keymapLegacyConflict": "Pintasan ini bertentangan dengan tindakan yang belum mendukung pintasan bersama","keymapSystemScope": "Seluruh sistem","keymapSaveFailed": "Tidak dapat menyimpan pintasan","connect": "Hubungkan",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 67fc6866e5..dea52694bc 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Assegnate",+ "keymapCustomized": "Personalizzate da me",+ "keymapUnassigned": "Non assegnate",+ "keymapAdd": "Aggiungi scorciatoia da tastiera","keymapUnset": "Non impostato","keymapPrimary": "Imposta come scorciatoia principale","keymapRecording": "Premi una scorciatoia...",- "keymapShared": "Scorciatoia condivisa",- "keymapSharedTip": "I comandi locali hanno la precedenza. In ogni contesto vengono valutati nell’ordine mostrato; quando un comando inizia, nessun altro viene eseguito",- "keymapLegacyConflict": "Questa scorciatoia è in conflitto con un’azione che non supporta ancora le assegnazioni condivise","keymapSystemScope": "A livello di sistema","keymapSaveFailed": "Impossibile salvare le scorciatoie","connect": "Connetti",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 1d9950037a..d63160e79c 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "割り当て済み",+ "keymapCustomized": "自分でカスタマイズ",+ "keymapUnassigned": "未割り当て",+ "keymapAdd": "ショートカットを追加","keymapUnset": "未設定","keymapPrimary": "メインのショートカットに設定","keymapRecording": "ショートカットを入力...",- "keymapShared": "共有ショートカット",- "keymapSharedTip": "局所的なコマンドが優先されます。同じコンテキストでは表示順に判定し、コマンドの実行開始後は他のコマンドを実行しません",- "keymapLegacyConflict": "このショートカットは、共有割り当てにまだ対応していない操作と競合しています","keymapSystemScope": "システム全体","keymapSaveFailed": "ショートカットを保存できませんでした","connect": "接続",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 41376f0687..dd70ccad9f 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "할당됨",+ "keymapCustomized": "내가 사용자 지정함",+ "keymapUnassigned": "할당되지 않음",+ "keymapAdd": "단축키 추가","keymapUnset": "설정되지 않음","keymapPrimary": "기본 단축키로 설정","keymapRecording": "단축키를 누르세요...",- "keymapShared": "공유 단축키",- "keymapSharedTip": "로컬 명령이 우선합니다. 각 컨텍스트에서 표시된 순서대로 명령을 확인하며, 명령이 실행되기 시작하면 다른 명령은 실행하지 않습니다",- "keymapLegacyConflict": "이 단축키는 아직 공유 할당을 지원하지 않는 작업과 충돌합니다","keymapSystemScope": "시스템 전체","keymapSaveFailed": "단축키를 저장할 수 없습니다","connect": "연결",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex ee0e48d86e..f88e00a67a 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Toegewezen",+ "keymapCustomized": "Door mij aangepast",+ "keymapUnassigned": "Niet toegewezen",+ "keymapAdd": "Sneltoets toevoegen","keymapUnset": "Niet ingesteld","keymapPrimary": "Instellen als primaire sneltoets","keymapRecording": "Druk op een sneltoets...",- "keymapShared": "Gedeelde sneltoets",- "keymapSharedTip": "Lokale opdrachten hebben voorrang. Per context worden opdrachten in de getoonde volgorde geprobeerd; zodra een opdracht begint, wordt geen andere uitgevoerd",- "keymapLegacyConflict": "Deze sneltoets conflicteert met een actie die gedeelde toewijzingen nog niet ondersteunt","keymapSystemScope": "Systeembreed","keymapSaveFailed": "Sneltoetsen konden niet worden opgeslagen","connect": "Verbinden",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 9ccd0851fa..a2ced308c0 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Przypisane",+ "keymapCustomized": "Dostosowane przeze mnie",+ "keymapUnassigned": "Nieprzypisane",+ "keymapAdd": "Dodaj skrót klawiszowy","keymapUnset": "Nie ustawiono","keymapPrimary": "Ustaw jako główny skrót","keymapRecording": "Naciśnij skrót...",- "keymapShared": "Wspólny skrót",- "keymapSharedTip": "Polecenia lokalne mają pierwszeństwo. W każdym kontekście polecenia są sprawdzane w wyświetlonej kolejności; po rozpoczęciu jednego żadne inne nie zostanie wykonane",- "keymapLegacyConflict": "Ten skrót koliduje z działaniem, które nie obsługuje jeszcze wspólnych przypisań","keymapSystemScope": "Cały system","keymapSaveFailed": "Nie można zapisać skrótów","connect": "Połącz",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex a8128ba297..1cf4269944 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Atribuídos",+ "keymapCustomized": "Personalizados por mim",+ "keymapUnassigned": "Não atribuídos",+ "keymapAdd": "Adicionar atalho de teclado","keymapUnset": "Não definido","keymapPrimary": "Definir como atalho principal","keymapRecording": "Pressione um atalho...",- "keymapShared": "Atalho compartilhado",- "keymapSharedTip": "Comandos locais têm prioridade. Em cada contexto, os comandos são avaliados na ordem exibida; após o início de um comando, nenhum outro é executado",- "keymapLegacyConflict": "Este atalho entra em conflito com uma ação que ainda não aceita atribuições compartilhadas","keymapSystemScope": "Todo o sistema","keymapSaveFailed": "Não foi possível salvar os atalhos","connect": "Conectar",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex df0ddf12c3..1fc7e52839 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Назначенные",+ "keymapCustomized": "Настроенные мной",+ "keymapUnassigned": "Неназначенные",+ "keymapAdd": "Добавить сочетание клавиш","keymapUnset": "Не назначено","keymapPrimary": "Сделать основным сочетанием","keymapRecording": "Нажмите сочетание клавиш...",- "keymapShared": "Общее сочетание клавиш",- "keymapSharedTip": "Локальные команды имеют приоритет. В каждом контексте команды проверяются в указанном порядке; после запуска одной команды другие не выполняются",- "keymapLegacyConflict": "Это сочетание конфликтует с действием, которое пока не поддерживает общие назначения","keymapSystemScope": "Вся система","keymapSaveFailed": "Не удалось сохранить сочетания клавиш","connect": "Подключиться",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex ddeedd548a..64d0b86b68 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Priradené",+ "keymapCustomized": "Upravené mnou",+ "keymapUnassigned": "Nepriradené",+ "keymapAdd": "Pridať klávesovú skratku","keymapUnset": "Nenastavené","keymapPrimary": "Nastaviť ako hlavnú skratku","keymapRecording": "Stlačte klávesovú skratku...",- "keymapShared": "Zdieľaná skratka",- "keymapSharedTip": "Miestne príkazy majú prednosť. V každom kontexte sa príkazy skúšajú v zobrazenom poradí; po spustení jedného sa ďalší nevykoná",- "keymapLegacyConflict": "Táto skratka je v konflikte s akciou, ktorá zatiaľ nepodporuje zdieľané priradenia","keymapSystemScope": "Celý systém","keymapSaveFailed": "Klávesové skratky sa nepodarilo uložiť","connect": "Pripojiť",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 846faea371..d563a1f45f 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "กำหนดแล้ว",+ "keymapCustomized": "ปรับแต่งโดยฉัน",+ "keymapUnassigned": "ยังไม่ได้กำหนด",+ "keymapAdd": "เพิ่มแป้นพิมพ์ลัด","keymapUnset": "ยังไม่ได้ตั้งค่า","keymapPrimary": "ตั้งเป็นปุ่มลัดหลัก","keymapRecording": "กดปุ่มลัด...",- "keymapShared": "ปุ่มลัดที่ใช้ร่วมกัน",- "keymapSharedTip": "คำสั่งเฉพาะบริบทมีลำดับความสำคัญสูงกว่า ในแต่ละบริบทจะตรวจสอบคำสั่งตามลำดับที่แสดง เมื่อคำสั่งหนึ่งเริ่มทำงานแล้วจะไม่เรียกใช้คำสั่งอื่น",- "keymapLegacyConflict": "ปุ่มลัดนี้ขัดแย้งกับการทำงานที่ยังไม่รองรับการใช้ปุ่มลัดร่วมกัน","keymapSystemScope": "ทั้งระบบ","keymapSaveFailed": "ไม่สามารถบันทึกปุ่มลัดได้","connect": "เชื่อมต่อ",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 2237a7d3ac..cebac728b0 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Atanmış",+ "keymapCustomized": "Benim özelleştirdiklerim",+ "keymapUnassigned": "Atanmamış",+ "keymapAdd": "Klavye kısayolu ekle","keymapUnset": "Ayarlanmadı","keymapPrimary": "Birincil kısayol olarak ayarla","keymapRecording": "Kısayola basın...",- "keymapShared": "Paylaşılan kısayol",- "keymapSharedTip": "Yerel komutlar önceliklidir. Her bağlamda komutlar gösterilen sırayla denenir; bir komut başladığında başka bir komut çalıştırılmaz",- "keymapLegacyConflict": "Bu kısayol, henüz paylaşılan atamaları desteklemeyen bir işlemle çakışıyor","keymapSystemScope": "Sistem genelinde","keymapSaveFailed": "Kısayollar kaydedilemedi","connect": "Bağlan",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex a25e19d081..5f2e775305 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "Призначені",+ "keymapCustomized": "Налаштовані мною",+ "keymapUnassigned": "Непризначені",+ "keymapAdd": "Додати сполучення клавіш","keymapUnset": "Не призначено","keymapPrimary": "Зробити основним сполученням","keymapRecording": "Натисніть сполучення клавіш...",- "keymapShared": "Спільне сполучення клавіш",- "keymapSharedTip": "Локальні команди мають пріоритет. У кожному контексті команди перевіряються в показаному порядку; після запуску однієї інші не виконуються",- "keymapLegacyConflict": "Це сполучення конфліктує з дією, яка ще не підтримує спільні призначення","keymapSystemScope": "Уся система","keymapSaveFailed": "Не вдалося зберегти сполучення клавіш","connect": "Підключитися",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex c8e65353a2..08f8743a16 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "已分配",+ "keymapCustomized": "由我分配",+ "keymapUnassigned": "未分配",+ "keymapAdd": "添加快捷键","keymapUnset": "未设置","keymapPrimary": "设为主快捷键","keymapRecording": "按下快捷键...",- "keymapShared": "共用快捷键",- "keymapSharedTip": "局部命令优先。同一上下文按显示顺序匹配;命令开始执行后,不再执行其他命令",- "keymapLegacyConflict": "此快捷键与尚不支持共用绑定的操作冲突","keymapSystemScope": "系统全局","keymapSaveFailed": "无法保存快捷键","connect": "连接",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 47d89db120..b601accc87 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,10 +1,11 @@{+ "keymapAssigned": "已指派",+ "keymapCustomized": "由我指派",+ "keymapUnassigned": "未指派",+ "keymapAdd": "新增快捷鍵","keymapUnset": "未設定","keymapPrimary": "設為主要快捷鍵","keymapRecording": "按下快捷鍵...",- "keymapShared": "共用快捷鍵",- "keymapSharedTip": "局部命令優先。同一上下文依顯示順序比對;命令開始執行後,不再執行其他命令",- "keymapLegacyConflict": "此快捷鍵與尚不支援共用綁定的操作衝突","keymapSystemScope": "系統全域","keymapSaveFailed": "無法儲存快捷鍵","connect": "連線",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 52d4b777c7..35c807bf28 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": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -15,7 +15,7 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-3tm4lvq",- "updated": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -38,7 +38,7 @@},{"Type": "NodeText",- "Data": ", you can assign multiple shortcuts to the same action. Click the plus button at the end of a row and press a key combination to save it. Click an existing shortcut to edit it, its close button to remove it, or the reset button to restore all defaults for that action. Press Esc or click outside to cancel recording. The first shortcut appears in menu hints; right-click another shortcut to make it the primary shortcut."+ "Data": ", you can assign multiple shortcuts to the same action. Click the plus button in a row and press a key combination to save it. Click a shortcut’s close button to remove it, or the reset button to restore all defaults for that action. To replace a shortcut, remove it and add another. Press Esc or click outside to cancel recording. The first shortcut appears in menu hints; right-click another shortcut to make it the primary shortcut. If you enter a shortcut already assigned to the same action, it is not saved and recording stays active so you can enter another key combination."}]},@@ -47,12 +47,26 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-jbgcc13",- "updated": "20260908092714"+ "updated": "20260908180419"},"Children": [{"Type": "NodeText",- "Data": "Click “Shared shortcut” to see contexts and execution order. Use the up and down buttons to reorder commands within the same context. Local commands take priority, with unavailable commands skipped. Once a command starts, cancellation or failure does not trigger another command. Some actions do not support shared bindings yet; if recording reports a conflict, choose another shortcut."+ "Data": "Different actions can use the same shortcut. Duplicate bindings are highlighted as conflicts. The currently focused local scope takes precedence over the general scope. Actions within a scope follow a fixed order, and execution priority cannot be customized. Built-in actions use their fixed handler order; plugin actions are sorted by plugin name and command identifier. Each keypress runs only the first available action. Once it starts, cancellation or failure does not trigger another action."+ }+ ]+ },+ {+ "ID": "20260908172944-uu4n5dl",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260908172944-uu4n5dl",+ "updated": "20260908180419"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "Below the search fields, filter by “All”, “Assigned”, “Customized by me”, or “Unassigned”, together with a name or key search. “Assigned” means at least one shortcut is set. “Customized by me” means bindings differ from the defaults, including added, changed, or removed bindings. “Unassigned” means no shortcut is set. The “Conflict” filter appears only when unresolved conflicts exist, and the affected shortcuts are highlighted individually. Results update after edits. If the active “Conflict” filter has no conflicts left, it automatically switches to “All”."}]},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 a30621d7d7..7f321af01f 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": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -15,7 +15,7 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-514td5y",- "updated": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -38,7 +38,7 @@},{"Type": "NodeText",- "Data": " 中为同一个操作配置多个快捷键。点击行末的加号后按下组合键即可保存;点击已有快捷键可修改,点击其关闭按钮可删除,点击恢复按钮可恢复该操作的全部默认快捷键。按 Esc 或点击外部可取消录入。第一项用于菜单提示,右击其他快捷键可将其设为主快捷键。"+ "Data": " 中为同一个操作配置多个快捷键。点击该行的加号后按下组合键即可保存;点击快捷键的关闭按钮可删除;如需更换,请先删除再添加。点击恢复按钮可恢复该操作的全部默认快捷键。按 Esc 或点击外部可取消录入。第一项用于菜单提示,右击其他快捷键可将其设为主快捷键。同一操作内输入重复快捷键时,不会保存或退出录入,可以继续输入其他组合键。"}]},@@ -47,12 +47,26 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-88wn8r6",- "updated": "20260908092714"+ "updated": "20260908180419"},"Children": [{"Type": "NodeText",- "Data": "点击「共用快捷键」可查看适用上下文和执行顺序,并用上下按钮调整同一上下文内的顺序。局部命令优先,不可用时继续匹配;命令开始执行后,即使取消或失败,也不会执行其他命令。部分操作暂不支持共用绑定,录入时会提示冲突,此时请使用其他快捷键。"+ "Data": "不同操作可以设置相同的快捷键,重复绑定会以冲突配色提示。执行时,当前局部范围优先,通用范围其次;同一范围按固定顺序匹配,用户不能调整执行优先级。内置操作使用固定判断顺序,插件操作按插件名称和命令标识排序。每次按键只执行首个可用操作;开始执行后,即使取消或失败,也不会继续执行其他操作。"+ }+ ]+ },+ {+ "ID": "20260908172944-s7w2qn9",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260908172944-s7w2qn9",+ "updated": "20260908180419"+ },+ "Children": [+ {+ "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 7edac24060..9fbb2a06c6 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": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -15,7 +15,7 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-e1q4nu2",- "updated": "20260908092714"+ "updated": "20260908202901"},"Children": [{@@ -38,7 +38,7 @@},{"Type": "NodeText",- "Data": " 中為同一個操作設定多個快捷鍵。點擊列末的加號後按下組合鍵即可儲存;點擊既有快捷鍵可修改,點擊其關閉按鈕可刪除,點擊還原按鈕可還原該操作的全部預設快捷鍵。按 Esc 或點擊外部可取消輸入。第一項用於選單提示,右擊其他快捷鍵可將其設為主要快捷鍵。"+ "Data": " 中為同一個操作設定多個快捷鍵。點擊該列的加號後按下組合鍵即可儲存;點擊快捷鍵的關閉按鈕可刪除;如需更換,請先刪除再新增。點擊還原按鈕可還原該操作的全部預設快捷鍵。按 Esc 或點擊外部可取消輸入。第一項用於選單提示,右擊其他快捷鍵可將其設為主要快捷鍵。同一操作內輸入重複快捷鍵時,不會儲存或結束輸入,可以繼續輸入其他組合鍵。"}]},@@ -47,12 +47,26 @@"Type": "NodeParagraph","Properties": {"id": "20260908092714-g928py1",- "updated": "20260908092714"+ "updated": "20260908180419"},"Children": [{"Type": "NodeText",- "Data": "點擊「共用快捷鍵」可查看適用上下文和執行順序,並以上下按鈕調整同一上下文內的順序。局部命令優先,不可用時繼續比對;命令開始執行後,即使取消或失敗,也不會執行其他命令。部分操作暫不支援共用綁定,輸入時會提示衝突,此時請使用其他快捷鍵。"+ "Data": "不同操作可以設定相同的快捷鍵,重複綁定會以衝突配色提示。執行時,目前局部範圍優先,通用範圍其次;同一範圍依固定順序比對,使用者不能調整執行優先順序。內建操作使用固定判斷順序,外掛操作依外掛名稱和命令識別碼排序。每次按鍵只執行首個可用操作;開始執行後,即使取消或失敗,也不會繼續執行其他操作。"+ }+ ]+ },+ {+ "ID": "20260908172944-8gbcie5",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260908172944-8gbcie5",+ "updated": "20260908180419"+ },+ "Children": [+ {+ "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 b04bbb45a8..383cdf28ce 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": "20260908134131"+ "updated": "20260908202835"},"Children": [{@@ -17,7 +17,7 @@"Type": "NodeParagraph","Properties": {"id": "20260908134131-m3ys4ns",- "updated": "20260908134131"+ "updated": "20260908202835"},"Children": [{@@ -36,7 +36,7 @@},{"Type": "NodeText",- "Data": " では、同じ操作に複数のショートカットを割り当てられます。行末のプラスボタンをクリックし、キーの組み合わせを入力すると保存されます。既存のショートカットをクリックすると変更でき、その閉じるボタンをクリックすると削除できます。リセットボタンをクリックすると、その操作のすべてのショートカットが初期設定に戻ります。Esc キーを押すか入力欄の外をクリックすると、入力を取り消せます。先頭のショートカットがメニューのヒントに表示されます。別のショートカットを右クリックすると、メインのショートカットに設定できます。"+ "Data": " では、同じ操作に複数のショートカットを割り当てられます。同じ行のプラスボタンをクリックし、キーの組み合わせを入力すると保存されます。既存のショートカットは閉じるボタンをクリックすると削除できます。変更する場合は、削除してから新しいショートカットを追加してください。リセットボタンをクリックすると、その操作のすべてのショートカットが初期設定に戻ります。Esc キーを押すか入力欄の外をクリックすると、入力を取り消せます。先頭のショートカットがメニューのヒントに表示されます。別のショートカットを右クリックすると、メインのショートカットに設定できます。同じ操作に割り当て済みのショートカットを入力しても保存されず、入力状態が続くため、別のキーの組み合わせを入力できます。"}]},@@ -45,12 +45,26 @@"Type": "NodeParagraph","Properties": {"id": "20260908134131-eojg73f",- "updated": "20260908134131"+ "updated": "20260908180419"},"Children": [{"Type": "NodeText",- "Data": "「共有ショートカット」をクリックすると、適用されるコンテキストと実行順序を確認できます。上下のボタンで、同じコンテキスト内の順序を変更できます。局所的なコマンドが優先され、使用できない場合は次の候補を判定します。コマンドの実行開始後は、キャンセルや失敗が発生しても他のコマンドは実行されません。一部の操作は共有割り当てにまだ対応していません。入力時に競合が表示された場合は、別のショートカットを使用してください。"+ "Data": "異なる操作に同じショートカットを設定できます。重複する割り当ては競合として強調表示されます。実行時は現在フォーカスしている局所的な範囲が優先され、次に全般的な範囲が判定されます。同じ範囲内では固定順序で判定され、実行優先順位は変更できません。組み込み操作は固定の判定順序、プラグイン操作はプラグイン名とコマンド識別子の順序に従います。一度のキー入力で実行されるのは最初の利用可能な操作だけです。実行開始後にキャンセルや失敗が発生しても、他の操作は実行されません。"+ }+ ]+ },+ {+ "ID": "20260908172944-0h53s6j",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260908172944-0h53s6j",+ "updated": "20260908180419"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "検索欄の下で「すべて」「割り当て済み」「自分でカスタマイズ」「未割り当て」を選び、名前やキーの検索と組み合わせて絞り込めます。「割り当て済み」は少なくとも一つのショートカットが設定されている操作、「自分でカスタマイズ」は追加・変更・削除した割り当てが初期設定と異なる操作、「未割り当て」はショートカットが設定されていない操作を表示します。未解決の競合がある場合のみ「競合」フィルターが表示され、競合するショートカットが個別に強調表示されます。変更後は結果が自動更新されます。「競合」を選択中にすべての競合が解消されると、自動的に「すべて」に切り替わります。"}]},diff --git a/app/src/assets/scss/business/_config.scss b/app/src/assets/scss/business/_config.scssindex f8c178d963..85675dff14 100644--- a/app/src/assets/scss/business/_config.scss+++ b/app/src/assets/scss/business/_config.scss@@ -399,6 +399,17 @@}&-keymap {+ &__filters {+ display: flex;+ flex-wrap: wrap;+ gap: 8px;+ margin-bottom: 8px;++ button {+ border: 0;+ }+ }+&__row {flex-wrap: wrap;@@ -417,6 +428,10 @@&__controls {max-width: 70%;margin-left: auto;++ > .b3-list-item__action {+ display: flex;+ }}&__bindings {@@ -429,6 +444,7 @@display: inline-flex;align-items: center;white-space: nowrap;+}&__text {@@ -437,7 +453,7 @@background: transparent;color: inherit;font: inherit;- cursor: pointer;+ cursor: default;}&__remove {@@ -470,65 +486,6 @@}}- &__shared-button {- border: 0;- background: transparent;- color: var(--b3-theme-on-surface);- cursor: pointer;- flex-shrink: 0;- padding: 4px;- border-radius: var(--b3-border-radius);-- &:hover,- &--active {- color: var(--b3-theme-primary);- }-- &:focus-visible {- outline: 2px solid var(--b3-theme-primary);- }-- &:disabled {- opacity: .35;- cursor: default;- }-- svg {- display: block;- width: 16px;- height: 16px;- }- }-- &__record {- width: 150px;- max-width: 100%;- }-- &__shared {- flex-basis: 100%;- padding: 8px 12px;- background: var(--b3-theme-surface);- border-radius: var(--b3-border-radius);- white-space: normal;- }-- &__shared-title {- margin: 8px 0;- font-weight: bold;- }-- &__shared-button--conflict {- color: var(--b3-card-warning-color);- }-- &__candidate {- display: flex;- align-items: center;- gap: 8px;- padding: 4px 0;- }-&__key {padding: 2px 4px;font-family: var(--b3-font-family-kbd);@@ -539,7 +496,7 @@background-color: var(--b3-theme-background);border: solid 1px var(--b3-theme-surface-lighter);border-radius: var(--b3-border-radius);- box-shadow: inset 0 -1px 0 var(--b3-theme-surface-lighter);+ box-shadow: inset 0 -1px 0 var(--b3-theme-on-surface-lighter);margin-left: 4px;cursor: pointer;height: 14px;@@ -552,6 +509,20 @@}}+ &__record {+ display: inline-flex;+ align-items: center;+ max-width: 100%;+ background-color: var(--b3-font-background3);+ color: var(--b3-font-color3);+ white-space: nowrap;+ }++ &__chip--conflict {+ background-color: var(--b3-font-background1);+ color: var(--b3-font-color1);+ }+.b3-list__panel .b3-text-field {margin-left: 4px;}diff --git a/app/src/boot/globalEvent/event.ts b/app/src/boot/globalEvent/event.tsindex b115d89bbf..b2d2e5c890 100644--- a/app/src/boot/globalEvent/event.ts+++ b/app/src/boot/globalEvent/event.ts@@ -19,8 +19,6 @@ import {initHarmonyTextSelectionMenu} from "../../util/harmonyTextSelectionMenu"import {clearDragTipGhost, hideDragTip} from "../../protyle/util/dragTip";import {formatPainter} from "../../protyle/toolbar/FormatPainter";import {SELECTION_TOOLBAR_SUB_ELEMENT_SOURCE} from "../../protyle/toolbar/subElementLifecycle";-import {dispatchSharedShortcut} from "../../command/shortcutRuntime";-import {ensureCommandSystem} from "../../command/executor";const KANBAN_GROUP_DRAG_TYPE = `${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Group${Constants.ZWSP}`.toLowerCase();@@ -255,10 +253,6 @@ export const initWindowEvent = (app: App) => {windowKeyUp(app, event);});- window.addEventListener("keydown", (event) => {- dispatchSharedShortcut(app, event, () => ensureCommandSystem(app));- }, true);-window.addEventListener("keydown", (event) => {windowKeyDown(app, event);});diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 1938a3b9dc..9f21725ddf 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -611,12 +611,6 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {return true;}- if (matchHotKey(window.siyuan.config.keymap.general.selectOpen1, event)) {- event.preventDefault();- globalCommand("selectOpen1", app);- return;- }-if (!files.element.parentElement.classList.contains("layout__tab--active")) {return false;}@@ -1024,15 +1018,9 @@ const panelTreeKeydown = (app: App, event: KeyboardEvent) => {const bottomBacklinkElement = hasClosestByClassName(target, "sy__backlink--bottom", true);const bottomBacklink = bottomBacklinkElement ? getAllModels().backlink.find(item =>item.type === "bottom" && item.element === bottomBacklinkElement) : undefined;- let activePanelElement = bottomBacklinkElement || document.querySelector(".layout__tab--active");- if (!activePanelElement) {- Array.from(document.querySelectorAll(".layout__wnd--active .layout-tab-container > div")).find(item => {- if (!item.classList.contains("fn__none") && item.className.indexOf("sy__") > -1) {- activePanelElement = item;- return true;- }- });- }+ const activePanelElement = bottomBacklinkElement ||+ target.closest(".layout__tab--active, .layout__wnd--active .layout-tab-container > div") ||+ (target === document.body ? document.querySelector(".layout__tab--active") : undefined);if (!activePanelElement) {return false;}@@ -1257,7 +1245,7 @@ const panelTreeKeydown = (app: App, event: KeyboardEvent) => {let switchDialog: Dialog;export const windowKeyDown = (app: App, event: KeyboardEvent) => {- if (filterHotkey(event, app)) {+ if (event.defaultPrevented || filterHotkey(event, app)) {return;}if (switchDialog &&@@ -1274,6 +1262,35 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {}const isTabWindow = isWindow();+ if (bindMenuKeydown(event)) {+ event.preventDefault();+ return;+ }++ if (bindAVPanelKeydown(event)) {+ event.preventDefault();+ return;+ }++ // 当前焦点范围先处理快捷键,未命中再按固定顺序处理通用操作。+ // 面板通过活动样式记录焦点,点击后按键事件的目标可能是 body。+ const shortcutTarget = event.target === document.body ?+ document.querySelector<HTMLElement>(".layout__tab--active") || document.body : event.target as HTMLElement;+ if (!shortcutTarget.closest("input, textarea, .b3-menu, .av__panel, .av__mask")) {+ if (shortcutTarget.closest(".protyle") && editKeydown(app, event)) {+ return;+ }+ if (!isTabWindow && shortcutTarget.closest(".sy__file") && fileTreeKeydown(app, event)) {+ return;+ }+ if (!shortcutTarget.closest(".protyle, .sy__file") &&+ (!isTabWindow || shortcutTarget.closest(".sy__backlink--bottom")) &&+ shortcutTarget.closest(".layout__tab--active, .sy__backlink--bottom, .layout__wnd--active .layout-tab-container > div") &&+ panelTreeKeydown(app, event)) {+ return;+ }+ }+const switchHotkey = [...getKeymapBindings(window.siyuan.config.keymap.general.goToEditTabNext),...getKeymapBindings(window.siyuan.config.keymap.general.goToEditTabPrev)].find(key => matchHotKey(key, event));if (switchHotkey) {@@ -1371,16 +1388,6 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {return;}- if (bindMenuKeydown(event)) {- event.preventDefault();- return;- }-- if (bindAVPanelKeydown(event)) {- event.preventDefault();- return;- }-if (["Home", "End", "ArrowUp", "ArrowDown"].includes(event.key)) {let matchDialog: Dialog;// 需找到最顶层的,因此不能用 find@@ -1815,20 +1822,11 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {globalCommand("unsplitAll", app);return;}- if (editKeydown(app, event)) {- return;- }-- // 文件树的操作- if (!isTabWindow && fileTreeKeydown(app, event)) {- return;- }-- // 面板的操作- if ((!isTabWindow || hasClosestByClassName(target, "sy__backlink--bottom", true)) && panelTreeKeydown(app, event)) {+ if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.selectOpen1, event)) {+ event.preventDefault();+ globalCommand("selectOpen1", app);return;}-if (dispatchPluginShortcut(app, event, "shortcut", () => captureShortcutContext(app, event))) {return true;}diff --git a/app/src/command/shortcutCatalog.ts b/app/src/command/shortcutCatalog.tsdeleted file mode 100644index 28ed8d1ddb..0000000000--- a/app/src/command/shortcutCatalog.ts+++ /dev/null@@ -1,77 +0,0 @@-export type TShortcutScope = "editor" | "fileTree" | "dock" | "global" | "system";--export const getShortcutId = (path: readonly string[]) => path[0] === "plugin" ?- `plugin/${encodeURIComponent(path[1])}/${encodeURIComponent(path[2])}` : `core.${path.join(".")}`;--interface IShortcutPlugin {- name: string;- commands: Array<{- langKey: string;- callback?: unknown;- execute?: unknown;- editorCallback?: unknown;- fileTreeCallback?: unknown;- dockCallback?: unknown;- globalCallback?: unknown;- }>;-}--// 这些命令的快捷键只执行标签页切换,无编辑器局部执行分支。-export const SHARED_NATIVE_SHORTCUTS = [- "goToTab1", "goToTab2", "goToTab3", "goToTab4", "goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9",- "goToTabNext", "goToTabPrev",-];--export const getShortcutScopes = (path: readonly string[], plugins: IShortcutPlugin[] = window.siyuan.ws.app.plugins): TShortcutScope[] => {- if (path[0] === "general" && SHARED_NATIVE_SHORTCUTS.includes(path[1])) {- return ["global"];- }- if (path[0] !== "plugin") {- return [];- }- const command = plugins.find(plugin => plugin.name === path[1])?.commands.find(item => item.langKey === path[2]);- if (!command) {- return [];- }- const scopes: TShortcutScope[] = [];- if (command.editorCallback) {- scopes.push("editor");- }- if (command.fileTreeCallback) {- scopes.push("fileTree");- }- if (command.dockCallback) {- scopes.push("dock");- }- if (command.globalCallback) {- scopes.push("system");- }- if (!scopes.length && (command.callback || command.execute)) {- scopes.push("global");- }- return scopes;-};--export const canShareKeymap = (path: readonly string[], plugins?: IShortcutPlugin[]) =>- getShortcutScopes(path, plugins).length > 0;--export const canShareShortcutPaths = (paths: readonly (readonly string[])[], plugins?: IShortcutPlugin[]) => {- const scopes = paths.map(path => getShortcutScopes(path, plugins));- // 系统级注册会先于窗口按键事件触发,共用绑定必须属于相同的触发入口。- return scopes.every(scope => scope.length > 0 && scope.includes("system") === scopes[0].includes("system"));-};--export interface IShortcutOrder {- id: string;- scope: TShortcutScope;- priority?: number;- order?: number;-}--export const compareShortcutBindings = (first: IShortcutOrder, second: IShortcutOrder) => {- const scope = (first.scope === "global" ? 1 : 0) - (second.scope === "global" ? 1 : 0);- const priority = (Number.isFinite(second.priority) ? second.priority : 0) -- (Number.isFinite(first.priority) ? first.priority : 0);- return scope || priority || (first.order ?? 0) - (second.order ?? 0) ||- (first.id < second.id ? -1 : first.id > second.id ? 1 : 0);-};diff --git a/app/src/command/shortcutResolver.test.ts b/app/src/command/shortcutResolver.test.tsindex 5091b1adac..7f7ae15b8e 100644--- a/app/src/command/shortcutResolver.test.ts+++ b/app/src/command/shortcutResolver.test.ts@@ -2,21 +2,20 @@ import * as assert from "node:assert/strict";import test from "node:test";import {CommandRegistry} from "./registry";import {IShortcutCandidate, resolveShortcut} from "./shortcutResolver";-import {canShareKeymap, canShareShortcutPaths, getShortcutScopes} from "./shortcutCatalog";import type {ICommandContextSnapshot, ICommandDefinition} from "./types";const context: ICommandContextSnapshot = {app: {}, source: "shortcut", environment: "desktop", focus: "editor", selectedBlocks: []};-const candidate = (id: string, priority = 0, scope: IShortcutCandidate["scope"] = "global"): IShortcutCandidate =>- ({id, priority, scope, context});+const candidate = (id: string, scope: IShortcutCandidate["scope"] = "global"): IShortcutCandidate =>+ ({id, scope, context});const definition = (id: string, overrides: Partial<ICommandDefinition> = {}): ICommandDefinition =>({id, category: "core", label: () => id, execute: () => undefined, ...overrides});-test("local scope wins before explicit priorities; disabled local commands fall back", async () => {+test("current local scope wins before global scope; disabled local commands fall back", async () => {const registry = new CommandRegistry();let enabled = true;registry.register(definition("local", {enabled: () => enabled}), "local");registry.register(definition("global"), "global");- const candidates = [candidate("global", 100), candidate("local", 0, "editor")];+ const candidates = [candidate("global"), candidate("local", "editor")];assert.equal(resolveShortcut(registry, candidates, assert.fail).candidate.id, "local");enabled = false;assert.equal(resolveShortcut(registry, candidates, assert.fail).candidate.id, "global");@@ -28,9 +27,9 @@ test("source, platform, when and enabled are checked before execution", () => {registry.register(definition("platform", {platform: environment => environment === "mobile"}), "platform");registry.register(definition("when", {when: () => false}), "when");registry.register(definition("enabled", {enabled: () => false}), "enabled");- registry.register(definition("available"), "available");- assert.equal(resolveShortcut(registry, [candidate("source", 4), candidate("platform", 3),- candidate("when", 2), candidate("enabled", 1), candidate("available")], assert.fail).candidate.id, "available");+ registry.register(definition("zz.available"), "zz.available");+ assert.equal(resolveShortcut(registry, [candidate("source"), candidate("platform"),+ candidate("when"), candidate("enabled"), candidate("zz.available")], assert.fail).candidate.id, "zz.available");});test("tie breaking survives registration and plugin reload order", () => {@@ -57,7 +56,7 @@ test("preparing a shortcut has no execution side effects and failures never runreturn failure;}}), "first");registry.register(definition("second", {execute: () => calls.push("second")}), "second");- const prepared = resolveShortcut(registry, [candidate("first", 1), candidate("second")], assert.fail);+ const prepared = resolveShortcut(registry, [candidate("first"), candidate("second")], assert.fail);assert.deepEqual(calls, []);if (failure instanceof Error) {await assert.rejects(prepared.run, /failed/);@@ -73,20 +72,21 @@ test("a throwing condition is reported and skipped", () => {const registry = new CommandRegistry();registry.register(definition("first", {when: () => { throw new Error("condition"); }}), "first");registry.register(definition("second"), "second");- assert.equal(resolveShortcut(registry, [candidate("first", 1), candidate("second")], error => errors.push(error)).candidate.id, "second");+ assert.equal(resolveShortcut(registry, [candidate("first"), candidate("second")], error => errors.push(error)).candidate.id, "second");assert.equal(errors.length, 1);});-test("shared bindings expose only migrated native actions and installed plugin commands", () => {- assert.equal(canShareKeymap(["general", "goToTab5"], []), true);- assert.equal(canShareKeymap(["editor", "insert", "bold"], []), false);- assert.equal(canShareKeymap(["plugin", "missing", "command"], []), false);- assert.deepEqual(getShortcutScopes(["plugin", "test", "command"], [{name: "test", commands: [{langKey: "command",- callback: (): void => {}, editorCallback: (): void => {}, globalCallback: (): void => {}}]}]), ["editor", "system"]);+test("inactive local scopes never handle the shortcut", () => {+ const registry = new CommandRegistry();+ registry.register(definition("dock"), "dock");+ registry.register(definition("global"), "global");+ assert.equal(resolveShortcut(registry, [candidate("dock", "dock"), candidate("global")], assert.fail).candidate.id, "global");});-test("system-wide bindings cannot shadow application bindings through sharing", () => {- const plugins = [{name: "test", commands: [{langKey: "system", globalCallback: true}, {langKey: "other", globalCallback: true}]}];- assert.equal(canShareShortcutPaths([["general", "goToTab5"], ["plugin", "test", "system"]], plugins), false);- assert.equal(canShareShortcutPaths([["plugin", "test", "other"], ["plugin", "test", "system"]], plugins), true);+test("legacy priorities do not affect the fixed order", () => {+ const registry = new CommandRegistry();+ registry.register(definition("a"), "a");+ registry.register(definition("b"), "b");+ const candidates = [Object.assign(candidate("b"), {priority: 100}), candidate("a")];+ assert.equal(resolveShortcut(registry, candidates, assert.fail).candidate.id, "a");});diff --git a/app/src/command/shortcutResolver.ts b/app/src/command/shortcutResolver.tsindex 575f3be017..28b082d02f 100644--- a/app/src/command/shortcutResolver.ts+++ b/app/src/command/shortcutResolver.ts@@ -1,13 +1,18 @@-import {compareShortcutBindings, IShortcutOrder} from "./shortcutCatalog";import type {CommandRegistry} from "./registry";import type {ICommandContextSnapshot} from "./types";-export interface IShortcutCandidate extends IShortcutOrder {+export interface IShortcutCandidate {+ id: string;+ scope: "editor" | "fileTree" | "dock" | "global";context: ICommandContextSnapshot;}export const resolveShortcut = (registry: CommandRegistry, candidates: IShortcutCandidate[], reportError: (error: unknown) => void) => {- for (const candidate of [...candidates].sort(compareShortcutBindings)) {+ // 仅考虑当前局部范围和通用范围,同范围按稳定标识排序,不读取用户优先级。+ const ordered = candidates.filter(candidate => candidate.scope === "global" || candidate.scope === candidate.context.focus)+ .sort((first, second) => Number(first.scope === "global") - Number(second.scope === "global") ||+ (first.id < second.id ? -1 : first.id > second.id ? 1 : 0));+ for (const candidate of ordered) {try {const prepared = registry.prepare(candidate.id, candidate.context);if (prepared.run) {diff --git a/app/src/command/shortcutRuntime.ts b/app/src/command/shortcutRuntime.tsindex f2385c54e9..75e1ee1646 100644--- a/app/src/command/shortcutRuntime.ts+++ b/app/src/command/shortcutRuntime.ts@@ -1,15 +1,11 @@import type {App} from "../index";import {captureCommandContext} from "./context";import {getCommandRegistry} from "./service";-import type {CommandRegistry} from "./registry";-import {getNativeCommandId} from "./nativeCommands";import {getPluginCommandId, supportsPluginCommandSource} from "../plugin/commandAdapter";-import {getKeymapBindings, getKeymapItem, visitKeymapItems} from "../util/keymapBindings";+import {getKeymapBindings, getKeymapItem} from "../util/keymapBindings";import {matchHotKey} from "../protyle/util/hotKey";-import {canShareShortcutPaths, getShortcutScopes, SHARED_NATIVE_SHORTCUTS} from "./shortcutCatalog";import {IShortcutCandidate, resolveShortcut} from "./shortcutResolver";-import type {ICommandContextSnapshot, TCommandSource} from "./types";-import {areProtylePluginExtensionsEnabled} from "../protyle/runtimeCapabilities";+import type {ICommandContextSnapshot} from "./types";const reportError = (error: unknown) => console.error("Shortcut command failed:", error);const handledEvents = new WeakSet<KeyboardEvent>();@@ -59,7 +55,7 @@ export const dispatchPluginShortcut = (app: App, event: KeyboardEvent,if (handledEvents.has(event)) {return true;}- const matches: Array<{id: string; priority?: number}> = [];+ const matches: Array<{id: string}> = [];app.plugins.forEach(plugin => plugin.commands.forEach(command => {if (!supportsPluginCommandSource(command, source)) {return;@@ -67,68 +63,13 @@ export const dispatchPluginShortcut = (app: App, event: KeyboardEvent,const item = getKeymapItem(window.siyuan.config.keymap, ["plugin", plugin.name, command.langKey]);const hotkey = getKeymapBindings(item || {custom: command.customHotkey}).find(key => matchHotKey(key, event));if (hotkey) {- const scope = ({shortcut: "global", editorShortcut: "editor", fileTreeShortcut: "fileTree", dockShortcut: "dock"})[source];- matches.push({id: getPluginCommandId(plugin.name, command.langKey),- priority: item?.bindings?.priority?.[`${scope}:${hotkey}`]});+ matches.push({id: getPluginCommandId(plugin.name, command.langKey)});}}));if (!matches.length) {return false;}const context = capture();- return runCandidates(app, event, matches.map(item => ({...item, context,- scope: source === "shortcut" ? "global" : context.focus})));-};--// 共用绑定在捕获阶段统一选择;未接入的按键继续使用原有事件入口。-export const dispatchSharedShortcut = (app: App, event: KeyboardEvent, ensureCommands: () => CommandRegistry) => {- if (handledEvents.has(event) || event.defaultPrevented || event.isComposing || !event.key ||- (!event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && !/^F\d{1,2}$/.test(event.key))) {- return false;- }- const target = event.target as HTMLElement;- if (target.closest(".config-keymap, .b3-menu, .av__panel, .av__mask") ||- document.getElementById("progress") || document.getElementById("errorLog")) {- return false;- }- const matches: Array<{path: string[]; hotkey: string; priorities?: Record<string, number>}> = [];- visitKeymapItems(window.siyuan.config.keymap, (item, path) => {- const hotkey = getKeymapBindings(item).find(key => matchHotKey(key, event));- if (hotkey) {- matches.push({path, hotkey, priorities: item.bindings?.priority});- }- });- if (matches.length < 2 || !canShareShortcutPaths(matches.map(item => item.path), app.plugins)) {- return false;- }- const context = captureShortcutContext(app, event);- const candidates: IShortcutCandidate[] = [];- const sources: Record<string, TCommandSource> = {- global: "shortcut", editor: "editorShortcut", fileTree: "fileTreeShortcut", dock: "dockShortcut",- };- matches.forEach(({path, hotkey, priorities}) => {- const scopes = getShortcutScopes(path, app.plugins);- const scope = scopes.includes(context.focus) ? context.focus : scopes.includes("global") ? "global" : undefined;- if (!scope || (scope === "editor" && (!context.protyle || !areProtylePluginExtensionsEnabled(context.protyle)))) {- return;- }- if (["mobile", "browser-mobile"].includes(context.environment) && scope !== "global") {- return;- }- const priority = priorities?.[`${scope}:${hotkey}`];- if (path[0] === "general") {- if (event.repeat || !SHARED_NATIVE_SHORTCUTS.includes(path[1])) {- return;- }- candidates.push({id: getNativeCommandId(path[1]), context, scope, priority});- } else {- candidates.push({id: getPluginCommandId(path[1], path[2]),- context: {...context, source: sources[scope]}, scope, priority});- }- });- if (!runCandidates(app, event, candidates, ensureCommands())) {- // 已仲裁的共用绑定不再进入旧命令分支,浏览器默认输入仍可继续。- event.stopImmediatePropagation();- }- return true;+ const scopes = {shortcut: "global", editorShortcut: "editor", fileTreeShortcut: "fileTree", dockShortcut: "dock"} as const;+ return runCandidates(app, event, matches.map(item => ({...item, context, scope: scopes[source]})));};diff --git a/app/src/config/tabs/keymapRow.ts b/app/src/config/tabs/keymapRow.tsindex 2f480f50d8..05cb4d8ade 100644--- a/app/src/config/tabs/keymapRow.ts+++ b/app/src/config/tabs/keymapRow.ts@@ -12,11 +12,11 @@ export const keymapBindingsHtml = (keys: string[], defaults: string[]) => {const changed = JSON.stringify(keys) !== JSON.stringify(defaults);return `<div class="config-keymap__bindings">${keys.map((key, index) =>`<span class="config-keymap__key config-keymap__chip" data-index="${index}">- <button type="button" data-type="update" class="config-keymap__text" aria-label="${attr(languages.keymap + ": " + updateHotkeyTip(key))}">${escapeHtml(updateHotkeyTip(key))}</button>+ <span class="config-keymap__text">${escapeHtml(updateHotkeyTip(key))}</span><button type="button" data-type="remove" class="b3-chip__close config-keymap__remove ariaLabel" aria-label="${attr(languages.remove)}"><svg><use xlink:href="#iconClose"></use></svg></button></span>`).join("")}</div>${keymapActionHtml("reset", "iconUndo", languages.reset, changed ? "" : 'style="display:none" tabindex="-1"')}- ${keymapActionHtml("add", "iconAdd", languages.keymapRecording)}`;+ ${keymapActionHtml("add", "iconAdd", languages.keymapAdd)}`;};export const genKeymapRowHtml = (label: string, dataKey: string, item: IShortcutKeymap) => {@@ -24,7 +24,6 @@ export const genKeymapRowHtml = (label: string, dataKey: string, item: IShortcutreturn `<div class="b3-list-item b3-list-item--narrow b3-list-item--hide-action config-keymap__row" data-key="${attr(dataKey)}" data-keys="${attr(JSON.stringify(keys))}" data-defaults="${attr(JSON.stringify(getDefaultKeymapBindings(item)))}"><span class="b3-list-item__text">${escapeHtml(label)}</span><div class="config-keymap__controls">${keymapBindingsHtml(keys, getDefaultKeymapBindings(item))}</div>- <div class="config-keymap__shared fn__none"></div></div>`;};diff --git a/app/src/config/tabs/keymapUi.ts b/app/src/config/tabs/keymapUi.tsindex ba93ad9243..c8203d39e2 100644--- a/app/src/config/tabs/keymapUi.ts+++ b/app/src/config/tabs/keymapUi.ts@@ -14,10 +14,9 @@ import type {Plugin} from "../../plugin";import {isDisallowedTextInputHotkey, isReservedKeymap} from "../../util/hotKeyPolicy";import {resolvePluginToolbar} from "../../plugin/toolbarItem";import {ensurePluginKeymap} from "../../plugin/keymap";-import {getKeymapBindings, getKeymapItem, setKeymapBindings, visitKeymapItems, normalizeShortcutKey} from "../../util/keymapBindings";+import {getKeymapBindings, getKeymapItem, setKeymapBindings, normalizeShortcutKey} from "../../util/keymapBindings";import {genKeymapRowHtml, getRowBindings, renderRowBindings} from "./keymapRow";-import {escapeAttr, escapeHtml} from "../../util/escape";-import {canShareShortcutPaths, getShortcutScopes, compareShortcutBindings, getShortcutId} from "../../command/shortcutCatalog";+import {escapeHtml} from "../../util/escape";import {Menu} from "../../plugin/Menu";const keymapToolbarSearchStrings = (): string[] => [@@ -27,6 +26,14 @@ const keymapToolbarSearchStrings = (): string[] => [window.siyuan.languages.reset,];+const keymapFilters = () => [+ ["all", window.siyuan.languages.all],+ ["assigned", window.siyuan.languages.keymapAssigned],+ ["customized", window.siyuan.languages.keymapCustomized],+ ["unassigned", window.siyuan.languages.keymapUnassigned],+ ["conflict", window.siyuan.languages.conflict],+];+const genKeymapToolbarHtml = () => genConfigGroup(genButtonRowHtml("keymapRefreshBtn",@@ -124,6 +131,7 @@ const buildKeymapKeywords = (): string[] => [window.siyuan.languages.search,window.siyuan.languages.keymap,window.siyuan.languages.clear,+ ...keymapFilters().map(([, label]) => label),// 命令分组标题window.siyuan.languages.general,window.siyuan.languages.editor,@@ -202,7 +210,7 @@ const genKeymapListHtml = () => {}const pluginHtml = pluginHtmlParts.join("");- return `<div class="b3-label file-tree config-keymap config-item" id="keymapList">+ return `<div class="b3-label file-tree config-keymap config-item" id="keymapList" data-keymap-filter="all"><div class="fn__flex"><input id="keymapInput" class="b3-text-field fn__flex-1" placeholder="${window.siyuan.languages.searchPlaceholder}"><div class="fn__space"></div>@@ -217,6 +225,8 @@ const genKeymapListHtml = () => {</button></div><div class="fn__hr"></div>+ <div class="config-keymap__filters">${keymapFilters().map(([value, label]) =>+ `<button type="button" data-keymap-filter-value="${value}" aria-pressed="${value === "all"}" class="b3-chip b3-chip--middle b3-chip--pointer${value === "all" ? " b3-chip--current" : ""}${value === "conflict" ? " fn__none" : ""}">${escapeHtml(label)}</button>`).join("")}</div>${genKeymapListBlock(window.siyuan.languages.general, generalHtml)}${genKeymapListBlock(window.siyuan.languages.editor, editorHtml, true)}${genKeymapListBlock(window.siyuan.languages.plugin, pluginHtml, true)}@@ -351,12 +361,12 @@ const bindKeymapList = (root: HTMLElement) => {searchKeymapElement.dataset.keymap = "";resetKeymapList(keymapListElement);});- let recording: {row: HTMLElement; input: HTMLInputElement; index: number} | undefined;+ let recording: {row: HTMLElement; element: HTMLElement} | undefined;const outsideRecording = (event: PointerEvent) => {- if (recording && event.target !== recording.input &&+ if (recording && event.target !== recording.element &&!(event.target as HTMLElement).closest(".config-keymap__controls")) {cancelRecording();- refreshShared();+ refreshBindings();}};const cancelRecording = (restoreFocus = false) => {@@ -367,24 +377,33 @@ const bindKeymapList = (root: HTMLElement) => {recording = undefined;document.removeEventListener("pointerdown", outsideRecording, true);renderRowBindings(row, getRowBindings(row));+ refreshKeymapBindings(root);hideMessage("keymapInvalid");- hideMessage("keymapConflict");sendGlobalShortcut(window.siyuan.ws.app);if (restoreFocus) {row.querySelector<HTMLButtonElement>('[data-type="add"]').focus();}};- const refreshShared = () => refreshSharedBindings(root);+ const refreshBindings = () => refreshKeymapBindings(root);+ root.querySelector(".config-keymap__filters").addEventListener("click", (event) => {+ const button = (event.target as HTMLElement).closest<HTMLElement>("[data-keymap-filter-value]");+ if (!button) {+ return;+ }+ cancelRecording();+ keymapListElement.dataset.keymapFilter = button.dataset.keymapFilterValue;+ refreshBindings();+ });const saveRow = (row: HTMLElement, keys: string[], reset = false) => {renderRowBindings(row, keys);saveKeymapRow(root, row, keys, reset ? data => {delete getKeymapItem(data, row.dataset.key.split(Constants.ZWSP)).bindings.priority;} : undefined);- refreshShared();+ refreshBindings();};keymapListElement.addEventListener("pointerdown", (event) => {if (recording && (event.target as HTMLElement).closest(".config-keymap__controls") &&- event.target !== recording.input) {+ event.target !== recording.element) {event.preventDefault();}});@@ -432,36 +451,23 @@ const bindKeymapList = (root: HTMLElement) => {keys.splice(index, 1);saveRow(row, keys);row.querySelector<HTMLButtonElement>('[data-type="add"]').focus();- } else if (type === "add" || type === "update") {- const input = document.createElement("input");- input.className = "b3-text-field config-keymap__record";- input.readOnly = true;- input.spellcheck = false;- input.autocomplete = "off";- input.inputMode = "none";- input.placeholder = window.siyuan.languages.keymapRecording;- input.setAttribute("aria-label", window.siyuan.languages.keymapRecording);- if (type === "update") {- row.querySelector(`[data-index="${index}"]`).replaceWith(input);- } else {- row.querySelector(".config-keymap__bindings").append(input);- }- recording = {row, input, index: type === "update" ? index : -1};+ } else if (type === "add") {+ const recorder = document.createElement("span");+ recorder.className = "config-keymap__key config-keymap__record";+ recorder.tabIndex = 0;+ recorder.setAttribute("role", "button");+ recorder.textContent = window.siyuan.languages.keymapRecording;+ recorder.setAttribute("aria-label", window.siyuan.languages.keymapRecording);+ row.querySelector(".config-keymap__bindings").append(recorder);+ recording = {row, element: recorder};document.addEventListener("pointerdown", outsideRecording, true);row.querySelector('[data-type="add"]').classList.add("config-keymap__action--active");sendUnregisterGlobalShortcut(window.siyuan.ws.app);- input.focus();- } else if (type === "shared") {- const detail = row.querySelector<HTMLElement>(".config-keymap__shared");- const hidden = detail.classList.toggle("fn__none");- action.setAttribute("aria-expanded", String(!hidden));- } else if (type === "priority-up" || type === "priority-down") {- moveSharedBinding(root, row, action, type === "priority-up" ? -1 : 1);- refreshShared();+ recorder.focus();}});keymapListElement.addEventListener("keydown", (event: KeyboardEvent) => {- if (!recording || event.target !== recording.input) {+ if (!recording || event.target !== recording.element) {return;}event.preventDefault();@@ -477,41 +483,21 @@ const bindKeymapList = (root: HTMLElement) => {if (!hotkey || ["⌘", "⇧", "⌥", "⌃"].includes(hotkey.at(-1))) {return;}- const {row, index, input} = recording;+ const {row, element} = recording;const path = row.dataset.key.split(Constants.ZWSP);if (isDisallowedTextInputHotkey(hotkey) || isReservedKeymap(hotkey, path) ||!matchHotKey(hotkey, event) ||(isMac() && path[0] === "general" && ["goToEditTabNext", "goToEditTabPrev"].includes(path[1]) && hotkey.includes("⌘"))) {- input.setAttribute("aria-invalid", "true");+ element.setAttribute("aria-invalid", "true");showMessage(`${window.siyuan.languages.invalid} [${updateHotkeyTip(hotkey)}]`, undefined, undefined, "keymapInvalid");return;}- const conflicts: string[] = [];- visitKeymapItems(window.siyuan.config.keymap, (item, otherPath) => {- if (otherPath.join(Constants.ZWSP) !== row.dataset.key &&- getKeymapBindings(item).some(key => matchHotKey(key, event)) &&- !canShareShortcutPaths([path, otherPath])) {- const otherRow = Array.from(root.querySelectorAll<HTMLElement>(".config-keymap__row"))- .find(candidate => candidate.dataset.key === otherPath.join(Constants.ZWSP));- conflicts.push(otherRow?.querySelector(".b3-list-item__text").textContent || otherPath.join(" - "));- }- });- if (conflicts.length) {- showMessage(`${window.siyuan.languages.keymapLegacyConflict} [${conflicts.map(escapeHtml).join("] [")}]`, undefined, undefined, "keymapConflict");- return;- }const keys = getRowBindings(row);- const duplicate = keys.findIndex((key, keyIndex) => keyIndex !== index && matchHotKey(key, event));- cancelRecording();- if (duplicate !== -1) {- row.querySelector<HTMLButtonElement>(`[data-index="${duplicate}"] [data-type="update"]`).focus();+ if (keys.some(key => matchHotKey(key, event))) {return;}- if (index < 0) {- keys.push(hotkey);- } else {- keys[index] = hotkey;- }+ cancelRecording();+ keys.push(hotkey);saveRow(row, keys);row.querySelector<HTMLButtonElement>('[data-type="add"]').focus();}, true);@@ -521,17 +507,17 @@ const bindKeymapList = (root: HTMLElement) => {}});keymapListElement.addEventListener("focusout", (event: FocusEvent) => {- if (recording && event.target === recording.input) {+ if (recording && event.target === recording.element) {// 等待当前点击完成,避免移除目标按钮后丢失添加、删除或恢复操作。setTimeout(() => {- if (recording && document.activeElement !== recording.input) {+ if (recording && document.activeElement !== recording.element) {cancelRecording();- refreshShared();+ refreshBindings();}}, 0);}});- refreshShared();+ refreshBindings();};const getKeymapString = (event: KeyboardEvent) => {@@ -572,6 +558,10 @@ const getKeymapString = (event: KeyboardEvent) => {};const resetKeymapList = (keymapListElement: HTMLElement) => {+ if (keymapListElement.dataset.keymapFilter !== "all") {+ searchKeymapList(keymapListElement, "", "");+ return;+ }keymapListElement.querySelectorAll(".b3-list-item--hide-action").forEach((liElement) => {liElement.classList.remove("fn__none");liElement.parentElement.classList.remove("fn__none");@@ -593,13 +583,18 @@ const resetKeymapList = (keymapListElement: HTMLElement) => {const searchKeymapList = (keymapListElement: HTMLElement, keywords: string, keymapStr: string) => {const keywordsLower = keywords.trim().toLowerCase();const keymapStrLower = keymapStr.trim().toLowerCase();- if (!keywordsLower && !keymapStrLower) {+ const filter = keymapListElement.dataset.keymapFilter;+ if (!keywordsLower && !keymapStrLower && filter === "all") {resetKeymapList(keymapListElement);return;}keymapListElement.querySelectorAll(".b3-list-item--hide-action > .b3-list-item__text").forEach((item) => {const liElement = item.parentElement;- let matchedKeymap = true;+ const keys = getRowBindings(liElement);+ let matchedKeymap = filter === "assigned" ? keys.length > 0 :+ filter === "unassigned" ? keys.length === 0 :+ filter === "customized" ? liElement.dataset.customized === "true" :+ filter === "conflict" ? liElement.dataset.conflict === "true" : true;if (keymapStrLower) {const dataValue = getRowBindings(liElement).join(" ");if (!dataValue || dataValue.toLowerCase().indexOf(keymapStrLower) === -1) {@@ -652,118 +647,53 @@ const toggleKeymapSearchItem = (editorKeymapElement: HTMLElement, isFiltering: b}};-const scopeLabel = (scope: string) => {- const languages = window.siyuan.languages;- return ({editor: languages.editor, fileTree: languages.fileTree, dock: languages.entryDock,- global: languages.general, system: languages.keymapSystemScope})[scope] || scope;-};--const getRowHotkey = (row: HTMLElement, hotkey: string) => getRowBindings(row)- .find(key => normalizeShortcutKey(key, isMac()) === normalizeShortcutKey(hotkey, isMac()));--const sharedRows = (root: HTMLElement, hotkey: string) =>- Array.from(root.querySelectorAll<HTMLElement>(".config-keymap__row"))- .filter(row => getRowBindings(row).some(key => normalizeShortcutKey(key, isMac()) === normalizeShortcutKey(hotkey, isMac())));--const refreshSharedBindings = (root: HTMLElement) => {- root.querySelectorAll<HTMLElement>(".config-keymap__row").forEach(row => {- const keys = getRowBindings(row).filter(key => sharedRows(root, key).length > 1);- const controls = row.querySelector(".config-keymap__controls");+const refreshKeymapBindings = (root: HTMLElement) => {+ const rows = Array.from(root.querySelectorAll<HTMLElement>(".config-keymap__row"));+ const owners = new Map<string, Set<HTMLElement>>();+ rows.forEach(row => getRowBindings(row).forEach(key => {+ const normalized = normalizeShortcutKey(key, isMac());+ if (normalized) {+ const matches = owners.get(normalized) || new Set<HTMLElement>();+ matches.add(row);+ owners.set(normalized, matches);+ }+ }));+ rows.forEach(row => {+ const keys = getRowBindings(row);const config = getKeymapItem(window.siyuan.config.keymap, row.dataset.key.split(Constants.ZWSP));- const resetButton = controls.querySelector<HTMLButtonElement>('[data-type="reset"]');+ const controls = row.querySelector(".config-keymap__controls");if (config?.bindings && config.bindings.version !== 1) {controls.querySelectorAll<HTMLButtonElement>("button").forEach(button => {button.disabled = true;button.title = window.siyuan.languages.invalid;});}- const changed = JSON.stringify(getRowBindings(row)) !== row.dataset.defaults ||- Object.keys(config?.bindings?.priority || {}).length > 0;- resetButton.style.display = changed ? "" : "none";- resetButton.tabIndex = changed ? 0 : -1;- controls.querySelector('[data-type="shared"]')?.remove();- const detail = row.querySelector<HTMLElement>(".config-keymap__shared");- if (!keys.length) {- detail.classList.add("fn__none");- detail.innerHTML = "";- return;- }- const button = document.createElement("button");- button.type = "button";- button.dataset.type = "shared";- button.className = "config-keymap__shared-button";- button.textContent = window.siyuan.languages.keymapShared;- const ambiguous = keys.some(hotkey => {- const seen = new Set<string>();- return sharedRows(root, hotkey).some(item => {- const path = item.dataset.key.split(Constants.ZWSP);- const config = getKeymapItem(window.siyuan.config.keymap, path);- return getShortcutScopes(path).some(scope => {- const priority = config?.bindings?.priority?.[`${scope}:${getRowHotkey(item, hotkey)}`] || 0;- const identity = `${scope}:${priority}`;- if (seen.has(identity)) {- return true;- }- seen.add(identity);- return false;- });- });+ const changed = JSON.stringify(keys) !== row.dataset.defaults;+ row.dataset.customized = String(changed);+ const reset = controls.querySelector<HTMLButtonElement>('[data-type="reset"]');+ reset.style.display = changed ? "" : "none";+ reset.tabIndex = changed ? 0 : -1;+ const conflicts = keys.map(key => (owners.get(normalizeShortcutKey(key, isMac()))?.size || 0) > 1);+ row.dataset.conflict = String(conflicts.some(Boolean));+ row.querySelectorAll<HTMLElement>(".config-keymap__chip").forEach(chip => {+ chip.classList.toggle("config-keymap__chip--conflict", conflicts[Number(chip.dataset.index)]);});- button.classList.toggle("config-keymap__shared-button--conflict", ambiguous);- button.title = ambiguous ? window.siyuan.languages.conflict : window.siyuan.languages.keymapShared;- button.setAttribute("aria-expanded", String(!detail.classList.contains("fn__none")));- controls.prepend(button);- detail.innerHTML = keys.map(hotkey => {- const rows = sharedRows(root, hotkey);- const supported = canShareShortcutPaths(rows.map(item => item.dataset.key.split(Constants.ZWSP)));- const groups = new Map<string, HTMLElement[]>();- rows.forEach(item => {- const scopes = getShortcutScopes(item.dataset.key.split(Constants.ZWSP));- (scopes.length ? scopes : ["global"]).forEach(scope => {- const group = groups.get(scope) || [];- group.push(item);- groups.set(scope, group);- });- });- return `<div class="config-keymap__shared-title">${escapeHtml(updateHotkeyTip(hotkey))}</div>` +- Array.from(groups, ([scope, items]) => {- items.sort((first, second) => compareShortcutBindings(- {id: getShortcutId(first.dataset.key.split(Constants.ZWSP)), scope: "global", priority: getKeymapItem(window.siyuan.config.keymap,- first.dataset.key.split(Constants.ZWSP))?.bindings?.priority?.[`${scope}:${getRowHotkey(first, hotkey)}`]},- {id: getShortcutId(second.dataset.key.split(Constants.ZWSP)), scope: "global", priority: getKeymapItem(window.siyuan.config.keymap,- second.dataset.key.split(Constants.ZWSP))?.bindings?.priority?.[`${scope}:${getRowHotkey(second, hotkey)}`]},- ));- return `<div class="ft__on-surface">${escapeHtml(scopeLabel(scope))}</div>` + items.map((item, index) =>- `<div class="config-keymap__candidate"><span class="fn__flex-1">${index + 1}. ${escapeHtml(item.querySelector(".b3-list-item__text").textContent)}</span>${supported ?- ["up", "down"].map(direction => `<button type="button" class="config-keymap__action b3-list-item__action" data-type="priority-${direction}" data-path="${escapeAttr(escapeHtml(item.dataset.key))}" data-hotkey="${escapeAttr(escapeHtml(hotkey))}" data-scope="${scope}" aria-label="${escapeAttr(window.siyuan.languages[direction])}" ${((direction === "up" && index === 0) || (direction === "down" && index === items.length - 1)) ? "disabled" : ""}><svg><use xlink:href="#${direction === "up" ? "iconUp" : "iconDown"}"></use></svg></button>`).join("") : ""}</div>`).join("");- }).join("") + `<div class="ft__on-surface">${escapeHtml(window.siyuan.languages[supported ? "keymapSharedTip" : "keymapLegacyConflict"])}</div>`;- }).join("");});-};--const moveSharedBinding = (root: HTMLElement, row: HTMLElement, action: HTMLElement, direction: number) => {- const hotkey = action.dataset.hotkey;- const items = sharedRows(root, hotkey).filter(item =>- getShortcutScopes(item.dataset.key.split(Constants.ZWSP)).includes(action.dataset.scope as "global"));- items.sort((first, second) => compareShortcutBindings(- {id: getShortcutId(first.dataset.key.split(Constants.ZWSP)), scope: "global", priority: getKeymapItem(window.siyuan.config.keymap,- first.dataset.key.split(Constants.ZWSP))?.bindings?.priority?.[`${action.dataset.scope}:${getRowHotkey(first, hotkey)}`]},- {id: getShortcutId(second.dataset.key.split(Constants.ZWSP)), scope: "global", priority: getKeymapItem(window.siyuan.config.keymap,- second.dataset.key.split(Constants.ZWSP))?.bindings?.priority?.[`${action.dataset.scope}:${getRowHotkey(second, hotkey)}`]},- ));- const index = items.findIndex(item => item.dataset.key === action.dataset.path);- const next = index + direction;- if (index < 0 || next < 0 || next >= items.length) {- return;+ const list = root.querySelector<HTMLElement>("#keymapList");+ const hasConflict = Boolean(list.querySelector('[data-conflict="true"]'));+ if (!hasConflict && list.dataset.keymapFilter === "conflict") {+ list.dataset.keymapFilter = "all";}- [items[index], items[next]] = [items[next], items[index]];- saveKeymapRow(root, row, getRowBindings(row), data => {- items.forEach((item, position) => {- const config = getKeymapItem(data, item.dataset.key.split(Constants.ZWSP));- setKeymapBindings(config, getKeymapBindings(config));- config.bindings.priority[`${action.dataset.scope}:${getRowHotkey(item, hotkey)}`] = items.length - position;- });+ list.querySelectorAll<HTMLElement>("[data-keymap-filter-value]").forEach(button => {+ const active = button.dataset.keymapFilterValue === list.dataset.keymapFilter;+ button.classList.toggle("b3-chip--current", active);+ button.setAttribute("aria-pressed", String(active));+ if (button.dataset.keymapFilterValue === "conflict") {+ button.classList.toggle("fn__none", !hasConflict);+ }});+ searchKeymapList(list, list.querySelector<HTMLInputElement>("#keymapInput").value,+ list.querySelector<HTMLInputElement>("#searchByKey").dataset.keymap || "");};let keymapSaveQueue = Promise.resolve();@@ -810,7 +740,7 @@ const saveKeymapRow = (root: HTMLElement, row: HTMLElement, keys: string[], chanroot.querySelectorAll<HTMLElement>(".config-keymap__row").forEach(element => {renderRowBindings(element, getKeymapBindings(getKeymapItem(savedKeymap, element.dataset.key.split(Constants.ZWSP))));});- refreshSharedBindings(root);+ refreshKeymapBindings(root);showMessage(window.siyuan.languages.keymapSaveFailed);}});diff --git a/app/src/mobile/util/keydown.ts b/app/src/mobile/util/keydown.tsindex 08e05fc267..af98352619 100644--- a/app/src/mobile/util/keydown.ts+++ b/app/src/mobile/util/keydown.ts@@ -1,19 +1,16 @@import type {App} from "../../index";-import {ensureCommandSystem, execByCommand} from "../../command/executor";+import {execByCommand} from "../../command/executor";import {matchHotKey} from "../../protyle/util/hotKey";import {getCurrentEditor} from "../editor";import {filterHotkey} from "../../boot/globalEvent/commonHotkey";-import {captureShortcutContext, dispatchPluginShortcut, dispatchSharedShortcut} from "../../command/shortcutRuntime";+import {captureShortcutContext, dispatchPluginShortcut} from "../../command/shortcutRuntime";export const mobileKeydown = (app: App, event: KeyboardEvent) => {// 移动端输入框默认填充无 event.key- if (!event.key || filterHotkey(event, app)) {+ if (!event.key || event.defaultPrevented || filterHotkey(event, app)) {return;}- if (dispatchSharedShortcut(app, event, () => ensureCommandSystem(app))) {- return;- }- const matchGeneral = Object.keys(window.siyuan.config.keymap.general).find((key) => {+ const matchGeneral = Object.keys(window.siyuan.config.keymap.general).sort().find((key) => {if (matchHotKey(window.siyuan.config.keymap.general[key], event)) {const protyle = getCurrentEditor()?.protyle;if (protyle) {diff --git a/app/src/plugin/globalShortcut.test.ts b/app/src/plugin/globalShortcut.test.tsindex 216da7df36..54a2f28ad2 100644--- a/app/src/plugin/globalShortcut.test.ts+++ b/app/src/plugin/globalShortcut.test.ts@@ -3,7 +3,7 @@ import * as assert from "node:assert/strict";import {dispatchPluginGlobalShortcut} from "./globalShortcut";describe("plugin global shortcuts", () => {- it("matches secondary bindings and skips disabled high priority commands", () => {+ it("matches secondary bindings and skips disabled commands", () => {const calls: string[] = [];const plugins = ["first", "second"].map(name => ({name, commands: [{langKey: "action", customHotkey: "⌘K", enabled: () => name !== "first",@@ -16,6 +16,20 @@ describe("plugin global shortcuts", () => {assert.equal(dispatchPluginGlobalShortcut(plugins, "⌘L", keymap), true);assert.deepEqual(calls, ["second"]);});+ it("uses stable command IDs after reload and ignores legacy priority settings", () => {+ for (const order of [["second", "first"], ["first", "second"]]) {+ const calls: string[] = [];+ const plugins = order.map(name => ({name, commands: [{+ langKey: "action", customHotkey: "⌘L", globalCallback: () => calls.push(name),+ }]}));+ const keymap = Object.fromEntries(plugins.map(plugin => [plugin.name, {action: {+ custom: "⌘L", bindings: {version: 1 as const, keys: ["⌘L"],+ priority: {"system:⌘L": plugin.name === "second" ? 100 : 0}},+ }}]));+ assert.equal(dispatchPluginGlobalShortcut(plugins, "⌘L", keymap), true);+ assert.deepEqual(calls, ["first"]);+ }+ });it("runs only the first matching command", () => {const calls: string[] = [];const plugins = ["first", "second"].map(name => ({diff --git a/app/src/plugin/globalShortcut.ts b/app/src/plugin/globalShortcut.tsindex 07ba1c57c8..0bfdd0c866 100644--- a/app/src/plugin/globalShortcut.ts+++ b/app/src/plugin/globalShortcut.ts@@ -1,5 +1,4 @@import {getKeymapBindings, IShortcutKeymap, normalizeShortcutKey} from "../util/keymapBindings";-import {compareShortcutBindings} from "../command/shortcutCatalog";interface IPluginGlobalShortcutCommand {langKey?: string;@@ -22,9 +21,9 @@ export const dispatchPluginGlobalShortcut = (plugins: IPluginGlobalShortcutOwnerconst item = keymap?.[plugin.name]?.[command.langKey];const key = getKeymapBindings(item || {custom: command.customHotkey}).find(key => normalizeShortcutKey(key, mac) === normalizeShortcutKey(hotkey, mac));- return {command, item, id: `plugin/${encodeURIComponent(plugin.name ?? String(index))}/${encodeURIComponent(command.langKey ?? String(commandIndex))}`,- scope: "system" as const, priority: item?.bindings?.priority?.[`system:${key}`], key};- })).filter(({command, key}) => command.globalCallback && key).sort(compareShortcutBindings);+ return {command, key, id: `plugin/${encodeURIComponent(plugin.name ?? String(index))}/${encodeURIComponent(command.langKey ?? String(commandIndex))}`};+ })).filter(({command, key}) => command.globalCallback && key)+ .sort((first, second) => first.id < second.id ? -1 : first.id > second.id ? 1 : 0);for (const {command} of candidates) {try {if ((command.when && !command.when(context)) || (command.enabled && !command.enabled(context))) {diff --git a/app/src/plugin/keymap.test.ts b/app/src/plugin/keymap.test.tsindex 40168d9bfe..7cb5491a4d 100644--- a/app/src/plugin/keymap.test.ts+++ b/app/src/plugin/keymap.test.ts@@ -1,6 +1,7 @@import * as assert from "node:assert/strict";import test from "node:test";import {ensurePluginKeymap, setPluginKeymapCustom, updatePluginKeymap} from "./keymap";+import {getDefaultKeymapBindings, getKeymapBindings, setKeymapBindings} from "../util/keymapBindings";const withKeymap = (plugin: Config.IKeymapPlugin, callback: () => void) => {const windowDescriptor = Object.getOwnPropertyDescriptor(globalThis, "window");@@ -57,3 +58,20 @@ test("plugin default lists are available on first registration and preserve custassert.equal(reloaded.custom, "⌘M");});});++test("switching from a default list to a single or empty default preserves custom bindings and updates reset", () => {+ for (const hotkey of ["⌘M", ""]) {+ for (const keys of [["⌘J", "⌘N"], []]) {+ withKeymap({}, () => {+ const item = updatePluginKeymap("test", "command", "", ["⌘K", "⌘L"]);+ setKeymapBindings(item, keys);+ const updated = updatePluginKeymap("test", "command", hotkey);+ assert.deepEqual(getKeymapBindings(updated), keys);+ assert.equal(updated.custom, keys[0] || "");+ assert.deepEqual(getDefaultKeymapBindings(updated), hotkey ? [hotkey] : []);+ setKeymapBindings(updated, getDefaultKeymapBindings(updated));+ assert.deepEqual(getKeymapBindings(updated), hotkey ? [hotkey] : []);+ });+ }+ }+});diff --git a/app/src/plugin/keymap.ts b/app/src/plugin/keymap.tsindex 16c832a70b..e87de48471 100644--- a/app/src/plugin/keymap.ts+++ b/app/src/plugin/keymap.ts@@ -32,6 +32,9 @@ export const updatePluginKeymap = (pluginName: string, key: string, hotkey: unknsetKeymapBindings(item, keymapItem ? getKeymapBindings(item) : defaults);item.bindings.defaults = defaults;item.default = defaults[0] || "";+ } else if (!Array.isArray(hotkeys) && item.bindings?.version === 1) {+ // 未声明默认列表时,重置使用本次注册的单个默认快捷键。+ delete item.bindings.defaults;}return item;};