Skip to content

Bug: registerCodeHighlighting throws when creating a code node within the initial editor state since v0.22.0 #7014

@vydimitrov

Description

@vydimitrov

Since version 0.22.0, registerCodeHighlighting throws - Lexical node does not exist in active editor state. Avoid using the same node references between nested closures from editorState.read/editor.update., when trying to create a code node within the initial editor state. I tested the code in the Codesandbox(below) with version 0.21.0 and it works like a charm.

Lexical version: 0.22.0

Steps To Reproduce

  1. Try to create a simple code block within the initial editor state as shown in the Codesandbox
  2. The editor throws an error from registerCodeHighlighting

image

Link to code example: Codesandbox demo

The current behavior

The editor immediately throws an error

The expected behavior

The editor is able to create the initial editor state using create code node

Impact of fix

It happens every time when we want to create the initial editor state with code node

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions