Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/ui/node/new.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

export const NewNode = {
view({attrs: {workbench, path}}) {
const startNew = (e) => {
workbench.executeCommand("insert-child", {node: path.node, path}, e.target.value);
}
const tabNew = (e) => {
const keydown = (e) => {
if (e.key === "Tab") {
e.stopPropagation();
e.preventDefault();
if (node.childCount > 0) {
const lastchild = path.node.children[path.node.childCount-1];
workbench.executeCommand("insert-child", {node: lastchild, path});
}
} else {
workbench.executeCommand("insert-child", {node: path.node, path}, e.target.value);
}
}
return (
Expand All @@ -23,8 +22,7 @@ export const NewNode = {
<div class="flex grow">
<input class="grow"
type="text"
oninput={startNew}
onkeydown={tabNew}
onkeydown={keydown}
value={""}
/>
</div>
Expand Down