@pixerate/editor-react 0.181.0 → 0.182.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.
@@ -3389,22 +3389,96 @@ function ShotInspector({ controller, shot, className = "" }) {
3389
3389
  // src/animation-editor/AnimationEffectsPanel.tsx
3390
3390
  var import_react24 = require("react");
3391
3391
  var import_animation_editor11 = require("@pixerate/editor/animation-editor");
3392
+ var import_effects8 = require("@pixerate/editor/effects");
3392
3393
  var import_jsx_runtime23 = require("react/jsx-runtime");
3393
3394
  var btn6 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
3394
- function Controls({ controller, instance, effect, values }) {
3395
+ function Controls({
3396
+ controller,
3397
+ instance,
3398
+ effect,
3399
+ values,
3400
+ pathNodes,
3401
+ defaultPathNode,
3402
+ disabled
3403
+ }) {
3395
3404
  const provider = controller.effectsProvider;
3396
3405
  const { description, error } = useEffectDescription(provider, effect);
3397
3406
  const [message, setMessage] = (0, import_react24.useState)(null);
3407
+ const [pathNode, setPathNode] = (0, import_react24.useState)("");
3408
+ const [words, setWords] = (0, import_react24.useState)("");
3398
3409
  const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
3399
3410
  if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: its commands are kept as they are." });
3400
3411
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
3401
3412
  if (!description) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
3413
+ const pathControls = description.kind === "vector" ? (0, import_effects8.pathControlsOf)(description) : [];
3414
+ const chosenPathNode = pathNode && pathNodes.includes(pathNode) ? pathNode : defaultPathNode && pathNodes.includes(defaultPathNode) ? defaultPathNode : pathNodes[0] ?? "";
3402
3415
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
3416
+ pathControls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "mb-1 flex flex-wrap items-center gap-1", "data-effect-part": "path", children: [
3417
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", children: "Path" }),
3418
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
3419
+ "select",
3420
+ {
3421
+ className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]",
3422
+ "aria-label": "Path node",
3423
+ value: chosenPathNode,
3424
+ disabled: disabled || !pathNodes.length,
3425
+ onChange: (e) => setPathNode(e.currentTarget.value),
3426
+ children: [
3427
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", children: "Path node\u2026" }),
3428
+ pathNodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: id, children: id }, id))
3429
+ ]
3430
+ }
3431
+ ),
3432
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3433
+ "button",
3434
+ {
3435
+ type: "button",
3436
+ className: btn6,
3437
+ disabled: disabled || !chosenPathNode,
3438
+ onClick: () => report(controller.setVectorEffectPath(instance, { node: chosenPathNode })),
3439
+ children: "Use path node"
3440
+ }
3441
+ ),
3442
+ provider.pathFromText && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
3443
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3444
+ "input",
3445
+ {
3446
+ className: "w-24 rounded border border-border bg-transparent px-1 py-0.5",
3447
+ "aria-label": "Words to write along the path",
3448
+ placeholder: "Words",
3449
+ value: words,
3450
+ disabled,
3451
+ onChange: (e) => setWords(e.currentTarget.value)
3452
+ }
3453
+ ),
3454
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3455
+ "button",
3456
+ {
3457
+ type: "button",
3458
+ className: btn6,
3459
+ disabled: disabled || !words.trim(),
3460
+ onClick: () => report(controller.setVectorEffectPath(instance, { text: words })),
3461
+ children: "Write"
3462
+ }
3463
+ )
3464
+ ] }),
3465
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3466
+ "button",
3467
+ {
3468
+ type: "button",
3469
+ className: btn6,
3470
+ disabled,
3471
+ onClick: () => report(controller.updateMotionEffect(instance, { [pathControls[0]]: "" })),
3472
+ children: "Clear path"
3473
+ }
3474
+ )
3475
+ ] }),
3403
3476
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3404
3477
  EffectParameters,
3405
3478
  {
3406
3479
  description,
3407
3480
  values,
3481
+ disabled,
3408
3482
  onChange: (k, v, gesture) => report(controller.updateMotionEffect(instance, { [k]: v }, { merge: gesture ?? void 0 })),
3409
3483
  onReset: (k) => report(controller.updateMotionEffect(instance, { [k]: null })),
3410
3484
  onPreset: (v) => report(controller.updateMotionEffect(instance, v))
@@ -3416,14 +3490,22 @@ function Controls({ controller, instance, effect, values }) {
3416
3490
  function AnimationEffectsPanel({ controller, node, className = "" }) {
3417
3491
  const state = useAnimationEditorState(controller);
3418
3492
  const provider = state.effectsProvider;
3493
+ const applied = (0, import_react24.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
3419
3494
  const nodes = (0, import_react24.useMemo)(() => [...(0, import_animation_editor11.indexMotionNodes)(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
3495
+ const pathNodes = (0, import_react24.useMemo)(() => {
3496
+ const vectorGroups = new Set(applied.filter((e) => e.kind === "vector").map((e) => e.instance));
3497
+ const own = state.scene.artwork.nodes.filter((n) => !vectorGroups.has(n.id));
3498
+ return [...(0, import_animation_editor11.indexMotionNodes)(own).values()].filter((e) => e.node.type === "path").map((e) => e.node.id);
3499
+ }, [state.scene.artwork, applied]);
3420
3500
  const [chosen, setChosen] = (0, import_react24.useState)("");
3421
3501
  const target = node && nodes.includes(node) ? node : chosen && nodes.includes(chosen) ? chosen : "";
3422
3502
  const [browse, setBrowse] = (0, import_react24.useState)(null);
3503
+ const [vectorPathNode, setVectorPathNode] = (0, import_react24.useState)("");
3504
+ const [vectorWords, setVectorWords] = (0, import_react24.useState)("");
3505
+ const activeVectorPathNode = vectorPathNode && pathNodes.includes(vectorPathNode) ? vectorPathNode : "";
3423
3506
  const [open, setOpen] = (0, import_react24.useState)(null);
3424
3507
  const [message, setMessage] = (0, import_react24.useState)(null);
3425
3508
  const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? x.notes.length ? x.notes.join(" ") : null : x.error));
3426
- const applied = (0, import_react24.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
3427
3509
  const disabled = state.readOnly;
3428
3510
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
3429
3511
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
@@ -3438,7 +3520,49 @@ function AnimationEffectsPanel({ controller, node, className = "" }) {
3438
3520
  !provider && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
3439
3521
  browse === "motion" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
3440
3522
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(EffectTemplates, { provider, disabled, fillLabel: "New scene from template", onFill: (t, v) => controller.fillTemplate(t, v).then((r) => (r.ok && r.notes.length && setMessage(r.notes.join(" ")), r)) }),
3441
- browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
3523
+ browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "space-y-1", children: [
3524
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-effect-part": "vector-path", children: [
3525
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", children: "Path" }),
3526
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
3527
+ "select",
3528
+ {
3529
+ className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]",
3530
+ "aria-label": "Path node for vector effect",
3531
+ value: activeVectorPathNode,
3532
+ disabled: disabled || !pathNodes.length,
3533
+ onChange: (e) => setVectorPathNode(e.currentTarget.value),
3534
+ children: [
3535
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", children: "Default path" }),
3536
+ pathNodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: id, children: id }, id))
3537
+ ]
3538
+ }
3539
+ ),
3540
+ provider?.pathFromText && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3541
+ "input",
3542
+ {
3543
+ className: "w-24 rounded border border-border bg-transparent px-1 py-0.5",
3544
+ "aria-label": "Words for vector effect path",
3545
+ placeholder: "Words",
3546
+ value: vectorWords,
3547
+ disabled,
3548
+ onChange: (e) => setVectorWords(e.currentTarget.value)
3549
+ }
3550
+ )
3551
+ ] }),
3552
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3553
+ EffectsBrowser,
3554
+ {
3555
+ provider,
3556
+ kinds: ["vector"],
3557
+ title: "Vector effects",
3558
+ onPick: (e) => {
3559
+ setBrowse(null);
3560
+ const path = e.accepts?.includes("path") ? vectorWords.trim() ? { text: vectorWords } : activeVectorPathNode ? { node: activeVectorPathNode } : void 0 : void 0;
3561
+ report(controller.addVectorEffect(e.id, path ? { path } : void 0));
3562
+ }
3563
+ }
3564
+ )
3565
+ ] }),
3442
3566
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
3443
3567
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-1", children: [
3444
3568
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.instance, onClick: () => setOpen(open === e.instance ? null : e.instance), children: [
@@ -3451,7 +3575,7 @@ function AnimationEffectsPanel({ controller, node, className = "" }) {
3451
3575
  ] }),
3452
3576
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", className: btn6, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeMotionEffect(e.instance)), children: "\u2715" })
3453
3577
  ] }),
3454
- open === e.instance && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "mt-1", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values }) })
3578
+ open === e.instance && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "mt-1", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values, pathNodes, defaultPathNode: target, disabled }) })
3455
3579
  ] }, e.instance)) }),
3456
3580
  !applied.length && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
3457
3581
  message && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
@@ -1386,22 +1386,96 @@ function ShotInspector({ controller, shot, className = "" }) {
1386
1386
  // src/animation-editor/AnimationEffectsPanel.tsx
1387
1387
  import { useMemo as useMemo6, useState as useState8 } from "react";
1388
1388
  import { indexMotionNodes } from "@pixerate/editor/animation-editor";
1389
+ import { pathControlsOf } from "@pixerate/editor/effects";
1389
1390
  import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1390
1391
  var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
1391
- function Controls({ controller, instance, effect, values }) {
1392
+ function Controls({
1393
+ controller,
1394
+ instance,
1395
+ effect,
1396
+ values,
1397
+ pathNodes,
1398
+ defaultPathNode,
1399
+ disabled
1400
+ }) {
1392
1401
  const provider = controller.effectsProvider;
1393
1402
  const { description, error } = useEffectDescription(provider, effect);
1394
1403
  const [message, setMessage] = useState8(null);
1404
+ const [pathNode, setPathNode] = useState8("");
1405
+ const [words, setWords] = useState8("");
1395
1406
  const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
1396
1407
  if (!provider) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: its commands are kept as they are." });
1397
1408
  if (error) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-amber-500", children: error });
1398
1409
  if (!description) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
1410
+ const pathControls = description.kind === "vector" ? pathControlsOf(description) : [];
1411
+ const chosenPathNode = pathNode && pathNodes.includes(pathNode) ? pathNode : defaultPathNode && pathNodes.includes(defaultPathNode) ? defaultPathNode : pathNodes[0] ?? "";
1399
1412
  return /* @__PURE__ */ jsxs11(Fragment4, { children: [
1413
+ pathControls.length > 0 && /* @__PURE__ */ jsxs11("div", { className: "mb-1 flex flex-wrap items-center gap-1", "data-effect-part": "path", children: [
1414
+ /* @__PURE__ */ jsx13("span", { className: "text-muted-foreground", children: "Path" }),
1415
+ /* @__PURE__ */ jsxs11(
1416
+ "select",
1417
+ {
1418
+ className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]",
1419
+ "aria-label": "Path node",
1420
+ value: chosenPathNode,
1421
+ disabled: disabled || !pathNodes.length,
1422
+ onChange: (e) => setPathNode(e.currentTarget.value),
1423
+ children: [
1424
+ /* @__PURE__ */ jsx13("option", { value: "", children: "Path node\u2026" }),
1425
+ pathNodes.map((id) => /* @__PURE__ */ jsx13("option", { value: id, children: id }, id))
1426
+ ]
1427
+ }
1428
+ ),
1429
+ /* @__PURE__ */ jsx13(
1430
+ "button",
1431
+ {
1432
+ type: "button",
1433
+ className: btn5,
1434
+ disabled: disabled || !chosenPathNode,
1435
+ onClick: () => report(controller.setVectorEffectPath(instance, { node: chosenPathNode })),
1436
+ children: "Use path node"
1437
+ }
1438
+ ),
1439
+ provider.pathFromText && /* @__PURE__ */ jsxs11(Fragment4, { children: [
1440
+ /* @__PURE__ */ jsx13(
1441
+ "input",
1442
+ {
1443
+ className: "w-24 rounded border border-border bg-transparent px-1 py-0.5",
1444
+ "aria-label": "Words to write along the path",
1445
+ placeholder: "Words",
1446
+ value: words,
1447
+ disabled,
1448
+ onChange: (e) => setWords(e.currentTarget.value)
1449
+ }
1450
+ ),
1451
+ /* @__PURE__ */ jsx13(
1452
+ "button",
1453
+ {
1454
+ type: "button",
1455
+ className: btn5,
1456
+ disabled: disabled || !words.trim(),
1457
+ onClick: () => report(controller.setVectorEffectPath(instance, { text: words })),
1458
+ children: "Write"
1459
+ }
1460
+ )
1461
+ ] }),
1462
+ /* @__PURE__ */ jsx13(
1463
+ "button",
1464
+ {
1465
+ type: "button",
1466
+ className: btn5,
1467
+ disabled,
1468
+ onClick: () => report(controller.updateMotionEffect(instance, { [pathControls[0]]: "" })),
1469
+ children: "Clear path"
1470
+ }
1471
+ )
1472
+ ] }),
1400
1473
  /* @__PURE__ */ jsx13(
1401
1474
  EffectParameters,
1402
1475
  {
1403
1476
  description,
1404
1477
  values,
1478
+ disabled,
1405
1479
  onChange: (k, v, gesture) => report(controller.updateMotionEffect(instance, { [k]: v }, { merge: gesture ?? void 0 })),
1406
1480
  onReset: (k) => report(controller.updateMotionEffect(instance, { [k]: null })),
1407
1481
  onPreset: (v) => report(controller.updateMotionEffect(instance, v))
@@ -1413,14 +1487,22 @@ function Controls({ controller, instance, effect, values }) {
1413
1487
  function AnimationEffectsPanel({ controller, node, className = "" }) {
1414
1488
  const state = useAnimationEditorState(controller);
1415
1489
  const provider = state.effectsProvider;
1490
+ const applied = useMemo6(() => controller.appliedEffects(), [controller, state.scene]);
1416
1491
  const nodes = useMemo6(() => [...indexMotionNodes(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
1492
+ const pathNodes = useMemo6(() => {
1493
+ const vectorGroups = new Set(applied.filter((e) => e.kind === "vector").map((e) => e.instance));
1494
+ const own = state.scene.artwork.nodes.filter((n) => !vectorGroups.has(n.id));
1495
+ return [...indexMotionNodes(own).values()].filter((e) => e.node.type === "path").map((e) => e.node.id);
1496
+ }, [state.scene.artwork, applied]);
1417
1497
  const [chosen, setChosen] = useState8("");
1418
1498
  const target = node && nodes.includes(node) ? node : chosen && nodes.includes(chosen) ? chosen : "";
1419
1499
  const [browse, setBrowse] = useState8(null);
1500
+ const [vectorPathNode, setVectorPathNode] = useState8("");
1501
+ const [vectorWords, setVectorWords] = useState8("");
1502
+ const activeVectorPathNode = vectorPathNode && pathNodes.includes(vectorPathNode) ? vectorPathNode : "";
1420
1503
  const [open, setOpen] = useState8(null);
1421
1504
  const [message, setMessage] = useState8(null);
1422
1505
  const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? x.notes.length ? x.notes.join(" ") : null : x.error));
1423
- const applied = useMemo6(() => controller.appliedEffects(), [controller, state.scene]);
1424
1506
  const disabled = state.readOnly;
1425
1507
  return /* @__PURE__ */ jsxs11("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
1426
1508
  /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-1", children: [
@@ -1435,7 +1517,49 @@ function AnimationEffectsPanel({ controller, node, className = "" }) {
1435
1517
  !provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
1436
1518
  browse === "motion" && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
1437
1519
  /* @__PURE__ */ jsx13(EffectTemplates, { provider, disabled, fillLabel: "New scene from template", onFill: (t, v) => controller.fillTemplate(t, v).then((r) => (r.ok && r.notes.length && setMessage(r.notes.join(" ")), r)) }),
1438
- browse === "vector" && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
1520
+ browse === "vector" && /* @__PURE__ */ jsxs11("div", { className: "space-y-1", children: [
1521
+ /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-1", "data-effect-part": "vector-path", children: [
1522
+ /* @__PURE__ */ jsx13("span", { className: "text-muted-foreground", children: "Path" }),
1523
+ /* @__PURE__ */ jsxs11(
1524
+ "select",
1525
+ {
1526
+ className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]",
1527
+ "aria-label": "Path node for vector effect",
1528
+ value: activeVectorPathNode,
1529
+ disabled: disabled || !pathNodes.length,
1530
+ onChange: (e) => setVectorPathNode(e.currentTarget.value),
1531
+ children: [
1532
+ /* @__PURE__ */ jsx13("option", { value: "", children: "Default path" }),
1533
+ pathNodes.map((id) => /* @__PURE__ */ jsx13("option", { value: id, children: id }, id))
1534
+ ]
1535
+ }
1536
+ ),
1537
+ provider?.pathFromText && /* @__PURE__ */ jsx13(
1538
+ "input",
1539
+ {
1540
+ className: "w-24 rounded border border-border bg-transparent px-1 py-0.5",
1541
+ "aria-label": "Words for vector effect path",
1542
+ placeholder: "Words",
1543
+ value: vectorWords,
1544
+ disabled,
1545
+ onChange: (e) => setVectorWords(e.currentTarget.value)
1546
+ }
1547
+ )
1548
+ ] }),
1549
+ /* @__PURE__ */ jsx13(
1550
+ EffectsBrowser,
1551
+ {
1552
+ provider,
1553
+ kinds: ["vector"],
1554
+ title: "Vector effects",
1555
+ onPick: (e) => {
1556
+ setBrowse(null);
1557
+ const path = e.accepts?.includes("path") ? vectorWords.trim() ? { text: vectorWords } : activeVectorPathNode ? { node: activeVectorPathNode } : void 0 : void 0;
1558
+ report(controller.addVectorEffect(e.id, path ? { path } : void 0));
1559
+ }
1560
+ }
1561
+ )
1562
+ ] }),
1439
1563
  /* @__PURE__ */ jsx13("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ jsxs11("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
1440
1564
  /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
1441
1565
  /* @__PURE__ */ jsxs11("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.instance, onClick: () => setOpen(open === e.instance ? null : e.instance), children: [
@@ -1448,7 +1572,7 @@ function AnimationEffectsPanel({ controller, node, className = "" }) {
1448
1572
  ] }),
1449
1573
  /* @__PURE__ */ jsx13("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeMotionEffect(e.instance)), children: "\u2715" })
1450
1574
  ] }),
1451
- open === e.instance && /* @__PURE__ */ jsx13("div", { className: "mt-1", children: /* @__PURE__ */ jsx13(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values }) })
1575
+ open === e.instance && /* @__PURE__ */ jsx13("div", { className: "mt-1", children: /* @__PURE__ */ jsx13(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values, pathNodes, defaultPathNode: target, disabled }) })
1452
1576
  ] }, e.instance)) }),
1453
1577
  !applied.length && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
1454
1578
  message && /* @__PURE__ */ jsx13("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
@@ -1658,6 +1658,7 @@ function useCanvasDraw(options) {
1658
1658
  optionsRef.current = options;
1659
1659
  const [tool, setToolState] = (0, import_react17.useState)(options.initialTool ?? "select");
1660
1660
  const [activeStroke, setActiveStroke] = (0, import_react17.useState)(null);
1661
+ const [colorLocked, setColorLockedState] = (0, import_react17.useState)(!!options.initialColorLocked);
1661
1662
  const controller = (0, import_react17.useMemo)(
1662
1663
  () => (0, import_canvas12.createCanvasDrawController)({
1663
1664
  getNodes: () => nodesRef.current,
@@ -1674,6 +1675,8 @@ function useCanvasDraw(options) {
1674
1675
  generateNodeId: options.generateNodeId,
1675
1676
  brushLibrary: options.brushLibrary,
1676
1677
  colorScheme: options.colorScheme,
1678
+ colorLocked: options.initialColorLocked,
1679
+ onColorLockChange: setColorLockedState,
1677
1680
  onToolChange: setToolState,
1678
1681
  onStyleChange: (s) => setStyleState(s),
1679
1682
  onActiveStrokeChange: setActiveStroke,
@@ -1697,6 +1700,7 @@ function useCanvasDraw(options) {
1697
1700
  style,
1698
1701
  activeStroke,
1699
1702
  isDrawing: activeStroke !== null,
1703
+ colorLocked,
1700
1704
  setTool: controller.setTool,
1701
1705
  setStyle: controller.setStyle,
1702
1706
  startStroke: controller.startStroke,
@@ -1707,9 +1711,11 @@ function useCanvasDraw(options) {
1707
1711
  drawStroke: controller.drawStroke,
1708
1712
  nodeBounds: controller.nodeBounds,
1709
1713
  listBrushes: controller.listBrushes,
1710
- selectBrush: controller.selectBrush
1714
+ selectBrush: controller.selectBrush,
1715
+ setColorLocked: controller.setColorLocked,
1716
+ brushSettings: controller.brushSettings
1711
1717
  }),
1712
- [tool, style, activeStroke, controller]
1718
+ [tool, style, activeStroke, colorLocked, controller]
1713
1719
  );
1714
1720
  }
1715
1721
 
@@ -1199,6 +1199,7 @@ function useCanvasDraw(options) {
1199
1199
  optionsRef.current = options;
1200
1200
  const [tool, setToolState] = useState4(options.initialTool ?? "select");
1201
1201
  const [activeStroke, setActiveStroke] = useState4(null);
1202
+ const [colorLocked, setColorLockedState] = useState4(!!options.initialColorLocked);
1202
1203
  const controller = useMemo7(
1203
1204
  () => createCanvasDrawController({
1204
1205
  getNodes: () => nodesRef.current,
@@ -1215,6 +1216,8 @@ function useCanvasDraw(options) {
1215
1216
  generateNodeId: options.generateNodeId,
1216
1217
  brushLibrary: options.brushLibrary,
1217
1218
  colorScheme: options.colorScheme,
1219
+ colorLocked: options.initialColorLocked,
1220
+ onColorLockChange: setColorLockedState,
1218
1221
  onToolChange: setToolState,
1219
1222
  onStyleChange: (s) => setStyleState(s),
1220
1223
  onActiveStrokeChange: setActiveStroke,
@@ -1238,6 +1241,7 @@ function useCanvasDraw(options) {
1238
1241
  style,
1239
1242
  activeStroke,
1240
1243
  isDrawing: activeStroke !== null,
1244
+ colorLocked,
1241
1245
  setTool: controller.setTool,
1242
1246
  setStyle: controller.setStyle,
1243
1247
  startStroke: controller.startStroke,
@@ -1248,9 +1252,11 @@ function useCanvasDraw(options) {
1248
1252
  drawStroke: controller.drawStroke,
1249
1253
  nodeBounds: controller.nodeBounds,
1250
1254
  listBrushes: controller.listBrushes,
1251
- selectBrush: controller.selectBrush
1255
+ selectBrush: controller.selectBrush,
1256
+ setColorLocked: controller.setColorLocked,
1257
+ brushSettings: controller.brushSettings
1252
1258
  }),
1253
- [tool, style, activeStroke, controller]
1259
+ [tool, style, activeStroke, colorLocked, controller]
1254
1260
  );
1255
1261
  }
1256
1262
 
@@ -1,4 +1,4 @@
1
- import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
1
+ import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushChoice, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
2
2
  export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
3
3
  nodes: TNode[];
4
4
  setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
@@ -11,6 +11,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
11
11
  brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
12
12
  /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
13
13
  colorScheme?: 'light' | 'dark';
14
+ /** Start with the colour locked ("Keep my colour"); change it with `setColorLocked`. */
15
+ initialColorLocked?: boolean;
14
16
  onStrokeComplete?: (node: TNode) => void;
15
17
  onNodesErase?: (erasedNodes: TNode[]) => void;
16
18
  }
@@ -19,6 +21,8 @@ export interface CanvasDrawState {
19
21
  style: FreehandStrokeStyle;
20
22
  activeStroke: FreehandStroke | null;
21
23
  isDrawing: boolean;
24
+ /** "Keep my colour": choosing a brush keeps the stroke colour. */
25
+ colorLocked: boolean;
22
26
  }
23
27
  export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
24
28
  setTool: (tool: FreehandTool) => void;
@@ -47,6 +51,10 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
47
51
  selectBrush: (id: string | null, choice?: {
48
52
  keepColour?: boolean;
49
53
  }) => Promise<CanvasBrushPreset | null>;
54
+ /** Locks the stroke colour ("Keep my colour"): `selectBrush` then keeps it. */
55
+ setColorLocked: (locked: boolean) => void;
56
+ /** What the brush picker is set to (brush, colour, scheme, lock), read now; `canvas.selectBrush` returns it. */
57
+ brushSettings: () => CanvasBrushChoice;
50
58
  }
51
59
  export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
52
60
  /**
@@ -1,4 +1,4 @@
1
- import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
1
+ import { type CanvasDrawControllerOptions, type ArrangeHistoryTarget, type CanvasBrushChoice, type CanvasBrushPreset, type CanvasNode, type DrawStrokeInput, type DrawStrokeResult, type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from '@pixerate/editor/canvas';
2
2
  export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
3
3
  nodes: TNode[];
4
4
  setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
@@ -11,6 +11,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
11
11
  brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
12
12
  /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
13
13
  colorScheme?: 'light' | 'dark';
14
+ /** Start with the colour locked ("Keep my colour"); change it with `setColorLocked`. */
15
+ initialColorLocked?: boolean;
14
16
  onStrokeComplete?: (node: TNode) => void;
15
17
  onNodesErase?: (erasedNodes: TNode[]) => void;
16
18
  }
@@ -19,6 +21,8 @@ export interface CanvasDrawState {
19
21
  style: FreehandStrokeStyle;
20
22
  activeStroke: FreehandStroke | null;
21
23
  isDrawing: boolean;
24
+ /** "Keep my colour": choosing a brush keeps the stroke colour. */
25
+ colorLocked: boolean;
22
26
  }
23
27
  export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
24
28
  setTool: (tool: FreehandTool) => void;
@@ -47,6 +51,10 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
47
51
  selectBrush: (id: string | null, choice?: {
48
52
  keepColour?: boolean;
49
53
  }) => Promise<CanvasBrushPreset | null>;
54
+ /** Locks the stroke colour ("Keep my colour"): `selectBrush` then keeps it. */
55
+ setColorLocked: (locked: boolean) => void;
56
+ /** What the brush picker is set to (brush, colour, scheme, lock), read now; `canvas.selectBrush` returns it. */
57
+ brushSettings: () => CanvasBrushChoice;
50
58
  }
51
59
  export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
52
60
  /**
@@ -1665,7 +1665,12 @@ function VectorAppearancePanel({ controller, renderBrushPreview, className }) {
1665
1665
  ),
1666
1666
  kind === "stroke" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: buttonClass2, title: "Add a brushstroke (a natural-media brush along the path)", "aria-label": "Add brushstroke", "data-vector-add-brushstroke": "", disabled: !ids.length, onClick: () => controller.addBrushstroke({ brushId: controller.listBrushstrokeBrushes()[0].id, seed: (0, import_vector5.randomVectorBrushstrokeSeed)() }, { ids }), children: "\u270E+" })
1667
1667
  ] }),
1668
- [...layers].reverse().map((l) => layerRow(l, layers.length))
1668
+ [...layers].reverse().map((l) => layerRow(l, layers.length)),
1669
+ kind === "stroke" && layers.some((l) => l.brushstroke) && // Editor state: brushstrokes added or rebrushed from now on keep their colour.
1670
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { className: "flex items-center gap-1 text-[11px] text-muted-foreground", title: "Choosing a brush keeps the stroke's colour instead of taking the brush's default colour", children: [
1671
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { type: "checkbox", "aria-label": "Keep my colour", "data-vector-keep-colour": "", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
1672
+ " Keep my colour when choosing a brush"
1673
+ ] })
1669
1674
  ] });
1670
1675
  const filterNode = panel.filterNodeId;
1671
1676
  const setFilter = (f, key, value, merge) => {
@@ -1237,7 +1237,12 @@ function VectorAppearancePanel({ controller, renderBrushPreview, className }) {
1237
1237
  ),
1238
1238
  kind === "stroke" && /* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, title: "Add a brushstroke (a natural-media brush along the path)", "aria-label": "Add brushstroke", "data-vector-add-brushstroke": "", disabled: !ids.length, onClick: () => controller.addBrushstroke({ brushId: controller.listBrushstrokeBrushes()[0].id, seed: randomVectorBrushstrokeSeed() }, { ids }), children: "\u270E+" })
1239
1239
  ] }),
1240
- [...layers].reverse().map((l) => layerRow(l, layers.length))
1240
+ [...layers].reverse().map((l) => layerRow(l, layers.length)),
1241
+ kind === "stroke" && layers.some((l) => l.brushstroke) && // Editor state: brushstrokes added or rebrushed from now on keep their colour.
1242
+ /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-1 text-[11px] text-muted-foreground", title: "Choosing a brush keeps the stroke's colour instead of taking the brush's default colour", children: [
1243
+ /* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": "Keep my colour", "data-vector-keep-colour": "", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
1244
+ " Keep my colour when choosing a brush"
1245
+ ] })
1241
1246
  ] });
1242
1247
  const filterNode = panel.filterNodeId;
1243
1248
  const setFilter = (f, key, value, merge) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.181.0",
3
+ "version": "0.182.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -277,7 +277,7 @@
277
277
  "dependencies": {},
278
278
  "peerDependencies": {
279
279
  "@dagrejs/dagre": "^1.1.8",
280
- "@pixerate/editor": ">=0.265.0 <1.0.0-0",
280
+ "@pixerate/editor": ">=0.267.0 <1.0.0-0",
281
281
  "@tiptap/core": "^2.27.3",
282
282
  "@tiptap/extension-bubble-menu": "^2.27.3",
283
283
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -328,7 +328,7 @@
328
328
  "tsup": "^9.0.0",
329
329
  "typescript": "^5.7.3",
330
330
  "vitest": "^5.0.5",
331
- "@pixerate/editor": "0.265.0"
331
+ "@pixerate/editor": "0.267.0"
332
332
  },
333
333
  "scripts": {
334
334
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",