@pixerate/editor-react 0.160.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/StickerPanel.d.cts +3 -3
- package/dist/paint-editor/StickerPanel.d.ts +3 -3
- package/dist/paint-editor/StrokePanel.d.cts +12 -0
- package/dist/paint-editor/StrokePanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +399 -303
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +167 -72
- 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" : "#f472b6",
|
|
180
|
-
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" ? 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
|
|
@@ -1187,13 +1197,13 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1187
1197
|
};
|
|
1188
1198
|
|
|
1189
1199
|
// src/paint-editor/StickerPanel.tsx
|
|
1190
|
-
import { useState as useState8 } from "react";
|
|
1191
1200
|
import { STAMP_KINDS as STAMP_KINDS2, STAMP_LABELS as STAMP_LABELS2, STICKER_SLIDERS, readPath as readPath4 } from "@pixerate/editor/paint-editor";
|
|
1192
1201
|
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1193
1202
|
var StickerPanel = ({ controller, className }) => {
|
|
1194
1203
|
const state = usePaintEditorState(controller);
|
|
1195
1204
|
const [error, attempt] = useAttempt();
|
|
1196
|
-
const
|
|
1205
|
+
const picked = state.selectedSticker;
|
|
1206
|
+
const setPicked = (id) => controller.selectSticker(id);
|
|
1197
1207
|
const layerId = state.document.activeLayerId;
|
|
1198
1208
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1199
1209
|
if (!stickers.length) return null;
|
|
@@ -1210,6 +1220,22 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1210
1220
|
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Stamp" }),
|
|
1211
1221
|
/* @__PURE__ */ jsx10("select", { "aria-label": "Sticker stamp", value: sel.stamp, onChange: (e) => attempt(() => controller.updateSticker(layerId, sel.id, { stamp: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: STAMP_KINDS2.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: STAMP_LABELS2[k] }, k)) })
|
|
1212
1222
|
] }),
|
|
1223
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1224
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Position" }),
|
|
1225
|
+
/* @__PURE__ */ jsx10("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx10(
|
|
1226
|
+
"input",
|
|
1227
|
+
{
|
|
1228
|
+
type: "number",
|
|
1229
|
+
"aria-label": `Sticker ${k}`,
|
|
1230
|
+
defaultValue: sel[k],
|
|
1231
|
+
step: 1,
|
|
1232
|
+
onBlur: (e) => Number(e.target.value) !== sel[k] && attempt(() => controller.updateSticker(layerId, sel.id, { [k]: Number(e.target.value) })),
|
|
1233
|
+
onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
|
|
1234
|
+
className: "w-16 rounded bg-slate-800 px-1 py-0.5"
|
|
1235
|
+
},
|
|
1236
|
+
`${sel.id}-${k}-${sel[k]}`
|
|
1237
|
+
)) })
|
|
1238
|
+
] }),
|
|
1213
1239
|
STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx10(PaintSlider, { control: c, value: readPath4(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1214
1240
|
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between", children: [
|
|
1215
1241
|
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Colour" }),
|
|
@@ -1225,16 +1251,83 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1225
1251
|
] });
|
|
1226
1252
|
};
|
|
1227
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
|
+
|
|
1228
1321
|
// src/paint-editor/PaintEditor.tsx
|
|
1229
|
-
import { useRef as useRef7, useState as
|
|
1322
|
+
import { useRef as useRef7, useState as useState9 } from "react";
|
|
1230
1323
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1231
1324
|
|
|
1232
1325
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1233
|
-
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as
|
|
1326
|
+
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
|
|
1234
1327
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1235
|
-
import { jsx as
|
|
1328
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1236
1329
|
function usePaintEffectsProvider(controller) {
|
|
1237
|
-
const [provider, setProvider] =
|
|
1330
|
+
const [provider, setProvider] = useState8(controller.effectsProvider);
|
|
1238
1331
|
useEffect4(() => {
|
|
1239
1332
|
setProvider(controller.effectsProvider);
|
|
1240
1333
|
return controller.effects.subscribe(setProvider);
|
|
@@ -1251,19 +1344,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1251
1344
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1252
1345
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1253
1346
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1254
|
-
if (!provider) return /* @__PURE__ */
|
|
1347
|
+
if (!provider) return /* @__PURE__ */ jsxs11("p", { className: "text-[11px] text-slate-400", children: [
|
|
1255
1348
|
'No effects provider: "',
|
|
1256
1349
|
name ?? effect,
|
|
1257
1350
|
'" is kept as it was drawn.'
|
|
1258
1351
|
] });
|
|
1259
|
-
if (error) return /* @__PURE__ */
|
|
1260
|
-
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" });
|
|
1261
1354
|
const commit = (gesture) => {
|
|
1262
1355
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1263
1356
|
drags.current.add(gesture);
|
|
1264
1357
|
return true;
|
|
1265
1358
|
};
|
|
1266
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ jsx12(
|
|
1267
1360
|
EffectParameters,
|
|
1268
1361
|
{
|
|
1269
1362
|
description,
|
|
@@ -1285,8 +1378,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1285
1378
|
const state = usePaintEditorState(controller);
|
|
1286
1379
|
const provider = usePaintEffectsProvider(controller);
|
|
1287
1380
|
const [error, attempt] = useAttempt();
|
|
1288
|
-
const [browse, setBrowse] =
|
|
1289
|
-
const [busy, setBusy] =
|
|
1381
|
+
const [browse, setBrowse] = useState8(null);
|
|
1382
|
+
const [busy, setBusy] = useState8(false);
|
|
1290
1383
|
const paper = controller.getPaperEffect();
|
|
1291
1384
|
const activeId = state.document.activeLayerId;
|
|
1292
1385
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1308,28 +1401,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1308
1401
|
};
|
|
1309
1402
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1310
1403
|
const pixel = active?.type === "pixel";
|
|
1311
|
-
return /* @__PURE__ */
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1315
|
-
/* @__PURE__ */
|
|
1316
|
-
/* @__PURE__ */
|
|
1317
|
-
/* @__PURE__ */
|
|
1318
|
-
/* @__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" })
|
|
1319
1412
|
] }),
|
|
1320
|
-
!provider && /* @__PURE__ */
|
|
1321
|
-
browse && /* @__PURE__ */
|
|
1322
|
-
paper && /* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1324
|
-
/* @__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: [
|
|
1325
1418
|
"Paper: ",
|
|
1326
1419
|
paper.name ?? paper.effect
|
|
1327
1420
|
] }),
|
|
1328
|
-
/* @__PURE__ */
|
|
1421
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1329
1422
|
] }),
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__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(
|
|
1333
1426
|
"input",
|
|
1334
1427
|
{
|
|
1335
1428
|
type: "range",
|
|
@@ -1351,55 +1444,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1351
1444
|
`o${paper.opacity}`
|
|
1352
1445
|
)
|
|
1353
1446
|
] }),
|
|
1354
|
-
/* @__PURE__ */
|
|
1355
|
-
/* @__PURE__ */
|
|
1356
|
-
/* @__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) => {
|
|
1357
1450
|
const blend = e.currentTarget.value;
|
|
1358
1451
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1359
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1452
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx12("option", { value: b, children: b }, b)) })
|
|
1360
1453
|
] }),
|
|
1361
|
-
/* @__PURE__ */
|
|
1454
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1362
1455
|
] }),
|
|
1363
|
-
effectPaint && /* @__PURE__ */
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
thumbnail ? /* @__PURE__ */
|
|
1366
|
-
/* @__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: [
|
|
1367
1460
|
"Paint: ",
|
|
1368
1461
|
effectPaint.effect,
|
|
1369
1462
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1370
1463
|
] }),
|
|
1371
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1372
1465
|
] }),
|
|
1373
|
-
/* @__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 })) })
|
|
1374
1467
|
] }),
|
|
1375
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
/* @__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: [
|
|
1378
1471
|
"Layer: ",
|
|
1379
1472
|
layerEffect.name ?? layerEffect.effect
|
|
1380
1473
|
] }),
|
|
1381
|
-
/* @__PURE__ */
|
|
1474
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1382
1475
|
] }),
|
|
1383
|
-
/* @__PURE__ */
|
|
1476
|
+
/* @__PURE__ */ jsx12(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1384
1477
|
] }),
|
|
1385
|
-
/* @__PURE__ */
|
|
1478
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1386
1479
|
] });
|
|
1387
1480
|
};
|
|
1388
1481
|
|
|
1389
1482
|
// src/paint-editor/PaintEditor.tsx
|
|
1390
|
-
import { jsx as
|
|
1483
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1391
1484
|
var PAINT_CONTROLS = {
|
|
1392
1485
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1393
1486
|
lighting: '[data-testid="light-panel"]',
|
|
1394
1487
|
symmetry: '[aria-label="Symmetry"]'
|
|
1395
1488
|
};
|
|
1396
1489
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1397
|
-
const [tool, setTool] =
|
|
1398
|
-
const [tab, setTab] =
|
|
1490
|
+
const [tool, setTool] = useState9("brush");
|
|
1491
|
+
const [tab, setTab] = useState9("color");
|
|
1399
1492
|
const tabRef = useRef7(tab);
|
|
1400
1493
|
tabRef.current = tab;
|
|
1401
1494
|
const rootRef = useRef7(null);
|
|
1402
|
-
const [ownPresence] =
|
|
1495
|
+
const [ownPresence] = useState9(() => new PaintPresence2());
|
|
1403
1496
|
const ambientPlayback = useAgentPlayback();
|
|
1404
1497
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1405
1498
|
const viewBox = () => {
|
|
@@ -1455,27 +1548,28 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
1455
1548
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1456
1549
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1457
1550
|
};
|
|
1458
|
-
const [error, setError] =
|
|
1551
|
+
const [error, setError] = useState9(null);
|
|
1459
1552
|
const effects = usePaintEffectsProvider(controller);
|
|
1460
1553
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1461
|
-
return /* @__PURE__ */
|
|
1462
|
-
playing && /* @__PURE__ */
|
|
1463
|
-
/* @__PURE__ */
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
1466
|
-
/* @__PURE__ */
|
|
1467
|
-
/* @__PURE__ */
|
|
1468
|
-
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 })
|
|
1469
1562
|
] }),
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
/* @__PURE__ */
|
|
1472
|
-
/* @__PURE__ */
|
|
1473
|
-
tab === "color" && /* @__PURE__ */
|
|
1474
|
-
tab === "wet" && /* @__PURE__ */
|
|
1475
|
-
tab === "paper" && /* @__PURE__ */
|
|
1476
|
-
tab === "layers" && /* @__PURE__ */
|
|
1477
|
-
tab === "layers" && /* @__PURE__ */
|
|
1478
|
-
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 })
|
|
1479
1573
|
] })
|
|
1480
1574
|
] })
|
|
1481
1575
|
] })
|
|
@@ -1494,6 +1588,7 @@ export {
|
|
|
1494
1588
|
PaintToolbar,
|
|
1495
1589
|
PaperPanel,
|
|
1496
1590
|
StickerPanel,
|
|
1591
|
+
StrokePanel,
|
|
1497
1592
|
WetPanel,
|
|
1498
1593
|
usePaintDirector,
|
|
1499
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",
|