Skip to content

Text node selection#199

Draft
aidenybai wants to merge 2 commits intomainfrom
cursor/text-node-selection-d9e8
Draft

Text node selection#199
aidenybai wants to merge 2 commits intomainfrom
cursor/text-node-selection-d9e8

Conversation

@aidenybai
Copy link
Owner

@aidenybai aidenybai commented Feb 27, 2026

Add support for selecting and copying text nodes to enable direct text content interaction.


Open in Web Open in Cursor 


Summary by cubic

Adds precise text node selection and copy within mixed-content elements. Labels now show "truncated text…" and copy feedback uses exact text bounds.

  • New Features
    • Detect text nodes under the cursor using caretRangeFromPoint.
    • Render accurate text bounds via Range; selection label shows truncated text in quotes.
    • Copy text node content with parent-derived context (getTextNodeContext).
    • Integrated into hover, freeze, selection bounds, copy flow, and context menu.

Written for commit b7c12fb. Summary will update on new commits.

When hovering over text within elements that have mixed content (both text
nodes and child elements), the tool now selects the specific text node
rather than the entire parent element. This provides more precise
selections.

Changes:
- Add get-text-node-at-position utility using caretRangeFromPoint API
- Add create-text-node-bounds utility using Range API for text node bounds
- Add getTextNodeContext in context.ts for text node copy content
- Integrate text node detection into hover, selection bounds, tag name,
  copy flow, and context menu in core/index.tsx
- Text nodes show as #text in the selection label

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Feb 27, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link
Contributor

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-website Ready Ready Preview, Comment Feb 27, 2026 10:24am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

@react-grab/cli

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cli@199

grab

npm i https://pkg.pr.new/aidenybai/react-grab/grab@199

@react-grab/ami

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/ami@199

@react-grab/amp

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/amp@199

@react-grab/claude-code

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/claude-code@199

@react-grab/codex

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/codex@199

@react-grab/copilot

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/copilot@199

@react-grab/cursor

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cursor@199

@react-grab/droid

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/droid@199

@react-grab/gemini

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/gemini@199

@react-grab/opencode

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/opencode@199

react-grab

npm i https://pkg.pr.new/aidenybai/react-grab@199

@react-grab/relay

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/relay@199

@react-grab/utils

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/utils@199

commit: b7c12fb

…text nodes

- Tag display now shows Component."truncated text..." instead of #text
- Prevent parent element bounds from overriding text node bounds in
  the Copied! feedback label and grabbed box highlight
- Add TEXT_NODE_TAG_DISPLAY_MAX_LENGTH constant (20 chars)

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants