@pixerate/editor-react 0.142.0 → 0.143.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -199,7 +199,8 @@ import {
199
199
  DEFAULT_SELECTION_TOOL_OPTIONS as DEFAULT_SELECTION_TOOL_OPTIONS2,
200
200
  FreeTransformTool as FreeTransformTool2,
201
201
  DEFAULT_SHAPE_TOOL_OPTIONS as DEFAULT_SHAPE_TOOL_OPTIONS2,
202
- DEFAULT_TYPE_TOOL_OPTIONS as DEFAULT_TYPE_TOOL_OPTIONS2
202
+ DEFAULT_TYPE_TOOL_OPTIONS as DEFAULT_TYPE_TOOL_OPTIONS2,
203
+ imageToolLabel
203
204
  } from "@pixerate/editor/image-editor";
204
205
 
205
206
  // src/image-editor/ImageEditorCanvas.tsx
@@ -228,6 +229,8 @@ import {
228
229
  handleMaskViewKey,
229
230
  ShapeDrawGesture,
230
231
  TypeToolGesture,
232
+ PathEditGesture,
233
+ isPathEditTool,
231
234
  DEFAULT_SHAPE_TOOL_OPTIONS,
232
235
  DEFAULT_TYPE_TOOL_OPTIONS
233
236
  } from "@pixerate/editor/image-editor";
@@ -366,6 +369,12 @@ var ImageEditorCanvas = ({
366
369
  typeToolRef.current = new TypeToolGesture(controller, () => typeOptionsRef.current);
367
370
  shapeTypeControllerRef.current = controller;
368
371
  }
372
+ const pathGestureRef = useRef2(null);
373
+ const pathControllerRef = useRef2(controller);
374
+ if (!pathGestureRef.current || pathControllerRef.current !== controller) {
375
+ pathGestureRef.current = new PathEditGesture(controller);
376
+ pathControllerRef.current = controller;
377
+ }
369
378
  const typeInputRef = useRef2(null);
370
379
  const [typeSession, setTypeSessionState] = useState2(typeToolRef.current.session);
371
380
  const setTypeSession = (session) => {
@@ -387,7 +396,10 @@ var ImageEditorCanvas = ({
387
396
  if (!canvas || !container) return;
388
397
  const viewport = measureCanvasViewport(container);
389
398
  viewRef.current = { width: viewport.width, height: viewport.height };
390
- transformTool.setView(getViewportProjection(controller.getState(), viewport.width, viewport.height, mode === "crop").scale);
399
+ const viewScale = getViewportProjection(controller.getState(), viewport.width, viewport.height, mode === "crop").scale;
400
+ transformTool.setView(viewScale);
401
+ pathGestureRef.current?.setView(viewScale);
402
+ const activeTool = controller.getState().activeTool;
391
403
  await controller.render(canvas, {
392
404
  viewportWidth: viewport.width,
393
405
  viewportHeight: viewport.height,
@@ -403,7 +415,8 @@ var ImageEditorCanvas = ({
403
415
  draftSelectionPath: selectionDraftRef.current,
404
416
  brushCursor: mode === "paint" && brushCursorRef.current && controller.getState().activeTool !== "move" && !transformTool.active ? { ...brushCursorRef.current, diameter: controller.getState().paint.brush.size } : null,
405
417
  freeTransform: transformTool.overlay(),
406
- textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null
418
+ textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null,
419
+ pathEdit: mode === "annotate" && isPathEditTool(activeTool) ? pathGestureRef.current?.overlay(activeTool) : null
407
420
  });
408
421
  },
409
422
  [controller, mode, fit, transformTool]
@@ -620,6 +633,21 @@ var ImageEditorCanvas = ({
620
633
  window.addEventListener("keydown", onKey);
621
634
  return () => window.removeEventListener("keydown", onKey);
622
635
  });
636
+ useEffect2(() => {
637
+ if (mode !== "annotate" || typeof window === "undefined") return;
638
+ const onKey = (e) => {
639
+ const target = e.target;
640
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
641
+ if (!isPathEditTool(controller.getState().activeTool)) return;
642
+ if (pathGestureRef.current?.key(e.key)) {
643
+ e.preventDefault();
644
+ report("path", pathGestureRef.current.error);
645
+ void renderCanvas();
646
+ }
647
+ };
648
+ window.addEventListener("keydown", onKey);
649
+ return () => window.removeEventListener("keydown", onKey);
650
+ });
623
651
  useEffect2(() => {
624
652
  if (mode !== "paint" || typeof window === "undefined") return;
625
653
  const onKey = (e) => {
@@ -668,6 +696,13 @@ var ImageEditorCanvas = ({
668
696
  }
669
697
  return;
670
698
  }
699
+ if (mode === "annotate" && isPathEditTool(state.activeTool)) {
700
+ const g = pathGestureRef.current;
701
+ g.down(canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false), state.activeTool, { shift: e.shiftKey, alt: e.altKey });
702
+ report("path", g.error);
703
+ void renderCanvas();
704
+ return;
705
+ }
671
706
  if (mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "type")) {
672
707
  const imgPt = canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
673
708
  report(state.activeTool, null);
@@ -769,6 +804,16 @@ var ImageEditorCanvas = ({
769
804
  }
770
805
  return;
771
806
  }
807
+ if (mode === "annotate" && isPathEditTool(state.activeTool)) {
808
+ const g = pathGestureRef.current;
809
+ const imgPt = canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
810
+ if (g.active) {
811
+ g.move(imgPt, { shift: e.shiftKey, alt: e.altKey });
812
+ if (g.error) report("path", g.error);
813
+ } else g.hover(imgPt);
814
+ void renderCanvas();
815
+ return;
816
+ }
772
817
  if (mode === "annotate" && state.activeTool === "shape") {
773
818
  const g = shapeGestureRef.current;
774
819
  if (g.active) {
@@ -880,6 +925,11 @@ var ImageEditorCanvas = ({
880
925
  }
881
926
  return;
882
927
  }
928
+ if (mode === "annotate" && isPathEditTool(state.activeTool)) {
929
+ pathGestureRef.current.up();
930
+ void renderCanvas();
931
+ return;
932
+ }
883
933
  if (mode === "annotate" && state.activeTool === "shape") {
884
934
  shapeGestureRef.current.up();
885
935
  return;
@@ -968,7 +1018,7 @@ var ImageEditorCanvas = ({
968
1018
  onPointerCancel: () => paintGestureRef.current?.cancel(),
969
1019
  "data-testid": "image-editor-canvas",
970
1020
  style: transformTool.active ? { width: "100%", height: "100%", cursor: transformCursor } : { width: "100%", height: "100%" },
971
- className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && state.activeTool === "shape" ? "cursor-crosshair" : ""}`
1021
+ className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "path-pen") ? "cursor-crosshair" : mode === "annotate" && isPathEditTool(state.activeTool) ? "cursor-default" : ""}`
972
1022
  }
973
1023
  ),
974
1024
  typeSession && /* @__PURE__ */ jsx(
@@ -4064,86 +4114,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
4064
4114
  setError(err instanceof Error ? err.message : String(err));
4065
4115
  }
4066
4116
  };
4067
- return /* @__PURE__ */ jsxs18("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
4068
- /* @__PURE__ */ jsx20("span", { className: imageSectionTitleClass, children: "Paths" }),
4069
- paths.length === 0 && /* @__PURE__ */ jsx20("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
4070
- /* @__PURE__ */ jsx20("ul", { role: "list", className: "flex flex-col gap-0.5", children: paths.map((p) => /* @__PURE__ */ jsxs18(
4071
- "li",
4072
- {
4073
- "data-testid": "path-row",
4074
- "aria-current": p.id === activeId ? "true" : void 0,
4075
- className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
4076
- onClick: () => attempt(() => controller.setActivePath(p.id)),
4077
- onDoubleClick: () => setRenaming(p.id),
4078
- children: [
4079
- /* @__PURE__ */ jsx20("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ jsx20("path", { d: pathSvgData(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
4080
- renaming === p.id ? /* @__PURE__ */ jsx20(
4081
- "input",
4082
- {
4083
- autoFocus: true,
4084
- "aria-label": "Path name",
4085
- defaultValue: p.work ? "" : p.name,
4086
- placeholder: "Path name",
4087
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
4088
- onClick: (e) => e.stopPropagation(),
4089
- onBlur: (e) => {
4090
- setRenaming(null);
4091
- const name = e.currentTarget.value.trim();
4092
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
4093
- },
4094
- onKeyDown: (e) => {
4095
- if (e.key === "Enter") e.currentTarget.blur();
4096
- if (e.key === "Escape") setRenaming(null);
4097
- }
4098
- }
4099
- ) : /* @__PURE__ */ jsx20("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
4100
- ]
4101
- },
4102
- p.id
4103
- )) }),
4104
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4105
- /* @__PURE__ */ jsx20(
4106
- "button",
4117
+ return (
4118
+ // Clicking the panel's empty space deselects the path (the path tools then edit the active layer).
4119
+ /* @__PURE__ */ jsxs18("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: [
4120
+ /* @__PURE__ */ jsx20("span", { className: imageSectionTitleClass, children: "Paths" }),
4121
+ paths.length === 0 && /* @__PURE__ */ jsx20("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
4122
+ /* @__PURE__ */ jsx20("ul", { role: "list", className: "flex flex-col gap-0.5 min-h-4", onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: paths.map((p) => /* @__PURE__ */ jsxs18(
4123
+ "li",
4107
4124
  {
4108
- type: "button",
4109
- className: btn3(),
4110
- disabled: !active,
4111
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
4112
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: selectionModeFromModifiers2(e, "replace") })),
4113
- children: "Load as Selection"
4114
- }
4115
- ),
4116
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
4117
- active?.work && /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
4118
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
4119
- ] }),
4120
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap items-center gap-1", children: [
4121
- /* @__PURE__ */ jsx20("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
4122
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
4123
- /* @__PURE__ */ jsxs18("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
4125
+ "data-testid": "path-row",
4126
+ "aria-current": p.id === activeId ? "true" : void 0,
4127
+ className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
4128
+ onClick: () => attempt(() => controller.setActivePath(p.id)),
4129
+ onDoubleClick: () => setRenaming(p.id),
4130
+ children: [
4131
+ /* @__PURE__ */ jsx20("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ jsx20("path", { d: pathSvgData(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
4132
+ renaming === p.id ? /* @__PURE__ */ jsx20(
4133
+ "input",
4134
+ {
4135
+ autoFocus: true,
4136
+ "aria-label": "Path name",
4137
+ defaultValue: p.work ? "" : p.name,
4138
+ placeholder: "Path name",
4139
+ className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
4140
+ onClick: (e) => e.stopPropagation(),
4141
+ onBlur: (e) => {
4142
+ setRenaming(null);
4143
+ const name = e.currentTarget.value.trim();
4144
+ if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
4145
+ },
4146
+ onKeyDown: (e) => {
4147
+ if (e.key === "Enter") e.currentTarget.blur();
4148
+ if (e.key === "Escape") setRenaming(null);
4149
+ }
4150
+ }
4151
+ ) : /* @__PURE__ */ jsx20("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
4152
+ ]
4153
+ },
4154
+ p.id
4155
+ )) }),
4156
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4124
4157
  /* @__PURE__ */ jsx20(
4125
- "input",
4158
+ "button",
4126
4159
  {
4127
- type: "number",
4128
- min: 0.5,
4129
- max: 250,
4130
- step: 0.5,
4131
- "aria-label": "Stroke width",
4132
- value: width,
4133
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
4134
- className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
4160
+ type: "button",
4161
+ className: btn3(),
4162
+ disabled: !active,
4163
+ title: "Load the path as the selection (Shift adds, Alt subtracts)",
4164
+ onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: selectionModeFromModifiers2(e, "replace") })),
4165
+ children: "Load as Selection"
4135
4166
  }
4136
4167
  ),
4137
- "px"
4168
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
4169
+ active?.work && /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
4170
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
4138
4171
  ] }),
4139
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
4140
- ] }),
4141
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4142
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
4143
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
4144
- ] }),
4145
- error && /* @__PURE__ */ jsx20("p", { role: "alert", className: "text-destructive", children: error })
4146
- ] });
4172
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap items-center gap-1", children: [
4173
+ /* @__PURE__ */ jsx20("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
4174
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
4175
+ /* @__PURE__ */ jsxs18("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
4176
+ /* @__PURE__ */ jsx20(
4177
+ "input",
4178
+ {
4179
+ type: "number",
4180
+ min: 0.5,
4181
+ max: 250,
4182
+ step: 0.5,
4183
+ "aria-label": "Stroke width",
4184
+ value: width,
4185
+ onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
4186
+ className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
4187
+ }
4188
+ ),
4189
+ "px"
4190
+ ] }),
4191
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
4192
+ ] }),
4193
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4194
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
4195
+ /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
4196
+ ] }),
4197
+ error && /* @__PURE__ */ jsx20("p", { role: "alert", className: "text-destructive", children: error })
4198
+ ] })
4199
+ );
4147
4200
  };
4148
4201
 
4149
4202
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -5104,15 +5157,15 @@ var ImageEditor = ({
5104
5157
  /* @__PURE__ */ jsx24("div", { className: imageSectionClass, children: /* @__PURE__ */ jsx24(LayersPanel, { controller }) })
5105
5158
  ] }),
5106
5159
  activeTab === "annotate" && /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-3 text-xs", children: [
5107
- /* @__PURE__ */ jsx24("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
5108
- /* @__PURE__ */ jsx24("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ jsx24(
5160
+ /* @__PURE__ */ jsx24("span", { className: imageSectionTitleClass, children: "Shape & Type Layers, Paths" }),
5161
+ /* @__PURE__ */ jsx24("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type", "path-pen", "path-select", "direct-select"].map((t) => /* @__PURE__ */ jsx24(
5109
5162
  "button",
5110
5163
  {
5111
5164
  type: "button",
5112
5165
  "aria-pressed": state.activeTool === t,
5113
5166
  onClick: () => editor.setTool(t),
5114
5167
  className: `py-1.5 px-2 rounded-lg font-medium border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
5115
- children: t === "shape" ? "Shape" : "Type"
5168
+ children: imageToolLabel(t)
5116
5169
  },
5117
5170
  t
5118
5171
  )) }),
@@ -5128,7 +5181,7 @@ var ImageEditor = ({
5128
5181
  type: "button",
5129
5182
  onClick: () => editor.setTool(t),
5130
5183
  className: `py-1.5 px-2 rounded-lg font-medium capitalize border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
5131
- children: t
5184
+ children: t === "pen" ? "freehand" : t
5132
5185
  },
5133
5186
  t
5134
5187
  )) }),
@@ -6,7 +6,7 @@ import type { UseImageEditorReturn } from './useImageEditor.cjs';
6
6
  /** What pointer gestures on the canvas do (and whether the crop overlay shows). */
7
7
  export type ImageEditorCanvasMode = 'crop' | 'select' | 'paint' | 'annotate' | 'none';
8
8
  /** Which gesture an `onError` report comes from. */
9
- export type ImageEditorCanvasErrorSource = 'paint' | 'select' | 'shape' | 'type';
9
+ export type ImageEditorCanvasErrorSource = 'paint' | 'select' | 'shape' | 'type' | 'path';
10
10
  export interface ImageEditorCanvasProps {
11
11
  /** The editor to draw and edit (`useImageEditor`). */
12
12
  editor: UseImageEditorReturn;
@@ -6,7 +6,7 @@ import type { UseImageEditorReturn } from './useImageEditor.js';
6
6
  /** What pointer gestures on the canvas do (and whether the crop overlay shows). */
7
7
  export type ImageEditorCanvasMode = 'crop' | 'select' | 'paint' | 'annotate' | 'none';
8
8
  /** Which gesture an `onError` report comes from. */
9
- export type ImageEditorCanvasErrorSource = 'paint' | 'select' | 'shape' | 'type';
9
+ export type ImageEditorCanvasErrorSource = 'paint' | 'select' | 'shape' | 'type' | 'path';
10
10
  export interface ImageEditorCanvasProps {
11
11
  /** The editor to draw and edit (`useImageEditor`). */
12
12
  editor: UseImageEditorReturn;
@@ -11,6 +11,7 @@ export interface PathsPanelProps {
11
11
  * thumbnails. Click selects a path, double-click renames it (renaming the Work Path saves it).
12
12
  * Load as Selection (Shift adds, Alt subtracts), Make Work Path from the selection, Fill and
13
13
  * Stroke on the active layer with a colour and width, Add Vector Mask to the active layer,
14
- * Duplicate and Delete. Every change is one undo step on the controller.
14
+ * Duplicate and Delete. Clicking empty space deselects the path. Every change is one undo step on
15
+ * the controller.
15
16
  */
16
17
  export declare const PathsPanel: React.FC<PathsPanelProps>;
@@ -11,6 +11,7 @@ export interface PathsPanelProps {
11
11
  * thumbnails. Click selects a path, double-click renames it (renaming the Work Path saves it).
12
12
  * Load as Selection (Shift adds, Alt subtracts), Make Work Path from the selection, Fill and
13
13
  * Stroke on the active layer with a colour and width, Add Vector Mask to the active layer,
14
- * Duplicate and Delete. Every change is one undo step on the controller.
14
+ * Duplicate and Delete. Clicking empty space deselects the path. Every change is one undo step on
15
+ * the controller.
15
16
  */
16
17
  export declare const PathsPanel: React.FC<PathsPanelProps>;
@@ -470,6 +470,12 @@ var ImageEditorCanvas = ({
470
470
  typeToolRef.current = new import_image_editor2.TypeToolGesture(controller, () => typeOptionsRef.current);
471
471
  shapeTypeControllerRef.current = controller;
472
472
  }
473
+ const pathGestureRef = (0, import_react5.useRef)(null);
474
+ const pathControllerRef = (0, import_react5.useRef)(controller);
475
+ if (!pathGestureRef.current || pathControllerRef.current !== controller) {
476
+ pathGestureRef.current = new import_image_editor2.PathEditGesture(controller);
477
+ pathControllerRef.current = controller;
478
+ }
473
479
  const typeInputRef = (0, import_react5.useRef)(null);
474
480
  const [typeSession, setTypeSessionState] = (0, import_react5.useState)(typeToolRef.current.session);
475
481
  const setTypeSession = (session) => {
@@ -491,7 +497,10 @@ var ImageEditorCanvas = ({
491
497
  if (!canvas || !container) return;
492
498
  const viewport = (0, import_image_editor2.measureCanvasViewport)(container);
493
499
  viewRef.current = { width: viewport.width, height: viewport.height };
494
- transformTool.setView((0, import_image_editor2.getViewportProjection)(controller.getState(), viewport.width, viewport.height, mode === "crop").scale);
500
+ const viewScale = (0, import_image_editor2.getViewportProjection)(controller.getState(), viewport.width, viewport.height, mode === "crop").scale;
501
+ transformTool.setView(viewScale);
502
+ pathGestureRef.current?.setView(viewScale);
503
+ const activeTool = controller.getState().activeTool;
495
504
  await controller.render(canvas, {
496
505
  viewportWidth: viewport.width,
497
506
  viewportHeight: viewport.height,
@@ -507,7 +516,8 @@ var ImageEditorCanvas = ({
507
516
  draftSelectionPath: selectionDraftRef.current,
508
517
  brushCursor: mode === "paint" && brushCursorRef.current && controller.getState().activeTool !== "move" && !transformTool.active ? { ...brushCursorRef.current, diameter: controller.getState().paint.brush.size } : null,
509
518
  freeTransform: transformTool.overlay(),
510
- textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null
519
+ textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null,
520
+ pathEdit: mode === "annotate" && (0, import_image_editor2.isPathEditTool)(activeTool) ? pathGestureRef.current?.overlay(activeTool) : null
511
521
  });
512
522
  },
513
523
  [controller, mode, fit, transformTool]
@@ -724,6 +734,21 @@ var ImageEditorCanvas = ({
724
734
  window.addEventListener("keydown", onKey);
725
735
  return () => window.removeEventListener("keydown", onKey);
726
736
  });
737
+ (0, import_react5.useEffect)(() => {
738
+ if (mode !== "annotate" || typeof window === "undefined") return;
739
+ const onKey = (e) => {
740
+ const target = e.target;
741
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
742
+ if (!(0, import_image_editor2.isPathEditTool)(controller.getState().activeTool)) return;
743
+ if (pathGestureRef.current?.key(e.key)) {
744
+ e.preventDefault();
745
+ report("path", pathGestureRef.current.error);
746
+ void renderCanvas();
747
+ }
748
+ };
749
+ window.addEventListener("keydown", onKey);
750
+ return () => window.removeEventListener("keydown", onKey);
751
+ });
727
752
  (0, import_react5.useEffect)(() => {
728
753
  if (mode !== "paint" || typeof window === "undefined") return;
729
754
  const onKey = (e) => {
@@ -772,6 +797,13 @@ var ImageEditorCanvas = ({
772
797
  }
773
798
  return;
774
799
  }
800
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
801
+ const g = pathGestureRef.current;
802
+ g.down((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), state.activeTool, { shift: e.shiftKey, alt: e.altKey });
803
+ report("path", g.error);
804
+ void renderCanvas();
805
+ return;
806
+ }
775
807
  if (mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "type")) {
776
808
  const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
777
809
  report(state.activeTool, null);
@@ -873,6 +905,16 @@ var ImageEditorCanvas = ({
873
905
  }
874
906
  return;
875
907
  }
908
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
909
+ const g = pathGestureRef.current;
910
+ const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
911
+ if (g.active) {
912
+ g.move(imgPt, { shift: e.shiftKey, alt: e.altKey });
913
+ if (g.error) report("path", g.error);
914
+ } else g.hover(imgPt);
915
+ void renderCanvas();
916
+ return;
917
+ }
876
918
  if (mode === "annotate" && state.activeTool === "shape") {
877
919
  const g = shapeGestureRef.current;
878
920
  if (g.active) {
@@ -984,6 +1026,11 @@ var ImageEditorCanvas = ({
984
1026
  }
985
1027
  return;
986
1028
  }
1029
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
1030
+ pathGestureRef.current.up();
1031
+ void renderCanvas();
1032
+ return;
1033
+ }
987
1034
  if (mode === "annotate" && state.activeTool === "shape") {
988
1035
  shapeGestureRef.current.up();
989
1036
  return;
@@ -1072,7 +1119,7 @@ var ImageEditorCanvas = ({
1072
1119
  onPointerCancel: () => paintGestureRef.current?.cancel(),
1073
1120
  "data-testid": "image-editor-canvas",
1074
1121
  style: transformTool.active ? { width: "100%", height: "100%", cursor: transformCursor } : { width: "100%", height: "100%" },
1075
- className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && state.activeTool === "shape" ? "cursor-crosshair" : ""}`
1122
+ className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "path-pen") ? "cursor-crosshair" : mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool) ? "cursor-default" : ""}`
1076
1123
  }
1077
1124
  ),
1078
1125
  typeSession && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -5992,86 +6039,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
5992
6039
  setError(err instanceof Error ? err.message : String(err));
5993
6040
  }
5994
6041
  };
5995
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
5996
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
5997
- paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
5998
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
5999
- "li",
6000
- {
6001
- "data-testid": "path-row",
6002
- "aria-current": p.id === activeId ? "true" : void 0,
6003
- className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
6004
- onClick: () => attempt(() => controller.setActivePath(p.id)),
6005
- onDoubleClick: () => setRenaming(p.id),
6006
- children: [
6007
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: (0, import_image_editor19.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
6008
- renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6009
- "input",
6010
- {
6011
- autoFocus: true,
6012
- "aria-label": "Path name",
6013
- defaultValue: p.work ? "" : p.name,
6014
- placeholder: "Path name",
6015
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
6016
- onClick: (e) => e.stopPropagation(),
6017
- onBlur: (e) => {
6018
- setRenaming(null);
6019
- const name = e.currentTarget.value.trim();
6020
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
6021
- },
6022
- onKeyDown: (e) => {
6023
- if (e.key === "Enter") e.currentTarget.blur();
6024
- if (e.key === "Escape") setRenaming(null);
6025
- }
6026
- }
6027
- ) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
6028
- ]
6029
- },
6030
- p.id
6031
- )) }),
6032
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6033
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6034
- "button",
6042
+ return (
6043
+ // Clicking the panel's empty space deselects the path (the path tools then edit the active layer).
6044
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: [
6045
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
6046
+ paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
6047
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5 min-h-4", onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6048
+ "li",
6035
6049
  {
6036
- type: "button",
6037
- className: btn3(),
6038
- disabled: !active,
6039
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
6040
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
6041
- children: "Load as Selection"
6042
- }
6043
- ),
6044
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
6045
- active?.work && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
6046
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
6047
- ] }),
6048
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
6049
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
6050
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
6051
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
6050
+ "data-testid": "path-row",
6051
+ "aria-current": p.id === activeId ? "true" : void 0,
6052
+ className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
6053
+ onClick: () => attempt(() => controller.setActivePath(p.id)),
6054
+ onDoubleClick: () => setRenaming(p.id),
6055
+ children: [
6056
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: (0, import_image_editor19.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
6057
+ renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6058
+ "input",
6059
+ {
6060
+ autoFocus: true,
6061
+ "aria-label": "Path name",
6062
+ defaultValue: p.work ? "" : p.name,
6063
+ placeholder: "Path name",
6064
+ className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
6065
+ onClick: (e) => e.stopPropagation(),
6066
+ onBlur: (e) => {
6067
+ setRenaming(null);
6068
+ const name = e.currentTarget.value.trim();
6069
+ if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
6070
+ },
6071
+ onKeyDown: (e) => {
6072
+ if (e.key === "Enter") e.currentTarget.blur();
6073
+ if (e.key === "Escape") setRenaming(null);
6074
+ }
6075
+ }
6076
+ ) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
6077
+ ]
6078
+ },
6079
+ p.id
6080
+ )) }),
6081
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6052
6082
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6053
- "input",
6083
+ "button",
6054
6084
  {
6055
- type: "number",
6056
- min: 0.5,
6057
- max: 250,
6058
- step: 0.5,
6059
- "aria-label": "Stroke width",
6060
- value: width,
6061
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
6062
- className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
6085
+ type: "button",
6086
+ className: btn3(),
6087
+ disabled: !active,
6088
+ title: "Load the path as the selection (Shift adds, Alt subtracts)",
6089
+ onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
6090
+ children: "Load as Selection"
6063
6091
  }
6064
6092
  ),
6065
- "px"
6093
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
6094
+ active?.work && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
6095
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
6066
6096
  ] }),
6067
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
6068
- ] }),
6069
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6070
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
6071
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
6072
- ] }),
6073
- error && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { role: "alert", className: "text-destructive", children: error })
6074
- ] });
6097
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
6098
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
6099
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
6100
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
6101
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6102
+ "input",
6103
+ {
6104
+ type: "number",
6105
+ min: 0.5,
6106
+ max: 250,
6107
+ step: 0.5,
6108
+ "aria-label": "Stroke width",
6109
+ value: width,
6110
+ onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
6111
+ className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
6112
+ }
6113
+ ),
6114
+ "px"
6115
+ ] }),
6116
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
6117
+ ] }),
6118
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6119
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
6120
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
6121
+ ] }),
6122
+ error && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { role: "alert", className: "text-destructive", children: error })
6123
+ ] })
6124
+ );
6075
6125
  };
6076
6126
 
6077
6127
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -7032,15 +7082,15 @@ var ImageEditor = ({
7032
7082
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayersPanel, { controller }) })
7033
7083
  ] }),
7034
7084
  activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
7035
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
7036
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7085
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers, Paths" }),
7086
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type", "path-pen", "path-select", "direct-select"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7037
7087
  "button",
7038
7088
  {
7039
7089
  type: "button",
7040
7090
  "aria-pressed": state.activeTool === t,
7041
7091
  onClick: () => editor.setTool(t),
7042
7092
  className: `py-1.5 px-2 rounded-lg font-medium border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
7043
- children: t === "shape" ? "Shape" : "Type"
7093
+ children: (0, import_image_editor23.imageToolLabel)(t)
7044
7094
  },
7045
7095
  t
7046
7096
  )) }),
@@ -7056,7 +7106,7 @@ var ImageEditor = ({
7056
7106
  type: "button",
7057
7107
  onClick: () => editor.setTool(t),
7058
7108
  className: `py-1.5 px-2 rounded-lg font-medium capitalize border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
7059
- children: t
7109
+ children: t === "pen" ? "freehand" : t
7060
7110
  },
7061
7111
  t
7062
7112
  )) }),
@@ -30,7 +30,7 @@ import {
30
30
  useImageEditorControls,
31
31
  useImageEffectsTools,
32
32
  useImageHistogram
33
- } from "../chunk-ULBLX67B.js";
33
+ } from "../chunk-35MOGNMT.js";
34
34
  import "../chunk-AJCWF6SN.js";
35
35
  import "../chunk-6BWTJ3EE.js";
36
36
  import "../chunk-5RPB4WGT.js";
package/dist/index.cjs CHANGED
@@ -4184,6 +4184,12 @@ var ImageEditorCanvas = ({
4184
4184
  typeToolRef.current = new import_image_editor2.TypeToolGesture(controller, () => typeOptionsRef.current);
4185
4185
  shapeTypeControllerRef.current = controller;
4186
4186
  }
4187
+ const pathGestureRef = (0, import_react41.useRef)(null);
4188
+ const pathControllerRef = (0, import_react41.useRef)(controller);
4189
+ if (!pathGestureRef.current || pathControllerRef.current !== controller) {
4190
+ pathGestureRef.current = new import_image_editor2.PathEditGesture(controller);
4191
+ pathControllerRef.current = controller;
4192
+ }
4187
4193
  const typeInputRef = (0, import_react41.useRef)(null);
4188
4194
  const [typeSession, setTypeSessionState] = (0, import_react41.useState)(typeToolRef.current.session);
4189
4195
  const setTypeSession = (session) => {
@@ -4205,7 +4211,10 @@ var ImageEditorCanvas = ({
4205
4211
  if (!canvas || !container) return;
4206
4212
  const viewport = (0, import_image_editor2.measureCanvasViewport)(container);
4207
4213
  viewRef.current = { width: viewport.width, height: viewport.height };
4208
- transformTool.setView((0, import_image_editor2.getViewportProjection)(controller.getState(), viewport.width, viewport.height, mode === "crop").scale);
4214
+ const viewScale = (0, import_image_editor2.getViewportProjection)(controller.getState(), viewport.width, viewport.height, mode === "crop").scale;
4215
+ transformTool.setView(viewScale);
4216
+ pathGestureRef.current?.setView(viewScale);
4217
+ const activeTool = controller.getState().activeTool;
4209
4218
  await controller.render(canvas, {
4210
4219
  viewportWidth: viewport.width,
4211
4220
  viewportHeight: viewport.height,
@@ -4221,7 +4230,8 @@ var ImageEditorCanvas = ({
4221
4230
  draftSelectionPath: selectionDraftRef.current,
4222
4231
  brushCursor: mode === "paint" && brushCursorRef.current && controller.getState().activeTool !== "move" && !transformTool.active ? { ...brushCursorRef.current, diameter: controller.getState().paint.brush.size } : null,
4223
4232
  freeTransform: transformTool.overlay(),
4224
- textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null
4233
+ textEdit: typeToolRef.current?.session?.alive ? typeToolRef.current.session.overlay() : null,
4234
+ pathEdit: mode === "annotate" && (0, import_image_editor2.isPathEditTool)(activeTool) ? pathGestureRef.current?.overlay(activeTool) : null
4225
4235
  });
4226
4236
  },
4227
4237
  [controller, mode, fit, transformTool]
@@ -4438,6 +4448,21 @@ var ImageEditorCanvas = ({
4438
4448
  window.addEventListener("keydown", onKey);
4439
4449
  return () => window.removeEventListener("keydown", onKey);
4440
4450
  });
4451
+ (0, import_react41.useEffect)(() => {
4452
+ if (mode !== "annotate" || typeof window === "undefined") return;
4453
+ const onKey = (e) => {
4454
+ const target = e.target;
4455
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
4456
+ if (!(0, import_image_editor2.isPathEditTool)(controller.getState().activeTool)) return;
4457
+ if (pathGestureRef.current?.key(e.key)) {
4458
+ e.preventDefault();
4459
+ report("path", pathGestureRef.current.error);
4460
+ void renderCanvas();
4461
+ }
4462
+ };
4463
+ window.addEventListener("keydown", onKey);
4464
+ return () => window.removeEventListener("keydown", onKey);
4465
+ });
4441
4466
  (0, import_react41.useEffect)(() => {
4442
4467
  if (mode !== "paint" || typeof window === "undefined") return;
4443
4468
  const onKey = (e) => {
@@ -4486,6 +4511,13 @@ var ImageEditorCanvas = ({
4486
4511
  }
4487
4512
  return;
4488
4513
  }
4514
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
4515
+ const g = pathGestureRef.current;
4516
+ g.down((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), state.activeTool, { shift: e.shiftKey, alt: e.altKey });
4517
+ report("path", g.error);
4518
+ void renderCanvas();
4519
+ return;
4520
+ }
4489
4521
  if (mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "type")) {
4490
4522
  const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
4491
4523
  report(state.activeTool, null);
@@ -4587,6 +4619,16 @@ var ImageEditorCanvas = ({
4587
4619
  }
4588
4620
  return;
4589
4621
  }
4622
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
4623
+ const g = pathGestureRef.current;
4624
+ const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
4625
+ if (g.active) {
4626
+ g.move(imgPt, { shift: e.shiftKey, alt: e.altKey });
4627
+ if (g.error) report("path", g.error);
4628
+ } else g.hover(imgPt);
4629
+ void renderCanvas();
4630
+ return;
4631
+ }
4590
4632
  if (mode === "annotate" && state.activeTool === "shape") {
4591
4633
  const g = shapeGestureRef.current;
4592
4634
  if (g.active) {
@@ -4698,6 +4740,11 @@ var ImageEditorCanvas = ({
4698
4740
  }
4699
4741
  return;
4700
4742
  }
4743
+ if (mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool)) {
4744
+ pathGestureRef.current.up();
4745
+ void renderCanvas();
4746
+ return;
4747
+ }
4701
4748
  if (mode === "annotate" && state.activeTool === "shape") {
4702
4749
  shapeGestureRef.current.up();
4703
4750
  return;
@@ -4786,7 +4833,7 @@ var ImageEditorCanvas = ({
4786
4833
  onPointerCancel: () => paintGestureRef.current?.cancel(),
4787
4834
  "data-testid": "image-editor-canvas",
4788
4835
  style: transformTool.active ? { width: "100%", height: "100%", cursor: transformCursor } : { width: "100%", height: "100%" },
4789
- className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && state.activeTool === "shape" ? "cursor-crosshair" : ""}`
4836
+ className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : mode === "paint" ? "touch-none cursor-crosshair" : mode === "annotate" && state.activeTool === "type" ? "cursor-text" : mode === "annotate" && (state.activeTool === "shape" || state.activeTool === "path-pen") ? "cursor-crosshair" : mode === "annotate" && (0, import_image_editor2.isPathEditTool)(state.activeTool) ? "cursor-default" : ""}`
4790
4837
  }
4791
4838
  ),
4792
4839
  typeSession && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -9706,86 +9753,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
9706
9753
  setError(err instanceof Error ? err.message : String(err));
9707
9754
  }
9708
9755
  };
9709
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
9710
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
9711
- paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
9712
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
9713
- "li",
9714
- {
9715
- "data-testid": "path-row",
9716
- "aria-current": p.id === activeId ? "true" : void 0,
9717
- className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
9718
- onClick: () => attempt(() => controller.setActivePath(p.id)),
9719
- onDoubleClick: () => setRenaming(p.id),
9720
- children: [
9721
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("path", { d: (0, import_image_editor19.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
9722
- renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9723
- "input",
9724
- {
9725
- autoFocus: true,
9726
- "aria-label": "Path name",
9727
- defaultValue: p.work ? "" : p.name,
9728
- placeholder: "Path name",
9729
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
9730
- onClick: (e) => e.stopPropagation(),
9731
- onBlur: (e) => {
9732
- setRenaming(null);
9733
- const name = e.currentTarget.value.trim();
9734
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
9735
- },
9736
- onKeyDown: (e) => {
9737
- if (e.key === "Enter") e.currentTarget.blur();
9738
- if (e.key === "Escape") setRenaming(null);
9739
- }
9740
- }
9741
- ) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
9742
- ]
9743
- },
9744
- p.id
9745
- )) }),
9746
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9747
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9748
- "button",
9756
+ return (
9757
+ // Clicking the panel's empty space deselects the path (the path tools then edit the active layer).
9758
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: [
9759
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
9760
+ paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
9761
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5 min-h-4", onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
9762
+ "li",
9749
9763
  {
9750
- type: "button",
9751
- className: btn3(),
9752
- disabled: !active,
9753
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
9754
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
9755
- children: "Load as Selection"
9756
- }
9757
- ),
9758
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
9759
- active?.work && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
9760
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
9761
- ] }),
9762
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
9763
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
9764
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
9765
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
9764
+ "data-testid": "path-row",
9765
+ "aria-current": p.id === activeId ? "true" : void 0,
9766
+ className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
9767
+ onClick: () => attempt(() => controller.setActivePath(p.id)),
9768
+ onDoubleClick: () => setRenaming(p.id),
9769
+ children: [
9770
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("path", { d: (0, import_image_editor19.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
9771
+ renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9772
+ "input",
9773
+ {
9774
+ autoFocus: true,
9775
+ "aria-label": "Path name",
9776
+ defaultValue: p.work ? "" : p.name,
9777
+ placeholder: "Path name",
9778
+ className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
9779
+ onClick: (e) => e.stopPropagation(),
9780
+ onBlur: (e) => {
9781
+ setRenaming(null);
9782
+ const name = e.currentTarget.value.trim();
9783
+ if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
9784
+ },
9785
+ onKeyDown: (e) => {
9786
+ if (e.key === "Enter") e.currentTarget.blur();
9787
+ if (e.key === "Escape") setRenaming(null);
9788
+ }
9789
+ }
9790
+ ) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
9791
+ ]
9792
+ },
9793
+ p.id
9794
+ )) }),
9795
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9766
9796
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9767
- "input",
9797
+ "button",
9768
9798
  {
9769
- type: "number",
9770
- min: 0.5,
9771
- max: 250,
9772
- step: 0.5,
9773
- "aria-label": "Stroke width",
9774
- value: width,
9775
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
9776
- className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
9799
+ type: "button",
9800
+ className: btn3(),
9801
+ disabled: !active,
9802
+ title: "Load the path as the selection (Shift adds, Alt subtracts)",
9803
+ onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
9804
+ children: "Load as Selection"
9777
9805
  }
9778
9806
  ),
9779
- "px"
9807
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
9808
+ active?.work && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
9809
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
9780
9810
  ] }),
9781
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
9782
- ] }),
9783
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9784
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
9785
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
9786
- ] }),
9787
- error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
9788
- ] });
9811
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
9812
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
9813
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
9814
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
9815
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9816
+ "input",
9817
+ {
9818
+ type: "number",
9819
+ min: 0.5,
9820
+ max: 250,
9821
+ step: 0.5,
9822
+ "aria-label": "Stroke width",
9823
+ value: width,
9824
+ onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
9825
+ className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
9826
+ }
9827
+ ),
9828
+ "px"
9829
+ ] }),
9830
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
9831
+ ] }),
9832
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9833
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
9834
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
9835
+ ] }),
9836
+ error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
9837
+ ] })
9838
+ );
9789
9839
  };
9790
9840
 
9791
9841
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -10746,15 +10796,15 @@ var ImageEditor = ({
10746
10796
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LayersPanel, { controller }) })
10747
10797
  ] }),
10748
10798
  activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
10749
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
10750
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10799
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers, Paths" }),
10800
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type", "path-pen", "path-select", "direct-select"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10751
10801
  "button",
10752
10802
  {
10753
10803
  type: "button",
10754
10804
  "aria-pressed": state.activeTool === t,
10755
10805
  onClick: () => editor.setTool(t),
10756
10806
  className: `py-1.5 px-2 rounded-lg font-medium border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
10757
- children: t === "shape" ? "Shape" : "Type"
10807
+ children: (0, import_image_editor23.imageToolLabel)(t)
10758
10808
  },
10759
10809
  t
10760
10810
  )) }),
@@ -10770,7 +10820,7 @@ var ImageEditor = ({
10770
10820
  type: "button",
10771
10821
  onClick: () => editor.setTool(t),
10772
10822
  className: `py-1.5 px-2 rounded-lg font-medium capitalize border transition-colors ${state.activeTool === t ? "bg-primary border-primary text-primary-foreground" : "bg-muted border-border text-foreground hover:bg-accent"}`,
10773
- children: t
10823
+ children: t === "pen" ? "freehand" : t
10774
10824
  },
10775
10825
  t
10776
10826
  )) }),
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  useImageEditorControls,
55
55
  useImageEffectsTools,
56
56
  useImageHistogram
57
- } from "./chunk-ULBLX67B.js";
57
+ } from "./chunk-35MOGNMT.js";
58
58
  import "./chunk-AJCWF6SN.js";
59
59
  import "./chunk-6BWTJ3EE.js";
60
60
  import "./chunk-5RPB4WGT.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.142.0",
3
+ "version": "0.143.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -254,7 +254,7 @@
254
254
  "dependencies": {},
255
255
  "peerDependencies": {
256
256
  "@dagrejs/dagre": "^1.1.8",
257
- "@pixerate/editor": ">=0.212.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.213.0 <1.0.0-0",
258
258
  "@tiptap/core": "^2.27.3",
259
259
  "@tiptap/extension-bubble-menu": "^2.27.3",
260
260
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -305,7 +305,7 @@
305
305
  "tsup": "^9.0.0",
306
306
  "typescript": "^5.7.3",
307
307
  "vitest": "^5.0.5",
308
- "@pixerate/editor": "0.212.0"
308
+ "@pixerate/editor": "0.213.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",