Skip to content

Bug: Pasting from Ghostty terminal inserts unintended linebreaks #8418

@etrepum

Description

@etrepum

When pasting from Ghostty into Lexical you get a code block, because of the <div style="font-family: monospace; white-space: pre;"> wrapper. However, the contents is full of unintended linebreaks because it treats each <div style="display: inline"> as having an implicit linebreak.

Ghostty arguably should be using a natively inline element for this, but it should be straightforward to address in the importDOM infrastructure (and whatever replaces it).

Lexical version: v0.44

Steps To Reproduce

  1. Select and copy some text from a Ghostty terminal
  2. Paste into the playground

Some example HTML from Ghostty's clipboard code:

<div style="font-family: monospace; white-space: pre;"><div style="display: inline;color: rgb(181, 189, 104);font-weight: bold;">&#10095;</div> cd ~/src/lexical

<div style="display: inline;color: rgb(138, 190, 183);font-weight: bold;">lexical</div> on <div style="display: inline;color: rgb(178, 148, 187);font-weight: bold;">&#62488; main</div> <div style="display: inline;color: rgb(204, 102, 102);font-weight: bold;">[$&#8675;]</div> via <div style="display: inline;color: rgb(181, 189, 104);font-weight: bold;">&#59160; v22.17.0 </div>
<div style="display: inline;color: rgb(181, 189, 104);font-weight: bold;">&#10095;</div> </div>

The current behavior

playground url

Image

The expected behavior

playground url

Image

Impact of fix

importDOM will work more predictably in cases where <div> is used as an inline element

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions