From 2abe0f9ca8f5d78555d29a068d4504c41d81653d Mon Sep 17 00:00:00 2001 From: sid597 Date: Mon, 25 Aug 2025 20:56:42 +0530 Subject: [PATCH] handle node tags with # in front and update placeholder to use # --- apps/roam/src/components/DiscourseNodeMenu.tsx | 10 +++++++--- apps/roam/src/components/settings/NodeConfig.tsx | 2 +- apps/roam/src/utils/renderNodeTagPopup.tsx | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/roam/src/components/DiscourseNodeMenu.tsx b/apps/roam/src/components/DiscourseNodeMenu.tsx index 62160488c..24fd56602 100644 --- a/apps/roam/src/components/DiscourseNodeMenu.tsx +++ b/apps/roam/src/components/DiscourseNodeMenu.tsx @@ -113,7 +113,7 @@ const NodeMenu = ({ setTimeout(() => { const currentText = textarea.value; const cursorPos = textarea.selectionStart; - const textToInsert = `#${tag} `; + const textToInsert = `#${tag.replace(/^#/, "")} `; const newText = `${currentText.substring( 0, @@ -249,9 +249,13 @@ const NodeMenu = ({ setActiveIndex(i)} diff --git a/apps/roam/src/components/settings/NodeConfig.tsx b/apps/roam/src/components/settings/NodeConfig.tsx index 0b1bd5eca..70b7c92c1 100644 --- a/apps/roam/src/components/settings/NodeConfig.tsx +++ b/apps/roam/src/components/settings/NodeConfig.tsx @@ -229,7 +229,7 @@ const NodeConfig = ({ onChange={handleTagChange} onBlur={handleTagBlur} error={tagError} - placeholder={`${node.text}`} + placeholder={`#${node.text.toLowerCase()}`} /> } diff --git a/apps/roam/src/utils/renderNodeTagPopup.tsx b/apps/roam/src/utils/renderNodeTagPopup.tsx index 4ea1204e1..453af5280 100644 --- a/apps/roam/src/utils/renderNodeTagPopup.tsx +++ b/apps/roam/src/utils/renderNodeTagPopup.tsx @@ -36,11 +36,15 @@ export const renderNodeTagPopupButton = ( const tag = tagAttr.replace(/^#/, "").toLowerCase(); const discourseNodes = getDiscourseNodes(); const discourseTagSet = new Set( - discourseNodes.map((n) => n.tag?.toLowerCase()).filter(Boolean), + discourseNodes + .map((n) => n.tag?.replace(/^#/, "").toLowerCase()) + .filter(Boolean), ); if (!discourseTagSet.has(tag)) return; - const matchedNode = discourseNodes.find((n) => n.tag?.toLowerCase() === tag); + const matchedNode = discourseNodes.find( + (n) => n.tag?.replace(/^#/, "").toLowerCase() === tag, + ); if (!matchedNode) return; @@ -67,7 +71,7 @@ export const renderNodeTagPopupButton = ( initialTitle: cleanedBlockText, }); }} - text={`Create ${matchedNode.text}`} + text={`Create #${matchedNode.tag?.replace(/^#/, "").toLowerCase()}`} /> } target={