@pixerate/editor-react 0.150.1 → 0.152.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.
@@ -2390,6 +2390,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
2390
2390
  const [, setTick] = useState10(0);
2391
2391
  useEffect7(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
2392
2392
  const [browse, setBrowse] = useState10(null);
2393
+ const [clip, setClip] = useState10(false);
2393
2394
  const [message, setMessage] = useState10(null);
2394
2395
  const [open, setOpen] = useState10(null);
2395
2396
  const [scrubbed, setScrubbed] = useState10(null);
@@ -2529,7 +2530,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
2529
2530
  /* @__PURE__ */ jsx13("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
2530
2531
  /* @__PURE__ */ jsx13("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
2531
2532
  ] }),
2532
- browse === "filter" && layer && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
2533
+ browse === "filter" && layer && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true, preserveTransparency: true }))) }),
2533
2534
  filters.length > 0 && layer && /* @__PURE__ */ jsx13("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
2534
2535
  const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
2535
2536
  const all = layer.smartFilters.filters;
@@ -2550,6 +2551,17 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
2550
2551
  /* @__PURE__ */ jsx13("button", { type: "button", className: imageOutlineButtonClass, disabled: index === 0, "aria-label": "Move down", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index - 1 })), children: "\u2193" }),
2551
2552
  /* @__PURE__ */ jsx13("button", { type: "button", className: imageOutlineButtonClass, "aria-label": `Remove ${label}`, onClick: () => run(() => controller.removeSmartFilter(layer.id, f.id)), children: "\u2715" })
2552
2553
  ] }),
2554
+ /* @__PURE__ */ jsxs12("label", { className: "mt-0.5 flex items-center gap-1 pl-0.5 text-[11px] text-muted-foreground", title: "Draw the filter only over the layer's own pixels; clear it to let the effect fill transparent areas", children: [
2555
+ /* @__PURE__ */ jsx13(
2556
+ ImageCheckbox,
2557
+ {
2558
+ checked: f.preserveTransparency === true,
2559
+ label: `${label}: keep transparency`,
2560
+ onChange: (preserveTransparency) => run(() => controller.updateEffectFilter(layer.id, f.id, { preserveTransparency }))
2561
+ }
2562
+ ),
2563
+ "Keep transparency"
2564
+ ] }),
2553
2565
  open === f.id && /* @__PURE__ */ jsxs12("div", { className: "mt-1 space-y-2", children: [
2554
2566
  /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
2555
2567
  /* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-foreground", children: "Opacity" }),
@@ -2581,7 +2593,18 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
2581
2593
  ] })
2582
2594
  ] }, f.id);
2583
2595
  }) }),
2584
- layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties; new effect layers are added from the layers panel." }),
2596
+ layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties." }),
2597
+ provider && /* @__PURE__ */ jsxs12("div", { className: "space-y-1", "data-effect-part": "add-layer", children: [
2598
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
2599
+ /* @__PURE__ */ jsx13("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Effect layers" }),
2600
+ /* @__PURE__ */ jsx13("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "layer", onClick: () => setBrowse(browse === "layer" ? null : "layer"), children: "Add effect layer\u2026" })
2601
+ ] }),
2602
+ /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1 text-[11px] text-muted-foreground", title: "Show the new effect layer only over the pixels of the layer below it (a clipping mask)", children: [
2603
+ /* @__PURE__ */ jsx13(ImageCheckbox, { checked: clip, label: "Clip to layer below", onChange: setClip }),
2604
+ "Clip to layer below"
2605
+ ] }),
2606
+ browse === "layer" && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: EFFECT_LAYER_USES, title: "Add an effect layer", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id, { clipped: clip }))) })
2607
+ ] }),
2585
2608
  !layer && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
2586
2609
  message && /* @__PURE__ */ jsx13("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
2587
2610
  ] });
@@ -11,8 +11,9 @@ export interface ImageProviderEffectsPanelProps {
11
11
  * Provider effects for the active layer. An effect layer first: its effect (change it or
12
12
  * rasterize it), a still frame or an animation for an effect that moves, and its controls. Then
13
13
  * the provider filters applied to the layer (smart filters; applying one converts a pixel layer to
14
- * a smart object in the same undo step). Layer styles (drop shadow, stroke…) are not here: they
15
- * are part of the layer's properties (`LayerEffectsPanel`). New effect layers come from the layers
16
- * panel. Without a provider it says why nothing can be added.
14
+ * a smart object in the same undo step), each keeping the layer's transparency unless "Keep
15
+ * transparency" is cleared. Then adding an effect layer, above the active layer and optionally
16
+ * clipped to it. Layer styles (drop shadow, stroke…) are not here: they are part of the layer's
17
+ * properties (`LayerEffectsPanel`). Without a provider it says why nothing can be added.
17
18
  */
18
19
  export declare function ImageProviderEffectsPanel({ controller, className, components }: ImageProviderEffectsPanelProps): React.JSX.Element;
@@ -11,8 +11,9 @@ export interface ImageProviderEffectsPanelProps {
11
11
  * Provider effects for the active layer. An effect layer first: its effect (change it or
12
12
  * rasterize it), a still frame or an animation for an effect that moves, and its controls. Then
13
13
  * the provider filters applied to the layer (smart filters; applying one converts a pixel layer to
14
- * a smart object in the same undo step). Layer styles (drop shadow, stroke…) are not here: they
15
- * are part of the layer's properties (`LayerEffectsPanel`). New effect layers come from the layers
16
- * panel. Without a provider it says why nothing can be added.
14
+ * a smart object in the same undo step), each keeping the layer's transparency unless "Keep
15
+ * transparency" is cleared. Then adding an effect layer, above the active layer and optionally
16
+ * clipped to it. Layer styles (drop shadow, stroke…) are not here: they are part of the layer's
17
+ * properties (`LayerEffectsPanel`). Without a provider it says why nothing can be added.
17
18
  */
18
19
  export declare function ImageProviderEffectsPanel({ controller, className, components }: ImageProviderEffectsPanelProps): React.JSX.Element;
@@ -4226,6 +4226,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
4226
4226
  const [, setTick] = (0, import_react23.useState)(0);
4227
4227
  (0, import_react23.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
4228
4228
  const [browse, setBrowse] = (0, import_react23.useState)(null);
4229
+ const [clip, setClip] = (0, import_react23.useState)(false);
4229
4230
  const [message, setMessage] = (0, import_react23.useState)(null);
4230
4231
  const [open, setOpen] = (0, import_react23.useState)(null);
4231
4232
  const [scrubbed, setScrubbed] = (0, import_react23.useState)(null);
@@ -4365,7 +4366,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
4365
4366
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
4366
4367
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
4367
4368
  ] }),
4368
- browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
4369
+ browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true, preserveTransparency: true }))) }),
4369
4370
  filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
4370
4371
  const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
4371
4372
  const all = layer.smartFilters.filters;
@@ -4386,6 +4387,17 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
4386
4387
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: imageOutlineButtonClass, disabled: index === 0, "aria-label": "Move down", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index - 1 })), children: "\u2193" }),
4387
4388
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-label": `Remove ${label}`, onClick: () => run(() => controller.removeSmartFilter(layer.id, f.id)), children: "\u2715" })
4388
4389
  ] }),
4390
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "mt-0.5 flex items-center gap-1 pl-0.5 text-[11px] text-muted-foreground", title: "Draw the filter only over the layer's own pixels; clear it to let the effect fill transparent areas", children: [
4391
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4392
+ ImageCheckbox,
4393
+ {
4394
+ checked: f.preserveTransparency === true,
4395
+ label: `${label}: keep transparency`,
4396
+ onChange: (preserveTransparency) => run(() => controller.updateEffectFilter(layer.id, f.id, { preserveTransparency }))
4397
+ }
4398
+ ),
4399
+ "Keep transparency"
4400
+ ] }),
4389
4401
  open === f.id && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "mt-1 space-y-2", children: [
4390
4402
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
4391
4403
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-14 text-[11px] text-foreground", children: "Opacity" }),
@@ -4417,7 +4429,18 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
4417
4429
  ] })
4418
4430
  ] }, f.id);
4419
4431
  }) }),
4420
- layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties; new effect layers are added from the layers panel." }),
4432
+ layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties." }),
4433
+ provider && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "space-y-1", "data-effect-part": "add-layer", children: [
4434
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
4435
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Effect layers" }),
4436
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "layer", onClick: () => setBrowse(browse === "layer" ? null : "layer"), children: "Add effect layer\u2026" })
4437
+ ] }),
4438
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1 text-[11px] text-muted-foreground", title: "Show the new effect layer only over the pixels of the layer below it (a clipping mask)", children: [
4439
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ImageCheckbox, { checked: clip, label: "Clip to layer below", onChange: setClip }),
4440
+ "Clip to layer below"
4441
+ ] }),
4442
+ browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Add an effect layer", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id, { clipped: clip }))) })
4443
+ ] }),
4421
4444
  !layer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
4422
4445
  message && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4423
4446
  ] });
@@ -36,7 +36,7 @@ import {
36
36
  useImageEditorControls,
37
37
  useImageEffectsTools,
38
38
  useImageHistogram
39
- } from "../chunk-KCA3KEPC.js";
39
+ } from "../chunk-M75ZC7DI.js";
40
40
  import "../chunk-AJCWF6SN.js";
41
41
  import "../chunk-IDUWADYT.js";
42
42
  import "../chunk-5RPB4WGT.js";
package/dist/index.cjs CHANGED
@@ -7940,6 +7940,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
7940
7940
  const [, setTick] = (0, import_react59.useState)(0);
7941
7941
  (0, import_react59.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7942
7942
  const [browse, setBrowse] = (0, import_react59.useState)(null);
7943
+ const [clip, setClip] = (0, import_react59.useState)(false);
7943
7944
  const [message2, setMessage] = (0, import_react59.useState)(null);
7944
7945
  const [open, setOpen] = (0, import_react59.useState)(null);
7945
7946
  const [scrubbed, setScrubbed] = (0, import_react59.useState)(null);
@@ -8079,7 +8080,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8079
8080
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
8080
8081
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
8081
8082
  ] }),
8082
- browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
8083
+ browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true, preserveTransparency: true }))) }),
8083
8084
  filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
8084
8085
  const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
8085
8086
  const all = layer.smartFilters.filters;
@@ -8100,6 +8101,17 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8100
8101
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { type: "button", className: imageOutlineButtonClass, disabled: index === 0, "aria-label": "Move down", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index - 1 })), children: "\u2193" }),
8101
8102
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-label": `Remove ${label}`, onClick: () => run(() => controller.removeSmartFilter(layer.id, f.id)), children: "\u2715" })
8102
8103
  ] }),
8104
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("label", { className: "mt-0.5 flex items-center gap-1 pl-0.5 text-[11px] text-muted-foreground", title: "Draw the filter only over the layer's own pixels; clear it to let the effect fill transparent areas", children: [
8105
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8106
+ ImageCheckbox,
8107
+ {
8108
+ checked: f.preserveTransparency === true,
8109
+ label: `${label}: keep transparency`,
8110
+ onChange: (preserveTransparency) => run(() => controller.updateEffectFilter(layer.id, f.id, { preserveTransparency }))
8111
+ }
8112
+ ),
8113
+ "Keep transparency"
8114
+ ] }),
8103
8115
  open === f.id && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "mt-1 space-y-2", children: [
8104
8116
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("label", { className: "flex items-center gap-1", children: [
8105
8117
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "w-14 text-[11px] text-foreground", children: "Opacity" }),
@@ -8131,7 +8143,18 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8131
8143
  ] })
8132
8144
  ] }, f.id);
8133
8145
  }) }),
8134
- layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties; new effect layers are added from the layers panel." }),
8146
+ layer && canFilter && !generator && filters.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No filters yet. A filter changes the layer's pixels and stays editable. Layer styles such as a drop shadow are in the layer's properties." }),
8147
+ provider && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "space-y-1", "data-effect-part": "add-layer", children: [
8148
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-1", children: [
8149
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Effect layers" }),
8150
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "layer", onClick: () => setBrowse(browse === "layer" ? null : "layer"), children: "Add effect layer\u2026" })
8151
+ ] }),
8152
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("label", { className: "flex items-center gap-1 text-[11px] text-muted-foreground", title: "Show the new effect layer only over the pixels of the layer below it (a clipping mask)", children: [
8153
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ImageCheckbox, { checked: clip, label: "Clip to layer below", onChange: setClip }),
8154
+ "Clip to layer below"
8155
+ ] }),
8156
+ browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Add an effect layer", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id, { clipped: clip }))) })
8157
+ ] }),
8135
8158
  !layer && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
8136
8159
  message2 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message2 })
8137
8160
  ] });
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ import {
60
60
  useImageEditorControls,
61
61
  useImageEffectsTools,
62
62
  useImageHistogram
63
- } from "./chunk-KCA3KEPC.js";
63
+ } from "./chunk-M75ZC7DI.js";
64
64
  import "./chunk-AJCWF6SN.js";
65
65
  import "./chunk-IDUWADYT.js";
66
66
  import "./chunk-5RPB4WGT.js";
@@ -12,8 +12,9 @@ export declare function usePaintEffectsProvider(controller: PaintEditorControlle
12
12
  export declare function usePaintEffectsTools(registry: ToolRegistry | null | undefined, controller: PaintEditorController, options?: PaintEffectsToolProviderOptions): void;
13
13
  /**
14
14
  * Provider effects in the paint editor: effect paper (a generator over the sheet, multiplied so
15
- * the grain shows), effect layers, effect fills and light baked onto the active layer's dried
16
- * paint; plus the controls of the effect paper and of an active effect layer. Each change is one
15
+ * the grain shows), effect layers, effect fills, light baked onto the active layer's dried paint
16
+ * and effect paint (brushes take their colours from the effect); plus the controls of the effect
17
+ * paper, of an active effect layer and of the effect paint. Each change is one
17
18
  * undo step (a slider drag is one). Without a provider it says why nothing can be added.
18
19
  */
19
20
  export declare const PaintEffectsPanel: React.FC<PaintEffectsPanelProps>;
@@ -12,8 +12,9 @@ export declare function usePaintEffectsProvider(controller: PaintEditorControlle
12
12
  export declare function usePaintEffectsTools(registry: ToolRegistry | null | undefined, controller: PaintEditorController, options?: PaintEffectsToolProviderOptions): void;
13
13
  /**
14
14
  * Provider effects in the paint editor: effect paper (a generator over the sheet, multiplied so
15
- * the grain shows), effect layers, effect fills and light baked onto the active layer's dried
16
- * paint; plus the controls of the effect paper and of an active effect layer. Each change is one
15
+ * the grain shows), effect layers, effect fills, light baked onto the active layer's dried paint
16
+ * and effect paint (brushes take their colours from the effect); plus the controls of the effect
17
+ * paper, of an active effect layer and of the effect paint. Each change is one
17
18
  * undo step (a slider drag is one). Without a provider it says why nothing can be added.
18
19
  */
19
20
  export declare const PaintEffectsPanel: React.FC<PaintEffectsPanelProps>;
@@ -946,6 +946,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
946
946
  const harmony = (0, import_react8.useMemo)(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
947
947
  const [r, g, b] = (0, import_paint_editor8.parseHexColor)(color);
948
948
  const hsv = (0, import_paint_editor8.rgbToHsv)(r, g, b);
949
+ const effectWell = (0, import_react8.useMemo)(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
949
950
  const pad = (0, import_react8.useMemo)(() => ({ width: import_paint_editor8.MIXING_PAD_WIDTH, height: import_paint_editor8.MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
950
951
  const R = wheelSize / 2;
951
952
  const mid = R * 0.82;
@@ -1003,9 +1004,10 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
1003
1004
  "span",
1004
1005
  {
1005
1006
  className: "h-5 flex-1 rounded ring-1 ring-slate-700",
1006
- "aria-label": state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
1007
+ "aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
1007
1008
  "data-testid": "paint-well",
1008
- style: { background: (0, import_paint_editor9.paintSourceCss)(state.paint, { paint: color, secondary: state.secondaryColor }) }
1009
+ "data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
1010
+ style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : (0, import_paint_editor9.paintSourceCss)(state.paint, { paint: color, secondary: state.secondaryColor }) }
1009
1011
  }
1010
1012
  ),
1011
1013
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -3243,7 +3245,8 @@ var BROWSERS = {
3243
3245
  paper: { uses: ["generator"], title: "Effect paper" },
3244
3246
  layer: { uses: ["generator", "overlay", "title"], title: "Effect layer" },
3245
3247
  fill: { uses: ["generator", "overlay", "title"], title: "Fill the layer" },
3246
- light: { uses: ["filter"], title: "Light on the paint" }
3248
+ light: { uses: ["filter"], title: "Light on the paint" },
3249
+ paint: { uses: ["generator", "overlay", "title"], title: "Paint with an effect" }
3247
3250
  };
3248
3251
  var PaintEffectsPanel = ({ controller, className }) => {
3249
3252
  const state = usePaintEditorState(controller);
@@ -3255,6 +3258,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
3255
3258
  const activeId = state.document.activeLayerId;
3256
3259
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
3257
3260
  const active = activeId ? controller.getLayer(activeId) : void 0;
3261
+ const effectPaint = state.effectPaint;
3262
+ const thumbnail = (0, import_react23.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
3258
3263
  const run = (work) => attempt(() => {
3259
3264
  setBusy(true);
3260
3265
  return work().finally(() => setBusy(false));
@@ -3266,6 +3271,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
3266
3271
  else if (kind === "layer") run(() => controller.addEffectLayer(id));
3267
3272
  else if (kind === "fill") run(() => controller.fillLayerWithEffect(id));
3268
3273
  else if (kind === "light" && activeId) run(() => controller.applyLightEffect(activeId, id));
3274
+ else if (kind === "paint") run(() => controller.setEffectPaint({ effect: id }));
3269
3275
  };
3270
3276
  const toggle = (b) => setBrowse(browse === b ? null : b);
3271
3277
  const pixel = active?.type === "pixel";
@@ -3275,7 +3281,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
3275
3281
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
3276
3282
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
3277
3283
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
3278
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
3284
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
3285
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
3279
3286
  ] }),
3280
3287
  !provider && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
3281
3288
  browse && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
@@ -3320,6 +3327,18 @@ var PaintEffectsPanel = ({ controller, className }) => {
3320
3327
  ] }),
3321
3328
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
3322
3329
  ] }),
3330
+ effectPaint && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
3331
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3332
+ thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
3333
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3334
+ "Paint: ",
3335
+ effectPaint.effect,
3336
+ state.effectPaintRendering ? " (rendering\u2026)" : ""
3337
+ ] }),
3338
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
3339
+ ] }),
3340
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
3341
+ ] }),
3323
3342
  layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
3324
3343
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3325
3344
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
@@ -833,6 +833,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
833
833
  const harmony = useMemo5(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
834
834
  const [r, g, b] = parseHexColor(color);
835
835
  const hsv = rgbToHsv(r, g, b);
836
+ const effectWell = useMemo5(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
836
837
  const pad = useMemo5(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
837
838
  const R = wheelSize / 2;
838
839
  const mid = R * 0.82;
@@ -890,9 +891,10 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
890
891
  "span",
891
892
  {
892
893
  className: "h-5 flex-1 rounded ring-1 ring-slate-700",
893
- "aria-label": state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
894
+ "aria-label": state.effectPaint ? `Effect paint: ${state.effectPaint.effect}` : state.paint.type === "gradient" ? "Gradient paint" : "Paint colour",
894
895
  "data-testid": "paint-well",
895
- style: { background: paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
896
+ "data-effect-paint": state.effectPaint ? state.effectPaint.effect : void 0,
897
+ style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
896
898
  }
897
899
  ),
898
900
  /* @__PURE__ */ jsx7(
@@ -1228,7 +1230,7 @@ import { useRef as useRef7, useState as useState10 } from "react";
1228
1230
  import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
1229
1231
 
1230
1232
  // src/paint-editor/PaintEffectsPanel.tsx
1231
- import { useEffect as useEffect4, useRef as useRef6, useState as useState9 } from "react";
1233
+ import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState9 } from "react";
1232
1234
  import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
1233
1235
  import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1234
1236
  function usePaintEffectsProvider(controller) {
@@ -1276,7 +1278,8 @@ var BROWSERS = {
1276
1278
  paper: { uses: ["generator"], title: "Effect paper" },
1277
1279
  layer: { uses: ["generator", "overlay", "title"], title: "Effect layer" },
1278
1280
  fill: { uses: ["generator", "overlay", "title"], title: "Fill the layer" },
1279
- light: { uses: ["filter"], title: "Light on the paint" }
1281
+ light: { uses: ["filter"], title: "Light on the paint" },
1282
+ paint: { uses: ["generator", "overlay", "title"], title: "Paint with an effect" }
1280
1283
  };
1281
1284
  var PaintEffectsPanel = ({ controller, className }) => {
1282
1285
  const state = usePaintEditorState(controller);
@@ -1288,6 +1291,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1288
1291
  const activeId = state.document.activeLayerId;
1289
1292
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
1290
1293
  const active = activeId ? controller.getLayer(activeId) : void 0;
1294
+ const effectPaint = state.effectPaint;
1295
+ const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
1291
1296
  const run = (work) => attempt(() => {
1292
1297
  setBusy(true);
1293
1298
  return work().finally(() => setBusy(false));
@@ -1299,6 +1304,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
1299
1304
  else if (kind === "layer") run(() => controller.addEffectLayer(id));
1300
1305
  else if (kind === "fill") run(() => controller.fillLayerWithEffect(id));
1301
1306
  else if (kind === "light" && activeId) run(() => controller.applyLightEffect(activeId, id));
1307
+ else if (kind === "paint") run(() => controller.setEffectPaint({ effect: id }));
1302
1308
  };
1303
1309
  const toggle = (b) => setBrowse(browse === b ? null : b);
1304
1310
  const pixel = active?.type === "pixel";
@@ -1308,7 +1314,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1308
1314
  /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1309
1315
  /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1310
1316
  /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1311
- /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
1317
+ /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
1318
+ /* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
1312
1319
  ] }),
1313
1320
  !provider && /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1314
1321
  browse && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
@@ -1353,6 +1360,18 @@ var PaintEffectsPanel = ({ controller, className }) => {
1353
1360
  ] }),
1354
1361
  /* @__PURE__ */ jsx11(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
1355
1362
  ] }),
1363
+ effectPaint && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
1364
+ /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", children: [
1365
+ thumbnail ? /* @__PURE__ */ jsx11("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
1366
+ /* @__PURE__ */ jsxs10("span", { className: "flex-1 truncate", children: [
1367
+ "Paint: ",
1368
+ effectPaint.effect,
1369
+ state.effectPaintRendering ? " (rendering\u2026)" : ""
1370
+ ] }),
1371
+ /* @__PURE__ */ jsx11("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1372
+ ] }),
1373
+ /* @__PURE__ */ jsx11(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
1374
+ ] }),
1356
1375
  layerEffect && activeId && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1357
1376
  /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", children: [
1358
1377
  /* @__PURE__ */ jsxs10("span", { className: "flex-1 truncate", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.150.1",
3
+ "version": "0.152.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.224.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.227.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.224.0"
308
+ "@pixerate/editor": "0.227.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",