@pixerate/editor-react 0.161.0 → 0.162.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/StrokePanel.d.cts +12 -0
- package/dist/paint-editor/StrokePanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +295 -215
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +140 -61
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ export * from './ColorPanel.cjs';
|
|
|
7
7
|
export * from './PaintLayersPanel.cjs';
|
|
8
8
|
export * from './WetPanel.cjs';
|
|
9
9
|
export * from './StickerPanel.cjs';
|
|
10
|
+
export * from './StrokePanel.cjs';
|
|
10
11
|
export * from './PaintEditor.cjs';
|
|
11
12
|
export { PaintSlider } from './shared.cjs';
|
|
12
13
|
export * from './PaintGradientEditor.cjs';
|
|
@@ -7,6 +7,7 @@ export * from './ColorPanel.js';
|
|
|
7
7
|
export * from './PaintLayersPanel.js';
|
|
8
8
|
export * from './WetPanel.js';
|
|
9
9
|
export * from './StickerPanel.js';
|
|
10
|
+
export * from './StrokePanel.js';
|
|
10
11
|
export * from './PaintEditor.js';
|
|
11
12
|
export { PaintSlider } from './shared.js';
|
|
12
13
|
export * from './PaintGradientEditor.js';
|
|
@@ -62,6 +62,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
62
62
|
const [size, setSize] = useState2({ width: 800, height: 600 });
|
|
63
63
|
const measured = useRef(false);
|
|
64
64
|
const [predicted, setPredicted] = useState2([]);
|
|
65
|
+
const [strokeDrag, setStrokeDrag] = useState2(null);
|
|
65
66
|
const presenter = useMemo2(() => new PaintCanvasPresenter(controller), [controller]);
|
|
66
67
|
const gesture = useMemo2(
|
|
67
68
|
() => new PaintGesture(controller, () => {
|
|
@@ -115,7 +116,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
115
116
|
}, [gesture]);
|
|
116
117
|
const report = () => onError?.(gesture.error);
|
|
117
118
|
const transform = viewCssTransform(state.view, doc, size);
|
|
118
|
-
const lines = showGuides ? guideOverlay(controller) : [];
|
|
119
|
+
const lines = showGuides ? guideOverlay(controller, strokeDrag) : [];
|
|
119
120
|
return /* @__PURE__ */ jsxs(
|
|
120
121
|
"div",
|
|
121
122
|
{
|
|
@@ -125,7 +126,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
125
126
|
"aria-label": "Paint canvas",
|
|
126
127
|
"data-testid": "paint-canvas",
|
|
127
128
|
className: `relative overflow-hidden bg-slate-950 outline-none touch-none select-none ${className ?? ""}`,
|
|
128
|
-
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : "crosshair" },
|
|
129
|
+
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : tool === "stroke" ? "default" : "crosshair" },
|
|
129
130
|
onPointerDown: (e) => {
|
|
130
131
|
viewport.current?.focus();
|
|
131
132
|
if (gesture.down(e.nativeEvent)) e.target.setPointerCapture?.(e.pointerId);
|
|
@@ -134,14 +135,18 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
134
135
|
onPointerMove: (e) => {
|
|
135
136
|
gesture.move(e.nativeEvent);
|
|
136
137
|
if (gesture.predicted.length || predicted.length) setPredicted(gesture.predicted.map((p) => ({ x: p.x, y: p.y })));
|
|
138
|
+
if (gesture.strokeDrag || strokeDrag) setStrokeDrag(gesture.strokeDrag);
|
|
137
139
|
},
|
|
138
140
|
onPointerUp: (e) => {
|
|
139
141
|
gesture.up(e.nativeEvent);
|
|
140
142
|
setPredicted([]);
|
|
143
|
+
setStrokeDrag(null);
|
|
144
|
+
report();
|
|
141
145
|
},
|
|
142
146
|
onPointerCancel: () => {
|
|
143
147
|
gesture.cancel();
|
|
144
148
|
setPredicted([]);
|
|
149
|
+
setStrokeDrag(null);
|
|
145
150
|
},
|
|
146
151
|
onKeyDown: (e) => {
|
|
147
152
|
if (handlePaintShortcut(controller, gesture, e)) e.preventDefault();
|
|
@@ -176,8 +181,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
176
181
|
y1: l.from.y,
|
|
177
182
|
x2: l.to.x,
|
|
178
183
|
y2: l.to.y,
|
|
179
|
-
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
180
|
-
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
184
|
+
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
185
|
+
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
181
186
|
strokeWidth: 1 / state.view.zoom,
|
|
182
187
|
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
183
188
|
},
|
|
@@ -1044,6 +1049,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1044
1049
|
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", children: [
|
|
1045
1050
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1046
1051
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1052
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1047
1053
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1048
1054
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1049
1055
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
@@ -1091,6 +1097,10 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1091
1097
|
}
|
|
1092
1098
|
) : /* @__PURE__ */ jsxs7("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1093
1099
|
l.type === "group" ? "\u25B8 " : "",
|
|
1100
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs7("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1101
|
+
"\u270E",
|
|
1102
|
+
" "
|
|
1103
|
+
] }),
|
|
1094
1104
|
l.name
|
|
1095
1105
|
] }),
|
|
1096
1106
|
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx8("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
@@ -1241,6 +1251,73 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1241
1251
|
] });
|
|
1242
1252
|
};
|
|
1243
1253
|
|
|
1254
|
+
// src/paint-editor/StrokePanel.tsx
|
|
1255
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath5 } from "@pixerate/editor/paint-editor";
|
|
1256
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1257
|
+
var StrokePanel = ({ controller, className }) => {
|
|
1258
|
+
const state = usePaintEditorState(controller);
|
|
1259
|
+
const [error, attempt] = useAttempt();
|
|
1260
|
+
const layerId = state.document.activeLayerId;
|
|
1261
|
+
const strokes = layerId ? state.document.liveStrokes?.[layerId] : void 0;
|
|
1262
|
+
if (!layerId || !strokes) return null;
|
|
1263
|
+
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1264
|
+
const sel = index >= 0 ? strokes[index] : null;
|
|
1265
|
+
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1266
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1267
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1268
|
+
/* @__PURE__ */ jsxs10("span", { className: "font-medium text-slate-300", children: [
|
|
1269
|
+
"Strokes (",
|
|
1270
|
+
strokes.length,
|
|
1271
|
+
")"
|
|
1272
|
+
] }),
|
|
1273
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1274
|
+
] }),
|
|
1275
|
+
/* @__PURE__ */ jsx11("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ jsx11(
|
|
1276
|
+
"button",
|
|
1277
|
+
{
|
|
1278
|
+
type: "button",
|
|
1279
|
+
role: "option",
|
|
1280
|
+
"aria-selected": s.id === state.selectedStroke,
|
|
1281
|
+
title: `${i + 1}. ${s.brush.name} (${s.id})`,
|
|
1282
|
+
className: `h-5 w-5 rounded ring-1 ${s.id === state.selectedStroke ? "ring-indigo-400" : "ring-slate-700"}`,
|
|
1283
|
+
style: { background: s.color },
|
|
1284
|
+
onClick: () => controller.selectStroke(s.id)
|
|
1285
|
+
},
|
|
1286
|
+
s.id
|
|
1287
|
+
)) }),
|
|
1288
|
+
sel && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1289
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1290
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Brush" }),
|
|
1291
|
+
/* @__PURE__ */ jsxs10(
|
|
1292
|
+
"select",
|
|
1293
|
+
{
|
|
1294
|
+
"aria-label": "Stroke brush",
|
|
1295
|
+
value: brushes.some((b) => b.id === sel.brush.id) ? sel.brush.id : "",
|
|
1296
|
+
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1297
|
+
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1298
|
+
children: [
|
|
1299
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx11("option", { value: "", children: sel.brush.name }),
|
|
1300
|
+
brushes.map((b) => /* @__PURE__ */ jsx11("option", { value: b.id, children: b.name }, b.id))
|
|
1301
|
+
]
|
|
1302
|
+
}
|
|
1303
|
+
)
|
|
1304
|
+
] }),
|
|
1305
|
+
STROKE_SLIDERS.map((c) => /* @__PURE__ */ jsx11(PaintSlider, { control: c, value: readPath5(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1306
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between", children: [
|
|
1307
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Colour" }),
|
|
1308
|
+
/* @__PURE__ */ jsx11(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1309
|
+
] }),
|
|
1310
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1311
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1312
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: index === strokes.length - 1, "aria-label": "Move stroke up", onClick: () => attempt(() => controller.reorderStroke(sel.id, index + 1)), children: "\u2191" }),
|
|
1313
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1314
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1315
|
+
] })
|
|
1316
|
+
] }),
|
|
1317
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1318
|
+
] });
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1244
1321
|
// src/paint-editor/PaintEditor.tsx
|
|
1245
1322
|
import { useRef as useRef7, useState as useState9 } from "react";
|
|
1246
1323
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
@@ -1248,7 +1325,7 @@ import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2,
|
|
|
1248
1325
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1249
1326
|
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
|
|
1250
1327
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1251
|
-
import { jsx as
|
|
1328
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1252
1329
|
function usePaintEffectsProvider(controller) {
|
|
1253
1330
|
const [provider, setProvider] = useState8(controller.effectsProvider);
|
|
1254
1331
|
useEffect4(() => {
|
|
@@ -1267,19 +1344,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1267
1344
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1268
1345
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1269
1346
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1270
|
-
if (!provider) return /* @__PURE__ */
|
|
1347
|
+
if (!provider) return /* @__PURE__ */ jsxs11("p", { className: "text-[11px] text-slate-400", children: [
|
|
1271
1348
|
'No effects provider: "',
|
|
1272
1349
|
name ?? effect,
|
|
1273
1350
|
'" is kept as it was drawn.'
|
|
1274
1351
|
] });
|
|
1275
|
-
if (error) return /* @__PURE__ */
|
|
1276
|
-
if (!description) return /* @__PURE__ */
|
|
1352
|
+
if (error) return /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1353
|
+
if (!description) return /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1277
1354
|
const commit = (gesture) => {
|
|
1278
1355
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1279
1356
|
drags.current.add(gesture);
|
|
1280
1357
|
return true;
|
|
1281
1358
|
};
|
|
1282
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ jsx12(
|
|
1283
1360
|
EffectParameters,
|
|
1284
1361
|
{
|
|
1285
1362
|
description,
|
|
@@ -1324,28 +1401,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1324
1401
|
};
|
|
1325
1402
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1326
1403
|
const pixel = active?.type === "pixel";
|
|
1327
|
-
return /* @__PURE__ */
|
|
1328
|
-
/* @__PURE__ */
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__PURE__ */
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1404
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1405
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1406
|
+
/* @__PURE__ */ jsx12("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1407
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1408
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1409
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1410
|
+
/* @__PURE__ */ jsx12("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" }),
|
|
1411
|
+
/* @__PURE__ */ jsx12("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" })
|
|
1335
1412
|
] }),
|
|
1336
|
-
!provider && /* @__PURE__ */
|
|
1337
|
-
browse && /* @__PURE__ */
|
|
1338
|
-
paper && /* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */
|
|
1413
|
+
!provider && /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1414
|
+
browse && /* @__PURE__ */ jsx12(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1415
|
+
paper && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1416
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1417
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1341
1418
|
"Paper: ",
|
|
1342
1419
|
paper.name ?? paper.effect
|
|
1343
1420
|
] }),
|
|
1344
|
-
/* @__PURE__ */
|
|
1421
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1345
1422
|
] }),
|
|
1346
|
-
/* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1423
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1424
|
+
/* @__PURE__ */ jsx12("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1425
|
+
/* @__PURE__ */ jsx12(
|
|
1349
1426
|
"input",
|
|
1350
1427
|
{
|
|
1351
1428
|
type: "range",
|
|
@@ -1367,43 +1444,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1367
1444
|
`o${paper.opacity}`
|
|
1368
1445
|
)
|
|
1369
1446
|
] }),
|
|
1370
|
-
/* @__PURE__ */
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
/* @__PURE__ */
|
|
1447
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1448
|
+
/* @__PURE__ */ jsx12("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1449
|
+
/* @__PURE__ */ jsx12("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) => {
|
|
1373
1450
|
const blend = e.currentTarget.value;
|
|
1374
1451
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1375
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1452
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx12("option", { value: b, children: b }, b)) })
|
|
1376
1453
|
] }),
|
|
1377
|
-
/* @__PURE__ */
|
|
1454
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1378
1455
|
] }),
|
|
1379
|
-
effectPaint && /* @__PURE__ */
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
thumbnail ? /* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1456
|
+
effectPaint && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1457
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1458
|
+
thumbnail ? /* @__PURE__ */ jsx12("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
1459
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1383
1460
|
"Paint: ",
|
|
1384
1461
|
effectPaint.effect,
|
|
1385
1462
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1386
1463
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1388
1465
|
] }),
|
|
1389
|
-
/* @__PURE__ */
|
|
1466
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
|
|
1390
1467
|
] }),
|
|
1391
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
/* @__PURE__ */
|
|
1468
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1469
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1470
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1394
1471
|
"Layer: ",
|
|
1395
1472
|
layerEffect.name ?? layerEffect.effect
|
|
1396
1473
|
] }),
|
|
1397
|
-
/* @__PURE__ */
|
|
1474
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1398
1475
|
] }),
|
|
1399
|
-
/* @__PURE__ */
|
|
1476
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1400
1477
|
] }),
|
|
1401
|
-
/* @__PURE__ */
|
|
1478
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1402
1479
|
] });
|
|
1403
1480
|
};
|
|
1404
1481
|
|
|
1405
1482
|
// src/paint-editor/PaintEditor.tsx
|
|
1406
|
-
import { jsx as
|
|
1483
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1407
1484
|
var PAINT_CONTROLS = {
|
|
1408
1485
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1409
1486
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -1474,24 +1551,25 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
1474
1551
|
const [error, setError] = useState9(null);
|
|
1475
1552
|
const effects = usePaintEffectsProvider(controller);
|
|
1476
1553
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1477
|
-
return /* @__PURE__ */
|
|
1478
|
-
playing && /* @__PURE__ */
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
/* @__PURE__ */
|
|
1481
|
-
/* @__PURE__ */
|
|
1482
|
-
/* @__PURE__ */
|
|
1483
|
-
/* @__PURE__ */
|
|
1484
|
-
error && /* @__PURE__ */
|
|
1554
|
+
return /* @__PURE__ */ jsxs12("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: [
|
|
1555
|
+
playing && /* @__PURE__ */ jsx13(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1556
|
+
/* @__PURE__ */ jsx13(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1557
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1558
|
+
/* @__PURE__ */ jsx13(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1559
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1560
|
+
/* @__PURE__ */ jsx13(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
1561
|
+
error && /* @__PURE__ */ jsx13("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1485
1562
|
] }),
|
|
1486
|
-
/* @__PURE__ */
|
|
1487
|
-
/* @__PURE__ */
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
tab === "color" && /* @__PURE__ */
|
|
1490
|
-
tab === "wet" && /* @__PURE__ */
|
|
1491
|
-
tab === "paper" && /* @__PURE__ */
|
|
1492
|
-
tab === "layers" && /* @__PURE__ */
|
|
1493
|
-
tab === "layers" && /* @__PURE__ */
|
|
1494
|
-
tab === "
|
|
1563
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1564
|
+
/* @__PURE__ */ jsx13("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx13("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)) }),
|
|
1565
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1566
|
+
tab === "color" && /* @__PURE__ */ jsx13(ColorPanel, { controller }),
|
|
1567
|
+
tab === "wet" && /* @__PURE__ */ jsx13(WetPanel, { controller }),
|
|
1568
|
+
tab === "paper" && /* @__PURE__ */ jsx13(PaperPanel, { controller }),
|
|
1569
|
+
tab === "layers" && /* @__PURE__ */ jsx13(PaintLayersPanel, { controller }),
|
|
1570
|
+
tab === "layers" && /* @__PURE__ */ jsx13(StrokePanel, { controller }),
|
|
1571
|
+
tab === "layers" && /* @__PURE__ */ jsx13(StickerPanel, { controller }),
|
|
1572
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx13(PaintEffectsPanel, { controller })
|
|
1495
1573
|
] })
|
|
1496
1574
|
] })
|
|
1497
1575
|
] })
|
|
@@ -1510,6 +1588,7 @@ export {
|
|
|
1510
1588
|
PaintToolbar,
|
|
1511
1589
|
PaperPanel,
|
|
1512
1590
|
StickerPanel,
|
|
1591
|
+
StrokePanel,
|
|
1513
1592
|
WetPanel,
|
|
1514
1593
|
usePaintDirector,
|
|
1515
1594
|
usePaintEditor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.162.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.240.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.240.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|