Bug: Pasting content that has disjointed pre tags into an existing code block loses content.
- Dominant language
- TypeScript
- Stars
- 23.9k
- Forks
- 2.2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 57
Description
Lexical version: v0.50.0+dev.esm
## Steps To Reproduce
1. Copy the output of this HTML from somewhere like jsfiddle
```
Some text here
Some more text there
```
2. Paste the clipboard in the lexical playground
3. Notice that a code block with content `some text here` then an empty line then another code block with content `Some more text there` will be added
4. Delete everything from the playground so you are in a fresh state
5. Now add a code block with ctrl+alt+c and ensure your cursor is inside the code block.
6. Paste content from your clipboard again
7. Notice that only `Some text here` will be copied, the second part is lost.
## The current behavior
Pasting multiple pre tags inside an existing code block means only the first one is correctly pasted
## The expected behavior
All consecutive pre tags are collapsed into the same code block, or expanded to different code blocks, as long as no content is lost from the paste operation.
## Impact of fix
Lower severity as not a lot of places copy disjointed pre tags, but notably, telemetry services like jenkins and humio do, so a lot of internal customers that rely on a workflow of creating a code block > pasting the logs are affected. This can be somewhat alleviated as not pre-creating the code block removes this issue, but we have still gotten reports from this awkward behavior.
Contributor guide
Research direction
Reproduce the paste sequence in the Lexical playground: copy HTML containing two disjointed pre tags, paste into a fresh code block, and confirm the second segment is lost. Trace the clipboard paste handling for an existing code block. Done means all consecutive pre-tag content is preserved, either in one code block or in separate code blocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100