@pixerate/editor-react 0.175.0 → 0.176.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/PaintCanvas.d.cts +3 -1
- package/dist/paint-editor/PaintCanvas.d.ts +3 -1
- package/dist/paint-editor/PaintEditor.d.cts +3 -1
- package/dist/paint-editor/PaintEditor.d.ts +3 -1
- package/dist/paint-editor/index.cjs +8 -3
- package/dist/paint-editor/index.js +9 -3
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
3
3
|
export interface PaintCanvasProps {
|
|
4
4
|
controller: PaintEditorController;
|
|
5
5
|
/** The active tool (default brush). */
|
|
@@ -14,6 +14,8 @@ export interface PaintCanvasProps {
|
|
|
14
14
|
presence?: PaintPresence;
|
|
15
15
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
|
|
16
16
|
proposals?: PaintProposals;
|
|
17
|
+
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
18
|
+
agentStrokes?: PaintAgentStrokes;
|
|
17
19
|
className?: string;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
3
3
|
export interface PaintCanvasProps {
|
|
4
4
|
controller: PaintEditorController;
|
|
5
5
|
/** The active tool (default brush). */
|
|
@@ -14,6 +14,8 @@ export interface PaintCanvasProps {
|
|
|
14
14
|
presence?: PaintPresence;
|
|
15
15
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
|
|
16
16
|
proposals?: PaintProposals;
|
|
17
|
+
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
18
|
+
agentStrokes?: PaintAgentStrokes;
|
|
17
19
|
className?: string;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PaintPresence, type PaintEditorController, type PaintProposals } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { PaintPresence, type PaintEditorController, type PaintProposals, type PaintAgentStrokes } from '@pixerate/editor/paint-editor';
|
|
3
3
|
import type { AgentPlayback } from '@pixerate/editor/tools';
|
|
4
4
|
export interface PaintEditorProps {
|
|
5
5
|
controller: PaintEditorController;
|
|
@@ -11,6 +11,8 @@ export interface PaintEditorProps {
|
|
|
11
11
|
presence?: PaintPresence;
|
|
12
12
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
|
|
13
13
|
proposals?: PaintProposals;
|
|
14
|
+
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
15
|
+
agentStrokes?: PaintAgentStrokes;
|
|
14
16
|
className?: string;
|
|
15
17
|
/**
|
|
16
18
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PaintPresence, type PaintEditorController, type PaintProposals } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { PaintPresence, type PaintEditorController, type PaintProposals, type PaintAgentStrokes } from '@pixerate/editor/paint-editor';
|
|
3
3
|
import type { AgentPlayback } from '@pixerate/editor/tools';
|
|
4
4
|
export interface PaintEditorProps {
|
|
5
5
|
controller: PaintEditorController;
|
|
@@ -11,6 +11,8 @@ export interface PaintEditorProps {
|
|
|
11
11
|
presence?: PaintPresence;
|
|
12
12
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `usePaintProposals`). */
|
|
13
13
|
proposals?: PaintProposals;
|
|
14
|
+
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
15
|
+
agentStrokes?: PaintAgentStrokes;
|
|
14
16
|
className?: string;
|
|
15
17
|
/**
|
|
16
18
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
|
|
@@ -109,7 +109,7 @@ function usePaintChangeFeed(controller, options = {}) {
|
|
|
109
109
|
var import_react2 = require("react");
|
|
110
110
|
var import_paint_editor2 = require("@pixerate/editor/paint-editor");
|
|
111
111
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
112
|
-
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, className }) => {
|
|
112
|
+
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
113
113
|
const state = usePaintEditorState(controller);
|
|
114
114
|
const viewport = (0, import_react2.useRef)(null);
|
|
115
115
|
const canvas = (0, import_react2.useRef)(null);
|
|
@@ -247,6 +247,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
247
247
|
},
|
|
248
248
|
i
|
|
249
249
|
)),
|
|
250
|
+
agentStrokes && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaintAgentStrokeLines, { strokes: agentStrokes }),
|
|
250
251
|
predicted.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
|
|
251
252
|
] }),
|
|
252
253
|
state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReferencePanel, { controller, id: r.id }, r.id)),
|
|
@@ -353,6 +354,10 @@ var PaintProposalGhost = ({ proposal, transform, zoom }) => {
|
|
|
353
354
|
}
|
|
354
355
|
);
|
|
355
356
|
};
|
|
357
|
+
var PaintAgentStrokeLines = ({ strokes }) => {
|
|
358
|
+
const { strokes: list } = (0, import_react2.useSyncExternalStore)(strokes.subscribe, strokes.getState, strokes.getState);
|
|
359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: list.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { "data-agent-stroke": s.id, points: (0, import_paint_editor2.paintAgentStrokePoints)(s), fill: "none", stroke: s.color, strokeOpacity: s.opacity ?? 0.6, strokeWidth: s.size, strokeLinecap: "round", strokeLinejoin: "round" }, s.id)) });
|
|
360
|
+
};
|
|
356
361
|
|
|
357
362
|
// src/paint-editor/PaintToolbar.tsx
|
|
358
363
|
var import_react4 = require("react");
|
|
@@ -3996,7 +4001,7 @@ var PAINT_CONTROLS = {
|
|
|
3996
4001
|
lighting: '[data-testid="light-panel"]',
|
|
3997
4002
|
symmetry: '[aria-label="Symmetry"]'
|
|
3998
4003
|
};
|
|
3999
|
-
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4004
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4000
4005
|
const [tool, setTool] = (0, import_react29.useState)("brush");
|
|
4001
4006
|
const [tab, setTab] = (0, import_react29.useState)("color");
|
|
4002
4007
|
const tabRef = (0, import_react29.useRef)(tab);
|
|
@@ -4067,7 +4072,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, cl
|
|
|
4067
4072
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
4068
4073
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
4069
4074
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4070
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, className: "flex-1 rounded-lg" }),
|
|
4075
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
4071
4076
|
error && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
4072
4077
|
] }),
|
|
4073
4078
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
@@ -87,10 +87,11 @@ import {
|
|
|
87
87
|
guideOverlay,
|
|
88
88
|
handlePaintShortcut,
|
|
89
89
|
viewCssTransform,
|
|
90
|
+
paintAgentStrokePoints,
|
|
90
91
|
paintProposalGhost
|
|
91
92
|
} from "@pixerate/editor/paint-editor";
|
|
92
93
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
93
|
-
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, className }) => {
|
|
94
|
+
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
94
95
|
const state = usePaintEditorState(controller);
|
|
95
96
|
const viewport = useRef2(null);
|
|
96
97
|
const canvas = useRef2(null);
|
|
@@ -228,6 +229,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
228
229
|
},
|
|
229
230
|
i
|
|
230
231
|
)),
|
|
232
|
+
agentStrokes && /* @__PURE__ */ jsx(PaintAgentStrokeLines, { strokes: agentStrokes }),
|
|
231
233
|
predicted.length > 0 && /* @__PURE__ */ jsx("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
|
|
232
234
|
] }),
|
|
233
235
|
state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ jsx(ReferencePanel, { controller, id: r.id }, r.id)),
|
|
@@ -334,6 +336,10 @@ var PaintProposalGhost = ({ proposal, transform, zoom }) => {
|
|
|
334
336
|
}
|
|
335
337
|
);
|
|
336
338
|
};
|
|
339
|
+
var PaintAgentStrokeLines = ({ strokes }) => {
|
|
340
|
+
const { strokes: list } = useSyncExternalStore2(strokes.subscribe, strokes.getState, strokes.getState);
|
|
341
|
+
return /* @__PURE__ */ jsx(Fragment, { children: list.map((s) => /* @__PURE__ */ jsx("polyline", { "data-agent-stroke": s.id, points: paintAgentStrokePoints(s), fill: "none", stroke: s.color, strokeOpacity: s.opacity ?? 0.6, strokeWidth: s.size, strokeLinecap: "round", strokeLinejoin: "round" }, s.id)) });
|
|
342
|
+
};
|
|
337
343
|
|
|
338
344
|
// src/paint-editor/PaintToolbar.tsx
|
|
339
345
|
import { useRef as useRef4, useState as useState4 } from "react";
|
|
@@ -1675,7 +1681,7 @@ var PAINT_CONTROLS = {
|
|
|
1675
1681
|
lighting: '[data-testid="light-panel"]',
|
|
1676
1682
|
symmetry: '[aria-label="Symmetry"]'
|
|
1677
1683
|
};
|
|
1678
|
-
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1684
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1679
1685
|
const [tool, setTool] = useState10("brush");
|
|
1680
1686
|
const [tab, setTab] = useState10("color");
|
|
1681
1687
|
const tabRef = useRef8(tab);
|
|
@@ -1746,7 +1752,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, cl
|
|
|
1746
1752
|
/* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1747
1753
|
/* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1748
1754
|
/* @__PURE__ */ jsxs14("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1749
|
-
/* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, className: "flex-1 rounded-lg" }),
|
|
1755
|
+
/* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1750
1756
|
error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1751
1757
|
] }),
|
|
1752
1758
|
/* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.176.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.258.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.258.0"
|
|
332
332
|
},
|
|
333
333
|
"scripts": {
|
|
334
334
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|