| 4999 | } |
| 5000 | |
| 5001 | function getSelectionBoundsPx(ids) { |
| 5002 | const sels = (ids && ids.length ? ids : (selectedIds && selectedIds.size ? Array.from(selectedIds) : [])).map((id) => elements.find((e) => e.id === id)).filter(Boolean); |
| 5003 | if (!sels.length) return null; |
| 5004 | let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity; |
| 5005 | sels.forEach((el) => { |
| 5006 | minX = Math.min(minX, el.x); |
| 5007 | minY = Math.min(minY, el.y); |
| 5008 | maxX = Math.max(maxX, el.x + el.w); |
| 5009 | maxY = Math.max(maxY, el.y + el.h); |
| 5010 | }); |
| 5011 | return { x: minX, y: minY, w: Math.max(1, maxX - minX), h: Math.max(1, maxY - minY) }; |
| 5012 | } |
| 5013 | |
| 5014 | function groupSelection() { |
| 5015 | const sels = getSelectedElements().filter((s) => !s.locked && !s.hidden); |