Bug
When pasting multiline plain text into an existing (empty) code block, only the first couple of lines stay inside the code block. The remaining lines spill out below as regular paragraphs.
Steps to reproduce
- Create an empty code block in the editor (via toolbar or ``` shortcut)
- Place cursor inside the code block
- Copy multiline code as plain text (e.g., from GitHub's file viewer, a terminal, or a text editor)
- Paste into the code block
Expected
All pasted lines should be inserted inside the code block.
Actual
Only the first 1-2 lines remain in the code block. The rest appear as plain paragraphs below it.
Root cause
In src/editor/clipboard.js:19, #isPastingIntoCodeBlock() returns true and the custom paste handler bails out (return false), deferring to Lexical's default $insertDataTransferForRichText. The default handler doesn't properly constrain multiline plain text insertion within a CodeNode — it splits on newlines and creates separate nodes that escape the code block boundary.
Related
- GitHub's file viewer copies as plain text only (invisible textarea), so the CommonMark
<code class="language-*"> detection in detectLanguage() never fires for that source. This is a separate issue but compounds the UX problem.
Screenshots

🤖 Generated with Claude Code
Bug
When pasting multiline plain text into an existing (empty) code block, only the first couple of lines stay inside the code block. The remaining lines spill out below as regular paragraphs.
Steps to reproduce
Expected
All pasted lines should be inserted inside the code block.
Actual
Only the first 1-2 lines remain in the code block. The rest appear as plain paragraphs below it.
Root cause
In
src/editor/clipboard.js:19,#isPastingIntoCodeBlock()returnstrueand the custom paste handler bails out (return false), deferring to Lexical's default$insertDataTransferForRichText. The default handler doesn't properly constrain multiline plain text insertion within aCodeNode— it splits on newlines and creates separate nodes that escape the code block boundary.Related
<code class="language-*">detection indetectLanguage()never fires for that source. This is a separate issue but compounds the UX problem.Screenshots
🤖 Generated with Claude Code