mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-25 14:08:44 +02:00
The CodeHighlightPlugin's selection restoration could create an invalid Lexical selection targeting a LineBreakNode with type 'element'. Since LineBreakNode is not an ElementNode, Lexical threw during reconciliation and the LexicalErrorBoundary replaced the editor with an error state. The fix ensures findPoint never targets a LineBreakNode directly. Instead it falls back to an element-level selection on the parent CodeNode using the child index, which is always a valid target. Extracted the selection helpers (getCodeNodeAbsoluteOffset, findCodeNodeSelectionPoint, restoreCodeNodeSelection) into markdownEditor.ts for testability and added regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>