@pixerate/editor-react 0.151.0 → 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.
@@ -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.151.0",
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.226.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.226.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",