Skip to content

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

@juusolain

Description

@juusolain

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.

Lexical version:

Steps To Reproduce

  1. In Lexical playground, turn off code highlighting
    2.Add a code block and type a link in the code block

Link to code example: https://playground.lexical.dev/?isCodeHighlighted=false

The current behavior

Links are highlighted in code blocks

The expected behavior

AutoLink should ignore links in code blocks

Impact of fix

My current use case expects code blocks to look like code instead of having interactive links. For example, most links included are not meant to be opened by the user, such as in code examples of API calls.
If the current behaviour is desired in some cases, an option could be added to disable highlighting in certain contexts such as code blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions