@pixerate/editor-react 0.118.0 → 0.121.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.
package/dist/index.cjs CHANGED
@@ -4193,6 +4193,7 @@ var ImageEditorCanvas = ({
4193
4193
  const isDrawingRef = (0, import_react41.useRef)(false);
4194
4194
  const currentPathRef = (0, import_react41.useRef)([]);
4195
4195
  const dragStartPointRef = (0, import_react41.useRef)(null);
4196
+ const antsOffsetRef = (0, import_react41.useRef)(0);
4196
4197
  const renderCanvas = (0, import_react41.useCallback)(
4197
4198
  async (draftAnnotation, draftCrop) => {
4198
4199
  const canvas = canvasRef.current;
@@ -4209,6 +4210,7 @@ var ImageEditorCanvas = ({
4209
4210
  fit,
4210
4211
  showCropOverlay: mode === "crop",
4211
4212
  showSelectionOverlay: true,
4213
+ antsOffset: antsOffsetRef.current,
4212
4214
  interactive: true,
4213
4215
  draftAnnotation: draftAnnotation !== void 0 ? draftAnnotation : draftAnnotationRef.current,
4214
4216
  draftCrop: draftCrop !== void 0 ? draftCrop : draftCropRef.current,
@@ -4220,6 +4222,14 @@ var ImageEditorCanvas = ({
4220
4222
  },
4221
4223
  [controller, mode, fit, transformTool]
4222
4224
  );
4225
+ const marching = !!state.selection?.bounds && !state.quickMask;
4226
+ (0, import_react41.useEffect)(() => {
4227
+ if (!marching) return;
4228
+ return (0, import_image_editor2.startMarchingAnts)((offset) => {
4229
+ antsOffsetRef.current = offset;
4230
+ void renderCanvas();
4231
+ });
4232
+ }, [marching, renderCanvas]);
4223
4233
  (0, import_react41.useEffect)(() => {
4224
4234
  let drafting = false;
4225
4235
  return agentPresence.subscribe(
@@ -4400,6 +4410,26 @@ var ImageEditorCanvas = ({
4400
4410
  if (g.error) report("paint", g.error);
4401
4411
  }
4402
4412
  };
4413
+ (0, import_react41.useEffect)(() => {
4414
+ if (mode !== "select" || typeof window === "undefined") return;
4415
+ const onKey = (e) => {
4416
+ const target = e.target;
4417
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
4418
+ if (window.getSelection?.()?.toString()) return;
4419
+ const gesture = selectionGestureRef.current;
4420
+ if ((0, import_image_editor2.handleSelectionShortcut)(controller, e, (message2) => report("select", message2))) {
4421
+ e.preventDefault();
4422
+ return;
4423
+ }
4424
+ if (gesture?.key(e.key)) {
4425
+ e.preventDefault();
4426
+ selectionDraftRef.current = gesture.draftPath;
4427
+ void renderCanvas();
4428
+ }
4429
+ };
4430
+ window.addEventListener("keydown", onKey);
4431
+ return () => window.removeEventListener("keydown", onKey);
4432
+ });
4403
4433
  (0, import_react41.useEffect)(() => {
4404
4434
  if (mode !== "paint" || typeof window === "undefined") return;
4405
4435
  const onKey = (e) => {
@@ -4415,7 +4445,11 @@ var ImageEditorCanvas = ({
4415
4445
  if (mode === "select") {
4416
4446
  const gesture = selectionGestureRef.current;
4417
4447
  const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
4418
- void gesture.begin(imgPt, e).then(() => report("select", gesture.error));
4448
+ void gesture.begin(imgPt, e).then(() => {
4449
+ report("select", gesture.error);
4450
+ selectionDraftRef.current = gesture.draftPath;
4451
+ void renderCanvas();
4452
+ });
4419
4453
  return;
4420
4454
  }
4421
4455
  if (mode === "crop") {
@@ -4497,7 +4531,7 @@ var ImageEditorCanvas = ({
4497
4531
  const canvasPt = getCanvasEventPoint(e);
4498
4532
  if (mode === "select") {
4499
4533
  const gesture = selectionGestureRef.current;
4500
- if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false))) {
4534
+ if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e)) {
4501
4535
  selectionDraftRef.current = gesture.draftPath;
4502
4536
  renderCanvas();
4503
4537
  }
@@ -4640,7 +4674,7 @@ var ImageEditorCanvas = ({
4640
4674
  const gesture = selectionGestureRef.current;
4641
4675
  if (gesture.active) {
4642
4676
  gesture.end((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e);
4643
- selectionDraftRef.current = null;
4677
+ selectionDraftRef.current = gesture.draftPath;
4644
4678
  renderCanvas();
4645
4679
  }
4646
4680
  return;
@@ -5149,7 +5183,7 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
5149
5183
  type: "button",
5150
5184
  className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",
5151
5185
  onClick: () => {
5152
- setSelectedId(controller.addAdjustmentLayer(newKind));
5186
+ setSelectedId(controller.addAdjustmentLayer({ kind: newKind, useSelection: true }));
5153
5187
  setChannel("master");
5154
5188
  setRange(-1);
5155
5189
  },
@@ -5702,7 +5736,14 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5702
5736
  pixels: thumb(layer),
5703
5737
  size: thumbnailSize,
5704
5738
  label: `${row.label} pixels`,
5705
- selected: row.active && state.activeTarget === "pixels" && Boolean(layer.mask)
5739
+ testId: "layer-thumbnail",
5740
+ selected: row.active && state.activeTarget === "pixels" && Boolean(layer.mask),
5741
+ onClick: (e) => {
5742
+ if (e.ctrlKey || e.metaKey) {
5743
+ e.stopPropagation();
5744
+ attempt(() => (0, import_image_editor8.layerThumbnailClick)(controller, layer, e));
5745
+ }
5746
+ }
5706
5747
  }
5707
5748
  ),
5708
5749
  layer.type !== "pixel" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -5747,8 +5788,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5747
5788
  selected: row.active && state.activeTarget === "mask",
5748
5789
  onClick: (e) => {
5749
5790
  e.stopPropagation();
5750
- if (e.shiftKey) attempt(() => controller.setLayerMaskProps(layer.id, { enabled: layer.mask.enabled === false }));
5751
- else attempt(() => controller.setActiveLayer(layer.id, "mask"));
5791
+ attempt(() => (0, import_image_editor8.maskThumbnailClick)(controller, layer, e));
5752
5792
  }
5753
5793
  }
5754
5794
  ),
@@ -7820,7 +7860,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
7820
7860
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
7821
7861
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
7822
7862
  ] }),
7823
- browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
7863
+ browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
7824
7864
  filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
7825
7865
  const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
7826
7866
  const all = layer.smartFilters.filters;
@@ -8255,12 +8295,18 @@ var import_react61 = require("react");
8255
8295
  var import_image_editor14 = require("@pixerate/editor/image-editor");
8256
8296
  var import_jsx_runtime41 = require("react/jsx-runtime");
8257
8297
  var MODIFY_OPS = [
8258
- { op: "grow", label: "Grow" },
8259
- { op: "shrink", label: "Shrink" },
8298
+ { op: "expand", label: "Expand" },
8299
+ { op: "contract", label: "Contract" },
8260
8300
  { op: "feather", label: "Feather" },
8261
8301
  { op: "border", label: "Border" },
8262
8302
  { op: "smooth", label: "Smooth" }
8263
8303
  ];
8304
+ var DISPLAYS = [
8305
+ { id: "ants", label: "Ants" },
8306
+ { id: "quickMask", label: "Quick Mask" },
8307
+ { id: "none", label: "Hidden" }
8308
+ ];
8309
+ var numberInput = "w-14 bg-background border border-border rounded px-1 py-0.5 text-foreground";
8264
8310
  var btn = (on) => `px-2 py-1 rounded-md border text-[11px] transition-colors ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
8265
8311
  var SelectionOptionsBar = ({
8266
8312
  controller,
@@ -8268,12 +8314,67 @@ var SelectionOptionsBar = ({
8268
8314
  onOptionsChange,
8269
8315
  selection,
8270
8316
  quickMask,
8317
+ selectionDisplay,
8271
8318
  className = ""
8272
8319
  }) => {
8273
8320
  const [radius, setRadius] = (0, import_react61.useState)(2);
8274
8321
  const set = (patch) => onOptionsChange({ ...options, ...patch });
8275
8322
  const sel = selection === void 0 ? controller.getSelection() : selection;
8276
- const qm = quickMask ?? Boolean(controller.getState().quickMask);
8323
+ const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
8324
+ const [preset, setPreset] = (0, import_react61.useState)("reds");
8325
+ const [rangeStatus, setRangeStatus] = (0, import_react61.useState)(null);
8326
+ const [colorStatus, setColorStatus] = (0, import_react61.useState)(null);
8327
+ const [strokeWidth, setStrokeWidth] = (0, import_react61.useState)(4);
8328
+ const [strokeLocation, setStrokeLocation] = (0, import_react61.useState)("outside");
8329
+ const edit = (fn) => {
8330
+ setColorStatus(null);
8331
+ try {
8332
+ fn();
8333
+ } catch (err) {
8334
+ setColorStatus(err instanceof Error ? err.message : String(err));
8335
+ }
8336
+ };
8337
+ const runColor = async (op) => {
8338
+ setColorStatus(null);
8339
+ const opts = { tolerance: options.tolerance, sampleMerged: options.sampleMerged, sample: options.sample };
8340
+ try {
8341
+ await (op === "grow" ? controller.growSelection(opts) : controller.selectSimilar(opts));
8342
+ } catch (err) {
8343
+ setColorStatus(err instanceof Error ? err.message : String(err));
8344
+ }
8345
+ };
8346
+ const applyPreset = async () => {
8347
+ setRangeStatus(null);
8348
+ try {
8349
+ await controller.selectColorRangePreset(preset, {
8350
+ mode: options.mode,
8351
+ feather: options.feather ?? 0,
8352
+ invert: options.rangeInvert ?? false,
8353
+ falloff: options.fuzziness ?? 20,
8354
+ sampleMerged: options.sampleMerged,
8355
+ sample: options.sample
8356
+ });
8357
+ } catch (err) {
8358
+ setRangeStatus(err instanceof Error ? err.message : String(err));
8359
+ }
8360
+ };
8361
+ const [subject, setSubject] = (0, import_react61.useState)("");
8362
+ const [segmenting, setSegmenting] = (0, import_react61.useState)(false);
8363
+ const [subjectStatus, setSubjectStatus] = (0, import_react61.useState)(null);
8364
+ const selectSubject = async () => {
8365
+ const target = subject.trim();
8366
+ if (!target || segmenting) return;
8367
+ setSegmenting(true);
8368
+ setSubjectStatus(null);
8369
+ try {
8370
+ const { segments } = await controller.selectSubject(target, { mode: options.mode });
8371
+ setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
8372
+ } catch (err) {
8373
+ setSubjectStatus(err instanceof Error ? err.message : String(err));
8374
+ } finally {
8375
+ setSegmenting(false);
8376
+ }
8377
+ };
8277
8378
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { "data-testid": "selection-options-bar", className: `flex flex-col gap-3 text-xs ${className}`, children: [
8278
8379
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "group", "aria-label": "Selection tool", className: "flex flex-wrap gap-1", children: import_image_editor14.SELECTION_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", "aria-pressed": options.tool === t.id, className: btn(options.tool === t.id), onClick: () => set({ tool: t.id }), children: t.label }, t.id)) }),
8279
8380
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "group", "aria-label": "Selection mode", className: "flex flex-wrap gap-1", children: import_image_editor14.SELECTION_MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", "aria-pressed": options.mode === m, className: btn(options.mode === m), onClick: () => set({ mode: m }), children: import_image_editor14.SELECTION_MODE_LABELS[m] }, m)) }),
@@ -8289,6 +8390,21 @@ var SelectionOptionsBar = ({
8289
8390
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Contiguous", checked: options.contiguous, onChange: (on) => set({ contiguous: on }) }),
8290
8391
  "Contiguous"
8291
8392
  ] }),
8393
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
8394
+ "Distance",
8395
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8396
+ ImageSelect,
8397
+ {
8398
+ label: "Colour distance",
8399
+ value: options.distance,
8400
+ options: [
8401
+ { value: "rgb", label: "RGB" },
8402
+ { value: "perceptual", label: "Perceptual" }
8403
+ ],
8404
+ onChange: (v) => set({ distance: v })
8405
+ }
8406
+ )
8407
+ ] }),
8292
8408
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
8293
8409
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Sample adjusted image", checked: options.sampleMerged, onChange: (on) => set({ sampleMerged: on }) }),
8294
8410
  "Sample adjusted image"
@@ -8309,6 +8425,96 @@ var SelectionOptionsBar = ({
8309
8425
  )
8310
8426
  ] })
8311
8427
  ] }),
8428
+ options.tool === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click to add corners (Shift for 45\xB0), drag for a free-hand stretch; double-click, Enter or a click on the first corner closes it, Backspace removes a corner, Escape cancels." }),
8429
+ options.tool === "range" && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { "data-testid": "color-range-options", className: "flex flex-col gap-2", children: [
8430
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click a colour to select it; Shift-click adds a colour, Alt-click removes one." }),
8431
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex flex-col gap-1", children: [
8432
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
8433
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Fuzziness" }),
8434
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "font-mono", children: options.fuzziness ?? 40 })
8435
+ ] }),
8436
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageRange, { label: "Fuzziness", min: 0, max: 200, step: 1, value: options.fuzziness ?? 40, onChange: (v) => set({ fuzziness: v }) })
8437
+ ] }),
8438
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
8439
+ "Localized radius",
8440
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8441
+ "input",
8442
+ {
8443
+ type: "number",
8444
+ min: 0,
8445
+ step: 1,
8446
+ "aria-label": "Localized radius",
8447
+ value: options.localized ?? 0,
8448
+ onChange: (e) => set({ localized: Math.max(0, Number(e.target.value) || 0) }),
8449
+ className: numberInput
8450
+ }
8451
+ ),
8452
+ "px"
8453
+ ] }),
8454
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
8455
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Invert", checked: options.rangeInvert ?? false, onChange: (on) => set({ rangeInvert: on }) }),
8456
+ "Invert"
8457
+ ] }),
8458
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex items-center gap-1", children: [
8459
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8460
+ ImageSelect,
8461
+ {
8462
+ label: "Color Range preset",
8463
+ value: preset,
8464
+ options: import_image_editor14.COLOR_RANGE_PRESETS.map((p) => ({ value: p, label: import_image_editor14.COLOR_RANGE_PRESET_LABELS[p] })),
8465
+ onChange: (v) => setPreset(v)
8466
+ }
8467
+ ),
8468
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => void applyPreset(), children: "Select" })
8469
+ ] }),
8470
+ rangeStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: rangeStatus })
8471
+ ] }),
8472
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
8473
+ "Feather",
8474
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8475
+ "input",
8476
+ {
8477
+ type: "number",
8478
+ min: 0,
8479
+ max: 1e3,
8480
+ step: 0.5,
8481
+ "aria-label": "Feather",
8482
+ value: options.feather ?? 0,
8483
+ onChange: (e) => set({ feather: Math.max(0, Number(e.target.value) || 0) }),
8484
+ className: numberInput
8485
+ }
8486
+ ),
8487
+ "px"
8488
+ ] }),
8489
+ controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
8490
+ "form",
8491
+ {
8492
+ "data-testid": "select-subject",
8493
+ className: "flex flex-col gap-1",
8494
+ onSubmit: (e) => {
8495
+ e.preventDefault();
8496
+ void selectSubject();
8497
+ },
8498
+ children: [
8499
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex gap-1", children: [
8500
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8501
+ "input",
8502
+ {
8503
+ type: "text",
8504
+ "aria-label": "Subject to select",
8505
+ placeholder: "Subject, e.g. the dog",
8506
+ value: subject,
8507
+ disabled: segmenting,
8508
+ onChange: (e) => setSubject(e.currentTarget.value),
8509
+ className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
8510
+ }
8511
+ ),
8512
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
8513
+ ] }),
8514
+ subjectStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
8515
+ ]
8516
+ }
8517
+ ),
8312
8518
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
8313
8519
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Anti-alias", checked: options.antiAlias, onChange: (on) => set({ antiAlias: on }) }),
8314
8520
  "Anti-alias"
@@ -8317,7 +8523,13 @@ var SelectionOptionsBar = ({
8317
8523
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.selectAll(), children: "Select All" }),
8318
8524
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
8319
8525
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
8320
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", "aria-pressed": qm, className: btn(qm), onClick: () => controller.setQuickMask(!qm), children: "Quick Mask" })
8526
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !controller.canReselect(), onClick: () => controller.reselect(), children: "Reselect" }),
8527
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, title: "Add connected pixels of a selected colour (wand tolerance)", onClick: () => void runColor("grow"), children: "Grow" }),
8528
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, title: "Add every pixel of a selected colour (wand tolerance)", onClick: () => void runColor("similar"), children: "Similar" })
8529
+ ] }),
8530
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Show selection", className: "flex flex-wrap items-center gap-1", children: [
8531
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "text-muted-foreground", children: "Show" }),
8532
+ DISPLAYS.map((d) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", "aria-pressed": display === d.id, className: btn(display === d.id), onClick: () => controller.setSelectionDisplay(d.id), children: d.label }, d.id))
8321
8533
  ] }),
8322
8534
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
8323
8535
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
@@ -8332,12 +8544,57 @@ var SelectionOptionsBar = ({
8332
8544
  "aria-label": "Modify radius",
8333
8545
  value: radius,
8334
8546
  onChange: (e) => setRadius(Math.max(0, Number(e.target.value) || 0)),
8335
- className: "w-14 bg-background border border-border rounded px-1 py-0.5 text-foreground"
8547
+ className: numberInput
8336
8548
  }
8337
8549
  )
8338
8550
  ] }),
8339
8551
  MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
8340
8552
  ] }),
8553
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Edit selection", className: "flex flex-wrap items-center gap-1", children: [
8554
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
8555
+ "Stroke",
8556
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8557
+ "input",
8558
+ {
8559
+ type: "number",
8560
+ min: 1,
8561
+ max: 250,
8562
+ step: 1,
8563
+ "aria-label": "Stroke width",
8564
+ value: strokeWidth,
8565
+ onChange: (e) => setStrokeWidth(Math.min(250, Math.max(1, Number(e.target.value) || 1))),
8566
+ className: numberInput
8567
+ }
8568
+ ),
8569
+ "px"
8570
+ ] }),
8571
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8572
+ ImageSelect,
8573
+ {
8574
+ label: "Stroke location",
8575
+ value: strokeLocation,
8576
+ options: [
8577
+ { value: "outside", label: "Outside" },
8578
+ { value: "center", label: "Center" },
8579
+ { value: "inside", label: "Inside" }
8580
+ ],
8581
+ onChange: (v) => setStrokeLocation(v)
8582
+ }
8583
+ ),
8584
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.strokeSelection({ width: strokeWidth, location: strokeLocation })), children: "Stroke" }),
8585
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cropToSelection()), children: "Crop to Selection" }),
8586
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.contentAwareFill({ output: "new-layer" })), children: "Content-Aware Fill" })
8587
+ ] }),
8588
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Clipboard", className: "flex flex-wrap gap-1", children: [
8589
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels()), children: "Copy" }),
8590
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels({ merged: true })), children: "Copy Merged" }),
8591
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cutPixels()), children: "Cut" }),
8592
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("new-layer")), children: "Paste" }),
8593
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("in-place")), children: "Paste in Place" }),
8594
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("into")), children: "Paste Into" }),
8595
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("outside")), children: "Paste Outside" })
8596
+ ] }),
8597
+ colorStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: colorStatus }),
8341
8598
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { "data-testid": "selection-status", className: "text-muted-foreground", children: (0, import_image_editor14.describeSelection)(sel) })
8342
8599
  ] });
8343
8600
  };
@@ -9672,7 +9929,8 @@ var ImageEditor = ({
9672
9929
  options: selectionOptions,
9673
9930
  onOptionsChange: setSelectionOptions,
9674
9931
  selection: state.selection ?? null,
9675
- quickMask: Boolean(state.quickMask)
9932
+ quickMask: Boolean(state.quickMask),
9933
+ selectionDisplay: state.selectionDisplay
9676
9934
  }
9677
9935
  ),
9678
9936
  selectionError && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  useImageEditorControls,
51
51
  useImageEffectsTools,
52
52
  useImageHistogram
53
- } from "./chunk-CDKNJK56.js";
53
+ } from "./chunk-CQXZVIV7.js";
54
54
  import "./chunk-AJCWF6SN.js";
55
55
  import "./chunk-6BWTJ3EE.js";
56
56
  import "./chunk-5RPB4WGT.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.118.0",
3
+ "version": "0.121.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.179.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.185.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.179.0"
308
+ "@pixerate/editor": "0.185.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",