mirror of
https://github.com/excalidraw/excalidraw.git
synced 2026-11-22 14:01:54 +03:00
fix/multi-tab-delete-undo
4148
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9a9b888b28 |
fix(editor): drop undo/redo entries for elements deleted in another tab
The tab sync replaces the scene from localStorage, which keeps no deleted elements, so an element deleted in another tab leaves the scene entirely. Its history entries stayed behind, leaving undo and redo enabled with nothing to do. Add excalidrawAPI.history.prune() and call it from the tab sync. It drops stale entries from the top of both stacks, and undo/redo drop the ones they later expose, limited to elements prune() found gone. Hosts that never call it, and collaboration sessions, are unaffected. Also stop counting a reorder of only deleted elements as a visible change. Signed-off-by: Mark Tolmacs <mark@lazycat.hu> |
||
|
|
7ded689cad |
feat(editor): bump mermaid-to-excalidraw to 3.6.0 (elbow flowcharts, Gantt, quadrant charts, timelines) (#12535)
* feat(editor): bump mermaid-to-excalidraw to 3.3.0 (Pele 1.13, stepped edges) - mermaid-to-excalidraw 3.1.0 -> 3.3.0 (Pele 1.8.0 -> 1.13.0): flowchart edges and state transitions are elbow arrows when the definition asks for a stepped curve (`curve: "step"`, `linkStyle … interpolate step`); class namespaces are drawn as boxes like subgraphs (3.2.0) - Pele 1.13 reports syntax errors on the source line (counting front matter, directives, comments and blank lines) and errors past the end on the last line, so the TTD dialog no longer converts them: the conversion would shift them twice Claude Opus 5.5 (low) * docs: link #12535 in the changelog Claude Opus 5.5 (low) * feat(editor): draw Mermaid flowchart and state edges as elbow arrows Convert Mermaid diagrams (TTD dialog and paste) with `flowchart.curve: "step"` (`MERMAID_TO_EXCALIDRAW_CONFIG`), which m2e 3.3 turns into elbow arrows for flowchart edges and state transitions. A curve the definition sets itself (front matter, `%%{init}%%`, `linkStyle … interpolate`) still wins; class and ER diagrams are unaffected. Claude Opus 5.5 (low) * feat(editor): elbow arrows for Mermaid flowcharts only (mermaid-to-excalidraw 3.4.0) mermaid-to-excalidraw 3.4.0 replaces `flowchart.curve` with `elbow`, per diagram type. Use `elbow: { flowchart: true }`: state diagrams' elbow transitions need more work in m2e, so they stay as before. Claude Opus 5.5 (low) * feat(editor): bump mermaid-to-excalidraw to 3.5.0 (Gantt, quadrant charts, timelines) mermaid-to-excalidraw 3.5.0 converts Gantt charts, quadrant charts and timelines to Excalidraw elements instead of an image. The Mermaid dialog's description lists them (and State diagrams, missing before), its syntax links built by one helper. Claude Opus 5.5 (low) * fix(editor): detect pasted Mermaid after comments and front matter Pasted text was only taken for Mermaid when its diagram type came first, or after a single one-line `%%{...}%%` directive. Skip everything Mermaid allows before it: blank lines, `%%` comments, directives (also over several lines) and front matter. A directive doesn't run past the next `%%{`, so text with many unclosed directives is checked in linear time (searching each to the end of the text would be quadratic: ReDoS). Claude Opus 5.5 (low) * feat(editor): bump mermaid-to-excalidraw to 3.6.0 (diagram types loaded on first use) mermaid-to-excalidraw 3.6.0 loads each diagram type's parser and converter on first use: its main chunk is 20.3 KiB (brotli) instead of 35.8, plus 1.5–5.1 KiB for the type converted (a first flowchart: 28.5 KiB). Claude Opus 5.5 (low) |
||
|
|
dd2f8fc32b |
fix(editor): don't clip arrows to their frames (#12516)
* fix(editor): don't clip arrows to their frames Arrows (and their labels) are no longer clipped to the frame they belong to, so they can connect elements across and out of frames. They stay members of their frame, so they're still moved, copied, deleted and exported with it. - Not clipped on the canvas or in SVG, and hit (click, hover, box and lasso selection) outside their frame too. - Exporting a frame includes other frames' arrows reaching into it, as it does other non-children overlapping it. - Moving a frame (dragging it, with the arrow keys or from the stats panel) keeps its arrows bound to the elements that don't move with it, instead of unbinding them. Their free points move with the frame, elbow arrows are routed once per move and keep their fixed segments. - mutateElement no longer ignores an elbow arrow's x/y update to 0. Fixes #6749 Fixes #7827 Claude Opus 5.5 (xhigh reasoning) * docs(changelog): arrows aren't clipped to frames Claude Opus 5.5 (xhigh reasoning) * fix(editor): take arrows out of frames once neither of their ends is in them An arrow belongs to its frame only while one of its ends is in it: bound to an element in the frame, or, unbound, inside it. Checked when an arrow is finished (drawn, or an end dragged), when a drag ends (the dragged arrows and those bound to the dragged elements), and when a frame's children are recomputed (resize, grouping). An arrow bound only to elements outside its frame thus no longer gets cut, duplicated or exported with it. Claude Opus 5.5 (xhigh reasoning) * fix(editor): take arrows out of frames when nudged or moved from the stats panel The arrow keys and the stats panel move arrows too, so check there as well whether a moved arrow still has an end in its frame. Claude Opus 5.5 (xhigh reasoning) |
||
|
|
8bcdca4526 |
fix(editor): ignore deleted elements when inserting frame children (#12510)
fix(editor): place new frame children below the frame despite deleted children Deleted frame children keep their frameId and index, so one left above the frame made new children of that frame (created or dragged in) go above it, up to the top of the canvas, until a reload dropped the deleted elements. Only live children count now. Claude Opus 5.5 (xhigh) |
||
|
|
2610ebae0c |
feat(editor): Alt+arrows move to the flowchart node that's visually next (#12502)
* feat(editor): Alt+arrows move to the flowchart node that's visually next Alt+arrow navigation used to follow only the arrows bound to the pressed side of the selected node, cycled through siblings on repeated presses, and fell back to any linked node when nothing was that way. It now picks, among the nodes of the selected node's flowchart, the nearest node of the first non-empty tier: 1. nodes in line (sharing the row for left/right, the column for up/down) 2. linked nodes whose center lies past the selected node's edge 3. nodes whose center lies in the 45° cone of the pressed direction 4. any other node whose center lies past that edge Near-ties (within 10%) go to linked nodes, successors first, then reading order. Pressing the opposite of the last move goes back where it came from, also after releasing Alt. Claude Opus 5.5 (xhigh) * docs(packages/excalidraw): changelog for visual flowchart navigation Claude Opus 5.5 (xhigh) * feat(editor): forget the way back when Alt is released Going back where the last Alt+arrow move came from only applies while Alt is still held; a new Alt session navigates from scratch. Claude Opus 5.5 (xhigh) * feat(editor): drop the Alt+arrow way back Pressing the opposite of the last move no longer returns to the node it came from. As an override it beat even nodes in line (B ← went back down to A instead of to C in B's row); navigation is now stateless, so a key from a given node always goes to the same place. Claude Opus 5.5 (xhigh) * feat(editor): link flowchart nodes through non-elbow arrows too Any arrow bound at both ends now links its nodes, for Alt+arrow navigation and for the nodes Ctrl+arrows keeps new nodes clear of. Claude Opus 5.5 (xhigh) * fix(editor): break flowchart navigation ties by alignment before reading order Of two equally near in-line nodes, both linked, Alt+arrow went to the upper one even when the other was level with the selected node's center. Offsets within a pixel still tie, so float noise in fanned-out siblings doesn't decide between them. Claude Opus 5.5 (xhigh) * perf(editor): walk flowchart links in one pass over the scene Collecting a node's flowchart rescanned every arrow in the scene for each node visited, so Alt+arrow and Ctrl+arrow in a large chart paid chart nodes × all arrows (~10 ms per press at 1,000 nodes). A neighbour map built in one pass makes it linear. Claude Opus 5.5 (xhigh) |
||
|
|
a758e93d6a | fix(editor): restore centered flowchart node creation (#12500) | ||
|
|
b99a49dbeb |
perf(editor): load Mermaid diagram code per diagram type (mermaid-to-excalidraw 3.1) (#12481)
* perf(editor): bump @excalidraw/mermaid-to-excalidraw to 3.1.0 3.1.0 loads Pele's code per diagram type, on first use (`pele/lazy`), instead of all 33 diagram types at once: a first flowchart downloads ~66 KiB (brotli) instead of ~217 KiB. The per-diagram chunks are only reachable through the lib's dynamic import, so `lazyChunksPlugin` keeps them out of the PWA precache. Claude Opus 5.5 (xhigh) * chore(editor): name Pele's diagram chunks in TTD chunk-load comments Since mermaid-to-excalidraw v3, it's Pele (not Mermaid) that lazy-loads a chunk per diagram type, as of 3.1.0. Claude Opus 5.5 (xhigh) * feat(app): cache all Mermaid chunks for offline use once the TTD dialog opens mermaid-to-excalidraw 3.1 splits Pele into a chunk per diagram type, which aren't precached. With 3.0, the single Pele chunk cached on first use covered every diagram type offline; now only the types converted while online would. `lazyChunksPlugin` emits the list of mermaid chunks as a hashed JSON asset, which index.html points to with a `<meta>` (+33 B br). Once the TTD dialog is opened, the app fetches the list and the chunks (after 5 s, so the dialog's own chunks aren't fetched twice, at low priority) for the service worker to cache in `lazy-chunks` (~200 kB br on top of what the dialog loads). App only: package hosts (e.g. E+) are unaffected. Claude Opus 5.5 (xhigh) |
||
|
|
e7b534668a |
ci(repo): measure each master commit against the one before it (#12484)
GitHub's hosted runners differ from run to run (region, CPU), so a commit's timings only compare with timings from the same runner. - The perf job builds the commit and master before the push and loads both alternately (`yarn stats:compare --base <commit> --iterations 6`), instead of waiting for staging; without staging there's nothing to cancel, so every merge gets its run. - `perf.mjs --base` takes a commit: checked out into a temporary worktree with its own dependencies, built and served like this checkout. `--out *.json` writes both builds' loads; `--wait-for` is gone. One unrecorded warm-up load per build, and the runner's CPU in the environment. - `post.mjs` sends the commit time (the admin orders runs by it) and the base build; perf runs need one. Claude Opus 5.5 (xhigh) |
||
|
|
14bb42edee |
feat(editor): lay Mermaid diagrams out with Pele (mermaid-to-excalidraw v3) (#12480)
* chore: type-check linked packages' `@excalidraw/excalidraw/{element,common}/*` imports against the sources
Packages linked into the monorepo (e.g. a local `@excalidraw/mermaid-to-excalidraw`)
import types from `@excalidraw/excalidraw/element/*` and `.../common/*`, which
didn't map to the sources and fell back to the linked package's own (published)
copy of `@excalidraw/excalidraw`, failing the type check. The mocked arrows in
the Mermaid tests now use the `LocalPoint` their points are typed as.
Claude Opus 5.5 (xhigh)
* feat(editor): TTD Mermaid errors on their source line, with guidance by diagram type
- Mermaid (and Pele) number lines as they parse the definition: without its
front matter, directives, comment lines and leading blank lines (and in
flowcharts and ER diagrams, a line ending with a comment runs on into the
next one). Errors are now mapped back to the line of the source they're on
for the highlighted line, the summary, the shown message, the auto-fixer and
the AI repair prompt. Errors past the end (e.g. a missing `end`) are on its
last non-empty line.
- The likely causes depend on the diagram type: an unclosed class body,
composite state or entity (not "a decision node"), sequence blocks missing
their `end`, labels with brackets or parentheses that need quoting, `end`
used as a node.
- Definitions without a (known) diagram type get a summary and hint, and their
first line is highlighted. Mermaid and Pele word that error differently.
Claude Opus 5.5 (xhigh)
* feat(editor): auto-fix more common Mermaid mistakes in TTD
New auto-fix candidates (each still only offered if it parses):
- quote labels with brackets or parentheses in them:
`A[Process (main)]` -> `A["Process (main)"]`
- close unclosed blocks (`subgraph`/`loop`/... `end`s, class/state/entity
`}`s) where their indentation ends, not only at the end of the definition
- close a node label left open before its edge (`A[Start --> B` ->
`A[Start] --> B`), and drop closing brackets that close nothing
- `->` -> `-->` in flowcharts and state diagrams (labels left alone)
- `end` used as a flowchart node -> `End`
- the `:` missing before a sequence message's or ER relationship's label
- an invalid flowchart direction -> `TD`
- a misspelled diagram type (`flowchar TD`, `sequencediagram`), or a missing
one
Claude Opus 5.5 (xhigh)
* feat(editor): fix and explain invalid or misplaced directions in TTD Mermaid
- A flowchart subgraph's `direction` is uppercased (`lr` -> `LR`), `TD` is
`TB` there (unlike in the flowchart's header), and one that isn't any
direction is dropped, for the subgraph to keep the flowchart's.
- A direction on the first line of a class, state or ER diagram
(`classDiagram LR`, `erDiagram direction LR`) is moved to a `direction`
statement on the next line, unless the diagram has one already.
- Sequence diagrams have no direction: it's dropped from their first line and
their `direction` statements.
- The likely causes explain all of these.
Claude Opus 5.5 (xhigh)
* feat(editor): mark TTD assistant messages rendered with Pele
Assistant messages are saved with the chat with `renderer: "pele"`, to tell
their diagrams from those of chats saved before mermaid-to-excalidraw v3,
which Mermaid rendered (and which can't be told apart later).
Claude Opus 5.5 (xhigh)
* feat(editor): paste `swimlane-beta` diagrams as Mermaid
mermaid-to-excalidraw v3 converts them (Pele renders them, Mermaid doesn't),
but pasting one inserted it as text, as `swimlane` wasn't a diagram type
that marks pasted text as Mermaid.
Claude Opus 5.5 (xhigh)
* feat(editor): lay Mermaid diagrams out with Pele (mermaid-to-excalidraw 3.0.0)
mermaid-to-excalidraw 3.0.0 parses and lays out diagrams with Pele instead
of Mermaid, which is no longer bundled. It keeps labels where Pele placed
them along their arrows with `label.labelPosition`, which skeleton arrows
support since #12425.
Claude Opus 5.5 (xhigh)
* docs: changelog for mermaid-to-excalidraw v3 and skeleton bound arrows
Claude Opus 5.5 (xhigh)
|
||
|
|
c711e80ec5 |
fix(editor): route elbow arrows with a single corner where one fits (#12458)
* fix(editor): route elbow arrows with a single corner where one fits Elbow arrows keep a padding around the elements they connect, and enter the end element from the edge of it. When the end element is closer to the start's side than that (e.g. just below it), the route stepped aside to that edge first, with a few pixels' jog. When the elements can be connected with a single corner instead (leaving the start and entering the end the way they head, both legs clear of both elements, the legs with arrowheads long enough to fit them), that route is used, before (and instead of) routing on the grid. As a leg without an arrowhead can be short now, changing the arrowheads of an elbow arrow (from the picker, by flipping it, or by pasting styles) routes it again, to make room for them. Claude Opus 5.5 (xhigh) * fix(editor): route elbow arrows with two corners where they fit When the arrow leaves the start element and enters the end one heading the same way (e.g. from the bottom of one to the top of another below and to the side of it), and they're closer than the padding the arrow keeps around them, the route had a few pixels' jog between the two paddings. Such arrows are now routed with two corners, the same way as with a single one: turning halfway, as on the grid when there's room. When only one end has an arrowhead, and halfway would leave it a shorter leg than the padding, the turn moves toward the other end (keeping enough of that leg to round its corner). Claude Opus 5.5 (xhigh) * fix(editor): keep elbow arrows' simple routes when their fixed segments go When an element moves so that an elbow arrow's segment lines up with its fixed one (e.g. moving the start element a grid step, onto the fixed segment's level), they're merged and the fixed segment dropped, and the arrow re-routed, as when a fixed segment is released. That re-route went straight to the grid, without trying the one or two corner route first, which left the jog that route avoids until the arrow was routed again. Any route on the grid now tries the simple route first. Claude Opus 5.5 (xhigh) * refactor(editor): route and clean elbow arrows in one place routeElbowArrow() now tries the one or two corner route, falls back to the grid, and removes short segments and points between collinear ones, so its three callers don't repeat that. They also pass getElbowArrowData()'s result through, rather than destructuring and rebuilding it. Claude Opus 5.5 (xhigh) * refactor(editor): name elbow arrow route getters and updates apart routeElbowArrow() returns a route's points, and rerouteElbowArrow() an element update routing the arrow again, so they're getElbowArrowRoute() and updateElbowArrowRoute() now (and the grid routing getElbowArrowGridRoute()). Claude Opus 5.5 (xhigh) * fix(editor): draw elbow arrows' jogs too short to see straight While an element bound to an elbow arrow is moved so that a fixed segment lines up with the ones around it, the arrow keeps a zero-length jog between them until it's released, and rough.js drew the jog's two corners as a knot. A segment shorter than 1px between two longer ones heading the same way is now drawn straight. Corners of short segments in a row, and short U-turns, keep their corners. Claude Opus 5.5 (xhigh) * fix(editor): keep elbow arrows' simple route legs long enough to round A leg of the one or two corner route without an arrowhead only had to outlast the cleanup of short segments (1px), so the route could leave stubs a few pixels long (e.g. from the side of one element to the facing side of another just below and beside it, with no arrowheads). Their corners lost their rounding, and the arrow looked like a line hugging the element, coming from the wrong side. Every leg is now longer than half the corner radius, keeping at least a quarter of the rounding, and one with an arrowhead also fits it. Shorter legs go to the grid routing instead. Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix(editor): keep elbow arrows' simple routes clear by the binding gap The one or two corner route kept a fixed 5px from the elements it connects, rather than the binding gap the arrow keeps at its ends (which grows with the element's stroke). Where an element's bounds reach past the point the arrow binds to (e.g. an ellipse or a diamond entered below its top), a leg could pass closer to it than that, and over a thick stroke. The route now keeps clear of each element by its binding gap. Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * refactor(editor): check elbow arrow route legs with doBoundsIntersect() segmentCrossesBounds() repeated doBoundsIntersect()'s overlap check, so it now passes it the segment's bounds instead. Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * refactor(editor): tidy up the elbow arrow route getters getSimpleRoute() worked out the last leg of a one corner route also for two corner ones, which then replaced it, and took a Pick<> of the data its only caller passes whole. getElbowArrowGridRoute()'s doc listed parameters it doesn't take. Signed-off-by: Mark Tolmacs <mark@lazycat.hu> --------- Signed-off-by: Mark Tolmacs <mark@lazycat.hu> Co-authored-by: Mark Tolmacs <mark@lazycat.hu> |
||
|
|
808d068e18 |
fix(packages/excalidraw): update arrow binding on skeleton transform (#12425)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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.
* 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.
* 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.
* 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.
* 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.
|
||
|
|
95307fa136 |
fix(packages/excalidraw): export PNGs from a CPU-backed canvas (#12471)
Chrome's Skia Graphite GPU canvas backend antialiases paths with 4x MSAA, so PNG and clipboard exports came out jaggy, and large exports allocated GPU memory many times the bitmap's size. Request a willReadFrequently context on the export canvas before rough.canvas() creates one without options (only the first getContext() call's options apply). Claude Opus 5.5, xhigh |
||
|
|
cdc181c82a |
ci(repo): run the stats perf job on ubuntu-24.04 (#12479)
- ubuntu-latest now resolves to the 26.04 image, where Playwright 1.58 cannot install Chromium, so the first Performance run failed at Install - a fixed image also keeps the runs comparable across runner upgrades Claude Opus 5.5 (xhigh) |
||
|
|
4eb1e648aa |
ci(repo): track bundle size and performance of master builds (#12469)
- `Stats` workflow on master: posts the production build's file sizes (raw, gzip, Brotli; initial load vs. lazy; bytes per source package) and, once staging serves the commit, its page-load and pan/zoom measurements to the Excalidraw+ backend; OSS_STATS_TOKEN lives in the master-only `stats` environment - `scripts/stats/`: bundle-stats Vite plugin and wrapper config (`yarn stats:bundle`), the Playwright runner (`yarn stats:perf`) and the poster - `yarn stats:compare`: builds the checkout, serves it with `vite preview` and compares it with staging (alternating loads, Mann-Whitney U test); prints a table or writes CSV with `--out` - `excalidraw:app-start` mark in the app's entry, ending the runs' "HTML + JS" phase - `playwright` 1.58.2 dev dependency (installs no browsers by itself) Claude Opus 5.5 (xhigh) |
||
|
|
b7de45e881 |
feat(editor): fit arrowheads to short last segments & fill them along their outline (#12439)
* feat(editor): fit arrowheads to short last segments Arrowheads used to shrink to half of the last segment, so multi-segment arrows ending in a short segment got near-invisible heads. They now use the whole last segment, or extend past its start where the shape allows: - triangle: grows until its base reaches the previous segment - arrow: widens as it shrinks (20° -> 30°), grows to half its size while its sides stay a stroke width off the previous segment - circle: grows freely (no direction), also on curved arrows - bar: ends stay closer to the tip than to the previous segment - diamond: back vertex reaches the corner - cardinality markers: scaled as a whole to fit the last segment - elbow arrows: the corner rounding is taken into account Single-segment and curved arrows keep the old sizing, except circles. Claude Opus 5.5 (xhigh) * fix(editor): fill arrowheads along their outline rough.js jitters a solid fill separately from the outline (by up to 2px), which on shapes as small as arrowheads made the fill stick out, and the repeated closing point of triangles/diamonds drew a stray hair at the tip. - triangle, diamond and circle arrowheads are drawn as a single rough stroke, and filled along that stroke - polygon arrowheads keep their corners in place, only edges bow - fewer ops: faster to generate and draw 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> |
||
|
|
974f054baf | fix(editor): embed YouTube live links (#12178) | ||
|
|
afed9e6e27 |
fix(editor): handle the save-as shortcut while editing text (#11922)
* fix(editor): handle the save-as shortcut while editing text Cmd/Ctrl+Shift+S did nothing while a text editor was open — the editor stayed open and no save happened. Plain Cmd/Ctrl+S worked. The wysiwyg keydown handler only branches on `actionSaveToActiveFile`, whose keyTest requires `!event.shiftKey`, so the shift variant matched nothing and was swallowed. This adds the sibling branch for `actionSaveFileToDisk`, mirroring what the plain shortcut already does: commit the text, then run the action. Complements #9281, which fixed the plain shortcut in the same handler. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(editor): assert the save-as shortcut actually dispatches the save Review feedback: the regression test only asserted that editing ended, which `handleSubmit()` satisfies on its own — the test still passed with the `executeAction(actionSaveFileToDisk)` call deleted, so half the fix was unpinned. Now spies on `saveAsJSON`, which is what the action ultimately reaches, and captures `editingTextElement` at the moment it runs so the ordering (commit, then save) is pinned too. Verified: removing the dispatch now fails with `expected "saveAsJSON" to be called 1 times, but got 0 times`. Also adds a negative case — closing the editor with Escape must not save — so the spy proves the save is tied to the shortcut rather than to teardown. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(editor): dispatch text-editor save shortcuts as keyboard actions, trim tests - pass the "keyboard" source for both save shortcuts in the wysiwyg keydown (was the default "api", which skipped the interaction gate and mistracked) - drop the explanatory comment on the save-as branch - fold the three save tests into one it.each in the existing container-unbound suite, covering both Cmd/Ctrl+S and Cmd/Ctrl+Shift+S and pinning that the text is committed before saveAsJSON runs Claude Opus 5.5 (1M context), xhigh --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com> |
||
|
|
d29d864884 |
feat(editor): file drop overlay & shift-to-merge imported scene (#12177)
* feat(editor): add file drop overlay and Shift-to-insert support * fix(editor): report copy drop effect for file drags Shift defaults a drag to "move" (and a "Move" cursor), but a dropped file is only ever read in, never moved. Opus 5.5 (xhigh) * fix(editor): ignore file drops in view mode and when non-interactive The dragover/drop cancel listeners were only registered in edit mode, so elsewhere the browser opened a dropped file natively. Register them always, show a no-drop cursor where drops are ignored, and don't handle the drop. Opus 5.5 (xhigh) * feat(editor): cross out the existing file in the drop overlay when replacing Opus 5.5 (xhigh) * fix(editor): note that library files won't replace content in the drop overlay OS-dragged .excalidraw and .excalidrawlib files both report an empty MIME type until dropped, so the overlay can't tell them apart. Keep the replace copy for untyped files and add a secondary note for libraries. Opus 5.5 (xhigh) * fix(editor): use --overlay-bg-color for modal and file drop backdrops Replaces color-mix() in the file drop overlay, which is newer than our browserslist, with the (previously unused) --overlay-bg-color token, now hardcoded per theme, and reuses it for the <Modal> backdrop. Opus 5.5 (xhigh) * fix(editor): scope image-scene drop try to parsing, drop redundant preventDefault Only loadFromBlob is wrapped now, so an error while inserting or replacing isn't reported as an invalid file or followed by a plain image insert. App's dragover listener is always registered, so the overlay no longer needs to call preventDefault itself. Opus 5.5 (xhigh) * fix(editor): don't let the browser open files dropped on modals Modal portals live outside the editor container, so its dragover/drop listeners didn't cover them. Cancel file drags on body-level portal containers, leaving non-file drags (e.g. text into inputs) native. Opus 5.5 (xhigh) * chore(editor): move fileDrop locale strings next to overwriteConfirm Opus 5.5 (xhigh) * feat(editor): toast how to undo after a drop replaces the scene Opus 5.5 (xhigh) |
||
|
|
f3d99c42e9 |
fix(editor): pan the canvas to follow the caret instead of shifting the UI (#12175)
* fix(editor): keep the text editor flush with the canvas when a click places the caret in a tall text Editing a text that reaches past the viewport with the text tool (a click places the caret) scrolled the editor's content: the textarea is clamped to the viewport, focus() reveals the caret — which sits at the end of the value until the initial selection is applied — and the deferred refocus after the pointerdown's blur did that on an unfocused textarea, so the text moved up by the overflow while the box stayed put. The selection tool's single-click edit starts on pointerup, with no blur, so it never refocused and looked fine. After placing the initial caret — inside the visible box by construction — the textarea's own scroll goes back to zero. Verified in the browser on a 49-line text hanging 250px below the viewport at 90% zoom: internal scroll was 278px, now 0, for the text tool with the mousedown blur; the selection-tool path stays at 0. jsdom textareas don't scroll, so there is no unit test for it. Claude Fable 5.1, high effort * fix(editor): place the editor of a rotated text where the text is The editor's textarea was scaled and rotated about its own box's center, while the canvas rotates a text about the text's center. The two only agree when the box is the text's size — and it isn't once the box is clamped to the viewport (a tall text reaching past it) or, slightly, through the 5% height buffer. A rotated text scrolled partly off the viewport got its editor displaced by the rotated pivot offset (36px for a 49-line text at -18° and 130% zoom), and the clamp — a cut along the box's own edges — removed lines that were still on screen on the side the rotation lifted. Now the transform origin is the text's center whatever the box's size, with the translate derived from the text's dimensions, so the editor lands on the text in every case; the viewport clamps (right and bottom) apply only to an unrotated box, whose edges are the viewport's, and a rotated box is left whole. Since an unclamped box can reach past the viewport, both focus() calls pass preventScroll so revealing the caret can never scroll the container — the app owns scrolling. Verified in the browser: all four corners of the rotated editor coincide with the text's (they were off by up to 36px), typing at the off-screen end leaves the container unscrolled, and the unrotated case is unchanged — still clamped to the viewport bottom, top-left in place, no internal scroll on a click caret, select-all on Enter. Also updates the linear-editor style snapshot for the editor's explicit transform origin. Claude Fable 5.1, high effort Claude Opus 5.5 (1M), xhigh effort (moved the snapshot update in) * fix(editor): never let the browser scroll the editor container to reveal a caret The root container is `overflow: hidden`, which still makes it a scroll container the browser scrolls programmatically. Typing in a text editor whose box reaches past the viewport — a rotated text's editor cannot be clamped to the viewport without losing lines still on screen — made the browser reveal the caret by scrolling the container, pushing the whole UI out: two new lines below the viewport moved the toolbar up by 416px. `overflow: clip` clips exactly like `hidden` but is not a scroll container, so there is nothing for the caret reveal (or a focus) to scroll; `hidden` stays as the fallback where `clip` is unknown. The editor never scrolled this box itself. Verified in the browser with real key input on a rotated 49-line text hanging below the viewport at 130% zoom: the container stays at 0 and the toolbar in place through new lines and characters typed past the viewport. Claude Fable 5.1, high effort * fix(editor): the canvas follows the caret instead of the page scrolling to reveal it With the editor root at `overflow: clip` (previous commit), the browser's caret reveal skips the root, since it is no longer a scroll container. Full page, nothing moves, but the caret stays out of view. Embedded in a page that scrolls (directly, or in a same-origin iframe), the reveal scrolls that host page instead: 434px for a rotated text reaching past the editor's bottom edge, 345px for a text scrolled below it while edited. Only a cross-origin iframe stops it. The root goes back to `overflow: hidden`, so it absorbs the reveal again. While a text is being edited, the text editor hands any scroll of the root to the canvas (`viewport.translate` by the same screen distance) and resets the root. Scroll events fire before the frame is painted, so the root's shift is never seen. Nothing moves, host page included, and the canvas pans just far enough to bring the caret into view. The reveal is the browser's, so this covers everything that moves the caret: typing, Enter, arrow keys, paste, IME, and drag-selecting past the edge. Measured with real key input in Chromium, full page and in a same-origin iframe embed: host page and root unmoved, canvas panned 444px / 330-355px, caret visible, the editor still on its text. Outside text editing, a root scroll is left as it was. Test: a root scroll while editing is reset and pans the canvas (at 200% zoom, both axes) with the editor on it; with no text being edited, the root is left alone. Claude Opus 5.5 (1M), xhigh effort * fix(editor): never cut the text editor to the viewport; the canvas follows the caret for every text The editor of an unrotated text was cut to the viewport's right and bottom edges (the width of unbound text, plus a max-height), so a caret past an edge was revealed by scrolling the textarea's content inside the cut box. The canvas stood still, and the editor's text left its place on the canvas while typing. Rotated texts were already left whole, and their caret reveal panned the canvas (previous commit). Now no editor box is cut: rotated or not, it is the text's own box, and a caret past the viewport's edge is revealed by panning the canvas. Typing past the bottom edge, or a long line past the right edge, moves the view along; the editor stays on its text. What only existed for the cut goes with it: the `maxWidth` bookkeeping, and the reset of the textarea's internal scroll after placing a click's caret (a whole box never scrolls inside). Measured with real input in Chromium: 455px vertical pan for a 30-line text crossing the bottom edge, 454px horizontal pan for a line crossing the right edge, root and textarea unscrolled, editor on its text. A text-tool click on line 3 of a text taller than the viewport places the caret there without any pan or internal scroll. Tests: the max-width test now checks the editor isn't cut at either edge (it fails with the cut in place); the linear-editor style snapshot loses its max-height. Claude Opus 5.5 (1M), xhigh effort * feat(editor): leave room past the caret when the canvas follows it The browser reveals a caret only as far as it has to, so text typed past the viewport's edge came into view flush against the edge. The canvas now pans a further CARET_FOLLOW_PADDING (5 screen px) along the axis it follows, so the caret keeps a little room from the edge while the view follows it. Not done with the root's `scroll-padding`: the browser honors it only as far as it can scroll, and the editor box ends at the text (5% below it, nothing past a line's end). Measured in Chromium: `scroll-padding: 80px` left 39px below the caret and none to its right. Measured with real input: once the caret reaches the edge, every new line or character pans the canvas and the caret stays 4-5px from the edge, both typing down and along a long line. Test: the pan includes the padding, and a reveal along one axis pans along that axis only. Claude Opus 5.5 (1M), xhigh effort * feat(editor): the canvas follows a caret behind a docked sidebar; the reveal stays in the editor's box A caret that went behind a docked sidebar stayed hidden: it was still inside the editor root, so the browser had nothing to reveal and the canvas never followed. The text editor's container (`.excalidraw-textEditorContainer`) is now the box a caret is revealed into: the canvas area, clipped, and inset off a docked sidebar (measured from `.sidebar--docked` on every editor update, on the right or the left for RTL; the editor's position is relative to the box). A caret past its edge, or behind the sidebar, is revealed by scrolling the box, which the text editor turns into a canvas pan (+ padding) and resets, as it did for the root before. The reveal now never gets past the box, so the editor root is back to master's CSS, and what a host does to the root's overflow no longer matters: with the root forced to `overflow: visible` (as Excalidraw+ does, inside a wrapper that resets its own scroll), the canvas follows the same way and the wrapper never scrolls. Measured with real input in Chromium, full page, with the root forced to `visible`, in the Excalidraw+ arrangement, and in a same-origin iframe embed: nothing scrolled (host page, root, box), the canvas panned 449 / 360 / 580px for texts past the bottom edge, and for a line typed in behind the docked sidebar it panned 120px, leaving the caret 5px left of the sidebar. Clicks inside the editor still place the caret; clicks on the canvas still end editing. Tests: the pan test scrolls the editor's box; a new test covers the insets for a sidebar docked on either side, and their removal with the editor. Claude Opus 5.5 (1M), xhigh effort * refactor(editor): measure the sidebar through the viewport UI markers The text editor's box was kept off a docked sidebar by querying the `.sidebar--docked` class and measuring it inline in textWysiwyg. How far viewport UI reaches into the canvas is AppViewport's concern: `getOffsets` measures every UI marked `data-viewport-ui`, and the sidebar is marked (`side` / `sidebar`, except on phones, where it's an overlay). AppViewport gains `getSidebarInsets()`, which measures just the sidebar through those markers, with a `measureSide()` that `getOffsets` now shares. The text editor asks the viewport for the insets. An open sidebar that isn't docked covers the canvas the same way and now counts too; it closes when the canvas is clicked to start a text, so this rarely matters. `getOffsets` isn't used for the box: it gives one band per side for all marked UI, so the top toolbar and the styles panel (open while a text is edited) would pan the canvas as soon as one typed below them. Test: the docked-sidebar test's fake sidebar carries the markers. Claude Opus 5.5 (1M), xhigh effort * feat(editor): a text stops growing at the view's width, and is brought into view when it wraps Closes #8855. Typing a long line grew a free text past the view's edge. The canvas followed the caret, so the start of the text went out of view on the other side, and the box had to be resized by hand afterwards. A free text that grows with its content (`autoResize`) now stops at the view's width: the canvas minus the sidebar, less TEXT_VIEWPORT_PADDING (20px, in @excalidraw/common) at each side, in scene units, so it follows the zoom. On the keystroke that would cross it, the text becomes fixed width at exactly that width and wraps from then on (`autoResize: false`), anchored the way it grew, so a right-aligned or centered text keeps its edge or center. The editor switches to wrapping with it. A text that is already wider keeps growing; nothing shrinks. The rule is an optional `maxWidth` on `refreshTextDimensions`, which the editor's per-keystroke update passes. When a text starts wrapping in the editor, while typed or pasted into it, it is scrolled into view with the same room at the edges. Being exactly the padded view's width, it then fills it. That happens horizontally always, and vertically only if all of it fits; a taller text leaves the vertical to the caret-follow, so the view doesn't jump away from the caret. Pasting onto the canvas keeps its wrap width (half the view, 200-800), capped by the same limit, so that the 200 minimum can't outgrow a narrow or zoomed-in view. A paste that wrapped is scrolled fully into view; if it is taller than the view, its top is brought in. Scrolling into view is computed by a pure `scrollBoundsIntoView` in viewport.ts, next to `centerScrollOn` and `constrainScrollState`. It moves by the least amount, keeps the zoom, takes the usable area as `Offsets`, and returns null when nothing needs to move. The move itself goes through `viewport.translate`, as a user pan does: it respects scroll locks, yields to a host's pending locked navigation, and stops following a collaborator. No move, no translate. Measured with real input in Chromium on a 2560px view: typing character by character at 400% from 100px in, and a sentence inserted at once, both end as a wrapped text from 20 to 2540; with the docked sidebar the limit is 2226 (2560 - 294 - 40) and the text sits 20px left of it; a paste near the bottom-right corner ends 20px inside the right and bottom edges. Nothing scrolled the page or the editor box. Tests: the text stops and wraps at the view's width, and keeps that width; the limit follows the zoom and a docked sidebar; a right-aligned text keeps its right edge; a text already wider keeps growing (the not-cut-off test, reworked); starting to wrap scrolls it into view with room at its right edge, but not vertically when it's taller than the view; a paste isn't wider than the view at 800% and, wrapped, ends fully in view; `scrollBoundsIntoView` unit tests. Claude Opus 5.5 (1M), xhigh effort |
||
|
|
c10499eebb |
feat(editor): text tool edits what you click, shows what a click will do, drags out free text in shapes (#12082)
* fix(editor): do not inherit groupIds/angle from container if not binding the text to it * fix(editor): text tool edits a label only when clicking the label itself Clicking elsewhere inside a labeled container creates an independent text at the clicked position, with no modifier needed (so also on touch/pen), instead of warping to the label center and editing the existing label. * feat(editor): highlight what the text tool would act on when hovering Mirror the click logic on hover: the text element a click would edit gets a box highlight, and an empty text-bindable container the click would bind into gets the same binding highlight arrows use (box for arrow containers, which the binding outline renderer can't draw). Cleared on pointerdown and managed only while the text tool owns the interaction, so the frame flows sharing elementsToHighlight are untouched. Also documents suggestedBinding, isMidpointSnappingEnabled and elementsToHighlight in AppState. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): hit-test arrow labels at their derived position An arrow label's stored coords aren't updated when the arrow moves (dragging deliberately skips them — the position is derived at render time), which left hitElementItself internally inconsistent: its bounds pre-check derives the position, but the precise shape test read the stale stored coords, so a moved arrow's label was only hittable where its old and new rects overlap. Substitute the derived coords for the precise test, and skip the version-keyed point cache for container-bound labels (their position can change without a version bump, mirroring ElementBounds). Pass the elements map through renderElementsBoxHighlight so the highlight box is also drawn at the label's derived position. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): dashed text box for the text-tool hover, cleared when the tool is left The text a click would edit gets the same subtle dashed box as a wrapped text being edited (at the label's derived position for arrows), instead of the frame-style bounding box. The hover highlights are cleared whichever way the text tool is left — Esc/finalize paths bypass setActiveTool. * refactor(editor): dedupe container-bound label position derivation An arrow label's accurate position is derived from the arrow rather than stored on the element (dragging deliberately skips updating it), and three call sites hand-rolled the same clone-with-derived-coords dance. Extract it into getTextElementWithAccuratePosition next to the existing position helpers. Also routes the text-tool dashed hover highlight through the helper, so it renders at the label's actual position instead of its stale stored coords. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): defer text-tool hover highlights to arrow text anchors The arrow-endpoint text binding (#11777) added its own text-tool hover affordance (hoveredArrowTextAnchor) covering arrow endpoints and midpoint label anchors, and gave endpoints precedence on click. Mirror that in the text-tool highlight updater: skip positions where a bindable endpoint would take the click, and leave arrow anchors (endpoint & midpoint label) entirely to the anchor affordance — the highlights now only cover editing an existing text and binding into an empty non-arrow container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(editor): make endpoint-vs-text preference z-aware to prevent affordance flicker The endpoint offer was suppressed by any text element under the cursor, regardless of stacking order. With an arrow drawn over an existing text, the text's bbox edge cut into the endpoint's hit circle, and slow pointer movement flickered between the endpoint anchor and text editing. Drop the z-blind text check and let the existing z-order occlusion rule decide: whatever is stacked above owns its hit area. A text above the arrow keeps its edit behavior; when the arrow is on top, its endpoint has full preference over the whole hit circle, matching the drawn highlight. Container-bound labels need no special casing — a labeled container is interior-hittable, so the occlusion rule already yields to labels whose container sits above the arrow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(editor): defer a text-tool center click so a drag creates free text A click on an empty container's center still binds a label, but the decision now waits for pointerup: dragging horizontally past the autowrap threshold instead creates an independent fixed-width text at the pointer origin, and small shapes are no longer provisionally enlarged while dragging. Tool changes and the missing-pointerup cleanup cancel the pending click. Shape hover and pointerdown share the empty-container / center-snap / Alt eligibility via getTextCreationContainerAtPosition, and the hover indicators are cleared when deferred creation starts (stale outline under a locked tool at 200% zoom). Also: a direct collision-cache regression for labels of moved arrows, exact width/position assertions for drag creation across mouse/pen/touch, labelPosition coverage at 25/50/75%, and stale AppState comments fixed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(editor): redraw the dragged text box under a locked text tool Drag-sizing a new text mutates it in place without informing the scene, so sceneNonce never moves and the interactive canvas — which draws the dashed text box from the live element but memoizes on canvasNonce — kept the first size. Unlocked drags only repainted by accident: the tool had already reverted to selection, whose box-selection branch churns state every move. Fold the new text's versionNonce into canvasNonce, as is already done for framed new elements. Four rendering regressions cover successive drag widths on empty canvas and from a container's center, locked and unlocked. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * refactor(editor): extract the text tool's pointer interaction into AppTextTool Pure move of handleTextOnPointerDown, resetTextTool, maybeStartPendingText, maybeUpdateTextToolHighlightOnPointerMove and getTextCreationContainerAtPosition into App.textTool.ts — only `this.` became `this.app.` and the names lost their "Text" prefix. maybeDragNewGenericElement is now public so the pending center-drag can re-dispatch to it. No behavior change. Text editing itself (startTextEditing / handleTextWysiwyg and the hit helpers) is shared with Enter, double-click and the other entry points and stays in App. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(editor): resolve text-tool targets once; single textToolHover state What a text-tool click would do at a position was computed in three places — the text/container highlight, the arrow-anchor hover and the pointerdown — with different modifier awareness, and shown through three AppState fields (elementsToHighlight, suggestedBinding, hoveredArrowTextAnchor) cleared from seven sites. The affordance could promise what the click wouldn't deliver: - pressing or releasing Alt without moving left the container outline stale (and Ctrl/Cmd left the text box stale) - Alt-hovering an empty arrow's midpoint advertised a label while the click created free text - Ctrl/Cmd hid the container outline (the renderer gates suggestedBinding on isBindingEnabled) while the click still bound a label - over a shape's or arrow's label the cursor was a crosshair while the box promised an edit AppTextTool.getTargetAt now answers the question once — endpoint → text → empty centered container (unless Alt) → free — and feeds the hover, the cursor and the pointerdown. The hover lives in one field, textToolHover (replacing hoveredArrowTextAnchor), drawn by one renderTextToolHover branch; it is cleared on pointerdown and when the tool is left, nowhere else. Alt and Ctrl/Cmd keydown/keyup refresh it at the last pointer position. The scene is hit-tested once per pointermove instead of twice. Also drops AppArrowText's anchor-state members (the resolver covers them) and getLabelCenter, dead since the label-center warp was removed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * refactor(editor): let AppTextTool own the pending center click; explicit textElement The deferred center click was threaded through PointerDownState.text and a textCreation parameter that made startTextEditing — the entry point shared with Enter, double-click, sticky-note drops and autoshape — re-derive what the text tool's pointerdown had already established, then bail. The helper now arms `pending` itself (like AppBucketFill), decides it on pointermove/up, and PointerDownState loses its text slot. The affordance armed at pointerdown now stays up until the click resolves instead of being cleared and re-shown. startTextEditing takes an explicit `textElement` instead: the tool passes the text it resolved, or null to create — so a text selected through the host API can no longer hijack a text-tool click elsewhere (the Enter and double-click paths, which leave it undefined, resolve as before). The same selection shortcut leaves getTextBindableContainerAtPosition, which is now purely positional; the double-click path keeps it inline. Also: a pending container deleted mid-press (collab) now still ends the tool's turn, and the drag threshold's choices are documented in place. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * feat(editor): ctrl/cmd, not alt, opts out of labeling a container with the text tool Ctrl/cmd already turns off arrow-endpoint binding for the text tool; it now also keeps a center click from binding a label to an empty container, so one key means "no binding" throughout the tool, as elsewhere in the editor. It is read off the event rather than the arrow-binding preference — a label is not an arrow binding. Alt no longer plays a part in the text tool, so its hover refresh hooks go (alt keeps its generic drag meaning: resize from center). The double-click path is unchanged. Ported from #11210. Co-authored-by: Loric Brevet <loric.brevet@gmail.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(editor): cancel a pending text-tool click on tool exit and pointer cancel; refresh hover and cursor when the viewport moves Three lifecycle gaps in the text tool's hover and pending center click: - A pending center click only checked the active tool at the next pointer event, so leaving the tool (Esc) and picking it again before releasing revived the old press: moving then created free text at the original position. And with no pointerup after a pointercancel (scroll, palm rejection), the pending click stayed armed for unrelated movement. The helper now has an explicit cancel, called when the tool is left and on pointercancel next to the bucket fill's. The cancel also clears the outline the armed click had set, which no hovering pointer would clear otherwise — including when a second finger turns the press into a pinch/pan (that discard goes through the same cancel). - The hover was refreshed on pointer moves and modifier keys, but not when the viewport scrolled or zoomed under a still pointer, so an outline stayed on a shape that had moved away. The refresh now re-derives the scene point from the pointer's last viewport position, remembers the last modifiers, and runs from the viewport-change lifecycle. - A modifier press changed the target without updating the cursor (an endpoint's pointer cursor survived Ctrl). The refresh sets the cursor from the same target, mirroring the pointermove path and leaving a panning or scrollbar gesture its own cursor. Also fixes a stale renderer comment about the container outline's binding gate. Tests: tool exit and re-pick mid-press, pointercancel, wheel scroll and zoom under a still pointer for container and text targets, cursor on modifier press and release. Verified in Chromium as well. Claude Fable 5.1, high effort Claude Opus 5.5 (1M), xhigh effort (moved the snapshot update to the caret-overflow branch) Claude Opus 5.5 (1M), xhigh effort (the cancel clears the armed outline, from the 2026-09-26 review) * fix(editor): tear a gesture down on pointercancel; a replayed cleanup no longer counts as a click A canceled press (the browser taking the pointer for a scroll, a pinch or palm rejection) left the gesture's window listeners and its missing-pointerup cleanup subscription in place. The next pointerdown then replayed the old up handler, whose end-of-gesture revert switched the tool to selection while the new press was being armed — so after a canceled center press with the text tool, the next center click switched tools and created nothing. pointercancel now runs the missing-pointerup cleanup immediately, so nothing of the canceled gesture lies in wait. And the up handler's tool revert is gated on a genuine pointerup: a replay by the cleanup — a second finger landing, a pointercancel, the next press after a lost pointerup — only tears the gesture down and leaves the tool to the press that follows, instead of reverting it under that press. The pointercancel regression no longer sends a synthetic mouse-up that hid this: after the cancel the tool must still be the text tool and the next center click must bind a label. It fails without the fix. Claude Fable 5.1, high effort * refactor(editor): cursor from the text-tool target alone; a hover refresh needs a hovering pointer Follow-ups from the whole-branch simplification review (simplification.md), narrowed with the reviewer: - The cursor is derived from the resolved target only. The old fallback to the plain hit under the pointer kept a text cursor over other texts while editing or drag-sizing — where a click has nothing to point at — and forced a second hit test and a coordinate recomputation on every modifier press and viewport change. Both go. With a locked text tool, editing or dragging now shows the crosshair everywhere; hover, endpoint and label cursors are unchanged. - The hover refresh takes the pointer's last viewport position only. The fallback to the last *scene* coordinates was reachable when a tap preceded any pointer movement, and after a viewport change it resolved at a position nothing hovers — a phantom affordance. A tap leaves nothing to refresh, pinned by a test that fails with the fallback in place. Nor does a finger ever hover: a touch's last move is where it lifted, so touch input doesn't count as a hovering pointer (mouse and pen still refresh). The test drives real touches — a tap with jitter on a text, a short drag from a center — instead of clearing the pointer bookkeeping by hand. The pointercancel test now checks the armed outline is gone right after the cancel, and a second-finger test covers the missing-pointerup discard. - The explicit pending-click cancel on pointercancel stays, and its reason is written down: the gesture teardown that follows flushes a queued pointermove, which would otherwise find the click still pending and resolve it as a drag. Verified in Chromium by the reviewer; the test harness runs the throttle synchronously, so it cannot be reproduced there. - Two duplicated test scenarios removed: the arrow-anchor hover test the endpoint suite already covers, and a repeated Ctrl assertion. Claude Fable 5.1, high effort Claude Opus 5.5 (1M), xhigh effort (touch input never hovers; tests, from the 2026-09-26 review) * refactor(editor): the text tool refreshes its own hover and cursor; viewport navigation check lives in AppPan App's `refreshTextToolHover` was text-tool logic kept in App only because its cursor gate read App-private state. It moves into `AppTextTool` as `refresh(modifiers?)`, which re-resolves the hover and sets the cursor that goes with it, taking the place of `refreshHover`. The gate — space held, a pan in progress, a scrollbar drag, the hand tool — is the same check the canvas pointermove makes before touching hover or cursor. It becomes `AppPan.isNavigating()`, used by both. The scrollbar drag stays App's own and reaches AppPan as a dependency, like the pointer count. No behavior change. Claude Opus 5.5 (1M), xhigh effort --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Loric Brevet <loric.brevet@gmail.com> |