@pixerate/editor-react 0.141.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(
@@ -3054,6 +3104,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
3054
3104
  Math.round(zoom * 100),
3055
3105
  "%"
3056
3106
  ] }),
3107
+ !session.showsWholeImage && /* @__PURE__ */ jsx16("button", { type: "button", className: button2, title: "Show (and sample from) more of the image around the selection", onClick: () => session.expandView(), children: "Expand View" }),
3057
3108
  session.computing && /* @__PURE__ */ jsx16("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
3058
3109
  ] }),
3059
3110
  /* @__PURE__ */ jsxs14("div", { className: "flex-1 grid grid-cols-2 gap-2 p-2 min-h-0", children: [
@@ -3125,7 +3176,8 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
3125
3176
  value: settings.output,
3126
3177
  options: [
3127
3178
  { value: "new-layer", label: "New Layer" },
3128
- { value: "current", label: "Current Layer" }
3179
+ { value: "current", label: "Current Layer" },
3180
+ { value: "duplicate-layer", label: "Duplicate Layer" }
3129
3181
  ],
3130
3182
  onChange: (v) => set({ output: v })
3131
3183
  }
@@ -4062,86 +4114,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
4062
4114
  setError(err instanceof Error ? err.message : String(err));
4063
4115
  }
4064
4116
  };
4065
- return /* @__PURE__ */ jsxs18("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
4066
- /* @__PURE__ */ jsx20("span", { className: imageSectionTitleClass, children: "Paths" }),
4067
- paths.length === 0 && /* @__PURE__ */ jsx20("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
4068
- /* @__PURE__ */ jsx20("ul", { role: "list", className: "flex flex-col gap-0.5", children: paths.map((p) => /* @__PURE__ */ jsxs18(
4069
- "li",
4070
- {
4071
- "data-testid": "path-row",
4072
- "aria-current": p.id === activeId ? "true" : void 0,
4073
- 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"}`,
4074
- onClick: () => attempt(() => controller.setActivePath(p.id)),
4075
- onDoubleClick: () => setRenaming(p.id),
4076
- children: [
4077
- /* @__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" }) }),
4078
- renaming === p.id ? /* @__PURE__ */ jsx20(
4079
- "input",
4080
- {
4081
- autoFocus: true,
4082
- "aria-label": "Path name",
4083
- defaultValue: p.work ? "" : p.name,
4084
- placeholder: "Path name",
4085
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
4086
- onClick: (e) => e.stopPropagation(),
4087
- onBlur: (e) => {
4088
- setRenaming(null);
4089
- const name = e.currentTarget.value.trim();
4090
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
4091
- },
4092
- onKeyDown: (e) => {
4093
- if (e.key === "Enter") e.currentTarget.blur();
4094
- if (e.key === "Escape") setRenaming(null);
4095
- }
4096
- }
4097
- ) : /* @__PURE__ */ jsx20("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
4098
- ]
4099
- },
4100
- p.id
4101
- )) }),
4102
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4103
- /* @__PURE__ */ jsx20(
4104
- "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",
4105
4124
  {
4106
- type: "button",
4107
- className: btn3(),
4108
- disabled: !active,
4109
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
4110
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: selectionModeFromModifiers2(e, "replace") })),
4111
- children: "Load as Selection"
4112
- }
4113
- ),
4114
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
4115
- active?.work && /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
4116
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
4117
- ] }),
4118
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap items-center gap-1", children: [
4119
- /* @__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" }),
4120
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
4121
- /* @__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: [
4122
4157
  /* @__PURE__ */ jsx20(
4123
- "input",
4158
+ "button",
4124
4159
  {
4125
- type: "number",
4126
- min: 0.5,
4127
- max: 250,
4128
- step: 0.5,
4129
- "aria-label": "Stroke width",
4130
- value: width,
4131
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
4132
- 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"
4133
4166
  }
4134
4167
  ),
4135
- "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" })
4136
4171
  ] }),
4137
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
4138
- ] }),
4139
- /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap gap-1", children: [
4140
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
4141
- /* @__PURE__ */ jsx20("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
4142
- ] }),
4143
- error && /* @__PURE__ */ jsx20("p", { role: "alert", className: "text-destructive", children: error })
4144
- ] });
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
+ );
4145
4200
  };
4146
4201
 
4147
4202
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -5102,15 +5157,15 @@ var ImageEditor = ({
5102
5157
  /* @__PURE__ */ jsx24("div", { className: imageSectionClass, children: /* @__PURE__ */ jsx24(LayersPanel, { controller }) })
5103
5158
  ] }),
5104
5159
  activeTab === "annotate" && /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-3 text-xs", children: [
5105
- /* @__PURE__ */ jsx24("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
5106
- /* @__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(
5107
5162
  "button",
5108
5163
  {
5109
5164
  type: "button",
5110
5165
  "aria-pressed": state.activeTool === t,
5111
5166
  onClick: () => editor.setTool(t),
5112
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"}`,
5113
- children: t === "shape" ? "Shape" : "Type"
5168
+ children: imageToolLabel(t)
5114
5169
  },
5115
5170
  t
5116
5171
  )) }),
@@ -5126,7 +5181,7 @@ var ImageEditor = ({
5126
5181
  type: "button",
5127
5182
  onClick: () => editor.setTool(t),
5128
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"}`,
5129
- children: t
5184
+ children: t === "pen" ? "freehand" : t
5130
5185
  },
5131
5186
  t
5132
5187
  )) }),
@@ -6,7 +6,7 @@ export interface ContentAwareFillWorkspaceProps {
6
6
  onClose: (result: {
7
7
  layerId: string;
8
8
  bounds: CropBox;
9
- output: 'current' | 'new-layer';
9
+ output: 'current' | 'new-layer' | 'duplicate-layer';
10
10
  } | null) => void;
11
11
  className?: string;
12
12
  }
@@ -6,7 +6,7 @@ export interface ContentAwareFillWorkspaceProps {
6
6
  onClose: (result: {
7
7
  layerId: string;
8
8
  bounds: CropBox;
9
- output: 'current' | 'new-layer';
9
+ output: 'current' | 'new-layer' | 'duplicate-layer';
10
10
  } | null) => void;
11
11
  className?: string;
12
12
  }
@@ -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)(
@@ -4988,6 +5035,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
4988
5035
  Math.round(zoom * 100),
4989
5036
  "%"
4990
5037
  ] }),
5038
+ !session.showsWholeImage && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: button3, title: "Show (and sample from) more of the image around the selection", onClick: () => session.expandView(), children: "Expand View" }),
4991
5039
  session.computing && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
4992
5040
  ] }),
4993
5041
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex-1 grid grid-cols-2 gap-2 p-2 min-h-0", children: [
@@ -5059,7 +5107,8 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
5059
5107
  value: settings.output,
5060
5108
  options: [
5061
5109
  { value: "new-layer", label: "New Layer" },
5062
- { value: "current", label: "Current Layer" }
5110
+ { value: "current", label: "Current Layer" },
5111
+ { value: "duplicate-layer", label: "Duplicate Layer" }
5063
5112
  ],
5064
5113
  onChange: (v) => set({ output: v })
5065
5114
  }
@@ -5990,86 +6039,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
5990
6039
  setError(err instanceof Error ? err.message : String(err));
5991
6040
  }
5992
6041
  };
5993
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
5994
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
5995
- paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
5996
- /* @__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)(
5997
- "li",
5998
- {
5999
- "data-testid": "path-row",
6000
- "aria-current": p.id === activeId ? "true" : void 0,
6001
- 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"}`,
6002
- onClick: () => attempt(() => controller.setActivePath(p.id)),
6003
- onDoubleClick: () => setRenaming(p.id),
6004
- children: [
6005
- /* @__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" }) }),
6006
- renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6007
- "input",
6008
- {
6009
- autoFocus: true,
6010
- "aria-label": "Path name",
6011
- defaultValue: p.work ? "" : p.name,
6012
- placeholder: "Path name",
6013
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
6014
- onClick: (e) => e.stopPropagation(),
6015
- onBlur: (e) => {
6016
- setRenaming(null);
6017
- const name = e.currentTarget.value.trim();
6018
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
6019
- },
6020
- onKeyDown: (e) => {
6021
- if (e.key === "Enter") e.currentTarget.blur();
6022
- if (e.key === "Escape") setRenaming(null);
6023
- }
6024
- }
6025
- ) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
6026
- ]
6027
- },
6028
- p.id
6029
- )) }),
6030
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6031
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6032
- "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",
6033
6049
  {
6034
- type: "button",
6035
- className: btn3(),
6036
- disabled: !active,
6037
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
6038
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
6039
- children: "Load as Selection"
6040
- }
6041
- ),
6042
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
6043
- active?.work && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
6044
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
6045
- ] }),
6046
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
6047
- /* @__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" }),
6048
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
6049
- /* @__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: [
6050
6082
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6051
- "input",
6083
+ "button",
6052
6084
  {
6053
- type: "number",
6054
- min: 0.5,
6055
- max: 250,
6056
- step: 0.5,
6057
- "aria-label": "Stroke width",
6058
- value: width,
6059
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
6060
- 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"
6061
6091
  }
6062
6092
  ),
6063
- "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" })
6064
6096
  ] }),
6065
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
6066
- ] }),
6067
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
6068
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
6069
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
6070
- ] }),
6071
- error && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { role: "alert", className: "text-destructive", children: error })
6072
- ] });
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
+ );
6073
6125
  };
6074
6126
 
6075
6127
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -7030,15 +7082,15 @@ var ImageEditor = ({
7030
7082
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(LayersPanel, { controller }) })
7031
7083
  ] }),
7032
7084
  activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
7033
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
7034
- /* @__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)(
7035
7087
  "button",
7036
7088
  {
7037
7089
  type: "button",
7038
7090
  "aria-pressed": state.activeTool === t,
7039
7091
  onClick: () => editor.setTool(t),
7040
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"}`,
7041
- children: t === "shape" ? "Shape" : "Type"
7093
+ children: (0, import_image_editor23.imageToolLabel)(t)
7042
7094
  },
7043
7095
  t
7044
7096
  )) }),
@@ -7054,7 +7106,7 @@ var ImageEditor = ({
7054
7106
  type: "button",
7055
7107
  onClick: () => editor.setTool(t),
7056
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"}`,
7057
- children: t
7109
+ children: t === "pen" ? "freehand" : t
7058
7110
  },
7059
7111
  t
7060
7112
  )) }),
@@ -30,7 +30,7 @@ import {
30
30
  useImageEditorControls,
31
31
  useImageEffectsTools,
32
32
  useImageHistogram
33
- } from "../chunk-DD2SZVT2.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)(
@@ -8702,6 +8749,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
8702
8749
  Math.round(zoom * 100),
8703
8750
  "%"
8704
8751
  ] }),
8752
+ !session.showsWholeImage && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: button3, title: "Show (and sample from) more of the image around the selection", onClick: () => session.expandView(), children: "Expand View" }),
8705
8753
  session.computing && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
8706
8754
  ] }),
8707
8755
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex-1 grid grid-cols-2 gap-2 p-2 min-h-0", children: [
@@ -8773,7 +8821,8 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
8773
8821
  value: settings.output,
8774
8822
  options: [
8775
8823
  { value: "new-layer", label: "New Layer" },
8776
- { value: "current", label: "Current Layer" }
8824
+ { value: "current", label: "Current Layer" },
8825
+ { value: "duplicate-layer", label: "Duplicate Layer" }
8777
8826
  ],
8778
8827
  onChange: (v) => set({ output: v })
8779
8828
  }
@@ -9704,86 +9753,89 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
9704
9753
  setError(err instanceof Error ? err.message : String(err));
9705
9754
  }
9706
9755
  };
9707
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
9708
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
9709
- paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
9710
- /* @__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)(
9711
- "li",
9712
- {
9713
- "data-testid": "path-row",
9714
- "aria-current": p.id === activeId ? "true" : void 0,
9715
- 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"}`,
9716
- onClick: () => attempt(() => controller.setActivePath(p.id)),
9717
- onDoubleClick: () => setRenaming(p.id),
9718
- children: [
9719
- /* @__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" }) }),
9720
- renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9721
- "input",
9722
- {
9723
- autoFocus: true,
9724
- "aria-label": "Path name",
9725
- defaultValue: p.work ? "" : p.name,
9726
- placeholder: "Path name",
9727
- className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
9728
- onClick: (e) => e.stopPropagation(),
9729
- onBlur: (e) => {
9730
- setRenaming(null);
9731
- const name = e.currentTarget.value.trim();
9732
- if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
9733
- },
9734
- onKeyDown: (e) => {
9735
- if (e.key === "Enter") e.currentTarget.blur();
9736
- if (e.key === "Escape") setRenaming(null);
9737
- }
9738
- }
9739
- ) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
9740
- ]
9741
- },
9742
- p.id
9743
- )) }),
9744
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9745
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9746
- "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",
9747
9763
  {
9748
- type: "button",
9749
- className: btn3(),
9750
- disabled: !active,
9751
- title: "Load the path as the selection (Shift adds, Alt subtracts)",
9752
- onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
9753
- children: "Load as Selection"
9754
- }
9755
- ),
9756
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
9757
- active?.work && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
9758
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
9759
- ] }),
9760
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
9761
- /* @__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" }),
9762
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
9763
- /* @__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: [
9764
9796
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9765
- "input",
9797
+ "button",
9766
9798
  {
9767
- type: "number",
9768
- min: 0.5,
9769
- max: 250,
9770
- step: 0.5,
9771
- "aria-label": "Stroke width",
9772
- value: width,
9773
- onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
9774
- 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"
9775
9805
  }
9776
9806
  ),
9777
- "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" })
9778
9810
  ] }),
9779
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
9780
- ] }),
9781
- /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
9782
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
9783
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
9784
- ] }),
9785
- error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
9786
- ] });
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
+ );
9787
9839
  };
9788
9840
 
9789
9841
  // src/image-editor/FreeTransformOptionsBar.tsx
@@ -10744,15 +10796,15 @@ var ImageEditor = ({
10744
10796
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LayersPanel, { controller }) })
10745
10797
  ] }),
10746
10798
  activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
10747
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
10748
- /* @__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)(
10749
10801
  "button",
10750
10802
  {
10751
10803
  type: "button",
10752
10804
  "aria-pressed": state.activeTool === t,
10753
10805
  onClick: () => editor.setTool(t),
10754
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"}`,
10755
- children: t === "shape" ? "Shape" : "Type"
10807
+ children: (0, import_image_editor23.imageToolLabel)(t)
10756
10808
  },
10757
10809
  t
10758
10810
  )) }),
@@ -10768,7 +10820,7 @@ var ImageEditor = ({
10768
10820
  type: "button",
10769
10821
  onClick: () => editor.setTool(t),
10770
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"}`,
10771
- children: t
10823
+ children: t === "pen" ? "freehand" : t
10772
10824
  },
10773
10825
  t
10774
10826
  )) }),
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  useImageEditorControls,
55
55
  useImageEffectsTools,
56
56
  useImageHistogram
57
- } from "./chunk-DD2SZVT2.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.141.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.211.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.211.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",