Skip to content

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

:sparkles: Support mind map keyboard navigation and editing https://github.com/siyuan-note/siyuan/issues/19672

Vanessae169fa7b92e2
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
index efe863eef0..5b46350f91 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": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11956,7 +11956,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20210106154319-ans1gna",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11980,7 +11980,7 @@
"Properties": {
"colgroup": "||",
"id": "20210106154319-4oe7doq",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -12409,6 +12409,191 @@
]
}
]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Select the parent node"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "←"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Focus the mind map and select a node"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Select the first expanded child node"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "→"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Focus the mind map and select a node"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Select the previous sibling node"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Focus the mind map and select a node"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Select the next sibling node"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Focus the mind map and select a node"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Edit the selected node with the caret at the end"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Focus the mind map and select a node"
+ }
+ ]
+ }
+ ]
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
index 727b1bbb4b..298a90eabe 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": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11944,7 +11944,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20201227133317-x02vhoh",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11964,7 +11964,7 @@
"Properties": {
"colgroup": "||",
"id": "20201227133317-yv5msrs",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -12395,6 +12395,191 @@
]
}
]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "选中父节点"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "←"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦点位于脑图内且已选中节点"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "选中已展开的第一个子节点"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "→"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦点位于脑图内且已选中节点"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "选中上一个同级节点"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦点位于脑图内且已选中节点"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "选中下一个同级节点"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦点位于脑图内且已选中节点"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "编辑选中节点,光标定位末尾"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "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.sy
index d2fb139ba4..5e375a3205 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": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11956,7 +11956,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20211226122652-td76oes",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11976,7 +11976,7 @@
"Properties": {
"colgroup": "||",
"id": "20211226122652-qj1o02k",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -12401,6 +12401,191 @@
]
}
]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "選取父節點"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "←"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦點位於腦圖內且已選取節點"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "選取已展開的第一個子節點"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "→"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦點位於腦圖內且已選取節點"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "選取上一個同級節點"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦點位於腦圖內且已選取節點"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "選取下一個同級節點"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "焦點位於腦圖內且已選取節點"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "編輯選取的節點,游標定位末尾"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "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.sy
index 6e83750f5b..0d8e878b14 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": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11900,7 +11900,7 @@
"Properties": {
"ID": "20240530101000-uaq4ub6",
"id": "20240530101000-yl0e0sq",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -11930,7 +11930,7 @@
"Properties": {
"colgroup": "||",
"id": "20240530101000-wqr5cs1",
- "updated": "20260918223821"
+ "updated": "20260919231210"
},
"Children": [
{
@@ -12359,6 +12359,191 @@
]
}
]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "親ノードを選択"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "←"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マインドマップ内にフォーカスがあり、ノードが選択されている場合"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "展開済みの最初の子ノードを選択"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "→"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マインドマップ内にフォーカスがあり、ノードが選択されている場合"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "同じ親を持つ前のノードを選択"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マインドマップ内にフォーカスがあり、ノードが選択されている場合"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "同じ親を持つ次のノードを選択"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マインドマップ内にフォーカスがあり、ノードが選択されている場合"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "選択したノードを編集し、末尾にカーソルを移動"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マインドマップ内にフォーカスがあり、ノードが選択されている場合"
+ }
+ ]
+ }
+ ]
}
]
},
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index 971cb87849..b663378d2d 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -554,6 +554,46 @@ const browserCases = async (sourceCode: string, css: string) => {
};
select(beta);
const beforeShortcuts = additions.length;
+ const navigate = (key: string) => host.dispatchEvent(new KeyboardEvent("keydown", {key, bubbles: true, cancelable: true}));
+ navigate("ArrowUp");
+ check.equal(view.selectedId, alpha);
+ navigate("ArrowRight");
+ check.equal(view.selectedId, alpha, "folded descendants cannot receive keyboard selection");
+ navigate("ArrowUp");
+ check.equal(view.selectedId, alpha, "navigation does not wrap at sibling boundaries");
+ navigate("ArrowLeft");
+ check.equal(view.selectedId, model.root.id);
+ navigate("ArrowRight");
+ check.equal(view.selectedId, alpha);
+ model.nodes.get(alpha).collapsed = false;
+ view.update(model);
+ navigate("ArrowRight");
+ check.equal(view.selectedId, model.nodes.get(alpha).children[0].id);
+ navigate("ArrowLeft");
+ navigate("ArrowDown");
+ check.equal(view.selectedId, beta);
+ const beforeSpaceEdit = edits.length;
+ view.setReadOnly(true);
+ navigate(" ");
+ check.equal(edits.length, beforeSpaceEdit);
+ view.setReadOnly(false);
+ navigate(" ");
+ check.equal(edits[edits.length - 1], beta, "space opens the selected node editor");
+ navigate("ArrowUp");
+ check.equal(view.selectedId, beta, "editing keeps arrow keys inside the editor");
+ view.setEditing();
+ select(model.root.id);
+ navigate(" ");
+ const titleInput = host.querySelector<HTMLTextAreaElement>(".list-mindmap__root-title");
+ check.ok(titleInput);
+ check.equal(titleInput.selectionStart, titleInput.value.length);
+ check.equal(titleInput.selectionEnd, titleInput.value.length);
+ titleInput.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));
+ check.equal(document.activeElement, host);
+ edits.length = beforeSpaceEdit;
+ model.nodes.get(alpha).collapsed = true;
+ view.update(model);
+ select(beta);
const originalEditable = host.parentElement.contentEditable;
host.parentElement.contentEditable = "true";
for (const key of ["Tab", "Enter"]) {
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index 84f9c7058f..577fe0e342 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -1172,7 +1172,7 @@ export class ListMindmapView {
});
};
- private editRootTitle(id: string) {
+ private editRootTitle(id: string, toEnd = false) {
this.finishRelationEdit?.(true);
const content = this.getContentHost(id);
const input = createElement("textarea", "list-mindmap__root-title");
@@ -1210,10 +1210,15 @@ export class ListMindmapView {
if (!event.isComposing && (event.key === "Enter" || event.key === "Escape")) {
event.preventDefault();
finish(event.key === "Enter");
+ this.options.host.focus({preventScroll: true});
}
});
input.focus();
- input.select();
+ if (toEnd) {
+ input.setSelectionRange(input.value.length, input.value.length);
+ } else {
+ input.select();
+ }
}
private editRelationLabel(event: MouseEvent) {
@@ -1313,7 +1318,47 @@ export class ListMindmapView {
if (event.isComposing || target.closest("input, textarea, select, .list-mindmap__node--editing")) {
return;
}
- if ((event.key === "Tab" || event.key === "Enter") && !this.options.readOnly &&
+ if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", " "].includes(event.key) &&
+ !this.editingId && !this.relationFrom && this.selectedId &&
+ !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey &&
+ !target.isContentEditable && !target.closest("button, a")) {
+ const node = this.model.nodes.get(this.selectedId);
+ if (!node) {
+ return;
+ }
+ if (event.key === " ") {
+ if (this.options.readOnly || event.repeat) {
+ return;
+ }
+ this.finishThen(() => {
+ if (this.selectedId !== node.id) {
+ return;
+ }
+ if (node.virtual) {
+ this.editRootTitle(node.id, true);
+ } else {
+ this.setEditing(node.id);
+ this.options.onEdit?.(node.id, this.getContentHost(node.id));
+ }
+ });
+ } else {
+ const parent = this.model.nodes.get(node.parentId);
+ let next: string;
+ if (event.key === "ArrowLeft") {
+ next = parent?.id;
+ } else if (event.key === "ArrowRight") {
+ if (!(this.folded.get(node.id) ?? node.collapsed)) {
+ next = node.children[0]?.id;
+ }
+ } else if (parent) {
+ const index = parent.children.findIndex(child => child.id === node.id);
+ next = parent.children[index + (event.key === "ArrowUp" ? -1 : 1)]?.id;
+ }
+ if (next) {
+ this.selectNode(next);
+ }
+ }
+ } else if ((event.key === "Tab" || event.key === "Enter") && !this.options.readOnly &&
!this.editingId && !this.relationFrom && this.selectedId && !event.repeat &&
!event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey &&
!target.isContentEditable && !target.closest("button, a")) {