#8459·lexical

Feature: Wrap line and scrolling in code blocks

Author: levenstaCreated May 2, 2026Updated Sep 12, 2026
Labelsenhancementcode blocks

Description

Currently, a code block in the playground can contain content of any size, with overflow and scrolling within the element. When a line inside the code block is too long and overflows the container, navigating further within the line becomes difficult because changing the selection position with MOVE_TO_END (Ctrl + ArrowRight) or MOVE_TO_START (Ctrl + ArrowLeft) does not scroll the content inside the block

https://github.com/user-attachments/assets/85fbcac2-117e-4eda-bbc5-30f2880018c5

It would be nice to solve this problem by at least enabling auto-scrolling within the line when moving the cursor with the arrow keys. Ideally, this should be supplemented so that the content within the block doesn’t overflow, but instead wraps to the next line without creating a line break. Something like the word wrap mode in VS Code

Playground example

Impact

In the case of word wrap mode, it would be nice to be able to configure it via an extension. The challenge in implementing such a mode is that we will most likely have to use the experimental getDOMSlot API https://github.com/facebook/lexical/issues/8201, since it is impossible to render such an adaptive editor gutter using only pseudo-elements

Image