Skip to content

Commit 75f19b3

Browse files
trangdoan982claude
andauthored
ENG-1692: Open ModifyNodeModal pre-populated on hotkey node creation (#1001)
Instead of immediately calling createDiscourseNode after a type is picked in InlineNodeTypePicker, open ModifyNodeModal with the selected text as initialTitle and the chosen type pre-selected — consistent with right-click and tag-click creation flows. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3a37453 commit 75f19b3

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

apps/obsidian/src/components/InlineNodeTypePicker.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Editor } from "obsidian";
1+
import { Editor, MarkdownView } from "obsidian";
22
import { DiscourseNode } from "~/types";
3-
import { createDiscourseNode } from "~/utils/createNode";
43
import type DiscourseGraphPlugin from "~/index";
4+
import { createModifyNodeModalSubmitHandler } from "~/utils/registerCommands";
5+
import ModifyNodeModal from "./ModifyNodeModal";
56

67
/**
78
* A popover that shows all node types inline near the cursor/selection.
@@ -98,7 +99,7 @@ export class InlineNodeTypePicker {
9899
itemEl.addEventListener("mousedown", (e) => {
99100
e.preventDefault();
100101
e.stopPropagation();
101-
void this.selectItem(item);
102+
this.selectItem(item);
102103
});
103104

104105
itemEl.addEventListener("mouseenter", () => {
@@ -138,14 +139,22 @@ export class InlineNodeTypePicker {
138139
}
139140
}
140141

141-
private async selectItem(item: DiscourseNode) {
142+
private selectItem(item: DiscourseNode) {
142143
this.close();
143-
await createDiscourseNode({
144+
const currentFile =
145+
this.options.plugin.app.workspace.getActiveViewOfType(MarkdownView)
146+
?.file || undefined;
147+
new ModifyNodeModal(this.options.plugin.app, {
148+
nodeTypes: this.options.plugin.settings.nodeTypes,
144149
plugin: this.options.plugin,
145-
nodeType: item,
146-
text: this.options.selectedText,
147-
editor: this.options.editor,
148-
});
150+
initialTitle: this.options.selectedText,
151+
initialNodeType: item,
152+
currentFile,
153+
onSubmit: createModifyNodeModalSubmitHandler(
154+
this.options.plugin,
155+
this.options.editor,
156+
),
157+
}).open();
149158
}
150159

151160
private setupEventHandlers() {
@@ -173,7 +182,7 @@ export class InlineNodeTypePicker {
173182
e.stopPropagation();
174183
const selectedItem = this.items[this.selectedIndex];
175184
if (selectedItem) {
176-
void this.selectItem(selectedItem);
185+
this.selectItem(selectedItem);
177186
}
178187
} else if (e.key === "Escape") {
179188
e.preventDefault();

0 commit comments

Comments
 (0)