@pixerate/editor-react 0.187.0 → 0.188.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/PaintToolbar.d.cts +5 -2
- package/dist/paint-editor/PaintToolbar.d.ts +5 -2
- package/dist/paint-editor/index.cjs +79 -4
- package/dist/paint-editor/index.js +79 -4
- package/package.json +3 -3
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type PaintEditorController, type PaintAgentStrokes, type FillRegionOptions, 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). */
|
|
6
6
|
tool?: PaintTool;
|
|
7
|
+
/** Options for the Fill tool (`tool === 'fill'`). */
|
|
8
|
+
fillOptions?: Omit<FillRegionOptions, 'x' | 'y' | 'points'>;
|
|
7
9
|
/** Draw the symmetry axes and perspective lines (default true). */
|
|
8
10
|
showGuides?: boolean;
|
|
9
11
|
/** Fit the canvas in the viewport on mount (default true). */
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintAgentStrokes, type PaintPresence, type PaintProposals, type PaintTool, type PaintView } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type PaintEditorController, type PaintAgentStrokes, type FillRegionOptions, 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). */
|
|
6
6
|
tool?: PaintTool;
|
|
7
|
+
/** Options for the Fill tool (`tool === 'fill'`). */
|
|
8
|
+
fillOptions?: Omit<FillRegionOptions, 'x' | 'y' | 'points'>;
|
|
7
9
|
/** Draw the symmetry axes and perspective lines (default true). */
|
|
8
10
|
showGuides?: boolean;
|
|
9
11
|
/** Fit the canvas in the viewport on mount (default true). */
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type FillRegionOptions, type PaintEditorController, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
3
|
+
export type PaintFillToolbarOptions = Omit<FillRegionOptions, 'x' | 'y' | 'points'>;
|
|
3
4
|
export interface PaintToolbarProps {
|
|
4
5
|
controller: PaintEditorController;
|
|
5
6
|
tool: PaintTool;
|
|
6
7
|
onToolChange: (tool: PaintTool) => void;
|
|
8
|
+
fillOptions?: PaintFillToolbarOptions;
|
|
9
|
+
onFillOptionsChange?: (options: PaintFillToolbarOptions) => void;
|
|
7
10
|
/** Base name of saved and exported files (default `painting`). */
|
|
8
11
|
fileName?: string;
|
|
9
12
|
className?: string;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
|
-
* Tools (brush, eyedropper, pan, rotate view), undo / redo, view rotation, mirroring and reset,
|
|
15
|
+
* Tools (brush, fill, eyedropper, pan, rotate view), undo / redo, view rotation, mirroring and reset,
|
|
13
16
|
* the symmetry and perspective guides, stencils (ruler, circle, mask), the tracing image and reference images, the drawing hand,
|
|
14
17
|
* and file actions: save / open JSON, export PNG, JPEG and PSD, a time-lapse (zipped frames, video
|
|
15
18
|
* project and ffmpeg command) and a PNG repainted from the strokes at twice the size.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PaintEditorController, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { type FillRegionOptions, type PaintEditorController, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
3
|
+
export type PaintFillToolbarOptions = Omit<FillRegionOptions, 'x' | 'y' | 'points'>;
|
|
3
4
|
export interface PaintToolbarProps {
|
|
4
5
|
controller: PaintEditorController;
|
|
5
6
|
tool: PaintTool;
|
|
6
7
|
onToolChange: (tool: PaintTool) => void;
|
|
8
|
+
fillOptions?: PaintFillToolbarOptions;
|
|
9
|
+
onFillOptionsChange?: (options: PaintFillToolbarOptions) => void;
|
|
7
10
|
/** Base name of saved and exported files (default `painting`). */
|
|
8
11
|
fileName?: string;
|
|
9
12
|
className?: string;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
|
-
* Tools (brush, eyedropper, pan, rotate view), undo / redo, view rotation, mirroring and reset,
|
|
15
|
+
* Tools (brush, fill, eyedropper, pan, rotate view), undo / redo, view rotation, mirroring and reset,
|
|
13
16
|
* the symmetry and perspective guides, stencils (ruler, circle, mask), the tracing image and reference images, the drawing hand,
|
|
14
17
|
* and file actions: save / open JSON, export PNG, JPEG and PSD, a time-lapse (zipped frames, video
|
|
15
18
|
* project and ffmpeg command) and a PNG repainted from the strokes at twice the size.
|
|
@@ -110,7 +110,7 @@ function usePaintChangeFeed(controller, options = {}) {
|
|
|
110
110
|
var import_react2 = require("react");
|
|
111
111
|
var import_paint_editor2 = require("@pixerate/editor/paint-editor");
|
|
112
112
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
113
|
-
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
113
|
+
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
114
114
|
const state = usePaintEditorState(controller);
|
|
115
115
|
const viewport = (0, import_react2.useRef)(null);
|
|
116
116
|
const canvas = (0, import_react2.useRef)(null);
|
|
@@ -130,6 +130,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
130
130
|
[controller]
|
|
131
131
|
);
|
|
132
132
|
gesture.tool = tool;
|
|
133
|
+
if (fillOptions) gesture.fillOptions = fillOptions;
|
|
133
134
|
const { canvas: doc } = state.document;
|
|
134
135
|
(0, import_react2.useEffect)(() => {
|
|
135
136
|
const el = viewport.current;
|
|
@@ -456,11 +457,19 @@ var CommitColorInput = ({ value, label, onCommit, className }) => {
|
|
|
456
457
|
|
|
457
458
|
// src/paint-editor/PaintToolbar.tsx
|
|
458
459
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
459
|
-
var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", className }) => {
|
|
460
|
+
var PaintToolbar = ({ controller, tool, onToolChange, fillOptions: controlledFill, onFillOptionsChange, fileName = "painting", className }) => {
|
|
460
461
|
const state = usePaintEditorState(controller);
|
|
461
462
|
const [error, attempt] = useAttempt();
|
|
462
463
|
const [busy, setBusy] = (0, import_react4.useState)(null);
|
|
463
464
|
const [note, setNote] = (0, import_react4.useState)(null);
|
|
465
|
+
const [localFill, setLocalFill] = (0, import_react4.useState)({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
466
|
+
const fill = controlledFill ?? localFill;
|
|
467
|
+
const updateFill = (patch) => {
|
|
468
|
+
const next = { ...fill, ...patch };
|
|
469
|
+
setLocalFill(next);
|
|
470
|
+
onFillOptionsChange?.(next);
|
|
471
|
+
};
|
|
472
|
+
const layers = controller.listLayers().filter((l) => l.type === "pixel");
|
|
464
473
|
const openRef = (0, import_react4.useRef)(null);
|
|
465
474
|
const tracingRef = (0, import_react4.useRef)(null);
|
|
466
475
|
const refRef = (0, import_react4.useRef)(null);
|
|
@@ -469,6 +478,71 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
469
478
|
const exportImage = (format) => attempt(async () => (0, import_paint_editor3.downloadBytes)(await controller.exportImage({ format }), `${fileName}.${format === "image/png" ? "png" : "jpg"}`, format));
|
|
470
479
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `flex flex-wrap items-center gap-1.5 text-xs text-slate-200 ${className ?? ""}`, role: "toolbar", "aria-label": "Paint toolbar", "data-testid": "paint-toolbar", children: [
|
|
471
480
|
import_paint_editor3.PAINT_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", "aria-pressed": tool === t.id, title: `${t.label} (${t.key.toUpperCase()})`, className: chip(tool === t.id), onClick: () => onToolChange(t.id), children: t.label }, t.id)),
|
|
481
|
+
tool === "fill" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1.5 rounded border border-slate-700/80 bg-slate-900/60 px-2 py-0.5 text-[11px] text-slate-300", "data-testid": "paint-fill-options", children: [
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
483
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Ref" }),
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
485
|
+
"select",
|
|
486
|
+
{
|
|
487
|
+
"aria-label": "Fill reference",
|
|
488
|
+
className: "rounded bg-slate-800 px-1 py-0.5 text-[11px]",
|
|
489
|
+
value: fill.reference ?? "all",
|
|
490
|
+
onChange: (e) => updateFill({ reference: e.target.value }),
|
|
491
|
+
children: [
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "all", children: "All layers" }),
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "layer", children: "Active layer" }),
|
|
494
|
+
layers.map((l) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: l.id, children: l.name }, l.id))
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
] }),
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Tol" }),
|
|
501
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
502
|
+
"input",
|
|
503
|
+
{
|
|
504
|
+
type: "number",
|
|
505
|
+
"aria-label": "Fill tolerance",
|
|
506
|
+
min: 0,
|
|
507
|
+
max: 255,
|
|
508
|
+
value: fill.tolerance ?? 32,
|
|
509
|
+
onChange: (e) => updateFill({ tolerance: Math.max(0, Math.min(255, Number(e.target.value) || 0)) }),
|
|
510
|
+
className: "w-11 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Gap" }),
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
517
|
+
"input",
|
|
518
|
+
{
|
|
519
|
+
type: "number",
|
|
520
|
+
"aria-label": "Close gap",
|
|
521
|
+
min: 0,
|
|
522
|
+
max: 32,
|
|
523
|
+
value: fill.closeGap ?? 4,
|
|
524
|
+
onChange: (e) => updateFill({ closeGap: Math.max(0, Math.min(32, Number(e.target.value) || 0)) }),
|
|
525
|
+
className: "w-10 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
] }),
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
530
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Expand" }),
|
|
531
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
532
|
+
"input",
|
|
533
|
+
{
|
|
534
|
+
type: "number",
|
|
535
|
+
"aria-label": "Expand fill",
|
|
536
|
+
min: -16,
|
|
537
|
+
max: 16,
|
|
538
|
+
value: fill.expand ?? 1,
|
|
539
|
+
onChange: (e) => updateFill({ expand: Math.max(-16, Math.min(16, Number(e.target.value) || 0)) }),
|
|
540
|
+
className: "w-10 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
] }),
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chip(Boolean(fill.wet)), "aria-pressed": Boolean(fill.wet), onClick: () => updateFill({ wet: !fill.wet }), children: "Wet" })
|
|
545
|
+
] }),
|
|
472
546
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
473
547
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: button, disabled: !state.canUndo, title: state.undoLabel ? `Undo ${state.undoLabel}` : "Undo", onClick: () => controller.undo(), children: "Undo" }),
|
|
474
548
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: button, disabled: !state.canRedo, title: state.redoLabel ? `Redo ${state.redoLabel}` : "Redo", onClick: () => controller.redo(), children: "Redo" }),
|
|
@@ -4082,6 +4156,7 @@ var PAINT_CONTROLS = {
|
|
|
4082
4156
|
};
|
|
4083
4157
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4084
4158
|
const [tool, setTool] = (0, import_react30.useState)("brush");
|
|
4159
|
+
const [fillOptions, setFillOptions] = (0, import_react30.useState)({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
4085
4160
|
const [tab, setTab] = (0, import_react30.useState)("color");
|
|
4086
4161
|
const tabRef = (0, import_react30.useRef)(tab);
|
|
4087
4162
|
tabRef.current = tab;
|
|
@@ -4147,11 +4222,11 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4147
4222
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
4148
4223
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("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: [
|
|
4149
4224
|
playing && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
4150
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
4225
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
4151
4226
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
4152
4227
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
4153
4228
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4154
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
4229
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
4155
4230
|
error && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
4156
4231
|
] }),
|
|
4157
4232
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
paintProposalGhost
|
|
101
101
|
} from "@pixerate/editor/paint-editor";
|
|
102
102
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
103
|
-
var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
103
|
+
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
104
104
|
const state = usePaintEditorState(controller);
|
|
105
105
|
const viewport = useRef2(null);
|
|
106
106
|
const canvas = useRef2(null);
|
|
@@ -120,6 +120,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
120
120
|
[controller]
|
|
121
121
|
);
|
|
122
122
|
gesture.tool = tool;
|
|
123
|
+
if (fillOptions) gesture.fillOptions = fillOptions;
|
|
123
124
|
const { canvas: doc } = state.document;
|
|
124
125
|
useEffect2(() => {
|
|
125
126
|
const el = viewport.current;
|
|
@@ -354,11 +355,19 @@ var PaintAgentStrokeLines = ({ strokes }) => {
|
|
|
354
355
|
import { useRef as useRef3, useState as useState3 } from "react";
|
|
355
356
|
import { PAINT_TOOLS, SYMMETRY_MODES, decodeImageBlob, downloadBytes, quickStencil, timeLapseZip } from "@pixerate/editor/paint-editor";
|
|
356
357
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
357
|
-
var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", className }) => {
|
|
358
|
+
var PaintToolbar = ({ controller, tool, onToolChange, fillOptions: controlledFill, onFillOptionsChange, fileName = "painting", className }) => {
|
|
358
359
|
const state = usePaintEditorState(controller);
|
|
359
360
|
const [error, attempt] = useAttempt();
|
|
360
361
|
const [busy, setBusy] = useState3(null);
|
|
361
362
|
const [note, setNote] = useState3(null);
|
|
363
|
+
const [localFill, setLocalFill] = useState3({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
364
|
+
const fill = controlledFill ?? localFill;
|
|
365
|
+
const updateFill = (patch) => {
|
|
366
|
+
const next = { ...fill, ...patch };
|
|
367
|
+
setLocalFill(next);
|
|
368
|
+
onFillOptionsChange?.(next);
|
|
369
|
+
};
|
|
370
|
+
const layers = controller.listLayers().filter((l) => l.type === "pixel");
|
|
362
371
|
const openRef = useRef3(null);
|
|
363
372
|
const tracingRef = useRef3(null);
|
|
364
373
|
const refRef = useRef3(null);
|
|
@@ -367,6 +376,71 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
367
376
|
const exportImage = (format) => attempt(async () => downloadBytes(await controller.exportImage({ format }), `${fileName}.${format === "image/png" ? "png" : "jpg"}`, format));
|
|
368
377
|
return /* @__PURE__ */ jsxs2("div", { className: `flex flex-wrap items-center gap-1.5 text-xs text-slate-200 ${className ?? ""}`, role: "toolbar", "aria-label": "Paint toolbar", "data-testid": "paint-toolbar", children: [
|
|
369
378
|
PAINT_TOOLS.map((t) => /* @__PURE__ */ jsx2("button", { type: "button", "aria-pressed": tool === t.id, title: `${t.label} (${t.key.toUpperCase()})`, className: chip(tool === t.id), onClick: () => onToolChange(t.id), children: t.label }, t.id)),
|
|
379
|
+
tool === "fill" && /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1.5 rounded border border-slate-700/80 bg-slate-900/60 px-2 py-0.5 text-[11px] text-slate-300", "data-testid": "paint-fill-options", children: [
|
|
380
|
+
/* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-1", children: [
|
|
381
|
+
/* @__PURE__ */ jsx2("span", { children: "Ref" }),
|
|
382
|
+
/* @__PURE__ */ jsxs2(
|
|
383
|
+
"select",
|
|
384
|
+
{
|
|
385
|
+
"aria-label": "Fill reference",
|
|
386
|
+
className: "rounded bg-slate-800 px-1 py-0.5 text-[11px]",
|
|
387
|
+
value: fill.reference ?? "all",
|
|
388
|
+
onChange: (e) => updateFill({ reference: e.target.value }),
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ jsx2("option", { value: "all", children: "All layers" }),
|
|
391
|
+
/* @__PURE__ */ jsx2("option", { value: "layer", children: "Active layer" }),
|
|
392
|
+
layers.map((l) => /* @__PURE__ */ jsx2("option", { value: l.id, children: l.name }, l.id))
|
|
393
|
+
]
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-1", children: [
|
|
398
|
+
/* @__PURE__ */ jsx2("span", { children: "Tol" }),
|
|
399
|
+
/* @__PURE__ */ jsx2(
|
|
400
|
+
"input",
|
|
401
|
+
{
|
|
402
|
+
type: "number",
|
|
403
|
+
"aria-label": "Fill tolerance",
|
|
404
|
+
min: 0,
|
|
405
|
+
max: 255,
|
|
406
|
+
value: fill.tolerance ?? 32,
|
|
407
|
+
onChange: (e) => updateFill({ tolerance: Math.max(0, Math.min(255, Number(e.target.value) || 0)) }),
|
|
408
|
+
className: "w-11 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
409
|
+
}
|
|
410
|
+
)
|
|
411
|
+
] }),
|
|
412
|
+
/* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-1", children: [
|
|
413
|
+
/* @__PURE__ */ jsx2("span", { children: "Gap" }),
|
|
414
|
+
/* @__PURE__ */ jsx2(
|
|
415
|
+
"input",
|
|
416
|
+
{
|
|
417
|
+
type: "number",
|
|
418
|
+
"aria-label": "Close gap",
|
|
419
|
+
min: 0,
|
|
420
|
+
max: 32,
|
|
421
|
+
value: fill.closeGap ?? 4,
|
|
422
|
+
onChange: (e) => updateFill({ closeGap: Math.max(0, Math.min(32, Number(e.target.value) || 0)) }),
|
|
423
|
+
className: "w-10 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
424
|
+
}
|
|
425
|
+
)
|
|
426
|
+
] }),
|
|
427
|
+
/* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-1", children: [
|
|
428
|
+
/* @__PURE__ */ jsx2("span", { children: "Expand" }),
|
|
429
|
+
/* @__PURE__ */ jsx2(
|
|
430
|
+
"input",
|
|
431
|
+
{
|
|
432
|
+
type: "number",
|
|
433
|
+
"aria-label": "Expand fill",
|
|
434
|
+
min: -16,
|
|
435
|
+
max: 16,
|
|
436
|
+
value: fill.expand ?? 1,
|
|
437
|
+
onChange: (e) => updateFill({ expand: Math.max(-16, Math.min(16, Number(e.target.value) || 0)) }),
|
|
438
|
+
className: "w-10 rounded bg-slate-800 px-1 py-0.5 text-[11px]"
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
] }),
|
|
442
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: chip(Boolean(fill.wet)), "aria-pressed": Boolean(fill.wet), onClick: () => updateFill({ wet: !fill.wet }), children: "Wet" })
|
|
443
|
+
] }),
|
|
370
444
|
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
371
445
|
/* @__PURE__ */ jsx2("button", { type: "button", className: button, disabled: !state.canUndo, title: state.undoLabel ? `Undo ${state.undoLabel}` : "Undo", onClick: () => controller.undo(), children: "Undo" }),
|
|
372
446
|
/* @__PURE__ */ jsx2("button", { type: "button", className: button, disabled: !state.canRedo, title: state.redoLabel ? `Redo ${state.redoLabel}` : "Redo", onClick: () => controller.redo(), children: "Redo" }),
|
|
@@ -1528,6 +1602,7 @@ var PAINT_CONTROLS = {
|
|
|
1528
1602
|
};
|
|
1529
1603
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1530
1604
|
const [tool, setTool] = useState9("brush");
|
|
1605
|
+
const [fillOptions, setFillOptions] = useState9({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
1531
1606
|
const [tab, setTab] = useState9("color");
|
|
1532
1607
|
const tabRef = useRef7(tab);
|
|
1533
1608
|
tabRef.current = tab;
|
|
@@ -1593,11 +1668,11 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1593
1668
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1594
1669
|
return /* @__PURE__ */ jsxs13("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: [
|
|
1595
1670
|
playing && /* @__PURE__ */ jsx14(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1596
|
-
/* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1671
|
+
/* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
1597
1672
|
/* @__PURE__ */ jsxs13("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1598
1673
|
/* @__PURE__ */ jsx14(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1599
1674
|
/* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1600
|
-
/* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1675
|
+
/* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1601
1676
|
error && /* @__PURE__ */ jsx14("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1602
1677
|
] }),
|
|
1603
1678
|
/* @__PURE__ */ jsxs13("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.188.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
"dependencies": {},
|
|
284
284
|
"peerDependencies": {
|
|
285
285
|
"@dagrejs/dagre": "^1.1.8",
|
|
286
|
-
"@pixerate/editor": ">=0.
|
|
286
|
+
"@pixerate/editor": ">=0.273.0 <1.0.0-0",
|
|
287
287
|
"@tiptap/core": "^2.27.3",
|
|
288
288
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
289
289
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
"tsup": "^9.0.0",
|
|
335
335
|
"typescript": "^5.7.3",
|
|
336
336
|
"vitest": "^5.0.5",
|
|
337
|
-
"@pixerate/editor": "0.
|
|
337
|
+
"@pixerate/editor": "0.273.0"
|
|
338
338
|
},
|
|
339
339
|
"scripts": {
|
|
340
340
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|