Skip to content

Commit 3b34820

Browse files
trangdoan982claude
andcommitted
ENG-1626 Pre-fill Create node dialog with selected text
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 cc26688 commit 3b34820

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
@@ -94,15 +94,15 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => {
9494
id: "create-discourse-node",
9595
name: "Create discourse node",
9696
callback: () => {
97-
const currentFile =
98-
plugin.app.workspace.getActiveViewOfType(MarkdownView)?.file ||
99-
undefined;
100-
const editor =
101-
plugin.app.workspace.getActiveViewOfType(MarkdownView)?.editor;
97+
const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView);
98+
const currentFile = activeView?.file || undefined;
99+
const editor = activeView?.editor;
100+
const selectedText = editor?.getSelection()?.trim() || undefined;
102101
new ModifyNodeModal(plugin.app, {
103102
nodeTypes: plugin.settings.nodeTypes,
104103
plugin,
105104
currentFile,
105+
initialTitle: selectedText,
106106
onSubmit: createModifyNodeModalSubmitHandler(plugin, editor),
107107
}).open();
108108
},

0 commit comments

Comments
 (0)