@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/{chunk-CDKNJK56.js → chunk-CQXZVIV7.js} +278 -14
- package/dist/image-editor/LayersPanel.d.cts +2 -1
- package/dist/image-editor/LayersPanel.d.ts +2 -1
- package/dist/image-editor/SelectionOptionsBar.d.cts +9 -4
- package/dist/image-editor/SelectionOptionsBar.d.ts +9 -4
- package/dist/image-editor/index.cjs +272 -14
- package/dist/image-editor/index.js +1 -1
- package/dist/index.cjs +272 -14
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -479,6 +479,7 @@ var ImageEditorCanvas = ({
|
|
|
479
479
|
const isDrawingRef = (0, import_react5.useRef)(false);
|
|
480
480
|
const currentPathRef = (0, import_react5.useRef)([]);
|
|
481
481
|
const dragStartPointRef = (0, import_react5.useRef)(null);
|
|
482
|
+
const antsOffsetRef = (0, import_react5.useRef)(0);
|
|
482
483
|
const renderCanvas = (0, import_react5.useCallback)(
|
|
483
484
|
async (draftAnnotation, draftCrop) => {
|
|
484
485
|
const canvas = canvasRef.current;
|
|
@@ -495,6 +496,7 @@ var ImageEditorCanvas = ({
|
|
|
495
496
|
fit,
|
|
496
497
|
showCropOverlay: mode === "crop",
|
|
497
498
|
showSelectionOverlay: true,
|
|
499
|
+
antsOffset: antsOffsetRef.current,
|
|
498
500
|
interactive: true,
|
|
499
501
|
draftAnnotation: draftAnnotation !== void 0 ? draftAnnotation : draftAnnotationRef.current,
|
|
500
502
|
draftCrop: draftCrop !== void 0 ? draftCrop : draftCropRef.current,
|
|
@@ -506,6 +508,14 @@ var ImageEditorCanvas = ({
|
|
|
506
508
|
},
|
|
507
509
|
[controller, mode, fit, transformTool]
|
|
508
510
|
);
|
|
511
|
+
const marching = !!state.selection?.bounds && !state.quickMask;
|
|
512
|
+
(0, import_react5.useEffect)(() => {
|
|
513
|
+
if (!marching) return;
|
|
514
|
+
return (0, import_image_editor2.startMarchingAnts)((offset) => {
|
|
515
|
+
antsOffsetRef.current = offset;
|
|
516
|
+
void renderCanvas();
|
|
517
|
+
});
|
|
518
|
+
}, [marching, renderCanvas]);
|
|
509
519
|
(0, import_react5.useEffect)(() => {
|
|
510
520
|
let drafting = false;
|
|
511
521
|
return agentPresence.subscribe(
|
|
@@ -686,6 +696,26 @@ var ImageEditorCanvas = ({
|
|
|
686
696
|
if (g.error) report("paint", g.error);
|
|
687
697
|
}
|
|
688
698
|
};
|
|
699
|
+
(0, import_react5.useEffect)(() => {
|
|
700
|
+
if (mode !== "select" || typeof window === "undefined") return;
|
|
701
|
+
const onKey = (e) => {
|
|
702
|
+
const target = e.target;
|
|
703
|
+
if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
|
|
704
|
+
if (window.getSelection?.()?.toString()) return;
|
|
705
|
+
const gesture = selectionGestureRef.current;
|
|
706
|
+
if ((0, import_image_editor2.handleSelectionShortcut)(controller, e, (message) => report("select", message))) {
|
|
707
|
+
e.preventDefault();
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
if (gesture?.key(e.key)) {
|
|
711
|
+
e.preventDefault();
|
|
712
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
713
|
+
void renderCanvas();
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
window.addEventListener("keydown", onKey);
|
|
717
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
718
|
+
});
|
|
689
719
|
(0, import_react5.useEffect)(() => {
|
|
690
720
|
if (mode !== "paint" || typeof window === "undefined") return;
|
|
691
721
|
const onKey = (e) => {
|
|
@@ -701,7 +731,11 @@ var ImageEditorCanvas = ({
|
|
|
701
731
|
if (mode === "select") {
|
|
702
732
|
const gesture = selectionGestureRef.current;
|
|
703
733
|
const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
|
|
704
|
-
void gesture.begin(imgPt, e).then(() =>
|
|
734
|
+
void gesture.begin(imgPt, e).then(() => {
|
|
735
|
+
report("select", gesture.error);
|
|
736
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
737
|
+
void renderCanvas();
|
|
738
|
+
});
|
|
705
739
|
return;
|
|
706
740
|
}
|
|
707
741
|
if (mode === "crop") {
|
|
@@ -783,7 +817,7 @@ var ImageEditorCanvas = ({
|
|
|
783
817
|
const canvasPt = getCanvasEventPoint(e);
|
|
784
818
|
if (mode === "select") {
|
|
785
819
|
const gesture = selectionGestureRef.current;
|
|
786
|
-
if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false))) {
|
|
820
|
+
if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e)) {
|
|
787
821
|
selectionDraftRef.current = gesture.draftPath;
|
|
788
822
|
renderCanvas();
|
|
789
823
|
}
|
|
@@ -926,7 +960,7 @@ var ImageEditorCanvas = ({
|
|
|
926
960
|
const gesture = selectionGestureRef.current;
|
|
927
961
|
if (gesture.active) {
|
|
928
962
|
gesture.end((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e);
|
|
929
|
-
selectionDraftRef.current =
|
|
963
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
930
964
|
renderCanvas();
|
|
931
965
|
}
|
|
932
966
|
return;
|
|
@@ -1435,7 +1469,7 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
|
|
|
1435
1469
|
type: "button",
|
|
1436
1470
|
className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",
|
|
1437
1471
|
onClick: () => {
|
|
1438
|
-
setSelectedId(controller.addAdjustmentLayer(newKind));
|
|
1472
|
+
setSelectedId(controller.addAdjustmentLayer({ kind: newKind, useSelection: true }));
|
|
1439
1473
|
setChannel("master");
|
|
1440
1474
|
setRange(-1);
|
|
1441
1475
|
},
|
|
@@ -1988,7 +2022,14 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
1988
2022
|
pixels: thumb(layer),
|
|
1989
2023
|
size: thumbnailSize,
|
|
1990
2024
|
label: `${row.label} pixels`,
|
|
1991
|
-
|
|
2025
|
+
testId: "layer-thumbnail",
|
|
2026
|
+
selected: row.active && state.activeTarget === "pixels" && Boolean(layer.mask),
|
|
2027
|
+
onClick: (e) => {
|
|
2028
|
+
if (e.ctrlKey || e.metaKey) {
|
|
2029
|
+
e.stopPropagation();
|
|
2030
|
+
attempt(() => (0, import_image_editor8.layerThumbnailClick)(controller, layer, e));
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
1992
2033
|
}
|
|
1993
2034
|
),
|
|
1994
2035
|
layer.type !== "pixel" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -2033,8 +2074,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
2033
2074
|
selected: row.active && state.activeTarget === "mask",
|
|
2034
2075
|
onClick: (e) => {
|
|
2035
2076
|
e.stopPropagation();
|
|
2036
|
-
|
|
2037
|
-
else attempt(() => controller.setActiveLayer(layer.id, "mask"));
|
|
2077
|
+
attempt(() => (0, import_image_editor8.maskThumbnailClick)(controller, layer, e));
|
|
2038
2078
|
}
|
|
2039
2079
|
}
|
|
2040
2080
|
),
|
|
@@ -4106,7 +4146,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
4106
4146
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
|
|
4107
4147
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
|
|
4108
4148
|
] }),
|
|
4109
|
-
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
4149
|
+
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
|
|
4110
4150
|
filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
4111
4151
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
4112
4152
|
const all = layer.smartFilters.filters;
|
|
@@ -4541,12 +4581,18 @@ var import_react25 = require("react");
|
|
|
4541
4581
|
var import_image_editor14 = require("@pixerate/editor/image-editor");
|
|
4542
4582
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4543
4583
|
var MODIFY_OPS = [
|
|
4544
|
-
{ op: "
|
|
4545
|
-
{ op: "
|
|
4584
|
+
{ op: "expand", label: "Expand" },
|
|
4585
|
+
{ op: "contract", label: "Contract" },
|
|
4546
4586
|
{ op: "feather", label: "Feather" },
|
|
4547
4587
|
{ op: "border", label: "Border" },
|
|
4548
4588
|
{ op: "smooth", label: "Smooth" }
|
|
4549
4589
|
];
|
|
4590
|
+
var DISPLAYS = [
|
|
4591
|
+
{ id: "ants", label: "Ants" },
|
|
4592
|
+
{ id: "quickMask", label: "Quick Mask" },
|
|
4593
|
+
{ id: "none", label: "Hidden" }
|
|
4594
|
+
];
|
|
4595
|
+
var numberInput = "w-14 bg-background border border-border rounded px-1 py-0.5 text-foreground";
|
|
4550
4596
|
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"}`;
|
|
4551
4597
|
var SelectionOptionsBar = ({
|
|
4552
4598
|
controller,
|
|
@@ -4554,12 +4600,67 @@ var SelectionOptionsBar = ({
|
|
|
4554
4600
|
onOptionsChange,
|
|
4555
4601
|
selection,
|
|
4556
4602
|
quickMask,
|
|
4603
|
+
selectionDisplay,
|
|
4557
4604
|
className = ""
|
|
4558
4605
|
}) => {
|
|
4559
4606
|
const [radius, setRadius] = (0, import_react25.useState)(2);
|
|
4560
4607
|
const set = (patch) => onOptionsChange({ ...options, ...patch });
|
|
4561
4608
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
4562
|
-
const
|
|
4609
|
+
const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
|
|
4610
|
+
const [preset, setPreset] = (0, import_react25.useState)("reds");
|
|
4611
|
+
const [rangeStatus, setRangeStatus] = (0, import_react25.useState)(null);
|
|
4612
|
+
const [colorStatus, setColorStatus] = (0, import_react25.useState)(null);
|
|
4613
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react25.useState)(4);
|
|
4614
|
+
const [strokeLocation, setStrokeLocation] = (0, import_react25.useState)("outside");
|
|
4615
|
+
const edit = (fn) => {
|
|
4616
|
+
setColorStatus(null);
|
|
4617
|
+
try {
|
|
4618
|
+
fn();
|
|
4619
|
+
} catch (err) {
|
|
4620
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
4621
|
+
}
|
|
4622
|
+
};
|
|
4623
|
+
const runColor = async (op) => {
|
|
4624
|
+
setColorStatus(null);
|
|
4625
|
+
const opts = { tolerance: options.tolerance, sampleMerged: options.sampleMerged, sample: options.sample };
|
|
4626
|
+
try {
|
|
4627
|
+
await (op === "grow" ? controller.growSelection(opts) : controller.selectSimilar(opts));
|
|
4628
|
+
} catch (err) {
|
|
4629
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
4630
|
+
}
|
|
4631
|
+
};
|
|
4632
|
+
const applyPreset = async () => {
|
|
4633
|
+
setRangeStatus(null);
|
|
4634
|
+
try {
|
|
4635
|
+
await controller.selectColorRangePreset(preset, {
|
|
4636
|
+
mode: options.mode,
|
|
4637
|
+
feather: options.feather ?? 0,
|
|
4638
|
+
invert: options.rangeInvert ?? false,
|
|
4639
|
+
falloff: options.fuzziness ?? 20,
|
|
4640
|
+
sampleMerged: options.sampleMerged,
|
|
4641
|
+
sample: options.sample
|
|
4642
|
+
});
|
|
4643
|
+
} catch (err) {
|
|
4644
|
+
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
4645
|
+
}
|
|
4646
|
+
};
|
|
4647
|
+
const [subject, setSubject] = (0, import_react25.useState)("");
|
|
4648
|
+
const [segmenting, setSegmenting] = (0, import_react25.useState)(false);
|
|
4649
|
+
const [subjectStatus, setSubjectStatus] = (0, import_react25.useState)(null);
|
|
4650
|
+
const selectSubject = async () => {
|
|
4651
|
+
const target = subject.trim();
|
|
4652
|
+
if (!target || segmenting) return;
|
|
4653
|
+
setSegmenting(true);
|
|
4654
|
+
setSubjectStatus(null);
|
|
4655
|
+
try {
|
|
4656
|
+
const { segments } = await controller.selectSubject(target, { mode: options.mode });
|
|
4657
|
+
setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
|
|
4658
|
+
} catch (err) {
|
|
4659
|
+
setSubjectStatus(err instanceof Error ? err.message : String(err));
|
|
4660
|
+
} finally {
|
|
4661
|
+
setSegmenting(false);
|
|
4662
|
+
}
|
|
4663
|
+
};
|
|
4563
4664
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-testid": "selection-options-bar", className: `flex flex-col gap-3 text-xs ${className}`, children: [
|
|
4564
4665
|
/* @__PURE__ */ (0, import_jsx_runtime25.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_runtime25.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)) }),
|
|
4565
4666
|
/* @__PURE__ */ (0, import_jsx_runtime25.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_runtime25.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)) }),
|
|
@@ -4575,6 +4676,21 @@ var SelectionOptionsBar = ({
|
|
|
4575
4676
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageCheckbox, { label: "Contiguous", checked: options.contiguous, onChange: (on) => set({ contiguous: on }) }),
|
|
4576
4677
|
"Contiguous"
|
|
4577
4678
|
] }),
|
|
4679
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
4680
|
+
"Distance",
|
|
4681
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4682
|
+
ImageSelect,
|
|
4683
|
+
{
|
|
4684
|
+
label: "Colour distance",
|
|
4685
|
+
value: options.distance,
|
|
4686
|
+
options: [
|
|
4687
|
+
{ value: "rgb", label: "RGB" },
|
|
4688
|
+
{ value: "perceptual", label: "Perceptual" }
|
|
4689
|
+
],
|
|
4690
|
+
onChange: (v) => set({ distance: v })
|
|
4691
|
+
}
|
|
4692
|
+
)
|
|
4693
|
+
] }),
|
|
4578
4694
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
4579
4695
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageCheckbox, { label: "Sample adjusted image", checked: options.sampleMerged, onChange: (on) => set({ sampleMerged: on }) }),
|
|
4580
4696
|
"Sample adjusted image"
|
|
@@ -4595,6 +4711,96 @@ var SelectionOptionsBar = ({
|
|
|
4595
4711
|
)
|
|
4596
4712
|
] })
|
|
4597
4713
|
] }),
|
|
4714
|
+
options.tool === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime25.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." }),
|
|
4715
|
+
options.tool === "range" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-testid": "color-range-options", className: "flex flex-col gap-2", children: [
|
|
4716
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-muted-foreground", children: "Click a colour to select it; Shift-click adds a colour, Alt-click removes one." }),
|
|
4717
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
4718
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
4719
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Fuzziness" }),
|
|
4720
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: options.fuzziness ?? 40 })
|
|
4721
|
+
] }),
|
|
4722
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageRange, { label: "Fuzziness", min: 0, max: 200, step: 1, value: options.fuzziness ?? 40, onChange: (v) => set({ fuzziness: v }) })
|
|
4723
|
+
] }),
|
|
4724
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
4725
|
+
"Localized radius",
|
|
4726
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4727
|
+
"input",
|
|
4728
|
+
{
|
|
4729
|
+
type: "number",
|
|
4730
|
+
min: 0,
|
|
4731
|
+
step: 1,
|
|
4732
|
+
"aria-label": "Localized radius",
|
|
4733
|
+
value: options.localized ?? 0,
|
|
4734
|
+
onChange: (e) => set({ localized: Math.max(0, Number(e.target.value) || 0) }),
|
|
4735
|
+
className: numberInput
|
|
4736
|
+
}
|
|
4737
|
+
),
|
|
4738
|
+
"px"
|
|
4739
|
+
] }),
|
|
4740
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
4741
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageCheckbox, { label: "Invert", checked: options.rangeInvert ?? false, onChange: (on) => set({ rangeInvert: on }) }),
|
|
4742
|
+
"Invert"
|
|
4743
|
+
] }),
|
|
4744
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4745
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4746
|
+
ImageSelect,
|
|
4747
|
+
{
|
|
4748
|
+
label: "Color Range preset",
|
|
4749
|
+
value: preset,
|
|
4750
|
+
options: import_image_editor14.COLOR_RANGE_PRESETS.map((p) => ({ value: p, label: import_image_editor14.COLOR_RANGE_PRESET_LABELS[p] })),
|
|
4751
|
+
onChange: (v) => setPreset(v)
|
|
4752
|
+
}
|
|
4753
|
+
),
|
|
4754
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => void applyPreset(), children: "Select" })
|
|
4755
|
+
] }),
|
|
4756
|
+
rangeStatus && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "status", className: "text-muted-foreground", children: rangeStatus })
|
|
4757
|
+
] }),
|
|
4758
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
4759
|
+
"Feather",
|
|
4760
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4761
|
+
"input",
|
|
4762
|
+
{
|
|
4763
|
+
type: "number",
|
|
4764
|
+
min: 0,
|
|
4765
|
+
max: 1e3,
|
|
4766
|
+
step: 0.5,
|
|
4767
|
+
"aria-label": "Feather",
|
|
4768
|
+
value: options.feather ?? 0,
|
|
4769
|
+
onChange: (e) => set({ feather: Math.max(0, Number(e.target.value) || 0) }),
|
|
4770
|
+
className: numberInput
|
|
4771
|
+
}
|
|
4772
|
+
),
|
|
4773
|
+
"px"
|
|
4774
|
+
] }),
|
|
4775
|
+
controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4776
|
+
"form",
|
|
4777
|
+
{
|
|
4778
|
+
"data-testid": "select-subject",
|
|
4779
|
+
className: "flex flex-col gap-1",
|
|
4780
|
+
onSubmit: (e) => {
|
|
4781
|
+
e.preventDefault();
|
|
4782
|
+
void selectSubject();
|
|
4783
|
+
},
|
|
4784
|
+
children: [
|
|
4785
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-1", children: [
|
|
4786
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4787
|
+
"input",
|
|
4788
|
+
{
|
|
4789
|
+
type: "text",
|
|
4790
|
+
"aria-label": "Subject to select",
|
|
4791
|
+
placeholder: "Subject, e.g. the dog",
|
|
4792
|
+
value: subject,
|
|
4793
|
+
disabled: segmenting,
|
|
4794
|
+
onChange: (e) => setSubject(e.currentTarget.value),
|
|
4795
|
+
className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
|
|
4796
|
+
}
|
|
4797
|
+
),
|
|
4798
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
|
|
4799
|
+
] }),
|
|
4800
|
+
subjectStatus && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
|
|
4801
|
+
]
|
|
4802
|
+
}
|
|
4803
|
+
),
|
|
4598
4804
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
4599
4805
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageCheckbox, { label: "Anti-alias", checked: options.antiAlias, onChange: (on) => set({ antiAlias: on }) }),
|
|
4600
4806
|
"Anti-alias"
|
|
@@ -4603,7 +4809,13 @@ var SelectionOptionsBar = ({
|
|
|
4603
4809
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.selectAll(), children: "Select All" }),
|
|
4604
4810
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
|
|
4605
4811
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
|
|
4606
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button",
|
|
4812
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !controller.canReselect(), onClick: () => controller.reselect(), children: "Reselect" }),
|
|
4813
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" }),
|
|
4814
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" })
|
|
4815
|
+
] }),
|
|
4816
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { role: "group", "aria-label": "Show selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
4817
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-muted-foreground", children: "Show" }),
|
|
4818
|
+
DISPLAYS.map((d) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-pressed": display === d.id, className: btn(display === d.id), onClick: () => controller.setSelectionDisplay(d.id), children: d.label }, d.id))
|
|
4607
4819
|
] }),
|
|
4608
4820
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
4609
4821
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
@@ -4618,12 +4830,57 @@ var SelectionOptionsBar = ({
|
|
|
4618
4830
|
"aria-label": "Modify radius",
|
|
4619
4831
|
value: radius,
|
|
4620
4832
|
onChange: (e) => setRadius(Math.max(0, Number(e.target.value) || 0)),
|
|
4621
|
-
className:
|
|
4833
|
+
className: numberInput
|
|
4622
4834
|
}
|
|
4623
4835
|
)
|
|
4624
4836
|
] }),
|
|
4625
4837
|
MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
|
|
4626
4838
|
] }),
|
|
4839
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { role: "group", "aria-label": "Edit selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
4840
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
4841
|
+
"Stroke",
|
|
4842
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4843
|
+
"input",
|
|
4844
|
+
{
|
|
4845
|
+
type: "number",
|
|
4846
|
+
min: 1,
|
|
4847
|
+
max: 250,
|
|
4848
|
+
step: 1,
|
|
4849
|
+
"aria-label": "Stroke width",
|
|
4850
|
+
value: strokeWidth,
|
|
4851
|
+
onChange: (e) => setStrokeWidth(Math.min(250, Math.max(1, Number(e.target.value) || 1))),
|
|
4852
|
+
className: numberInput
|
|
4853
|
+
}
|
|
4854
|
+
),
|
|
4855
|
+
"px"
|
|
4856
|
+
] }),
|
|
4857
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4858
|
+
ImageSelect,
|
|
4859
|
+
{
|
|
4860
|
+
label: "Stroke location",
|
|
4861
|
+
value: strokeLocation,
|
|
4862
|
+
options: [
|
|
4863
|
+
{ value: "outside", label: "Outside" },
|
|
4864
|
+
{ value: "center", label: "Center" },
|
|
4865
|
+
{ value: "inside", label: "Inside" }
|
|
4866
|
+
],
|
|
4867
|
+
onChange: (v) => setStrokeLocation(v)
|
|
4868
|
+
}
|
|
4869
|
+
),
|
|
4870
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.strokeSelection({ width: strokeWidth, location: strokeLocation })), children: "Stroke" }),
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cropToSelection()), children: "Crop to Selection" }),
|
|
4872
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.contentAwareFill({ output: "new-layer" })), children: "Content-Aware Fill" })
|
|
4873
|
+
] }),
|
|
4874
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { role: "group", "aria-label": "Clipboard", className: "flex flex-wrap gap-1", children: [
|
|
4875
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels()), children: "Copy" }),
|
|
4876
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels({ merged: true })), children: "Copy Merged" }),
|
|
4877
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cutPixels()), children: "Cut" }),
|
|
4878
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("new-layer")), children: "Paste" }),
|
|
4879
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("in-place")), children: "Paste in Place" }),
|
|
4880
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("into")), children: "Paste Into" }),
|
|
4881
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("outside")), children: "Paste Outside" })
|
|
4882
|
+
] }),
|
|
4883
|
+
colorStatus && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "status", className: "text-muted-foreground", children: colorStatus }),
|
|
4627
4884
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { "data-testid": "selection-status", className: "text-muted-foreground", children: (0, import_image_editor14.describeSelection)(sel) })
|
|
4628
4885
|
] });
|
|
4629
4886
|
};
|
|
@@ -5958,7 +6215,8 @@ var ImageEditor = ({
|
|
|
5958
6215
|
options: selectionOptions,
|
|
5959
6216
|
onOptionsChange: setSelectionOptions,
|
|
5960
6217
|
selection: state.selection ?? null,
|
|
5961
|
-
quickMask: Boolean(state.quickMask)
|
|
6218
|
+
quickMask: Boolean(state.quickMask),
|
|
6219
|
+
selectionDisplay: state.selectionDisplay
|
|
5962
6220
|
}
|
|
5963
6221
|
),
|
|
5964
6222
|
selectionError && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
|