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 configurable context menu shortcuts https://github.com/siyuan-note/siyuan/issues/19849
Daniel66a548887495
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 09e4893f8d..d3e53ef385 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,5 @@{+ "openContextMenu": "فتح قائمة السياق","mobileSlashMenu": "قائمة الشرطة المائلة على الهاتف","mobileSlashMenuTip": "عند التفعيل، اكتب / في محرر الهاتف للبحث عن كتل المحتوى وإدراجها","mindmapAddSibling": "إضافة عقدة خريطة ذهنية شقيقة",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 47a6226fbd..e59ce48d23 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Kontextmenü öffnen","mobileSlashMenu": "Slash-Menü auf Mobilgeräten","mobileSlashMenuTip": "Nach dem Aktivieren / im mobilen Editor eingeben, um Inhaltsblöcke zu suchen und einzufügen","mindmapAddSibling": "Gleichrangigen Mindmap-Knoten hinzufügen",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex e9eedee202..5878618602 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Open context menu","mobileSlashMenu": "Mobile slash menu","mobileSlashMenuTip": "When enabled, type / in the mobile editor to search for and insert content blocks","mindmapAddSibling": "Add a sibling mind map node",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 9ca37d6c89..eb7ffb6ca4 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Abrir menú contextual","mobileSlashMenu": "Menú de barra diagonal en móvil","mobileSlashMenuTip": "Al activarlo, escribe / en el editor móvil para buscar e insertar bloques de contenido","mindmapAddSibling": "Añadir un nodo hermano al mapa mental",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 4353abb587..1fe1b379e2 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Ouvrir le menu contextuel","mobileSlashMenu": "Menu barre oblique sur mobile","mobileSlashMenuTip": "Une fois activé, saisissez / dans l’éditeur mobile pour rechercher et insérer des blocs de contenu","mindmapAddSibling": "Ajouter un nœud frère à la carte mentale",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 6711c7ab9c..97b4f78912 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,5 @@{+ "openContextMenu": "פתיחת תפריט ההקשר","mobileSlashMenu": "תפריט לוכסן בנייד","mobileSlashMenuTip": "לאחר ההפעלה, הקלידו / בעורך לנייד כדי לחפש ולהוסיף בלוקי תוכן","mindmapAddSibling": "הוספת צומת אח במפת החשיבה",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex fddeffc819..5121ae5096 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,5 @@{+ "openContextMenu": "संदर्भ मेनू खोलें","mobileSlashMenu": "मोबाइल स्लैश मेनू","mobileSlashMenuTip": "चालू होने पर, सामग्री ब्लॉक खोजने और डालने के लिए मोबाइल संपादक में / टाइप करें","mindmapAddSibling": "माइंड मैप में समान स्तर का नोड जोड़ें",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 3225ba2bdd..f9fe3e4549 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Buka menu konteks","mobileSlashMenu": "Menu garis miring di ponsel","mobileSlashMenuTip": "Jika diaktifkan, ketik / di editor ponsel untuk mencari dan menyisipkan blok konten","mindmapAddSibling": "Tambah simpul setingkat pada peta pikiran",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 424c289aa3..703c160415 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Apri menu contestuale","mobileSlashMenu": "Menu barra nell'editor mobile","mobileSlashMenuTip": "Quando è attivo, digita / nell'editor mobile per cercare e inserire blocchi di contenuto","mindmapAddSibling": "Aggiungi un nodo allo stesso livello nella mappa mentale",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 325a70186b..83c89572e8 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,5 @@{+ "openContextMenu": "コンテキストメニューを開く","mobileSlashMenu": "モバイルのスラッシュメニュー","mobileSlashMenuTip": "有効にすると、モバイルエディターで / を入力してコンテンツブロックを検索、挿入できます","mindmapAddSibling": "同階層のマインドマップノードを追加",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 41a996f448..a39f78eb11 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,5 @@{+ "openContextMenu": "컨텍스트 메뉴 열기","mobileSlashMenu": "모바일 슬래시 메뉴","mobileSlashMenuTip": "활성화하면 모바일 편집기에서 /를 입력해 콘텐츠 블록을 검색하고 삽입할 수 있습니다","mindmapAddSibling": "같은 수준의 마인드맵 노드 추가",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 0ed214db73..5df309a8ce 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Contextmenu openen","mobileSlashMenu": "Slashmenu op mobiel","mobileSlashMenuTip": "Typ na inschakelen / in de mobiele editor om inhoudsblokken te zoeken en in te voegen","mindmapAddSibling": "Een knooppunt op hetzelfde niveau toevoegen aan de mindmap",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex ec2315f285..c8ff594b5a 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Otwórz menu kontekstowe","mobileSlashMenu": "Menu ukośnika na urządzeniu mobilnym","mobileSlashMenuTip": "Po włączeniu wpisz / w edytorze mobilnym, aby wyszukać i wstawić bloki treści","mindmapAddSibling": "Dodaj węzeł równorzędny mapy myśli",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 0b505ffda9..c87b026f62 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Abrir menu de contexto","mobileSlashMenu": "Menu de barra no celular","mobileSlashMenuTip": "Quando ativado, digite / no editor móvel para pesquisar e inserir blocos de conteúdo","mindmapAddSibling": "Adicionar nó irmão ao mapa mental",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex f4aa80eb44..7c22d1a275 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Открыть контекстное меню","mobileSlashMenu": "Меню косой черты на мобильном устройстве","mobileSlashMenuTip": "После включения введите / в мобильном редакторе, чтобы найти и вставить блоки содержимого","mindmapAddSibling": "Добавить соседний узел интеллект-карты",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex a4d1c65f9a..63792677ff 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Otvoriť kontextové menu","mobileSlashMenu": "Ponuka lomky v mobile","mobileSlashMenuTip": "Po zapnutí zadajte / v mobilnom editore na vyhľadanie a vloženie blokov obsahu","mindmapAddSibling": "Pridať súrodenecký uzol myšlienkovej mapy",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex 620d7d3dc5..49a9fb4ecc 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Отвори контекстни мени","mobileSlashMenu": "Мени косе црте на мобилном уређају","mobileSlashMenuTip": "Када је укључен, унесите / у мобилном уређивачу да бисте претражили и уметнули блокове садржаја","mindmapAddSibling": "Додај чвор истог нивоа у мапу ума",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex bc8dc97e96..a92d3856ae 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,5 @@{+ "openContextMenu": "เปิดเมนูบริบท","mobileSlashMenu": "เมนูเครื่องหมายทับบนมือถือ","mobileSlashMenuTip": "เมื่อเปิดใช้งาน ให้พิมพ์ / ในตัวแก้ไขบนมือถือเพื่อค้นหาและแทรกบล็อกเนื้อหา","mindmapAddSibling": "เพิ่มโหนดระดับเดียวกันในแผนผังความคิด",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 44a019dbc4..878faf7210 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Bağlam menüsünü aç","mobileSlashMenu": "Mobil eğik çizgi menüsü","mobileSlashMenuTip": "Etkinleştirildiğinde içerik bloklarını aramak ve eklemek için mobil düzenleyicide / yazın","mindmapAddSibling": "Zihin haritasına aynı düzeyde düğüm ekle",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex f641b46380..6b8588bd66 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,5 @@{+ "openContextMenu": "Відкрити контекстне меню","mobileSlashMenu": "Меню косої риски на мобільному пристрої","mobileSlashMenuTip": "Після ввімкнення введіть / у мобільному редакторі, щоб знайти та вставити блоки вмісту","mindmapAddSibling": "Додати вузол того самого рівня мапи думок",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 02e2b5e3ba..a648161d6a 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,5 @@{+ "openContextMenu": "打开上下文菜单","mobileSlashMenu": "移动端斜杠菜单","mobileSlashMenuTip": "开启后,在移动端编辑器输入 / 可搜索并插入内容块","mindmapAddSibling": "添加同级思维导图节点",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 372847c975..44965ebff4 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,5 @@{+ "openContextMenu": "開啟快顯功能表","mobileSlashMenu": "行動端斜線選單","mobileSlashMenuTip": "啟用後,在行動端編輯器輸入 / 可搜尋並插入內容區塊","mindmapAddSibling": "新增同級心智圖節點",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 0676c109d4..a93b17eafc 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": "20260925172309"+ "updated": "20260925174006"},"Children": [{@@ -51,6 +51,56 @@}]},+ {+ "ID": "20260925174006-1syj8e1",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260925174006-1syj8e1",+ "updated": "20260925174006"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "You can customize or unbind "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Settings"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Keymap"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "General"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Open context menu"+ },+ {+ "Type": "NodeText",+ "Data": ". The default is Ctrl+/ on Windows/Linux and Cmd+/ on macOS. It opens the context menu for the current editor content, database rows, search results, or navigation items. Typing / still opens the slash menu."+ }+ ]+ },{"ID": "20260923233001-pfoov15","Type": "NodeParagraph",diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.syindex 547a0a7468..87e991b399 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": "20260925172309"+ "updated": "20260925174006"},"Children": [{@@ -51,6 +51,56 @@}]},+ {+ "ID": "20260925174006-mz00jbc",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260925174006-mz00jbc",+ "updated": "20260925174006"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "可在 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "设置"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "快捷键"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "打开上下文菜单"+ },+ {+ "Type": "NodeText",+ "Data": " 中修改或解绑快捷键,默认在 Windows/Linux 上为 Ctrl+/,在 macOS 上为 Cmd+/。它根据当前焦点打开编辑器内容、数据库行、搜索结果或导航项的上下文菜单。输入 / 仍用于触发斜杠菜单。"+ }+ ]+ },{"ID": "20260923233001-fcalbnf","Type": "NodeParagraph",diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.syindex b60a8a9ab9..66070e7ab9 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": "20260925172309"+ "updated": "20260925174006"},"Children": [{@@ -51,6 +51,56 @@}]},+ {+ "ID": "20260925174006-m7i1hw9",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260925174006-m7i1hw9",+ "updated": "20260925174006"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "可在 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "設定"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "快速鍵"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "通用"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "開啟快顯功能表"+ },+ {+ "Type": "NodeText",+ "Data": " 中修改或解除快捷鍵綁定,預設在 Windows/Linux 上為 Ctrl+/,在 macOS 上為 Cmd+/。它會依目前焦點開啟編輯器內容、資料庫列、搜尋結果或導覽項目的快顯功能表。輸入 / 仍用於觸發斜線選單。"+ }+ ]+ },{"ID": "20260923233001-dx1k6zh","Type": "NodeParagraph",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.syindex bade4d9e09..cf4cdee3dd 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": "20260925172309"+ "updated": "20260925174006"},"Children": [{@@ -49,6 +49,52 @@}]},+ {+ "ID": "20260925174006-lw5d4uc",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260925174006-lw5d4uc",+ "updated": "20260925174006"+ },+ "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": " でショートカットを変更または解除できます。既定値は Windows/Linux では Ctrl+/、macOS では Cmd+/ です。現在のフォーカスに応じて、エディター内のコンテンツ、データベースの行、検索結果、ナビゲーション項目のコンテキストメニューを開きます。文字 / の入力によるスラッシュメニューの表示は変わりません。"+ }+ ]+ },{"ID": "20260923233001-0vynujv","Type": "NodeParagraph",diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex a563ce046e..c29fcf7f1c 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -779,7 +779,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {return true;}- if (matchHotKey("⌘/", event)) {+ if (matchHotKey(window.siyuan.config.keymap.general.openContextMenu, event)) {const liRect = liElements[0].getBoundingClientRect();if (isFile) {initFileMenu(app, notebookId, pathString, liElements[0]).popup({diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.tsindex 69c2740063..4c2edb70f5 100644--- a/app/src/boot/globalEvent/searchKeydown.ts+++ b/app/src/boot/globalEvent/searchKeydown.ts@@ -116,7 +116,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {return true;}const id = currentList.getAttribute("data-node-id");- if (matchHotKey("⌘/", event)) {+ if (matchHotKey(window.siyuan.config.keymap.general.openContextMenu, event)) {const currentRect = currentList.getBoundingClientRect();initSearchMenu(id).popup({x: currentRect.left + 30,diff --git a/app/src/constants.ts b/app/src/constants.tsindex 9a09e9031d..f77bdc905a 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -485,11 +485,12 @@ export abstract class Constants {});// 冲突不使用 "⌘S/Q"// "⌘", "⇧", "⌥", "⌃"- // "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←",+ // "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←",// "⌘Home", "⌘End", "⇧↩", "PageUp", "PageDown", "⌫", "⌦", "Escape" 不可自定义// "⌥↩" 写死,但可自定义public static readonly SIYUAN_KEYMAP: Config.IKeymap = {general: {+ openContextMenu: {default: "⌘/", custom: "⌘/"},mainMenu: {default: "⌥\\", custom: "⌥\\"},commandPanel: {default: "⌥⇧P", custom: "⌥⇧P"},increaseEditorFontSize: {default: "", custom: ""},diff --git a/app/src/mobile/util/keydown.ts b/app/src/mobile/util/keydown.tsindex af98352619..fe535a922c 100644--- a/app/src/mobile/util/keydown.ts+++ b/app/src/mobile/util/keydown.ts@@ -11,6 +11,10 @@ export const mobileKeydown = (app: App, event: KeyboardEvent) => {return;}const matchGeneral = Object.keys(window.siyuan.config.keymap.general).sort().find((key) => {+ // 上下文菜单由当前编辑器或数据库处理,未处理时继续分发快捷键。+ if (key === "openContextMenu") {+ return false;+ }if (matchHotKey(window.siyuan.config.keymap.general[key], event)) {const protyle = getCurrentEditor()?.protyle;if (protyle) {diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.tsindex 8c9052c4f5..5d08ca824e 100644--- a/app/src/protyle/render/av/keydown.ts+++ b/app/src/protyle/render/av/keydown.ts@@ -285,7 +285,7 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl}}if (selectRowElements.length > 0) {- if (matchHotKey("⌘/", event)) {+ if (matchHotKey(window.siyuan.config.keymap.general.openContextMenu, event)) {event.stopPropagation();event.preventDefault();avContextmenu(protyle, selectRowElements[0] as HTMLElement, {diff --git a/app/src/protyle/util/contextMenuHotkey.test.ts b/app/src/protyle/util/contextMenuHotkey.test.tsnew file mode 100644index 0000000000..ac0ba43ab5--- /dev/null+++ b/app/src/protyle/util/contextMenuHotkey.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 {createSourceFile, forEachChild, isIfStatement, isVariableStatement, ModuleKind, ScriptTarget, transpileModule} from "typescript";+import * as bindings from "../../util/keymapBindings";+import {isDisallowedTextInputHotkey, isReservedKeymap} from "../../util/hotKeyPolicy";++const evaluate = (source: string, globals: Record<string, unknown>) => {+ const exports: Record<string, any> = {};+ runInNewContext(transpileModule(source, {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+ }).outputText, {exports, ...globals});+ return exports;+};++const constants = evaluate(readFileSync("src/constants.ts", "utf8"), {+ SIYUAN_VERSION: "test", NODE_ENV: "test",+}).Constants;++const loadFunction = (path: string, name: string, globals: Record<string, unknown>) => {+ const source = createSourceFile(path, readFileSync(path, "utf8"), ScriptTarget.ES2021, true);+ const declaration = source.statements.find(statement => isVariableStatement(statement) &&+ statement.declarationList.declarations.some(item => item.name.getText(source) === name));+ assert.ok(declaration);+ return evaluate(`${declaration.getText(source)}\nexports.subject = ${name};`, globals).subject;+};++const menuPaths = [+ "src/protyle/wysiwyg/keydown.ts",+ "src/protyle/render/av/keydown.ts",+ "src/boot/globalEvent/searchKeydown.ts",+ "src/boot/globalEvent/keydown.ts",+];++for (const mac of [false, true]) {+ const {matchHotKey} = evaluate(readFileSync("src/protyle/util/hotKey.ts", "utf8"), {+ require: (name: string) => name.endsWith("compatibility") ? {+ isMac: () => mac,+ isOnlyMeta: (event: KeyboardEvent) => mac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey,+ isNotCtrl: (event: KeyboardEvent) => !event.ctrlKey && !event.metaKey,+ } : name.endsWith("constants") ? {Constants: constants} : bindings,+ });+ for (const path of menuPaths) {+ test(`context menu respects defaults, rebindings and unbinding: ${path}, mac=${mac}`, () => {+ const source = createSourceFile(path, readFileSync(path, "utf8"), ScriptTarget.ES2021, true);+ let branch = "";+ const find = (node: import("typescript").Node) => {+ if (isIfStatement(node) && node.expression.getText(source).includes("matchHotKey(window.siyuan.config.keymap.general.openContextMenu, event)")) {+ branch = node.getText(source);+ return;+ }+ forEachChild(node, find);+ };+ find(source);+ assert.ok(branch);+ const item = bindings.mergeKeymapDefault(undefined, constants.SIYUAN_KEYMAP.general.openContextMenu);+ const run = (keyCode: number) => {+ let opened = 0;+ let prevented = false;+ const element = {getBoundingClientRect: () => ({left: 1, top: 2, right: 3, bottom: 4}),+ querySelector: () => element};+ const menu = {popup: () => { opened++; }};+ evaluate(`const run = () => { ${branch} }; run();`, {+ window: {siyuan: {config: {keymap: {general: {openContextMenu: item}}}, menus: {menu}}},+ event: {keyCode, ctrlKey: !mac, metaKey: mac, altKey: false, shiftKey: false,+ stopPropagation() {}, preventDefault() { prevented = true; }},+ matchHotKey, isInEmbedBlock: () => false,+ nodeElement: element, selectRowElements: [element], liElements: [element],+ protyle: {wysiwyg: {element: {querySelectorAll: () => [element]}}, gutter: {renderMenu() {}}},+ avContextmenu: () => { opened++; }, currentList: element, id: "block",+ initSearchMenu: () => menu, initFileMenu: () => menu,+ isFile: true, app: {}, notebookId: "box", pathString: "/doc.sy",+ });+ return {opened, prevented};+ };+ assert.equal(run(191).opened, 1);+ bindings.setKeymapBindings(item, ["⌘K", "⌘L"]);+ assert.equal(run(191).opened, 0);+ assert.equal(run(75).opened, 1);+ assert.equal(run(76).opened, 1);+ bindings.setKeymapBindings(item, []);+ assert.equal(run(191).opened, 0);+ assert.equal(run(75).opened, 0);+ });+ }+}++test("context menu shortcut is assignable while slash text remains protected", () => {+ assert.equal(isReservedKeymap("⌘/", ["editor", "general", "undo"]), false);+ assert.equal(isDisallowedTextInputHotkey("⌘/"), false);+ assert.equal(isDisallowedTextInputHotkey("/"), true);+});++test("startup adds context menu defaults and preserves an explicitly empty binding", () => {+ const keymap = {general: {}};+ const match = loadFunction("src/boot/globalEvent/commonHotkey.ts", "matchKeymap", {+ window: {siyuan: {config: {keymap}}}, Constants: constants,+ ipcRenderer: {send() {}}, mergeKeymapDefault: bindings.mergeKeymapDefault,+ });+ const defaults = {openContextMenu: constants.SIYUAN_KEYMAP.general.openContextMenu};+ match(defaults, "general");+ const item = bindings.getKeymapItem(keymap, ["general", "openContextMenu"]);+ assert.deepEqual(bindings.getKeymapBindings(item), ["⌘/"]);+ bindings.setKeymapBindings(item, []);+ match(defaults, "general");+ assert.deepEqual(bindings.getKeymapBindings(item), []);+});++test("mobile leaves unhandled context menu shortcuts available to plugin dispatch", () => {+ let dispatched = 0;+ const mobileKeydown = loadFunction("src/mobile/util/keydown.ts", "mobileKeydown", {+ window: {siyuan: {config: {keymap: {general: {openContextMenu: {custom: "⌘/"}}}}}},+ filterHotkey: () => false,+ matchHotKey: () => { throw new Error("Context menu must be handled locally"); },+ captureShortcutContext: () => ({}),+ dispatchPluginShortcut: () => { dispatched++; },+ });+ mobileKeydown({}, {key: "/", preventDefault() { throw new Error("Unexpected default prevention"); }});+ assert.equal(dispatched, 1);+ mobileKeydown({}, {key: "/", defaultPrevented: true});+ assert.equal(dispatched, 1);+});++test("keymap panel marks context menu conflicts and clears them after unbinding", () => {+ const item = {...constants.SIYUAN_KEYMAP.general.openContextMenu};+ const keymap = {general: {openContextMenu: item}, editor: {general: {undo: {custom: "⌘/"}}}};+ const rows = ["general.openContextMenu", "editor.general.undo"].map(path => ({+ dataset: {key: path.replaceAll(".", constants.ZWSP), keys: '["⌘/"]', defaults: '["⌘/"]', conflict: "false"},+ querySelector: () => ({querySelector: () => ({style: {}, tabIndex: 0})}),+ querySelectorAll: () => [],+ }));+ let hidden = true;+ const filter = {dataset: {keymapFilterValue: "conflict"}, setAttribute() {},+ classList: {toggle: (name: string, value: boolean) => { if (name === "fn__none") { hidden = value; } }}};+ const list = {dataset: {keymapFilter: "all"},+ querySelector: (selector: string) => selector === '[data-conflict="true"]' ?+ rows.find(row => row.dataset.conflict === "true") : {value: "", dataset: {}},+ querySelectorAll: () => [filter]};+ const refresh = loadFunction("src/config/tabs/keymapUi.ts", "refreshKeymapBindings", {+ window: {siyuan: {config: {keymap}}}, Constants: constants, isMac: () => false,+ getRowBindings: (row: typeof rows[number]) => JSON.parse(row.dataset.keys),+ getKeymapItem: bindings.getKeymapItem, normalizeShortcutKey: bindings.normalizeShortcutKey,+ searchKeymapList() {},+ });+ const root = {querySelectorAll: () => rows, querySelector: () => list};+ refresh(root);+ assert.equal(hidden, false);+ assert.ok(rows.every(row => row.dataset.conflict === "true"));+ bindings.setKeymapBindings(item, []);+ rows[0].dataset.keys = "[]";+ refresh(root);+ assert.equal(hidden, true);+ assert.ok(rows.every(row => row.dataset.conflict === "false"));+});diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 66d0cc665d..2dc6c5c8a9 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -921,7 +921,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {!protyle.hint.element.classList.contains("fn__none") && protyle.hint.select(event, protyle)) {return;}- if (matchHotKey("⌘/", event) && !isInEmbedBlock(nodeElement)) {+ if (matchHotKey(window.siyuan.config.keymap.general.openContextMenu, event) && !isInEmbedBlock(nodeElement)) {event.stopPropagation();event.preventDefault();const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex 046b5d7428..58496d4d00 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -1389,6 +1389,8 @@ declare namespace Config {* SiYuan general shortcut keys*/export interface IKeymapGeneral extends IKeys {+ /** 打开当前焦点的上下文菜单,默认 ⌘/,支持多绑定和解绑。 */+ openContextMenu?: IKey;mainMenu?: IKey;commandPanel?: IKey;increaseEditorFontSize?: IKey;diff --git a/app/src/util/hotKeyPolicy.ts b/app/src/util/hotKeyPolicy.tsindex 3a683e5db4..0a6ad48341 100644--- a/app/src/util/hotKeyPolicy.ts+++ b/app/src/util/hotKeyPolicy.ts@@ -2,7 +2,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", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥",+const RESERVED_KEYMAPS = new Set(["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥","⌃D", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape"]);export const isReservedKeymap = (hotkey: string, keyPath: string[]) =>