penpot/frontend
Andrey Antukh b0014d92aa 🐛 Fix crash when pasting into an empty or element-focused caret
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
2026-08-08 19:27:22 +00:00
..
2026-06-22 14:35:10 +02:00
2026-05-29 11:24:58 +02:00
2026-08-06 08:55:58 +02:00
2026-04-07 21:35:00 +02:00
2026-07-30 16:56:10 +02:00
2026-07-30 13:05:28 +02:00
2026-07-31 18:53:05 +02:00