@pixerate/editor-react 0.180.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.
- package/dist/animation-editor/index.cjs +128 -4
- package/dist/animation-editor/index.js +128 -4
- package/dist/brushes/BrushEditor.d.cts +2 -0
- package/dist/brushes/BrushEditor.d.ts +2 -0
- package/dist/brushes/BrushLibraryEditor.d.cts +6 -1
- package/dist/brushes/BrushLibraryEditor.d.ts +6 -1
- package/dist/brushes/index.cjs +7 -4
- 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-QIJJCDYW.js → chunk-THMOZMEE.js} +7 -4
- package/dist/{chunk-XAPJMT3W.js → chunk-WCSMREA4.js} +2 -2
- package/dist/{chunk-76JBZXLM.js → chunk-XORL5PGL.js} +2 -2
- package/dist/image-editor/index.cjs +7 -4
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +7 -4
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +4 -3
- package/dist/paint-editor/index.js +4 -3
- package/dist/vector/index.cjs +13 -5
- 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 })
|
|
@@ -17,6 +17,8 @@ export interface BrushEditorProps {
|
|
|
17
17
|
onChange: (brush: Brush) => void;
|
|
18
18
|
/** A live preview stroke of `brush`: pixels (e.g. `controller.brushThumbnail`) or an image URL. */
|
|
19
19
|
preview?: Pixels | string | null;
|
|
20
|
+
/** The colour behind an image-URL preview, for transparent previews (see `brushPreviewColours`). */
|
|
21
|
+
previewBackground?: string;
|
|
20
22
|
/** With it, a "Save" button (labelled `saveLabel`) saves the brush in place. */
|
|
21
23
|
onSave?: () => unknown;
|
|
22
24
|
/** The Save button's label (default "Save"; e.g. "Save a copy" for a built-in). */
|
|
@@ -17,6 +17,8 @@ export interface BrushEditorProps {
|
|
|
17
17
|
onChange: (brush: Brush) => void;
|
|
18
18
|
/** A live preview stroke of `brush`: pixels (e.g. `controller.brushThumbnail`) or an image URL. */
|
|
19
19
|
preview?: Pixels | string | null;
|
|
20
|
+
/** The colour behind an image-URL preview, for transparent previews (see `brushPreviewColours`). */
|
|
21
|
+
previewBackground?: string;
|
|
20
22
|
/** With it, a "Save" button (labelled `saveLabel`) saves the brush in place. */
|
|
21
23
|
onSave?: () => unknown;
|
|
22
24
|
/** The Save button's label (default "Save"; e.g. "Save a copy" for a built-in). */
|
|
@@ -9,7 +9,12 @@ export interface BrushLibraryEditorProps {
|
|
|
9
9
|
profile: BrushHostProfile;
|
|
10
10
|
/** Draws the preview stroke (the host's renderer, as for `preview_brush`). Without it there is no preview. */
|
|
11
11
|
renderPreview?: BrushPreviewRenderer;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What a transparent preview is shown on (#rrggbb, default white); the renderer's own `paper`
|
|
14
|
+
* wins. The preview colour is chosen to read on it (`brushPreviewColours`).
|
|
15
|
+
*/
|
|
16
|
+
previewPaper?: string;
|
|
17
|
+
/** A fixed preview colour instead (overrides the brush's own and the contrast check). */
|
|
13
18
|
previewColor?: string;
|
|
14
19
|
/** Called with the brush as saved (a copy has a new id): e.g. pick it in the host. */
|
|
15
20
|
onSaved?: (brush: Brush) => void;
|
|
@@ -9,7 +9,12 @@ export interface BrushLibraryEditorProps {
|
|
|
9
9
|
profile: BrushHostProfile;
|
|
10
10
|
/** Draws the preview stroke (the host's renderer, as for `preview_brush`). Without it there is no preview. */
|
|
11
11
|
renderPreview?: BrushPreviewRenderer;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What a transparent preview is shown on (#rrggbb, default white); the renderer's own `paper`
|
|
14
|
+
* wins. The preview colour is chosen to read on it (`brushPreviewColours`).
|
|
15
|
+
*/
|
|
16
|
+
previewPaper?: string;
|
|
17
|
+
/** A fixed preview colour instead (overrides the brush's own and the contrast check). */
|
|
13
18
|
previewColor?: string;
|
|
14
19
|
/** Called with the brush as saved (a copy has a new id): e.g. pick it in the host. */
|
|
15
20
|
onSaved?: (brush: Brush) => void;
|
package/dist/brushes/index.cjs
CHANGED
|
@@ -96,7 +96,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime.js
|
|
|
96
96
|
|
|
97
97
|
// src/brushes/BrushEditor.tsx
|
|
98
98
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
99
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
99
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
100
100
|
const sections = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
101
101
|
const scope = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
102
102
|
const [problems, setProblems] = (0, import_react2.useState)(null);
|
|
@@ -116,7 +116,7 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
116
116
|
if (r.brush !== brush) onChange(r.brush);
|
|
117
117
|
};
|
|
118
118
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
119
|
-
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" } }) : 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" } }),
|
|
119
|
+
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
120
|
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
121
|
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
122
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -257,7 +257,7 @@ var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, th
|
|
|
257
257
|
var import_react4 = require("react");
|
|
258
258
|
var import_brushes3 = require("@pixerate/editor/brushes");
|
|
259
259
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
260
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
260
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
261
261
|
const [original, setOriginal] = (0, import_react4.useState)(null);
|
|
262
262
|
const [builtin, setBuiltin] = (0, import_react4.useState)(false);
|
|
263
263
|
const [draft, setDraft] = (0, import_react4.useState)(null);
|
|
@@ -277,7 +277,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
277
277
|
live = false;
|
|
278
278
|
};
|
|
279
279
|
}, [library, brushId, profile]);
|
|
280
|
-
const
|
|
280
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
281
|
+
const colours = (0, import_react4.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
282
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
281
283
|
(0, import_react4.useEffect)(() => {
|
|
282
284
|
if (!draft || !renderPreview) return;
|
|
283
285
|
let live = true;
|
|
@@ -325,6 +327,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
325
327
|
brush: draft,
|
|
326
328
|
profile,
|
|
327
329
|
preview: renderPreview ? preview : void 0,
|
|
330
|
+
previewBackground: colours?.background,
|
|
328
331
|
onChange: (next) => {
|
|
329
332
|
setDraft(next);
|
|
330
333
|
setStatus(null);
|
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-THMOZMEE.js";
|
|
5
5
|
import {
|
|
6
6
|
BrushEditor,
|
|
7
7
|
BrushLibraryBrowser
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-XORL5PGL.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
|
|
|
@@ -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
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrushEditor,
|
|
3
3
|
button
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XORL5PGL.js";
|
|
5
5
|
|
|
6
6
|
// src/brushes/BrushLibraryEditor.tsx
|
|
7
7
|
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { brushPreviewColours, checkBrushEdit, newBrushFor, saveBrushEdit } from "@pixerate/editor/brushes";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
10
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
11
11
|
const [original, setOriginal] = useState(null);
|
|
12
12
|
const [builtin, setBuiltin] = useState(false);
|
|
13
13
|
const [draft, setDraft] = useState(null);
|
|
@@ -27,7 +27,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
27
27
|
live = false;
|
|
28
28
|
};
|
|
29
29
|
}, [library, brushId, profile]);
|
|
30
|
-
const
|
|
30
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
31
|
+
const colours = useMemo(() => draft ? brushPreviewColours(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
32
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
if (!draft || !renderPreview) return;
|
|
33
35
|
let live = true;
|
|
@@ -75,6 +77,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
75
77
|
brush: draft,
|
|
76
78
|
profile,
|
|
77
79
|
preview: renderPreview ? preview : void 0,
|
|
80
|
+
previewBackground: colours?.background,
|
|
78
81
|
onChange: (next) => {
|
|
79
82
|
setDraft(next);
|
|
80
83
|
setStatus(null);
|
|
@@ -44,10 +44,10 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
BrushLibraryEditor,
|
|
46
46
|
useBrushLibrary
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-THMOZMEE.js";
|
|
48
48
|
import {
|
|
49
49
|
BrushLibraryBrowser
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-XORL5PGL.js";
|
|
51
51
|
|
|
52
52
|
// src/image-editor/useImageEditor.ts
|
|
53
53
|
import { useRef, useState, useEffect, useCallback, useMemo } from "react";
|
|
@@ -143,7 +143,7 @@ var CommitColorInput = ({ value, label, onCommit, className }) => {
|
|
|
143
143
|
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
144
144
|
import { brushEditorScope, brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
|
|
145
145
|
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
146
|
-
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
146
|
+
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
147
147
|
const sections = useMemo2(() => brushEditorSections(brush, profile), [brush, profile]);
|
|
148
148
|
const scope = useMemo2(() => brushEditorScope(brush, profile), [brush, profile]);
|
|
149
149
|
const [problems, setProblems] = useState3(null);
|
|
@@ -163,7 +163,7 @@ var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSave,
|
|
|
163
163
|
if (r.brush !== brush) onChange(r.brush);
|
|
164
164
|
};
|
|
165
165
|
return /* @__PURE__ */ jsxs3("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
166
|
-
typeof preview === "string" ? /* @__PURE__ */ jsx3("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ jsx3(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
166
|
+
typeof preview === "string" ? /* @__PURE__ */ jsx3("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ jsx3(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
167
167
|
scope.note && /* @__PURE__ */ jsx3("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 }),
|
|
168
168
|
sections.map((s) => /* @__PURE__ */ jsxs3("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
169
169
|
/* @__PURE__ */ jsx3("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -4713,7 +4713,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime26.
|
|
|
4713
4713
|
var import_react27 = require("react");
|
|
4714
4714
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
4715
4715
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4716
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
4716
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
4717
4717
|
const sections = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
4718
4718
|
const scope = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
4719
4719
|
const [problems, setProblems] = (0, import_react27.useState)(null);
|
|
@@ -4733,7 +4733,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
4733
4733
|
if (r.brush !== brush) onChange(r.brush);
|
|
4734
4734
|
};
|
|
4735
4735
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
4736
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
4736
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
4737
4737
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime27.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 }),
|
|
4738
4738
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
4739
4739
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -4821,7 +4821,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
4821
4821
|
|
|
4822
4822
|
// src/brushes/BrushLibraryEditor.tsx
|
|
4823
4823
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4824
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
4824
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
4825
4825
|
const [original, setOriginal] = (0, import_react28.useState)(null);
|
|
4826
4826
|
const [builtin, setBuiltin] = (0, import_react28.useState)(false);
|
|
4827
4827
|
const [draft, setDraft] = (0, import_react28.useState)(null);
|
|
@@ -4841,7 +4841,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
4841
4841
|
live = false;
|
|
4842
4842
|
};
|
|
4843
4843
|
}, [library, brushId, profile]);
|
|
4844
|
-
const
|
|
4844
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
4845
|
+
const colours = (0, import_react28.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
4846
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
4845
4847
|
(0, import_react28.useEffect)(() => {
|
|
4846
4848
|
if (!draft || !renderPreview) return;
|
|
4847
4849
|
let live = true;
|
|
@@ -4889,6 +4891,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
4889
4891
|
brush: draft,
|
|
4890
4892
|
profile,
|
|
4891
4893
|
preview: renderPreview ? preview : void 0,
|
|
4894
|
+
previewBackground: colours?.background,
|
|
4892
4895
|
onChange: (next) => {
|
|
4893
4896
|
setDraft(next);
|
|
4894
4897
|
setStatus(null);
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
useImageEditor,
|
|
30
30
|
useImageEffectsTools,
|
|
31
31
|
useImageHistogram
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-WCSMREA4.js";
|
|
33
33
|
import {
|
|
34
34
|
ImageCheckbox,
|
|
35
35
|
ImageColor,
|
|
@@ -44,8 +44,8 @@ import "../chunk-5RPB4WGT.js";
|
|
|
44
44
|
import "../chunk-KIRIU53A.js";
|
|
45
45
|
import "../chunk-3I7FOSLF.js";
|
|
46
46
|
import "../chunk-W5CMGX3I.js";
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
47
|
+
import "../chunk-THMOZMEE.js";
|
|
48
|
+
import "../chunk-XORL5PGL.js";
|
|
49
49
|
export {
|
|
50
50
|
AdjustmentLayersPanel,
|
|
51
51
|
BrushOptionsBar,
|
package/dist/index.cjs
CHANGED
|
@@ -8477,7 +8477,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime43.
|
|
|
8477
8477
|
var import_react63 = require("react");
|
|
8478
8478
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
8479
8479
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8480
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
8480
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
8481
8481
|
const sections = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
8482
8482
|
const scope = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
8483
8483
|
const [problems, setProblems] = (0, import_react63.useState)(null);
|
|
@@ -8497,7 +8497,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
8497
8497
|
if (r.brush !== brush) onChange(r.brush);
|
|
8498
8498
|
};
|
|
8499
8499
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
8500
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
8500
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime44.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_runtime44.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
8501
8501
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime44.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 }),
|
|
8502
8502
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
8503
8503
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -8585,7 +8585,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
8585
8585
|
|
|
8586
8586
|
// src/brushes/BrushLibraryEditor.tsx
|
|
8587
8587
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8588
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
8588
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
8589
8589
|
const [original, setOriginal] = (0, import_react64.useState)(null);
|
|
8590
8590
|
const [builtin, setBuiltin] = (0, import_react64.useState)(false);
|
|
8591
8591
|
const [draft, setDraft] = (0, import_react64.useState)(null);
|
|
@@ -8605,7 +8605,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
8605
8605
|
live = false;
|
|
8606
8606
|
};
|
|
8607
8607
|
}, [library, brushId, profile]);
|
|
8608
|
-
const
|
|
8608
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
8609
|
+
const colours = (0, import_react64.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
8610
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
8609
8611
|
(0, import_react64.useEffect)(() => {
|
|
8610
8612
|
if (!draft || !renderPreview) return;
|
|
8611
8613
|
let live = true;
|
|
@@ -8653,6 +8655,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
8653
8655
|
brush: draft,
|
|
8654
8656
|
profile,
|
|
8655
8657
|
preview: renderPreview ? preview : void 0,
|
|
8658
|
+
previewBackground: colours?.background,
|
|
8656
8659
|
onChange: (next) => {
|
|
8657
8660
|
setDraft(next);
|
|
8658
8661
|
setStatus(null);
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
useImageEditor,
|
|
63
63
|
useImageEffectsTools,
|
|
64
64
|
useImageHistogram
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-WCSMREA4.js";
|
|
66
66
|
import {
|
|
67
67
|
ImageCheckbox,
|
|
68
68
|
ImageColor,
|
|
@@ -82,8 +82,8 @@ import {
|
|
|
82
82
|
useAgentPlayback,
|
|
83
83
|
usePlaybackSurface
|
|
84
84
|
} from "./chunk-W5CMGX3I.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
85
|
+
import "./chunk-THMOZMEE.js";
|
|
86
|
+
import "./chunk-XORL5PGL.js";
|
|
87
87
|
import {
|
|
88
88
|
CommandPalette,
|
|
89
89
|
useCommandPalette,
|
|
@@ -667,7 +667,7 @@ var import_brushes3 = require("@pixerate/editor/brushes");
|
|
|
667
667
|
var import_react5 = require("react");
|
|
668
668
|
var import_brushes = require("@pixerate/editor/brushes");
|
|
669
669
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
670
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
670
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
671
671
|
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
672
672
|
const scope = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
673
673
|
const [problems, setProblems] = (0, import_react5.useState)(null);
|
|
@@ -687,7 +687,7 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
687
687
|
if (r.brush !== brush) onChange(r.brush);
|
|
688
688
|
};
|
|
689
689
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
690
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
690
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
691
691
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime4.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 }),
|
|
692
692
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
693
693
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -1046,7 +1046,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1046
1046
|
const { brush, brushes } = state;
|
|
1047
1047
|
const paper = state.document.paper;
|
|
1048
1048
|
const thumbs = (0, import_react10.useMemo)(
|
|
1049
|
-
|
|
1049
|
+
// Each in a colour that reads on the paper (the brush's own default when it has one).
|
|
1050
|
+
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: (0, import_brushes3.brushPreviewColours)(controller.getBrushSpec(b.id), { paper: paper.color }).color })])),
|
|
1050
1051
|
// Thumbnails follow the library and the paper.
|
|
1051
1052
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1052
1053
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
chip,
|
|
30
30
|
panel,
|
|
31
31
|
useAttempt
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-XORL5PGL.js";
|
|
33
33
|
|
|
34
34
|
// src/paint-editor/usePaintEditor.ts
|
|
35
35
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -559,7 +559,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
559
559
|
// src/paint-editor/BrushPanel.tsx
|
|
560
560
|
import { useMemo as useMemo3, useRef as useRef4 } from "react";
|
|
561
561
|
import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
|
|
562
|
-
import { brushColourHex, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
562
|
+
import { brushColourHex, brushPreviewColours, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
563
563
|
|
|
564
564
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
565
565
|
import { PAINT_GRADIENT_KIT } from "@pixerate/editor/paint-editor";
|
|
@@ -598,7 +598,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
598
598
|
const { brush, brushes } = state;
|
|
599
599
|
const paper = state.document.paper;
|
|
600
600
|
const thumbs = useMemo3(
|
|
601
|
-
|
|
601
|
+
// Each in a colour that reads on the paper (the brush's own default when it has one).
|
|
602
|
+
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: brushPreviewColours(controller.getBrushSpec(b.id), { paper: paper.color }).color })])),
|
|
602
603
|
// Thumbnails follow the library and the paper.
|
|
603
604
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
604
605
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
package/dist/vector/index.cjs
CHANGED
|
@@ -1275,7 +1275,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime7.j
|
|
|
1275
1275
|
var import_react9 = require("react");
|
|
1276
1276
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
1277
1277
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1278
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
1278
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
1279
1279
|
const sections = (0, import_react9.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
1280
1280
|
const scope = (0, import_react9.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
1281
1281
|
const [problems, setProblems] = (0, import_react9.useState)(null);
|
|
@@ -1295,7 +1295,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
1295
1295
|
if (r.brush !== brush) onChange(r.brush);
|
|
1296
1296
|
};
|
|
1297
1297
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
1298
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
1298
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime8.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
1299
1299
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime8.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 }),
|
|
1300
1300
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
1301
1301
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -1383,7 +1383,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
1383
1383
|
|
|
1384
1384
|
// src/brushes/BrushLibraryEditor.tsx
|
|
1385
1385
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1386
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
1386
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
1387
1387
|
const [original, setOriginal] = (0, import_react10.useState)(null);
|
|
1388
1388
|
const [builtin, setBuiltin] = (0, import_react10.useState)(false);
|
|
1389
1389
|
const [draft, setDraft] = (0, import_react10.useState)(null);
|
|
@@ -1403,7 +1403,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
1403
1403
|
live = false;
|
|
1404
1404
|
};
|
|
1405
1405
|
}, [library, brushId, profile]);
|
|
1406
|
-
const
|
|
1406
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
1407
|
+
const colours = (0, import_react10.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
1408
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
1407
1409
|
(0, import_react10.useEffect)(() => {
|
|
1408
1410
|
if (!draft || !renderPreview) return;
|
|
1409
1411
|
let live = true;
|
|
@@ -1451,6 +1453,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
1451
1453
|
brush: draft,
|
|
1452
1454
|
profile,
|
|
1453
1455
|
preview: renderPreview ? preview : void 0,
|
|
1456
|
+
previewBackground: colours?.background,
|
|
1454
1457
|
onChange: (next) => {
|
|
1455
1458
|
setDraft(next);
|
|
1456
1459
|
setStatus(null);
|
|
@@ -1662,7 +1665,12 @@ function VectorAppearancePanel({ controller, renderBrushPreview, className }) {
|
|
|
1662
1665
|
),
|
|
1663
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+" })
|
|
1664
1667
|
] }),
|
|
1665
|
-
[...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
|
+
] })
|
|
1666
1674
|
] });
|
|
1667
1675
|
const filterNode = panel.filterNodeId;
|
|
1668
1676
|
const setFilter = (f, key, value, merge) => {
|
package/dist/vector/index.js
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
BrushLibraryEditor,
|
|
17
17
|
useBrushLibrary
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-THMOZMEE.js";
|
|
19
19
|
import {
|
|
20
20
|
BrushLibraryBrowser
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-XORL5PGL.js";
|
|
22
22
|
|
|
23
23
|
// src/vector/useVectorEditor.ts
|
|
24
24
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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",
|