[lexical-link][Bug Fix] avoid auto-linking urls in code snippets#8036
[lexical-link][Bug Fix] avoid auto-linking urls in code snippets#8036xnt wants to merge 2 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
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.
|
#8123 should be a sufficient fix for this issue |
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
After