docs/solutions/logic-errors/2026-05-09-nested-clipboard-fragments-must-merge-into-active-text-block.md
Lexical regression 1384 is named for insert nodes, but the portable behavior is native clipboard insertion inside a code block. Copying text from a nested code line and pasting it inside another code line should insert text into the active line, not create a new code block sibling.
code-block before the target
code-block.Add a package contract for inserting this fragment shape:
[
{
type: 'code-block',
children: [{ type: 'code-line', children: [{ text: 'Add' }] }],
},
]
into a collapsed selection inside an existing code-line.
Then update insertFragment nested fitting so a single nested text-block child
from the same structural container merges into the active nested text block. The
operation replaces the container's children in one logical operation and places
selection after the inserted text.
Finally, add a browser proof in the code-highlighting example that uses native desktop clipboard shortcuts and asserts:
Slate clipboard fragments preserve ancestor structure. A partial copy inside a
code line can therefore arrive as code-block -> code-line -> text, even though
the intended paste target is already inside a compatible code-line.
The nested fitting path already knows how to replace the shared structural container. The missing branch was the single-child case where the copied container has exactly one compatible text-block child. Merging that child's children into the active text block preserves the surrounding code block and keeps the paste local to the active line.