[lexical-link][lexical-react] Feature: Allow custom punctuation for AutoLink boundaries#8378
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a configurable punctuation boundary set for AutoLink matching so custom matchers can treat additional separators (e.g., :) as boundaries without breaking URL autolinking (including embedded colons).
Changes:
- Thread a new optional
punctuationoption throughregisterAutoLinkand the ReactAutoLinkPlugin. - Add unit tests covering colon-delimited matches and port URLs containing colons.
- Update Flow declarations and React plugin docs to reflect the new option.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/lexical-website/docs/react/plugins.md | Documents the new punctuation prop for AutoLinkPlugin. |
| packages/lexical-react/src/LexicalAutoLinkPlugin.ts | Adds punctuation prop and passes it through to registerAutoLink. |
| packages/lexical-react/flow/LexicalAutoLinkPlugin.js.flow | Updates Flow typings for AutoLinkPlugin props (including punctuation). |
| packages/lexical-link/src/LexicalAutoLinkExtension.ts | Implements punctuation-driven boundary detection and threads config through core logic. |
| packages/lexical-link/src/tests/unit/LexicalAutoLinkExtension.test.ts | Adds coverage for default/custom punctuation behavior and embedded-colon URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
etrepum
left a comment
There was a problem hiding this comment.
pnpm run ci-check is failing
…punctuation for AutoLink boundaries
ab76069 to
c33950e
Compare
| export type AutoLinkConfig = { | ||
| matchers: LinkMatcher[]; | ||
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; |
There was a problem hiding this comment.
| excludeParents: Array<(parent: ElementNode) => boolean>; | |
| excludeParents: ((parent: ElementNode) => boolean)[]; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; | ||
| matchers: LinkMatcher[]; | ||
| separatorRegex?: RegExp; |
There was a problem hiding this comment.
| separatorRegex?: RegExp; | |
| separatorRegex: RegExp; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| export interface AutoLinkConfig { | ||
| matchers: LinkMatcher[]; | ||
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; |
There was a problem hiding this comment.
| excludeParents: Array<(parent: ElementNode) => boolean>; | |
| excludeParents: ((parent: ElementNode) => boolean)[]; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| * characters count as separators when validating auto-link | ||
| * boundaries. Defaults to `/[.,;\s]/`. | ||
| */ | ||
| separatorRegex?: RegExp; |
There was a problem hiding this comment.
Configuration of extensions should always use required properties unless undefined is specifically a value that is useful to the extension.
| separatorRegex?: RegExp; | |
| separatorRegex: RegExp; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| export function registerAutoLink( | ||
| editor: LexicalEditor, | ||
| config: AutoLinkConfig = defaultConfig, |
There was a problem hiding this comment.
This type will have to change accordingly to something like Partial<AutoLinkConfig> (which would require some implementation changes below to provide defaults for each value) or Partial<AutoLinkConfig> & Omit<AutoLinkConfig, 'separatorRegex'>
| config: AutoLinkConfig = defaultConfig, | |
| config: Partial<AutoLinkConfig> & Omit<AutoLinkConfig, 'separatorRegex'> = defaultConfig, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| export type {ChangeHandler, LinkMatcher}; | ||
|
|
||
| declare export function AutoLinkPlugin(props: { | ||
| excludeParents?: Array<(parent: ElementNode) => boolean>, |
There was a problem hiding this comment.
| excludeParents?: Array<(parent: ElementNode) => boolean>, | |
| excludeParents?: ((parent: ElementNode) => boolean)[], |
|
|
||
| declare export function AutoLinkPlugin(props: { | ||
| excludeParents?: Array<(parent: ElementNode) => boolean>, | ||
| matchers: Array<LinkMatcher>, |
There was a problem hiding this comment.
| matchers: Array<LinkMatcher>, | |
| matchers: LinkMatcher[], |
|
@etrepum I've pushed the updates to address your feedback regarding the Flow array syntax and the AutoLinkConfig properties. Could you please take another look when you have a chance? |
etrepum
left a comment
There was a problem hiding this comment.
It doesn't look like you addressed any of the last round of suggestions?
| export type AutoLinkConfig = { | ||
| matchers: LinkMatcher[]; | ||
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; | ||
| matchers: LinkMatcher[]; | ||
| separatorRegex?: RegExp; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| export interface AutoLinkConfig { | ||
| matchers: LinkMatcher[]; | ||
| changeHandlers: ChangeHandler[]; | ||
| excludeParents: Array<(parent: ElementNode) => boolean>; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| * characters count as separators when validating auto-link | ||
| * boundaries. Defaults to `/[.,;\s]/`. | ||
| */ | ||
| separatorRegex?: RegExp; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| export function registerAutoLink( | ||
| editor: LexicalEditor, | ||
| config: AutoLinkConfig = defaultConfig, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Fixes #8189
Summary
Test plan