mirror of
https://github.com/excalidraw/excalidraw.git
synced 2026-12-06 03:05:18 +03:00
2fe86fe7f59e7b47819d3f6b53fc592af53c1940
4153
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2fe86fe7f5 |
fix(element): decide skeleton arrow end bindings before moving either end
When placing skeleton arrows, each end bound beyond its element's binding
area is either extended onto the element (if it just falls short) or
unbound.
|
||
|
|
3fa8f6f18b |
fix(editor): convert TTD dialog diagrams with the host's render environment
Review finding 7.
The text-to-diagram dialog (the Mermaid tab, and the AI chat's preview and
insert) converted mermaid's skeletons with `convertToExcalidrawElements`
without the host's `renderEnvironment`, while pasting a mermaid definition
(App.clipboard) passes `app.renderEnvironment`. So with a host's custom
`textMetrics`, every label in the dialog's conversion, container and arrow
labels alike, was measured with the default (canvas) metrics. The gap
predates this branch:
|
||
|
|
61255ad730 |
fix(element): unbind unreachable skeleton arrow ends, rebind the rest
`convertToExcalidrawElements` binds skeleton arrows to their `start`/`end`
elements while it is still creating elements, and the placement pass
(e0f198c15) then places every bound end where its binding puts it. Two
kinds of bindings made at conversion time are wrong, and placing the
arrows exposes them.
1. Ends given beyond the binding area of their element
A layout engine (e.g. mermaid's sequence diagrams, whose messages are
bound to the participants' headers but drawn far below them) can bind an
end the user could never bind in the editor. Its fixedPoint lies well
outside the element, and `normalizeFixedPoint` clamps it, so the binding
can't hold the end where it was given.
Reproduction: rectangles A (0,0 100x20) and B (500,0 100x20).
- "half-far": an arrow at (100,10) with points [0,0]->[450,490], start A,
end B, so its end is given at (550,500), far below B.
- "beyond": an arrow at (50,40) with points [0,0]->[500,0], start A, end B,
20px below both, so beyond binding distance.
Failure case (HEAD):
- "half-far": end bound to B at fixedPoint [0.5001,10]. Placing moves the
end from the given (550,500) to (550,200).
- "beyond": both ends bound at fixedPoint [0.5001,2]. That's a binding the
editor can't create, and it moves the arrow onto the headers the first
time A or B is moved.
Expected: ends beyond the binding area are left unbound where given.
Ends within it stay bound.
Fix: new `isPointInBindingArea` (collision.ts) checks whether a point is
inside an element or within binding distance of its outline.
`isEndBoundBeyondBindingArea` (binding.ts) applies it to an arrow's bound
end. Before placing, the pass unbinds every end beyond its element's
binding area (`unbindBindingElement`, which also drops the arrow from
the element's `boundElements`). An arrow with no binding left isn't
placed and keeps its geometry as given.
The check ignores frame clipping (`getBindingCandidates` still skips
the clipped parts of frame children): frames are sized around their
children only at the end of the conversion, so an element given with a
`frameId` would be checked against a 0x0 frame, and every end bound to
it would be beyond reach. Arrows unbound from an element are still
framed with it, as the frame pass frames what is bound to a frame's
children (through their `boundElements`, which no longer list them).
An end that just falls short of its element is extended onto it instead
(`extendBoundEndOntoElement`, binding.ts): its end segment is extended
past the end by the segment's length, at least 100px, and if that
reaches the element, the end is moved to where it does, off the element
by the binding gap, and stays bound. This keeps bindings a generator
meant to make, but drew arrows slightly too short for.
Reproduction: rectangle B (500,0 100x20), an arrow at (150,10) with
points [0,0]->[250,0], end B, so its end is given 100px short of B.
Expected: end bound to B, moved to (500 - binding gap, 10).
2. Ends bound before their element is sized
A rectangle/ellipse/diamond with a label and no width/height is created
0x0 and sized to fit its label only when its label is bound. That happens
in the same pass that binds arrows, in skeleton order. An arrow listed
before the element therefore binds to a 0x0 element, and
`calculateFixedPointForNonElbowArrowBinding` binds ends on elements
smaller than MIN_BINDABLE_SIZE to their center. Nothing recomputes the
binding once the element is sized, so the placement pass re-aims the end
at the center, and the result depends on element order.
Reproduction: an arrow at (100,50) with points [0,0]->[300,0], end bound
to B, where B is a rectangle at (400,25) with label "B" and no size
(sized to 20x35).
Failure case (HEAD):
arrow listed first: endBinding.fixedPoint [0.5001,0.5001] (center),
points [[0,0],[294,-7.11]] (tilted)
B listed first: endBinding.fixedPoint [0,0.714] (left edge),
points [[0,0],[294,0]] (straight)
Expected: the same in either order, the "B listed first" result.
Fix: the pass rebinds each end that is still bound
(`bindBindingElement`, keeping its mode) against its element as sized.
For elements whose size didn't change after binding, this gives the
same binding as before.
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
|
||
|
|
7decbf92f8 |
fix(element): place skeleton arrows' created end shapes along the arrow
`convertToExcalidrawElements` creates a rectangle/ellipse/diamond/text for
a skeleton arrow's `start`/`end` given by `type` (no id), and placed it as
if every arrow ran left to right: the start shape left of the arrow's
`x`, the end shape right of `x + width`, both centered on the arrow's `y`.
For any other direction the shape isn't where the arrow starts or ends,
so the arrow is bound to a shape it doesn't reach, and the placement pass
(e0f198c15) then moves its ends to where those bindings put them.
Reproduction: an arrow at (0,0) with `start: { type: "rectangle" }`,
`end: { type: "ellipse" }` and
- "diagonal": points [0,0]->[100,100]
- "vertical": points [0,0]->[0,200]
- "right-to-left": points [0,0]->[-200,0]
or `end: { type: "text", text: "end" }` on the diagonal one.
Failure case (HEAD): the shapes are at (-100,-50) and (100,-50) whatever
the direction, and the ends are bound at fixedPoints the editor can't
create, outside the shapes:
- "diagonal": ellipse at (100,-50), the arrow ends at (100,100): end
bound at fixedPoint [0,1.5].
- "vertical": end bound at [0,2.5], and the start is placed at y=56, as
the arrow runs down the rectangle's edge.
- "right-to-left": ellipse at x=200, on the wrong side: end bound at
[-4,0.5001], and the start is placed at x=-106, on the far side of the
rectangle the arrow passes through.
- the text end is bound at [0,4.5] the same way.
Expected: the shapes at the arrow's start/end, the arrow pointing into
them, both ends bound on their outlines and placed off them by the
binding gap.
Fix: new `getArrowEndShapePosition` centers the shape on the arrow's
first/last segment as extended past the end, at the distance from its
center to its outline (rectangle/text box, ellipse or diamond) in that
direction, so the end lies on its outline. Explicit `x`/`y` still win,
and an existing end text still keeps its x. Left-to-right arrows are
placed as before. Other directions change, e.g. the 300x300 start
rectangle of the 395x35 arrow in "should bind arrows to existing shapes
when start / end provided with ids" moves up 13.3px, onto the arrow's
line (snapshot updated).
|
||
|
|
86c61fb16d |
refactor(element): build one scene in skeleton conversion, resync it
convertToExcalidrawElements built a temp `scene` from the element store before labels and the elements skeleton arrows bind to were created, and then a second `boundScene` from the completed store for the bound-arrow placement pass, so the function held two scenes over overlapping element objects (Review finding 13). Evidence that the divergence produces no wrong output: the early scene is only used to measure non-arrow container labels (the container and label are passed directly; the sticky fit gets its label explicitly) and by bindBindingElement (geometry from the arrow and the element passed in; the map is only consulted for a text's container, and containers are always in the snapshot). This was already so on master, where the same snapshot scene was used the same way. To check, the scene was temporarily resynced (replaceAllElements) after every store addition, including before each bindBindingElement, and outputs were diffed against the current code (reseeded, ids canonicalized) for created rectangle/ellipse/diamond/text ends, elbow arrows, existing ids bound by two arrows (copied twice), text ends, a labelled sticky note, a frame around them, and an arrow label (given its own id) used as another arrow's start: all identical, and the full suite passed in that mode. So this is a maintainability fix: drop `boundScene` and resync the one scene with replaceAllElements once the store is complete, which is what `new Scene(...)` did. Outputs, snapshots and versions are unchanged. |
||
|
|
9e63f70211 |
fix(editor): re-measure bound labels with the host's render environment
Review finding 12.
The finding: the `renderEnvironment` option this branch added to
`updateBoundElements` (
|
||
|
|
472c879807 |
perf(element): measure skeleton arrow labels once, as placed
Review finding 11. `bindTextToContainer` ran `redrawTextBoundingBox` on every label, so an arrow's label was wrapped and measured against the arrow as given, then the placement pass (`updateBoundArrow` -> `handleBindTextResize`) wrapped and measured it again against the arrow shortened by its binding gaps, always throwing the first result away. Reproduction: a scratch vitest mocked `wrapText` / `measureText` with counters and converted two shapes and a 400px arrow bound to both with the label "aaaa bbbb cccc dddd eeee fff". Failure case: observed wrapText x2 (maxWidth 280, then 271.6) and measureText x3 (newTextElement's unwrapped measurement, the discarded redraw, the placed rewrap); expected wrapText x1, measureText x2. Six labelled arrows on one shape: wrapText 13, measureText 20 (now 7 / 14). Unbound labelled arrows were already measured once (wrap 1 / measure 2). Fix: `bindTextToContainer` no longer measures arrow labels; the transform records them, the placement pass drops each label `updateBoundArrow` just measured, and the labels left (of arrows not placed) are measured after it with `redrawTextBoundingBox`, as before. Nothing between creating a label and the pass reads its size: binding only sets `startBinding` / `endBinding` (no points), `labelPoints` is still taken on the input arrow, and for arrow containers `handleBindTextResize` ignores the old label height. Measuring the leftovers after the pass, rather than predicting at creation which arrows get placed, means no label can go unmeasured. A scratch dump of 18 scenarios (bound / one end / same shape both ends / elbow / created and text ends / missing end id / ids before data / frame / single point / autoResize: false / labelPosition in and out of range / unbound / hub of six / shape labels) is identical before and after (seeds, nonces and timestamps stripped, versions kept), except the label `version` of placed arrows, one lower for the dropped mutation; the 4 snapshot changes are exactly that. Added a test asserting the wrap / measure counts for a bound and an unbound labelled arrow (fails before: 3 wraps vs 2). |
||
|
|
eb7e4b0d09 |
fix(element): don't nudge skeleton arrow ends by 0.5px
bindLinearElementToElement() moved every skeleton arrow's start 0.5px towards its end and its end 0.5px towards its start, "so bindings don't overlap with start/end bound element coordinates" (#7195). The placement pass now re-places every bound end with updateBoundArrow(), which puts it off the bound element by the binding gap, so for bound ends the nudge was dead work (a clone, nudge and normalize that's overwritten). It only still had an effect on ends nothing re-places: the unbound end of half-bound arrows, and both ends of unbound arrows (including those whose start/end reference missing ids, which bind nothing). Reproduction (convertToExcalidrawElements, regenerateIds: false): - fully bound: rect A (0,0,100x100), rect B (400,0,100x100), arrow at (100,50) points [0,0]->[300,0], start A, end B - half bound: rect A, arrow at (100,50) points [0,0]->[300,100], start A - half bound: rect B, arrow at (100,50) points [0,0]->[300,0], end B - start: { id: "nope" } (missing), and an arrow with no start/end, both at (100,50) points [0,0]->[300,0] Failure case (observed -> expected): - fully bound: x 106, points [0,0]->[288,0], version 5 both with and without the nudge (it's fully overwritten) - half bound (start): unbound end at (399.5, 149.5) -> (400, 150) - half bound (end): unbound start at x 100.5 -> 100 - missing ref / unbound: x 100.5, points [0,0]->[299,0] while width stays 300 (stale, getNormalizeElementPointsAndCoords() doesn't update it) -> x 100, points [0,0]->[300,0], width 300 Fix: remove the nudge (and the single point early return that only guarded it), so ends are either placed by their bindings or kept where the skeleton puts them. Bound ends can't be left unplaced: the bound elements are always added to the element store, and updateBoundPoint() only skips degenerate arrows the nudge didn't change either. Snapshot changes: the unbound arrows in "should transform linear elements" and "should transform to labelled arrows when label provided for arrows" now keep x as given (100/450 instead of 100.5/450.5) and points spanning their width ([0,0]->[100,0] instead of [99,0]). Their labels don't move (the arrow midpoints are unchanged). The "should bind arrows to existing elements if ids are correct" assertion, whose ids are missing and so bind nothing, now expects x 255 as given (was 255.5). Adds a regression test that a half-bound arrow's unbound end and an unbound arrow stay where the skeleton puts them. Review finding 9. |
||
|
|
45276e6a94 |
refactor(element): place skeleton bound arrows once each, per arrow
Review finding 8.
The placement pass in `convertToExcalidrawElements` simulated moving every
bindable element (`updateBoundElements` per bindable) and repurposed
`simultaneouslyUpdated` as an "already placed" ledger (a fresh copy per
call to dodge the id-set cache), then re-collected the arrows each call
touched for the label loop. Its correctness hinged on `updateBoundElements`
internals: updating both ends from either one, the `doesNeedUpdate` stale
`boundElements` filter, and the array-identity id cache. It already broke
once (
|
||
|
|
a893b7abcf |
refactor(element): pass moveMidPointsWithElement as a movePoints option
Review finding 6.
Reproduction / evidence: `LinearElementEditor.movePoints()` took
`moveMidPointsWithElement` in its `otherUpdates` argument (typed next to
`startBinding`/`endBinding`), which is the bag of element updates forwarded
to `_updatePoints()` and from there into `scene.mutateElement()`. Callers:
- `updateBoundElements()` (binding.ts) passed
`{ moveMidPointsWithElement: <same element at both ends> }` as
`otherUpdates` - the only caller setting a real value.
- `LinearElementEditor` point dragging (two call sites) forwarded
`updates?.moveMidPointsWithElement` from `PointMoveOtherUpdates`, but
`pointDraggingUpdates()` never sets that field, so it was always
undefined there.
Before
|
||
|
|
8030861760 |
fix(excalidraw): strip leaked moveMidPointsWithElement on restore
`LinearElementEditor.movePoints()` used to spread its `otherUpdates` straight into `mutateElement()`, so the `moveMidPointsWithElement` option was persisted as a property on every arrow/line updated through its bindings. |
||
|
|
6d14841e41 |
fix(element): store skeleton arrow label x/y where placed arrows put them
Review finding 4. Placing bound arrows (updateBoundElements) moves and shortens them and rewraps their labels via handleBindTextResize, which sets the label's new width/height but, for arrow containers, never its x/y. The labels convertToExcalidrawElements returned kept the x/y computed for the arrow as given and the label as first wrapped. Reproduction: convertToExcalidrawElements with rectangles A(0,0,100x20) and B(500,0,100x20), and an arrow at (100,10) with points (0,0)-(400,0) bound A->B, labelled "aaaa bbbb cccc dddd eeee fff". Compare the label's stored x/y with LinearElementEditor.getBoundTextElementPosition on the returned elements. Failure case (observed vs expected, i.e. derived from the placed arrow): - in a frame, or not: x=160, y=-2.5 (240x50) vs x=180, y=-14.998 - with labelPosition 0.25: x=60, y=-2.5 vs x=80, y=-14.998 - short label "hi" (no rewrap): y=-2.5 vs y=-2.498 (the old 0.5px drift) Consumers reading label.x/y directly, rather than through getTextElementWithAccuratePosition, saw the box ~20px off. Fix: in transform.ts, in the loop after placement that re-derives labelPosition, also set every placed arrow's label x/y to LinearElementEditor.getBoundTextElementPosition, after labelPosition is final. All labels of placed arrows get it, given labelPosition or not. Not fixed in handleBindTextResize: the editor deliberately treats arrow label x/y as a cache. The renderer, bounds, hit testing and the WYSIWYG editor derive them from the arrow every time (see the doc comment on getTextElementWithAccuratePosition). Writing them there would change editor history/snapshots for no visible effect. convertToExcalidrawElements returns the elements as data, so its stored x/y should be right. Before this branch they were, up to 0.5px. Tests: a regression test checks that stored label x/y match the placed arrow, with and without labelPosition. It fails before the fix (160 vs 180). Two exact x/y assertions on "HELLO WORLD!!" labels became toBeCloseTo. Four snapshots change: label x/y now follow the placed arrows (sub-pixel in y, up to ~3px in x where placement is asymmetric), and version goes 3 -> 4 from the extra mutation. |
||
|
|
6cf1c3c71a |
fix(element): clamp skeleton arrow label positions as restore does
Review finding 3. Reproduction steps: - Call `convertToExcalidrawElements` with arrows whose `label.labelPosition` is 5, -1, NaN, Infinity or -Infinity, both unbound and bound to two rectangles via `start`/`end`. - Read `labelPosition` off the resulting text elements. Failure case: - Unbound arrows: 5 -> stored 5, -1 -> stored -1 (expected 1 and 0, what `restore` would produce via `clamp(v, 0, 1)`). - Bound arrows: already 1 and 0, only because the placement pass re-derives `labelPosition` from the placed path. - NaN/Infinity/-Infinity: 0.5 on both, since `cloneJSON` of the skeleton turns them into `null`, which falls back to the default. Fix: `bindTextToContainer` now normalizes an arrow label's `labelPosition` the way `restore` does: finite values are clamped to [0,1], anything else falls back to DEFAULT_BOUND_TEXT_LABEL_POSITION. This covers every arrow label at creation, independent of the cloneJSON side effect and of whether the placement pass touches the arrow. The `labelPoints` lookup is unaffected, as `getPointAtPathParameter` already clamps and rejects non-finite values. |
||
|
|
ee5d106840 |
fix(element): keep skeleton arrow labels where labelPosition put them
Review finding 2.
A skeleton arrow's `label.labelPosition` is a fraction of the arrow's path
as given (the only path a caller such as a layout engine knows), but the
placement pass (updateBoundElements() on bound arrows) then shortens both
ends by their binding gaps, and the stored fraction was resolved against
the shortened path. Unless both ends were trimmed equally, the label no
longer sat where the caller put it.
Reproduction steps:
convertToExcalidrawElements() with rectangles A (0,0,100x100) and
B (400,0,100x100), and an arrow at (80,50) with points [[0,0],[250,0]]
bound from A to B, label { text: "LABEL", labelPosition: 0.25 }. The
fraction denotes x = 80 + 0.25 * 250 = 142.5 on the arrow as given.
Placement moves the start to x = 106 (off A by the gap) and keeps the end
at 330. Label center measured with
LinearElementEditor.getBoundTextElementPosition().
Failure case:
observed label center x = 162 (0.25 of the placed 106..330 path), expected
142.5: 19.5px off. Other inputs: arrow 60..440, labelPosition 0.8 rendered
at 336.4 instead of 364 (-27.6px); arrow 100..400, labelPosition 0.25 at
178 instead of 175 (+3px).
Fix:
convertToExcalidrawElements() records the point a given labelPosition
denotes on the arrow as given, and after placing bound arrows re-derives
labelPosition as the parameter of the closest point on the placed path,
so the label stays at that point. Default labels (no labelPosition given)
are re-projected as an explicit 0.5 is: a layout engine that omits it
(mermaid-to-excalidraw does, for every edge label) puts its labels at the
midpoints of its routes as given. A point on a stretch placing trimmed
off projects onto the arrow's end, so the label is kept as close to it as
it can be while clear of the arrow's ends and arrowheads
(clampLabelPositionOffEnds()). The closest-point
projection is extracted from handleBoundTextDragging() into
LinearElementEditor.getPathParameterAtPoint() and reused, unchanged.
|
||
|
|
fb4f616d31 |
fix(element): don't grow arrow height to fit rewrapped labels
Review finding 1. The skeleton placement pass in convertToExcalidrawElements() calls updateBoundElements(), which calls handleBindTextResize() for arrows with labels. When the label rewraps taller than getBoundTextMaxHeight() allows (for arrows under 80px tall, that is the label's old height), it set the arrow's `height` from the text, leaving it inconsistent with its points. Reproduction steps: convertToExcalidrawElements() with rectangles A (0,0,100x20) and B (500,0,100x20), an arrow at (100,10) with points [[0,0],[400,0]] bound from A to B with label "aaaa bbbb cccc dddd eeee fff", and a frame containing all three. Placement shortens the arrow, so the label wraps to 2 lines (height 25 -> 50). Failure case: observed arrow height 130 (50 + 80 padding) with points [[0,0],[388,0]]; expected 0, as the points are horizontal. The stale height persists through updateScene() and inflates later getBoundTextMaxHeight() results. The same happens in the editor: dragging the end point of a horizontal labelled arrow (linearElementEditor.test.tsx) left it at height 130. Fix: handleBindTextResize() no longer grows arrow containers to fit their label, matching redrawTextBoundingBox(), which already exempts arrows: an arrow's size derives from its points, and its label is positioned along them rather than within its height. The label itself still rewraps. The linearElementEditor inline snapshot that recorded the bogus height of 130 for a horizontal arrow is updated to 0. |
||
|
|
fdc8262d5a |
fix(element): don't skip placing arrows listed by elements they aren't bound to
Placing skeleton bound arrows skips arrows already updated through another element, but marked every arrow an element's `boundElements` listed as updated, though `updateBoundElements()` only updates those bound to it. A stale entry on an element placed earlier kept the arrow from being placed. Claude Opus 5.5 (xhigh) |
||
|
|
a9b2d28782 |
fix(element): measure and frame skeleton bound arrows as placed
Placing bound arrows in `convertToExcalidrawElements()` re-measured their labels without the given render environment (`updateBoundElements()` now forwards one to `handleBindTextResize()`), and ran after frames were sized around them, so a label rewrapped by its shortened arrow could stick out of its frame. Arrows are now placed before frames are sized. Claude Opus 5.5 (xhigh) |
||
|
|
cce49a65f7 |
fix(element): place skeleton bound arrows where binding puts them
`convertToExcalidrawElements()` bound arrows to elements but kept the endpoints the skeleton gave, which aren't where Excalidraw puts the ends of bound arrows. The first time their bindings were updated (e.g. on undo/redo, or moving an element they're bound to) the arrows jumped there, e.g. by up to ~50px for arrows converted from Mermaid diagrams. Bound arrows are now placed where their bindings put them once all elements are converted. Claude Opus 5.5 (xhigh) |
||
|
|
63934812b5 |
feat(element): position skeleton arrow labels with label.labelPosition
`convertToExcalidrawElements()` always centered an arrow's label halfway along it. A skeleton arrow's `label` can now set `labelPosition` (0-1 along the arrow's path, as bound arrow labels store it), e.g. to keep a label where a layout engine placed it. Claude Opus 5.5 (xhigh) |
||
|
|
25902dc3b5 |
fix(element): don't store movePoints() options on linear elements
`LinearElementEditor.movePoints()` passed its `otherUpdates` straight into `mutateElement()`, so the `moveMidPointsWithElement` option ended up as a property on every arrow updated through its bindings. Only the bindings are element properties now. Claude Opus 5.5 (xhigh) |
||
|
|
1d4dc2c0e6 |
feat(editor): Lazy load and don't precache Firebase, lazy load mermaid (#12274)
To reduce the initial bundle size and the PWA precache size, Firebase and Mermaid are now lazy loaded. Both are out of the main bundle and the PWA precache. Each is downloaded the first time it's needed and then cached by the service worker, so it also works offline after that first use.
### How it's done
Rollup splits Mermaid into many chunks with arbitrary names (one per diagram type, plus shared deps), so `globIgnores` can't match them. A small build plugin (`lazyChunksPlugin` in `excalidraw-app/vite.config.mts`) finds the chunks that are only reachable through the dynamic `import("@excalidraw/mermaid-to-excalidraw")`. It then removes them from the precache manifest. Chunks that the main bundle also uses stay precached.
A new `lazy-chunks` runtime cache (`CacheFirst`, `/assets/*.js`, max 200 entries, 90 days) stores any JS chunk that isn't precached the first time it loads.
### Offline behaviour
- **Mermaid / text-to-diagram** is no longer cached at install. It works offline once it has been opened online at least once.
- While the Mermaid library loads, the preview shows a spinner (it used to flash an error).
- If the library fails to load:
- **Offline:** the preview shows "Couldn't load Mermaid. Check your internet connection and try again." with a Retry button. It also retries automatically when the browser comes back online.
- **Online** (e.g. a stale app version after a deploy): the preview shows "Couldn't load Mermaid. Reload the page to try again." On `vite:preloadError` the service worker checks for an update.
- **Chrome** keeps a failed dynamic import cached for the life of the page, so retrying can't work there. In Chrome the button reloads the page instead. The Mermaid definition being edited is saved before unload, so it isn't lost.
- Inserting a generated diagram while the library is unavailable shows a toast with the same message. If AI generation finishes while the library can't load, the Mermaid output is validated once the library loads.
- Pasting a Mermaid definition while the library can't load pastes it as plain text instead of failing.
- **Share / live collaboration** is hidden while offline, unless you're already in a session. This covers the top-right Share button, the main menu, the welcome screen and the command palette. An open Share dialog closes when you go offline. The online/offline state is read at startup, and changes to it are debounced by 1 s.
- **Not precached:** Mermaid and `firebaseSDK-*.js` are newly excluded. CodeMirror, font subsetting, QR code and locales were already excluded on `master`.
---------
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
|
||
|
|
6f0a4d19b5 |
fix(editor): recognize Firefox/legacy WebKit quota errors in isQuotaExceededError (#11970)
- `isQuotaExceededError` in `excalidraw-app/data/LocalData.ts` only matched `error.name === "QuotaExceededError"`, the name used by Chromium and by modern Firefox (111+, since Firefox adopted the standardized DOM spec name for this error around early 2023). Older Firefox releases (pre-111) throw `NS_ERROR_DOM_QUOTA_REACHED` instead, and legacy WebKit used `QUOTA_EXCEEDED_ERR` / `code === 22`. On those engines the check silently failed, `localStorageQuotaExceededAtom` never flipped to `true`, and the quota-exceeded banner never rendered — users kept drawing with no warning that their work had stopped persisting. - Widened the check to cover all four known spellings/codes (Chromium/modern-Firefox, legacy Firefox, legacy WebKit name, legacy WebKit code 1014/22), matching the fix suggested by @CanReader in the issue. - Exported the function so it's unit-testable directly, and added `excalidraw-app/tests/LocalData.test.ts` covering all four cases plus a negative case (non-quota `DOMException`) and a non-`DOMException` error, to guard against over-widening the check. - Left `excalidraw-app/sentry.ts` untouched — its quota filtering matches on error message text, not `.name`, so it's unaffected by this bug. --------- Signed-off-by: Mark Tolmacs <mark@lazycat.hu> Co-authored-by: Mark Tolmacs <mark@lazycat.hu> |
||
|
|
bee01e3a12 |
fix(packages/excalidraw): load export fonts into a worker's font set, warn without one (#12374)
* fix: load export fonts into a worker's own font set Since #12347 every export format loads the scene fonts before rendering, SVG included. Without a `document.fonts` -- a DOM shim like linkedom, e.g. Excalidraw+'s preview worker -- the loader returns early (#11997), so a worker never loaded fonts into its own `self.fonts`, which an OffscreenCanvas there measures and draws with. `Fonts.loadElementsFonts` now falls back to the worker's font set, and skips loading only where there is neither. Tested without the `document.fonts` mock from setupTests. Claude Opus 5.5 (xhigh) * fix: warn once when export fonts have no font set to load into Without a font set (Node, or a DOM shim like linkedom outside a worker) and no `config.environment.loadFonts`, the export silently measures and draws text with whatever fonts the environment has. Warn once per process when the elements use fonts that would need loading (local fonts like Helvetica never do). Claude Opus 5.5 (xhigh) |
||
|
|
a3fdf471ee |
feat(editor): support Instagram embeds (#12373)
* feat(editor): support Instagram embeds Instagram post and reel links (/p/, /reel/, /reels/, /tv/, also username-prefixed) embed via instagram.com/<type>/<code>/embed/. Uncaptioned so the height only depends on the media; 400x720 fits portrait posts and reels. Pasting Instagram's embed code works too: its loader <script> sits on a separate line, which made the paste fall back to text. Claude Opus 5.5 (1M context), reasoning: xhigh * fix(editor): match loose script end tags in embed code paste Addresses CodeQL "Bad HTML filtering regexp". Claude Opus 5.5 (1M context), reasoning: xhigh |
||
|
|
d3a9c2a195 |
fix(packages/excalidraw): complete cross-document runtime ownership (#11997)
* fix: complete cross-document runtime ownership * fix: schedule cross-document animations in owner window * fix: Prewarm the right font even if it's not Excalifont Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Hyperlink and tooltip host staleness issues Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Various hyperlink fixes * feat: Host abstraction * fix: exportToSvg support for document override Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Remove caches Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Refactor tests (cut non-critical) Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * chore: Break out host from App Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: hold after release fixes Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: repaint when link image decode is complete per app Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * chore: Font loading per-doc test Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Lint Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: draw SVG frame labels without text measurement Frame labels were baked into exports as measured, ellipsis-truncated text elements, which made `exportToSvg` depend on a canvas (through the render environment) for the only text it ever measures. - add `getFrameLabel` (element package): a measurement-free label spec -- position, font, color, arithmetic height, the frame's width as max width - SVG: draw labels from the spec in the frame branch, full title clipped to the frame's width; extract `appendSvgTextLines` so text elements and labels produce identical markup - canvas: unchanged output (measured, truncated text elements), now built from the same spec - fit label boxes into the SVG export bounds explicitly (`extraBounds`) - test: SVG export of a named frame succeeds with a render environment whose `createCanvas` throws and creates no canvas through `document` Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix: measurement-free embed placeholders; no render environment in SVG export The placeholder drawn for an embed that isn't rendered live was the last text `exportToSvg` measured, which kept a canvas (via the render environment) in the SVG path and made headless SVG export throw on any scene with an embed unless the process had been polyfilled. - show the placeholder as a single line capped at 30 characters (`getPlaceholderLinkText`: scheme and `www.` dropped, ellipsis) instead of wrapping the whole link: at or below that length the existing `width / length` font size fits the box by construction, so nothing is measured, wrapped or clipped, and output is identical on every host. The full link stays on the element's `<a href>` in SVG - `newTextElement` accepts pre-computed `metrics` to skip measuring - drop `renderEnvironment` from `SVGRenderConfig`, `exportToSvg` and the `@excalidraw/utils` signature: SVG export's only host dependency is its owner document - throw a guided error from the default canvas/image factories when there is no `document`/`Image`, instead of a bare ReferenceError - tests: placeholder text capping and layout; SVG export of an iframe and a long-link embed with a render environment whose `createCanvas` throws Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix: scope top picks drag to source window * feat: StickyNotes support Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * Revert "fix: measurement-free embed placeholders; no render environment in SVG export" This reverts commit |
||
|
|
e1b7aacb35 |
feat(packages/excalidraw): replace the export functions with exportScene (#12347)
* [export] rewrite - init * restore elements + filter deleted in export API (restores #11470 behavior) * fix snaps * port export callers added on master to the new API + snaps - renderOverrides (#12100), sticky notes (#12064) and arrow-label hole (#10947) tests called the old positional exportToSvg/exportToCanvas - embedded-scene snapshots gain master's new element fields (created, baseFontSize, labelPosition); decoded payloads match master's Claude Opus 5.5 (xhigh) * restore elements in embedded scene + json clipboard export (restores #12060 behavior) - master's #12060 made every public export entry point restore its input (legacy elements reach lower-level code with `created: null`), incl. the PNG metadata embed and the json clipboard copy in the removed @excalidraw/utils wrappers - SVG embed now serializes the restored, non-deleted elements (same as master's utils path), PNG embed serializes restoreElements(data.elements) and json clipboard copies the non-deleted restored elements - port #12060's utils tests to the new API, observing renderers/serializer instead of the (now identical) scene export functions Claude Opus 5.5 (xhigh) * make config.canvasBackgroundColor the single export background knob - background resolved once in configExportDimension; exportToSvg no longer reads appState.exportBackground (now omitted from ExportSceneData's appState type), and honors `canvasBackgroundColor: false` - outline arrowheads (circle/triangle/diamond_outline, cardinality_zero_*) are filled with the resolved background color, also when the background isn't painted (as on master) — the canvas path filled them transparent, showing the arrow's shaft through them; SVG ignored the config color - JPEG: `canvasBackgroundColor: false` falls back to the default background (+ warning) instead of rendering black; no more warning for the default - callers (exportCanvas, ImageExportDialog, library/chart/publish previews, AI) pass the background via config only Claude Opus 5.5 (xhigh) * resolve export theme before creating frame labels - frame labels were colored by appState.exportWithDarkMode, ignoring config.theme (export dialog's dark toggle), and in dark exports the dark-theme label color got dark-filtered again by the renderer (#7a7a7a -> #848484) - theme is now resolved once in configExportDimension; dark labels are pre-reverted so they render with the editor's frame name color Claude Opus 5.5 (xhigh) * drop appState.exportWithDarkMode theme fallback in export - `config.theme` is the only theme input (defaults to light); the type already omitted `exportWithDarkMode` from `data.appState` - callers that relied on the fallback (PublishLibrary item preview, AI frame export) pass `theme` explicitly, keeping their behavior Claude Opus 5.5 (xhigh) * exportToClipboard: don't restore appState before exportToSvg (already restored there) Claude Opus 5.5 (xhigh) * remove unused getExportSize, type getCanvasSize's [x, y, width, height] (not Bounds) Claude Opus 5.5 (xhigh) * fix typos in export comments/JSDoc Claude Opus 5.5 (xhigh) * port with-script-in-browser example to the new export API - exportToSvg/Blob/Canvas/Clipboard take `{ data, config }`; theme via `config.theme`, padding 10 kept explicit (new default is 0) - dropped the no-op `width`/`height` appState overrides from the SVG export Claude Opus 5.5 (xhigh) * call getDimensions once, ignore it when widthOrHeight is set - with an explicit `fit: "contain"`, getDimensions ran twice (the second time on its own output); it now supplies width/height (+ scale) once, and `contain` scales the content into that frame - getDimensions + widthOrHeight both applied; widthOrHeight now wins (with a warning), like width/height/maxWidthOrHeight already did - `fit: "none"` (the E+ export server path) renders identically Claude Opus 5.5 (xhigh) * type the export size options as mutually exclusive - `width`/`height`, `maxWidthOrHeight`, `widthOrHeight` and `getDimensions` are now a union where the unused options are `?: never`, so combining them is a type error (runtime still ignores/warns for JS callers) - the `never` keys are remapped over `keyof`, so every option keeps its JSDoc in completions & hovers (verified via the TS language service) Claude Opus 5.5 (xhigh) * replace getDimensions with a `scale` function, round the canvas size - `config.scale` also accepts `(width, height) => number`, called with the export dimensions at scale 1 (padding included) — covers content-dependent scaling (e.g. E+'s pixel budgets) without the getDimensions round trip - remove `getDimensions`: its returned `scale` replaced `config.scale` and multiplied the returned size, so callers thinking in output pixels had to divide it back out - exportToCanvas rounds the canvas size instead of letting the canvas truncate it (float noise like 28.999999999999996 lost a pixel); half pixels now round up (frame label area 20.5px, mermaid preview 89.5px) Claude Opus 5.5 (xhigh) * align fit/padding/position export docs with the code - `fit` defaults to "contain" when `width`/`height` is set, otherwise "none" (the doc said the opposite); dropped the unimplemented "x/y force none" claim - padding is always subtracted for `maxWidthOrHeight`/`widthOrHeight` (they ignore `fit`), not added - `position` values are "center" | "topLeft" (doc listed "none") Claude Opus 5.5 (xhigh) * derive a missing export width/height from the aspect ratio - with `fit: "contain"` (the default when a size is given), passing only `width` or `height` now derives the other from the content's aspect ratio, as documented — it defaulted to the content's unscaled size, e.g. `{ height: 50 }` of 200x100 content gave a 200x50 canvas with 60x30 content in wide empty bands (now 80x50 with padding 10) - with `fit: "none"` the missing side stays the content extent Claude Opus 5.5 (xhigh) * default export `fit` to "none" when x/y is set - `{ x, y, width, height }` was scaled to fit with `x`/`y` silently ignored (`fit` defaulted to "contain" whenever a size was given); an explicit region now crops by default, `fit: "contain"` still opts in (and ignores `x`/`y`, as now documented) Claude Opus 5.5 (xhigh) * ignore export x/y when the content is scaled to fit - with `fit: "contain"`, `maxWidthOrHeight` or `widthOrHeight`, `x`/`y` shifted the fitted content by a mix of scene units and pixels; they're now dropped with a warning, which the previous commit already documented (its "ignored" claim was based on a coincidental probe) Claude Opus 5.5 (xhigh) * pad an export x/y region on all sides - with `position: "center"` (the default), the centering adjustment also ran on axes pinned by `x`/`y`, shifting the region by the padding: the canvas started exactly at `x`/`y` with all padding on the right/bottom (`position: "topLeft"` padded all sides); `position` now only applies to unpinned axes, as documented Claude Opus 5.5 (xhigh) * consolidate exportToCanvas/Blob/Svg into exportScene({ type, data, config }) - `type: "canvas" | "png" | "jpeg" | "svg"`, return type per `type` (overloads, plus a union overload for dynamic callers); per-type options are type-checked: `quality` only for jpeg, `embedScene` for png/svg, `renderEmbeddables`/`skipInliningFonts`/`reuseImages` for svg - the format replaces `mimeType` (and its "image/jpg" typo handling) - `appState.exportEmbedScene` -> `config.embedScene` (no longer read from `data.appState`); `data.files` is optional - `config.createCanvas` -> `config.environment.createCanvas` (where #11997's render environment and richtext's text metrics will go) - exportToCanvas/Blob/Svg are no longer exported (no aliases); exportToClipboard stays, routed through exportScene - callers, the with-script-in-browser example and tests ported Claude Opus 5.5 (xhigh) * export: take only scene settings from data.appState, frameRendering -> config.frames - `data.appState` is typed as (and stripped at runtime to) the scene settings a .excalidraw file stores; the renderer state is built from those + defaults, so editor state passed in (a live AppState: open dialog, cropping, frame highlight…) can't affect the output. It only supplies the default background and what `embedScene` embeds - `appState.frameRendering` -> `config.frames: { name, outline, clip }` - editor callers translate their export settings via one internal `getExportConfigFromAppState`; `exportCanvas` drops its redundant exportBackground/viewBackgroundColor options - fixes the editor's SVG export ignoring `exportScale` (the branch's exportCanvas SVG path had dropped it; master passed it) Claude Opus 5.5 (xhigh) * type export positioning options as width/height-only - `fit`, `position`, `x`, `y`, `origin` move into the size-option union's `width`/`height` member, so combining them with `maxWidthOrHeight` / `widthOrHeight` (which ignore them) is a type error; runtime unchanged (still ignores/warns for JS callers) - docs stay visible in completions (same `keyof` remap as the size options) Claude Opus 5.5 (xhigh) * move export `loadFonts` into `config.environment` - font loading is a host capability, next to `createCanvas` (svg gets `environment: { loadFonts }` only, as it creates no canvas) Claude Opus 5.5 (xhigh) * changelog: export API (exportScene, config, migration table) Claude Opus 5.5 (xhigh) * export: default padding back to 10, canvas at least 1px - export bounds are geometric (no stroke width), so padding 0 cut half of the strokes on the content's edge and made flat content (a line) zero-height — the library/chart/publish previews, which inherited master's default of 10, rendered blank thumbnails for lines - canvas dimensions never go below 1px (a 0-sized canvas can't be encoded); SVG snapshot sizes are back to master's Claude Opus 5.5 (xhigh) * export: clamp padding against the fitted size, before deriving from it - the padding clamp used the content's unpadded size, so flat content (a horizontal line) lost its padding with maxWidthOrHeight/widthOrHeight (`{ padding: 10, maxWidthOrHeight: 400 }` → 200x0); it now only considers the target being fitted into - a missing width/height was derived before clamping (`{ height: 10, padding: 10 }` → 0x10, SVG viewBox NaN/Infinity) - a zero-extent content axis no longer yields a NaN scale under contain Claude Opus 5.5 (xhigh) * export: clip frame exports to the frame - frame clipping was off for exportingFrame (to avoid the rounded per-element clip), relying on the canvas/SVG edge — which only crops when the export is exactly the frame; a larger export (size options) painted children and overlapping elements into the margins, and SVG frame exports had stopped clipping (master clipped them) - everything drawn is now clipped to the frame with square corners: a canvas clip after the background (`renderConfig.clipToFrame`), and an SVG group with the frame's clip path; the background isn't clipped Claude Opus 5.5 (xhigh) * changelog: fill in PR numbers for the placeholder links Claude Opus 5.5 (xhigh) |
||
|
|
4c37956ba5 |
fix(editor): detect line height from the migrated font props on restore (#12033)
* fix(editor): detect line height from the migrated font props on restore The text branch of `restoreElement` parses the legacy `font` prop into local `fontSize` and `fontFamily`, but line-height detection kept reading `element.fontSize` and `element.fontFamily`. A diagram old enough to carry `font` has neither, so `detectLineHeight` divided by `undefined` and the element was restored with `lineHeight: NaN`. A non-numeric `height` produced the same result. Move the detection into `restoreLineHeight`, pass it the already-migrated values, and fall back to the font family's fixed line height when the detected value isn't a usable number. --------- Signed-off-by: Mark Tolmacs <mark@lazycat.hu> Co-authored-by: Mahiro Hirakawa <mahirohirakawa@glovrex.com> |
||
|
|
541653c7c9 |
fix(editor): frame membership, clipping and cut fixes (#12270)
* fix(editor): a frame snapped to an element's edges takes it in A new or resized frame takes the elements (and groups) within it by their outlines (not counting the stroke), to a hair beyond its edges, which snapping leaves them at. Claude Opus 5.5 (1M context), effort: medium * fix(editor): a frame always clips its children As in SVG exports — a child inside the frame may still reach out of it with its stroke — without checking geometry, but for children being dragged, which are clipped only while still in it, as their drop decides. The outline check remains for elements dragged into a frame. Claude Opus 5.5 (1M context), effort: medium * fix(editor): cutting a frame takes its children along Unlike deleting it, which leaves them: they're on the clipboard with the frame, so pasting it back would duplicate them. Claude Opus 5.5 (1M context), effort: medium |
||
|
|
4f310b7996 |
feat(app): restyle Excalidraw+ upgrade button as stacked trial CTA (#12269)
* feat: restyle Excalidraw+ upgrade button as stacked trial CTA with sparkle * feat: use gift icon instead of sparkle on Excalidraw+ button |
||
|
|
704db6803c |
feat(editor): w to wrap/unwrap selection (#12264)
* fix(editor): keep the text selected along with its container after unbinding Claude Opus 5.5 (1M context), effort: medium * feat(editor): `w` wraps or unwraps the selection - a text and an empty container: binds the text - texts (with any labeled containers): wraps each text in a container - labeled containers: unwraps the texts and removes the containers, moving their arrows onto the texts; the next `w` on the untouched selection brings the same containers back where the texts are now - a frame with its children, or all of a frame's children: removes the frame - anything else without a frame: wraps it in a frame "Wrap selection in frame" frames an image (and what lies on it) edge to edge, and removes the frame when all of its children are selected. Claude Opus 5.5 (1M context), effort: medium * fix(editor): unwrapping an arrow drops its point editor The selection unwrapping (and rewrapping, and removing a frame) leaves is resolved with its line editor, so a deleted arrow's editor doesn't linger. Claude Opus 5.5 (1M context), effort: medium * fix(editor): rewrapping a note keeps the label's font size and color A font size picked while the label was unwrapped becomes its base size, and the note takes the label's ink (shared with binding via `getStickyNoteInk`). Claude Opus 5.5 (1M context), effort: medium * fix(editor): resizing an unwrapped text doesn't move its rewrapped container A font size change keeps the text's alignment edge and middle in place, so the move is measured there rather than at the top left. Claude Opus 5.5 (1M context), effort: medium * fix(editor): binding, unbinding and framing resolve the arrow point editor Binding text to an arrow selects it with its point editor; wrapping a lone arrow in a frame, or unbinding an arrow's label (selecting both), drops it. Claude Opus 5.5 (1M context), effort: medium * feat(editor): wrapping a text draws a default rectangle in the text's color Not the current item's style — a wrapped text is a label, and the rectangle matches it. Claude Opus 5.5 (1M context), effort: medium * feat(editor): unbinding keeps the text as it rendered, at a fixed width The freed text keeps its wrapping, width and position (not auto-resizing); rewrapping it restores auto-resize. A fixed-width text keeps its top left through font size changes, so a rewrapped container measures the text's move there. Claude Opus 5.5 (1M context), effort: medium |
||
|
|
2df993fb39 |
fix(editor): resizing text by a corner follows the cursor on the axis it grows most (#12262)
Text scaled by the height alone, so a corner dragged sideways didn't follow the cursor; it now scales as resizing keeping the aspect ratio does (which text always does), by the axis that grows most. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
ef53e5417b |
feat(editor): crop editor modifiers as resizing, and double-click a handle to uncrop (#12260)
* fix(editor): shift in the crop editor: shift-click keeps it open, shift-drag moves the image along one axis
- shift-clicking the image being cropped no longer toggles it out of the
selection (which ended cropping)
- dragging the image within its crop follows the drag offset, axis-locked
with shift as dragging elements is, applied by its change since the
previous pointer move (pointerDownState.drag.lastOffset) so the image
still moves back right away after being dragged past its edge
- drops App.previousPointerMoveCoords, which only the crop drag used
Claude Opus 5.5 (1M), xhigh effort
* feat(editor): alt-drag a crop handle to crop from the center
- cropElementFromCenter crops the opposite side by as much as the dragged
one, keeping the element's center, as far as the image reaches on the
nearer side; with shift, keeping the aspect ratio
- no alt drag threshold in the crop editor: alt-clicks don't cycle the
selection there
Claude Opus 5.5 (1M), xhigh effort
* fix(editor): clicking a crop handle no longer leaves the crop editor
A press on a crop handle hits no element, so a click on one without a move
in between counted as a click outside the image.
Claude Opus 5.5 (1M), xhigh effort
* feat(editor): double-click a crop handle to uncrop its sides
- in the crop editor, double-clicking a side's handle uncrops that side, a
corner's its two sides, as dragging the handle out as far as the image
reaches does (uncropElementSides)
- with alt, the opposite side(s) too, so alt on a corner uncrops it all;
alt double-clicks aren't ignored in the crop editor, which doesn't cycle
the selection
Claude Opus 5.5 (1M), xhigh effort
* refactor(element): uncrop and crop from the center through one bounds helper
- cropElementToBounds crops the image to bounds relative to the element
(rotated and flipped with it); uncropElementSides and cropElementFromCenter
only compute those bounds
- uncropElementSides no longer drives cropElement with a pointer past the
image's edge, copying the crop it mutates, nor recurses for the mirrored
side
- maybeUncropSides takes the selected image, and the pointer type from
appState.lastPointerDownWith
Claude Opus 5.5 (1M), xhigh effort
* fix(editor): arrows bound to an image follow the sides uncropped by a double-click
Claude Opus 5.5 (1M), xhigh effort
* fix(editor): crop from the drag's start, as resizing does, so alt and shift apply mid-drag
- maybeHandleCrop crops the image as it was at pointer down
(pointerDownState.originalElements) rather than as of the previous pointer
move, and maybeHandleResize crops in the crop editor, so pressing or
releasing alt or shift mid-drag re-crops right away, as resizing does
- cropElement no longer mutates the crop of the element it's given (which is
now the drag's start state)
Claude Opus 5.5 (1M), xhigh effort
* fix(editor): no invisible rotation handle in the crop editor
The crop editor draws no rotation handle, but pressing where it would be hit
it, and dragging it cropped the image ("rotation" includes "n"). A press
there is now one outside the image, which leaves the editor.
Claude Opus 5.5 (1M), xhigh effort
* refactor(element): crop an image as resizing it would resize it
- cropElement sizes the crop from the pointer as resizing does
(getNextSingleWidthAndHeightFromPointer, from the center too), keeps it
within the image from what stays put (the opposite side, or the center),
and crops through cropElementToBounds; it replaces the per-handle cases,
recomputeOrigin and cropElementFromCenter
- options as resizing's: { shouldMaintainAspectRatio, shouldResizeFromCenter }
rather than a width aspect ratio (the element's, which is the drag's start)
- keeping the aspect ratio, a corner crops by the axis it grows most,
relatively, as resizing does (rather than by pixels), and an axis dragged
past what stays put has the minimal size rather than flipping
- an image already smaller than the minimal size crops no smaller, rather
than jumping to it
Claude Opus 5.5 (1M), xhigh effort
* fix(element): the image no longer shifts by a pixel while cropping it
The crop editor drew the cropped image from its own bitmap, snapped to whole
pixels by its own corner, over the faded uncropped image's: as the corner
moved by fractions of a pixel (cropping from the center, or keeping the
aspect ratio along a side), the image within the crop shifted by a pixel
against the faded rest. Within the crop, it now draws the uncropped image's
bitmap at full opacity, clipped to the crop.
Claude Opus 5.5 (1M), xhigh effort
|
||
|
|
e65eca999e |
refactor(editor): app.selection, and the rest of the selection tool out of App (#12258)
* refactor(editor): add AppSelection (app.selection) to select, add to, remove from and clear the selection - select(element) for click-select, the alt-click cycle and the context menu; add(element) for the selection tool and the lasso's touch select (was a near-copy); remove(element) for shift-click; clear() replaces App.deselectElements and three inline copies - isASelectedElement / isHittingCommonBoundingBoxOfSelectedElements move from the selection tool - select() drops a stale line editor of a no longer selected arrow; the context menu no longer spreads all of this.state into its setState - tests for the selection's frame, link selector and line editor rules Claude Opus 5.5 (1M), xhigh effort * refactor(editor): make the app.selection API generic over elements or ids, one or many - select / add / remove take elements or ids, one or many (missing and deleted ones skipped) - their rules become pure functions in App.selection.ts, for callers that need the next selection state rather than a setState (actions, duplication): getSelectionStateForElements (moved from @excalidraw/element, now keeping the current line editor), getSelectionStateAddingElements, getSelectionStateRemovingElements — one pass over the elements however many are added or removed - remove() recomputes selectedGroupIds (it put element ids into it and lost the other selected groups' flags), and leaves group editing once nothing is selected - the link popup on adding an element is the pointer's, not add()'s Claude Opus 5.5 (1M), xhigh effort * refactor(editor): move selectGroupsForSelectedElements from @excalidraw/element into App.selection.ts - editor state (selected group ids, the edited group), used by the editor only; moved as is - also ends the groups.ts <-> selection.ts import cycle in @excalidraw/element Claude Opus 5.5 (1M), xhigh effort * refactor(editor): move dragging the selection and box selection out of App into AppSelectionTool - handleSelectionDragOnPointerMove: dragging the selection (or the image within its crop), alt-drag duplicating past the threshold - handleBoxSelectionOnPointerMove: box selection (and of the line editor's points) - handleSelectionDragOnPointerUp: frame membership of the dragged selection - pure moves, verified mechanically - tests for shift-dragging along one axis and moving the image within its crop (both untested through the pointer) Claude Opus 5.5 (1M), xhigh effort * refactor(editor): one check for the selection's transform handle under the pointer - selectionTool.getTransformHandleAt() replaces the two copies in the hover cursor and on pointer down (line editor, elbow arrows, two-point lines, mobile lines, hovered line points; a lone element's or the selection's common bounds) - pointer down now also ignores the handles in the element link selector, as the hover cursor did - test for the resize cursor over the handles (untested) Claude Opus 5.5 (1M), xhigh effort * fix(editor): app.selection shows the link popup of what it selects - select / add / remove show the link popup of a lone selected element with a link (or an embeddable) and hide it otherwise; clear hides it — it was left as is, so select() showed it only if a previous selection had - the link editor stays open when its element is selected again - the pointer and lasso call sites no longer set it themselves Claude Opus 5.5 (1M), xhigh effort * feat(editor): app.selection ends what hangs on the deselected elements and skips locked ones - cropping ends unless the cropped image stays the selection, and an active embed is deactivated once deselected (the line editor already ended once its line is deselected) - select / add skip locked elements, unless includeLocked — which the context menu passes, to offer unlocking them - captureUpdate option, as updateScene's, to record the change for undo - deep option on select (the elements themselves, editing their shared group), which Ctrl+click now goes through - text editing isn't ended here: the editor ends itself on blur, and submitting it mid pointer event would commit half the event's state Claude Opus 5.5 (1M), xhigh effort * feat(editor): app.selection ends text editing, and add / remove / clear always end cropping - select / add of anything but the edited text (or its container) submit the text editor — after the current event (it submits with a flushSync), and only if that editing session is still open; clear / remove leave it (starting text editing clears the selection) - add / remove / clear end cropping; select keeps it only when selecting the cropped image again (a click inside it in the crop editor) Claude Opus 5.5 (1M), xhigh effort * fix(editor): app.selection derives the line editor from the final selection, and frame / deep fixes - the line editor is set from the selection once groups are expanded: an arrow selected with its group (e.g. by alt-click cycling) gets none, so dragging from its point moves the group rather than reshaping the arrow; add() sets it too (adding a lone arrow left Edit / Cmd+Enter throwing) - children of frames selected through the groups of the selected (or added) elements are left out, also ones selected in the same call — and adding within an edited group no longer deselects as if the edited group's frames were selected - deep selection never expands groups (it did for elements not sharing one) - a click-selected elbow arrow now gets its line editor on pointerdown, so that click's pointerup normalizes a hand-built route one gesture earlier Claude Opus 5.5 (1M), xhigh effort * feat(packages/excalidraw): excalidrawAPI.selection - app.selection on the imperative API — select / add / remove / clear, taking elements or ids, one or many, with the deep / includeLocked / captureUpdate options; the type exposes only those four - they're arrow properties, so they keep `this` when taken off the object - changelog entry Claude Opus 5.5 (1M), xhigh effort |
||
|
|
4c00f31ddc |
feat(editor): autoplay Google Drive videos when the embed is activated (#12246)
- Drive's player has no postMessage API (unlike YouTube/Vimeo), but its /preview page honors `autoplay=1`, so the first activation reloads the embed with it: a single click plays the video in view mode - reloaded via `contentWindow.location.replace` so it adds no history entry, and only once per iframe so re-activating doesn't restart it Claude Opus 5.5 (1M), xhigh effort |
||
|
|
2559257bb2 |
fix(editor): pan once and keep editing on a wheel-button drag over the text editor (#12244)
- the text editor's window pointerdown listener was added in capture mode but removed without it, so every past editing session kept panning too: the pan was multiplied by the number of texts edited since load - the pan focuses the container, which blurred the editor while blur still submitted it; submit is now disabled before the pan starts, and the editor is refocused on release Claude Opus 5.5 (1M), xhigh effort |
||
|
|
53973c3a42 |
feat(editor): alt-click to cycle the selection through overlapping elements (#12237)
* feat(editor): alt-click to cycle selection through overlapping elements - alt+click on the selected element (or group) selects the one below it under the pointer, wrapping around to the topmost - inside an edited group, cycles through that group's elements only - alt+drag duplicates only past a 10px threshold, so alt-clicks don't - alt+double-click no longer creates/edits text (except with autoshape) Claude Opus 5.5 (xhigh) * refactor(editor): move the selection tool out of App into AppSelectionTool (app.selectionTool) - handleSelectionOnPointerDown, clearSelection(IfNotUsingSelection), isASelectedElement, isHittingCommonBoundingBoxOfSelectedElements and the alt-click cycle target move as is - the click selection of the pointer up handler (alt-click cycle, shift toggle, click select, bbox-only deselect) becomes handleSelectionOnPointerUp - the selection's transform handles, maybeHandleResize / maybeHandleCrop, move as is - tests for alt-click cycling, and for cropping by dragging a crop handle Claude Opus 5.5 (1M), xhigh effort * feat(editor): alt-click cycles the selection on its resize handles too - alt-resizing starts only past the 10px drag threshold, as alt-drag duplicating does, so an alt-click on a resize handle can cycle - an alt-click on the selected element's resize handle (over the element) cycles the selection, but not once a resize happened Claude Opus 5.5 (1M), xhigh effort * feat(editor): hint at alt-click cycling while Alt is held - holding Alt over a single selected element (or group) with the selection or lasso tool shows "Alt-click to cycle selection, or drag to duplicate" - app.modifiers tracks the held Alt, Shift and Ctrl/Cmd outside appState, synced from key and pointer events and reset on blur; app.modifiers.useHeld(modifier?) re-renders only on the given one - the hover refresh after a pointer up replays the held modifiers, so it no longer releases them (the hint flickered on every alt-click) - selectionTool.canCycleSelection() shares the cycle rules between the hint and the click Claude Opus 5.5 (1M), xhigh effort |
||
|
|
ed10ac7dca |
feat(editor): alt-drag the text being edited to duplicate it (#12219)
* feat(editor): alt-drag the text being edited to duplicate it - alt-pressing the text editor ends the editing and hands the press over to the canvas, so the drag duplicates the text (or its container) - the handed-over press always moves what was edited, never resize handles or an arrow's points, midpoint or label beneath the editor - on drop, the duplicate is edited with all of its text selected (a list item's text only, as when alt-dragged on the canvas) Claude Opus 5.5 (xhigh) * fix(editor): no arrow hover highlights while editing its label - starting to edit text clears the hover state of the arrow's editor (kept up for the submit), so a midpoint hovered before the double-click doesn't stay highlighted - the arrow's hover affordances don't apply while editing text Claude Opus 5.5 (xhigh) * fix(editor): don't drop arrow hover updates on the same pointer move - the hovered point, midpoint and focus point were each set from `this.state`, so when one move changed several of them (e.g. from the midpoint straight onto an endpoint), only the last update survived Claude Opus 5.5 (xhigh) |
||
|
|
9ba66ed9b5 |
feat(editor): auto increment numbers/lists on duplicate (#12189)
* feat(editor): auto increment numbers/lists on duplicate - duplicating a text or a label (shape, arrow, sticky note) that starts with a list marker advances it: `1.` `1)` `(1)` `[1]`, `a.` `a)` `(a)` (`a`–`h`, then roman numerals `i`–`xcix`), and lone numbers (`1`) - markers must be followed by whitespace (`1.5`, `e.g.` aren't lists); whole lists are left as they are - numbers count up to 42, letters up to `i` - only if nothing but list items is duplicated (a label goes with its container); several items only if they're just markers (`1.` `2.`), continuing from the highest of them (`1.`, `3.`, `5.` -> `6.`, `7.`, `8.`) - the increment is a separate undo step after the duplication; alt-drag shows it from the start of the drag Opus 5.5 (1M context), xhigh * feat(editor): edit the text of an alt-duplicated list item - on alt-drag drop, a single list item with text after its marker enters the text editor with that text selected (`2. |foo|`) - not when duplicated along with other elements, nor when the drag doesn't end with a genuine pointerup (pointercancel, missing-pointerup cleanup) - `textWysiwyg` / `startTextEditing` take an `initialSelection` Opus 5.5 (1M context), xhigh |
||
|
|
1919728724 |
fix(editor): reach text containers below transparent ones (#12210)
The text tool (hover and click), and a double-click with nothing selected, took the top-most shape whose bounds held the pointer. A transparent shape stacked above a nested one kept the inner one out of reach at its center, and an arrow below a transparent shape couldn't get a label. - only a filled element or an image (the rule arrow binding uses, now exported as isOpaqueForBinding) or an arrow ends the search - of the containers found, the innermost one whose center is at the pointer wins, else the top-most as before - an arrow counts only where its path is hit, not anywhere in its bounds - a frame's children aren't hit outside the frame, where they're clipped (App.isClippedByFrameAt, shared with getElementsAtPosition) Claude Opus 5.5 (1M), xhigh effort |
||
|
|
35e854ecf7 |
feat(app): label E+ banner Upgrade / Sign in (#12204)
Claude Opus 5.5 (xhigh) |
||
|
|
5a406e5187 |
fix(app): correct typo in Mermaid input placeholder (#12186)
fix: correct typo in Mermaid input placeholder |
||
|
|
e283f724c8 |
refactor(editor): move the clipboard out of App into AppClipboard (app.clipboard) (#12197)
* refactor(editor): move the clipboard out of App into AppClipboard (app.clipboard) A pure move of the clipboard handling out of App.tsx (13,478 → 12,942 lines) into App.clipboard.ts: onCut and onCopy (the document's cut/copy events, through their actions), pasteFromClipboard (the paste event, parsed, and handed to a host's onPaste first), insertClipboardContent (inserting the pasted data as whatever it is: images or SVG code, elements, a Mermaid definition, embeddable URLs, a spreadsheet as a chart, mixed content, or text), addElementsFromMixedContentPaste and addTextFromPaste. The plain-paste flags move along as module-level state; Ctrl/Cmd+V's marking of a plain paste, and its reset, are App's former lines behind app.clipboard.onPasteShortcut and clearPlainPaste. Staying in App: addElementsFromPasteOrLibrary and insertImages, shared with drop, the library and text-to-diagram (insertImages becomes public for the clipboard), and onIframeSrcCopy, which belongs to the magic frame. Callers go through `app.clipboard`: no delegate is left on App, and AppClassProperties exposes `clipboard` (as it does `textTool`) instead of `pasteFromClipboard`. Beyond the move, `this.` becomes `this.app.` for what stays on App, onCut and onCopy become public, and the container ref comes in as a dependency. The moved code is identical to the removed, modulo those rewrites, whitespace and trailing commas (checked mechanically). Claude Opus 5.5 (1M), xhigh effort * test(editor): cover copy/cut events and more paste routes Only 80% of the clipboard code ran under the suite, and nothing went through the document's copy and cut events, which is how Ctrl/Cmd+C/X reach the editor in a browser. Now a copy event copies the selection and a cut event cuts it; a host's onPaste returning false keeps the paste from being inserted; a pasted spreadsheet opens the charts dialog; and with the image tool off, a paste of mixed content inserts its text. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
3947883063 |
refactor(editor): move text editing out of App into AppText (app.text) (#12195)
* refactor(editor): move text editing out of App into AppText (app.text) A pure move of the text editing session, and of the text helpers around it, out of App.tsx (14,250 → 13,478 lines) into App.text.ts. It sits next to AppTextTool, which keeps the text tool's pointer interaction. AppText holds: - the session: startTextEditing (creates or picks the text to edit, and opens the editor), handleTextWysiwyg (the editor's lifecycle) and the open editor's submit handler - the part of the canvas a typed or pasted text is kept within: getTextSidePanels, getTextViewportOffsets and getMaxTextWidth (paste, which stays in App for now, calls into them) - where a new text goes: getTextCreationGridPoint and getTextWysiwygSnappedToCenterPosition - the queries that find the text or container to edit: getTextElementAtPosition, getTextBindableContainerAtPosition, getSelectedTextElement, getSelectedTextEditingContainerAtPosition and isEditingTextContent - the auto-resize handle: isHittingTextAutoResizeHandle and handleTextAutoResizeHandlePointerDown Callers go through `app.text`, startTextEditing's included: no delegate is left on App (no host or test used it). Beyond the move, `this.` becomes `this.app.` for what stays on App, members called from outside become public (App.deselectElements too), and the container ref and the styles panel mode come in as dependencies, as AppViewport's do. The moved code is identical to the removed, modulo those rewrites, whitespace and trailing commas (checked mechanically). Claude Opus 5.5 (1M), xhigh effort * test(editor): click the text auto-resize handle through the pointer The handle that turns a fixed-width text back into a growing one was only covered through its action: nothing hovered or clicked it. Hovering it on a selected wrapped text now shows the pointer cursor, and clicking it unwraps the text, through AppText's hit test and pointerdown handler. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
3d056dbc8a |
feat(editor): wrap text at 800 and keep it clear of the side panels (#12192)
* feat(editor): wrap typed & pasted text at 800, clear of the side panels A free text growing as it's typed stopped only at the view's width (#12175), so on a large screen it ran to 2000+ px before wrapping, and a pasted text wrapped at half the view. Both now follow one rule, in `getMaxTextWidth`: - no wider than TEXT_MAX_WRAP_WIDTH (800, in @excalidraw/common) in scene units, at any zoom: the paste's former cap, now shared. A paste no longer wraps at half the view. - nor wider than the canvas between the side panels, less TEXT_VIEWPORT_PADDING at each side: the docked sidebar, as before; the full styles panel (desktop), which shows next to a text while it's edited, and once it's pasted and selected (pasting with nothing selected, its room is reserved: as last measured, else approximately); and the stats panel, only for a text beside it, i.e. with rows within that padding of it, as it covers only the top of the canvas' side. A text that starts wrapping is brought in between the same panels, as before. A paste is laid out as if the stats panel weren't there, and again, clear of it, only if it lands beside it. As the stats panel grows to show a selection's properties, with it open the paste is rendered selected first (not captured yet, via `flushSync`), so the panels are measured as they'll be; laid out again, it stays the same elements, and one undo step. A wrapped paste is then moved into view (as far as the view would have scrolled), instead of scrolling the view. The stats panel is marked as side viewport UI (`data-viewport-ui="side"`, named "stats"), so the viewport offsets' other users (zoom to fit, scroll to content, search, a host's `setViewport` with UI offsets) keep clear of it too while it's open. `AppViewport` gains `getSideInsets(names, { reserve })`, generalizing `getSidebarInsets`, and `getSideUIRect(name)`; `getOffsets` shares the reserve fallback through `getReservedSide`. Tests: the cap at 50% and 200%; a typed text clear of the styles and the stats panel, and of the stats panel only beside it; a paste wrapping as a typed one, with the styles panel's room reserved; a paste clear of the stats panel only where it lands beside it, and of the stats panel grown to show it, as one undo step; a wrapped paste moved into view, the view not scrolled. Claude Opus 5.5 (1M), xhigh effort * feat(editor): pan the canvas when the caret goes under the stats or styles panel The canvas follows the caret past the view's edge, and behind the docked sidebar, through the editor's box, which the browser scrolls to reveal a caret (#12175). The stats and the full styles panel don't span the box's height, so a caret typed in under them stayed out of sight. After each input, once the update (and any scroll it made) is in the app's state, the editor works out where the caret is: its line from `getWrappedTextLines`, its x from the width of the line before it, rotated with the text. In a line with RTL characters (`hasRTLChars`, new in @excalidraw/common) the x comes from the browser's bidirectional layout of the line instead, in its paragraph's direction (the editor's `dir="auto"` makes it `unicode-bidi: plaintext`: each paragraph goes its first strong character's way): with Hebrew then English, the caret after the English is mid-line, not at the line's edge. That's measured through a range in an off-screen mirror of the line, shared with the click-to-caret lookup. If the caret's under one of those panels, the canvas pans to bring it out on the canvas' side, with CARET_FOLLOW_PADDING to spare. Only then: a text beside or below a panel stays where it is. Tests: typing past the stats panel's left edge pans the canvas under it, but not below it; the caret in a bidirectional line, a paragraph after one going the other way, is found where the browser lays it out. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
2d3707b816 |
feat(editor): add showHints to command palette (#12187)
* feat(editor): route showHints through the action system (#12165 follow-up) `showHints` was the only item in the Preferences submenu that flipped appState directly instead of going through an action, so it was missing everything the action system provides: no command palette entry, no `trackEvent`, no `viewMode` declaration. - add `actionToggleShowHints`, modelled on `actionToggleMidpointSnapping` (`viewMode: false` — hints live in the toolbar, which view mode hides) - register it under `ActionName` and export it from `actions/index.ts` - `PreferencesToggleShowHintsItem` now calls `executeAction` - list it in the command palette's editor commands - document `appState.showHints` / `MainMenu.DefaultItems.Preferences.ToggleShowHints` in the CHANGELOG, which the original commit never touched No keyboard shortcut: like `arrowBinding` and `midpointSnapping`, this is a set-once preference, and the natural mnemonic (`Alt+H`) is already distribute-horizontally. Adds `tests/showHints.test.tsx` — the preference previously had no behavioural coverage at all, only incidental snapshot entries. * chore(editor): drop showHints tests & changelog entry Both will be rewritten in a follow-up PR. Opus 5.5 (1M context), xhigh --------- Co-authored-by: hiennd <hiennd@aidia.vn> Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com> |
||
|
|
834e5af631 |
fix(editor): follow-ups to zen mode polish & delayed tooltips (#12188)
* fix(editor): follow-ups to zen mode polish & delayed tooltips (#12165) Tooltip state (timer + warm window) is shared by all instances, since they share one tooltip node. Without an owner, any unrelated Tooltip unmounting (a collaborator leaving, a sidebar breakpoint) cancelled or hid a tooltip the user was still hovering. Track the owning item and only hide from the paths that own it; `hideTooltip` no longer creates the tooltip node just to hide it. Zen mode hides or slides controls without the pointer moving, so nothing fired pointerleave to retract their tooltips — markZenModeTransition now hides the tooltip up front. `:focus-visible` was not excluded from the chrome-less zen-mode rules, so the keyboard focus ring (a box-shadow) disappeared for the main menu trigger, scroll-back-to-content and exit-zen-mode buttons. The zoom buttons lost their native `title`, which was the only channel carrying their shortcut to keyboard/AT users — expose it via `aria-keyshortcuts`, as Tools.tsx does. Also: schedule the zen-mode timer on `ownerWindow` like every other DOM-touching timer in App.tsx, re-read the container ref when unflagging (and unflag on unmount), and drop the footer-left `--transition-left` class, which never matched a selector. Adds the missing coverage for the transition-attribute lifecycle, the `openMenu`-across-view-mode fix, and the tooltip delay/warm window. Split out of #12187 and ported onto the #12173 Tooltip rework: the owner is set in `showTooltip`, and its MutationObserver already retracts a tooltip whose wrapper got `disabled`, so that extra effect is dropped, as is the delayed-show label ref (`showTooltip` takes the label by value). Opus 5.5 (1M context), xhigh * refactor(editor): drop tooltip owner tracking, trim tests Since #12173, `showTooltip`'s MutationObserver retracts a visible tooltip whose wrapper leaves the DOM, and its `isConnected` check drops a pending one. That makes the Tooltip unmount effect, which hid whatever tooltip was showing, redundant: removing it fixes the unrelated-unmount bug on its own, without tracking an owner. Also drop zenMode.test.tsx and the tooltip tests that duplicated others. Opus 5.5 (1M context), xhigh --------- Co-authored-by: hiennd <hiennd@aidia.vn> |
||
|
|
438d89861f |
docs(repo): remove obsolete CodeSandbox contribution workflow (#11908)
* docs: remove obsolete CodeSandbox contribution workflow https://codesandbox.io/p/github/excalidraw/excalidraw (forking the whole repo as an editable sandbox to submit PRs from) no longer works. It was documented in two places — the Contributing guide and the Development guide — as an alternative to the manual clone/fork setup. This doesn't touch the other CodeSandbox links in the docs (README, installation/integration/development guides for the @excalidraw/excalidraw package), which point at the separate with-script-in-browser usage example and are unrelated to this contribution workflow. * chore: trigger CI Claude Opus 5.5 (low) --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com> |
||
|
|
02fc9f3505 |
fix(packages/excalidraw): setViewport stops following a collaborator (#12184)
Navigating with `setViewport` takes the view over from the followed user, as a user's pan or zoom does, so it now asks to stop following (`requestUnfollow`: `onUserFollow` with `action: "UNFOLLOW"`, when `userToFollow` is set). `setViewport(null)`, which only clears a lock, and a target that doesn't resolve don't navigate and leave following alone. Following itself doesn't go through `setViewport`: excalidraw-app and Excalidraw+ both apply the followed user's viewport with `updateScene` + `zoomToFitBounds`, so it's unaffected. Tests: navigating emits the UNFOLLOW intent once; clearing a lock and an unresolved target don't. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
74423812ec |
perf(editor): avoid rebuilding id sets on every drag (#12183)
perf(element): reuse one moved-element ID set when dragging dragSelectedElements passed a fresh Array.from(elementsToUpdate) to every element's updateBoundElements call. Each call missed the per-array ID-set cache and rebuilt a selection-sized set, so a drag step was quadratic in the number of dragged elements. Build the array once per drag step, pass it to every call, and reuse its cached set (getSimultaneouslyUpdatedElementIds, now exported) for the unbinding checks too. Document that callers must pass one array instance per operation and must not change its membership afterwards. Dragging 1K / 2K / 4K selected rectangles in the app went from 45 / 160 / 643 ms to 18.5 / 31 / 54 ms per frame (same tab, same window, dev build). Add coverage for the shared array, grouped labels across z-order, frames with their children, bound arrows, bindings, unbinding, and unchanged coordinates. Claude Opus 5.5 (1M context), reasoning effort 40 |
||
|
|
84e3f5a40c |
perf(editor): avoid rebuilding id sets on every resize (#12180)
perf: avoid rebuilding simultaneously-updated id set per element on multi-element resize updateBoundElements() rebuilt a Set of all simultaneouslyUpdated ids on every call. Multi-element resize/rotate call it once per selected element with the same array, making each pointer move O(n^2). Cache the set per array in a WeakMap. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |