@pixerate/editor-react 0.181.0 → 0.183.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.
- package/dist/animation-editor/index.cjs +128 -4
- package/dist/animation-editor/index.js +128 -4
- package/dist/brushes/BrushEditor.d.cts +8 -1
- package/dist/brushes/BrushEditor.d.ts +8 -1
- package/dist/brushes/BrushLibraryEditor.d.cts +1 -1
- package/dist/brushes/BrushLibraryEditor.d.ts +1 -1
- package/dist/brushes/index.cjs +57 -5
- package/dist/brushes/index.js +2 -2
- package/dist/canvas/index.cjs +8 -2
- package/dist/canvas/index.js +8 -2
- package/dist/canvas/useCanvasDraw.d.cts +9 -1
- package/dist/canvas/useCanvasDraw.d.ts +9 -1
- package/dist/{chunk-THMOZMEE.js → chunk-2QXGKOVK.js} +16 -3
- package/dist/{chunk-WCSMREA4.js → chunk-BICTULEJ.js} +2 -2
- package/dist/{chunk-XORL5PGL.js → chunk-GUBRH2OO.js} +34 -5
- package/dist/image-editor/index.cjs +47 -5
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +47 -5
- package/dist/index.js +3 -3
- package/dist/paint-editor/BrushPanel.d.cts +2 -1
- package/dist/paint-editor/BrushPanel.d.ts +2 -1
- package/dist/paint-editor/index.cjs +35 -4
- package/dist/paint-editor/index.js +4 -2
- package/dist/vector/index.cjs +53 -6
- package/dist/vector/index.js +8 -3
- package/package.json +3 -3
|
@@ -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({
|
|
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.
|
|
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({
|
|
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__ */
|
|
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 })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type Brush, type BrushHostProfile } from '@pixerate/editor/brushes';
|
|
2
|
+
import { type Brush, type BrushHostProfile, type BrushSource } from '@pixerate/editor/brushes';
|
|
3
3
|
type Pixels = {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -27,6 +27,13 @@ export interface BrushEditorProps {
|
|
|
27
27
|
onSaveAs?: (name: string) => unknown;
|
|
28
28
|
/** Extra controls a host adds to a section (e.g. the sticker picker for stamps). */
|
|
29
29
|
renderExtra?: (section: string) => React.ReactNode;
|
|
30
|
+
/** The library's image sources, offered as stamps and as grain. */
|
|
31
|
+
sources?: ReadonlyArray<Pick<BrushSource, 'id' | 'name'>>;
|
|
32
|
+
/**
|
|
33
|
+
* With it, "Add image…" buttons for an image tip and for grain: it stores the picked file as a
|
|
34
|
+
* source (e.g. `addBrushSourceFromFile`) and returns its `source:<id>` ref.
|
|
35
|
+
*/
|
|
36
|
+
onAddSource?: (file: File) => Promise<string>;
|
|
30
37
|
className?: string;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type Brush, type BrushHostProfile } from '@pixerate/editor/brushes';
|
|
2
|
+
import { type Brush, type BrushHostProfile, type BrushSource } from '@pixerate/editor/brushes';
|
|
3
3
|
type Pixels = {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -27,6 +27,13 @@ export interface BrushEditorProps {
|
|
|
27
27
|
onSaveAs?: (name: string) => unknown;
|
|
28
28
|
/** Extra controls a host adds to a section (e.g. the sticker picker for stamps). */
|
|
29
29
|
renderExtra?: (section: string) => React.ReactNode;
|
|
30
|
+
/** The library's image sources, offered as stamps and as grain. */
|
|
31
|
+
sources?: ReadonlyArray<Pick<BrushSource, 'id' | 'name'>>;
|
|
32
|
+
/**
|
|
33
|
+
* With it, "Add image…" buttons for an image tip and for grain: it stores the picked file as a
|
|
34
|
+
* source (e.g. `addBrushSourceFromFile`) and returns its `source:<id>` ref.
|
|
35
|
+
*/
|
|
36
|
+
onAddSource?: (file: File) => Promise<string>;
|
|
30
37
|
className?: string;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
@@ -24,7 +24,7 @@ export interface BrushLibraryEditorProps {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* `BrushEditor` on a brush library for one host: loads the brush, edits a draft and saves it with
|
|
27
|
-
* `saveBrushEdit`. A saved brush is changed in place, a built-in is saved as a copy, "Save brush"
|
|
27
|
+
* `saveBrushEdit`. Images added for an image tip or grain are stored in the library as sources. A saved brush is changed in place, a built-in is saved as a copy, "Save brush"
|
|
28
28
|
* saves under a new name, and "New brush" starts from the current one with only what the host
|
|
29
29
|
* uses. Facets the host can't use are kept on save; a new brush must pass the host's check.
|
|
30
30
|
*/
|
|
@@ -24,7 +24,7 @@ export interface BrushLibraryEditorProps {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* `BrushEditor` on a brush library for one host: loads the brush, edits a draft and saves it with
|
|
27
|
-
* `saveBrushEdit`. A saved brush is changed in place, a built-in is saved as a copy, "Save brush"
|
|
27
|
+
* `saveBrushEdit`. Images added for an image tip or grain are stored in the library as sources. A saved brush is changed in place, a built-in is saved as a copy, "Save brush"
|
|
28
28
|
* saves under a new name, and "New brush" starts from the current one with only what the host
|
|
29
29
|
* uses. Facets the host can't use are kept on save; a new brush must pass the host's check.
|
|
30
30
|
*/
|
package/dist/brushes/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/brushes/index.ts
|
|
@@ -28,7 +38,7 @@ __export(brushes_exports, {
|
|
|
28
38
|
module.exports = __toCommonJS(brushes_exports);
|
|
29
39
|
|
|
30
40
|
// src/brushes/BrushEditor.tsx
|
|
31
|
-
var import_react2 = require("react");
|
|
41
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
32
42
|
var import_brushes = require("@pixerate/editor/brushes");
|
|
33
43
|
|
|
34
44
|
// src/paint-editor/shared.tsx
|
|
@@ -96,8 +106,8 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime.js
|
|
|
96
106
|
|
|
97
107
|
// src/brushes/BrushEditor.tsx
|
|
98
108
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
99
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
100
|
-
const sections = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
109
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
|
|
110
|
+
const sections = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
|
|
101
111
|
const scope = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
102
112
|
const [problems, setProblems] = (0, import_react2.useState)(null);
|
|
103
113
|
const [name, setName] = (0, import_react2.useState)("");
|
|
@@ -115,12 +125,24 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
115
125
|
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
116
126
|
if (r.brush !== brush) onChange(r.brush);
|
|
117
127
|
};
|
|
128
|
+
const addSource = onAddSource ? async (file, as) => {
|
|
129
|
+
try {
|
|
130
|
+
const r = (0, import_brushes.withBrushSource)(brush, await onAddSource(file), as);
|
|
131
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
132
|
+
onChange(r.brush);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
setProblems(e.message);
|
|
135
|
+
}
|
|
136
|
+
} : void 0;
|
|
118
137
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
119
138
|
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
120
139
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
121
140
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
122
141
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
123
|
-
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
142
|
+
s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.default.Fragment, { children: [
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EditorControl, { control: c, onSet: set }),
|
|
144
|
+
addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
|
|
145
|
+
] }, c.path)),
|
|
124
146
|
renderExtra?.(s.id)
|
|
125
147
|
] }, s.id)),
|
|
126
148
|
(onSave || onSaveAs) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
@@ -133,6 +155,23 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
133
155
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorLine, { error: problems })
|
|
134
156
|
] });
|
|
135
157
|
};
|
|
158
|
+
var AddImage = ({ label, onFile }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: `${button} cursor-pointer self-start`, children: [
|
|
159
|
+
label,
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
161
|
+
"input",
|
|
162
|
+
{
|
|
163
|
+
type: "file",
|
|
164
|
+
accept: "image/*",
|
|
165
|
+
"aria-label": label,
|
|
166
|
+
className: "sr-only",
|
|
167
|
+
onChange: (e) => {
|
|
168
|
+
const file = e.target.files?.[0];
|
|
169
|
+
e.target.value = "";
|
|
170
|
+
if (file) onFile(file);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] });
|
|
136
175
|
var EditorControl = ({ control: c, onSet }) => {
|
|
137
176
|
const note = c.note ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
138
177
|
switch (c.kind) {
|
|
@@ -263,6 +302,17 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
263
302
|
const [draft, setDraft] = (0, import_react4.useState)(null);
|
|
264
303
|
const [status, setStatus] = (0, import_react4.useState)(null);
|
|
265
304
|
const [preview, setPreview] = (0, import_react4.useState)(null);
|
|
305
|
+
const [sources, setSources] = (0, import_react4.useState)([]);
|
|
306
|
+
(0, import_react4.useEffect)(() => {
|
|
307
|
+
let live = true;
|
|
308
|
+
const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
|
|
309
|
+
read();
|
|
310
|
+
const off = library.subscribe(read);
|
|
311
|
+
return () => {
|
|
312
|
+
live = false;
|
|
313
|
+
off();
|
|
314
|
+
};
|
|
315
|
+
}, [library]);
|
|
266
316
|
(0, import_react4.useEffect)(() => {
|
|
267
317
|
let live = true;
|
|
268
318
|
setStatus(null);
|
|
@@ -334,7 +384,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
|
|
|
334
384
|
},
|
|
335
385
|
onSave: original ? () => save() : void 0,
|
|
336
386
|
saveLabel: builtin ? "Save a copy" : "Save",
|
|
337
|
-
onSaveAs: (name) => save(name)
|
|
387
|
+
onSaveAs: (name) => save(name),
|
|
388
|
+
sources,
|
|
389
|
+
onAddSource: async (file) => (await (0, import_brushes3.addBrushSourceFromFile)(library, file)).ref
|
|
338
390
|
}
|
|
339
391
|
),
|
|
340
392
|
errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "text-[11px] text-rose-400", "data-testid": "brush-library-editor-issues", children: errors.map((i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
package/dist/brushes/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrushLibraryEditor,
|
|
3
3
|
useBrushLibrary
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-2QXGKOVK.js";
|
|
5
5
|
import {
|
|
6
6
|
BrushEditor,
|
|
7
7
|
BrushLibraryBrowser
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-GUBRH2OO.js";
|
|
9
9
|
export {
|
|
10
10
|
BrushEditor,
|
|
11
11
|
BrushLibraryBrowser,
|
package/dist/canvas/index.cjs
CHANGED
|
@@ -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
|
|
package/dist/canvas/index.js
CHANGED
|
@@ -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
|
|