Skip to content

fix(react): keep link toolbar URLs with schemes accepted by isValidLink - #3347

Open
PaulLampe wants to merge 1 commit into
TypeCellOS:mainfrom
PaulLampe:fix/link-form-custom-schemes
Open

PaulLampe wants to merge 1 commit into
TypeCellOS:mainfrom
PaulLampe:fix/link-form-custom-schemes

Conversation

@PaulLampe

@PaulLampe PaulLampe commented Nov 13, 2026 •

Copy link
Copy Markdown

Summary

The link toolbar (create/edit link form) prepends https:// to every URL that does not start with one of the built-in VALID_LINK_PROTOCOLS. Editors that allow an extra scheme through links.isValidLink therefore get https://myapp://page when a user types myapp://page into the form, even though paste, autolink and HTML import accept the same link.

Rationale

links.isValidLink is documented as the way to support additional URI schemes. The link toolbar was the one entry point that ignored it, so custom-scheme links could only be added by pasting.

Changes

  • normalizeLinkUrl(url, isValidLink) in @blocknote/core/extensions (next to VALID_LINK_PROTOCOLS): keeps URLs with a built-in protocol, keeps a URL with any other explicit scheme when isValidLink accepts it, and prepends DEFAULT_LINK_PROTOCOL otherwise.
  • LinkToolbarExtension reads links.isValidLink from the editor options (falling back to isAllowedUri) and exposes normalizeUrl(url).
  • EditLinkMenuItems uses normalizeUrl instead of its local validateUrl, for both editLink and the onSubmit path used by CreateLinkButton.
  • The links.isValidLink docs mention the link toolbar.

Impact

None without a custom isValidLink: the default isAllowedUri rejects schemes outside the built-in list, so those URLs still get https:// prepended exactly as before. Addresses without a scheme (example.com) are unchanged.

Testing

  • New unit tests in packages/core/src/extensions/LinkToolbar/protocols.test.ts (built-in protocol kept, bare address prefixed, accepted custom scheme kept, rejected scheme prefixed).
  • vp test --run src/extensions in packages/core: 369 passed.
  • tsc --noEmit and vp lint in packages/core and packages/react: no new errors or warnings.

Screenshots/Video

n/a

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

Repro: create an editor with links: { isValidLink: (href) => isAllowedUri(href) || href.startsWith("myapp:") }, select text, open the link form, enter myapp://page and submit. The saved href is https://myapp://page.

Summary by CodeRabbit

  • Bug Fixes
    • Link editing now applies the configured link validation rules when normalizing URLs.
    • Accepted URL schemes are preserved, including custom schemes; addresses without an accepted scheme receive an https:// prefix.

The link toolbar prepended https:// to every URL that did not start with
one of the built-in protocols, so a scheme the editor accepts through
links.isValidLink (e.g. myapp://page) was saved as https://myapp://page.
The toolbar now keeps a URL whose explicit scheme isValidLink accepts and
prepends the default protocol otherwise.
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown

@PaulLampe is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The link toolbar now normalizes URLs with the configured validator. The React link edit menu uses this normalization when submitting URLs. Tests cover accepted and rejected URL schemes.

Changes: Link URL normalization

Layer / File(s) Summary
Validator and normalization policy
packages/core/src/editor/BlockNoteEditor.ts, packages/core/src/extensions/LinkToolbar/*
The extension selects the configured validator and exposes URL normalization. The helper preserves accepted explicit schemes and prefixes other inputs with https://. Tests cover these cases. The editor documentation describes validation points.
React link submission
packages/react/src/components/LinkToolbar/EditLinkMenuItems.tsx
The edit menu uses the extension's normalization method for nonempty callback URLs and URLs passed to editLink. The optional callback still receives an empty URL unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: nperez0111, matthewlipski

Merge Risk: Minimal · up to b81d4

This change keeps link toolbar URLs with custom schemes that the editor's link validator accepts, instead of prepending https://. Behavior without a custom validator is reported as unchanged. No actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the link toolbar now keeps URLs whose custom schemes are accepted by links.isValidLink. It follows the fix(react) convention and matches the summary and objectives. It…
Description check Passed The description follows the repository template. It has Summary, Rationale, Changes, Impact, Testing, Screenshots/Video, Checklist, and Additional Notes sections. It explains the bug, the fix, the aff…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the link toolbar now keeps URLs whose custom schemes are accepted by links.isValidLink. It follows the fix(react) convention and matches the summary and objectives. It is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the repository template. It has Summary, Rationale, Changes, Impact, Testing, Screenshots/Video, Checklist, and Additional Notes sections. It explains the bug, the fix, the affected files, the default-behavior impact, and a reproduction. The Screenshots/Video section is marked n/a. The Checklist items are checked. The Rationale and Impact sections are clear and specific. Nothing required is missing.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each link with care,
And keeps accepted schemes intact.
It adds https where needed there,
Then sends the edited link on track.
The rabbit hops, content and URL matched!

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 13205ef6-0da2-4ef8-aedf-f06af48762c8
Commits

Reviewing files that changed from the base of the PR and between 58a40d2 and b81d453.

Files selected for processing: 5

  • packages/core/src/editor/BlockNoteEditor.ts
  • packages/core/src/extensions/LinkToolbar/LinkToolbar.ts
  • packages/core/src/extensions/LinkToolbar/protocols.test.ts
  • packages/core/src/extensions/LinkToolbar/protocols.ts
  • packages/react/src/components/LinkToolbar/EditLinkMenuItems.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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