mirror of
https://github.com/penpot/penpot.git
synced 2026-08-10 23:08:41 +00:00
Pasting text could throw "Unknown node type" and lose the paste. The insertion paths assume the caret sits on a text node or a <br>, but the browser can report it on a container element (the offset being a child index, common in Firefox) or, for an empty text shape that was just focused, on nothing at all: selectAll() returned early without ever setting a selection. Add resolveTextNodePosition(), which walks a (node, offset) pair down to the addressed text node or line break and returns null instead of throwing when it cannot. The selection controller normalizes the caret with it before inserting text or a pasted fragment, and selectAll() now collapses on the line break of an empty editor so the caret is always usable. Closes #11149 AI-assisted-by: longcat-2.0-free