Commit Graph
4180 Commits
Author SHA1 Message Date
David Luzar b03c3bb2c6 chore(packages/excalidraw): vendor roughjs as @excalidraw/sloppy (#12832)
* chore(packages/sloppy): vendor roughjs as @excalidraw/sloppy

- port roughjs 4.6.4 with hachure-fill, path-data-parser and points-on-path into packages/sloppy
- move points-on-curve and roughjs's Random into @excalidraw/math
- output is identical to roughjs 4.6.4 (tests/parity.test.ts)

* fix(packages/sloppy): don't change the caller's points in polygon pattern fills

The fillers rotate a polygon's points in place and back, which left float
drift in an element's points every time a sharp, pattern-filled line's
shape was regenerated.
2026-12-03 23:03:24 +01:00
David LuzarandMark Tolmacs 548eff0c3d feat(packages/excalidraw): [ui] rewrite ui regions (#11787)
* feat(packages/excalidraw): [ui] rewrite ui regions

* feat(packages/excalidraw): [ui] keep footer + status overlay within editor bounds

The top and center regions move into `.exc-region-mesh`, a sibling of
`.exc-region-bottom` inside `.exc-regions` (a `minmax(0,1fr) auto`
two-row grid). The footer band and the toast/scroll-back overlay no
longer share column tracks with the top row, so wide top-left/top-right
content can no longer push them past the editor edge, and nothing in the
footer can displace the toolbar.

The mesh's side columns keep their content floors (`minmax(auto, 1fr)`),
so the top row negotiates width as in production: toolbar exactly
centered while both sides fit, shifted aside once one side outgrows its
share, and overflowing to the right (clipped at the editor edge) only
when nothing fits. Host slots stay rigid at their intrinsic width; the
collaborator list is the one flexible piece, collapsing avatars into the
"+N" pill (flex-basis 0, so the avatar-count ResizeObserver can't feed
back into layout). The desktop top-right occupants are wrapped in the
shared `.exc-region-top-right-content` cluster.

Claude Opus 5.5 (xhigh)

* feat(packages/excalidraw): [ui] flush UI area with docked sidebar

The layer-ui wrapper (and with it the ViewportStatusFrame border, which
tracks its width) now stops at a docked sidebar's visible edge instead
of the --right-sidebar-width column it reserves — the sidebar's 8px
outer margin was a dead gap between the UI area and the sidebar. The
regions container compensates with a matching right inset so
right-aligned UI (and the status stack's center) keeps its previous
visual position.

Also moves the in-flow mobile bottom-bar status-stack rule inside the
mobile block: it must out-rank the standalone mobile stack rule (which
re-adds the absolute positioning the regions model removed from the
base rule), else the scroll-back button paints over MobileShapeActions
instead of stacking above it.

Claude Fable 5

* feat(packages/excalidraw): [ui] stack top + center regions in three columns

Replaces the 3×4 mesh with three column stacks: each column is a flex
column of its top region and the center region below it, so a center
region clears exactly its own column's top region. The mesh needed
spanning rows that absorb overhangs to express the same dependencies,
plus the invariant that only the top regions may occupy a single track.

Only the top regions size the columns: the center regions have
`contain: inline-size`, so a wide styles panel overflows toward the
canvas instead of widening its column and offsetting the toolbar. The
top-row width negotiation is unchanged (`minmax(auto,1fr) auto
minmax(auto,1fr)`), and a real column-gap replaces the toolbar's inline
margins now that there are no zero-height rows for gaps to double up in.

Behavior change: the stats panel now clears only the top-right UI — a
top-left UI taller than the top-right no longer pushes it down. The
empty center-center region is dropped, and the status stack is
absolutely positioned against `.exc-regions` instead of being a grid
item spanning both rows.

Claude Opus 5.5 (xhigh)

* fix(packages/excalidraw): [ui] bound the stats panel; RTL docked-sidebar inset

The stats panel now scrolls within its region like the styles panel,
instead of running past the footer and covering the help button in
short windows.

The inset that keeps region content clear of a docked sidebar used a
physical `right`, but the sidebar docks on the left in RTL — so the 8px
went to the free edge and the toolbar sat 4px off. It's now
`inset-inline-end`.

Claude Opus 5.5 (xhigh)

* feat(packages/excalidraw): [ui] make regions positioning contexts

Every region is now `position: relative`, so absolutely positioned host
content anchors to its own region. Excalidraw+ hangs its call tray below
the top-right UI with `absolute top-10 right-0`; without a positioned
region it anchored to `.exc-regions` instead, which lands in the same
spot in LTR only by coincidence and on the wrong side in RTL.

Claude Opus 5.5 (xhigh)

* feat(packages/excalidraw): [ui] render host top-right UI alongside defaults on phone

On phones, `renderTopRightUI` content used to replace the editor's
top-right controls (sidebar trigger, pen-mode button) — any non-nullish
return value hid them. It now renders next to them, same as on desktop
and as before the new mobile layout (#9996). excalidraw.com returns
null on phones, so it's unaffected; Excalidraw+ already patched its
fork to render both.

Claude Opus 5.5 (xhigh)

* feat: Progressive collapse

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: Region API with priority-based collapse and overflow menu

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: Vertical and footer region collapse, phone mapping, status stack placement

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(packages/excalidraw): [ui] let shrink items shrink in the top-left region

The floor counts shrink items at their minWidth, but the top-left grid
track sized to the content's min-content, so a nowrap item (e.g. a host
scene name) overflowed the region under the toolbar instead of truncating.

Claude Opus 5.5 (reasoning: xhigh)

* fix(packages/excalidraw): [ui] region floors stuck at 0 or too small

- compute the floor before the budget check: a floor measured before the
  items' tunneled content rendered (0px) shrank the region to 0, which
  left no budget, so the floor was never re-measured (fresh load at a
  narrow width put the top-right UI over the toolbar)
- count gaps for displayed zero-width items (e.g. absolutely positioned
  host content), which still take a gap in the row
- user list minWidth includes the current user's pill (57px, not 36px)

Claude Opus 5.5 (reasoning: xhigh)

* fix(packages/excalidraw): [ui] compute the toolbar fold count analytically

Every foldable tool is as wide as the hand tool, so the fold count is a
closed-form function of the region's width — no fold-and-remeasure loop.
Folds land in the same frame as the resize (flushSync in the
ResizeObserver), resize down/up end in the same state, and an open "more
tools" menu no longer corrupts the cached tool widths (it ratcheted the
toolbar track until reload).

* fix(packages/excalidraw): [ui] measure the editor interface before first paint

The constructor can't measure the container, so the first render always
assumed a desktop editor with the full UI; a tablet-sized editor painted
the full toolbar and switched to the compact one on some later render.

* fix(packages/excalidraw): [ui] no layout shifts around the collaborator list

- floored top-right content can shrink to the floor, so the list no longer
  renders a frame with the avatars of its previous width (overflowing
  under the toolbar)
- the list re-renders in its ResizeObserver callback, before paint (it was
  a frame late e.g. when a host item next to it appeared)
- the list is as tall as the buttons next to it (it grew the row by 1px)

* feat(packages/excalidraw): [ui] replace region "⋯" menus with collapse="hide"

A second "⋯" next to the toolbar's own is confusing. Items now either
adapt (`render`) or go away (`hide`, with 32px to spare), on desktop and
phone. The stats panel just scrolls down to 120px, like the styles panel.

* feat(packages/excalidraw): [ui] keep region items collapsed on tablets

The compact UI below 1180px frees room, so items collapsed at a wider
editor expanded again — they came and went while resizing.

* fix(packages/excalidraw): [ui] don't clip the styles and stats panel shadows

Their region items were scroll containers on top of the panels' own
scrolling.

* feat(excalidraw-app): [ui] hide the promo while collaborating or when it doesn't fit

* fix(packages/excalidraw): [ui] keep the styles panel clear of the minimap

The minimap (from master, ported into the bottom-left region) floats above
the canvas actions, in the left column's way. Its region now stops above
it — the region's budget follows, so the panel scrolls — instead of the
hardcoded MINIMAP_RESERVED_HEIGHT the old max-height used.

* fix(packages/excalidraw): [ui] phone: "more tools" menu opens above the scroll-back button

The status stack kept its z-index inside the bottom bar (it applies to a
static flex item too), which put it above the toolbar's menu.

* fix(packages/excalidraw): [ui] RTL: follow frame inset on the docked sidebar's side

The inset was a physical `right`, but the sidebar docks on the left in
RTL: the frame was drawn over the sidebar and left a sidebar-wide strip of
canvas outside it.

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: Mark Tolmacs <mark@lazycat.hu>
2026-12-02 20:22:50 +01:00
David Luzar c2fe379867 chore(repo): don't install package versions younger than 7 days (#12797)
* chore(repo): don't install package versions younger than 7 days

pnpm resolves only versions published at least 10080 minutes ago, so a
compromised release is likely caught and unpublished before it reaches us.
Locked versions are unaffected: frozen and plain installs leave the
lockfile as is.

* chore(repo): exempt our own @excalidraw/* packages from the release age

We upgrade @excalidraw/mermaid-to-excalidraw and the other packages we
publish as soon as they're out.
2026-12-02 11:58:02 +01:00
David Luzar 9eb7bb7aa8 fix(repo): keep the bundle stats' file names the same across builds (#12794)
Since the Vite bump (5.0.12 to 5.4.21, #12655) assets carry their source file,
so the stats plugin started to name them by it. The fonts got new names, and
the page's CSS and HTML were both named after `index.html`, the entry chunk's
name: per-file history on the Bundle size page broke at that commit.

Name an asset by its emitted file without the hash again, as every build
before did.
2026-12-02 09:48:35 +01:00
Márk Tolmácsanddwelle 30a4c631a5 chore(repo): Move to pnpm (#12655)
* fix: Undeclared dependencies

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* chore: Rationalize package versions

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* chore: Remove old react app remnants

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: Conversion to pnpm

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Circular deps #0

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: common package circular dependencies

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* chore: Move history and undo/redo to excalidraw/excalidraw

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: AppState broken up across package boundaries

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: renderElement and binding type racionalization

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Refactor linearElementEditor to not use types outside the package

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* chore: Do not import self barrel file

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: All circular dependencies except core

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: Bump pnpm to 11

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: SASS deprecation warnings

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Polynomial regular expression used on uncontrolled data

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Vercel deploy

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* feat: excalidraw/history package

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Polynomial regex in SVG payload decoding

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: emit the internal packages' types from the editor again

The editor advertises ./common/*, ./element/*, ./history/*, ./math/* and
./utils/* type subpaths, but without the path aliases tsc treats those
packages as external libraries and no longer emits them. Include their
sources in the editor's type build, and drop the relative cross-package
import that made element/ come out half-emitted.

* feat: export the history classes of the editor's API from the entry

onIncrement hands out StoreIncrement subclasses and applyDeltas takes
StoreDelta, so export them next to CaptureUpdateAction. Hosts then need no
dependency of their own on @excalidraw/history.

* chore: refuse to publish packages with npm or yarn

Only pnpm publish rewrites workspace:* dependencies and applies
publishConfig.exports, so a package published with another client can't be
installed.

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2026-12-01 22:17:47 +01:00
ea74995af2 feat(packages/excalidraw): Extended fonts support (#11601)
* feat: Extended fonts support

* Refactor fonts + improve picker

* Move font logic into AppFonts

* Consolidate the font metrics fallback

* chore: refresh history snapshot after rebase onto master

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* feat(editor): font provider search and hover-preview revert in the font picker

- optional `FontProvider.search` hook: matches and suggestions shared fairly
  across providers, "+N more" footer, "Did you mean" suggestions
- font preview text helpers
- revert a hover preview when the picker closes from outside (canvas click,
  compact mode); restore by cached id rather than selection

* fix(editor): font picker scene groups, search announcements and preview revert

- keep a hover preview out of the "In this scene" group while fonts register
- announce a searched family only from the search rows, not when it's listed
  already
- leave elements deleted meanwhile deleted when reverting a hover preview
- keep the focus in the picker after a selection that keeps it open while
  editing text
- skip the scene font reflow once the editor unmounted
- memoize the top picks, so hovering doesn't re-run their effects

* fix(editor): load fonts even when `document.fonts.check()` passes

Chrome's `check()` reports any family whose name matches an installed
system font as loaded, even while its web faces are unloaded (e.g. anyone
with Excalifont installed). Scene fonts then never got loaded explicitly,
so the first paint used the fallback font, and a font change measured text
with the fallback and never repaired it once the faces arrived (a wrong
bbox for good).

- scene font loading always calls `load()`, which settles right away
  (~0.1ms) when the faces are loaded already
- font family changes still redraw synchronously when `check()` passes,
  but load the faces regardless and re-measure when the load brought in
  faces that weren't loaded at measure time

Claude Opus 5.5 (xhigh)

* feat(fonts): custom fonts rework after the design review

Format and loading:

- a custom font id is `<provider>:<family>`. The provider key is `google`
  or a reverse-DNS name (`isValidFontProviderKey`,
  `GOOGLE_FONT_PROVIDER_KEY`)
- a custom font is registered under a generated CSS name
  (`xf-<slug>-<hash>`), so its id never reaches CSS
- restore keeps font families it doesn't know, instead of resetting them
- loading a font no longer rewrites elements. It invalidates caches, and
  only text measured before the font's metrics arrived gets repaired
- under collab, a scene with custom fonts no longer runs a font pass every
  second: only a family nothing of which has arrived yet schedules one
- a StrictMode remount no longer leaves the editor on a `Fonts` instance
  without its undo-safety hooks

Exports:

- `registerFontResolvers(resolvers)` registers resolvers for every image
  export of a page or worker, also exported from `@excalidraw/utils`. A
  per-call `config.fontResolvers` wins for the providers it names
- an export warns once per family it has no resolver for

Google Fonts, as a new entry `@excalidraw/excalidraw/fonts/google`:

- a catalog of the families with their vertical metrics, generated by
  `yarn gen:google-fonts` and append-only
- `createGoogleFontResolver()`: resolves a family through `css2`, retries
  transient failures, shares in-flight requests, and takes a `fetch` for
  servers
- `searchGoogleFonts`, `getGoogleFontPreviewText` and a list of default
  picks

Font picker and provider API:

- `availableFonts` and `search()` take `{ id, label }` entries besides
  plain names (`ProvidedFont`); search results are `{ kind, fonts }`
- typing a name no longer resolves it as a font id: the picker only offers
  what a provider lists or finds
- `fontPickerTip` replaces the picker's tip, i.e. to point at where a host
  manages its fonts
- `onNewFontUsed` is gone from `FontProvider`

Claude Opus 5.5 and Claude Fable 5.2 (effort 40 to 80)

* feat(fonts): Google catalog of text fonts only, with a browse list

- catalog: 1,895 families. Out are the 33 non-text families (symbols,
  emoji, knitting charts, SignWriting), Libertinus Math, which draws
  relation signs over the preceding letter, and the 28 families which
  take over 10 ms to draw a line of text in Chromium (median: 1.5 ms).
  Added since the first run: Agrave Pro, Firjar; kept: STIX Two Math and
  Noto Sans Math
- generator: the exclusion rules above, by classification and by name
  with the reason; a family new to Google's list whose font file looks
  slow to draw (huge outlines, colour layers) is held back until it's
  measured, `--allow` lets it in; output in prettier's format
- `loadMoreGoogleFonts` pages through the `GOOGLE_FONT_BROWSE_LIMIT` (100)
  most popular families, for a provider's `loadMore`; search still covers
  the whole catalog
- default picks are provisional, to be hand-picked before release

Claude Fable 5.2 (effort 30 to 80)

* feat(editor): font picker favorites, "Browse more fonts", faster list

- `fontFavorites={{ fonts, onChange }}`: the user's favorite fonts, kept
  by the host. A font is dragged onto a zone over the search to add it,
  and a favorite onto the same zone to remove it. Without the prop the
  picker has no favorites
- list order: fonts in the scene, favorites, then the available ones with
  the editor's own fonts first. A font only counts as in the scene once an
  element uses it
- `FontProvider.loadMore({ offset, limit, signal })`: a "Browse more
  fonts" row which pages through the provider's further fonts, and loads
  on by itself once clicked. What it loaded stays for when the picker
  reopens, and a font picked from it keeps its place. At the end, a
  provider with `search` gets a "Use search for more" note
- rows are memoized and skip rendering while off screen
  (`content-visibility`), so a list of a few hundred fonts stays
  responsive

Claude Fable 5.2 (effort 30 to 80)

* feat(app): resolve Google fonts on excalidraw.com, without the picker

What the app ships of the custom fonts: the package's Google Fonts
resolver alone. Nothing changes in the font picker, but a text in a Google
font - from a file, a shared link or a paste from another app such as
Excalidraw+ - renders in that font, and is listed among the scene's fonts.

- `fontProviders` with the resolver and no fonts on offer, no search
- the resolver is registered for image exports made outside of the editor
  (the frame snapshot for diagram-to-code), which otherwise draw such text
  in the fallback font

Claude Fable 5.2 (effort 30)

* fix(fonts): font repairs and retries found in review

- A font repair no longer lands during a text edit, where it took what
  had been typed out of undo's reach. It waits for the edit to be
  submitted, as it does for a drag.
- One loaded face no longer counts as the font being in for text which
  needs another `unicode-range` subset: such text is measured again once
  its subset arrives.
- A font file which failed to download is retried when the family is
  asked for again, i.e. by picking the font.
- New provider callbacks under the same key are used without rebuilding
  the `Fonts` instance.
- SVG export keeps a face whose `unicodeRange` is lowercase or uses
  wildcards.

Claude Fable 5.2, effort 80

* feat(fonts): drop 43 Google families the editor can't lay out reliably

The catalog goes from 1,895 to 1,852 families. Nothing has shipped, so
the entries are removed rather than kept.

- 12 whose text jumps when the text editor opens, as browsers don't
  agree on their vertical metrics, or whose line height is unusable.
- 29 whose lines the canvas and the text editor lay out at different
  widths in Chrome or Safari, with no setting to bring them together.
- 2 which don't draw as text fonts (Vibur, Libertinus Keyboard).

The generator names each with what was measured, and holds back a new
family whose font file shows the first kind. Provisional: the catalog
gets another pass before release.

Claude Fable 5.2, effort 80

* fix(editor): kern text the same on canvas, in the text editor and in SVG

Left on the default (`font-kerning: auto`), browsers skip the kerning
between a letter and a space in places: Chrome on canvas but not in the
DOM, Firefox everywhere. So a line was measured and drawn wider on canvas
than Chrome's text editor laid it out (6 px for "A V A T A R" in
Liberation Sans at 20 px), and wider in Firefox than in Chrome's editor.

Kerning is now `normal` wherever text is measured or drawn: the measuring
canvas, the element canvas, the text editor and exported SVG.

Claude Fable 5.2, effort 30

* fix(editor): wrap text and place the caret by the same kerning

Review follow-ups to the kerning change:

- Wrapping added up the widths of single-character tokens (and of the
  characters of a word too long for a line) one by one, which leaves out
  the kerning between them. "A V A T A R A V A T A R" in a 105 px box
  wrapped to three lines where the text editor shows two. Before a line
  breaks on such a sum, it's now measured as a whole.
- The hidden element which finds the caret for a click was still kerned
  with `auto`, so in Firefox the caret could land a character early.

Claude Fable 5.2, effort 80

* fix(editor): shape canvas text as a whole line, as the text editor does

Chrome's canvas shapes a line word by word by default. A font which picks
a letter's shape by what's around it, across spaces too (Caveat, Itim,
Sriracha), then measures and draws several px a line wider or narrower on
canvas than in the text editor, which the DOM lays out as a whole.

`textRendering = "optimizeLegibility"` has the canvas shape the whole
line. It changes nothing for a font without such rules, the built-in ones
included, and is set on the canvas only: the DOM, Firefox's canvas and
skia-canvas shape whole lines as it is.

Claude Fable 5.2, effort 80

* fix(editor): leave font-kerning on the browser's default

Kerning was set to `normal` wherever text is measured or drawn, so that
Firefox would kern a letter against a space as Chrome does. Set on the text,
it also has Firefox close up Japanese and Chinese: full-width punctuation
and kana lose their side space, by 7 to 22% on a line, in 17 Google
families and in system fonts such as Yu Gothic and Hiragino.

`font-kerning` is no longer set on the canvas, in the text editor or in
exported SVG. `textRendering = "optimizeLegibility"` stays on the canvas,
which is what brings Chrome's canvas to its text editor, the kerning next to
a space included.

The price: Firefox doesn't kern a letter against a space, so a line with
such pairs is a little wider there than in Chrome ("A V A T A R To WA" in
Liberation Sans at 20 px: 285 px against 273).

Claude Fable 5.2, effort 30

* feat(fonts): offer 9 Google families, not Google's whole list

The catalog held every family that passed the generator's checks (1,852).
It now holds the ones we offer: 9, picked by hand, each looked at on the
canvas and in the text editor at 16 to 36 px in Chrome and Firefox, on a
low and a high pixel density display. Safari 15.5 has seen all but Open
Sans and Bevan.

- handwriting: Kalam, Patrick Hand, Pacifico
- sans: Open Sans
- serif: Literata
- monospace: Fira Mono
- display: Bevan
- Japanese: Zen Maru Gothic
- Korean: Gowun Dodum

No Chinese family yet: none of Google's fits Simplified Chinese (LXGW
WenKai TC has the characters, in older forms than mainland's and with
Taiwan's punctuation), and a Traditional one alone would leave the larger
group out. Zen Maru Gothic has every kana and JIS X 0208 kanji, Gowun
Dodum every Hangul syllable, read from the font files.

All are under the SIL Open Font License with no reserved font name. All
but Zen Maru Gothic have the letters of Czech, Slovak, Polish, Hungarian,
Turkish and Romanian, also read from the font files: Google's "latin-ext"
label doesn't tell.

The generator works from that list (`OFFERED_FAMILIES`) and writes the
catalog in its order, so the order no longer follows Google's popularity
figures. A catalog can grow later; it can't shrink once a release has had
a name. `GOOGLE_FONT_DEFAULT_PICKS` is the same list.

Claude Fable 5.2, effort 30

* feat(fonts): list a family by a glyph of its own script

A Japanese or Korean family has a Latin name, and its row in the font
list looked like any other of its provider: the provider's icon, then the
name. Nothing said which script it writes.

The row now takes the family's preview text for its icon, written in the
family ("あ", "한"), where the provider's `getPreviewText` gives one. It
is the sample the top picks already show for a pinned family. A family
without one keeps the provider's icon.

`getPreviewText` is asked for every listed family, not only the pinned
ones; the answer is still kept for the session.

Claude Fable 5.2, effort 30

* feat(fonts): a provider's families get the icons our own fonts have

In the font list every family of a provider had the provider's icon. The
icon column said where a font comes from, the same on every row, and
nothing about the font. Our own fonts say what they're for there:
handwriting, text, code, headings.

A provider can now tell a family's kind: `getKind`, answering one of
`FontKind` ("hand-drawn", "normal", "code", "heading"). The row gets the
icon our own fonts of that kind have, so a host imports no icon of ours.
A row's icon is, in this order: the family's preview text (a glyph of its
script), the icon of its kind, the provider's `icon`, a normal font's.

`FontProvider.icon` is optional with that: it's what a family gets which
its provider says nothing about.

The Google catalog has a kind per family (`getGoogleFontKind`), set by
hand next to the name in the generator's `OFFERED_FAMILIES`: Google's own
categories file Bevan, a display face, as a serif. An entry is now
[name, unitsPerEm, ascender, descender, lineGap, kind, script?].

excalidraw.com's provider drops Google's icon, and passes the kind and
the preview text for the fonts it lists (the ones a scene uses).

fontPreviewText.ts is fontProviderInfo.ts now: one cache for what a
provider says about a family, the preview text and the kind.

Claude Fable 5.2, effort 30

* feat(fonts): offer "Browse more fonts" only when there are more

A provider able to page (`loadMore`) turned "Browse more fonts" on,
whether or not it had a font beyond the ones listed. One offering all of
its fonts up front, as the Google catalog's 9 are, got a button which
brought nothing and then went away.

The picker now asks for the first page as it opens, once per editor and
set of providers, and offers the button only if that brings a font it
doesn't list yet. Those fonts are what the first click lists; later pages
load as before.

Claude Fable 5.2, effort 30

* fix(fonts): findings of Astra's review

- Closing the font picker restored every selected element from the copy
  taken when it opened, as a newer version: whatever a collaborator had
  changed meanwhile was lost for everyone, and opening and closing the
  picker alone gave each element a new version. Now only a live preview
  is taken back, to the scene as it was when that preview started, and
  only what a preview changes: the font of a text and the layout that
  follows (its wrapping, size and position, on a sticky note its fitted
  font size; its container's size). A text edited during the preview
  gets its font back and is laid out anew. Whatever else is selected
  along with a text is never touched. A hover resets a container's size
  the same way, not the whole element.
- A headless export (no `document.fonts`, no `FontFace`) threw: on plain
  Helvetica text, on a font of a provider nobody configured, and on any
  custom font once a resolver was configured. A font face built its
  `FontFace` as it was created, and so did the registry for every
  built-in font. It's built when first asked for now, which such an
  export never does: nothing is installed or retried without a font set.
  Telling that a font is local, or registered, doesn't build the registry
  either (the font metadata, as on master; `hasCustomFamily`).
- Beyond what master could do: an SVG export embeds its fonts where
  there is no `window`, `document` or `FontFace` at all (i.e. Node, given
  a document to build in). A font face read `window.EXCALIDRAW_ASSET_PATH`
  unguarded, and asked its `FontFace` for the unicode range it covers
  when its descriptors named none; it covers everything then, as in CSS.
- `Fonts.loadElementsFonts(elements, ownerDocument)`, master's signature,
  threw: the second argument had become a `Fonts`. It takes either.
- The font picker called React 18's `useSyncExternalStore`, with React 17
  among the peer dependencies. `hooks/useSyncExternalStore` falls back to
  a subscription in an effect there, like `hooks/useTransition`.
- An export resolved the fonts of deleted elements, before it dropped
  them.
- An export loaded its fonts into the global document, whatever document
  it was given to draw in (`environment.document`): an editor in a popout
  window got them in its opener's, where its canvas can't use them. As on
  master, where it's an omission too. They go into the given document if
  it has a font set.
- "Browse more fonts" went missing with its group: when the scene uses
  every available font, the group is empty and wasn't rendered. A group
  with a footer is.

Left as they are, as rare: a collaborator moving or resizing a text or
its container within the seconds of someone's hover preview of it, a family picked in
a popout which another document registered, a provider added in the
middle of a gesture, a failing resolver asked three times by one export,
a slow pinned font overtaking a later pick, and the look-ahead's five
page limit.

Claude Fable 5.2, effort 30

* feat(fonts): favorites are pinned fonts

The font picker's "Favorites" are "Pinned" now, and so is everything
that names them:

- the prop: `fontFavorites` -> `pinnedFonts` (same shape, `fonts` and
  `onChange`)
- the list's section "Pinned", the drop zone's "Pin" and "Unpin"
- the locale keys `fontList.pinnedFonts`, `pinFont`, `unpinFont`

The tip at the bottom of the picker reads "Drag a font to pin". It spoke
of the top picks alone, while a drag also offers the pin zone, which only
shows up once the drag starts.

Claude Fable 5.2, effort 30

* feat(fonts): createGoogleFontProvider

A host had to put the Google provider together from the parts: the
resolver, the offered families, the search, the paging, the preview text
and, since this week, the kind. Each new part meant a change in every
host.

`createGoogleFontProvider()` in `fonts/google` returns the whole
`FontProvider`. `offerInPicker: false` leaves the fonts out of the font
picker (none listed, found by search or browsed to), while a scene's
Google fonts still render: what excalidraw.com ships, in one call now.
`resolve` takes a resolver of the host's own.

Claude Fable 5.2, effort 30

* feat(fonts): Escape closes the font picker; "Drop to pin" and a hint icon

- Escape closes the font picker, from its search too. It never did: the
  key took a hover preview back and left the popup open, as a focus
  moving out does. A live preview is still taken back, and the focus goes
  to the canvas, or back to the text being edited.
- The pin drop zone reads "Drop to pin" and "Drop to unpin".
- The hint "Drag a font to pin" has a drag-and-drop icon. A host's own
  `fontPickerTip` is shown as given.

Claude Fable 5.2, effort 30

* feat(app): keep Google's font stylesheets for offline use

Resolving a `google:` font asks Google for the family's stylesheet, which
lists its files. The service worker kept the files (the `.woff2` rule)
and not the stylesheet, so offline such a font resolved only for as long
as the browser's HTTP cache held it: a day, by Google's headers. After
that the text fell back to another font, its files in the cache or not.

A runtime caching rule for `fonts.googleapis.com/css2` keeps it for 90
days, served from the cache and refreshed in the background. Nothing is
fetched ahead: a stylesheet is stored when its family is first resolved.

Tried in a production build with the network cut for everything but
localhost: with the HTTP cache cleared, a text in Kalam is drawn in Kalam
with the rule and in the fallback font without it.

Claude Fable 5.2, effort 30

* docs: changelog for custom fonts

Claude Fable 5.2, effort 30

* fix(fonts): a font picked after its hover preview settled can be undone

Hovering a font in the picker previews it on the selected text without
capturing it. A font repair landing meanwhile (the hovered font itself
finishing to load, or any other) was committed as never-to-be-captured,
which took the previewed font into the store's snapshot along with it.
Picking that font then changed nothing against the snapshot: no undo
entry, and undo left the new font in place.

A live hover preview now counts among the changes yet to be captured, as
a drag and a text edit do, so repairs wait for it to end. The preview's
own redraw, once its font has loaded, runs as part of the preview.

Found by mtolmacs in review.

Claude Fable 5.2, effort 30

* fix(editor): load the custom fonts of a dropped scene

Dropping an `.excalidraw` file applied its scene without asking for its
fonts, and nothing else resolves a scene's custom fonts on that path, so
its text stayed in a fallback font until a reload. The "Open" action
asked already.

Found by mtolmacs in review.

Claude Fable 5.2, effort 30

* fix(build): keep the Google font catalog out of the package's fonts folder

The package build names a code-split chunk by its source folder, so the
catalog, imported from `fonts/google/`, was emitted as
`dist/prod/fonts/google/catalog-<hash>.js`: a script inside the folder of
font files which hosts copy over to serve them themselves (Excalidraw+,
and `examples/with-nextjs` here).

It's an entry point of its own now, emitted next to `fonts-google.js` as
`fonts-google-catalog.js`.

Claude Fable 5.2, effort 30

* feat(fonts): pinned fonts are favorites again

"Pin" already names what a drag onto the top picks does, so a second
kind of pinning in the same picker was easy to confuse with it. The
naming goes back:

- the prop: `pinnedFonts` -> `fontFavorites` (same shape, `fonts` and
  `onChange`)
- the list's section "Favorites", the drop zone's "Drag to favorite" and
  "Remove favorite"
- the locale keys `fontList.favoriteFonts`, `addToFavorites`,
  `removeFromFavorites`

The tip stays "Drag a font to pin".

Claude Fable 5.2, effort 10

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-12-01 12:42:28 +00:00
David LuzarandMark Tolmacs 4a12effe9a feat(editor): inside-bind elbow arrows started inside enclosing shapes (#12768)
* feat(editor): inside-bind elbow arrows started inside enclosing shapes

* fix(editor): keep orbiting elbow arrow start on its bound shape while dragging the end

When a new elbow arrow's start switched from inside to orbit binding during
an end drag, getElbowArrowData re-hit-tested the start's snapped point from
the previous frame to find its shape. A neighbouring shape whose outline was
closer to that point could win, so the start flickered between shapes in the
preview, and on drop the arrow jumped to a different route bound to the
original shape.

Use the arrow's own startBinding element as the start's shape in this case,
the same element the binding step uses on drop, so the preview and the
dropped route agree. Routing stays stateless between frames.

* fix(editor): don't inside-bind an orbiting elbow arrow end to a neighbouring shape

An orbit-bound elbow arrow end sits in its shape's binding gap, which can
also be inside a neighbouring shape that touches or overlaps the bound one.
When the end was dragged, that neighbour was recorded as enclosing it, so
dropping the end onto the neighbour inside-bound it at the drop point
instead of orbiting the neighbour and snapping to its outline.

For an orbit-bound end, only count a shape as enclosing if it also
encloses the bound shape. An end orbiting a shape nested inside a container
still inside-binds to that container when dropped within it.

* fix(editor): snap a new elbow arrow's orbiting start to its outline when dropped with Ctrl

When a new elbow arrow started inside a shape is dropped with its end
outside that shape, the start switches from inside to orbit binding. The
binding step on drop only snapped endpoints to the outline when binding was
enabled, so dropping with Ctrl held and no pointer move outside the shape
beforehand saved the start as an orbit binding whose fixed point was still
inside the shape.

Ctrl only disables binding for the dragged end, so always snap the start
to the outline when it isn't the end being dragged.

* refactor(editor): simplify elbow arrow inside-binding code

- Compute the shapes enclosing a dragged elbow arrow endpoint in one helper,
  getElbowDragEnclosingIds, used both when creating an arrow and when
  dragging an endpoint. It applies the orbit-neighbour rule and returns null
  when no shape encloses the endpoint.
- Add isPointInsideBindable for the "inside the shape and not clipped by its
  frame" check, and make isPointClippedByEnclosingFrame private again.
- In getElbowArrowData, look up each bound shape once, and only build the
  element list when a hit-test needs it.
- Check the cheap modifier and enclosure flags before the shape hit-test
  when deciding whether to bind inside.
- Drop the shouldSnapToOutline argument from bindOrUnbindBindingElementEdge.
  With binding disabled, the only end that still binds is a new arrow's
  start switching to orbit, which must snap anyway.
- Pass the binding strategy options straight through, and share the
  duplicated endOf test helper.

No behaviour change.

* fix(editor): only count shapes enclosing an elbow arrow's start shape for inside-binding

The shapes recorded at the start of an elbow arrow creation or endpoint
drag included every shape under the endpoint, also ones hidden behind the
shape the gesture started in. Starting a new arrow where a filled shape
covers part of another shape, then dragging the end into the visible part
of the shape behind, inside-bound the end there instead of orbiting its
outline.

Apply the rule already used for orbiting ends to every case: only the shape
the gesture starts in and the shapes enclosing it count. That is the
endpoint's bound shape (the new arrow's start binding at creation), or for
an unbound endpoint the shape the binding hit test picks there.

* perf(editor): skip the start shape hit test when no shape encloses an elbow arrow endpoint

getElbowDragEnclosingIds picked the gesture's start shape with a binding
hit test over the whole scene before checking whether any shape encloses
the endpoint. Look for enclosing shapes first and return early when there
are none, so a gesture starting on empty canvas scans the scene once.

---------

Co-authored-by: Mark Tolmacs <mark@lazycat.hu>
2026-11-30 17:43:44 +01:00
Márk TolmácsandDavid Luzar a0d99e7191 feat(editor): Elbow arrow inline binding on Alt (#12652)
* feat: Elbow arrow inline binding on Alt

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(editor): keep boundElements in step when arrow bindings change mid-drag

Dragging a bound arrow endpoint writes the new binding onto the arrow on
every move, but the elements it moved between were never updated. On
release, the cleanup only saw the latest target, so the original element
kept listing the arrow. For example, Alt-dragging an elbow arrow's end
from A through B and dropping it on the canvas, or inside B, left A's
boundElements stale. Plain arrows already had the same problem on master,
with or without Alt.

Bindings passed to `_updatePoints` now go through
`syncBoundElementsWithNextBindings`, which removes the arrow from the
elements it stops being bound to and adds it to the ones it becomes bound
to.

* fix(editor): keep inside anchors when changing the arrow type

Changing an inside-bound straight arrow to elbow moved its anchor to the
outline. The tip jumped outside the element while the binding still said
inside. For example, an anchor at [0.54, 0.35] became [0.5001, -0.03].
The elbow conversion ran every binding through
`calculateFixedPointForElbowArrowBinding`, which snaps to the outline,
whatever the binding's mode.

The other conversions turned inside bindings into orbit ones (elbow to
straight, straight to round). They re-bound with `appState.bindMode`,
which is only set while dragging and is almost always "orbit".

Inside bindings now keep their anchor when converting to elbow, and only
orbit bindings are re-snapped to the outline. The other conversions
re-bind with the binding's own mode.

* fix(editor): update click-to-place elbow previews when Alt changes in place

When placing an elbow arrow by clicking, pressing or releasing Alt
without moving the pointer left the preview where it was. The next click
then used the new Alt state, so the tip jumped on commit. For example,
hovering at (240, 40) inside a rectangle and pressing Alt kept the
preview on the outline at (240, -6). The click then placed the end
inside at (240, 40). Releasing Alt did the same in reverse.

The Alt key handlers re-run the preview through
`maybeHandleArrowPointlikeDrag`, but it only handled dragged endpoints.
It required `isDragging`, which is false when placing by clicking.

It now also re-runs `LinearElementEditor.handlePointerMove`, the same
call a pointer move makes, while an end point is being previewed. The
modifier keys come from the key event. `handlePointerMove` now accepts a
keyboard event, as it only reads the modifier keys.

* fix(editor): lock the arrow angle as soon as Shift is pressed

Pressing Shift while drawing an arrow, placing one by clicking or
dragging one of its points did not lock the angle until the pointer
moved. For example, with an arrow starting at (100, 100) and the pointer
resting at (300, 120), the tip stayed 20 px off horizontal after Shift
was pressed. The next pointer move at the same coordinates then snapped
it horizontal. Releasing Shift while Ctrl was held left the angle locked
in the same way.

Shift is only read when the point is recomputed, and no Shift key event
recomputed it. The Alt and Ctrl key handlers re-run the point through
`maybeHandleArrowPointlikeDrag`. Shift was only covered by accident: the
Ctrl keydown branch runs for any key pressed while Ctrl is held, and the
keyup branch runs for any key released without Ctrl.

Pressing Shift (ignoring auto-repeat) and releasing it now also call
`maybeHandleArrowPointlikeDrag`, which already handles all three cases.
Adds `KEYS.SHIFT`.

* fix(editor): hide elbow midpoint indicators while binding inside

Holding Alt to bind an elbow arrow end inside an element still drew all
four midpoint snap indicators on the element. The end stays where it is
dropped and doesn't snap to them. For example, dragging an elbow arrow's
end to (240, 40) inside a rectangle and pressing Alt highlighted no
midpoint, but all four dots stayed visible.

The inside binding clears `suggestedBinding.midPoint`, but that only
removed the highlight. Elbow arrows always draw every midpoint, and the
renderer had no way to tell an inside binding from an orbit binding with
the pointer inside the element.

`suggestedBinding` now carries an `inside` flag, which the elbow arrow
point-drag updates set from the dragged end's binding strategy. No
midpoint indicators are drawn while it is set. The element outline is
still highlighted.

* fix: Stale orbit binding storage and crash on Esc

* fix(editor): drop the arrow from the old element when an end is rebound

Rebinding an arrow end to another element left the old element still
listing the arrow in its `boundElements`. For example, dragging an elbow
arrow's end off rectangle A and dropping it on rectangle B without Alt
bound the end to B, and B listed the arrow, but so did A.

`applyBinding` wrote the new binding onto the arrow and added the arrow
to the new element, but never removed it from the previous one. Plain
arrows dragged in the editor were not affected, as their bindings are
written while dragging through `_updatePoints`, which keeps
`boundElements` in step. Elbow arrows only bind while dragging when Alt
is held, so a plain drop went through `applyBinding` alone. Calling
`bindBindingElement` or `bindBindingElementToFixedPoint` directly hit
the same gap with any arrow.

`applyBinding` now runs the new binding through
`syncBoundElementsWithNextBindings` before writing it. The element the
end leaves stops listing the arrow, unless the arrow's other end is
still bound to it.

The `move.test.tsx` snapshot changes in one `versionNonce` only. The
bound elements are now updated before the arrow rather than after, so
the random nonces are drawn in a different order.

* fix(editor): hide elbow midpoint indicators before an inside start

With the elbow arrow tool and Alt held, the midpoint snap indicators
still showed on an element while hovering inside it, and after pressing
down there, until the first drag move. The start binds inside at the
pointer and doesn't snap to them. For example, pressing down at
(240, 40) inside a rectangle bound the start inside at (240, 40), but
all four midpoint dots stayed visible.

The `inside` flag on `suggestedBinding` was only set by the point-drag
updates. The suggestions made while hovering with the arrow tool and on
pointer down, which are what show before the first drag move, always
carried a midpoint and never set the flag.

Hovering now sets `inside` and leaves out the midpoint when the elbow
arrow type is selected, Alt is held and the pointer is inside the
hovered element, which is when an elbow arrow binds inside. On pointer
down it is set from whether the start actually bound inside.

* fix(editor): don't re-run arrow point previews on Alt auto-repeat

Holding Alt while placing an arrow by clicking, or while dragging an
arrow's end, re-ran the preview on every keyboard auto-repeat. Each
repeat routed an elbow arrow again and set the state, with the same
result every time, for as long as Alt was held.

The Alt keydown handler re-runs the point being placed or dragged, so
the preview shows the new binding without the pointer moving. Unlike
the Shift and Ctrl handlers, it didn't skip repeated keydowns. Dragging
an end already re-ran on every repeat before the click-to-place preview
was added, it only didn't set the state.

The Alt keydown now skips auto-repeats, so the preview re-runs once
when Alt is pressed.

* fix(editor): re-run arrow point previews once on modifier release

Releasing Shift or Alt without Ctrl held re-ran the arrow point being
placed or dragged twice. For an elbow arrow that meant routing it twice
and setting the state twice, from the same state, for one key release.

The keyup handler re-ran the point in the Alt and Shift blocks, then
again at the end for any key released without Ctrl, which is how a Ctrl
release re-enables binding. Releasing Alt without Ctrl already ran twice
before the Shift call was added.

The point is now re-run once, at the end of the handler, when Alt or
Shift is released or any key is released without Ctrl. That's the
later of the two old calls, so it still runs after binding is
re-enabled and gives the same result.

* fix: Incorrect routing

* refactor(editor): bind elbow arrow ends on drop only

Alt-dragging an elbow arrow's end wrote an inside binding onto the arrow
on every pointer move, so the routing left the end where it was instead
of snapping it to the outline. Keeping that up took logic in
`pointDraggingUpdates` to write the binding, turn it back into an orbit
binding when Alt was released and clear it when the end left the
element. It also took `syncBoundElementsWithNextBindings` in
`_updatePoints`, so the elements the end passed over didn't keep
listing the arrow, and an extra unbind when click-to-place was
abandoned.

Elbow arrow bindings are now only written on drop, as on master. The
point drag tells the routing whether the dragged end binds inside
through `startInside` and `endInside`, passed down to
`getElbowArrowData` the same way as `isMidpointSnappingEnabled`. There
they override the binding's stored mode, so an inside end dragged
without Alt is already on the outline, where the drop puts it.

`applyBinding` now removes the arrow from the element the end was bound
to before, unless the other end is bound to it. An elbow arrow's end
stays bound to its old element until the drop, so dropping it on
another element left the old one listing the arrow.

Plain arrows still write their bindings while dragged, and without the
sync they leave the element an end is dragged off listing the arrow.
For example, dragging a plain arrow's end from rectangle A onto
rectangle B leaves the arrow in A's `boundElements`. Master behaves the
same, and this is left for a separate fix. The `move.test.tsx` snapshot
is back to master's.

The tests now check the preview while dragging and the bindings after
the drop. Three retargeting tests are dropped: they covered the steps of
the removed logic and now take the same path as other tests. A test is
added for dragging an inside bound end without Alt.

* perf(element): skip hover hit-tests for inside-bound elbow arrow ends

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: David Luzar <5153846+dwelle@users.noreply.github.com>
2026-11-28 22:41:26 +01:00
David Luzar f4e5226a3d fix(editor): memory leak when embedding fonts in an SVG export (#12755)
fix(editor): free the woff2 buffers after embedding a font

The woff2 module hands its result back as a vector living in its own
WebAssembly memory, which is freed only when asked to. It never was, so
every font subset for an SVG export ("embed fonts") leaked the
decompressed font and the compressed subset, for as long as the module
lived: the worker in a browser, the whole process on a server.

Measured over 2,000 subsets of the CJK font, with the garbage collector
forced: the process grew from 348 MB to 517 MB, and stays at 296 MB now.

Claude Fable 5.2, effort 30
2026-11-27 18:13:55 +01:00
aac07cad09 docs(repo): refresh the README with a new banner and CLI and MCP links (#12754)
* docs(repo): refresh the README with a new banner and CLI and MCP links

- New light and dark banner with a current screenshot of the editor,
  rendered from .github/assets/banner (see render.mjs). It replaces the
  old cover and the outdated product screenshot.
- README laid out like the CLI and Mermaid to Excalidraw READMEs, with
  the feature list brought up to date.
- References to the Excalidraw CLI and Excalidraw MCP, and an
  Excalidraw+ section.
- Docs links point to plus.excalidraw.com/docs/sdk, in the README,
  CONTRIBUTING.md and the package README.

* Potential fix for pull request finding 'CodeQL / Client-side URL redirect'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore: prettier format hero.html

---------

Co-authored-by: David Luzar <5153846+dwelle@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-11-27 17:28:33 +01:00
David Luzar dabd83c4aa fix(editor): keep the split-paste preference in the app state, not in localStorage (#12742)
* fix(editor): keep the split-paste preference in the app state, not in localStorage

The editor wrote the preference to the host's localStorage itself. It's
an app state key now (splitPastedTextEnabled, kept in the browser as the
other preferences are), for the host to store with the rest.

Removes the EDITOR_LS_KEYS.PASTE_TEXT_AS_LINES key and the ownerWindow
parameter of EditorLocalStorage, which nothing uses any more.

* refactor(editor): rename splitPastedTextEnabled to splitOnPaste
2026-11-25 22:59:21 +01:00
David Luzar b55c9ee92e feat(editor): remember pasting multiline text split into lines (#12737)
Once a pasted text is split from the toast, multiline text is pasted
split from then on (kept in localStorage), and the toast offers to
paste it as a single text element instead: the lines are swapped for
the element the text would have been pasted as, and the preference is
dropped.

- a paste that arrives split is centered at the pointer by its lines
- phones never paste split and set no paste toast (none is shown there)
- rows are matched to lines NFC-normalized, as wrapping composes
  characters (a wrapped line could swallow the next one on split)
- EditorLocalStorage methods take an optional ownerWindow
2026-11-25 20:00:54 +01:00
David Luzar 5681e7d8be revert(app): restore simple eplus banner (#12735)
Revert "feat(app): rotate promo banner messages per editor load (#12664)"

This reverts commit 9fbeaed54a.
2026-11-25 12:08:46 +01:00
David Luzar eaa7fa32a6 feat(editor): paste multiline text as a single element, with a toast to split it into lines (#12712)
* fix(editor): stack text pasted as separate lines without overlap, as the text is aligned

Each line was centered on a running y advanced by the previous line's
height, so a line wrapping to more rows than the one above overlapped
it. Lines now stack top to bottom, half a line height apart (blank lines
no longer add room), and take the current text align: the block is
centered at the pointer and its lines aligned in it.

* fix(editor): don't restart the toast's timer on each render

Its onClose is a new function on each LayerUI render, and the timer
depended on it: every render cleared the timer and started a full-length
one, so a toast stayed for as long as the UI kept re-rendering. The
timer now restarts only when the toast shows something else.

* feat(editor): paste multiline text as a single element, splitting it into lines from a toast

Ctrl/Cmd+V of a text with more lines pasted an element per line. It's
one text element now, and a toast offers to split it: each non-blank
line an element of its own, in place of the pasted one (wrapped and
aligned as in it, half a line height apart), as one step to undo.

The toast takes an optional action for that: a link-like button after
its message.

* fix(editor): give a toast shown again its full duration

Since the timer no longer restarts on a render, the same plain toast
shown again within its duration got only what was left of the first
one's. The toast takes a timerKey (LayerUI passes the toast object), so
that another toast restarts the timer, and a re-render still doesn't.

* fix(editor): split a pasted text into lines as it's laid out, in its place

Review fixes for splitting a pasted text from the toast:

- the lines keep their indentation and the rows they were wrapped to
  (wrapping a line anew at the text's measured width could break a long
  word elsewhere)
- a line moved out of the frame by the gaps is taken out of it
- the lines take the text's place in the layer order, and arrows bound
  to the text are let go of
- the focus is back in the editor after the toast's button is gone, so
  that the next paste isn't ignored
- a later paste retires the offer to split the text pasted before
2026-11-24 19:24:56 +01:00
David Luzar 542ad76fa6 fix(editor): keep group intact when dragging a member within the same frame (#12718) 2026-11-24 09:33:19 +01:00
zsviczian 9c2e462ec2 fix(packages/excalidraw): preserve color picker focus in secondary documents (#12700)
fix: preserve color picker focus in secondary documents
2026-11-21 19:23:03 +01:00
zsviczian 2c3dcc06ec fix(editor): prevent frame-drag lag when selecting large groups (#12692)
fix: avoid repeatedly selecting the same group during frame dragging
2026-11-19 20:01:22 +01:00
Excalidraw Botanddwelle 091bc0e9d8 chore(editor): Update translations from Crowdin (#12070)
* New translations en.json (Latvian)

[ci skip]

* New translations en.json (Azerbaijani)

[ci skip]

* New translations en.json (Hindi)

[ci skip]

* New translations en.json (Burmese)

[ci skip]

* New translations en.json (Chinese Traditional, Hong Kong)

[ci skip]

* New translations en.json (Sinhala)

[ci skip]

* New translations en.json (Uzbek)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (Occitan)

[ci skip]

* New translations en.json (German, Switzerland)

[ci skip]

* New translations en.json (Bengali, India)

[ci skip]

* New translations en.json (Kabyle)

[ci skip]

* New translations en.json (Karakalpak)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Norwegian Nynorsk)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Japanese)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Indonesian)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (French)

[ci skip]

* New translations en.json (Spanish)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Basque)

[ci skip]

* New translations en.json (Hebrew)

[ci skip]

* New translations en.json (Italian)

[ci skip]

* New translations en.json (Japanese)

[ci skip]

* New translations en.json (Korean)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Polish)

[ci skip]

* New translations en.json (Portuguese)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Slovak)

[ci skip]

* New translations en.json (Slovenian)

[ci skip]

* New translations en.json (Swedish)

[ci skip]

* New translations en.json (Turkish)

[ci skip]

* New translations en.json (Ukrainian)

[ci skip]

* New translations en.json (Chinese Simplified)

[ci skip]

* New translations en.json (Chinese Traditional)

[ci skip]

* New translations en.json (Portuguese, Brazilian)

[ci skip]

* New translations en.json (Norwegian Nynorsk)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (German, Switzerland)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (Chinese Traditional)

[ci skip]

* New translations en.json (Indonesian)

[ci skip]

* New translations en.json (Thai)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (French)

[ci skip]

* New translations en.json (Spanish)

[ci skip]

* New translations en.json (Arabic)

[ci skip]

* New translations en.json (Bulgarian)

[ci skip]

* New translations en.json (Catalan)

[ci skip]

* New translations en.json (Czech)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Greek)

[ci skip]

* New translations en.json (Basque)

[ci skip]

* New translations en.json (Finnish)

[ci skip]

* New translations en.json (Hebrew)

[ci skip]

* New translations en.json (Hungarian)

[ci skip]

* New translations en.json (Italian)

[ci skip]

* New translations en.json (Japanese)

[ci skip]

* New translations en.json (Korean)

[ci skip]

* New translations en.json (Kurdish)

[ci skip]

* New translations en.json (Lithuanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Punjabi)

[ci skip]

* New translations en.json (Polish)

[ci skip]

* New translations en.json (Portuguese)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Slovak)

[ci skip]

* New translations en.json (Slovenian)

[ci skip]

* New translations en.json (Swedish)

[ci skip]

* New translations en.json (Turkish)

[ci skip]

* New translations en.json (Ukrainian)

[ci skip]

* New translations en.json (Chinese Simplified)

[ci skip]

* New translations en.json (Chinese Traditional)

[ci skip]

* New translations en.json (Vietnamese)

[ci skip]

* New translations en.json (Galician)

[ci skip]

* New translations en.json (Portuguese, Brazilian)

[ci skip]

* New translations en.json (Persian)

[ci skip]

* New translations en.json (Khmer)

[ci skip]

* New translations en.json (Tamil)

[ci skip]

* New translations en.json (Bengali)

[ci skip]

* New translations en.json (Marathi)

[ci skip]

* New translations en.json (Norwegian Nynorsk)

[ci skip]

* New translations en.json (Kazakh)

[ci skip]

* New translations en.json (Latvian)

[ci skip]

* New translations en.json (Azerbaijani)

[ci skip]

* New translations en.json (Hindi)

[ci skip]

* New translations en.json (Burmese)

[ci skip]

* New translations en.json (Chinese Traditional, Hong Kong)

[ci skip]

* New translations en.json (Sinhala)

[ci skip]

* New translations en.json (Uzbek)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (Occitan)

[ci skip]

* New translations en.json (German, Switzerland)

[ci skip]

* New translations en.json (Bengali, India)

[ci skip]

* New translations en.json (Kabyle)

[ci skip]

* New translations en.json (Karakalpak)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Thai)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Indonesian)

[ci skip]

* New translations en.json (Thai)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (French)

[ci skip]

* New translations en.json (Spanish)

[ci skip]

* New translations en.json (Arabic)

[ci skip]

* New translations en.json (Bulgarian)

[ci skip]

* New translations en.json (Catalan)

[ci skip]

* New translations en.json (Czech)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Greek)

[ci skip]

* New translations en.json (Basque)

[ci skip]

* New translations en.json (Finnish)

[ci skip]

* New translations en.json (Hebrew)

[ci skip]

* New translations en.json (Hungarian)

[ci skip]

* New translations en.json (Italian)

[ci skip]

* New translations en.json (Japanese)

[ci skip]

* New translations en.json (Korean)

[ci skip]

* New translations en.json (Kurdish)

[ci skip]

* New translations en.json (Lithuanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Punjabi)

[ci skip]

* New translations en.json (Polish)

[ci skip]

* New translations en.json (Portuguese)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Slovak)

[ci skip]

* New translations en.json (Slovenian)

[ci skip]

* New translations en.json (Swedish)

[ci skip]

* New translations en.json (Turkish)

[ci skip]

* New translations en.json (Ukrainian)

[ci skip]

* New translations en.json (Chinese Simplified)

[ci skip]

* New translations en.json (Chinese Traditional)

[ci skip]

* New translations en.json (Vietnamese)

[ci skip]

* New translations en.json (Galician)

[ci skip]

* New translations en.json (Portuguese, Brazilian)

[ci skip]

* New translations en.json (Persian)

[ci skip]

* New translations en.json (Khmer)

[ci skip]

* New translations en.json (Tamil)

[ci skip]

* New translations en.json (Bengali)

[ci skip]

* New translations en.json (Marathi)

[ci skip]

* New translations en.json (Norwegian Nynorsk)

[ci skip]

* New translations en.json (Kazakh)

[ci skip]

* New translations en.json (Latvian)

[ci skip]

* New translations en.json (Azerbaijani)

[ci skip]

* New translations en.json (Hindi)

[ci skip]

* New translations en.json (Burmese)

[ci skip]

* New translations en.json (Chinese Traditional, Hong Kong)

[ci skip]

* New translations en.json (Sinhala)

[ci skip]

* New translations en.json (Uzbek)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (Occitan)

[ci skip]

* New translations en.json (German, Switzerland)

[ci skip]

* New translations en.json (Bengali, India)

[ci skip]

* New translations en.json (Kabyle)

[ci skip]

* New translations en.json (Karakalpak)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* Auto commit: Calculate translation coverage

* chore: list languages crossing the coverage threshold vs production in the l10n PR description

* docs: Crowdin upload notes in AGENTS.md

* docs: Crowdin translation workflow in AGENTS.md

* New translations from Crowdin: fill ar/fa/ko gaps, fix Excalidraw+ in RTL (ar/fa/he), ar diamond term

* Auto commit: Calculate translation coverage

* New translations from Crowdin: fill the editor gaps for the E+ languages (cs, de, es, fr, hi, hu, it, ja, pl, pt-BR, ru, uk, zh-CN)

* Auto commit: Calculate translation coverage

* New translations from Crowdin (Czech): objekt for elements, Poznámka, Mód pro čtení, Zobrazit mřížku, Zamknout nástroj

* New translations en.json (Indonesian)

[ci skip]

* New translations en.json (Thai)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (French)

[ci skip]

* New translations en.json (Spanish)

[ci skip]

* New translations en.json (Arabic)

[ci skip]

* New translations en.json (Bulgarian)

[ci skip]

* New translations en.json (Catalan)

[ci skip]

* New translations en.json (Czech)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations en.json (German)

[ci skip]

* New translations en.json (Greek)

[ci skip]

* New translations en.json (Basque)

[ci skip]

* New translations en.json (Finnish)

[ci skip]

* New translations en.json (Hebrew)

[ci skip]

* New translations en.json (Hungarian)

[ci skip]

* New translations en.json (Italian)

[ci skip]

* New translations en.json (Japanese)

[ci skip]

* New translations en.json (Korean)

[ci skip]

* New translations en.json (Kurdish)

[ci skip]

* New translations en.json (Lithuanian)

[ci skip]

* New translations en.json (Dutch)

[ci skip]

* New translations en.json (Punjabi)

[ci skip]

* New translations en.json (Polish)

[ci skip]

* New translations en.json (Portuguese)

[ci skip]

* New translations en.json (Russian)

[ci skip]

* New translations en.json (Slovak)

[ci skip]

* New translations en.json (Slovenian)

[ci skip]

* New translations en.json (Swedish)

[ci skip]

* New translations en.json (Turkish)

[ci skip]

* New translations en.json (Ukrainian)

[ci skip]

* New translations en.json (Chinese Simplified)

[ci skip]

* New translations en.json (Chinese Traditional)

[ci skip]

* New translations en.json (Vietnamese)

[ci skip]

* New translations en.json (Galician)

[ci skip]

* New translations en.json (Portuguese, Brazilian)

[ci skip]

* New translations en.json (Persian)

[ci skip]

* New translations en.json (Khmer)

[ci skip]

* New translations en.json (Tamil)

[ci skip]

* New translations en.json (Bengali)

[ci skip]

* New translations en.json (Marathi)

[ci skip]

* New translations en.json (Norwegian Nynorsk)

[ci skip]

* New translations en.json (Kazakh)

[ci skip]

* New translations en.json (Latvian)

[ci skip]

* New translations en.json (Azerbaijani)

[ci skip]

* New translations en.json (Hindi)

[ci skip]

* New translations en.json (Burmese)

[ci skip]

* New translations en.json (Chinese Traditional, Hong Kong)

[ci skip]

* New translations en.json (Sinhala)

[ci skip]

* New translations en.json (Uzbek)

[ci skip]

* New translations en.json (Norwegian Bokmal)

[ci skip]

* New translations en.json (Occitan)

[ci skip]

* New translations en.json (German, Switzerland)

[ci skip]

* New translations en.json (Bengali, India)

[ci skip]

* New translations en.json (Kabyle)

[ci skip]

* New translations en.json (Karakalpak)

[ci skip]

* New translations en.json (Romanian)

[ci skip]

* New translations en.json (Uzbek)

[ci skip]

* New translations en.json (Danish)

[ci skip]

* New translations from Crowdin: fit the promo banner variants to the EN width in all languages; shorter Share for mr/ku, add kk/my

* Auto commit: Calculate translation coverage

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2026-11-19 14:25:26 +00:00
9fbd8468f2 fix(editor): tear down an open text editor when the app unmounts (#12688)
Unmounting with a text editor open left its listeners on the window,
holding on to the app and its scene until one of them next fired.

The editor is now torn down with the app. Nothing is written: what was
typed is in the last change the app reported.

Co-authored-by: Márk Tolmács <14922478+mtolmacs@users.noreply.github.com>
Co-authored-by: sahargavriely <63425950+sahargavriely@users.noreply.github.com>
2026-11-19 14:10:19 +01:00
David Luzar 894589f399 feat(editor): keep editing text when the window loses focus (#12675)
Co-authored-by: Márk Tolmács <14922478+mtolmacs@users.noreply.github.com>
Co-authored-by: sahargavriely <63425950+sahargavriely@users.noreply.github.com>

* feat(editor): keep editing text when the window loses focus

The text editor submitted on any blur, the window's included: switching
to another tab or app and back ended the edit.

- submit only when the focus moves elsewhere in the document
- until the user types, and while the window is away, the editor shows
  the scene's text, so a change made in another tab or by a collaborator
  is there to go on from
- the editor closes when its element is deleted or removed from outside
- collab: a text being edited takes newer remote copies. Its editor holds
  the draft and writes it on top, so the clients end up on the same text
- excalidraw-app: the tab sync no longer ends a text edit

* fix(editor): keep the text editor open when the update that removed its element brings it back

The editor closes when its element is gone from the scene, deferred to
after the update. A reset followed by a load of the same scene removes
and restores the element in one go, and the deferred close then wrote the
draft over the restored text.
2026-11-19 13:08:26 +01:00
David Luzar d732d4f3d5 fix(editor): text auto-resize follow-ups (#12672)
* Revert "feat(editor): show the side of an edited text that can be dragged to wrap it"

This reverts commit baf95e5ce (part of #12634): drawing the hovered
side of an auto-resizing text while it's edited adds too much visual
noise. The resize cursor on the side handle stays.

* fix(editor): keep editing a text unwrapped from its auto-resize toggle

Clicking the auto-resize toggle on the box of the text being edited
landed on the canvas, which the editor took for a press outside it and
submitted. The editor now handles the press, keeping the text edited.

* fix(editor): keep a rotated text's anchor in place when toggling auto-resize

The point a text's alignment pins was kept in the text's unrotated frame,
but a rotated text turns about the center of its box, which (un)wrapping
moves: on the canvas, the text shifted. Keep the anchor where it's drawn.
2026-11-18 15:04:16 +01:00
David Luzar 9fbeaed54a feat(app): rotate promo banner messages per editor load (#12664)
Pick one of several promos (presentations, MCP, comments, teams, voice chat, CLI) at random on load, each with its own icon and utm_content. The CLI promo links to its GitHub repo in a blue variant.
2026-11-17 22:59:00 +01:00
David Luzar 680f58ccfd feat(app): return 404 for unknown paths (#12654)
* feat(app): return 404 for unknown paths

- vercel: drop the framework preset's catch-all to index.html, keep a rewrite for /excalidraw-plus-export
- add a static 404 page (excluded from the SW precache and the sitemap)
- service worker: serve the cached app shell only for / and APP_ROUTES
- APP_ROUTES list + test that it matches the vercel.json rewrites
- remove the dead web share target (nothing handled POST /web-share-target)
- robots.txt: simplify to what it already meant (allow all)

* fix(app): let the 404 page scroll and shrink on short screens

* feat(app): add Excalidraw+, docs and CLI links to the 404 page

* feat(app): add MCP link to the 404 page

* feat(app): track 404 page views on excalidraw.com
2026-11-17 18:08:12 +01:00
David Luzar c0a0ca348f feat(editor): pick the flowchart Alt+arrow target by a single distance score (#12646)
* fix(editor): Enter/Esc only close the shape switch popup

Esc no longer also deselects, and Enter no longer enters text/line editing.

* feat(editor): pick the flowchart Alt+arrow target by a single distance score

Replace the in-line/linked/cone/past-edge tiers with one score per node
(forward + (k * sideways)² / forward), so the nearest node that looks next in
the pressed direction wins; links only break near-ties.
2026-11-16 16:23:22 +01:00
David Luzar 82190fb28f feat(editor): w wrap tweaks: frame what's inside the selection, keep unbound containers (#12638)
* fix(editor): keep restored z-indices on undo/redo unless taken

Undo/redo generated a new fractional index for every element it moved in
the z-order, even when the restored index was still valid. Later history
entries refer to the original indices, so undoing several z-order changes
in a row could restore a different stacking order.

* fix(editor): frame deselected elements within the selection on `w`

Wrapping the selection in a frame now also takes in deselected elements
that are inside the selection's bounds, or overlap them while reaching out
by no more than the frame's padding (the frame grows to fit them; a frame
around an image keeps the image's size). Groups go in whole.

The frame takes the place of its lowest child in the z-order instead of
going on top, so that it stays below the elements overlapping it.

* feat(editor): `w` keeps the containers it unbinds texts from

Unwrapping a labeled container with `w` now unbinds its text and keeps
both selected, as the "unbind text" action does. Only a container that
`w` itself wrapped a text in is removed, while the selection stands.

The next `w` puts the unbound texts back into their containers as they
sat in them.
2026-11-15 17:23:19 +01:00
David Luzar 9e9621b873 feat(editor): text auto-resize: resize from the editor, Alt+W toggle, wider wrap when zoomed out (#12634)
* fix(editor): keep the text auto-resize toggle on the box while typing

The toggle was positioned from `appState.editingTextElement`, the element
as it was when editing started, so it stayed put as lines were added or
removed. Resolve the current element instead, for the hit test too.

* feat(editor): resize a text from its sides while editing it

Dragging the left or right side of the free text being edited sets the
width it wraps at, without leaving the editor (a mere click there still
submits). The edited text isn't reliably the selection, so the drag is
handled by the editor rather than the selection's transform handles —
with grid and object snapping, as when resizing on the canvas.

* feat(editor): let a typed or pasted text grow wider when zoomed out

Below 100% zoom, the width a text wraps at is TEXT_MAX_WRAP_WIDTH on
screen rather than in scene units, up to TEXT_MAX_WRAP_WIDTH_ZOOMED_OUT.

* feat(editor): toggle text auto-resizing with Alt+W

On the selected free texts (on if any of them wraps, else off) and on the
text being edited. Turning it off keeps the text's width, wrapping at it —
at the width a typed text stops growing at, if wider.

Zen mode (Alt+Z) now goes by the key's letter too where the layout gives
one, as on AZERTY both would otherwise claim the key labelled W.

* feat(editor): hint at Alt+W for a wrapped text and while editing a text

The hint for editing now also takes precedence over the one for a selected
text: a text just created is selected while it's edited.

* feat(editor): show the side of an edited text that can be dragged to wrap it

A text that doesn't wrap yet has no box showing its sides while it's
edited: the side under the pointer is now drawn (dashed, as the box of a
wrapped text), along with the resize cursor.

* fix(editor): no stale cursor or hidden transform handles around a text being edited

- the canvas kept the cursor of what was hovered before editing (the
  selected text's move cursor, a resize handle's), which flashed once the
  pointer left the editor: it's reset as editing starts
- a text just created is selected while it's edited, so its transform
  handles, which aren't drawn then, still resized it (ending the edit)

* fix(editor): no gap or cursor flash between a text's editor and its side handles

- the side handles of the text being edited get a hit test of their own:
  the selection's left the pixel at the text's right edge to neither the
  editor nor the handle
- the canvas is given, from over the editor, the cursor of what the pointer
  would leave the editor onto: the browser shows the canvas' cursor as it is
  when the pointer gets there, and what the canvas then sets a frame later

* fix(editor): give a text made to keep its width a pixel to spare

A text exactly as wide as its longest line is on the verge of wrapping:
Chrome lays the editor's text out in 1/64px steps, rounding each run of it
up (a line being split into more runs as it's edited), so the line could
wrap in the editor alone.
2026-11-15 13:10:59 +01:00
David Luzar 3a317b55f5 fix(editor): stop centered text lines jittering while typing (#12623)
* fix(editor): stop centered text lines jittering while typing

The text editor was placed by `left`/`top` and zoomed by a scale
transform. Browsers round a scaled element's layout offset to whole
pixels, so as a center- or right-aligned text grows (moving the editor
by fractions of a pixel) its other lines shifted by up to 1px per
keystroke at any zoom other than 100%. Place the editor by the
transform's translate instead, which is kept exact.

* fix(editor): stop the other lines' glyphs shimmering while typing

- Anchor the editor's transform at the text's alignment point (origin
  0 0), so it doesn't move while typing; only the box's own anchor
  (a whole or half px) changes.
- Give non-wrapping editors a whole-px width, so the browser's rounding
  of each line's centering offset stays constant. Wrapping editors keep
  their exact width, where the canvas wraps the text too.
- Grow the editor's box to its text when a font's glyphs overflow it,
  so the browser doesn't scroll the text to reveal the caret on each
  keystroke (which shifted the other lines).

* test(editor): update the text editor style snapshot for its new placement
2026-11-14 13:47:03 +01:00
David Luzar 01dc5ec62e feat(editor): anchor keyboard zoom on the caret while editing text (#12622) 2026-11-14 11:07:30 +01:00
David Luzar 82d5847e57 feat(editor): ui.disabled.minimap; zoom buttons without the minimap toggle (#12606)
* feat(editor): ui.disabled.minimap; zoom buttons without the minimap toggle

- `ui={{ disabled: { minimap: true } }}`: a new opt-out form of the `ui`
  prop, the full default UI minus the controls listed. Removes the minimap
  and every way to toggle it (footer button, Preferences item, command
  palette and context menu entries), through the minimap action's predicate
- without the minimap toggle (removed by `ui.disabled.minimap`, or the
  reduced UI of `ui.enabled`), the zoom controls are the zoom out / zoom
  level / zoom in buttons again instead of the zoom menu: their
  PanelComponents, styles and zen-mode rules are restored from before #12605
- `isUIControlEnabled` handles both forms and is on AppClassProperties; the
  props comparator compares either form generically

Claude Opus 5.5 (xhigh)

* docs(editor): changelog for the minimap, zoom menu and ui.disabled

Claude Opus 5.5 (xhigh)

* fix(editor): hide the zen-mode zoom buttons from keyboard focus

The −/+ buttons' own `visibility: visible` (.ToolIcon_type_button--show)
overrode their wrappers' `visibility: hidden` in zen mode, so Tab still
focused the invisible buttons. Hide the buttons too, at the end of the
wrappers' fade.

Claude Opus 5.5 (xhigh)
2026-11-12 18:58:27 +01:00
Dan DekkerandMark Tolmacs 609f0f2fff perf(editor): avoid redundant canvas transforms for cached elements (#12489)
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: Mark Tolmacs <mark@lazycat.hu>
2026-11-12 17:46:09 +01:00
David Luzar 1440f2d2f8 feat(editor): minimap + zoom menu (#12605)
* feat(editor): add a toggleable minimap

- bottom-left above the canvas actions; toggled via the footer button,
  Alt+M, the context menu, command palette and Preferences
  (`appState.minimapEnabled`, browser-persisted)
- elements drawn as single-color blocks (polylines for lines/arrows/
  freedraw, outlines for frames), rendered in a web worker on an
  OffscreenCanvas with a main-thread fallback; the controller, renderer and
  worker are lazy-loaded chunks
- drag the viewport (or press outside of it to center it), limited to one
  viewport size past the content, with edge auto-pan; wheel zooms around
  the viewport center
- locked viewports keep the minimap scale frozen while rubberbanding and
  snapping back; `viewport.beginGesture()` holds the overscroll during the
  drag
- the viewport rect turns opaque when small; the styles panel stays clear
  of the minimap (and the tablet pen-mode button); unavailable in editors
  shorter than 500px
- theme class is now applied before state-change listeners run
- `Scene.onUpdate` unsubscribe no longer throws after the scene is destroyed

Claude Fable 5.2 + Claude Opus 5.5 (xhigh)

* feat(editor): zoom menu in place of the zoom buttons

- the zoom island holds the zoom level and the minimap toggle (sharp where
  they meet); the -/+ buttons are gone
- clicking the zoom level opens a menu: zoom in/out, reset zoom, and the
  three zoom-to-fit actions, each with its shortcut
- zoom level's pressed/focus rings are inset, so the toggle can't cover them
- smaller gap between the styles panel and the minimap
- zoom in/out/reset actions no longer render their own buttons

Claude Fable 5.2 + Claude Opus 5.5 (xhigh)

* feat(editor): zoom menu fit items, no minimap shortcut, announcement dot

- zoom menu: zoom in/out, then "Zoom to fit" (Shift+1), "Zoom to
  selection" (Shift+2) and "Reset zoom" (Shift+0, which it already
  accepted); "Zoom to fit selection" (Shift+3) is no longer listed
- minimap: drop the Alt+M shortcut (action, help dialog, tooltip, menus)
- TEMPORARY pulsing dot on the minimap toggle announcing the minimap,
  until 2026-11-19, for editors that loaded with content; dismissed for
  good once the minimap is opened
- "Show hints" preference renamed "Toolbar hints"

Claude Opus 5.5 (xhigh)

* chore(repo): remove the minimap scroll-lock demo button

The dev-only "Scroll lock demo" button and the commented-out initialState
in excalidraw-app were for testing the minimap against a locked viewport
and aren't meant to ship.

Claude Opus 5.5 (xhigh)
2026-11-12 17:01:41 +01:00
David Luzar 701b901a0f docs(repo): redirect the bare docs.excalidraw.com root too (#12559)
Vercel compiles redirect sources with strict path-to-regexp, so "/:path*"
matches "/foo" but not "/". The root kept serving the old Docusaurus page.
"/(.*)" matches the root as well.

Opus 5.5 (xhigh)
2026-11-05 18:10:20 +01:00
Milos Vetesnik 0c9b449be6 docs(repo): redirect docs.excalidraw.com to plus.excalidraw.com/docs/sdk (#12537)
* docs(repo): redirect docs.excalidraw.com to plus.excalidraw.com/docs/sdk

The developer docs moved to the Excalidraw+ docs. Every old page redirects to its new location, and anything else redirects to the docs home.

* docs(repo): redirect the mermaid-to-excalidraw docs to their own section

The package's docs moved to plus.excalidraw.com/docs/mermaid-to-excalidraw, rewritten for v3.
2026-11-05 17:22:51 +01:00
David Luzar 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)
2026-11-04 20:53:43 +01:00
David Luzar 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)
2026-11-03 09:20:50 +01:00
David Luzar 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)
2026-10-31 17:48:47 +01:00
David Luzar 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)
2026-10-31 11:51:48 +00:00
David Luzar a758e93d6a fix(editor): restore centered flowchart node creation (#12500) 2026-10-30 20:19:53 +01:00
David Luzar 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)
2026-10-30 12:10:15 +01:00
David Luzar 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)
2026-10-28 16:29:35 +01:00
David Luzar 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)
2026-10-27 17:35:28 +01:00
David LuzarandMark Tolmacs 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>
2026-10-27 16:49:38 +01:00
David LuzarandMark Tolmacs 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. 25902dc3b stopped writing it, but scenes saved before that
still carry it, and `restoreElementWithProperties()` keeps unknown keys
(it spreads `...element` and only deletes `strokeSharpness` and
`boundElementIds`), so the junk prop survived every load and kept
travelling through saved files, collab payloads and history deltas.

Reproduction steps:
- Call `restoreElements()` on an arrow carrying
  `moveMidPointsWithElement: false` and a line carrying
  `moveMidPointsWithElement: true` (new test in restore.test.ts).

Failure case:
- Observed: the restored arrow still has
  `moveMidPointsWithElement: false` ("expected { id: 'id1', type:
  'arrow', ... } to not have property "moveMidPointsWithElement"",
  received `false`).
- Expected: the prop is not an element property and is dropped.

Fix:
- Delete `moveMidPointsWithElement` alongside the other stripped legacy
  props in `restoreElementWithProperties()`, and type it as a deprecated
  input prop there.

History: the leak was introduced by c141960ad ("feat: Non-elbow arrow
snapping and behavior changes (#9670)"), merged to master on
2025-11-25, and it is still present on master. It is not in any npm
release tag (v0.18.0, v0.18.1), but it shipped via master builds
(excalidraw.com and `@next` prereleases) for ~11 months, so real
scenes carry the prop.

Review finding 5.

* refactor(element): pass moveMidPointsWithElement as a movePoints option

Review finding 6.

Reproduction / evidence: `LinearElementEditor.movePoints()` took
`moveMidPointsWithElement` in its `otherUpdates` argument (typed next to
`startBinding`/`endBinding`), which is the bag of element updates forwarded
to `_updatePoints()` and from there into `scene.mutateElement()`. Callers:

- `updateBoundElements()` (binding.ts) passed
  `{ moveMidPointsWithElement: <same element at both ends> }` as
  `otherUpdates` - the only caller setting a real value.
- `LinearElementEditor` point dragging (two call sites) forwarded
  `updates?.moveMidPointsWithElement` from `PointMoveOtherUpdates`, but
  `pointDraggingUpdates()` never sets that field, so it was always
  undefined there.

Before 25902dc3b this put `moveMidPointsWithElement: false/true` on every
arrow updated through its bindings (and bumped its version). 25902dc3b
fixed it by copying only `startBinding`/`endBinding` out of `otherUpdates`
in the non-elbow branch of `_updatePoints()`.

Failure case: `otherUpdates` still mixed a behaviour flag with element
properties, so the filter in `_updatePoints()` had to know about every
non-property key. Any new option added to `otherUpdates` the same way
would be silently persisted on linear elements (and saved to scenes)
unless the filter was updated too.

Fix: move `moveMidPointsWithElement` into `movePoints()`'s existing
`options` parameter, next to `isBindingEnabled` /
`isMidpointSnappingEnabled`, and drop it from `otherUpdates` and from
`PointMoveOtherUpdates` (along with the dead forwarding at the two drag
call sites). `otherUpdates` now only holds element properties, so the
non-elbow branch of `_updatePoints()` spreads it directly again, as on
master; `mutateElement()` skips undefined values, so explicitly undefined
bindings remain no-ops. The elbow branch's binding filtering is untouched.
Behaviour is unchanged (no snapshot changes). Added a test that the option
still keeps midpoints moving with the element and isn't stored on it.

* refactor(element): place skeleton bound arrows once each, per arrow

Review finding 8.

The placement pass in `convertToExcalidrawElements` simulated moving every
bindable element (`updateBoundElements` per bindable) and repurposed
`simultaneouslyUpdated` as an "already placed" ledger (a fresh copy per
call to dodge the id-set cache), then re-collected the arrows each call
touched for the label loop. Its correctness hinged on `updateBoundElements`
internals: updating both ends from either one, the `doesNeedUpdate` stale
`boundElements` filter, and the array-identity id cache. It already broke
once (fdc8262d5).

Reproduction / evidence: a scratch vitest dumped the output (minus seeds,
nonces and timestamps, versions kept) of `convertToExcalidrawElements` for
arrows bound across two shapes, to the same shape at both ends (2- and
4-point), elbow arrows (one and two ends bound), arrows in frames, six
arrows on one labelled hub, text ends with ids referenced before the
elements, and multi-point arrows, and spied on `movePoints`. Every bound
arrow was placed exactly once.

Failure case: none found. Skeleton bindings all go through `applyBinding`,
which always lists the arrow on the bindable, so the ledger never skipped
or double-placed an arrow. This is a maintainability fix.

Fix: extract the per-arrow body of `updateBoundElements`' visitor into an
exported `updateBoundArrow` (`updateBoundPoint` for each binding, then
`movePoints` with `moveMidPointsWithElement` for arrows bound to one
element at both ends, then `handleBindTextResize`), and call it from
`updateBoundElements`. Dropped the visitor's per-binding `changedElement`
check: after `doesNeedUpdate`, one end is always bound to `changedElement`,
so it always held. The transform pass now iterates the arrows bound to
elements present and places each once, re-deriving its label's
`labelPosition` and x/y in the same loop. No ledger, no copies of it, no
per-bindable calls. Outputs of the scratch dump, versions included, are
byte-identical before and after; all existing tests and snapshots pass
unchanged.

* fix(element): don't nudge skeleton arrow ends by 0.5px

bindLinearElementToElement() moved every skeleton arrow's start 0.5px
towards its end and its end 0.5px towards its start, "so bindings don't
overlap with start/end bound element coordinates" (#7195). The placement
pass now re-places every bound end with updateBoundArrow(), which puts
it off the bound element by the binding gap, so for bound ends the
nudge was dead work (a clone, nudge and normalize that's overwritten).
It only still had an effect on ends nothing re-places: the unbound end
of half-bound arrows, and both ends of unbound arrows (including those
whose start/end reference missing ids, which bind nothing).

Reproduction (convertToExcalidrawElements, regenerateIds: false):
- fully bound: rect A (0,0,100x100), rect B (400,0,100x100), arrow at
  (100,50) points [0,0]->[300,0], start A, end B
- half bound: rect A, arrow at (100,50) points [0,0]->[300,100], start A
- half bound: rect B, arrow at (100,50) points [0,0]->[300,0], end B
- start: { id: "nope" } (missing), and an arrow with no start/end, both
  at (100,50) points [0,0]->[300,0]

Failure case (observed -> expected):
- fully bound: x 106, points [0,0]->[288,0], version 5 both with and
  without the nudge (it's fully overwritten)
- half bound (start): unbound end at (399.5, 149.5) -> (400, 150)
- half bound (end): unbound start at x 100.5 -> 100
- missing ref / unbound: x 100.5, points [0,0]->[299,0] while width
  stays 300 (stale, getNormalizeElementPointsAndCoords() doesn't update
  it) -> x 100, points [0,0]->[300,0], width 300

Fix: remove the nudge (and the single point early return that only
guarded it), so ends are either placed by their bindings or kept where
the skeleton puts them. Bound ends can't be left unplaced: the bound
elements are always added to the element store, and updateBoundPoint()
only skips degenerate arrows the nudge didn't change either.

Snapshot changes: the unbound arrows in "should transform linear
elements" and "should transform to labelled arrows when label provided
for arrows" now keep x as given (100/450 instead of 100.5/450.5) and
points spanning their width ([0,0]->[100,0] instead of [99,0]). Their
labels don't move (the arrow midpoints are unchanged). The "should bind
arrows to existing elements if ids are correct" assertion, whose ids
are missing and so bind nothing, now expects x 255 as given (was 255.5).

Adds a regression test that a half-bound arrow's unbound end and an
unbound arrow stay where the skeleton puts them.

Review finding 9.

* perf(element): measure skeleton arrow labels once, as placed

Review finding 11.

`bindTextToContainer` ran `redrawTextBoundingBox` on every label, so an
arrow's label was wrapped and measured against the arrow as given, then the
placement pass (`updateBoundArrow` -> `handleBindTextResize`) wrapped and
measured it again against the arrow shortened by its binding gaps, always
throwing the first result away.

Reproduction: a scratch vitest mocked `wrapText` / `measureText` with
counters and converted two shapes and a 400px arrow bound to both with the
label "aaaa bbbb cccc dddd eeee fff".

Failure case: observed wrapText x2 (maxWidth 280, then 271.6) and
measureText x3 (newTextElement's unwrapped measurement, the discarded
redraw, the placed rewrap); expected wrapText x1, measureText x2. Six
labelled arrows on one shape: wrapText 13, measureText 20 (now 7 / 14).
Unbound labelled arrows were already measured once (wrap 1 / measure 2).

Fix: `bindTextToContainer` no longer measures arrow labels; the transform
records them, the placement pass drops each label `updateBoundArrow` just
measured, and the labels left (of arrows not placed) are measured after it
with `redrawTextBoundingBox`, as before. Nothing between creating a label
and the pass reads its size: binding only sets `startBinding` /
`endBinding` (no points), `labelPoints` is still taken on the input arrow,
and for arrow containers `handleBindTextResize` ignores the old label
height. Measuring the leftovers after the pass, rather than predicting at
creation which arrows get placed, means no label can go unmeasured.

A scratch dump of 18 scenarios (bound / one end / same shape both ends /
elbow / created and text ends / missing end id / ids before data / frame /
single point / autoResize: false / labelPosition in and out of range /
unbound / hub of six / shape labels) is identical before and after (seeds,
nonces and timestamps stripped, versions kept), except the label `version`
of placed arrows, one lower for the dropped mutation; the 4 snapshot
changes are exactly that. Added a test asserting the wrap / measure counts
for a bound and an unbound labelled arrow (fails before: 3 wraps vs 2).

* fix(editor): re-measure bound labels with the host's render environment

Review finding 12.

The finding: the `renderEnvironment` option this branch added to
`updateBoundElements` (a9b2d2878) was passed only by the transform, and
since e0f198c15 not even by that (it calls `updateBoundArrow` directly),
so the option was dead while documenting that it "measures the labels of
the updated arrows". Meanwhile every editor path re-measured bound labels
with the default environment, ignoring the host's
`<Excalidraw renderEnvironment>` (its custom `textMetrics`), so a label
laid out with the host's metrics re-wrapped the first time its arrow was
touched.

The re-wrap itself predates this branch: master's `updateBoundElements`
never took an environment and called `handleBindTextResize(element,
scene, false)`, as `LinearElementEditor`'s point drag still did. Rather
than drop the dead option, this wires it (and the other label-measuring
editor paths) to the host's environment.

Reproduction: convert two rectangles A, B and an arrow bound to both,
labelled "aaaa bbbb cccc dddd eeee ffff", with
`convertToExcalidrawElements(..., { renderEnvironment })`, whose
`textMetrics.getLineWidth` is `text.length * 5`. Move B by 1px and call
`updateBoundElements(B, scene)` as the drag path does. In the editor:
render `<Excalidraw renderEnvironment={env}>` with the same scene and drag
or arrow-key nudge B, align A and B, undo/redo the drag, or drag the
arrow's point.

Failure case (this branch and master alike):
  observed: "aaaa bbbb cccc dddd eeee ffff", width 145, becomes
            "aaaa bbbb cccc dddd\neeee ffff", width 190
  expected: unchanged, "aaaa bbbb cccc dddd eeee ffff", width 145

Cause: no editor caller passed `updateBoundElements` an environment, so
it called `updateBoundArrow` without one; `ElementsDelta`'s redraw,
`LinearElementEditor`'s point drag and `listMarker`'s re-numbering
likewise measured without one.

Fix: optional `renderEnvironment` threaded the way resize already does it
(a trailing param, or an option where the function takes an options bag):
- `updateBoundElements`: its existing option is now passed by the editor
  (doc comment updated); `updateBindings` gains the same option and
  forwards it. Both pass it to `updateBoundArrow`.
- drag: `dragSelectedElements` (new trailing param), from the selection tool.
- arrow-key nudge (App.tsx).
- align / distribute: `alignElements` / `distributeElements` (new trailing
  param), from their actions.
- rotate/resize: the `updateBoundElements` calls in `transformElements`,
  `rotateMultipleElements`, `resizeSingleElement`, `resizeMultipleElements`
  now pass the environment they already had.
- sticky notes: `updateStickyNoteLayout` passes its `renderEnvironment` on
  to its bound-arrow pass.
- undo/redo: `ApplyToOptions.renderEnvironment` reaches
  `ElementsDelta.redrawElements` (both the bound-text redraw and the
  bound-arrow pass); `History.undo/redo` and `HistoryDelta.applyTo` take
  it, the history actions pass `app.renderEnvironment`, and
  `App.applyDeltas` defaults to it.
- `LinearElementEditor` point drag: `handleBindTextResize` gets
  `app.renderEnvironment`.
- list-marker re-numbering on duplicate (`advanceDuplicatedListMarkers`,
  `applyListMarkerAdvances`, new trailing param): both its label redraw and
  its free-text refresh.
- the remaining editor callers of `updateBoundElements` / `updateBindings`,
  each of which can move a labelled arrow bound to the element: text
  editing (App.text, textWysiwyg), duplicate, crop/uncrop, wrap/unwrap
  (also its `redrawTextBoundingBox`), font/style/auto-resize actions,
  element type conversion, and the Stats position/angle/dimension inputs
  (`moveElement` gets a trailing param).

Left alone:
- `updateBindings`' arrow branch (`updateArrowBindings`): it only rebinds
  the arrow's ends and measures no label.
- `transform.ts`: already measured with its environment (via
  `updateBoundArrow`).
- callers that already passed `app.renderEnvironment` to
  `redrawTextBoundingBox` / `handleBindTextResize` (resize, Stats font
  size, font/bound-text actions, textWysiwyg submit, type conversion).
- `updateBoundElements` re-measures only arrow labels (its visitor skips
  non-arrows), so no non-arrow container label path needed changing there.
- free-text measurement helpers called directly (`measureText`, `wrapText`,
  `refreshTextDimensions`, ...) outside these bound-label paths: not part
  of this finding.

Without the prop, `app.renderEnvironment` is the owner-window environment
with no `textMetrics`, so measurement still falls back to the global
provider or a canvas; single-window behaviour is unchanged (no snapshot
changes). All new params are optional, so external callers are unaffected.

Tests: a direct `updateBoundElements` test (packages/element) and editor
tests rendering `<Excalidraw renderEnvironment>` for drag, nudge, align,
undo/redo and arrow point drag; each fails without its path's change.

* refactor(element): build one scene in skeleton conversion, resync it

convertToExcalidrawElements built a temp `scene` from the element store
before labels and the elements skeleton arrows bind to were created, and
then a second `boundScene` from the completed store for the bound-arrow
placement pass, so the function held two scenes over overlapping element
objects (Review finding 13).

Evidence that the divergence produces no wrong output: the early scene
is only used to measure non-arrow container labels (the container and
label are passed directly; the sticky fit gets its label explicitly) and
by bindBindingElement (geometry from the arrow and the element passed
in; the map is only consulted for a text's container, and containers are
always in the snapshot). This was already so on master, where the same
snapshot scene was used the same way. To check, the scene was
temporarily resynced (replaceAllElements) after every store addition,
including before each bindBindingElement, and outputs were diffed
against the current code (reseeded, ids canonicalized) for created
rectangle/ellipse/diamond/text ends, elbow arrows, existing ids bound by
two arrows (copied twice), text ends, a labelled sticky note, a frame
around them, and an arrow label (given its own id) used as another
arrow's start: all identical, and the full suite passed in that mode.

So this is a maintainability fix: drop `boundScene` and resync the one
scene with replaceAllElements once the store is complete, which is what
`new Scene(...)` did. Outputs, snapshots and versions are unchanged.

* fix(element): place skeleton arrows' created end shapes along the arrow

`convertToExcalidrawElements` creates a rectangle/ellipse/diamond/text for
a skeleton arrow's `start`/`end` given by `type` (no id), and placed it as
if every arrow ran left to right: the start shape left of the arrow's
`x`, the end shape right of `x + width`, both centered on the arrow's `y`.
For any other direction the shape isn't where the arrow starts or ends,
so the arrow is bound to a shape it doesn't reach, and the placement pass
(e0f198c15) then moves its ends to where those bindings put them.

Reproduction: an arrow at (0,0) with `start: { type: "rectangle" }`,
`end: { type: "ellipse" }` and
- "diagonal": points [0,0]->[100,100]
- "vertical": points [0,0]->[0,200]
- "right-to-left": points [0,0]->[-200,0]
or `end: { type: "text", text: "end" }` on the diagonal one.

Failure case (HEAD): the shapes are at (-100,-50) and (100,-50) whatever
the direction, and the ends are bound at fixedPoints the editor can't
create, outside the shapes:
- "diagonal": ellipse at (100,-50), the arrow ends at (100,100): end
  bound at fixedPoint [0,1.5].
- "vertical": end bound at [0,2.5], and the start is placed at y=56, as
  the arrow runs down the rectangle's edge.
- "right-to-left": ellipse at x=200, on the wrong side: end bound at
  [-4,0.5001], and the start is placed at x=-106, on the far side of the
  rectangle the arrow passes through.
- the text end is bound at [0,4.5] the same way.
Expected: the shapes at the arrow's start/end, the arrow pointing into
them, both ends bound on their outlines and placed off them by the
binding gap.

Fix: new `getArrowEndShapePosition` centers the shape on the arrow's
first/last segment as extended past the end, at the distance from its
center to its outline (rectangle/text box, ellipse or diamond) in that
direction, so the end lies on its outline. Explicit `x`/`y` still win,
and an existing end text still keeps its x. Left-to-right arrows are
placed as before. Other directions change, e.g. the 300x300 start
rectangle of the 395x35 arrow in "should bind arrows to existing shapes
when start / end provided with ids" moves up 13.3px, onto the arrow's
line (snapshot updated).

* fix(element): unbind unreachable skeleton arrow ends, rebind the rest

`convertToExcalidrawElements` binds skeleton arrows to their `start`/`end`
elements while it is still creating elements, and the placement pass
(e0f198c15) then places every bound end where its binding puts it. Two
kinds of bindings made at conversion time are wrong, and placing the
arrows exposes them.

1. Ends given beyond the binding area of their element

   A layout engine (e.g. mermaid's sequence diagrams, whose messages are
   bound to the participants' headers but drawn far below them) can bind an
   end the user could never bind in the editor. Its fixedPoint lies well
   outside the element, and `normalizeFixedPoint` clamps it, so the binding
   can't hold the end where it was given.

   Reproduction: rectangles A (0,0 100x20) and B (500,0 100x20).
   - "half-far": an arrow at (100,10) with points [0,0]->[450,490], start A,
     end B, so its end is given at (550,500), far below B.
   - "beyond": an arrow at (50,40) with points [0,0]->[500,0], start A, end B,
     20px below both, so beyond binding distance.

   Failure case (HEAD):
   - "half-far": end bound to B at fixedPoint [0.5001,10]. Placing moves the
     end from the given (550,500) to (550,200).
   - "beyond": both ends bound at fixedPoint [0.5001,2]. That's a binding the
     editor can't create, and it moves the arrow onto the headers the first
     time A or B is moved.
   Expected: ends beyond the binding area are left unbound where given.
   Ends within it stay bound.

   Fix: new `isPointInBindingArea` (collision.ts) checks whether a point is
   inside an element or within binding distance of its outline.
   `isEndBoundBeyondBindingArea` (binding.ts) applies it to an arrow's bound
   end. Before placing, the pass unbinds every end beyond its element's
   binding area (`unbindBindingElement`, which also drops the arrow from
   the element's `boundElements`). An arrow with no binding left isn't
   placed and keeps its geometry as given.

   The check ignores frame clipping (`getBindingCandidates` still skips
   the clipped parts of frame children): frames are sized around their
   children only at the end of the conversion, so an element given with a
   `frameId` would be checked against a 0x0 frame, and every end bound to
   it would be beyond reach. Arrows unbound from an element are still
   framed with it, as the frame pass frames what is bound to a frame's
   children (through their `boundElements`, which no longer list them).

   An end that just falls short of its element is extended onto it instead
   (`extendBoundEndOntoElement`, binding.ts): its end segment is extended
   past the end by the segment's length, at least 100px, and if that
   reaches the element, the end is moved to where it does, off the element
   by the binding gap, and stays bound. This keeps bindings a generator
   meant to make, but drew arrows slightly too short for.

   Reproduction: rectangle B (500,0 100x20), an arrow at (150,10) with
   points [0,0]->[250,0], end B, so its end is given 100px short of B.
   Expected: end bound to B, moved to (500 - binding gap, 10).

2. Ends bound before their element is sized

   A rectangle/ellipse/diamond with a label and no width/height is created
   0x0 and sized to fit its label only when its label is bound. That happens
   in the same pass that binds arrows, in skeleton order. An arrow listed
   before the element therefore binds to a 0x0 element, and
   `calculateFixedPointForNonElbowArrowBinding` binds ends on elements
   smaller than MIN_BINDABLE_SIZE to their center. Nothing recomputes the
   binding once the element is sized, so the placement pass re-aims the end
   at the center, and the result depends on element order.

   Reproduction: an arrow at (100,50) with points [0,0]->[300,0], end bound
   to B, where B is a rectangle at (400,25) with label "B" and no size
   (sized to 20x35).

   Failure case (HEAD):
     arrow listed first: endBinding.fixedPoint [0.5001,0.5001] (center),
                         points [[0,0],[294,-7.11]] (tilted)
     B listed first:     endBinding.fixedPoint [0,0.714] (left edge),
                         points [[0,0],[294,0]] (straight)
   Expected: the same in either order, the "B listed first" result.

   Fix: the pass rebinds each end that is still bound
   (`bindBindingElement`, keeping its mode) against its element as sized.
   For elements whose size didn't change after binding, this gives the
   same binding as before.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(editor): convert TTD dialog diagrams with the host's render environment

Review finding 7.

The text-to-diagram dialog (the Mermaid tab, and the AI chat's preview and
insert) converted mermaid's skeletons with `convertToExcalidrawElements`
without the host's `renderEnvironment`, while pasting a mermaid definition
(App.clipboard) passes `app.renderEnvironment`. So with a host's custom
`textMetrics`, every label in the dialog's conversion, container and arrow
labels alike, was measured with the default (canvas) metrics. The gap
predates this branch: d3a9c2a19 added the option and passed it from the
paste path, but not from the dialog.

Reproduction: render `<Excalidraw renderEnvironment={env}>`, whose
`textMetrics.getLineWidth` is `text.length * 5`, open the Mermaid dialog
and insert a diagram with a 100x40 rectangle labelled "aaaa bbbb cccc", and
an arrow labelled "aaaa bbbb cccc dddd eeee ffff" bound to it.

Failure case:
  preview:  both labels wrapped by the default metrics ("aaaa bbbb\ncccc",
            "aaaa bbbb cccc dddd\neeee ffff"), and the rectangle grown to
            height 60 to fit two lines
  inserted: `addElementsFromPasteOrLibrary` redraws the labels with the
            host's environment, so they end up on one line, but the
            rectangle stays 60 high, around a one-line label
Expected: as when pasting the same definition: one-line labels (70px and
  145px wide) in the preview and the scene, and the rectangle 40 high.

Fix: `convertMermaidToExcalidraw` takes an optional `renderEnvironment` and
passes it to `convertToExcalidrawElements`. Its three callers pass
`app.renderEnvironment`: the Mermaid tab's preview (whose result is what
it inserts), and the AI chat's preview (`useMermaidRenderer`, now using
`useApp`) and insert (`TextToDiagram`).

Left alone: `exportScene`, which renders the preview, takes no environment;
it draws already measured elements, so the preview's layout now matches the
inserted one.

Without the prop, `app.renderEnvironment` has no `textMetrics`, so
measurement falls back as before (no snapshot changes).

Tests: inserting from the Mermaid dialog under a host environment
(renderEnvironmentLabels.test.tsx); the rectangle's height fails without
the fix.

* fix(element): decide skeleton arrow end bindings before moving either end

When placing skeleton arrows, each end bound beyond its element's binding
area is either extended onto the element (if it just falls short) or
unbound. 61255ad73 did this one end at a time: start first, then end. For
elbow arrows, extending the start goes through `movePoints`, which reroutes
the whole arrow from both its bindings. That moved the still-bound end onto
its element before it was checked, so it was kept bound. The result
depended on which end was the start.

Reproduction: rectangles A (0,0 100x20) and B (500,0 100x20), and an elbow
arrow (`elbowed: true`) [0,0]→[400,0]→[400,490] at (150,10), bound from A
to B. Its start falls 50px short of A, and its end is at (550,500), far
below B.

Failure case:
  A→B: start extended onto A and bound, end rerouted to about (550,26)
       just under B, and left bound to B
  B→A (same arrow reversed): end extended onto A and bound, start left at
       (550,500) and unbound
Expected: both directions as B→A: the A end extended and bound, the B end
  left where given and unbound.

Fix: `extendBoundEndOntoElement` becomes `getBoundEndExtension`, which only
returns where the end would be extended to and moves nothing. The skeleton
conversion now checks both ends against the arrow as given. It unbinds the
unreachable ends first, so the reroute doesn't take them along, then
applies every extension in one `movePoints` call, then rebinds as before.

Only elbow arrows were affected: moving one end of a non-elbow arrow leaves
its other end in place. Mermaid's converter doesn't produce elbow arrows,
so this needs hand-written or LLM-generated skeletons.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(element): rebind elbow skeleton arrows before extending their ends

The placement pass (61255ad73, 2fe86fe7f) extends bound ends that just
fall short of their elements onto them with one `movePoints` call. Only
after that does it rebind each end against its element as sized. For
elbow arrows, `movePoints` reroutes the whole arrow from both its
bindings. A binding made before its element was sized (a labelled shape
with no width/height, listed after the arrow, is still 0x0 when the
arrow binds to it) points at the element's center. The reroute then
routes the end around the element to that center, and the rebind that
follows keeps the side the end was rerouted to. The result depended on
element order.

Reproduction: rectangle A (0,25 100x50), rectangle B at (400,25) with
label "B" and no size (sized to 20x35), and an elbow arrow
(`elbowed: true`) at (150,50) with points [0,0]->[250,0], bound from A to
B. Its start falls 50px short of A, so it gets extended.

Failure case:
  [A, B, arrow]: endBinding.fixedPoint [-0.3,0.714] (B's left side),
                 points [[0,0],[288,0]]
  [A, arrow, B]: endBinding.fixedPoint [1.3,0.5] (B's right side), six
                 points running past B to x=466 and back into its right
                 side at (426,42.5)
The same happens when the extended end is the one bound to B (the arrow
at (106,50) with points [0,0]->[224,0], ending 70px short of B), and when
both ends are extended.
Expected: the same in either order, the [A, B, arrow] result.

Fix: before extending an elbow arrow's ends, rebind both of them against
their elements as sized: an end being extended at the point it's
extended to (`calculateFixedPointForNonElbowArrowBinding` with that
point as the focus point, then `bindBindingElementToFixedPoint`), and
any other end where it is (`bindBindingElement`). Then extend, and rebind
as before.

Rebinding before the move only the ends not being extended isn't enough:
an extended end would still be rerouted to its element's center. Neither
is rebinding only after the move, because by then the reroute has
already put the end on the wrong side.

Only elbow arrows were affected: moving one end of a non-elbow arrow
doesn't reroute it, so the rebind after the move already corrects it.

Tests: "should route elbow arrows extended onto elements as to elements
sized to fit their labels after them as to those before them"
(transform.test.ts), covering the start and the end extended. It fails
without the fix (`expected 1.3 to be less than 0`).

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(element): clamp skeleton arrow labels only off the ends they're trimmed off

ee5d10684 keeps skeleton arrow labels where `labelPosition` put them on
the arrow as given, by projecting that point onto the arrow as placed. A
point on a stretch placing trimmed off projects onto the arrow's end, so
`clampLabelPositionOffEnds` keeps the label clear of the end and its
arrowhead. But the clamp ran on the label of every bound arrow, wherever
its point projected. Labels on the arrow as placed were moved off its
ends too, which unbound (unplaced) arrows don't do.

Reproduction: rectangles A (0,0 100x100) and B (192,0 100x100), and an
arrow at (106,50) with points [0,0]->[80,0], bound from A to B. Its ends
are already off A and B by the binding gap, so placing it trims nothing.
Label widths are as measured in the tests.

Failure case:
  label "LABEL" (50px), no labelPosition:  labelPosition 0.375, center
      x=136, 10px toward the start, off the end arrowhead
  label "LABELX" (60px), no labelPosition: labelPosition 0.5, center
      x=146: too wide to clear both ends, so centered again. A 10px wider
      label jumps back 10px
  arrow [0,0]->[300,0] instead, label 220px wide at labelPosition 0.3:
      0.3667, 20px off where it was given
Expected: as on the same arrows unbound: 0.5 (center x=146) for both
  default labels, and 0.3 for the given one.

Fix: `clampLabelPositionOffEnds` returns the position unchanged unless it
is at an end of the arrow (0 or 1, within PRECISION), where points on
trimmed-off stretches project to.

Snapshot: the label in "should bind arrows to shapes when start / end
provided without ids" was too wide to clear both ends, so the clamp had
centered it at exactly 0.5. It now keeps its projected position,
0.4999999949 (and is stored at x=240 instead of 240.00000045, with its
version bumped as the position changed).

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(element): create skeleton arrow labels unrotated

Arrow labels aren't rotated: `restore` resets their `angle` to 0, and
`redrawTextBoundingBox` asserts it outside production and resets it. A
skeleton label can still give an `angle` (its type allows the generic
element props). Until 472c87980 every skeleton label was measured with
`redrawTextBoundingBox` as soon as it was created, so an arrow label's
angle was reset there. Since then, labels of placed (bound) arrows are
measured only as placed, through `handleBindTextResize`, which leaves
`angle` as given. Labels of arrows not placed are still measured with
`redrawTextBoundingBox`, so outside production a given angle failed its
invariant.

Reproduction: rectangles A (0,0 100x100) and B (400,0 100x100), and an
arrow at (106,50) with points [0,0]->[288,0] and label
{ text: "L", angle: 1 }, once bound from A to B and once unbound.

Failure case:
  bound:   label angle 1
  unbound: "text element angle must be 0 if bound to arrow container"
           (outside production; angle 0 in production)
Expected: label angle 0 on both arrows, as after `restore`.

Fix: the label of an arrow is created with angle 0, as `restore`
normalizes it. The labels of other containers are still rotated with
them by `redrawTextBoundingBox`.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix(element): keep skeleton loop arrows' midpoints where given

The placement pass (45276e6a9) places skeleton bound arrows with
`updateBoundArrow`, which the editor also uses as an element moves. For
an arrow bound to the same element at both ends, it passes
`moveMidPointsWithElement`, so that a loop moves with its element as a
whole: its midpoints follow its start. Placing a skeleton arrow moves
nothing it's bound to, only its ends, so a loop's midpoints followed its
start as it was placed off the element, and the loop changed shape.
Midpoints of other arrows stay where given. Only the start drags them,
so the result also depended on which end was the start.

Reproduction: rectangle A (0,0 100x100), and an arrow from A's center
around to A's right side: points (50,50) (50,-60) (160,-60) (160,50)
(106,50), bound to A at both ends.

Failure case:
  from the center: start placed off A's top edge, 56px up, at (50,-6),
      and the midpoints 56px up with it: (50,-116) (160,-116) (160,-6).
      The loop is 56px taller, and its last segment into A is diagonal
  from A's top edge (50,0): midpoints 6px up: (50,-66) (160,-66) (160,44)
  either, reversed: no change, as its start is already off A
Expected: the midpoints where given, (50,-60) (160,-60) (160,50), with
  only the ends placed.

Fix: `updateBoundArrow` takes `boundElementMoved` (default true, as the
editor calls it). The placement pass passes false, so loops are placed
like other arrows: only their ends move. Placed loops stay put under the
editor's next binding update, and still move whole with their element.

Left alone: a reversed loop given from the center still keeps its end
there. For loops, `updateBoundPoint` places the end with the arrowhead at
its fixed point and the other on the outline, and a skeleton end is bound
where given, here at the center. That's the editor's own rule from
master, applied to the binding as given.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: Mark Tolmacs <mark@lazycat.hu>
2026-10-27 16:37:03 +01:00
David Luzar 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
2026-10-27 16:29:21 +01:00
David Luzar 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)
2026-10-27 15:46:41 +01:00
David Luzar 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)
2026-10-27 15:34:46 +01:00
David Luzar 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)
2026-10-23 12:48:01 +02:00
Márk Tolmácsanddwelle 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>
2026-10-21 12:36:40 +02:00
Juan FernandezandMark Tolmacs 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>
2026-10-20 20:25:57 +02:00
David Luzar 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)
2026-10-20 12:12:18 +02:00