@pixerate/editor-react 0.177.0 → 0.178.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/paint-editor/PathStrokePanel.d.cts +12 -0
- package/dist/paint-editor/PathStrokePanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +351 -317
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +119 -86
- package/package.json +3 -3
|
@@ -11,6 +11,7 @@ export * from './WetPanel.cjs';
|
|
|
11
11
|
export * from './StickerPanel.cjs';
|
|
12
12
|
export * from './StickerPicker.cjs';
|
|
13
13
|
export * from './StrokePanel.cjs';
|
|
14
|
+
export * from './PathStrokePanel.cjs';
|
|
14
15
|
export * from './PaintEditor.cjs';
|
|
15
16
|
export { PaintSlider } from './shared.cjs';
|
|
16
17
|
export * from './PaintGradientEditor.cjs';
|
|
@@ -11,6 +11,7 @@ export * from './WetPanel.js';
|
|
|
11
11
|
export * from './StickerPanel.js';
|
|
12
12
|
export * from './StickerPicker.js';
|
|
13
13
|
export * from './StrokePanel.js';
|
|
14
|
+
export * from './PathStrokePanel.js';
|
|
14
15
|
export * from './PaintEditor.js';
|
|
15
16
|
export { PaintSlider } from './shared.js';
|
|
16
17
|
export * from './PaintGradientEditor.js';
|
|
@@ -1461,16 +1461,47 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1461
1461
|
] });
|
|
1462
1462
|
};
|
|
1463
1463
|
|
|
1464
|
+
// src/paint-editor/PathStrokePanel.tsx
|
|
1465
|
+
import { useState as useState9 } from "react";
|
|
1466
|
+
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1467
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1468
|
+
var PathStrokePanel = ({ controller, className }) => {
|
|
1469
|
+
const state = usePaintEditorState(controller);
|
|
1470
|
+
const [error, attempt] = useAttempt();
|
|
1471
|
+
const [path, setPath] = useState9("");
|
|
1472
|
+
const [taper, setTaper] = useState9(PATH_STROKE_TAPERS[0].id);
|
|
1473
|
+
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1474
|
+
return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1475
|
+
/* @__PURE__ */ jsx14("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1476
|
+
/* @__PURE__ */ jsx14(
|
|
1477
|
+
"textarea",
|
|
1478
|
+
{
|
|
1479
|
+
"aria-label": "SVG path data",
|
|
1480
|
+
placeholder: "M 40 200 C 120 40 280 40 360 200",
|
|
1481
|
+
value: path,
|
|
1482
|
+
onChange: (e) => setPath(e.target.value),
|
|
1483
|
+
rows: 2,
|
|
1484
|
+
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1485
|
+
}
|
|
1486
|
+
),
|
|
1487
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
|
|
1488
|
+
/* @__PURE__ */ jsx14("select", { "aria-label": "Pressure along the path", value: taper, onChange: (e) => setTaper(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: PATH_STROKE_TAPERS.map((t) => /* @__PURE__ */ jsx14("option", { value: t.id, children: t.label }, t.id)) }),
|
|
1489
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1490
|
+
] }),
|
|
1491
|
+
/* @__PURE__ */ jsx14(ErrorLine, { error })
|
|
1492
|
+
] });
|
|
1493
|
+
};
|
|
1494
|
+
|
|
1464
1495
|
// src/paint-editor/PaintEditor.tsx
|
|
1465
|
-
import { useRef as useRef8, useState as
|
|
1496
|
+
import { useRef as useRef8, useState as useState11 } from "react";
|
|
1466
1497
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1467
1498
|
|
|
1468
1499
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1469
|
-
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef7, useState as
|
|
1500
|
+
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef7, useState as useState10 } from "react";
|
|
1470
1501
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1471
|
-
import { jsx as
|
|
1502
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1472
1503
|
function usePaintEffectsProvider(controller) {
|
|
1473
|
-
const [provider, setProvider] =
|
|
1504
|
+
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1474
1505
|
useEffect5(() => {
|
|
1475
1506
|
setProvider(controller.effectsProvider);
|
|
1476
1507
|
return controller.effects.subscribe(setProvider);
|
|
@@ -1487,19 +1518,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1487
1518
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1488
1519
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1489
1520
|
const drags = useRef7(/* @__PURE__ */ new Set());
|
|
1490
|
-
if (!provider) return /* @__PURE__ */
|
|
1521
|
+
if (!provider) return /* @__PURE__ */ jsxs14("p", { className: "text-[11px] text-slate-400", children: [
|
|
1491
1522
|
'No effects provider: "',
|
|
1492
1523
|
name ?? effect,
|
|
1493
1524
|
'" is kept as it was drawn.'
|
|
1494
1525
|
] });
|
|
1495
|
-
if (error) return /* @__PURE__ */
|
|
1496
|
-
if (!description) return /* @__PURE__ */
|
|
1526
|
+
if (error) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1527
|
+
if (!description) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1497
1528
|
const commit = (gesture) => {
|
|
1498
1529
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1499
1530
|
drags.current.add(gesture);
|
|
1500
1531
|
return true;
|
|
1501
1532
|
};
|
|
1502
|
-
return /* @__PURE__ */
|
|
1533
|
+
return /* @__PURE__ */ jsx15(
|
|
1503
1534
|
EffectParameters,
|
|
1504
1535
|
{
|
|
1505
1536
|
description,
|
|
@@ -1521,8 +1552,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1521
1552
|
const state = usePaintEditorState(controller);
|
|
1522
1553
|
const provider = usePaintEffectsProvider(controller);
|
|
1523
1554
|
const [error, attempt] = useAttempt();
|
|
1524
|
-
const [browse, setBrowse] =
|
|
1525
|
-
const [busy, setBusy] =
|
|
1555
|
+
const [browse, setBrowse] = useState10(null);
|
|
1556
|
+
const [busy, setBusy] = useState10(false);
|
|
1526
1557
|
const paper = controller.getPaperEffect();
|
|
1527
1558
|
const activeId = state.document.activeLayerId;
|
|
1528
1559
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1550,28 +1581,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1550
1581
|
};
|
|
1551
1582
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1552
1583
|
const pixel = active?.type === "pixel";
|
|
1553
|
-
return /* @__PURE__ */
|
|
1554
|
-
/* @__PURE__ */
|
|
1555
|
-
/* @__PURE__ */
|
|
1556
|
-
/* @__PURE__ */
|
|
1557
|
-
/* @__PURE__ */
|
|
1558
|
-
/* @__PURE__ */
|
|
1559
|
-
/* @__PURE__ */
|
|
1560
|
-
/* @__PURE__ */
|
|
1584
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1585
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1586
|
+
/* @__PURE__ */ jsx15("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1587
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1588
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1589
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1590
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
|
|
1591
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
|
|
1561
1592
|
] }),
|
|
1562
|
-
!provider && /* @__PURE__ */
|
|
1563
|
-
browse && /* @__PURE__ */
|
|
1564
|
-
paper && /* @__PURE__ */
|
|
1565
|
-
/* @__PURE__ */
|
|
1566
|
-
/* @__PURE__ */
|
|
1593
|
+
!provider && /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1594
|
+
browse && /* @__PURE__ */ jsx15(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1595
|
+
paper && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1596
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1597
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1567
1598
|
"Paper: ",
|
|
1568
1599
|
paper.name ?? paper.effect
|
|
1569
1600
|
] }),
|
|
1570
|
-
/* @__PURE__ */
|
|
1601
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1571
1602
|
] }),
|
|
1572
|
-
/* @__PURE__ */
|
|
1573
|
-
/* @__PURE__ */
|
|
1574
|
-
/* @__PURE__ */
|
|
1603
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1604
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1605
|
+
/* @__PURE__ */ jsx15(
|
|
1575
1606
|
"input",
|
|
1576
1607
|
{
|
|
1577
1608
|
type: "range",
|
|
@@ -1593,39 +1624,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1593
1624
|
`o${paper.opacity}`
|
|
1594
1625
|
)
|
|
1595
1626
|
] }),
|
|
1596
|
-
/* @__PURE__ */
|
|
1597
|
-
/* @__PURE__ */
|
|
1598
|
-
/* @__PURE__ */
|
|
1627
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1628
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1629
|
+
/* @__PURE__ */ jsx15("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
|
|
1599
1630
|
const blend = e.currentTarget.value;
|
|
1600
1631
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1601
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1632
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx15("option", { value: b, children: b }, b)) })
|
|
1602
1633
|
] }),
|
|
1603
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1604
1635
|
] }),
|
|
1605
|
-
effectPaint && /* @__PURE__ */
|
|
1606
|
-
/* @__PURE__ */
|
|
1607
|
-
thumbnail ? /* @__PURE__ */
|
|
1608
|
-
/* @__PURE__ */
|
|
1636
|
+
effectPaint && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1637
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1638
|
+
thumbnail ? /* @__PURE__ */ jsx15("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
1639
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1609
1640
|
"Paint: ",
|
|
1610
1641
|
effectPaint.effect,
|
|
1611
1642
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1612
1643
|
] }),
|
|
1613
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1614
1645
|
] }),
|
|
1615
|
-
/* @__PURE__ */
|
|
1616
|
-
/* @__PURE__ */
|
|
1617
|
-
/* @__PURE__ */
|
|
1646
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1647
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1648
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1618
1649
|
"Along the stroke"
|
|
1619
1650
|
] }),
|
|
1620
|
-
/* @__PURE__ */
|
|
1621
|
-
/* @__PURE__ */
|
|
1651
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1652
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1622
1653
|
"Live"
|
|
1623
1654
|
] })
|
|
1624
1655
|
] }),
|
|
1625
|
-
effectPaint.map && /* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */
|
|
1627
|
-
/* @__PURE__ */
|
|
1628
|
-
/* @__PURE__ */
|
|
1656
|
+
effectPaint.map && /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1657
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1658
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "Length" }),
|
|
1659
|
+
/* @__PURE__ */ jsx15(
|
|
1629
1660
|
"input",
|
|
1630
1661
|
{
|
|
1631
1662
|
type: "number",
|
|
@@ -1639,55 +1670,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1639
1670
|
effectPaint.map.length
|
|
1640
1671
|
)
|
|
1641
1672
|
] }),
|
|
1642
|
-
/* @__PURE__ */
|
|
1643
|
-
/* @__PURE__ */
|
|
1644
|
-
/* @__PURE__ */
|
|
1645
|
-
/* @__PURE__ */
|
|
1673
|
+
/* @__PURE__ */ jsxs14("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
|
|
1674
|
+
/* @__PURE__ */ jsx15("option", { value: "repeat", children: "Repeat" }),
|
|
1675
|
+
/* @__PURE__ */ jsx15("option", { value: "mirror", children: "Mirror" }),
|
|
1676
|
+
/* @__PURE__ */ jsx15("option", { value: "clamp", children: "Clamp" })
|
|
1646
1677
|
] })
|
|
1647
1678
|
] }),
|
|
1648
|
-
/* @__PURE__ */
|
|
1679
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1649
1680
|
] }),
|
|
1650
|
-
animation && /* @__PURE__ */
|
|
1651
|
-
/* @__PURE__ */
|
|
1681
|
+
animation && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1682
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1652
1683
|
"Live paint: ",
|
|
1653
1684
|
animation.strokes,
|
|
1654
1685
|
" ",
|
|
1655
1686
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1656
1687
|
] }),
|
|
1657
|
-
/* @__PURE__ */
|
|
1658
|
-
/* @__PURE__ */
|
|
1659
|
-
/* @__PURE__ */
|
|
1660
|
-
/* @__PURE__ */
|
|
1688
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1689
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1690
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "fps" }),
|
|
1691
|
+
/* @__PURE__ */ jsx15("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
|
|
1661
1692
|
] })
|
|
1662
1693
|
] }),
|
|
1663
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1664
|
-
/* @__PURE__ */
|
|
1665
|
-
/* @__PURE__ */
|
|
1694
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1695
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1696
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1666
1697
|
"Layer: ",
|
|
1667
1698
|
layerEffect.name ?? layerEffect.effect
|
|
1668
1699
|
] }),
|
|
1669
|
-
/* @__PURE__ */
|
|
1700
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1670
1701
|
] }),
|
|
1671
|
-
/* @__PURE__ */
|
|
1702
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1672
1703
|
] }),
|
|
1673
|
-
/* @__PURE__ */
|
|
1704
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1674
1705
|
] });
|
|
1675
1706
|
};
|
|
1676
1707
|
|
|
1677
1708
|
// src/paint-editor/PaintEditor.tsx
|
|
1678
|
-
import { jsx as
|
|
1709
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1679
1710
|
var PAINT_CONTROLS = {
|
|
1680
1711
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1681
1712
|
lighting: '[data-testid="light-panel"]',
|
|
1682
1713
|
symmetry: '[aria-label="Symmetry"]'
|
|
1683
1714
|
};
|
|
1684
1715
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1685
|
-
const [tool, setTool] =
|
|
1686
|
-
const [tab, setTab] =
|
|
1716
|
+
const [tool, setTool] = useState11("brush");
|
|
1717
|
+
const [tab, setTab] = useState11("color");
|
|
1687
1718
|
const tabRef = useRef8(tab);
|
|
1688
1719
|
tabRef.current = tab;
|
|
1689
1720
|
const rootRef = useRef8(null);
|
|
1690
|
-
const [ownPresence] =
|
|
1721
|
+
const [ownPresence] = useState11(() => new PaintPresence2());
|
|
1691
1722
|
const ambientPlayback = useAgentPlayback();
|
|
1692
1723
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1693
1724
|
const viewBox = () => {
|
|
@@ -1743,28 +1774,29 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1743
1774
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1744
1775
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1745
1776
|
};
|
|
1746
|
-
const [error, setError] =
|
|
1777
|
+
const [error, setError] = useState11(null);
|
|
1747
1778
|
const effects = usePaintEffectsProvider(controller);
|
|
1748
1779
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1749
|
-
return /* @__PURE__ */
|
|
1750
|
-
playing && /* @__PURE__ */
|
|
1751
|
-
/* @__PURE__ */
|
|
1752
|
-
/* @__PURE__ */
|
|
1753
|
-
/* @__PURE__ */
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
/* @__PURE__ */
|
|
1756
|
-
error && /* @__PURE__ */
|
|
1780
|
+
return /* @__PURE__ */ jsxs15("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|
|
1781
|
+
playing && /* @__PURE__ */ jsx16(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1782
|
+
/* @__PURE__ */ jsx16(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1783
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1784
|
+
/* @__PURE__ */ jsx16(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1785
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1786
|
+
/* @__PURE__ */ jsx16(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1787
|
+
error && /* @__PURE__ */ jsx16("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1757
1788
|
] }),
|
|
1758
|
-
/* @__PURE__ */
|
|
1759
|
-
/* @__PURE__ */
|
|
1760
|
-
/* @__PURE__ */
|
|
1761
|
-
tab === "color" && /* @__PURE__ */
|
|
1762
|
-
tab === "wet" && /* @__PURE__ */
|
|
1763
|
-
tab === "paper" && /* @__PURE__ */
|
|
1764
|
-
tab === "layers" && /* @__PURE__ */
|
|
1765
|
-
tab === "layers" && /* @__PURE__ */
|
|
1766
|
-
tab === "layers" && /* @__PURE__ */
|
|
1767
|
-
tab === "
|
|
1789
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1790
|
+
/* @__PURE__ */ jsx16("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx16("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
1791
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1792
|
+
tab === "color" && /* @__PURE__ */ jsx16(ColorPanel, { controller }),
|
|
1793
|
+
tab === "wet" && /* @__PURE__ */ jsx16(WetPanel, { controller }),
|
|
1794
|
+
tab === "paper" && /* @__PURE__ */ jsx16(PaperPanel, { controller }),
|
|
1795
|
+
tab === "layers" && /* @__PURE__ */ jsx16(PaintLayersPanel, { controller }),
|
|
1796
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StrokePanel, { controller }),
|
|
1797
|
+
tab === "layers" && /* @__PURE__ */ jsx16(PathStrokePanel, { controller }),
|
|
1798
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StickerPanel, { controller }),
|
|
1799
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx16(PaintEffectsPanel, { controller })
|
|
1768
1800
|
] })
|
|
1769
1801
|
] })
|
|
1770
1802
|
] })
|
|
@@ -1785,6 +1817,7 @@ export {
|
|
|
1785
1817
|
PaintSlider,
|
|
1786
1818
|
PaintToolbar,
|
|
1787
1819
|
PaperPanel,
|
|
1820
|
+
PathStrokePanel,
|
|
1788
1821
|
StickerPanel,
|
|
1789
1822
|
StickerPicker,
|
|
1790
1823
|
StrokePanel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.178.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.262.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.262.0"
|
|
332
332
|
},
|
|
333
333
|
"scripts": {
|
|
334
334
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|