Skip to content

Conversation

@xnt
Copy link

@xnt xnt commented Dec 18, 2025

Description

The AutoLinkPlugin (registerAutoLink underneath) does not take code blocks into account, and inserts AutoLinks in code blocks, even though this is not usually desired. This only happens if a highlighter plugin is not used. Can be easily reproduced in the Lexical playground.

This fix validates that the current block is not a code block before trying to insert auto-links. Also, adds a test with that check.

Closes #8028

Test plan

Before

image

After

image image

@vercel
Copy link

vercel bot commented Dec 18, 2025

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

Project Deployment Review Updated (UTC)
lexical Error Error Dec 18, 2025 10:48pm
lexical-playground Error Error Dec 18, 2025 10:48pm

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 18, 2025
Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a dependency on @lexical/code from @lexical/link which breaks the build and is not desired. One way or another this issue should be addressed in a way that doesn't introduce this kind of dependency (note also that checking getType() is also not an acceptable solution because the type of a CodeNode can be any string if it's subclassed).

A cleaner possibility might be to add configuration to AutoLinkConfig to allow you to specify some predicates that control which nodes shouldn't be considered. The extensions could have a peer dependency to set this up automatically for CodeNode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: AutoLink produces links inside non-highlighted code-blocks

2 participants