@pixerate/editor-react 0.185.0 → 0.187.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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type PaintEditorController, type PaintEffectsToolProviderOptions } from '@pixerate/editor/paint-editor';
3
- import type { EffectProvider } from '@pixerate/editor/effects';
3
+ import { type EffectProvider } from '@pixerate/editor/effects';
4
4
  import type { ToolRegistry } from '@pixerate/editor/tools';
5
5
  export interface PaintEffectsPanelProps {
6
6
  controller: PaintEditorController;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type PaintEditorController, type PaintEffectsToolProviderOptions } from '@pixerate/editor/paint-editor';
3
- import type { EffectProvider } from '@pixerate/editor/effects';
3
+ import { type EffectProvider } from '@pixerate/editor/effects';
4
4
  import type { ToolRegistry } from '@pixerate/editor/tools';
5
5
  export interface PaintEffectsPanelProps {
6
6
  controller: PaintEditorController;
@@ -1088,7 +1088,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
1088
1088
  const carried = (0, import_paint_editor5.brushLoadColor)(state.mixerLoad);
1089
1089
  const palette = (spec.colour?.palette ?? []).flatMap((c) => (0, import_brushes3.brushColourHex)(c, state.colorScheme) ?? []);
1090
1090
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
1091
- const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
1091
+ const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost;
1092
1092
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
1093
1093
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
1094
1094
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -2097,6 +2097,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
2097
2097
  // src/paint-editor/PaintEffectsPanel.tsx
2098
2098
  var import_react29 = require("react");
2099
2099
  var import_paint_editor14 = require("@pixerate/editor/paint-editor");
2100
+ var import_effects4 = require("@pixerate/editor/effects");
2100
2101
 
2101
2102
  // src/effects/useEffects.ts
2102
2103
  var import_react20 = require("react");
@@ -3920,6 +3921,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
3920
3921
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
3921
3922
  const active = activeId ? controller.getLayer(activeId) : void 0;
3922
3923
  const effectPaint = state.effectPaint;
3924
+ const { description: paintDescription } = useEffectDescription(provider, effectPaint?.effect);
3925
+ const hasPathControl = Boolean(paintDescription && (0, import_effects4.pathControlsOf)(paintDescription).length > 0);
3923
3926
  const animation = controller.getAnimation();
3924
3927
  const playback = state.effectPlayback;
3925
3928
  const repaint = (patch) => {
@@ -4006,15 +4009,19 @@ var PaintEffectsPanel = ({ controller, className }) => {
4006
4009
  ] }),
4007
4010
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
4008
4011
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
4009
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
4012
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
4010
4013
  "Along the stroke"
4011
4014
  ] }),
4015
+ hasPathControl && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
4016
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
4017
+ "Along the stroke (native)"
4018
+ ] }),
4012
4019
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
4013
4020
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
4014
4021
  "Live"
4015
4022
  ] })
4016
4023
  ] }),
4017
- effectPaint.map && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
4024
+ effectPaint.map?.by === "stroke" && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
4018
4025
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "flex items-center gap-1", children: [
4019
4026
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-slate-400", children: "Length" }),
4020
4027
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
@@ -611,7 +611,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
611
611
  const carried = brushLoadColor(state.mixerLoad);
612
612
  const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
613
613
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
614
- const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
614
+ const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost;
615
615
  return /* @__PURE__ */ jsxs4("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
616
616
  /* @__PURE__ */ jsx5(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
617
617
  /* @__PURE__ */ jsx5(
@@ -1306,6 +1306,7 @@ import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2,
1306
1306
  // src/paint-editor/PaintEffectsPanel.tsx
1307
1307
  import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
1308
1308
  import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
1309
+ import { pathControlsOf } from "@pixerate/editor/effects";
1309
1310
  import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1310
1311
  function usePaintEffectsProvider(controller) {
1311
1312
  const [provider, setProvider] = useState8(controller.effectsProvider);
@@ -1366,6 +1367,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1366
1367
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
1367
1368
  const active = activeId ? controller.getLayer(activeId) : void 0;
1368
1369
  const effectPaint = state.effectPaint;
1370
+ const { description: paintDescription } = useEffectDescription(provider, effectPaint?.effect);
1371
+ const hasPathControl = Boolean(paintDescription && pathControlsOf(paintDescription).length > 0);
1369
1372
  const animation = controller.getAnimation();
1370
1373
  const playback = state.effectPlayback;
1371
1374
  const repaint = (patch) => {
@@ -1452,15 +1455,19 @@ var PaintEffectsPanel = ({ controller, className }) => {
1452
1455
  ] }),
1453
1456
  /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1454
1457
  /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1455
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1458
+ /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1456
1459
  "Along the stroke"
1457
1460
  ] }),
1461
+ hasPathControl && /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
1462
+ /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
1463
+ "Along the stroke (native)"
1464
+ ] }),
1458
1465
  /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1459
1466
  /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1460
1467
  "Live"
1461
1468
  ] })
1462
1469
  ] }),
1463
- effectPaint.map && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
1470
+ effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
1464
1471
  /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1465
1472
  /* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Length" }),
1466
1473
  /* @__PURE__ */ jsx13(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.185.0",
3
+ "version": "0.187.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -283,7 +283,7 @@
283
283
  "dependencies": {},
284
284
  "peerDependencies": {
285
285
  "@dagrejs/dagre": "^1.1.8",
286
- "@pixerate/editor": ">=0.270.0 <1.0.0-0",
286
+ "@pixerate/editor": ">=0.272.0 <1.0.0-0",
287
287
  "@tiptap/core": "^2.27.3",
288
288
  "@tiptap/extension-bubble-menu": "^2.27.3",
289
289
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -334,7 +334,7 @@
334
334
  "tsup": "^9.0.0",
335
335
  "typescript": "^5.7.3",
336
336
  "vitest": "^5.0.5",
337
- "@pixerate/editor": "0.270.0"
337
+ "@pixerate/editor": "0.272.0"
338
338
  },
339
339
  "scripts": {
340
340
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",