From 3b348205d4312ad9c3d2479cd8b23ff49b6df64d Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Tue, 5 May 2026 18:36:34 -0400 Subject: [PATCH] ENG-1626 Pre-fill Create node dialog with selected text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/obsidian/src/utils/registerCommands.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/obsidian/src/utils/registerCommands.ts b/apps/obsidian/src/utils/registerCommands.ts index 9401c1c0b..052c35144 100644 --- a/apps/obsidian/src/utils/registerCommands.ts +++ b/apps/obsidian/src/utils/registerCommands.ts @@ -94,15 +94,15 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => { id: "create-discourse-node", name: "Create discourse node", callback: () => { - const currentFile = - plugin.app.workspace.getActiveViewOfType(MarkdownView)?.file || - undefined; - const editor = - plugin.app.workspace.getActiveViewOfType(MarkdownView)?.editor; + const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView); + const currentFile = activeView?.file || undefined; + const editor = activeView?.editor; + const selectedText = editor?.getSelection()?.trim() || undefined; new ModifyNodeModal(plugin.app, { nodeTypes: plugin.settings.nodeTypes, plugin, currentFile, + initialTitle: selectedText, onSubmit: createModifyNodeModalSubmitHandler(plugin, editor), }).open(); },