Skip to content

feat: Resolve reference designator text for {NAME}, {REF}, and {REFERENCE} in SchematicText#2058

Merged
seveibar merged 5 commits intotscircuit:mainfrom
techmannih:jap
Mar 17, 2026
Merged

feat: Resolve reference designator text for {NAME}, {REF}, and {REFERENCE} in SchematicText#2058
seveibar merged 5 commits intotscircuit:mainfrom
techmannih:jap

Conversation

@techmannih
Copy link
Member

@techmannih techmannih commented Mar 15, 2026

This PR implements dynamic replacement of reference designator within primitives. This allows users to use variables like {NAME} or {REF} inside symbol text, which will then be automatically resolved to the component's reference designator (e.g., U1, R5) during rendering.

Changes

Added a protected _resolveText method that searches for the parent NormalComponent and performs regex-based substitution for {NAME}, {REF}, and {REFERENCE}.

Updated the render phase to process the text property through _resolveText before inserting it into the database.

  • Tests: Added a new test file schematic-text-refdes.test.tsx and corresponding snapshots to verify that text inside chip symbols are correctly replaced with the component's name.

Testing

  • Verified that {NAME} is correctly replaced with the component name.
  • Verified that normalization for Circuit JSON is preserved.
  • All tests passed with bun test.

@vercel
Copy link

vercel bot commented Mar 15, 2026

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Mar 16, 2026 3:52pm

Request Review

@techmannih techmannih changed the title feat: Resolve reference designator placeholders ({NAME}, {REF}) in SchematicText feat: Resolve reference designator text ({NAME}, {REF}) in SchematicText Mar 15, 2026
@techmannih techmannih changed the title feat: Resolve reference designator text ({NAME}, {REF}) in SchematicText feat: Resolve reference designator text for {NAME}, {REF}, and {REFERENCE} in SchematicText Mar 15, 2026
Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve text should take no arguments

<schematictext schX={-0.35} schY={-0.35} text="-" fontSize={0.3} />

<port
name="IN+"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an invalid port name and should throw, dont use it

@seveibar
Copy link
Contributor

Neither IN+ nor IN- are valid port names

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

@seveibar seveibar merged commit 5375a34 into tscircuit:main Mar 17, 2026
12 checks passed
@techmannih techmannih deleted the jap branch March 17, 2026 06:44
@tscircuitbot
Copy link
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

3 participants