Virtual whiteboard for sketching hand-drawn like diagrams
feat(editor): text tool edits what you click, shows what a click will do, drags out free text in shapes (#12082)
David Luzarc10499eebb62
diff --git a/packages/element/src/collision.ts b/packages/element/src/collision.tsindex c548080bf0..83a8eeaef2 100644--- a/packages/element/src/collision.ts+++ b/packages/element/src/collision.ts@@ -42,6 +42,7 @@ import {import {hasBoundTextElement,isBindableElement,+ isBoundToContainer,isFrameLikeElement,isFreeDrawElement,isIframeLikeElement,@@ -55,9 +56,10 @@ import {deconstructRectanguloidElement,} from "./utils";-import { getBoundTextElement } from "./textElement";--import { LinearElementEditor } from "./linearElementEditor";+import {+ getBoundTextElement,+ getTextElementWithAccuratePosition,+} from "./textElement";import { distanceToElement } from "./distance";@@ -144,7 +146,10 @@ export const hitElementItself = ({// A cached hit stays valid for any larger threshold, while a cached miss// stays valid only for a threshold no larger than the cached one (a larger// threshold could turn a miss into a hit).+ // Skipped for container-bound labels — their position can change without+ // their version being bumped (see ElementBounds.getBounds).if (+ !isBoundToContainer(element) &&cachedPoint &&pointsEqual(point, cachedPoint) &&(cachedHit ? cachedThreshold <= threshold : cachedThreshold >= threshold) &&@@ -192,6 +197,15 @@ export const hitElementItself = ({return false;}+ // an arrow label's stored coords can be stale. The bounds test above+ // already accounts for it (getElementBounds derives the position+ // internally), but the precise test below reads the element coords+ // directly, so substitute them. Done after the early bail so the common+ // miss path stays allocation-free.+ if (isTextElement(element)) {+ element = getTextElementWithAccuratePosition(element, elementsMap);+ }+// Do the precise (and relatively costly) hit testconst hitElement = (overrideShouldTestInside ? true : shouldTestInside(element)@@ -262,18 +276,10 @@ export const hitElementBoundText = (if (!boundTextElementCandidate) {return false;}- const boundTextElement = isLinearElement(element)- ? {- ...boundTextElementCandidate,- // arrow's bound text accurate position is not stored in the element's property- // but rather calculated and returned from the following static method- ...LinearElementEditor.getBoundTextElementPosition(- element,- boundTextElementCandidate,- elementsMap,- ),- }- : boundTextElementCandidate;+ const boundTextElement = getTextElementWithAccuratePosition(+ boundTextElementCandidate,+ elementsMap,+ );return isPointInElement(point, boundTextElement, elementsMap);};diff --git a/packages/element/src/textElement.ts b/packages/element/src/textElement.tsindex 1469137bb1..64c05c1313 100644--- a/packages/element/src/textElement.ts+++ b/packages/element/src/textElement.ts@@ -443,6 +443,35 @@ export const getBoundTextElementPosition = (}};+/**+ * Returns the text element with its accurate coords. An arrow label's+ * position is derived from the arrow at render time rather than kept in+ * sync on the element itself (see getBoundTextElementPosition), so+ * consumers reading a label's coords directly must go through this helper.+ */+export const getTextElementWithAccuratePosition = <+ T extends ExcalidrawTextElement,+>(+ textElement: T,+ elementsMap: ElementsMap,+): T => {+ if (!textElement.containerId) {+ return textElement;+ }+ const container = elementsMap.get(textElement.containerId);+ if (!container || !isArrowElement(container)) {+ return textElement;+ }+ return {+ ...textElement,+ ...LinearElementEditor.getBoundTextElementPosition(+ container,+ textElement as ExcalidrawTextElementWithContainer,+ elementsMap,+ ),+ };+};+export const shouldAllowVerticalAlign = (selectedElements: readonly ExcalidrawElement[],elementsMap: ElementsMap,diff --git a/packages/element/tests/collision.test.tsx b/packages/element/tests/collision.test.tsxindex 744fd11ab9..2d3a49cb20 100644--- a/packages/element/tests/collision.test.tsx+++ b/packages/element/tests/collision.test.tsx@@ -247,6 +247,50 @@ describe("hitElementItself cache", () => {}),).toBe(true);});++ it("rechecks a bound label when only its arrow changes", () => {+ const arrow = API.createElement({+ type: "arrow",+ x: 200,+ y: 200,+ width: 300,+ height: 0,+ points: [pointFrom(0, 0), pointFrom(300, 0)],+ });+ const label = API.createElement({+ type: "text",+ text: "label",+ x: 325,+ y: 187.5,+ width: 50,+ height: 25,+ containerId: arrow.id,+ });+ API.setElements([arrow, label]);+ API.updateElement(arrow, {+ boundElements: [{ id: label.id, type: "text" }],+ });+ const elementsMap = window.h.scene.getNonDeletedElementsMap();+ const labelVersion = label.version;+ const point = pointFrom<GlobalPoint>(350, 200);++ expect(+ hitElementItself({ point, element: label, threshold: 1, elementsMap }),+ ).toBe(true);+ API.updateElement(arrow, { x: 500 });+ expect(label.version).toBe(labelVersion);+ expect(+ hitElementItself({ point, element: label, threshold: 1, elementsMap }),+ ).toBe(false);+ expect(+ hitElementItself({+ point: pointFrom<GlobalPoint>(650, 200),+ element: label,+ threshold: 1,+ elementsMap,+ }),+ ).toBe(true);+ });});describe("freedraw collision matches the rendered stroke width", () => {diff --git a/packages/excalidraw/actions/actionDeselect.ts b/packages/excalidraw/actions/actionDeselect.tsindex 0a97a5f882..74e7c98cca 100644--- a/packages/excalidraw/actions/actionDeselect.ts+++ b/packages/excalidraw/actions/actionDeselect.ts@@ -104,7 +104,6 @@ export const actionDeselect = register({selectionElement: null,showHyperlinkPopup: false,suggestedBinding: null,- hoveredArrowTextAnchor: null,frameToHighlight: null,},captureUpdate: CaptureUpdateAction.IMMEDIATELY,@@ -123,7 +122,6 @@ export const actionDeselect = register({selectionElement: null,showHyperlinkPopup: false,suggestedBinding: null,- hoveredArrowTextAnchor: null,frameToHighlight: null,},captureUpdate: CaptureUpdateAction.IMMEDIATELY,diff --git a/packages/excalidraw/actions/actionFinalize.tsx b/packages/excalidraw/actions/actionFinalize.tsxindex ae554d69b3..69d208d40f 100644--- a/packages/excalidraw/actions/actionFinalize.tsx+++ b/packages/excalidraw/actions/actionFinalize.tsx@@ -197,7 +197,6 @@ export const actionFinalize = register<FormData>({},selectionElement: null,suggestedBinding: null,- hoveredArrowTextAnchor: null,newElement: null,multiElement: null,},@@ -401,7 +400,6 @@ export const actionFinalize = register<FormData>({multiElement: null,editingTextElement: null,suggestedBinding: null,- hoveredArrowTextAnchor: null,frameToHighlight: null,selectedElementIds: isDrawShapeTool? {}diff --git a/packages/excalidraw/appState.ts b/packages/excalidraw/appState.tsindex e448d2084b..e4017c73eb 100644--- a/packages/excalidraw/appState.ts+++ b/packages/excalidraw/appState.ts@@ -108,7 +108,7 @@ export const getDefaultAppState = (): Omit<panels: STATS_PANELS.generalStats | STATS_PANELS.elementProperties,},suggestedBinding: null,- hoveredArrowTextAnchor: null,+ textToolHover: null,frameRendering: { enabled: true, clip: true, name: true, outline: true },frameToHighlight: null,editingFrame: null,@@ -264,7 +264,7 @@ const APP_STATE_STORAGE_CONF = (<shouldCacheIgnoreZoom: { browser: true, export: false, server: false },stats: { browser: true, export: false, server: false },suggestedBinding: { browser: false, export: false, server: false },- hoveredArrowTextAnchor: { browser: false, export: false, server: false },+ textToolHover: { browser: false, export: false, server: false },frameRendering: { browser: false, export: false, server: false },frameToHighlight: { browser: false, export: false, server: false },editingFrame: { browser: false, export: false, server: false },diff --git a/packages/excalidraw/components/App.arrowText.ts b/packages/excalidraw/components/App.arrowText.tsindex 9ca3307307..b5f18bb86e 100644--- a/packages/excalidraw/components/App.arrowText.ts+++ b/packages/excalidraw/components/App.arrowText.ts@@ -3,7 +3,6 @@ import { CURSOR_TYPE, DRAGGING_THRESHOLD } from "@excalidraw/common";import {bindBindingElementToFixedPoint,dragNewTextElement,- getBoundTextElement,getEndpointBoundTextDragAnchor,getTextBindingForArrowEndpoint,getUnboundArrowEndpointAtPoint,@@ -27,20 +26,17 @@ import type {} from "@excalidraw/element/types";import type App from "./App";-import type { AppState, PointerDownState } from "../types";+import type { PointerDownState } from "../types";/*** Text ↔ arrow interactions.*- * With the text tool: the hover affordance showing where a click would attach- * text to an arrow — a free endpoint (binds the arrow to a new text element- * positioned against that endpoint) or the arrow's midpoint (adds a label- * bound to the arrow) — and the endpoint-bound flavor of drag-sizing a new- * text.+ * With the text tool: the free endpoint a click would bind a new text to+ * (`AppTextTool` resolves and shows it), the binding itself, and the+ * endpoint-bound flavor of drag-sizing a new text.** With the selection tool: dragging an arrow's existing label along the arrow- * — the grab affordance, the drag itself, and where a double-click starts- * editing a label the drag has moved.+ * — the grab affordance and the drag itself.** The scene-level logic lives in `@excalidraw/element`'s* `arrowEndpointText.ts` and `linearElementEditor.ts`.@@ -48,47 +44,6 @@ import type { AppState, PointerDownState } from "../types";export class AppArrowText {constructor(private app: App) {}- /**- * With the text tool active, an arrow under the cursor is a target for- * attaching text. Returns where the text would land (if anywhere), and keeps- * `appState.hoveredArrowTextAnchor` — which drives the highlight — in sync.- */- updateHoveredAnchor = (scenePointer: {- x: number;- y: number;- }): AppState["hoveredArrowTextAnchor"] => {- const hovered =- this.app.state.activeTool.type === "text" &&- !this.app.state.editingTextElement &&- !this.app.state.newElement- ? this.getAnchorAtPosition(scenePointer.x, scenePointer.y)- : null;-- const previous = this.app.state.hoveredArrowTextAnchor;-- if (- previous?.elementId !== hovered?.elementId ||- previous?.anchor !== hovered?.anchor- ) {- this.app.setState({ hoveredArrowTextAnchor: hovered });- }-- return hovered;- };-- /**- * Re-evaluates the hovered anchor at the last known pointer position — for- * events that change what a click would do without the pointer moving,- * i.e. the ctrl/cmd binding toggle. (Events that invalidate the anchor- * wholesale — tool switches, finalize, deselect — clear it directly- * instead.)- */- refresh = (): void => {- if (this.app.lastPointerMoveCoords) {- this.updateHoveredAnchor(this.app.lastPointerMoveCoords);- }- };-/*** A free arrow endpoint a new text could be bound to. Binding an endpoint is* an arrow binding, so it follows the binding toggle (ctrl/cmd) like every@@ -110,17 +65,17 @@ export class AppArrowText {return null;}- // The text tool edits before it creates: when a text element is the- // top-most hit at this position, a click edits that text, so a nearby- // endpoint must not be offered over it.- if (this.app.getTextElementAtPosition(x, y)) {- return null;- }-// The endpoint scan only knows about arrows, so it happily reaches through// whatever is drawn on top of them. An element stacked above the arrow that- // the pointer actually hits owns the click — the text tool should label- // that element rather than bind the endpoint hidden behind it.+ // the pointer actually hits owns the click — the text tool should edit or+ // label that element rather than bind the endpoint hidden behind it. This+ // includes text: a text stacked above the arrow keeps its edit behavior.+ //+ // The preference is z-aware on purpose. When the arrow is the top-most hit+ // (e.g. drawn over an existing text), its endpoint has full preference+ // over the whole hit circle — a z-blind "any text under the cursor wins"+ // rule would make the affordance flicker between the endpoint anchor and+ // text editing wherever a text bbox edge cuts into the circle.const hitElement = this.app.getElementAtPosition(x, y, {includeLockedElements: true,});@@ -137,49 +92,6 @@ export class AppArrowText {return endpoint;}- /**- * Mirrors what `handleTextOnPointerDown` would do at this position, so the- * highlight can't promise something the click won't deliver.- */- private getAnchorAtPosition(- x: number,- y: number,- ): AppState["hoveredArrowTextAnchor"] {- const endpoint = this.getBindableEndpointAtPosition(x, y);-- if (endpoint) {- return { elementId: endpoint.arrow.id, anchor: endpoint.startOrEnd };- }-- const container = this.app.getTextBindableContainerAtPosition(x, y);-- // Only arrows get a midpoint label anchor worth pointing at; other- // containers center the text in themselves, which needs no affordance.- // An arrow that already has a label is edited in place, not re-anchored.- if (- !isArrowElement(container) ||- getBoundTextElement(container, this.app.scene.getNonDeletedElementsMap())- ) {- return null;- }-- // `getTextBindableContainerAtPosition` resolves an arrow anywhere in its- // bounding box, but a click only becomes a *label* when it also snaps to- // the arrow's center — off-center clicks drop a free-floating text- // instead. Gate on the same check so the highlight can't promise a label- // the click won't deliver.- const snappedToCenter = this.app.getTextWysiwygSnappedToCenterPosition(- x,- y,- this.app.state,- container,- );-- return snappedToCenter- ? { elementId: container.id, anchor: "label" }- : null;- }-/*** How a text should be created to read as a label for this endpoint — the* side midpoint to bind, the alignment that pins it, and the scene position@@ -319,34 +231,4 @@ export class AppArrowText {return true;}-- /**- * Where a double-click on a labeled arrow should start text editing: the- * center of the label itself, which a label drag may have moved away from- * the arrow's midpoint. Null when the element is not a labeled arrow.- */- getLabelCenter(element: ExcalidrawElement): { x: number; y: number } | null {- const elementsMap = this.app.scene.getNonDeletedElementsMap();-- if (!isArrowElement(element)) {- return null;- }-- const boundTextElement = getBoundTextElement(element, elementsMap);-- if (!boundTextElement) {- return null;- }-- const { x, y } = LinearElementEditor.getBoundTextElementPosition(- element,- boundTextElement,- elementsMap,- );-- return {- x: x + boundTextElement.width / 2,- y: y + boundTextElement.height / 2,- };- }}diff --git a/packages/excalidraw/components/App.pan.ts b/packages/excalidraw/components/App.pan.tsindex 66f6a60cae..81504a3492 100644--- a/packages/excalidraw/components/App.pan.ts+++ b/packages/excalidraw/components/App.pan.ts@@ -44,6 +44,8 @@ export class AppPan {private dependencies: {/** pointers currently down (a two-finger gesture is not a pan) */getPointerCount: () => number;+ /** a scrollbar being dragged (App's own drag, not a pan session) */+ isDraggingScrollBar: () => boolean;},) {}@@ -55,6 +57,17 @@ export class AppPan {this.spaceHeld = held;};+ /**+ * Whether the pointer is navigating the viewport rather than acting on the+ * scene — space held to pan, a pan in progress, a scrollbar drag, or the+ * hand tool. Hover and cursor then belong to the navigation.+ */+ isNavigating = () =>+ this.spaceHeld ||+ this.active ||+ this.dependencies.isDraggingScrollBar() ||+ isHandToolActive(this.app.state);+/** applies the pointer move still waiting for its frame, if any */flushMove = () => {this.pendingMoveFlush?.();diff --git a/packages/excalidraw/components/App.textTool.ts b/packages/excalidraw/components/App.textTool.tsnew file mode 100644index 0000000000..89395927d5--- /dev/null+++ b/packages/excalidraw/components/App.textTool.ts@@ -0,0 +1,455 @@+import { flushSync } from "react-dom";++import {+ CURSOR_TYPE,+ EVENT,+ KEYS,+ TEXT_AUTOWRAP_THRESHOLD,+ updateActiveTool,+ viewportCoordsToSceneCoords,+} from "@excalidraw/common";++import {+ hasBoundTextElement,+ isArrowElement,+ isTextBindableContainer,+} from "@excalidraw/element";++import type { ArrowEndpoint } from "@excalidraw/element";+import type {+ ExcalidrawElement,+ ExcalidrawTextContainer,+ ExcalidrawTextElement,+ NonDeleted,+} from "@excalidraw/element/types";++import type React from "react";++import type App from "./App";+import type { AppState, PointerDownState } from "../types";++type ScenePoint = { x: number; y: number };++/** the modifier state a target depends on — off a pointer or keyboard event */+export type Modifiers = Pick<KeyboardEvent, "ctrlKey" | "metaKey">;++/** What a text-tool click at a position does. */+export type TextToolTarget =+ /** binds a new text to a free arrow endpoint */+ | { type: "endpoint"; endpoint: ArrowEndpoint }+ /** edits this text (a label included, at its derived position) */+ | { type: "text"; element: NonDeleted<ExcalidrawTextElement> }+ /** binds a new label to this empty container (an arrow included) */+ | { type: "container"; element: NonDeleted<ExcalidrawTextContainer> }+ /** creates free text at the pointer */+ | { type: "free" };++const toHoverState = (target: TextToolTarget): AppState["textToolHover"] => {+ switch (target.type) {+ case "endpoint":+ return {+ type: "arrow",+ elementId: target.endpoint.arrow.id,+ anchor: target.endpoint.startOrEnd,+ };+ case "text":+ return { type: "text", elementId: target.element.id };+ case "container":+ // a shape is outlined whole (the label centers in it); an arrow gets+ // its midpoint pointed at+ return isArrowElement(target.element)+ ? { type: "arrow", elementId: target.element.id, anchor: "label" }+ : { type: "container", elementId: target.element.id };+ case "free":+ return null;+ }+};++const isSameHover = (+ a: AppState["textToolHover"],+ b: AppState["textToolHover"],+) => {+ if (a === b) {+ return true;+ }+ if (!a || !b || a.type !== b.type || a.elementId !== b.elementId) {+ return false;+ }+ return a.type !== "arrow" || b.type !== "arrow" || a.anchor === b.anchor;+};++/**+ * The text tool's pointer interaction.+ *+ * Everything hangs off one question — what would a click at this position+ * do (`getTargetAt`)? — answered once and used for the hover affordance+ * (`appState.textToolHover`), the cursor and the pointerdown itself, so the+ * affordance can never promise something the click won't deliver.+ *+ * A click on an empty container's center is armed on pointerdown and+ * committed on pointerup as a bound label; dragging past the autowrap+ * threshold first turns it into a free fixed-width text at the origin+ * instead.+ *+ * Text editing itself (`app.startTextEditing`) is shared with Enter,+ * double-click and the other entry points and stays in `App`.+ */+export class AppTextTool {+ constructor(private app: App) {}++ /**+ * A click on an empty container's center, armed on pointerdown and decided+ * on the pointer's way out: a click binds a label, a drag creates free+ * text instead. Deferring is what keeps the drag from first binding to+ * (and provisionally enlarging) the container.+ */+ private pending: {+ containerId: ExcalidrawElement["id"];+ origin: ScenePoint;+ } | null = null;++ /**+ * The modifiers the hover was last resolved with — what a refresh without+ * an event of its own (the viewport moving under a still pointer) uses.+ */+ private lastModifiers: Modifiers = { ctrlKey: false, metaKey: false };++ /**+ * What a click at this position would do, in the order the click resolves+ * it: a free arrow endpoint (the smaller, more deliberate target; z-aware,+ * and off while ctrl/cmd disables binding) → the text under the pointer,+ * which the click edits → an empty container near its center, which gets+ * a label unless ctrl/cmd opts out → free text at the pointer.+ *+ * Ctrl/cmd is "no binding" throughout the tool, as elsewhere in the+ * editor. For the container it is read off the event rather than the+ * arrow-binding preference: a label is not an arrow binding.+ */+ getTargetAt = (+ scenePointer: ScenePoint,+ modifiers: Modifiers,+ ): TextToolTarget => {+ const { x, y } = scenePointer;++ const endpoint = this.app.arrowText.getBindableEndpointAtPosition(x, y);+ if (endpoint) {+ return { type: "endpoint", endpoint };+ }++ const text = this.app.getTextElementAtPosition(x, y);+ if (text) {+ return { type: "text", element: text };+ }++ if (!modifiers[KEYS.CTRL_OR_CMD]) {+ const container = this.app.getTextBindableContainerAtPosition(x, y);+ if (+ container &&+ // an existing label is edited by hitting the text itself (above)+ !hasBoundTextElement(container) &&+ this.app.getTextWysiwygSnappedToCenterPosition(+ x,+ y,+ this.app.state,+ container,+ )+ ) {+ return { type: "container", element: container };+ }+ }++ return { type: "free" };+ };++ /**+ * Keeps `appState.textToolHover` — the affordance for what a click would+ * do — in sync with the pointer, and returns the target (for the cursor).+ * Suppressed while something else owns the interaction: a text being+ * edited or drag-sized, a multi-point element, a box selection, a drag of+ * the selection, or the pointer over a scrollbar.+ */+ updateHover = (+ scenePointer: ScenePoint,+ modifiers: Modifiers,+ isOverScrollBar = false,+ ): TextToolTarget | null => {+ const { state } = this.app;+ if (state.activeTool.type !== "text") {+ return null;+ }+ // a pending center click keeps the affordance it was armed with until+ // it resolves (the pointer may leave the snap radius before the drag+ // threshold, and a release would still bind)+ if (this.pending) {+ return null;+ }+ this.lastModifiers = {+ ctrlKey: modifiers.ctrlKey,+ metaKey: modifiers.metaKey,+ };+ const target =+ state.editingTextElement ||+ state.newElement ||+ state.multiElement ||+ state.selectionElement ||+ state.selectedElementsAreBeingDragged ||+ isOverScrollBar+ ? null+ : this.getTargetAt(scenePointer, modifiers);+ this.setHover(target && toHoverState(target));+ return target;+ };++ /**+ * Re-resolves the hover — and the cursor that goes with it — where the+ * pointer last was, for what changes a click's outcome without the pointer+ * moving: the ctrl/cmd toggle (pass its event), or the viewport scrolling+ * or zooming under the pointer (no event; the last modifiers stand). The+ * scene position is re-derived from the pointer's viewport position, so a+ * moved viewport resolves what is under the pointer now.+ *+ * Nothing to refresh with another tool or without a hovering pointer — a+ * finger never hovers (its last move is where it lifted), and the+ * affordance a press armed is cleared when the press resolves or is+ * canceled. The cursor is left to viewport navigation (space/wheel+ * panning, a scrollbar drag, the hand tool), as on pointermove.+ */+ refresh = (modifiers: Modifiers = this.lastModifiers) => {+ const pointer = this.app.lastPointerMoveEvent;+ if (+ this.app.state.activeTool.type !== "text" ||+ !pointer ||+ pointer.pointerType === "touch"+ ) {+ return;+ }+ const target = this.updateHover(+ viewportCoordsToSceneCoords(pointer, this.app.state),+ modifiers,+ );+ if (!this.app.pan.isNavigating()) {+ this.app.cursor.set(this.cursorFor(target));+ }+ };++ /**+ * Drops a pending center click without acting on it — the tool was left,+ * the browser took the pointer (pointercancel), or a second finger turned+ * the press into a pinch/pan — so no pointerup of ours will decide it. The+ * outline it armed goes with it: while pending, the hover is that click's.+ */+ cancel = () => {+ if (this.pending) {+ this.pending = null;+ this.clearHover();+ }+ };++ clearHover = () => {+ if (this.app.state.textToolHover) {+ this.app.setState({ textToolHover: null });+ }+ };++ private setHover = (next: AppState["textToolHover"]) => {+ if (!isSameHover(this.app.state.textToolHover, next)) {+ this.app.setState({ textToolHover: next });+ }+ };++ /**+ * The cursor for what a click would do: a pointer over the arrow anchors+ * text would attach to, a text cursor over text the click would edit, the+ * tool's crosshair otherwise — also while the affordance is suppressed+ * (editing, drag-sizing), where a click has nothing to point at.+ */+ cursorFor = (target: TextToolTarget | null): string => {+ if (+ target?.type === "endpoint" ||+ (target?.type === "container" && isArrowElement(target.element))+ ) {+ return CURSOR_TYPE.POINTER;+ }+ if (target?.type === "text") {+ return CURSOR_TYPE.TEXT;+ }+ return CURSOR_TYPE.CROSSHAIR;+ };++ handlePointerDown = (+ event: React.PointerEvent<HTMLElement>,+ pointerDownState: PointerDownState,+ ): void => {+ // while editing, a click outside only finalizes the edit — it doesn't+ // create another text (irrespective of state.activeTool.locked)+ if (this.app.state.editingTextElement) {+ return;+ }+ const sceneX = pointerDownState.origin.x;+ const sceneY = pointerDownState.origin.y;+ const target = this.getTargetAt({ x: sceneX, y: sceneY }, event);++ switch (target.type) {+ case "endpoint":+ this.app.startTextEditing({+ sceneX,+ sceneY,+ // the binding fixes the position, but the width is still the+ // user's to drag out (see `getEndpointBoundTextDragAnchor`)+ autoEdit: false,+ arrowEndpoint: target.endpoint,+ textElement: null,+ });+ break;+ case "text":+ this.app.startTextEditing({+ sceneX,+ sceneY,+ textElement: target.element,+ autoEdit: false,+ initialCaretSceneCoords: { x: sceneX, y: sceneY },+ });+ break;+ case "container":+ // decided on the way out (see handlePointerMove / handlePointerUp).+ // The affordance stays up meanwhile — set explicitly, since a tap+ // has no hover before it+ this.pending = {+ containerId: target.element.id,+ origin: { x: sceneX, y: sceneY },+ };+ this.setHover(toHoverState(target));+ return;+ case "free":+ this.app.startTextEditing({+ sceneX,+ sceneY,+ container: null,+ textElement: null,+ insertAtParentCenter: false,+ autoEdit: false,+ });+ break;+ }++ this.finish();+ };++ /**+ * The pointer-move half of a pending center click. Once the pointer has+ * moved past the autowrap threshold the click is a drag: free text is+ * created at the origin and sized by the drag from here on. Horizontal+ * only (a text is only ever sized that way) and in screen space, and+ * deliberately wider than the generic drag threshold so a jittery click+ * still binds. Returns whether a pending click owned the move.+ */+ handlePointerMove = (+ event: PointerEvent,+ pointerDownState: PointerDownState,+ ): boolean => {+ if (!this.pending) {+ return false;+ }+ // a tool switch mid-press orphans the click+ if (this.app.state.activeTool.type !== "text") {+ this.cancel();+ return true;+ }+ const pointerCoords = viewportCoordsToSceneCoords(event, this.app.state);+ if (this.isDrag(pointerCoords)) {+ this.resolvePending(true, pointerCoords, pointerDownState, event);+ }+ return true;+ };++ /**+ * The pointer-up half: a genuine pointerup binds the label. The+ * missing-pointerup cleanup replays this with the pointerdown event (a+ * second finger landing mid-press), and a tool switch orphans the click —+ * both discard it instead.+ */+ handlePointerUp = (+ event: PointerEvent,+ pointerDownState: PointerDownState,+ ): void => {+ if (!this.pending) {+ return;+ }+ if (+ event.type !== EVENT.POINTER_UP ||+ this.app.state.activeTool.type !== "text"+ ) {+ this.cancel();+ return;+ }+ const pointerCoords = viewportCoordsToSceneCoords(event, this.app.state);+ this.resolvePending(+ this.isDrag(pointerCoords),+ pointerCoords,+ pointerDownState,+ event,+ );+ };++ private isDrag = (pointerCoords: ScenePoint) =>+ Math.abs(pointerCoords.x - this.pending!.origin.x) *+ this.app.state.zoom.value >+ TEXT_AUTOWRAP_THRESHOLD;++ private resolvePending = (+ isDrag: boolean,+ pointerCoords: ScenePoint,+ pointerDownState: PointerDownState,+ event: PointerEvent,+ ) => {+ const { containerId, origin } = this.pending!;+ this.pending = null;++ // gone mid-press (a collaborator deleted it): nothing to create, but the+ // click still ends the tool's turn+ const container = this.app.scene.getNonDeletedElement(containerId);+ const created = isTextBindableContainer(container, false);++ // flushed so the drag below reads the created element off the state+ flushSync(() => {+ if (created) {+ this.app.startTextEditing({+ sceneX: origin.x,+ sceneY: origin.y,+ container: isDrag ? null : container,+ textElement: null,+ insertAtParentCenter: !isDrag,+ autoEdit: !isDrag,+ });+ }+ this.finish();+ });++ if (created && isDrag) {+ pointerDownState.lastCoords.x = pointerCoords.x;+ pointerDownState.lastCoords.y = pointerCoords.y;+ this.app.maybeDragNewGenericElement(pointerDownState, event);+ }+ };++ /**+ * The click has been acted on: drop the affordance, revert the tool unless+ * it is locked, restore the cursor.+ */+ private finish = () => {+ this.clearHover();+ if (!this.app.isToolLocked()) {+ this.app.setState(+ {+ activeTool: updateActiveTool(this.app.state, {+ type: this.app.state.preferredSelectionTool.type,+ }),+ },+ // reset once the tool revert has settled+ () => this.app.cursor.reset(),+ );+ } else {+ this.app.cursor.reset();+ }+ };+}diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsxindex a1cf8242f2..57dd82dbca 100644--- a/packages/excalidraw/components/App.tsx+++ b/packages/excalidraw/components/App.tsx@@ -348,11 +348,7 @@ import { ActionManager } from "../actions/manager";import { actions } from "../actions/register";import { getShortcutFromShortcutName } from "../actions/shortcuts";import { trackEvent } from "../analytics";-import {- getDefaultAppState,- isEraserActive,- isHandToolActive,-} from "../appState";+import { getDefaultAppState, isEraserActive } from "../appState";import {copyTextToSystemClipboard,parseClipboard,@@ -446,6 +442,7 @@ import ConvertElementTypePopup, {import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";import { AppArrowText } from "./App.arrowText";+import { AppTextTool } from "./App.textTool";import { AppBucketFill } from "./App.bucketFill";import { AppToolDrag, TOOL_DRAG_PREVIEW_OPACITY } from "./App.toolDrag";import { AppCursor } from "./App.cursor";@@ -723,7 +720,9 @@ class App extends React.Component<AppProps, AppState> {public arrowText: AppArrowText = new AppArrowText(this);public pan: AppPan = new AppPan(this, {getPointerCount: () => gesture.pointers.size,+ isDraggingScrollBar: () => isDraggingScrollBar,});+ public textTool: AppTextTool = new AppTextTool(this);public viewport: AppViewport = new AppViewport(this, {getContainer: () => this.excalidrawContainerRef.current,getStylesPanelMode: () => this.stylesPanelMode,@@ -2744,7 +2743,7 @@ class App extends React.Component<AppProps, AppState> {onClick={this.handleCanvasClick}onPointerMove={this.handleCanvasPointerMove}onPointerUp={this.handleCanvasPointerUp}- onPointerCancel={this.removePointer}+ onPointerCancel={this.handleCanvasPointerCancel}onTouchMove={this.handleTouchMove}onPointerDown={this.handleCanvasPointerDown}onDoubleClick={this.handleCanvasDoubleClick}@@ -3385,6 +3384,7 @@ class App extends React.Component<AppProps, AppState> {suggestedBinding: null,frameToHighlight: null,elementsToHighlight: null,+ textToolHover: null,snapLines: [],showHyperlinkPopup: false,});@@ -4323,6 +4323,17 @@ class App extends React.Component<AppProps, AppState> {this.setState({ showWelcomeScreen: true });}+ // neither the text tool's hover affordance nor a pending center click+ // may outlive the tool, however it gets left (Esc/finalize paths bypass+ // setActiveTool) — the tool coming back mid-press must not revive them+ if (+ prevState.activeTool.type === "text" &&+ this.state.activeTool.type !== "text"+ ) {+ this.textTool.clearHover();+ this.textTool.cancel();+ }+if (prevState.zoom.value !== this.state.zoom.value ||prevState.scrollX !== this.state.scrollX ||@@ -4338,6 +4349,9 @@ class App extends React.Component<AppProps, AppState> {this.state.scrollY,this.state.zoom,);+ // the scene moved under a still pointer: what a text-tool click would+ // do there may have changed+ this.textTool.refresh();}if (@@ -5143,8 +5157,14 @@ class App extends React.Component<AppProps, AppState> {if (event.type === "pointercancel") {// the browser took the pointer over (scroll, palm rejection) — no- // pointerup will follow, so the armed bucket fill must not commit+ // pointerup will follow, so the armed bucket fill must not commit and+ // the text tool's pending center click must not resolve either. Both+ // are canceled right here, ahead of the gesture teardown that follows+ // (handleCanvasPointerCancel): that teardown first flushes a pointermove+ // the gesture has queued, and with the click still pending that move+ // would resolve it as a drag.this.bucketFill.cancel();+ this.textTool.cancel();}const wasMultiTouchGesture = gesture.pointers.size >= 2;@@ -5797,7 +5817,7 @@ class App extends React.Component<AppProps, AppState> {// the toggle changes what a text-tool click at the current position// would do, with no pointermove to refresh the affordance- this.arrowText.refresh();+ this.textTool.refresh(event);maybeHandleArrowPointlikeDrag({ app: this, event });}@@ -6082,7 +6102,7 @@ class App extends React.Component<AppProps, AppState> {this.setState({ isBindingEnabled: preferenceEnabled });});- this.arrowText.refresh();+ this.textTool.refresh(event);}maybeHandleArrowPointlikeDrag({ app: this, event });@@ -6230,9 +6250,6 @@ class App extends React.Component<AppProps, AppState> {? prevState.selectedLinearElement: null,frameToHighlight: null,- // only the text tool offers arrow-endpoint binding, and the highlight- // is refreshed on pointermove — don't leave a stale one behind- hoveredArrowTextAnchor: null,} as const;if (nextActiveTool.type === "freedraw") {@@ -6862,14 +6879,13 @@ class App extends React.Component<AppProps, AppState> {});}+ /**+ * The text container at a position — an arrow hit on its path, any other+ * container hit anywhere in its bounds (frames are skipped so a container+ * inside one can be hit). Purely positional: the selection plays no part.+ */getTextBindableContainerAtPosition(x: number, y: number) {const elements = this.scene.getNonDeletedElements();- const selectedElements = this.scene.getSelectedElements(this.state);- if (selectedElements.length === 1) {- return isTextBindableContainer(selectedElements[0], false)- ? selectedElements[0]- : null;- }let hitElement = null;// We need to do hit testing from front (end of the array) to back (beginning of the array)for (let index = elements.length - 1; index >= 0; --index) {@@ -6931,6 +6947,7 @@ class App extends React.Component<AppProps, AppState> {autoEdit = true,initialCaretSceneCoords,arrowEndpoint,+ textElement,}: {/** X position to insert text at */sceneX: number;@@ -6946,6 +6963,13 @@ class App extends React.Component<AppProps, AppState> {* dictates the text's position and alignment, overriding (sceneX, sceneY)*/arrowEndpoint?: ArrowEndpoint | null;+ /**+ * the text to edit: an element to edit exactly that one; `null` to always+ * create, never adopting a selected text or one under the pointer;+ * `undefined` to resolve it here — a single selected text, the label of a+ * selected or passed arrow container, else the text at (sceneX, sceneY)+ */+ textElement?: NonDeleted<ExcalidrawTextElement> | null;}) => {let shouldBindToContainer = false;@@ -6989,6 +7013,8 @@ class App extends React.Component<AppProps, AppState> {}const existingTextElement = arrowEndpointBinding? null+ : textElement !== undefined+ ? textElement: this.getSelectedTextElement(container) ||(container && isArrowElement(container)? getBoundTextElement(@@ -7114,13 +7140,12 @@ class App extends React.Component<AppProps, AppState> {shouldBindToContainer && container && isArrowElement(container)? DEFAULT_BOUND_TEXT_LABEL_POSITION: null,- groupIds: container?.groupIds ?? [],+ groupIds: shouldBindToContainer ? container?.groupIds ?? [] : [],lineHeight,- angle: container- ? isArrowElement(container)- ? (0 as Radians)- : container.angle- : (0 as Radians),+ angle:+ shouldBindToContainer && container && !isArrowElement(container)+ ? container.angle+ : (0 as Radians),frameId,});@@ -7154,7 +7179,8 @@ class App extends React.Component<AppProps, AppState> {);}- if (autoEdit || existingTextElement || container) {+ // A nearby container only skips drag sizing when the text binds to it.+ if (autoEdit || existingTextElement || shouldBindToContainer) {this.handleTextWysiwyg(element, {isExistingElement: !!existingTextElement,initialCaretSceneCoords: existingTextElement@@ -7390,7 +7416,13 @@ class App extends React.Component<AppProps, AppState> {const container =// skip binding to container on dblclick when holding ctrl!event[KEYS.CTRL_OR_CMD] &&- this.getTextBindableContainerAtPosition(sceneX, sceneY);+ // a single selected element is what the double-click is about —+ // typing into it — wherever the click lands+ (selectedElements.length === 1+ ? isTextBindableContainer(selectedElements[0], false)+ ? selectedElements[0]+ : null+ : this.getTextBindableContainerAtPosition(sceneX, sceneY));if (container) {if (@@ -7861,12 +7893,7 @@ class App extends React.Component<AppProps, AppState> {this.updateMultiTouchGesture(event);- if (- this.pan.isSpaceHeld() ||- this.pan.isActive() ||- isDraggingScrollBar ||- isHandToolActive(this.state)- ) {+ if (this.pan.isNavigating()) {return;}@@ -7897,6 +7924,12 @@ class App extends React.Component<AppProps, AppState> {isOverScrollBar,);+ const textToolTarget = this.textTool.updateHover(+ scenePointer,+ event,+ isOverScrollBar,+ );+if (!this.state.newElement &&isActiveToolNonLinearSnappable(this.state.activeTool.type)@@ -8283,9 +8316,6 @@ class App extends React.Component<AppProps, AppState> {hitElement = hitElementMightBeLocked;}- const hoveredArrowTextAnchor =- this.arrowText.updateHoveredAnchor(scenePointer);-if (!this.handleIframeLikeElementHover({hitElement,@@ -8312,13 +8342,7 @@ class App extends React.Component<AppProps, AppState> {) {this.setState({ showHyperlinkPopup: "info" });} else if (this.state.activeTool.type === "text") {- this.cursor.set(- hoveredArrowTextAnchor- ? CURSOR_TYPE.POINTER- : isTextElement(hitElement)- ? CURSOR_TYPE.TEXT- : CURSOR_TYPE.CROSSHAIR,- );+ this.cursor.set(this.textTool.cursorFor(textToolTarget));} else if (!event[KEYS.CTRL_OR_CMD] &&this.isHittingCommonBoundingBoxOfSelectedElements(@@ -8967,7 +8991,7 @@ class App extends React.Component<AppProps, AppState> {pointerDownState.hit.wasAddedToSelection = true;}} else if (this.state.activeTool.type === "text") {- this.handleTextOnPointerDown(event, pointerDownState);+ this.textTool.handlePointerDown(event, pointerDownState);} else if (this.state.activeTool.type === "arrow" ||this.state.activeTool.type === "line"@@ -9061,6 +9085,19 @@ class App extends React.Component<AppProps, AppState> {}};+ /**+ * The browser took the pointer over (scroll, pinch, palm rejection): no+ * pointerup will follow, so the gesture is torn down here and now — the+ * same cleanup a lost pointerup gets at the next press, only not left+ * lying in wait for it, where its replay would tangle with that press.+ */+ private handleCanvasPointerCancel = (+ event: React.PointerEvent<HTMLCanvasElement>,+ ) => {+ this.removePointer(event);+ this.maybeCleanupAfterMissingPointerUp(event.nativeEvent);+ };+private handleCanvasPointerUp = (event: React.PointerEvent<HTMLCanvasElement>,) => {@@ -9846,84 +9883,6 @@ class App extends React.Component<AppProps, AppState> {);}- private handleTextOnPointerDown = (- event: React.PointerEvent<HTMLElement>,- pointerDownState: PointerDownState,- ): void => {- // if we're currently still editing text, clicking outside- // should only finalize it, not create another (irrespective- // of state.activeTool.locked)- if (this.state.editingTextElement) {- return;- }- let sceneX = pointerDownState.origin.x;- let sceneY = pointerDownState.origin.y;-- // the click transitions into text editing either way, consuming (or- // bypassing) whatever anchor was highlighted — don't leave it lingering- // under the editor, which outlives the hover when the tool is locked- this.setState({ hoveredArrowTextAnchor: null });-- // a free arrow endpoint takes precedence over adding a label *to* the- // arrow — it's the smaller, more deliberate target- const arrowEndpoint = this.arrowText.getBindableEndpointAtPosition(- sceneX,- sceneY,- );-- if (arrowEndpoint) {- this.startTextEditing({- sceneX,- sceneY,- // the binding fixes the position, but the width is still the user's- // to drag out (see `getEndpointBoundTextDragAnchor`)- autoEdit: false,- arrowEndpoint,- });- } else {- const element = this.getElementAtPosition(sceneX, sceneY, {- includeBoundTextElement: true,- });-- // FIXME- let container = this.getTextBindableContainerAtPosition(sceneX, sceneY);-- if (hasBoundTextElement(element)) {- container = element as NonDeleted<ExcalidrawTextContainer>;- const labelCenter = this.arrowText.getLabelCenter(element);- if (labelCenter) {- sceneX = labelCenter.x;- sceneY = labelCenter.y;- } else {- sceneX = element.x + element.width / 2;- sceneY = element.y + element.height / 2;- }- }- this.startTextEditing({- sceneX,- sceneY,- insertAtParentCenter: !event.altKey,- container,- autoEdit: false,- initialCaretSceneCoords: { x: sceneX, y: sceneY },- });- }-- if (!this.isToolLocked()) {- this.setState(- {- activeTool: updateActiveTool(this.state, {- type: this.state.preferredSelectionTool.type,- }),- },- // reset once the tool revert has settled- () => this.cursor.reset(),- );- } else {- this.cursor.reset();- }- };-private handleFreeDrawElementOnPointerDown = (event: React.PointerEvent<HTMLElement>,elementType: ExcalidrawFreeDrawElement["type"],@@ -10737,6 +10696,10 @@ class App extends React.Component<AppProps, AppState> {return;}+ if (this.textTool.handlePointerMove(event, pointerDownState)) {+ return;+ }+if (isEraserActive(this.state)) {this.handleEraser(event, pointerCoords);return;@@ -11451,11 +11414,14 @@ class App extends React.Component<AppProps, AppState> {pointerDownState.eventListeners.onMove.flush();}+ this.textTool.handlePointerUp(childEvent, pointerDownState);+// an armed bucket fill commits only on a GENUINE pointer up. The// missing-pointer-up cleanup replays this handler with the pointer// DOWN event (e.g. when a second finger lands mid-press — pinch/pan- // intent), and a tool switch mid-press orphans the click — both must- // discard the fill instead of committing an unwanted edit.+ // intent) or with a pointercancel, and a tool switch mid-press orphans+ // the click — all must discard the fill instead of committing an+ // unwanted edit.if (childEvent.type === "pointerup" &&this.state.activeTool.type === TOOL_TYPE.bucketfill@@ -12524,6 +12490,12 @@ class App extends React.Component<AppProps, AppState> {}if (+ // only a genuine pointerup is a click of the tool, which reverts it.+ // A replay by the missing-pointerup cleanup — a second finger+ // landing, a pointercancel, the next press after a lost pointerup —+ // only tears the gesture down, and must leave the tool to the press+ // that follows+ childEvent.type === "pointerup" &&!this.isToolLocked() &&activeTool.type !== "freedraw" &&// bucket fill stays active for back-to-back fills regardless of the@@ -13361,7 +13333,7 @@ class App extends React.Component<AppProps, AppState> {);};- private maybeDragNewGenericElement = (+ public maybeDragNewGenericElement = (pointerDownState: PointerDownState,event: MouseEvent | KeyboardEvent,informMutation = true,diff --git a/packages/excalidraw/components/canvases/InteractiveCanvas.tsx b/packages/excalidraw/components/canvases/InteractiveCanvas.tsxindex 0c43856d57..cf5bb14641 100644--- a/packages/excalidraw/components/canvases/InteractiveCanvas.tsx+++ b/packages/excalidraw/components/canvases/InteractiveCanvas.tsx@@ -254,7 +254,7 @@ const getRelevantAppStateProps = (isMidpointSnappingEnabled: appState.isMidpointSnappingEnabled,gridModeEnabled: appState.gridModeEnabled,suggestedBinding: appState.suggestedBinding,- hoveredArrowTextAnchor: appState.hoveredArrowTextAnchor,+ textToolHover: appState.textToolHover,isRotating: appState.isRotating,elementsToHighlight: appState.elementsToHighlight,collaborators: appState.collaborators, // Necessary for collab. sessionsdiff --git a/packages/excalidraw/renderer/interactiveScene.ts b/packages/excalidraw/renderer/interactiveScene.tsindex f9d088db67..4976670441 100644--- a/packages/excalidraw/renderer/interactiveScene.ts+++ b/packages/excalidraw/renderer/interactiveScene.ts@@ -41,6 +41,7 @@ import {isLinearElement,isLineElement,isTextElement,+ getTextElementWithAccuratePosition,LinearElementEditor,maxBindingDistance_simple,getActiveTextElement,@@ -215,41 +216,6 @@ const highlightPoint = <Point extends LocalPoint | GlobalPoint>(context.restore();};-/**- * Marks where on the hovered arrow the text tool would attach text — a free- * endpoint, or the midpoint the arrow's label would center on.- *- * Purely presentational: `AppArrowText` maintains the anchor at every event- * that can change it (pointermove, the ctrl/cmd binding toggle, pointerdown,- * tool switches, finalize). The element lookup below only guards against the- * arrow vanishing through channels no local event covers, e.g. a collaborator- * deleting it.- */-const renderHoveredArrowTextAnchor = (- context: CanvasRenderingContext2D,- appState: InteractiveCanvasAppState,- elementsMap: ElementsMap,-) => {- const { elementId, anchor } = appState.hoveredArrowTextAnchor!;-- const element = elementsMap.get(elementId);-- if (!element || !isArrowElement(element) || element.isDeleted) {- return;- }-- const point =- anchor === "label"- ? LinearElementEditor.getBoundTextElementCenter(element, elementsMap)- : LinearElementEditor.getPointAtIndexGlobalCoordinates(- element,- anchor === "start" ? 0 : -1,- elementsMap,- );-- highlightPoint(point, context, appState);-};-const renderSingleLinearPoint = <Point extends GlobalPoint | LocalPoint>(context: CanvasRenderingContext2D,appState: InteractiveCanvasAppState,@@ -1531,6 +1497,85 @@ const renderTextBox = (context.restore();};+/**+ * The text tool's hover affordance — what a click would act on (see+ * `AppTextTool`): a dashed box around the text it would edit, the binding+ * outline around the empty container it would label, or a point on the arrow+ * anchor (free endpoint / midpoint label) it would attach text to.+ *+ * Purely presentational: `AppTextTool` keeps the state current at every event+ * that can change it. The element lookup only guards against the element+ * vanishing through channels no local event covers, e.g. a collaborator+ * deleting it.+ */+const renderTextToolHover = (+ app: AppClassProperties,+ context: CanvasRenderingContext2D,+ appState: InteractiveCanvasAppState,+ elementsMap: NonDeletedSceneElementsMap,+ selectionColor: InteractiveCanvasRenderConfig["selectionColor"],+) => {+ const hover = appState.textToolHover!;+ const element = elementsMap.get(hover.elementId);+ if (!element || element.isDeleted) {+ return;+ }+ switch (hover.type) {+ case "text": {+ if (isTextElement(element)) {+ // the same subtle box as around a wrapped text being edited; a+ // label's stored coords can be stale, so derive them+ renderTextBox(+ getTextElementWithAccuratePosition(element, elementsMap),+ context,+ appState,+ selectionColor,+ );+ }+ return;+ }+ case "container": {+ if (isBindableElement(element)) {+ // the outline arrow binding shows, minus its animation and its+ // `isBindingEnabled` gate: the resolved target already accounts for+ // the modifier, independently of the arrow-binding preference+ context.save();+ context.translate(appState.scrollX, appState.scrollY);+ renderBindingHighlightForBindableElement_simple(+ context,+ { element },+ elementsMap,+ appState,+ app.lastPointerMoveCoords+ ? pointFrom<GlobalPoint>(+ app.lastPointerMoveCoords.x,+ app.lastPointerMoveCoords.y,+ )+ : null,+ );+ context.restore();+ }+ return;+ }+ case "arrow": {+ if (isArrowElement(element)) {+ const point =+ hover.anchor === "label"+ ? LinearElementEditor.getBoundTextElementCenter(+ element,+ elementsMap,+ )+ : LinearElementEditor.getPointAtIndexGlobalCoordinates(+ element,+ hover.anchor === "start" ? 0 : -1,+ elementsMap,+ );+ highlightPoint(point, context, appState);+ }+ }+ }+};+const renderResetAutoResizeHandle = (text: ExcalidrawTextElement,context: CanvasRenderingContext2D,@@ -1694,8 +1739,14 @@ const _renderInteractiveScene = ({};}- if (appState.hoveredArrowTextAnchor) {- renderHoveredArrowTextAnchor(context, appState, allElementsMap);+ if (appState.textToolHover) {+ renderTextToolHover(+ app,+ context,+ appState,+ allElementsMap,+ renderConfig.selectionColor,+ );}if (appState.frameToHighlight) {diff --git a/packages/excalidraw/scene/Renderer.ts b/packages/excalidraw/scene/Renderer.tsindex 34f75aa59c..ba7a8f9d42 100644--- a/packages/excalidraw/scene/Renderer.ts+++ b/packages/excalidraw/scene/Renderer.ts@@ -360,8 +360,16 @@ export class Renderer {public getRenderableElements = (opts: GetRenderableElementsOpts) => {const { newElement } = opts;+ // A new element being drag-sized is mutated in place without informing+ // the scene, so `sceneNonce` doesn't move. Fold the element's own nonce+ // in where a canvas draws it from the live element but memoizes on this+ // nonce: a framed new element stays in the static canvas' element map+ // (see getRenderableElementsMap), and a new text gets its dashed text box+ // drawn by the interactive canvas (it doubles as `editingTextElement`).const canvasNonce = `${this.scene.getSceneNonce()}${- newElement?.frameId ? `:${newElement.versionNonce}` : ""+ newElement?.frameId || isTextElement(newElement)+ ? `:${newElement.versionNonce}`+ : ""}`;const ret = this._getRenderableElements({diff --git a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snapindex ad21e641f9..1321699b20 100644--- a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap+++ b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap@@ -940,7 +940,6 @@ exports[`contextMenu element > right-clicking on a group should select whole gro"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -998,6 +997,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1154,7 +1154,6 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1206,6 +1205,7 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": {"message": "Added to library",@@ -1383,7 +1383,6 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1435,6 +1434,7 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1731,7 +1731,6 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1783,6 +1782,7 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2079,7 +2079,6 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2131,6 +2130,7 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": {"message": "Copied styles.",@@ -2308,7 +2308,6 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2358,6 +2357,7 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2564,7 +2564,6 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2616,6 +2615,7 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2879,7 +2879,6 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2936,6 +2935,7 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3268,7 +3268,6 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3320,6 +3319,7 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": {"message": "Copied styles.",@@ -3805,7 +3805,6 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3857,6 +3856,7 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4145,7 +4145,6 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4197,6 +4196,7 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4485,7 +4485,6 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4540,6 +4539,7 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5787,7 +5787,6 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5842,6 +5841,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7021,7 +7021,6 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7078,6 +7077,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7995,7 +7995,6 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8048,6 +8047,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9008,7 +9008,6 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9060,6 +9059,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10012,7 +10012,6 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap"gridSize": 20,"gridStep": 5,"height": 100,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10067,6 +10066,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snapindex 4bcd7ace1b..f8a0b34d49 100644--- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap+++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap@@ -66,7 +66,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -117,6 +116,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -719,7 +719,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -770,6 +769,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1299,7 +1299,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1349,6 +1348,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1677,7 +1677,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1727,6 +1726,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2056,7 +2056,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2106,6 +2105,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2336,7 +2336,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2385,6 +2384,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2808,7 +2808,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2858,6 +2857,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3132,7 +3132,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3182,6 +3181,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3474,7 +3474,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3524,6 +3523,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3788,7 +3788,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3838,6 +3837,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4092,7 +4092,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4142,6 +4141,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4344,7 +4344,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4394,6 +4393,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4619,7 +4619,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4669,6 +4668,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4910,7 +4910,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4960,6 +4959,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5156,7 +5156,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5206,6 +5205,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5402,7 +5402,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5452,6 +5451,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5667,7 +5667,6 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5717,6 +5716,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5943,7 +5943,6 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5993,6 +5992,7 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -6217,7 +6217,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -6266,6 +6265,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -6563,7 +6563,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -6612,6 +6611,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7009,7 +7009,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7061,6 +7060,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7402,7 +7402,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7460,6 +7459,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7731,7 +7731,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7778,6 +7777,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8038,7 +8038,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8085,6 +8084,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8283,7 +8283,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8330,6 +8329,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8654,7 +8654,6 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8701,6 +8700,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9025,7 +9025,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9078,6 +9077,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9449,7 +9449,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9496,6 +9495,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9752,7 +9752,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9801,6 +9800,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10032,7 +10032,6 @@ exports[`history > multiplayer undo/redo > should not override remote changes on"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10081,6 +10080,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10313,7 +10313,6 @@ exports[`history > multiplayer undo/redo > should not override remote changes on"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10362,6 +10361,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10560,7 +10560,6 @@ exports[`history > multiplayer undo/redo > should override remotely added groups"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10610,6 +10609,7 @@ exports[`history > multiplayer undo/redo > should override remotely added groups"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10874,7 +10874,6 @@ exports[`history > multiplayer undo/redo > should override remotely added points"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10923,6 +10922,7 @@ exports[`history > multiplayer undo/redo > should override remotely added points"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -11206,7 +11206,6 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -11253,6 +11252,7 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -11457,7 +11457,6 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -11507,6 +11506,7 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12401,7 +12401,6 @@ exports[`history > multiplayer undo/redo > should update history entries after r"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12450,6 +12449,7 @@ exports[`history > multiplayer undo/redo > should update history entries after r"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12676,7 +12676,6 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12723,6 +12722,7 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12927,7 +12927,6 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12976,6 +12975,7 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13180,7 +13180,6 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13227,6 +13226,7 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13601,7 +13601,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on e"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13653,6 +13652,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on e"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13826,7 +13826,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on e"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13875,6 +13874,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on e"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -14048,7 +14048,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on i"gridSize": 20,"gridStep": 5,"height": 1000,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14101,6 +14100,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on i"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -14366,7 +14366,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on i"gridSize": 20,"gridStep": 5,"height": 1000,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14416,6 +14415,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on i"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -14681,7 +14681,6 @@ exports[`history > singleplayer undo/redo > should create new history entry on s"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14731,6 +14730,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on s"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#000",@@ -14942,7 +14942,6 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14991,6 +14990,7 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15195,7 +15195,6 @@ exports[`history > singleplayer undo/redo > should end up with no history entry"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15244,6 +15243,7 @@ exports[`history > singleplayer undo/redo > should end up with no history entry"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15448,7 +15448,6 @@ exports[`history > singleplayer undo/redo > should iterate through the history w"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15497,6 +15496,7 @@ exports[`history > singleplayer undo/redo > should iterate through the history w"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15710,7 +15710,6 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15759,6 +15758,7 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -16058,7 +16058,6 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -16108,6 +16107,7 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -16242,7 +16242,6 @@ exports[`history > singleplayer undo/redo > should not end up with history entry"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -16294,6 +16293,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -16543,7 +16543,6 @@ exports[`history > singleplayer undo/redo > should not end up with history entry"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -16593,6 +16592,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -16823,7 +16823,6 @@ exports[`history > singleplayer undo/redo > should not modify anything on unrela"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -16873,6 +16872,7 @@ exports[`history > singleplayer undo/redo > should not modify anything on unrela"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -16990,7 +16990,6 @@ exports[`history > singleplayer undo/redo > should not override appstate changes"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -17041,6 +17040,7 @@ exports[`history > singleplayer undo/redo > should not override appstate changes"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -17287,7 +17287,6 @@ exports[`history > singleplayer undo/redo > should support appstate name or view"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -17337,6 +17336,7 @@ exports[`history > singleplayer undo/redo > should support appstate name or view"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#000",@@ -17462,7 +17462,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -17513,6 +17512,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -18235,7 +18235,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -18286,6 +18285,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -18906,7 +18906,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -18957,6 +18956,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -19577,7 +19577,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -19626,6 +19625,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -20351,7 +20351,6 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -20403,6 +20402,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -21144,7 +21144,6 @@ exports[`history > singleplayer undo/redo > should support changes in elements'"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -21196,6 +21195,7 @@ exports[`history > singleplayer undo/redo > should support changes in elements'"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -21643,7 +21643,6 @@ exports[`history > singleplayer undo/redo > should support duplication of groups"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -21697,6 +21696,7 @@ exports[`history > singleplayer undo/redo > should support duplication of groups"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -22177,7 +22177,6 @@ exports[`history > singleplayer undo/redo > should support element creation, del"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -22226,6 +22225,7 @@ exports[`history > singleplayer undo/redo > should support element creation, del"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -22655,7 +22655,6 @@ exports[`history > singleplayer undo/redo > should support linear element creati"gridSize": 20,"gridStep": 5,"height": 0,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -22706,6 +22705,7 @@ exports[`history > singleplayer undo/redo > should support linear element creati"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",diff --git a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snapindex ddeb2bd111..b6d7b5cab7 100644--- a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap+++ b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap@@ -66,7 +66,6 @@ exports[`given element A and group of elements B and given both are selected whe"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -125,6 +124,7 @@ exports[`given element A and group of elements B and given both are selected whe"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -508,7 +508,6 @@ exports[`given element A and group of elements B and given both are selected whe"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -569,6 +568,7 @@ exports[`given element A and group of elements B and given both are selected whe"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -940,7 +940,6 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -992,6 +991,7 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1522,7 +1522,6 @@ exports[`regression tests > Drags selected element when hitting only bounding bo"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1574,6 +1573,7 @@ exports[`regression tests > Drags selected element when hitting only bounding bo"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -1743,7 +1743,6 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -1800,6 +1799,7 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2143,7 +2143,6 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2197,6 +2196,7 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2403,7 +2403,6 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = `"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2455,6 +2454,7 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = `"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2597,7 +2597,6 @@ exports[`regression tests > can drag element that covers another element, while"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2651,6 +2650,7 @@ exports[`regression tests > can drag element that covers another element, while"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -2938,7 +2938,6 @@ exports[`regression tests > change the properties of a shape > [end of test] app"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -2990,6 +2989,7 @@ exports[`regression tests > change the properties of a shape > [end of test] app"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3207,7 +3207,6 @@ exports[`regression tests > click on an element and drag it > [dragged] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3261,6 +3260,7 @@ exports[`regression tests > click on an element and drag it > [dragged] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3463,7 +3463,6 @@ exports[`regression tests > click on an element and drag it > [end of test] appS"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3517,6 +3516,7 @@ exports[`regression tests > click on an element and drag it > [end of test] appS"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3713,7 +3713,6 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`]"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -3767,6 +3766,7 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`]"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -3986,7 +3986,6 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4041,6 +4040,7 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4316,7 +4316,6 @@ exports[`regression tests > deleting last but one element in editing group shoul"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4370,6 +4369,7 @@ exports[`regression tests > deleting last but one element in editing group shoul"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -4767,7 +4767,6 @@ exports[`regression tests > deselects group of selected elements on pointer down"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -4849,6 +4848,7 @@ exports[`regression tests > deselects group of selected elements on pointer down"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5066,7 +5066,6 @@ exports[`regression tests > deselects group of selected elements on pointer up w"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5119,6 +5118,7 @@ exports[`regression tests > deselects group of selected elements on pointer up w"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5357,7 +5357,6 @@ exports[`regression tests > deselects selected element on pointer down when poin"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5438,6 +5437,7 @@ exports[`regression tests > deselects selected element on pointer down when poin"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5580,7 +5580,6 @@ exports[`regression tests > deselects selected element, on pointer up, when clic"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5632,6 +5631,7 @@ exports[`regression tests > deselects selected element, on pointer up, when clic"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -5794,7 +5794,6 @@ exports[`regression tests > double click to edit a group > [end of test] appStat"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -5846,6 +5845,7 @@ exports[`regression tests > double click to edit a group > [end of test] appStat"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -6203,7 +6203,6 @@ exports[`regression tests > drags selected elements from point inside common bou"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -6259,6 +6258,7 @@ exports[`regression tests > drags selected elements from point inside common bou"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -6515,7 +6515,6 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1`"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -6565,6 +6564,7 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1`"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7328,7 +7328,6 @@ exports[`regression tests > given a group of selected elements with an element t"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7383,6 +7382,7 @@ exports[`regression tests > given a group of selected elements with an element t"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7678,7 +7678,6 @@ exports[`regression tests > given a selected element A and a not selected elemen"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -7733,6 +7732,7 @@ exports[`regression tests > given a selected element A and a not selected elemen"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -7972,7 +7972,6 @@ exports[`regression tests > given selected element A with lower z-index than uns"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8026,6 +8025,7 @@ exports[`regression tests > given selected element A with lower z-index than uns"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8222,7 +8222,6 @@ exports[`regression tests > given selected element A with lower z-index than uns"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8276,6 +8275,7 @@ exports[`regression tests > given selected element A with lower z-index than uns"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8477,7 +8477,6 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8529,6 +8528,7 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8671,7 +8671,6 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8723,6 +8722,7 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -8865,7 +8865,6 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -8917,6 +8916,7 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9059,7 +9059,6 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9142,6 +9141,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9306,7 +9306,6 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9389,6 +9388,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9551,7 +9551,6 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9601,6 +9600,7 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -9761,7 +9761,6 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -9844,6 +9843,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10008,7 +10008,6 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10060,6 +10059,7 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10202,7 +10202,6 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10285,6 +10284,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10447,7 +10447,6 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10499,6 +10498,7 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10641,7 +10641,6 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10691,6 +10690,7 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -10851,7 +10851,6 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -10903,6 +10902,7 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -11045,7 +11045,6 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -11105,6 +11104,7 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -11595,7 +11595,6 @@ exports[`regression tests > noop interaction after undo shouldn't create history"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -11649,6 +11648,7 @@ exports[`regression tests > noop interaction after undo shouldn't create history"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -11890,7 +11890,6 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -11940,6 +11939,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12026,7 +12026,6 @@ exports[`regression tests > shift click on selected element should deselect it o"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12078,6 +12077,7 @@ exports[`regression tests > shift click on selected element should deselect it o"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12240,7 +12240,6 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12296,6 +12295,7 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -12574,7 +12574,6 @@ exports[`regression tests > should group elements and ungroup them > [end of tes"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -12632,6 +12631,7 @@ exports[`regression tests > should group elements and ungroup them > [end of tes"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13019,7 +13019,6 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13081,6 +13080,7 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13676,7 +13676,6 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13729,6 +13728,7 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -13815,7 +13815,6 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`]"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -13869,6 +13868,7 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`]"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -14462,7 +14462,6 @@ exports[`regression tests > switches from group of selected elements to another"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14546,6 +14545,7 @@ exports[`regression tests > switches from group of selected elements to another"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -14818,7 +14818,6 @@ exports[`regression tests > switches selected element on pointer down > [end of"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -14901,6 +14900,7 @@ exports[`regression tests > switches selected element on pointer down > [end of"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15098,7 +15098,6 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15148,6 +15147,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15234,7 +15234,6 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15286,6 +15285,7 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15614,7 +15614,6 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15664,6 +15663,7 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",@@ -15750,7 +15750,6 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = `"gridSize": 20,"gridStep": 5,"height": 768,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -15803,6 +15802,7 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = `"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",diff --git a/packages/excalidraw/tests/arrowEndpointTextBinding.test.tsx b/packages/excalidraw/tests/arrowEndpointTextBinding.test.tsxindex b0309bd7b9..6d3dab03ea 100644--- a/packages/excalidraw/tests/arrowEndpointTextBinding.test.tsx+++ b/packages/excalidraw/tests/arrowEndpointTextBinding.test.tsx@@ -1,4 +1,4 @@-import { KEYS } from "@excalidraw/common";+import { CURSOR_TYPE, KEYS } from "@excalidraw/common";import { isTextElement } from "@excalidraw/element";@@ -16,7 +16,7 @@ import { actionTextAutoResize } from "../actions/actionTextAutoResize";import { API } from "./helpers/api";import { Keyboard, Pointer, UI } from "./helpers/ui";import { getTextEditor, updateTextEditor } from "./queries/dom";-import { render, unmountComponent } from "./test-utils";+import { GlobalTestState, render, unmountComponent } from "./test-utils";unmountComponent();@@ -97,14 +97,15 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "end",});// away from the arrow entirelymouse.moveTo(400, 400);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();});it("highlights the label midpoint when hovering the arrow itself", () => {@@ -114,7 +115,8 @@ describe("binding text to an arrow endpoint", () => {// mid-arrow, clear of both endpointsmouse.moveTo(100, 200);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "label",});@@ -127,7 +129,10 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor?.anchor).toBe("end");+ expect(h.state.textToolHover).toMatchObject({+ type: "arrow",+ anchor: "end",+ });});it("does not offer a label midpoint on an arrow that already has one", () => {@@ -145,7 +150,10 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 200);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: label.id,+ });});// a click only becomes a label when it snaps to the arrow's center, so@@ -172,14 +180,15 @@ describe("binding text to an arrow endpoint", () => {// inside the bounding box but nowhere near the stroke or the midpointmouse.moveTo(150, 560);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();// on the stroke, but far from the midpointmouse.moveTo(175, 490);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();mouse.moveTo(250, 580);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "label",});@@ -191,7 +200,7 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("selection");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();});it("clears the highlight on escape", () => {@@ -199,13 +208,13 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).not.toBeNull();+ expect(h.state.textToolHover).not.toBeNull();// escape reverts the tool via the action's appState rather than// `setActiveTool`, so the highlight has to be cleared there tooKeyboard.keyPress(KEYS.ESCAPE);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();});});@@ -217,7 +226,7 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();});it("still offers the label anchor — a label is not an arrow binding", () => {@@ -227,32 +236,44 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 200);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "label",});});// the highlight is maintained at write time — the renderer draws whatever- // `hoveredArrowTextAnchor` says — so the toggle itself has to refresh the+ // `textToolHover` says — so the toggle itself has to refresh the// anchor: there is no pointermove to do itit("clears the highlight the moment ctrl is pressed, restores on release", () => {API.setElements([createArrow("arrow", [100, 300], [100, 100])]);UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).not.toBeNull();+ expect(h.state.textToolHover).not.toBeNull();+ expect(GlobalTestState.interactiveCanvas.style.cursor).toBe(+ CURSOR_TYPE.POINTER,+ );Keyboard.withModifierKeys({ ctrl: true }, () => {Keyboard.keyDown("Control");- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();+ // the cursor describes the click as much as the highlight does+ expect(GlobalTestState.interactiveCanvas.style.cursor).toBe(+ CURSOR_TYPE.CROSSHAIR,+ );});Keyboard.keyUp("Control");- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "end",});+ expect(GlobalTestState.interactiveCanvas.style.cursor).toBe(+ CURSOR_TYPE.POINTER,+ );});it("drops plain text instead of binding the endpoint", async () => {@@ -287,11 +308,12 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();// ...but the arrow can still take a label at its midpointmouse.moveTo(100, 200);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "label",});@@ -302,10 +324,10 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).not.toBeNull();+ expect(h.state.textToolHover).not.toBeNull();UI.clickTool("selection");- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toBeNull();});});@@ -630,7 +652,11 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ // ...and the rect is what the text tool offers to label+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: "rect",+ });// the click belongs to the rect, as it would without the arrow thereawait bindTextAt(100, 100, "label");@@ -647,7 +673,8 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "end",});@@ -663,7 +690,8 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "end",});@@ -695,7 +723,8 @@ describe("binding text to an arrow endpoint", () => {// and the endpoint is immediately reusableUI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: arrowId,anchor: "end",});@@ -736,11 +765,10 @@ describe("binding text to an arrow endpoint", () => {expect(getArrow("arrow").startBinding).toBeNull();});- // the text tool edits before it creates: a text that is the top-most hit- // under the cursor takes the click, so the endpoint must not be offered- // over it. Occlusion alone can't provide this — its hit test skips bound- // texts.- it("yields to a container-bound label overlapping the endpoint", async () => {+ // the text-vs-endpoint preference is z-aware: whatever is stacked above+ // owns its hit area. Here the labeled container sits above the arrow, so+ // its label takes the click and the endpoint is not offered through it.+ it("yields to a container-bound label overlapping the endpoint from above", async () => {const rect = API.createElement({type: "rectangle",id: "rect",@@ -769,7 +797,10 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toBeNull();+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: label.id,+ });// the click edits the label rather than binding the endpoint under itmouse.clickAt(100, 100);@@ -778,6 +809,98 @@ describe("binding text to an arrow endpoint", () => {expect(getArrow("arrow").endBinding).toBeNull();});+ it("yields to a free text stacked above the arrow", async () => {+ API.setElements([+ createArrow("arrow", [100, 300], [100, 100]),+ API.createElement({+ type: "text",+ id: "overlap",+ x: 95,+ y: 87.5,+ width: 50,+ height: 25,+ text: "txt",+ }),+ ]);++ UI.clickTool("text");+ mouse.moveTo(100, 100);+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: "overlap",+ });++ // the click edits the covering text+ mouse.clickAt(100, 100);+ await getTextEditor();+ expect(h.state.editingTextElement?.id).toBe("overlap");+ expect(getArrow("arrow").endBinding).toBeNull();+ });++ // ...but when the arrow is the one on top, its endpoint keeps full+ // preference over the whole hit circle — a z-blind "any text under the+ // cursor wins" rule would flicker the affordance against the text's+ // bbox edge cutting into the circle+ it("wins over a free text stacked below the arrow", async () => {+ API.setElements([+ API.createElement({+ type: "text",+ id: "overlap",+ x: 95,+ y: 87.5,+ width: 50,+ height: 25,+ text: "txt",+ }),+ createArrow("arrow", [100, 300], [100, 100]),+ ]);++ UI.clickTool("text");+ mouse.moveTo(100, 100);+ expect(h.state.textToolHover).toEqual({+ type: "arrow",+ elementId: "arrow",+ anchor: "end",+ });++ // the click binds a fresh text to the endpoint; the covering text is+ // left alone+ const editor = await bindTextAt(100, 100, "bound");+ Keyboard.exitTextEditor(editor);+ const boundText = h.elements.find(+ (el): el is ExcalidrawTextElement =>+ el.type === "text" && el.id !== "overlap",+ )!;+ expect(boundText.text).toBe("bound");+ expect(getArrow("arrow").endBinding?.elementId).toBe(boundText.id);+ });++ it("keeps the endpoint while crossing the covered text's edge inside the hit circle", () => {+ API.setElements([+ API.createElement({+ type: "text",+ id: "overlap",+ x: 95,+ y: 87.5,+ width: 50,+ height: 25,+ text: "txt",+ }),+ createArrow("arrow", [100, 300], [100, 100]),+ ]);++ UI.clickTool("text");+ // the text's left edge is at x=95; the endpoint's hit circle spans it+ for (const x of [98, 96, 95, 94, 92]) {+ mouse.moveTo(x, 100);+ expect(h.state.textToolHover).toEqual({+ type: "arrow",+ elementId: "arrow",+ anchor: "end",+ });+ }+ });+it("creates a fresh text instead of adopting the selected one", async () => {// with a text selected, a text-tool click normally edits that text no// matter where the click lands — but a click on an endpoint promises a@@ -825,7 +948,8 @@ describe("binding text to an arrow endpoint", () => {UI.clickTool("text");mouse.moveTo(100, 100);- expect(h.state.hoveredArrowTextAnchor).toEqual({+ expect(h.state.textToolHover).toEqual({+ type: "arrow",elementId: "arrow",anchor: "end",});diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.tsindex 17b6e455d9..3a37d94ee9 100644--- a/packages/excalidraw/types.ts+++ b/packages/excalidraw/types.ts@@ -234,7 +234,7 @@ export type InteractiveCanvasAppState = Readonly<isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];gridModeEnabled: AppState["gridModeEnabled"];suggestedBinding: AppState["suggestedBinding"];- hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];+ textToolHover: AppState["textToolHover"];isRotating: AppState["isRotating"];elementsToHighlight: AppState["elementsToHighlight"];// Collaborators@@ -386,14 +386,21 @@ export interface AppState {midPoint?: GlobalPoint;} | null;/**- * Where on a hovered arrow the text tool would attach text if clicked —- * a free endpoint (binds the arrow to a new text element positioned against- * that endpoint) or the arrow's midpoint (adds a label bound to the arrow).+ * What a text-tool click at the hovered position would act on — the text+ * it would edit, the empty container it would label, or the arrow anchor+ * (a free endpoint, or the midpoint for a label) it would attach text to.+ * `null` when the click would create free text, or the tool isn't active.+ * Drives the hover affordance only.*/- hoveredArrowTextAnchor: {- elementId: ExcalidrawArrowElement["id"];- anchor: "start" | "end" | "label";- } | null;+ textToolHover:+ | { type: "text"; elementId: ExcalidrawElement["id"] }+ | { type: "container"; elementId: ExcalidrawElement["id"] }+ | {+ type: "arrow";+ elementId: ExcalidrawArrowElement["id"];+ anchor: "start" | "end" | "label";+ }+ | null;frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;frameRendering: {enabled: boolean;@@ -405,6 +412,10 @@ export interface AppState {* frame-like element whose name is currently being edited*/editingFrame: ExcalidrawFrameLikeElement["id"] | null;+ /**+ * Elements the UI highlights with a bounding-box outline — those that+ * would get added to a frame being dragged/resized.+ */elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;/*** set when a new text is created or when an existing text is being edited@@ -602,7 +613,7 @@ export type UIAppState = Omit<| "snapLines"| "originSnapOffset"| "suggestedBinding"- | "hoveredArrowTextAnchor"+ | "textToolHover"| "frameToHighlight"| "elementsToHighlight">;@@ -1205,6 +1216,7 @@ export type AppClassProperties = {flowchart: App["flowchart"];drawShape: App["drawShape"];arrowText: App["arrowText"];+ textTool: App["textTool"];cursor: App["cursor"];bucketFill: App["bucketFill"];duplicate: App["duplicate"];diff --git a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsxindex 5ad3ee2423..a411497d0c 100644--- a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx+++ b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx@@ -4,11 +4,13 @@ import { pointFrom } from "@excalidraw/math";import {getLineHeightInPx,getOriginalContainerHeightFromCache,+ newElementWith,} from "@excalidraw/element";import {CODES,colorToHex,+ CURSOR_TYPE,KEYS,FONT_FAMILY,TEXT_ALIGN,@@ -36,6 +38,7 @@ import {} from "../tests/test-utils";import {fireEvent,+ waitFor,mockBoundingClientRect,restoreOriginalGetBoundingClientRect,} from "../tests/test-utils";@@ -275,6 +278,259 @@ describe("textWysiwyg", () => {expect(text.y).toBe(72);});+ it.each([+ { type: "rectangle", fromX: 220, toX: 380, y: 230 },+ { type: "ellipse", fromX: 220, toX: 380, y: 230 },+ { type: "diamond", fromX: 220, toX: 380, y: 230 },+ { type: "rectangle", fromX: 380, toX: 220, y: 230 },+ { type: "rectangle", fromX: 350, toX: 510, y: 300 },+ { type: "ellipse", fromX: 350, toX: 510, y: 300 },+ { type: "diamond", fromX: 350, toX: 510, y: 300 },+ { type: "rectangle", fromX: 350, toX: 190, y: 300 },+ { type: "rectangle", fromX: 365, toX: 525, y: 300 },+ ] as const)(+ "should set a fixed text width when dragging inside a $type from $fromX to $toX",+ async ({ type, fromX, toX, y }) => {+ const container = API.createElement({+ type,+ x: 100,+ y: 100,+ width: 500,+ height: 400,+ });+ API.setElements([container]);+ UI.clickTool("text");++ mouse.downAt(fromX, y);+ for (let i = 1; i <= 4; i++) {+ mouse.moveTo(fromX + ((toX - fromX) * i) / 4, y);+ }+ mouse.upAt(toX, y);++ const editor = await getTextEditor();+ const originalText =+ "A label long enough to wrap within the dragged width";+ updateTextEditor(editor, originalText);+ Keyboard.exitTextEditor(editor);++ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.autoResize).toBe(false);+ expect(text.width).toBe(160);+ expect(text.x).toBe(Math.min(fromX, toX));+ expect(text.y).toBe(y);+ expect(text.containerId).toBe(null);+ expect(text.textAlign).toBe(TEXT_ALIGN.LEFT);+ expect(text.originalText).toBe(originalText);+ expect(text.text).toContain("\n");+ expect(container.boundElements).toBe(null);+ },+ );++ it.each([0, 10])(+ "should bind text on a center click with %s pixels of pointer movement",+ async (deltaX) => {+ const container = API.createElement({+ type: "rectangle",+ x: 100,+ y: 100,+ width: 500,+ height: 400,+ });+ API.setElements([container]);+ UI.clickTool("text");++ mouse.downAt(350, 300);+ expect(h.elements).toEqual([container]);+ expect(await getTextEditor({ waitForEditor: false })).toBe(null);+ // the pending click keeps advertising the bind until it resolves+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: container.id,+ });+ mouse.moveTo(350 + deltaX, 300);+ mouse.upAt(350 + deltaX, 300);++ const editor = await getTextEditor();+ updateTextEditor(editor, "Label");+ Keyboard.exitTextEditor(editor);++ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.containerId).toBe(container.id);+ expect(text.textAlign).toBe(TEXT_ALIGN.CENTER);+ expect(text.verticalAlign).toBe(VERTICAL_ALIGN.MIDDLE);+ expect(container.boundElements).toEqual([+ { id: text.id, type: "text" },+ ]);+ },+ );++ it("should not resize a small shape when dragging text from its center", async () => {+ const container = API.createElement({+ type: "rectangle",+ x: 100,+ y: 100,+ width: 10,+ height: 10,+ });+ API.setElements([container]);+ UI.clickTool("text");++ mouse.downAt(105, 105);+ mouse.moveTo(185, 105);+ mouse.moveTo(265, 105);+ mouse.upAt(265, 105);++ const editor = await getTextEditor();+ updateTextEditor(editor, "Free text");+ Keyboard.exitTextEditor(editor);++ expect(container.width).toBe(10);+ expect(container.height).toBe(10);+ expect(container.boundElements).toBe(null);+ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(text.autoResize).toBe(false);+ expect(text.width).toBe(160);+ });++ it("should cancel a pending center click when switching tools", async () => {+ const container = API.createElement({ type: "rectangle" });+ API.setElements([container]);+ UI.clickTool("text");++ mouse.downAt(50, 50);+ Keyboard.keyPress(KEYS.ESCAPE);+ mouse.upAt(50, 50);++ expect(h.elements).toEqual([container]);+ expect(container.boundElements).toBe(null);+ expect(await getTextEditor({ waitForEditor: false })).toBe(null);+ });++ it("should clear binding highlights when a locked text tool starts a center drag", async () => {+ const container = API.createElement({+ type: "rectangle",+ width: 500,+ height: 400,+ });+ API.setElements([container]);+ API.setAppState({ zoom: { value: 2 as typeof h.state.zoom.value } });+ UI.clickTool("text");+ UI.clickTool("lock");++ mouse.moveTo(500, 400);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: container.id,+ });+ mouse.downAt(500, 400);+ // At 200% zoom the drag threshold is inside the center snap radius.+ mouse.moveTo(515, 400);+ mouse.moveTo(545, 400);+ expect(h.state.newElement?.type).toBe("text");+ expect(h.state.textToolHover).toBe(null);+ mouse.moveTo(660, 400);+ mouse.upAt(660, 400);++ const editor = await getTextEditor();+ updateTextEditor(editor, "Free text");+ Keyboard.exitTextEditor(editor);+ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.width).toBe(80);+ expect(text.containerId).toBe(null);+ expect(text.autoResize).toBe(false);+ expect(h.state.activeTool.type).toBe("text");+ });++ it("should set a fixed text width when ctrl/cmd-dragging at a shape's center", async () => {+ const container = API.createElement({+ type: "rectangle",+ x: 100,+ y: 100,+ width: 500,+ height: 400,+ backgroundColor: "#a5d8ff",+ });+ API.setElements([container]);+ UI.clickTool("text");++ Keyboard.withModifierKeys({ ctrl: true }, () => {+ mouse.downAt(350, 300);+ for (let i = 1; i <= 4; i++) {+ mouse.moveTo(350 + i * 20, 300);+ }+ mouse.upAt(430, 300);+ });++ const editor = await getTextEditor();+ updateTextEditor(editor, "Hello");+ Keyboard.exitTextEditor(editor);++ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.autoResize).toBe(false);+ // one-sided from the origin (alt would resize from the center, as it+ // does for any tool)+ expect(text.width).toBe(80);+ expect(text.x).toBe(350);+ expect(text.containerId).toBe(null);+ expect(container.boundElements).toBe(null);+ });++ it.each([+ { location: "canvas", locked: false },+ { location: "canvas", locked: true },+ { location: "container center", locked: false },+ { location: "container center", locked: true },+ ])(+ "should redraw dashed text bounds while dragging from $location (tool locked: $locked)",+ async ({ location, locked }) => {+ if (location === "container center") {+ API.setElements([+ API.createElement({+ type: "rectangle",+ x: 100,+ y: 100,+ width: 500,+ height: 400,+ }),+ ]);+ }+ UI.clickTool("text");+ if (locked) {+ UI.clickTool("lock");+ }++ const context = GlobalTestState.interactiveCanvas.getContext("2d")!;+ const setLineDash = vi.spyOn(context, "setLineDash");+ const strokeRect = vi.spyOn(context, "strokeRect");++ mouse.downAt(350, 300);+ for (const width of [80, 160]) {+ setLineDash.mockClear();+ strokeRect.mockClear();+ mouse.moveTo(350 + width, 300);++ expect(setLineDash).toHaveBeenCalledWith([6, 4]);+ // The outline follows the dragged width, with 4px padding per side.+ expect(strokeRect).toHaveBeenCalledWith(+ expect.any(Number),+ expect.any(Number),+ width + 8,+ 33,+ );+ }+ mouse.upAt(510, 300);++ const editor = await getTextEditor();+ updateTextEditor(editor, "Free text");+ Keyboard.exitTextEditor(editor);+ expect(h.state.activeTool.locked).toBe(locked);+ expect(h.state.activeTool.type).toBe(locked ? "text" : "selection");+ setLineDash.mockRestore();+ strokeRect.mockRestore();+ },+ );+it("should edit text under cursor when double-clicked with selection tool", async () => {const text = API.createElement({type: "text",@@ -1814,6 +2070,636 @@ describe("textWysiwyg", () => {expect(text.text).toBe("Excalidraw");});+ it("shouldn't inherit groupIds or angle when creating unbound text inside a grouped/rotated container", async () => {+ const groupedRectangle = API.createElement({+ type: "rectangle",+ x: 10,+ y: 20,+ width: 90,+ height: 75,+ groupIds: ["group1"],+ angle: 0.3,+ });+ API.setElements([groupedRectangle]);++ UI.clickTool("text");+ // click inside the container but away from its center so the text+ // doesn't bind to it+ mouse.clickAt(90, 57.5);++ const editor = await getTextEditor();+ updateTextEditor(editor, "Hello");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(2);+ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(text.groupIds).toEqual([]);+ expect(text.angle).toBe(0);+ });++ it("should edit the existing label only when clicking on the label itself", async () => {+ // create a centered label ("Hello!" → 60x25 label centered in the+ // 90x75 rectangle at (10, 20), so the label bbox is (25, 45)-(85, 70))+ Keyboard.keyPress(KEYS.ENTER);+ let editor = await getTextEditor();+ updateTextEditor(editor, "Hello!");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(2);+ const label = h.elements[1] as ExcalidrawTextElementWithContainer;+ expect(label.containerId).toBe(rectangle.id);++ // clicking on the label itself should edit it+ UI.clickTool("text");+ mouse.clickAt(55, 57.5);+ editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).toBe(label.id);+ Keyboard.exitTextEditor(editor);+ expect(h.elements.length).toBe(2);++ // clicking inside the container but off the label should create+ // a free text at the clicked position instead+ UI.clickTool("text");+ mouse.clickAt(20, 30);+ editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).not.toBe(label.id);+ updateTextEditor(editor, "Excalidraw");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(3);+ expect(rectangle.boundElements).toStrictEqual([+ { id: label.id, type: "text" },+ ]);+ const text = h.elements[2] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(text.text).toBe("Excalidraw");+ // created at the clicked position (first line box centered on cursor),+ // not warped to the container or label center+ expect(text.x).toBe(20);+ expect(text.y).toBe(17.5);+ });++ it.each(["mouse", "pen", "touch"] as const)(+ "should allow dragging a free text box inside a labeled container with %s",+ async (pointerType) => {+ API.updateElement(rectangle, { width: 500, height: 400 });+ Keyboard.keyPress(KEYS.ENTER);+ let editor = await getTextEditor();+ updateTextEditor(editor, "Hello!");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(2);+ const label = h.elements[1] as ExcalidrawTextElementWithContainer;++ UI.clickTool("text");+ const pointer = new Pointer(pointerType);+ pointer.downAt(110, 120);+ pointer.moveTo(175, 120);+ pointer.moveTo(240, 120);+ pointer.up();++ editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).not.toBe(label.id);+ updateTextEditor(editor, "Excalidraw");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(3);+ expect(rectangle.boundElements).toStrictEqual([+ { id: label.id, type: "text" },+ ]);+ const text = h.elements[2] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(text.autoResize).toBe(false);+ expect(text.width).toBe(130);+ expect(text.x).toBe(110);+ expect(text.y).toBe(120);+ expect(label.originalText).toBe("Hello!");+ },+ );++ it("should highlight an empty container the text tool would bind to on hover", async () => {+ UI.clickTool("text");++ // near the container center → click would bind to it, shown with the+ // same binding highlight as arrow binding+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ // ctrl/cmd opts out of binding, so no highlight either+ Keyboard.withModifierKeys({ ctrl: true }, () => {+ mouse.moveTo(54, 57.5);+ expect(h.state.textToolHover).toBe(null);+ });++ // off-center → click would create a free text+ mouse.moveTo(20, 30);+ expect(h.state.textToolHover).toBe(null);+ });++ it("should edit the arrow label when clicking on the label with the text tool", async () => {+ const arrow = API.createElement({+ type: "arrow",+ x: 200,+ y: 200,+ width: 300,+ height: 0,+ points: [pointFrom(0, 0), pointFrom(300, 0)],+ });+ const label = API.createElement({+ type: "text",+ text: "label",+ x: 325,+ y: 187.5,+ width: 50,+ height: 25,+ containerId: arrow.id,+ });+ API.setElements([arrow, label]);+ API.updateElement(arrow, {+ boundElements: [{ type: "text", id: label.id }],+ });++ // clicking the label itself should edit it+ UI.clickTool("text");+ mouse.clickAt(350, 200);+ let editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).toBe(label.id);+ Keyboard.exitTextEditor(editor);++ // Click off the label and outside the endpoint hit circles.+ UI.clickTool("text");+ mouse.clickAt(300, 200);+ editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).not.toBe(label.id);+ updateTextEditor(editor, "free");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(3);+ expect((h.elements[2] as ExcalidrawTextElement).containerId).toBe(null);+ expect(arrow.boundElements).toStrictEqual([+ { id: label.id, type: "text" },+ ]);+ expect(arrow.startBinding).toBe(null);+ expect(arrow.endBinding).toBe(null);+ });++ it.each([null, 0.25, 0.75])(+ "should hit the arrow label at its derived position after the arrow moves (labelPosition: %s)",+ async (labelPosition) => {+ const arrow = API.createElement({+ type: "arrow",+ x: 200,+ y: 200,+ width: 400,+ height: 0,+ points: [pointFrom(0, 0), pointFrom(400, 0)],+ });+ // Stored at the original midpoint; moved labels derive their position.+ const label = API.createElement({+ type: "text",+ text: "label",+ x: 375,+ y: 187.5,+ width: 50,+ height: 25,+ containerId: arrow.id,+ });+ API.setElements([arrow, label]);+ API.updateElement(arrow, {+ boundElements: [{ type: "text", id: label.id }],+ });+ API.updateElement(label, { labelPosition });++ // move the arrow; like dragging, this doesn't update the label's+ // stored coords — its position is derived from the arrow at render+ API.updateElement(arrow, { x: 300, y: 250 });++ UI.clickTool("text");++ const labelCenterX = 300 + 400 * (labelPosition ?? 0.5);+ mouse.moveTo(labelCenterX, 250);+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: label.id,+ });++ // hovering at the label's stale stored position+ mouse.moveTo(400, 200);+ expect(h.state.textToolHover).toBe(null);++ // clicking at the derived position should edit the label+ mouse.clickAt(labelCenterX, 250);+ const editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).toBe(label.id);+ Keyboard.exitTextEditor(editor);+ },+ );++ it("should clear the hover highlights when the text tool is canceled", async () => {+ const text = API.createElement({+ type: "text",+ text: "free",+ x: 500,+ y: 500,+ width: 40,+ height: 25,+ });+ API.setElements([...h.elements, text]);++ // text hover highlight is cleared on Escape+ UI.clickTool("text");+ mouse.moveTo(520, 512);+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: text.id,+ });+ Keyboard.keyPress(KEYS.ESCAPE);+ expect(h.state.activeTool.type).not.toBe("text");+ expect(h.state.textToolHover).toBe(null);++ // container binding highlight is cleared on Escape+ UI.clickTool("text");+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });+ Keyboard.keyPress(KEYS.ESCAPE);+ expect(h.state.textToolHover).toBe(null);+ });++ it("should highlight the text the text tool would edit on hover", async () => {+ // create a centered label (60x25 label bbox: (25, 45)-(85, 70))+ Keyboard.keyPress(KEYS.ENTER);+ const editor = await getTextEditor();+ updateTextEditor(editor, "Hello!");+ Keyboard.exitTextEditor(editor);+ const label = h.elements[1] as ExcalidrawTextElementWithContainer;++ UI.clickTool("text");++ // over the label → click would edit it+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: label.id,+ });++ // inside the container but off the label → click would create a free+ // text, so neither the label nor the labeled container is highlighted+ mouse.moveTo(20, 30);+ expect(h.state.textToolHover).toBe(null);+ });++ it("should refresh the container hover when ctrl/cmd is pressed or released without moving", () => {+ UI.clickTool("text");+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ // ctrl/cmd opts out of binding: the outline goes with no pointermove...+ Keyboard.withModifierKeys({ ctrl: true }, () => {+ Keyboard.keyDown("Control");+ expect(h.state.textToolHover).toBe(null);+ });+ // ...and comes back on release+ Keyboard.keyUp("Control");+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });+ });++ it("should create free text on a ctrl/cmd click at an empty container's center", async () => {+ UI.clickTool("text");+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ Keyboard.withModifierKeys({ ctrl: true }, () => {+ mouse.moveTo(54, 57.5);+ mouse.clickAt(54, 57.5);+ });+ const editor = await getTextEditor();+ updateTextEditor(editor, "free");+ Keyboard.exitTextEditor(editor);++ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(rectangle.boundElements).toBe(null);+ });+ it("should not advertise a label on an empty arrow's midpoint while ctrl/cmd is held", async () => {+ const arrow = API.createElement({+ type: "arrow",+ x: 200,+ y: 200,+ width: 300,+ height: 0,+ points: [pointFrom(0, 0), pointFrom(300, 0)],+ });+ API.setElements([arrow]);+ UI.clickTool("text");++ mouse.moveTo(350, 200);+ expect(h.state.textToolHover).toEqual({+ type: "arrow",+ elementId: arrow.id,+ anchor: "label",+ });++ Keyboard.withModifierKeys({ ctrl: true }, () => {+ mouse.moveTo(351, 200);+ expect(h.state.textToolHover).toBe(null);+ mouse.clickAt(351, 200);+ });+ const editor = await getTextEditor();+ updateTextEditor(editor, "free");+ Keyboard.exitTextEditor(editor);++ expect(h.elements.length).toBe(2);+ expect((h.elements[1] as ExcalidrawTextElement).containerId).toBe(null);+ expect(arrow.boundElements).toBe(null);+ });++ it("should show the text cursor over a label the text tool would edit", async () => {+ Keyboard.keyPress(KEYS.ENTER);+ const editor = await getTextEditor();+ updateTextEditor(editor, "Hello!");+ Keyboard.exitTextEditor(editor);++ UI.clickTool("text");+ // over the label (60x25, centered in the rectangle)+ mouse.moveTo(55, 57.5);+ expect(GlobalTestState.interactiveCanvas.style.cursor).toBe(+ CURSOR_TYPE.TEXT,+ );+ // inside the rectangle but off the label: a click creates free text+ mouse.moveTo(20, 30);+ expect(GlobalTestState.interactiveCanvas.style.cursor).toBe(+ CURSOR_TYPE.CROSSHAIR,+ );+ });++ it("should not edit a host-selected text when the text tool clicks elsewhere", async () => {+ const text = API.createElement({+ type: "text",+ text: "selected",+ x: 300,+ y: 300,+ width: 80,+ height: 25,+ });+ API.setElements([...h.elements, text]);+ UI.clickTool("text");+ // a host can select through the API after the tool is active+ API.setSelectedElements([text]);+ expect(h.state.selectedElementIds[text.id]).toBe(true);++ mouse.moveTo(500, 500);+ expect(h.state.textToolHover).toBe(null);+ mouse.clickAt(500, 500);+ const editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).not.toBe(text.id);+ updateTextEditor(editor, "new");+ Keyboard.exitTextEditor(editor);++ expect(text.text).toBe("selected");+ expect(h.elements.length).toBe(3);+ });++ it("should not label a host-selected container when the text tool clicks elsewhere", async () => {+ UI.clickTool("text");+ API.setSelectedElements([rectangle]);+ expect(h.state.selectedElementIds[rectangle.id]).toBe(true);++ mouse.moveTo(400, 400);+ expect(h.state.textToolHover).toBe(null);+ mouse.clickAt(400, 400);+ const editor = await getTextEditor();+ updateTextEditor(editor, "free");+ Keyboard.exitTextEditor(editor);++ const text = h.elements[1] as ExcalidrawTextElement;+ expect(text.containerId).toBe(null);+ expect(rectangle.boundElements).toBe(null);+ });++ it("should end the text tool's turn when the pending container is deleted before pointerup", () => {+ UI.clickTool("text");+ mouse.downAt(55, 57.5);+ expect(h.elements.length).toBe(1);++ // a collaborator deletes the container mid-press+ API.setElements([newElementWith(rectangle, { isDeleted: true })]);+ mouse.upAt(55, 57.5);++ expect(h.elements.filter((el) => !el.isDeleted)).toEqual([]);+ expect(h.state.editingTextElement).toBe(null);+ expect(h.state.activeTool.type).toBe("selection");+ });++ it("should not revive a pending center click when the text tool is left and picked again mid-press", async () => {+ UI.clickTool("text");+ mouse.downAt(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ Keyboard.keyPress(KEYS.ESCAPE);+ expect(h.state.activeTool.type).toBe("selection");+ UI.clickTool("text");+ // the press belonged to the tool that was left+ mouse.moveTo(175, 57.5);+ expect(h.elements.map((el) => el.type)).toEqual(["rectangle"]);+ mouse.upAt(175, 57.5);+ expect(h.elements.map((el) => el.type)).toEqual(["rectangle"]);+ expect(h.state.editingTextElement).toBe(null);++ // a fresh center click still binds (the release above counted as a+ // click of the re-picked tool and reverted it, as any tool's would)+ UI.clickTool("text");+ mouse.clickAt(55, 57.5);+ const editor = await getTextEditor();+ updateTextEditor(editor, "Label");+ Keyboard.exitTextEditor(editor);+ expect((h.elements[1] as ExcalidrawTextElement).containerId).toBe(+ rectangle.id,+ );+ });++ it("should drop a pending center click when the browser cancels the pointer", async () => {+ UI.clickTool("text");+ const touch = new Pointer("touch", 7);+ touch.downAt(55, 57.5);+ // finger jitter, well under the drag threshold — and what makes the+ // finger, not the mouse that drew the rectangle, the last pointer to+ // have moved, as in a touch-only session+ touch.moveTo(56, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ // scroll / palm rejection: no pointerup will follow+ fireEvent.pointerCancel(GlobalTestState.interactiveCanvas, {+ pointerId: 7,+ pointerType: "touch",+ clientX: 55,+ clientY: 57.5,+ });+ // the outline was the armed click's: it goes with it, before any other+ // pointer moves (no finger is left to refresh it)+ expect(h.state.textToolHover).toBe(null);+ // the gesture is gone with the pointer: nothing listens for movement+ // any more, and the tool is still the user's+ mouse.moveTo(175, 57.5);+ expect(h.elements.map((el) => el.type)).toEqual(["rectangle"]);+ expect(h.state.editingTextElement).toBe(null);+ expect(h.state.activeTool.type).toBe("text");++ // the next center click is an ordinary one — nothing of the canceled+ // press replays into it+ mouse.clickAt(55, 57.5);+ const editor = await getTextEditor();+ updateTextEditor(editor, "Label");+ Keyboard.exitTextEditor(editor);+ expect((h.elements[1] as ExcalidrawTextElement).containerId).toBe(+ rectangle.id,+ );+ });++ it("should clear the armed outline when a second finger discards a pending center click", () => {+ UI.clickTool("text");+ const first = new Pointer("touch", 7);+ const second = new Pointer("touch", 8);+ first.downAt(55, 57.5);+ // jitter: the finger is the last pointer to have moved (see above)+ first.moveTo(56, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ // pinch/pan intent: the first press is torn down unresolved, and its+ // outline with it — no finger hovers to refresh it later+ second.downAt(300, 300);+ expect(h.state.textToolHover).toBe(null);+ first.upAt(55, 57.5);+ second.upAt(300, 300);+ expect(h.state.textToolHover).toBe(null);+ expect(h.elements.map((el) => el.type)).toEqual(["rectangle"]);+ });++ it("should not refresh the hover from a lifted finger's position when the viewport moves", async () => {+ const text = API.createElement({+ type: "text",+ text: "free",+ x: 300,+ y: 300,+ width: 40,+ height: 25,+ });+ API.setElements([...h.elements, text]);+ UI.clickTool("text");+ UI.clickTool("lock");+ const touch = new Pointer("touch", 7);++ // a tap on the text (with some finger jitter) edits it+ touch.downAt(320, 312);+ touch.moveTo(322, 312);+ touch.upAt(322, 312);+ let editor = await getTextEditor();+ expect(h.state.editingTextElement?.id).toBe(text.id);+ Keyboard.exitTextEditor(editor);+ expect(h.state.activeTool.type).toBe("text");+ expect(h.state.textToolHover).toBe(null);+ // a finger doesn't hover: a viewport change has nothing to re-resolve,+ // not even where it lifted, over the text+ API.setAppState({ scrollY: h.state.scrollY - 1 });+ expect(h.state.textToolHover).toBe(null);+ API.setAppState({ scrollY: h.state.scrollY + 1 });+ expect(h.state.textToolHover).toBe(null);++ // a short drag from an empty container's center still binds a label;+ // once its editor closes, the lifted finger doesn't bring the outline+ // back either+ touch.downAt(55, 57.5);+ touch.moveTo(65, 57.5);+ touch.upAt(65, 57.5);+ editor = await getTextEditor();+ expect(h.state.editingTextElement?.containerId).toBe(rectangle.id);+ Keyboard.exitTextEditor(editor);+ expect(h.state.textToolHover).toBe(null);+ API.setAppState({ scrollY: h.state.scrollY - 1 });+ expect(h.state.textToolHover).toBe(null);+ API.setAppState({ zoom: { value: 2 as typeof h.state.zoom.value } });+ API.setAppState({ zoom: { value: 1 as typeof h.state.zoom.value } });+ expect(h.state.textToolHover).toBe(null);+ });+ it("should refresh the hover when the viewport scrolls or zooms under a still pointer", async () => {+ const text = API.createElement({+ type: "text",+ text: "free",+ x: 300,+ y: 300,+ width: 40,+ height: 25,+ });+ API.setElements([...h.elements, text]);+ UI.clickTool("text");++ // container target, scrolled away and back+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });+ fireEvent.wheel(GlobalTestState.interactiveCanvas, { deltaY: 400 });+ await waitFor(() => expect(h.state.scrollY).not.toBe(0));+ expect(h.state.textToolHover).toBe(null);+ fireEvent.wheel(GlobalTestState.interactiveCanvas, { deltaY: -400 });+ await waitFor(() => expect(h.state.scrollY).toBe(0));+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });++ // text target+ mouse.moveTo(320, 312);+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: text.id,+ });+ fireEvent.wheel(GlobalTestState.interactiveCanvas, { deltaY: 400 });+ await waitFor(() => expect(h.state.scrollY).not.toBe(0));+ expect(h.state.textToolHover).toBe(null);+ fireEvent.wheel(GlobalTestState.interactiveCanvas, { deltaY: -400 });+ await waitFor(() => expect(h.state.scrollY).toBe(0));+ expect(h.state.textToolHover).toEqual({+ type: "text",+ elementId: text.id,+ });++ // a zoom about the viewport origin (as from the keyboard) moves the+ // rectangle's center away from the still pointer+ mouse.moveTo(55, 57.5);+ expect(h.state.textToolHover).toEqual({+ type: "container",+ elementId: rectangle.id,+ });+ API.setAppState({ zoom: { value: 2 as typeof h.state.zoom.value } });+ expect(h.state.textToolHover).toBe(null);+ });+it("should reset the text element angle to the container's when binding to rotated non-arrow container", async () => {const text = API.createElement({type: "text",diff --git a/packages/utils/tests/__snapshots__/export.test.ts.snap b/packages/utils/tests/__snapshots__/export.test.ts.snapindex fdb6e6f2a1..618ac57a04 100644--- a/packages/utils/tests/__snapshots__/export.test.ts.snap+++ b/packages/utils/tests/__snapshots__/export.test.ts.snap@@ -66,7 +66,6 @@ exports[`exportToSvg > with default arguments 1`] = `"gridModeEnabled": false,"gridSize": 20,"gridStep": 5,- "hoveredArrowTextAnchor": null,"hoveredElementIds": {},"inputDevice": "auto","isBindingEnabled": true,@@ -117,6 +116,7 @@ exports[`exportToSvg > with default arguments 1`] = `"panels": 3,},"suggestedBinding": null,+ "textToolHover": null,"theme": "light","toast": null,"viewBackgroundColor": "#ffffff",