Repository navigation
Conversation
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.
|
@PaulLampe is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
The link toolbar (create/edit link form) prepends
https://to every URL that does not start with one of the built-inVALID_LINK_PROTOCOLS. Editors that allow an extra scheme throughlinks.isValidLinktherefore gethttps://myapp://pagewhen a user typesmyapp://pageinto the form, even though paste, autolink and HTML import accept the same link.Rationale
links.isValidLinkis 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 toVALID_LINK_PROTOCOLS): keeps URLs with a built-in protocol, keeps a URL with any other explicit scheme whenisValidLinkaccepts it, and prependsDEFAULT_LINK_PROTOCOLotherwise.LinkToolbarExtensionreadslinks.isValidLinkfrom the editor options (falling back toisAllowedUri) and exposesnormalizeUrl(url).EditLinkMenuItemsusesnormalizeUrlinstead of its localvalidateUrl, for botheditLinkand theonSubmitpath used byCreateLinkButton.links.isValidLinkdocs mention the link toolbar.Impact
None without a custom
isValidLink: the defaultisAllowedUrirejects schemes outside the built-in list, so those URLs still gethttps://prepended exactly as before. Addresses without a scheme (example.com) are unchanged.Testing
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/extensionsinpackages/core: 369 passed.tsc --noEmitandvp lintinpackages/coreandpackages/react: no new errors or warnings.Screenshots/Video
n/a
Checklist
Additional Notes
Repro: create an editor with
links: { isValidLink: (href) => isAllowedUri(href) || href.startsWith("myapp:") }, select text, open the link form, entermyapp://pageand submit. The saved href ishttps://myapp://page.Summary by CodeRabbit
https://prefix.