@pixerate/editor-react 0.161.0 → 0.163.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 +351 -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 +196 -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, () => {
|
|
@@ -103,6 +104,10 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
103
104
|
const ctx = water.current?.getContext("2d");
|
|
104
105
|
if (ctx && typeof ctx.createImageData === "function") drawWaterOverlay(controller, ctx);
|
|
105
106
|
}, [state, controller]);
|
|
107
|
+
useEffect2(() => {
|
|
108
|
+
const player = controller.playEffects();
|
|
109
|
+
return () => player.stop();
|
|
110
|
+
}, [controller]);
|
|
106
111
|
useEffect2(() => {
|
|
107
112
|
const el = viewport.current;
|
|
108
113
|
if (!el) return;
|
|
@@ -115,7 +120,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
115
120
|
}, [gesture]);
|
|
116
121
|
const report = () => onError?.(gesture.error);
|
|
117
122
|
const transform = viewCssTransform(state.view, doc, size);
|
|
118
|
-
const lines = showGuides ? guideOverlay(controller) : [];
|
|
123
|
+
const lines = showGuides ? guideOverlay(controller, strokeDrag) : [];
|
|
119
124
|
return /* @__PURE__ */ jsxs(
|
|
120
125
|
"div",
|
|
121
126
|
{
|
|
@@ -125,7 +130,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
125
130
|
"aria-label": "Paint canvas",
|
|
126
131
|
"data-testid": "paint-canvas",
|
|
127
132
|
className: `relative overflow-hidden bg-slate-950 outline-none touch-none select-none ${className ?? ""}`,
|
|
128
|
-
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : "crosshair" },
|
|
133
|
+
style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : tool === "stroke" ? "default" : "crosshair" },
|
|
129
134
|
onPointerDown: (e) => {
|
|
130
135
|
viewport.current?.focus();
|
|
131
136
|
if (gesture.down(e.nativeEvent)) e.target.setPointerCapture?.(e.pointerId);
|
|
@@ -134,14 +139,18 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
134
139
|
onPointerMove: (e) => {
|
|
135
140
|
gesture.move(e.nativeEvent);
|
|
136
141
|
if (gesture.predicted.length || predicted.length) setPredicted(gesture.predicted.map((p) => ({ x: p.x, y: p.y })));
|
|
142
|
+
if (gesture.strokeDrag || strokeDrag) setStrokeDrag(gesture.strokeDrag);
|
|
137
143
|
},
|
|
138
144
|
onPointerUp: (e) => {
|
|
139
145
|
gesture.up(e.nativeEvent);
|
|
140
146
|
setPredicted([]);
|
|
147
|
+
setStrokeDrag(null);
|
|
148
|
+
report();
|
|
141
149
|
},
|
|
142
150
|
onPointerCancel: () => {
|
|
143
151
|
gesture.cancel();
|
|
144
152
|
setPredicted([]);
|
|
153
|
+
setStrokeDrag(null);
|
|
145
154
|
},
|
|
146
155
|
onKeyDown: (e) => {
|
|
147
156
|
if (handlePaintShortcut(controller, gesture, e)) e.preventDefault();
|
|
@@ -176,8 +185,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
176
185
|
y1: l.from.y,
|
|
177
186
|
x2: l.to.x,
|
|
178
187
|
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,
|
|
188
|
+
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
189
|
+
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
181
190
|
strokeWidth: 1 / state.view.zoom,
|
|
182
191
|
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
183
192
|
},
|
|
@@ -1044,6 +1053,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1044
1053
|
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", children: [
|
|
1045
1054
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1046
1055
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1056
|
+
/* @__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
1057
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1048
1058
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1049
1059
|
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
@@ -1091,6 +1101,10 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1091
1101
|
}
|
|
1092
1102
|
) : /* @__PURE__ */ jsxs7("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1093
1103
|
l.type === "group" ? "\u25B8 " : "",
|
|
1104
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs7("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1105
|
+
"\u270E",
|
|
1106
|
+
" "
|
|
1107
|
+
] }),
|
|
1094
1108
|
l.name
|
|
1095
1109
|
] }),
|
|
1096
1110
|
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx8("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
@@ -1241,6 +1255,73 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1241
1255
|
] });
|
|
1242
1256
|
};
|
|
1243
1257
|
|
|
1258
|
+
// src/paint-editor/StrokePanel.tsx
|
|
1259
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath5 } from "@pixerate/editor/paint-editor";
|
|
1260
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1261
|
+
var StrokePanel = ({ controller, className }) => {
|
|
1262
|
+
const state = usePaintEditorState(controller);
|
|
1263
|
+
const [error, attempt] = useAttempt();
|
|
1264
|
+
const layerId = state.document.activeLayerId;
|
|
1265
|
+
const strokes = layerId ? state.document.liveStrokes?.[layerId] : void 0;
|
|
1266
|
+
if (!layerId || !strokes) return null;
|
|
1267
|
+
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1268
|
+
const sel = index >= 0 ? strokes[index] : null;
|
|
1269
|
+
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1270
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1271
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1272
|
+
/* @__PURE__ */ jsxs10("span", { className: "font-medium text-slate-300", children: [
|
|
1273
|
+
"Strokes (",
|
|
1274
|
+
strokes.length,
|
|
1275
|
+
")"
|
|
1276
|
+
] }),
|
|
1277
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1278
|
+
] }),
|
|
1279
|
+
/* @__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(
|
|
1280
|
+
"button",
|
|
1281
|
+
{
|
|
1282
|
+
type: "button",
|
|
1283
|
+
role: "option",
|
|
1284
|
+
"aria-selected": s.id === state.selectedStroke,
|
|
1285
|
+
title: `${i + 1}. ${s.brush.name} (${s.id})`,
|
|
1286
|
+
className: `h-5 w-5 rounded ring-1 ${s.id === state.selectedStroke ? "ring-indigo-400" : "ring-slate-700"}`,
|
|
1287
|
+
style: { background: s.color },
|
|
1288
|
+
onClick: () => controller.selectStroke(s.id)
|
|
1289
|
+
},
|
|
1290
|
+
s.id
|
|
1291
|
+
)) }),
|
|
1292
|
+
sel && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1293
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1294
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Brush" }),
|
|
1295
|
+
/* @__PURE__ */ jsxs10(
|
|
1296
|
+
"select",
|
|
1297
|
+
{
|
|
1298
|
+
"aria-label": "Stroke brush",
|
|
1299
|
+
value: brushes.some((b) => b.id === sel.brush.id) ? sel.brush.id : "",
|
|
1300
|
+
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1301
|
+
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1302
|
+
children: [
|
|
1303
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx11("option", { value: "", children: sel.brush.name }),
|
|
1304
|
+
brushes.map((b) => /* @__PURE__ */ jsx11("option", { value: b.id, children: b.name }, b.id))
|
|
1305
|
+
]
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
] }),
|
|
1309
|
+
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)),
|
|
1310
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between", children: [
|
|
1311
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Colour" }),
|
|
1312
|
+
/* @__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" })
|
|
1313
|
+
] }),
|
|
1314
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1315
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1316
|
+
/* @__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" }),
|
|
1317
|
+
/* @__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" }),
|
|
1318
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1319
|
+
] })
|
|
1320
|
+
] }),
|
|
1321
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1322
|
+
] });
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1244
1325
|
// src/paint-editor/PaintEditor.tsx
|
|
1245
1326
|
import { useRef as useRef7, useState as useState9 } from "react";
|
|
1246
1327
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
@@ -1248,7 +1329,7 @@ import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2,
|
|
|
1248
1329
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1249
1330
|
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
|
|
1250
1331
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1251
|
-
import { jsx as
|
|
1332
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1252
1333
|
function usePaintEffectsProvider(controller) {
|
|
1253
1334
|
const [provider, setProvider] = useState8(controller.effectsProvider);
|
|
1254
1335
|
useEffect4(() => {
|
|
@@ -1267,19 +1348,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1267
1348
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1268
1349
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1269
1350
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1270
|
-
if (!provider) return /* @__PURE__ */
|
|
1351
|
+
if (!provider) return /* @__PURE__ */ jsxs11("p", { className: "text-[11px] text-slate-400", children: [
|
|
1271
1352
|
'No effects provider: "',
|
|
1272
1353
|
name ?? effect,
|
|
1273
1354
|
'" is kept as it was drawn.'
|
|
1274
1355
|
] });
|
|
1275
|
-
if (error) return /* @__PURE__ */
|
|
1276
|
-
if (!description) return /* @__PURE__ */
|
|
1356
|
+
if (error) return /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1357
|
+
if (!description) return /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1277
1358
|
const commit = (gesture) => {
|
|
1278
1359
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1279
1360
|
drags.current.add(gesture);
|
|
1280
1361
|
return true;
|
|
1281
1362
|
};
|
|
1282
|
-
return /* @__PURE__ */
|
|
1363
|
+
return /* @__PURE__ */ jsx12(
|
|
1283
1364
|
EffectParameters,
|
|
1284
1365
|
{
|
|
1285
1366
|
description,
|
|
@@ -1308,6 +1389,12 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1308
1389
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
1309
1390
|
const active = activeId ? controller.getLayer(activeId) : void 0;
|
|
1310
1391
|
const effectPaint = state.effectPaint;
|
|
1392
|
+
const animation = controller.getAnimation();
|
|
1393
|
+
const playback = state.effectPlayback;
|
|
1394
|
+
const repaint = (patch) => {
|
|
1395
|
+
if (!effectPaint) return;
|
|
1396
|
+
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1397
|
+
};
|
|
1311
1398
|
const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1312
1399
|
const run = (work) => attempt(() => {
|
|
1313
1400
|
setBusy(true);
|
|
@@ -1324,28 +1411,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1324
1411
|
};
|
|
1325
1412
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1326
1413
|
const pixel = active?.type === "pixel";
|
|
1327
|
-
return /* @__PURE__ */
|
|
1328
|
-
/* @__PURE__ */
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__PURE__ */
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1414
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1415
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1416
|
+
/* @__PURE__ */ jsx12("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1417
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1418
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1419
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1420
|
+
/* @__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" }),
|
|
1421
|
+
/* @__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
1422
|
] }),
|
|
1336
|
-
!provider && /* @__PURE__ */
|
|
1337
|
-
browse && /* @__PURE__ */
|
|
1338
|
-
paper && /* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */
|
|
1423
|
+
!provider && /* @__PURE__ */ jsx12("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1424
|
+
browse && /* @__PURE__ */ jsx12(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1425
|
+
paper && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1426
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1427
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1341
1428
|
"Paper: ",
|
|
1342
1429
|
paper.name ?? paper.effect
|
|
1343
1430
|
] }),
|
|
1344
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1345
1432
|
] }),
|
|
1346
|
-
/* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1433
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1434
|
+
/* @__PURE__ */ jsx12("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1435
|
+
/* @__PURE__ */ jsx12(
|
|
1349
1436
|
"input",
|
|
1350
1437
|
{
|
|
1351
1438
|
type: "range",
|
|
@@ -1367,43 +1454,89 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1367
1454
|
`o${paper.opacity}`
|
|
1368
1455
|
)
|
|
1369
1456
|
] }),
|
|
1370
|
-
/* @__PURE__ */
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
/* @__PURE__ */
|
|
1457
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1458
|
+
/* @__PURE__ */ jsx12("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1459
|
+
/* @__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
1460
|
const blend = e.currentTarget.value;
|
|
1374
1461
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1375
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1462
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx12("option", { value: b, children: b }, b)) })
|
|
1376
1463
|
] }),
|
|
1377
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1378
1465
|
] }),
|
|
1379
|
-
effectPaint && /* @__PURE__ */
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
thumbnail ? /* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1466
|
+
effectPaint && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1467
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1468
|
+
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,
|
|
1469
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1383
1470
|
"Paint: ",
|
|
1384
1471
|
effectPaint.effect,
|
|
1385
1472
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1386
1473
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1474
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1475
|
+
] }),
|
|
1476
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1477
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1478
|
+
/* @__PURE__ */ jsx12("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1479
|
+
"Along the stroke"
|
|
1480
|
+
] }),
|
|
1481
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1482
|
+
/* @__PURE__ */ jsx12("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1483
|
+
"Live"
|
|
1484
|
+
] })
|
|
1388
1485
|
] }),
|
|
1389
|
-
/* @__PURE__ */
|
|
1486
|
+
effectPaint.map && /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1487
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1488
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Length" }),
|
|
1489
|
+
/* @__PURE__ */ jsx12(
|
|
1490
|
+
"input",
|
|
1491
|
+
{
|
|
1492
|
+
type: "number",
|
|
1493
|
+
"aria-label": "Effect length along the stroke",
|
|
1494
|
+
min: 16,
|
|
1495
|
+
max: 4096,
|
|
1496
|
+
defaultValue: effectPaint.map.length,
|
|
1497
|
+
onBlur: (e) => Number(e.target.value) !== effectPaint.map.length && repaint({ map: { ...effectPaint.map, length: Number(e.target.value) } }),
|
|
1498
|
+
className: "w-16 rounded bg-slate-800 px-1 py-0.5"
|
|
1499
|
+
},
|
|
1500
|
+
effectPaint.map.length
|
|
1501
|
+
)
|
|
1502
|
+
] }),
|
|
1503
|
+
/* @__PURE__ */ jsxs11("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: [
|
|
1504
|
+
/* @__PURE__ */ jsx12("option", { value: "repeat", children: "Repeat" }),
|
|
1505
|
+
/* @__PURE__ */ jsx12("option", { value: "mirror", children: "Mirror" }),
|
|
1506
|
+
/* @__PURE__ */ jsx12("option", { value: "clamp", children: "Clamp" })
|
|
1507
|
+
] })
|
|
1508
|
+
] }),
|
|
1509
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1390
1510
|
] }),
|
|
1391
|
-
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
|
|
1511
|
+
animation && /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1512
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1513
|
+
"Live paint: ",
|
|
1514
|
+
animation.strokes,
|
|
1515
|
+
" ",
|
|
1516
|
+
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1517
|
+
] }),
|
|
1518
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1519
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center gap-1", children: [
|
|
1520
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "fps" }),
|
|
1521
|
+
/* @__PURE__ */ jsx12("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" })
|
|
1522
|
+
] })
|
|
1523
|
+
] }),
|
|
1524
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1525
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
1526
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex-1 truncate", children: [
|
|
1394
1527
|
"Layer: ",
|
|
1395
1528
|
layerEffect.name ?? layerEffect.effect
|
|
1396
1529
|
] }),
|
|
1397
|
-
/* @__PURE__ */
|
|
1530
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1398
1531
|
] }),
|
|
1399
|
-
/* @__PURE__ */
|
|
1532
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1400
1533
|
] }),
|
|
1401
|
-
/* @__PURE__ */
|
|
1534
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1402
1535
|
] });
|
|
1403
1536
|
};
|
|
1404
1537
|
|
|
1405
1538
|
// src/paint-editor/PaintEditor.tsx
|
|
1406
|
-
import { jsx as
|
|
1539
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1407
1540
|
var PAINT_CONTROLS = {
|
|
1408
1541
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1409
1542
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -1474,24 +1607,25 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
1474
1607
|
const [error, setError] = useState9(null);
|
|
1475
1608
|
const effects = usePaintEffectsProvider(controller);
|
|
1476
1609
|
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__ */
|
|
1610
|
+
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: [
|
|
1611
|
+
playing && /* @__PURE__ */ jsx13(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1612
|
+
/* @__PURE__ */ jsx13(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1613
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1614
|
+
/* @__PURE__ */ jsx13(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1615
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1616
|
+
/* @__PURE__ */ jsx13(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
1617
|
+
error && /* @__PURE__ */ jsx13("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1485
1618
|
] }),
|
|
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 === "
|
|
1619
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1620
|
+
/* @__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)) }),
|
|
1621
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1622
|
+
tab === "color" && /* @__PURE__ */ jsx13(ColorPanel, { controller }),
|
|
1623
|
+
tab === "wet" && /* @__PURE__ */ jsx13(WetPanel, { controller }),
|
|
1624
|
+
tab === "paper" && /* @__PURE__ */ jsx13(PaperPanel, { controller }),
|
|
1625
|
+
tab === "layers" && /* @__PURE__ */ jsx13(PaintLayersPanel, { controller }),
|
|
1626
|
+
tab === "layers" && /* @__PURE__ */ jsx13(StrokePanel, { controller }),
|
|
1627
|
+
tab === "layers" && /* @__PURE__ */ jsx13(StickerPanel, { controller }),
|
|
1628
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx13(PaintEffectsPanel, { controller })
|
|
1495
1629
|
] })
|
|
1496
1630
|
] })
|
|
1497
1631
|
] })
|
|
@@ -1510,6 +1644,7 @@ export {
|
|
|
1510
1644
|
PaintToolbar,
|
|
1511
1645
|
PaperPanel,
|
|
1512
1646
|
StickerPanel,
|
|
1647
|
+
StrokePanel,
|
|
1513
1648
|
WetPanel,
|
|
1514
1649
|
usePaintDirector,
|
|
1515
1650
|
usePaintEditor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.163.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.241.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.241.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|