Skip to content

Commit 6121851

Browse files
trangdoan982claude
andauthored
ENG-1626 Pre-fill Create node dialog with selected text (#1003)
When the "Create discourse node" command is triggered with text selected in the editor, pass it as initialTitle to ModifyNodeModal so the title field is pre-filled — matching the existing behaviour of the right-click context menu. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 42cae58 commit 6121851

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

apps/obsidian/src/utils/registerCommands.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => {
6565
id: "create-discourse-node",
6666
name: "Create discourse node",
6767
callback: () => {
68-
const currentFile =
69-
plugin.app.workspace.getActiveViewOfType(MarkdownView)?.file ||
70-
undefined;
71-
const editor =
72-
plugin.app.workspace.getActiveViewOfType(MarkdownView)?.editor;
68+
const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView);
69+
const currentFile = activeView?.file || undefined;
70+
const editor = activeView?.editor;
71+
const selectedText = editor?.getSelection()?.trim() || undefined;
7372
new ModifyNodeModal(plugin.app, {
7473
nodeTypes: plugin.settings.nodeTypes,
7574
plugin,
7675
currentFile,
76+
initialTitle: selectedText,
7777
onSubmit: createModifyNodeModalSubmitHandler(plugin, editor),
7878
}).open();
7979
},

0 commit comments

Comments
 (0)