From c55dc7867e987c5410d47676c7b78ccd0f80ca45 Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Tue, 28 Apr 2026 16:13:26 -0400 Subject: [PATCH] add the gate for backlink --- apps/obsidian/src/utils/createNode.ts | 2 +- apps/obsidian/src/utils/registerCommands.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/obsidian/src/utils/createNode.ts b/apps/obsidian/src/utils/createNode.ts index ac88f65f2..e16a2de04 100644 --- a/apps/obsidian/src/utils/createNode.ts +++ b/apps/obsidian/src/utils/createNode.ts @@ -134,7 +134,7 @@ export const createDiscourseNode = async ({ nodeType, }); - if (newFile && editor) { + if (newFile && editor && editor.somethingSelected()) { editor.replaceSelection(`[[${formattedNodeName}]]`); } diff --git a/apps/obsidian/src/utils/registerCommands.ts b/apps/obsidian/src/utils/registerCommands.ts index a9af4e237..d2131108d 100644 --- a/apps/obsidian/src/utils/registerCommands.ts +++ b/apps/obsidian/src/utils/registerCommands.ts @@ -36,8 +36,8 @@ const createModifyNodeModalSubmitHandler = ( relationshipTargetFile, }: ModifyNodeSubmitParams) => { if (selectedExistingNode) { - if (editor) { - editor.replaceSelection(`[[${selectedExistingNode.basename}]]`); + if (editor && editor.somethingSelected()) { + editor?.replaceSelection(`[[${selectedExistingNode.basename}]]`); } await addRelationIfRequested(plugin, selectedExistingNode, { relationshipId,