@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
|
@@ -222,6 +222,8 @@ import {
|
|
|
222
222
|
getViewportProjection,
|
|
223
223
|
measureCanvasViewport,
|
|
224
224
|
watchCanvasViewport,
|
|
225
|
+
startMarchingAnts,
|
|
226
|
+
handleSelectionShortcut,
|
|
225
227
|
ShapeDrawGesture,
|
|
226
228
|
TypeToolGesture,
|
|
227
229
|
DEFAULT_SHAPE_TOOL_OPTIONS,
|
|
@@ -375,6 +377,7 @@ var ImageEditorCanvas = ({
|
|
|
375
377
|
const isDrawingRef = useRef2(false);
|
|
376
378
|
const currentPathRef = useRef2([]);
|
|
377
379
|
const dragStartPointRef = useRef2(null);
|
|
380
|
+
const antsOffsetRef = useRef2(0);
|
|
378
381
|
const renderCanvas = useCallback2(
|
|
379
382
|
async (draftAnnotation, draftCrop) => {
|
|
380
383
|
const canvas = canvasRef.current;
|
|
@@ -391,6 +394,7 @@ var ImageEditorCanvas = ({
|
|
|
391
394
|
fit,
|
|
392
395
|
showCropOverlay: mode === "crop",
|
|
393
396
|
showSelectionOverlay: true,
|
|
397
|
+
antsOffset: antsOffsetRef.current,
|
|
394
398
|
interactive: true,
|
|
395
399
|
draftAnnotation: draftAnnotation !== void 0 ? draftAnnotation : draftAnnotationRef.current,
|
|
396
400
|
draftCrop: draftCrop !== void 0 ? draftCrop : draftCropRef.current,
|
|
@@ -402,6 +406,14 @@ var ImageEditorCanvas = ({
|
|
|
402
406
|
},
|
|
403
407
|
[controller, mode, fit, transformTool]
|
|
404
408
|
);
|
|
409
|
+
const marching = !!state.selection?.bounds && !state.quickMask;
|
|
410
|
+
useEffect2(() => {
|
|
411
|
+
if (!marching) return;
|
|
412
|
+
return startMarchingAnts((offset) => {
|
|
413
|
+
antsOffsetRef.current = offset;
|
|
414
|
+
void renderCanvas();
|
|
415
|
+
});
|
|
416
|
+
}, [marching, renderCanvas]);
|
|
405
417
|
useEffect2(() => {
|
|
406
418
|
let drafting = false;
|
|
407
419
|
return agentPresence.subscribe(
|
|
@@ -582,6 +594,26 @@ var ImageEditorCanvas = ({
|
|
|
582
594
|
if (g.error) report("paint", g.error);
|
|
583
595
|
}
|
|
584
596
|
};
|
|
597
|
+
useEffect2(() => {
|
|
598
|
+
if (mode !== "select" || typeof window === "undefined") return;
|
|
599
|
+
const onKey = (e) => {
|
|
600
|
+
const target = e.target;
|
|
601
|
+
if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
|
|
602
|
+
if (window.getSelection?.()?.toString()) return;
|
|
603
|
+
const gesture = selectionGestureRef.current;
|
|
604
|
+
if (handleSelectionShortcut(controller, e, (message) => report("select", message))) {
|
|
605
|
+
e.preventDefault();
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (gesture?.key(e.key)) {
|
|
609
|
+
e.preventDefault();
|
|
610
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
611
|
+
void renderCanvas();
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
window.addEventListener("keydown", onKey);
|
|
615
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
616
|
+
});
|
|
585
617
|
useEffect2(() => {
|
|
586
618
|
if (mode !== "paint" || typeof window === "undefined") return;
|
|
587
619
|
const onKey = (e) => {
|
|
@@ -597,7 +629,11 @@ var ImageEditorCanvas = ({
|
|
|
597
629
|
if (mode === "select") {
|
|
598
630
|
const gesture = selectionGestureRef.current;
|
|
599
631
|
const imgPt = canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
|
|
600
|
-
void gesture.begin(imgPt, e).then(() =>
|
|
632
|
+
void gesture.begin(imgPt, e).then(() => {
|
|
633
|
+
report("select", gesture.error);
|
|
634
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
635
|
+
void renderCanvas();
|
|
636
|
+
});
|
|
601
637
|
return;
|
|
602
638
|
}
|
|
603
639
|
if (mode === "crop") {
|
|
@@ -679,7 +715,7 @@ var ImageEditorCanvas = ({
|
|
|
679
715
|
const canvasPt = getCanvasEventPoint(e);
|
|
680
716
|
if (mode === "select") {
|
|
681
717
|
const gesture = selectionGestureRef.current;
|
|
682
|
-
if (gesture.active && gesture.move(canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false))) {
|
|
718
|
+
if (gesture.active && gesture.move(canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e)) {
|
|
683
719
|
selectionDraftRef.current = gesture.draftPath;
|
|
684
720
|
renderCanvas();
|
|
685
721
|
}
|
|
@@ -822,7 +858,7 @@ var ImageEditorCanvas = ({
|
|
|
822
858
|
const gesture = selectionGestureRef.current;
|
|
823
859
|
if (gesture.active) {
|
|
824
860
|
gesture.end(canvasToImagePoint(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e);
|
|
825
|
-
selectionDraftRef.current =
|
|
861
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
826
862
|
renderCanvas();
|
|
827
863
|
}
|
|
828
864
|
return;
|
|
@@ -1350,7 +1386,7 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
|
|
|
1350
1386
|
type: "button",
|
|
1351
1387
|
className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",
|
|
1352
1388
|
onClick: () => {
|
|
1353
|
-
setSelectedId(controller.addAdjustmentLayer(newKind));
|
|
1389
|
+
setSelectedId(controller.addAdjustmentLayer({ kind: newKind, useSelection: true }));
|
|
1354
1390
|
setChannel("master");
|
|
1355
1391
|
setRange(-1);
|
|
1356
1392
|
},
|
|
@@ -1612,6 +1648,8 @@ import {
|
|
|
1612
1648
|
downloadPsd,
|
|
1613
1649
|
dropPlacement,
|
|
1614
1650
|
dropZone,
|
|
1651
|
+
maskThumbnailClick,
|
|
1652
|
+
layerThumbnailClick,
|
|
1615
1653
|
openPsdFile,
|
|
1616
1654
|
layerBadge,
|
|
1617
1655
|
layerHasThumbnail,
|
|
@@ -1918,7 +1956,14 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
1918
1956
|
pixels: thumb(layer),
|
|
1919
1957
|
size: thumbnailSize,
|
|
1920
1958
|
label: `${row.label} pixels`,
|
|
1921
|
-
|
|
1959
|
+
testId: "layer-thumbnail",
|
|
1960
|
+
selected: row.active && state.activeTarget === "pixels" && Boolean(layer.mask),
|
|
1961
|
+
onClick: (e) => {
|
|
1962
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1963
|
+
e.stopPropagation();
|
|
1964
|
+
attempt(() => layerThumbnailClick(controller, layer, e));
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1922
1967
|
}
|
|
1923
1968
|
),
|
|
1924
1969
|
layer.type !== "pixel" && /* @__PURE__ */ jsx8(
|
|
@@ -1963,8 +2008,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
1963
2008
|
selected: row.active && state.activeTarget === "mask",
|
|
1964
2009
|
onClick: (e) => {
|
|
1965
2010
|
e.stopPropagation();
|
|
1966
|
-
|
|
1967
|
-
else attempt(() => controller.setActiveLayer(layer.id, "mask"));
|
|
2011
|
+
attempt(() => maskThumbnailClick(controller, layer, e));
|
|
1968
2012
|
}
|
|
1969
2013
|
}
|
|
1970
2014
|
),
|
|
@@ -2270,7 +2314,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
2270
2314
|
/* @__PURE__ */ jsx11("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
|
|
2271
2315
|
/* @__PURE__ */ jsx11("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
|
|
2272
2316
|
] }),
|
|
2273
|
-
browse === "filter" && layer && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
2317
|
+
browse === "filter" && layer && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
|
|
2274
2318
|
filters.length > 0 && layer && /* @__PURE__ */ jsx11("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
2275
2319
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
2276
2320
|
const all = layer.smartFilters.filters;
|
|
@@ -2594,6 +2638,8 @@ var ColorProfilePanel = ({ controller, className }) => {
|
|
|
2594
2638
|
// src/image-editor/SelectionOptionsBar.tsx
|
|
2595
2639
|
import { useState as useState11 } from "react";
|
|
2596
2640
|
import {
|
|
2641
|
+
COLOR_RANGE_PRESETS,
|
|
2642
|
+
COLOR_RANGE_PRESET_LABELS,
|
|
2597
2643
|
SELECTION_MODES,
|
|
2598
2644
|
SELECTION_MODE_LABELS,
|
|
2599
2645
|
SELECTION_TOOLS,
|
|
@@ -2601,12 +2647,18 @@ import {
|
|
|
2601
2647
|
} from "@pixerate/editor/image-editor";
|
|
2602
2648
|
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2603
2649
|
var MODIFY_OPS = [
|
|
2604
|
-
{ op: "
|
|
2605
|
-
{ op: "
|
|
2650
|
+
{ op: "expand", label: "Expand" },
|
|
2651
|
+
{ op: "contract", label: "Contract" },
|
|
2606
2652
|
{ op: "feather", label: "Feather" },
|
|
2607
2653
|
{ op: "border", label: "Border" },
|
|
2608
2654
|
{ op: "smooth", label: "Smooth" }
|
|
2609
2655
|
];
|
|
2656
|
+
var DISPLAYS = [
|
|
2657
|
+
{ id: "ants", label: "Ants" },
|
|
2658
|
+
{ id: "quickMask", label: "Quick Mask" },
|
|
2659
|
+
{ id: "none", label: "Hidden" }
|
|
2660
|
+
];
|
|
2661
|
+
var numberInput = "w-14 bg-background border border-border rounded px-1 py-0.5 text-foreground";
|
|
2610
2662
|
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"}`;
|
|
2611
2663
|
var SelectionOptionsBar = ({
|
|
2612
2664
|
controller,
|
|
@@ -2614,12 +2666,67 @@ var SelectionOptionsBar = ({
|
|
|
2614
2666
|
onOptionsChange,
|
|
2615
2667
|
selection,
|
|
2616
2668
|
quickMask,
|
|
2669
|
+
selectionDisplay,
|
|
2617
2670
|
className = ""
|
|
2618
2671
|
}) => {
|
|
2619
2672
|
const [radius, setRadius] = useState11(2);
|
|
2620
2673
|
const set = (patch) => onOptionsChange({ ...options, ...patch });
|
|
2621
2674
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
2622
|
-
const
|
|
2675
|
+
const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
|
|
2676
|
+
const [preset, setPreset] = useState11("reds");
|
|
2677
|
+
const [rangeStatus, setRangeStatus] = useState11(null);
|
|
2678
|
+
const [colorStatus, setColorStatus] = useState11(null);
|
|
2679
|
+
const [strokeWidth, setStrokeWidth] = useState11(4);
|
|
2680
|
+
const [strokeLocation, setStrokeLocation] = useState11("outside");
|
|
2681
|
+
const edit = (fn) => {
|
|
2682
|
+
setColorStatus(null);
|
|
2683
|
+
try {
|
|
2684
|
+
fn();
|
|
2685
|
+
} catch (err) {
|
|
2686
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
const runColor = async (op) => {
|
|
2690
|
+
setColorStatus(null);
|
|
2691
|
+
const opts = { tolerance: options.tolerance, sampleMerged: options.sampleMerged, sample: options.sample };
|
|
2692
|
+
try {
|
|
2693
|
+
await (op === "grow" ? controller.growSelection(opts) : controller.selectSimilar(opts));
|
|
2694
|
+
} catch (err) {
|
|
2695
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
2696
|
+
}
|
|
2697
|
+
};
|
|
2698
|
+
const applyPreset = async () => {
|
|
2699
|
+
setRangeStatus(null);
|
|
2700
|
+
try {
|
|
2701
|
+
await controller.selectColorRangePreset(preset, {
|
|
2702
|
+
mode: options.mode,
|
|
2703
|
+
feather: options.feather ?? 0,
|
|
2704
|
+
invert: options.rangeInvert ?? false,
|
|
2705
|
+
falloff: options.fuzziness ?? 20,
|
|
2706
|
+
sampleMerged: options.sampleMerged,
|
|
2707
|
+
sample: options.sample
|
|
2708
|
+
});
|
|
2709
|
+
} catch (err) {
|
|
2710
|
+
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
const [subject, setSubject] = useState11("");
|
|
2714
|
+
const [segmenting, setSegmenting] = useState11(false);
|
|
2715
|
+
const [subjectStatus, setSubjectStatus] = useState11(null);
|
|
2716
|
+
const selectSubject = async () => {
|
|
2717
|
+
const target = subject.trim();
|
|
2718
|
+
if (!target || segmenting) return;
|
|
2719
|
+
setSegmenting(true);
|
|
2720
|
+
setSubjectStatus(null);
|
|
2721
|
+
try {
|
|
2722
|
+
const { segments } = await controller.selectSubject(target, { mode: options.mode });
|
|
2723
|
+
setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
|
|
2724
|
+
} catch (err) {
|
|
2725
|
+
setSubjectStatus(err instanceof Error ? err.message : String(err));
|
|
2726
|
+
} finally {
|
|
2727
|
+
setSegmenting(false);
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2623
2730
|
return /* @__PURE__ */ jsxs13("div", { "data-testid": "selection-options-bar", className: `flex flex-col gap-3 text-xs ${className}`, children: [
|
|
2624
2731
|
/* @__PURE__ */ jsx15("div", { role: "group", "aria-label": "Selection tool", className: "flex flex-wrap gap-1", children: SELECTION_TOOLS.map((t) => /* @__PURE__ */ jsx15("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)) }),
|
|
2625
2732
|
/* @__PURE__ */ jsx15("div", { role: "group", "aria-label": "Selection mode", className: "flex flex-wrap gap-1", children: SELECTION_MODES.map((m) => /* @__PURE__ */ jsx15("button", { type: "button", "aria-pressed": options.mode === m, className: btn(options.mode === m), onClick: () => set({ mode: m }), children: SELECTION_MODE_LABELS[m] }, m)) }),
|
|
@@ -2635,6 +2742,21 @@ var SelectionOptionsBar = ({
|
|
|
2635
2742
|
/* @__PURE__ */ jsx15(ImageCheckbox, { label: "Contiguous", checked: options.contiguous, onChange: (on) => set({ contiguous: on }) }),
|
|
2636
2743
|
"Contiguous"
|
|
2637
2744
|
] }),
|
|
2745
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
2746
|
+
"Distance",
|
|
2747
|
+
/* @__PURE__ */ jsx15(
|
|
2748
|
+
ImageSelect,
|
|
2749
|
+
{
|
|
2750
|
+
label: "Colour distance",
|
|
2751
|
+
value: options.distance,
|
|
2752
|
+
options: [
|
|
2753
|
+
{ value: "rgb", label: "RGB" },
|
|
2754
|
+
{ value: "perceptual", label: "Perceptual" }
|
|
2755
|
+
],
|
|
2756
|
+
onChange: (v) => set({ distance: v })
|
|
2757
|
+
}
|
|
2758
|
+
)
|
|
2759
|
+
] }),
|
|
2638
2760
|
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
2639
2761
|
/* @__PURE__ */ jsx15(ImageCheckbox, { label: "Sample adjusted image", checked: options.sampleMerged, onChange: (on) => set({ sampleMerged: on }) }),
|
|
2640
2762
|
"Sample adjusted image"
|
|
@@ -2655,6 +2777,96 @@ var SelectionOptionsBar = ({
|
|
|
2655
2777
|
)
|
|
2656
2778
|
] })
|
|
2657
2779
|
] }),
|
|
2780
|
+
options.tool === "polygon" && /* @__PURE__ */ jsx15("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." }),
|
|
2781
|
+
options.tool === "range" && /* @__PURE__ */ jsxs13("div", { "data-testid": "color-range-options", className: "flex flex-col gap-2", children: [
|
|
2782
|
+
/* @__PURE__ */ jsx15("p", { className: "text-muted-foreground", children: "Click a colour to select it; Shift-click adds a colour, Alt-click removes one." }),
|
|
2783
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
|
|
2784
|
+
/* @__PURE__ */ jsxs13("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
2785
|
+
/* @__PURE__ */ jsx15("span", { children: "Fuzziness" }),
|
|
2786
|
+
/* @__PURE__ */ jsx15("span", { className: "font-mono", children: options.fuzziness ?? 40 })
|
|
2787
|
+
] }),
|
|
2788
|
+
/* @__PURE__ */ jsx15(ImageRange, { label: "Fuzziness", min: 0, max: 200, step: 1, value: options.fuzziness ?? 40, onChange: (v) => set({ fuzziness: v }) })
|
|
2789
|
+
] }),
|
|
2790
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
2791
|
+
"Localized radius",
|
|
2792
|
+
/* @__PURE__ */ jsx15(
|
|
2793
|
+
"input",
|
|
2794
|
+
{
|
|
2795
|
+
type: "number",
|
|
2796
|
+
min: 0,
|
|
2797
|
+
step: 1,
|
|
2798
|
+
"aria-label": "Localized radius",
|
|
2799
|
+
value: options.localized ?? 0,
|
|
2800
|
+
onChange: (e) => set({ localized: Math.max(0, Number(e.target.value) || 0) }),
|
|
2801
|
+
className: numberInput
|
|
2802
|
+
}
|
|
2803
|
+
),
|
|
2804
|
+
"px"
|
|
2805
|
+
] }),
|
|
2806
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
2807
|
+
/* @__PURE__ */ jsx15(ImageCheckbox, { label: "Invert", checked: options.rangeInvert ?? false, onChange: (on) => set({ rangeInvert: on }) }),
|
|
2808
|
+
"Invert"
|
|
2809
|
+
] }),
|
|
2810
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
|
|
2811
|
+
/* @__PURE__ */ jsx15(
|
|
2812
|
+
ImageSelect,
|
|
2813
|
+
{
|
|
2814
|
+
label: "Color Range preset",
|
|
2815
|
+
value: preset,
|
|
2816
|
+
options: COLOR_RANGE_PRESETS.map((p) => ({ value: p, label: COLOR_RANGE_PRESET_LABELS[p] })),
|
|
2817
|
+
onChange: (v) => setPreset(v)
|
|
2818
|
+
}
|
|
2819
|
+
),
|
|
2820
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => void applyPreset(), children: "Select" })
|
|
2821
|
+
] }),
|
|
2822
|
+
rangeStatus && /* @__PURE__ */ jsx15("p", { role: "status", className: "text-muted-foreground", children: rangeStatus })
|
|
2823
|
+
] }),
|
|
2824
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
2825
|
+
"Feather",
|
|
2826
|
+
/* @__PURE__ */ jsx15(
|
|
2827
|
+
"input",
|
|
2828
|
+
{
|
|
2829
|
+
type: "number",
|
|
2830
|
+
min: 0,
|
|
2831
|
+
max: 1e3,
|
|
2832
|
+
step: 0.5,
|
|
2833
|
+
"aria-label": "Feather",
|
|
2834
|
+
value: options.feather ?? 0,
|
|
2835
|
+
onChange: (e) => set({ feather: Math.max(0, Number(e.target.value) || 0) }),
|
|
2836
|
+
className: numberInput
|
|
2837
|
+
}
|
|
2838
|
+
),
|
|
2839
|
+
"px"
|
|
2840
|
+
] }),
|
|
2841
|
+
controller.segmentationProvider && /* @__PURE__ */ jsxs13(
|
|
2842
|
+
"form",
|
|
2843
|
+
{
|
|
2844
|
+
"data-testid": "select-subject",
|
|
2845
|
+
className: "flex flex-col gap-1",
|
|
2846
|
+
onSubmit: (e) => {
|
|
2847
|
+
e.preventDefault();
|
|
2848
|
+
void selectSubject();
|
|
2849
|
+
},
|
|
2850
|
+
children: [
|
|
2851
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex gap-1", children: [
|
|
2852
|
+
/* @__PURE__ */ jsx15(
|
|
2853
|
+
"input",
|
|
2854
|
+
{
|
|
2855
|
+
type: "text",
|
|
2856
|
+
"aria-label": "Subject to select",
|
|
2857
|
+
placeholder: "Subject, e.g. the dog",
|
|
2858
|
+
value: subject,
|
|
2859
|
+
disabled: segmenting,
|
|
2860
|
+
onChange: (e) => setSubject(e.currentTarget.value),
|
|
2861
|
+
className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
|
|
2862
|
+
}
|
|
2863
|
+
),
|
|
2864
|
+
/* @__PURE__ */ jsx15("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
|
|
2865
|
+
] }),
|
|
2866
|
+
subjectStatus && /* @__PURE__ */ jsx15("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
|
|
2867
|
+
]
|
|
2868
|
+
}
|
|
2869
|
+
),
|
|
2658
2870
|
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
2659
2871
|
/* @__PURE__ */ jsx15(ImageCheckbox, { label: "Anti-alias", checked: options.antiAlias, onChange: (on) => set({ antiAlias: on }) }),
|
|
2660
2872
|
"Anti-alias"
|
|
@@ -2663,7 +2875,13 @@ var SelectionOptionsBar = ({
|
|
|
2663
2875
|
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => controller.selectAll(), children: "Select All" }),
|
|
2664
2876
|
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
|
|
2665
2877
|
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
|
|
2666
|
-
/* @__PURE__ */ jsx15("button", { type: "button",
|
|
2878
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !controller.canReselect(), onClick: () => controller.reselect(), children: "Reselect" }),
|
|
2879
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, title: "Add connected pixels of a selected colour (wand tolerance)", onClick: () => void runColor("grow"), children: "Grow" }),
|
|
2880
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, title: "Add every pixel of a selected colour (wand tolerance)", onClick: () => void runColor("similar"), children: "Similar" })
|
|
2881
|
+
] }),
|
|
2882
|
+
/* @__PURE__ */ jsxs13("div", { role: "group", "aria-label": "Show selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
2883
|
+
/* @__PURE__ */ jsx15("span", { className: "text-muted-foreground", children: "Show" }),
|
|
2884
|
+
DISPLAYS.map((d) => /* @__PURE__ */ jsx15("button", { type: "button", "aria-pressed": display === d.id, className: btn(display === d.id), onClick: () => controller.setSelectionDisplay(d.id), children: d.label }, d.id))
|
|
2667
2885
|
] }),
|
|
2668
2886
|
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2669
2887
|
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
@@ -2678,12 +2896,57 @@ var SelectionOptionsBar = ({
|
|
|
2678
2896
|
"aria-label": "Modify radius",
|
|
2679
2897
|
value: radius,
|
|
2680
2898
|
onChange: (e) => setRadius(Math.max(0, Number(e.target.value) || 0)),
|
|
2681
|
-
className:
|
|
2899
|
+
className: numberInput
|
|
2682
2900
|
}
|
|
2683
2901
|
)
|
|
2684
2902
|
] }),
|
|
2685
2903
|
MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
|
|
2686
2904
|
] }),
|
|
2905
|
+
/* @__PURE__ */ jsxs13("div", { role: "group", "aria-label": "Edit selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
2906
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
2907
|
+
"Stroke",
|
|
2908
|
+
/* @__PURE__ */ jsx15(
|
|
2909
|
+
"input",
|
|
2910
|
+
{
|
|
2911
|
+
type: "number",
|
|
2912
|
+
min: 1,
|
|
2913
|
+
max: 250,
|
|
2914
|
+
step: 1,
|
|
2915
|
+
"aria-label": "Stroke width",
|
|
2916
|
+
value: strokeWidth,
|
|
2917
|
+
onChange: (e) => setStrokeWidth(Math.min(250, Math.max(1, Number(e.target.value) || 1))),
|
|
2918
|
+
className: numberInput
|
|
2919
|
+
}
|
|
2920
|
+
),
|
|
2921
|
+
"px"
|
|
2922
|
+
] }),
|
|
2923
|
+
/* @__PURE__ */ jsx15(
|
|
2924
|
+
ImageSelect,
|
|
2925
|
+
{
|
|
2926
|
+
label: "Stroke location",
|
|
2927
|
+
value: strokeLocation,
|
|
2928
|
+
options: [
|
|
2929
|
+
{ value: "outside", label: "Outside" },
|
|
2930
|
+
{ value: "center", label: "Center" },
|
|
2931
|
+
{ value: "inside", label: "Inside" }
|
|
2932
|
+
],
|
|
2933
|
+
onChange: (v) => setStrokeLocation(v)
|
|
2934
|
+
}
|
|
2935
|
+
),
|
|
2936
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.strokeSelection({ width: strokeWidth, location: strokeLocation })), children: "Stroke" }),
|
|
2937
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cropToSelection()), children: "Crop to Selection" }),
|
|
2938
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.contentAwareFill({ output: "new-layer" })), children: "Content-Aware Fill" })
|
|
2939
|
+
] }),
|
|
2940
|
+
/* @__PURE__ */ jsxs13("div", { role: "group", "aria-label": "Clipboard", className: "flex flex-wrap gap-1", children: [
|
|
2941
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels()), children: "Copy" }),
|
|
2942
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels({ merged: true })), children: "Copy Merged" }),
|
|
2943
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cutPixels()), children: "Cut" }),
|
|
2944
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("new-layer")), children: "Paste" }),
|
|
2945
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("in-place")), children: "Paste in Place" }),
|
|
2946
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("into")), children: "Paste Into" }),
|
|
2947
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("outside")), children: "Paste Outside" })
|
|
2948
|
+
] }),
|
|
2949
|
+
colorStatus && /* @__PURE__ */ jsx15("p", { role: "status", className: "text-muted-foreground", children: colorStatus }),
|
|
2687
2950
|
/* @__PURE__ */ jsx15("p", { "data-testid": "selection-status", className: "text-muted-foreground", children: describeSelection(sel) })
|
|
2688
2951
|
] });
|
|
2689
2952
|
};
|
|
@@ -4023,7 +4286,8 @@ var ImageEditor = ({
|
|
|
4023
4286
|
options: selectionOptions,
|
|
4024
4287
|
onOptionsChange: setSelectionOptions,
|
|
4025
4288
|
selection: state.selection ?? null,
|
|
4026
|
-
quickMask: Boolean(state.quickMask)
|
|
4289
|
+
quickMask: Boolean(state.quickMask),
|
|
4290
|
+
selectionDisplay: state.selectionDisplay
|
|
4027
4291
|
}
|
|
4028
4292
|
),
|
|
4029
4293
|
selectionError && /* @__PURE__ */ jsx20("p", { role: "alert", className: "text-destructive", children: selectionError }),
|
|
@@ -14,7 +14,8 @@ export interface LayersPanelProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* The layer stack, top first: visibility, thumbnails, names (double-click to rename), locks,
|
|
17
|
-
* mask thumbnails (click to paint the mask, Shift-click to disable it
|
|
17
|
+
* mask thumbnails (click to paint the mask, Shift-click to disable it, Ctrl/⌘-click to load it
|
|
18
|
+
* as the selection; Ctrl/⌘-click a layer thumbnail to select its pixels), drag to reorder or drop
|
|
18
19
|
* into a group, opacity / fill / blend / clipping for the active layer, and the layer menu
|
|
19
20
|
* (right-click a row, or the ⋯ button), an fx badge on rows with effects (click to switch them
|
|
20
21
|
* on or off) and the active layer's effects. Every action is one undo step on the controller.
|
|
@@ -14,7 +14,8 @@ export interface LayersPanelProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* The layer stack, top first: visibility, thumbnails, names (double-click to rename), locks,
|
|
17
|
-
* mask thumbnails (click to paint the mask, Shift-click to disable it
|
|
17
|
+
* mask thumbnails (click to paint the mask, Shift-click to disable it, Ctrl/⌘-click to load it
|
|
18
|
+
* as the selection; Ctrl/⌘-click a layer thumbnail to select its pixels), drag to reorder or drop
|
|
18
19
|
* into a group, opacity / fill / blend / clipping for the active layer, and the layer menu
|
|
19
20
|
* (right-click a row, or the ⋯ button), an fx badge on rows with effects (click to switch them
|
|
20
21
|
* on or off) and the active layer's effects. Every action is one undo step on the controller.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ImageEditorController, SelectionMask, SelectionToolOptions } from '@pixerate/editor/image-editor';
|
|
2
|
+
import type { ImageEditorController, SelectionDisplay, SelectionMask, SelectionToolOptions } from '@pixerate/editor/image-editor';
|
|
3
3
|
export interface SelectionOptionsBarProps {
|
|
4
4
|
controller: ImageEditorController;
|
|
5
5
|
options: SelectionToolOptions;
|
|
@@ -8,11 +8,16 @@ export interface SelectionOptionsBarProps {
|
|
|
8
8
|
selection?: SelectionMask | null;
|
|
9
9
|
/** The current Quick Mask view flag (`state.quickMask`). */
|
|
10
10
|
quickMask?: boolean;
|
|
11
|
+
/** How the canvas shows the selection (`state.selectionDisplay`); wins over `quickMask`. */
|
|
12
|
+
selectionDisplay?: SelectionDisplay;
|
|
11
13
|
className?: string;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
|
-
* Options bar of the selection tools: tool, mode (new / add / subtract / intersect),
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Options bar of the selection tools: tool, mode (new / add / subtract / intersect), feather,
|
|
17
|
+
* magic wand tolerance, contiguous and colour distance, Color Range (click to sample, Shift-click
|
|
18
|
+
* to add, Alt-click to remove; fuzziness, localized, invert, presets), anti-alias, sample merged,
|
|
19
|
+
* Select › All / Deselect / Inverse, Modify (grow, shrink, feather, border, smooth) and how the
|
|
20
|
+
* selection shows (marching ants, Quick Mask or hidden). With a segmentation
|
|
21
|
+
* provider on the controller it adds Select › Subject (a description and a button).
|
|
17
22
|
*/
|
|
18
23
|
export declare const SelectionOptionsBar: React.FC<SelectionOptionsBarProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ImageEditorController, SelectionMask, SelectionToolOptions } from '@pixerate/editor/image-editor';
|
|
2
|
+
import type { ImageEditorController, SelectionDisplay, SelectionMask, SelectionToolOptions } from '@pixerate/editor/image-editor';
|
|
3
3
|
export interface SelectionOptionsBarProps {
|
|
4
4
|
controller: ImageEditorController;
|
|
5
5
|
options: SelectionToolOptions;
|
|
@@ -8,11 +8,16 @@ export interface SelectionOptionsBarProps {
|
|
|
8
8
|
selection?: SelectionMask | null;
|
|
9
9
|
/** The current Quick Mask view flag (`state.quickMask`). */
|
|
10
10
|
quickMask?: boolean;
|
|
11
|
+
/** How the canvas shows the selection (`state.selectionDisplay`); wins over `quickMask`. */
|
|
12
|
+
selectionDisplay?: SelectionDisplay;
|
|
11
13
|
className?: string;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
|
-
* Options bar of the selection tools: tool, mode (new / add / subtract / intersect),
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Options bar of the selection tools: tool, mode (new / add / subtract / intersect), feather,
|
|
17
|
+
* magic wand tolerance, contiguous and colour distance, Color Range (click to sample, Shift-click
|
|
18
|
+
* to add, Alt-click to remove; fuzziness, localized, invert, presets), anti-alias, sample merged,
|
|
19
|
+
* Select › All / Deselect / Inverse, Modify (grow, shrink, feather, border, smooth) and how the
|
|
20
|
+
* selection shows (marching ants, Quick Mask or hidden). With a segmentation
|
|
21
|
+
* provider on the controller it adds Select › Subject (a description and a button).
|
|
17
22
|
*/
|
|
18
23
|
export declare const SelectionOptionsBar: React.FC<SelectionOptionsBarProps>;
|