feat(web): automatic links#598
Conversation
- Add experimental web platform note; EnrichedText is iOS/Android only for now - Replace all "Both" platform cells with explicit iOS/Android/Web labels - cursorColor: Android, Web only (iOS uses selectionColor for cursor color) - useHtmlNormalizer: iOS, Android only — ignored on web - contextMenuItems: iOS, Android only — not available on web - linkRegex: update default value label to "platform default regex" - onPasteImages: add web note about blob URLs and URL.revokeObjectURL() - Add onSubmitEditing, returnKeyLabel, returnKeyType, submitBehavior props - returnKeyLabel: iOS/Android only — browsers don't allow customizing return key label - returnKeyType: web supports only enterkeyhint-compatible values - Add Keyboard Shortcuts (Web only) section with full shortcut table Assumes PRs #600 (submit props), #598 (automatic links), #584 (image paste), #603 (shortcuts) will be merged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kacperzolkiewski
left a comment
There was a problem hiding this comment.
When we type swmansion.com, in HTML I can see that https:// is automatically added to the href. Is this the intended behavior?
Screen.Recording.2026-05-26.at.09.02.49.mov
|
When we paste text containing a link, it is treated as a manually added link, which allows inserting new lines inside it: Screen.Recording.2026-05-26.at.09.42.49.mov |
208c368 to
39080f7
Compare
removed automatic |
now it checks if |
|
It looks to me like |
There was a problem hiding this comment.
Pull request overview
This PR adds automatic link detection for the web EnrichedTextInput by introducing a custom ProseMirror/Tiptap plugin that applies link marks based on a configurable linkRegex, while sharing a single link-detection emitter to avoid duplicate onLinkDetected events.
Changes:
- Added a custom
AutolinkPluginthat scans edited blocks and applies/removeslinkmarks based on a default URL regex or a providedlinkRegexprop. - Refactored
useOnLinkDetectedto emit through a sharedLinkEmitterState(emitLinkDetected) so autolink and selection-based detection dedupe properly. - Added/updated example UI + Playwright E2E coverage for autolink typing and paste flows, plus updated web docs.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/useOnLinkDetected.ts | Refactors link detection to use a shared emitter state and improved range detection at cursor boundaries. |
| src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts | Types Extension.create options for the plugin configuration. |
| src/web/pmPlugins/AutolinkPlugin/index.ts | Adds the main autolink detection + mark application ProseMirror plugin. |
| src/web/pmPlugins/AutolinkPlugin/autolinkRegex.ts | Adds default URL matching + helper to globalize custom regex. |
| src/web/formats/EnrichedLink.ts | Adds an internal-only auto attribute to link marks. |
| src/web/EnrichedTextInput.tsx | Wires linkRegex + AutolinkPlugin + shared LinkEmitterState into the editor. |
| src/web/emitLinkDetected.ts | Introduces shared emitter state + dedupe logic for link-detected events. |
| docs/WEB.md | Documents automatic link detection as supported on web. |
| apps/example-web/src/testScreens/TestLinks.tsx | Adds controls for testing default/disabled/custom linkRegex modes. |
| apps/example-web/src/App.tsx | Demonstrates passing a LINK_REGEX prop on web example app. |
| .playwright/tests/links.spec.ts | Adds E2E tests for autolink while typing and pasting, and for disabling autolink. |
| .playwright/playwright.config.ts | Enables clipboard permissions needed for paste tests. |
| .playwright/helpers/clipboard.ts | Adds helper to dispatch a plain-text paste event into the editor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…anges Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Functionally works well, however there are failing e2e tests: |
Summary
linkRegexpropuseOnLinkDetectedso it uses a sharedLinkEmitterwith autolink plugin, because we want to emit an event when an automatic link is created, but we also do no want to send the same event twice.Linkextensions from Tiptap, as it doesn't allow passing any regex, and it also struggles with extending automatic links on the right. I've implemented a custom plugin that looks at changed rages and research using a regex for texts where we should applied the automatic link mark.Test Plan
yarn test:e2e:webto see if all the tests passyarn example-web devand play around with automatic links, changeLINK_REGEXinapps/example-web/App.tsxScreenshots / Videos
Compatibility
Checklist