@pixerate/editor-react 0.162.0 → 0.163.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.
@@ -132,6 +132,10 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
132
132
  const ctx = water.current?.getContext("2d");
133
133
  if (ctx && typeof ctx.createImageData === "function") (0, import_paint_editor2.drawWaterOverlay)(controller, ctx);
134
134
  }, [state, controller]);
135
+ (0, import_react2.useEffect)(() => {
136
+ const player = controller.playEffects();
137
+ return () => player.stop();
138
+ }, [controller]);
135
139
  (0, import_react2.useEffect)(() => {
136
140
  const el = viewport.current;
137
141
  if (!el) return;
@@ -3353,6 +3357,12 @@ var PaintEffectsPanel = ({ controller, className }) => {
3353
3357
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
3354
3358
  const active = activeId ? controller.getLayer(activeId) : void 0;
3355
3359
  const effectPaint = state.effectPaint;
3360
+ const animation = controller.getAnimation();
3361
+ const playback = state.effectPlayback;
3362
+ const repaint = (patch) => {
3363
+ if (!effectPaint) return;
3364
+ run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
3365
+ };
3356
3366
  const thumbnail = (0, import_react22.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
3357
3367
  const run = (work) => attempt(() => {
3358
3368
  setBusy(true);
@@ -3431,7 +3441,53 @@ var PaintEffectsPanel = ({ controller, className }) => {
3431
3441
  ] }),
3432
3442
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
3433
3443
  ] }),
3434
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
3444
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
3445
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
3446
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
3447
+ "Along the stroke"
3448
+ ] }),
3449
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
3450
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
3451
+ "Live"
3452
+ ] })
3453
+ ] }),
3454
+ effectPaint.map && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
3455
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3456
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "Length" }),
3457
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3458
+ "input",
3459
+ {
3460
+ type: "number",
3461
+ "aria-label": "Effect length along the stroke",
3462
+ min: 16,
3463
+ max: 4096,
3464
+ defaultValue: effectPaint.map.length,
3465
+ onBlur: (e) => Number(e.target.value) !== effectPaint.map.length && repaint({ map: { ...effectPaint.map, length: Number(e.target.value) } }),
3466
+ className: "w-16 rounded bg-slate-800 px-1 py-0.5"
3467
+ },
3468
+ effectPaint.map.length
3469
+ )
3470
+ ] }),
3471
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
3472
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "repeat", children: "Repeat" }),
3473
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "mirror", children: "Mirror" }),
3474
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "clamp", children: "Clamp" })
3475
+ ] })
3476
+ ] }),
3477
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
3478
+ ] }),
3479
+ animation && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
3480
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
3481
+ "Live paint: ",
3482
+ animation.strokes,
3483
+ " ",
3484
+ animation.strokes === 1 ? "stroke" : "strokes"
3485
+ ] }),
3486
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
3487
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3488
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "fps" }),
3489
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
3490
+ ] })
3435
3491
  ] }),
3436
3492
  layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
3437
3493
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
@@ -104,6 +104,10 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
104
104
  const ctx = water.current?.getContext("2d");
105
105
  if (ctx && typeof ctx.createImageData === "function") drawWaterOverlay(controller, ctx);
106
106
  }, [state, controller]);
107
+ useEffect2(() => {
108
+ const player = controller.playEffects();
109
+ return () => player.stop();
110
+ }, [controller]);
107
111
  useEffect2(() => {
108
112
  const el = viewport.current;
109
113
  if (!el) return;
@@ -1385,6 +1389,12 @@ var PaintEffectsPanel = ({ controller, className }) => {
1385
1389
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
1386
1390
  const active = activeId ? controller.getLayer(activeId) : void 0;
1387
1391
  const effectPaint = state.effectPaint;
1392
+ const animation = controller.getAnimation();
1393
+ const playback = state.effectPlayback;
1394
+ const repaint = (patch) => {
1395
+ if (!effectPaint) return;
1396
+ run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
1397
+ };
1388
1398
  const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
1389
1399
  const run = (work) => attempt(() => {
1390
1400
  setBusy(true);
@@ -1463,7 +1473,53 @@ var PaintEffectsPanel = ({ controller, className }) => {
1463
1473
  ] }),
1464
1474
  /* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1465
1475
  ] }),
1466
- /* @__PURE__ */ jsx12(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
1476
+ /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1477
+ /* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1478
+ /* @__PURE__ */ jsx12("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1479
+ "Along the stroke"
1480
+ ] }),
1481
+ /* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1482
+ /* @__PURE__ */ jsx12("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1483
+ "Live"
1484
+ ] })
1485
+ ] }),
1486
+ effectPaint.map && /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", children: [
1487
+ /* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
1488
+ /* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Length" }),
1489
+ /* @__PURE__ */ jsx12(
1490
+ "input",
1491
+ {
1492
+ type: "number",
1493
+ "aria-label": "Effect length along the stroke",
1494
+ min: 16,
1495
+ max: 4096,
1496
+ defaultValue: effectPaint.map.length,
1497
+ onBlur: (e) => Number(e.target.value) !== effectPaint.map.length && repaint({ map: { ...effectPaint.map, length: Number(e.target.value) } }),
1498
+ className: "w-16 rounded bg-slate-800 px-1 py-0.5"
1499
+ },
1500
+ effectPaint.map.length
1501
+ )
1502
+ ] }),
1503
+ /* @__PURE__ */ jsxs11("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
1504
+ /* @__PURE__ */ jsx12("option", { value: "repeat", children: "Repeat" }),
1505
+ /* @__PURE__ */ jsx12("option", { value: "mirror", children: "Mirror" }),
1506
+ /* @__PURE__ */ jsx12("option", { value: "clamp", children: "Clamp" })
1507
+ ] })
1508
+ ] }),
1509
+ /* @__PURE__ */ jsx12(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
1510
+ ] }),
1511
+ animation && /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
1512
+ /* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
1513
+ "Live paint: ",
1514
+ animation.strokes,
1515
+ " ",
1516
+ animation.strokes === 1 ? "stroke" : "strokes"
1517
+ ] }),
1518
+ /* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
1519
+ /* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
1520
+ /* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "fps" }),
1521
+ /* @__PURE__ */ jsx12("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
1522
+ ] })
1467
1523
  ] }),
1468
1524
  layerEffect && activeId && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1469
1525
  /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.162.0",
3
+ "version": "0.163.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.240.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.241.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.240.0"
308
+ "@pixerate/editor": "0.241.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",