Skip to content

ENG-2228 Add link support to tldraw text shapes in Obsidian (prototype C: reuse tldraw's link button) - #1504

Merged
trangdoan982 merged 2 commits into
eng-2228-add-link-support-to-tldraw-text-shapes-in-obsidianfrom
prototype-c-patch-hyperlinkbutton
Oct 9, 2026
Merged

trangdoan982 merged 2 commits into
eng-2228-add-link-support-to-tldraw-text-shapes-in-obsidianfrom
prototype-c-patch-hyperlinkbutton

Conversation

@trangdoan982

@trangdoan982 trangdoan982 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Draft — comparison only, not for merge. Stacked on #1442 so the diff shows only what this alternative changes. The decision between the two is open on #1442.

Reviewer brief

Result: The same text-shape links as #1442, but obsidian://open?file=… page links also work on geo, note, image, video and bookmark shapes, and the link icon is tldraw's own HyperlinkButton instead of our vendored copy.

How it differs from #1442:

#1442 This prototype
Patches tldraw@3.14.2.patch: eligibility gate only (26 lines) gate + export HyperlinkButton + cancelable tldraw.navigate-link event (201 lines), and @tldraw__validate@3.14.2.patch widening linkUrl (40 lines)
Shapes with page links text text, geo, note, image, video, bookmark
URL rule our allowlist for text, T.linkUrl for the rest T.linkUrl everywhere (patched)
Click handling in the vendored button inside TextLinkOverlay one listener on the editor container, utils/linkNavigation.ts, serving every link button
App code — net −50 lines

Review focus:

  • The validator patch changes the check body, not the protocol Set. Adding obsidian: to validLinkProtocols would also admit action URIs such as advanced-uri?commandid=; only obsidian://open with a file param passes.
  • Why the validator patch is load-bearing: geo/note/image/video/bookmark carry MakeUrlsValid migrations that silently blank any URL T.linkUrl rejects. Dropping the validator patch later would wipe saved obsidian:// links on those shapes at load.
  • The cost: patch surface goes 26 → 241 lines, all of which must be re-applied by hand on the next tldraw upgrade. The TextLinkDialog fork stays: tldraw's EditLinkDialog writes props.url, and text links live in meta.url.

Verification

Driven in a real vault over CDP at 52dd9c91: #1442's five text-link scenarios still pass, and a geo shape accepts an obsidian://open page link, renders the button without an href, and opens the page in the sidebar. 5cbaa2be only changes the dialog's hint copy and lint fixes; on that head check-types and lint are clean (0 warnings) and pnpm build has 0 errors.

Not verified: note, image, video and bookmark shapes were not driven; they share the geo path (same validator, same button, same listener) but no scenario covers them.

Scope check

Standards check

  • Ran $dg-pr-adherence-check against the final diff and PR metadata.

Not run — prototype.

Local delegated full review

  • Ran a comprehensive review of the entire final diff in a subagent with a fresh context.

Not run — prototype.

🤖 Generated with Claude Code

trangdoan982 and others added 2 commits October 1, 2026 14:06
Not for merge -- a comparison branch against 5253da0, which ships a two-line
eligibility patch and keeps a vendored hyperlink button.

Patches @tldraw/validate so linkUrl accepts obsidian://open?file=, editing the
check body rather than the protocol Set so advanced-uri's commandid stays
rejected. Patches tldraw to export HyperlinkButton, dispatch a cancelable
tldraw.navigate-link event from it, and keep non-web URIs out of href. One
listener in the app then serves every link button tldraw renders, so geo, note
and image shapes get the same in-app open and cross-vault check as text.

App code drops 477 -> 434 lines: the vendored button and our own allowlist go,
and the dialog's text-vs-geo validator split collapses. Patch surface grows
26 -> 241 lines across two packages, and becomes a behaviour patch on a shared
component rather than a predicate flip.

Verified over CDP: the five text-link scenarios still pass, and a geo shape now
accepts an obsidian page link, omits href, and opens it in the sidebar.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Entire-Checkpoint: 01M3WAA741724YSM5FFQ91Q97J
Validation was unified across shape types but the hint still told geo
shapes "Enter a URL." Also drops the unused T import and the never-narrowed
isValid call that tripped two lint warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@supabase

supabase Bot commented Oct 1, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
discourse-graph Skipped Skipped Oct 1, 2026 7:16pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 1, 2026

Copy link
Copy Markdown

ENG-2228

@trangdoan982
trangdoan982 merged commit e197200 into eng-2228-add-link-support-to-tldraw-text-shapes-in-obsidian Oct 9, 2026
9 checks passed
@trangdoan982

Copy link
Copy Markdown
Member Author

This approach was chosen and now lives in #1442; its commits merged into that PR's branch, not main. Review there.

This branch was previously deployed

1 inactive deployment
Preview — 5cbaa2be Deployed Oct 1, 2026 by vercel[bot]
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.

1 participant