@pixerate/editor-react 0.180.0 → 0.181.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/brushes/BrushEditor.d.cts +2 -0
- package/dist/brushes/BrushEditor.d.ts +2 -0
- package/dist/brushes/BrushLibraryEditor.d.cts +6 -1
- package/dist/brushes/BrushLibraryEditor.d.ts +6 -1
- package/dist/brushes/index.cjs +7 -4
- package/dist/brushes/index.js +2 -2
- package/dist/{chunk-QIJJCDYW.js → chunk-THMOZMEE.js} +7 -4
- package/dist/{chunk-XAPJMT3W.js → chunk-WCSMREA4.js} +2 -2
- package/dist/{chunk-76JBZXLM.js → chunk-XORL5PGL.js} +2 -2
- package/dist/image-editor/index.cjs +7 -4
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +7 -4
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +4 -3
- package/dist/paint-editor/index.js +4 -3
- package/dist/vector/index.cjs +7 -4
- package/dist/vector/index.js +2 -2
- package/package.json +3 -3
|
@@ -17,6 +17,8 @@ export interface BrushEditorProps {
|
|
|
17
17
|
onChange: (brush: Brush) => void;
|
|
18
18
|
/** A live preview stroke of `brush`: pixels (e.g. `controller.brushThumbnail`) or an image URL. */
|
|
19
19
|
preview?: Pixels | string | null;
|
|
20
|
+
/** The colour behind an image-URL preview, for transparent previews (see `brushPreviewColours`). */
|
|
21
|
+
previewBackground?: string;
|
|
20
22
|
/** With it, a "Save" button (labelled `saveLabel`) saves the brush in place. */
|
|
21
23
|
onSave?: () => unknown;
|
|
22
24
|
/** The Save button's label (default "Save"; e.g. "Save a copy" for a built-in). */
|
|
@@ -17,6 +17,8 @@ export interface BrushEditorProps {
|
|
|
17
17
|
onChange: (brush: Brush) => void;
|
|
18
18
|
/** A live preview stroke of `brush`: pixels (e.g. `controller.brushThumbnail`) or an image URL. */
|
|
19
19
|
preview?: Pixels | string | null;
|
|
20
|
+
/** The colour behind an image-URL preview, for transparent previews (see `brushPreviewColours`). */
|
|
21
|
+
previewBackground?: string;
|
|
20
22
|
/** With it, a "Save" button (labelled `saveLabel`) saves the brush in place. */
|
|
21
23
|
onSave?: () => unknown;
|
|
22
24
|
/** The Save button's label (default "Save"; e.g. "Save a copy" for a built-in). */
|
|
@@ -9,7 +9,12 @@ export interface BrushLibraryEditorProps {
|
|
|
9
9
|
profile: BrushHostProfile;
|
|
10
10
|
/** Draws the preview stroke (the host's renderer, as for `preview_brush`). Without it there is no preview. */
|
|
11
11
|
renderPreview?: BrushPreviewRenderer;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What a transparent preview is shown on (#rrggbb, default white); the renderer's own `paper`
|
|
14
|
+
* wins. The preview colour is chosen to read on it (`brushPreviewColours`).
|
|
15
|
+
*/
|
|
16
|
+
previewPaper?: string;
|
|
17
|
+
/** A fixed preview colour instead (overrides the brush's own and the contrast check). */
|
|
13
18
|
previewColor?: string;
|
|
14
19
|
/** Called with the brush as saved (a copy has a new id): e.g. pick it in the host. */
|
|
15
20
|
onSaved?: (brush: Brush) => void;
|
|
@@ -9,7 +9,12 @@ export interface BrushLibraryEditorProps {
|
|
|
9
9
|
profile: BrushHostProfile;
|
|
10
10
|
/** Draws the preview stroke (the host's renderer, as for `preview_brush`). Without it there is no preview. */
|
|
11
11
|
renderPreview?: BrushPreviewRenderer;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What a transparent preview is shown on (#rrggbb, default white); the renderer's own `paper`
|
|
14
|
+
* wins. The preview colour is chosen to read on it (`brushPreviewColours`).
|
|
15
|
+
*/
|
|
16
|
+
previewPaper?: string;
|
|
17
|
+
/** A fixed preview colour instead (overrides the brush's own and the contrast check). */
|
|
13
18
|
previewColor?: string;
|
|
14
19
|
/** Called with the brush as saved (a copy has a new id): e.g. pick it in the host. */
|
|
15
20
|
onSaved?: (brush: Brush) => void;
|
package/dist/brushes/index.cjs
CHANGED
|
@@ -96,7 +96,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime.js
|
|
|
96
96
|
|
|
97
97
|
// src/brushes/BrushEditor.tsx
|
|
98
98
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
99
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
99
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
100
100
|
const sections = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
101
101
|
const scope = (0, import_react2.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
102
102
|
const [problems, setProblems] = (0, import_react2.useState)(null);
|
|
@@ -116,7 +116,7 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
116
116
|
if (r.brush !== brush) onChange(r.brush);
|
|
117
117
|
};
|
|
118
118
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
119
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
119
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
120
120
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
121
121
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
122
122
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -257,7 +257,7 @@ var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, th
|
|
|
257
257
|
var import_react4 = require("react");
|
|
258
258
|
var import_brushes3 = require("@pixerate/editor/brushes");
|
|
259
259
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
260
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
260
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
261
261
|
const [original, setOriginal] = (0, import_react4.useState)(null);
|
|
262
262
|
const [builtin, setBuiltin] = (0, import_react4.useState)(false);
|
|
263
263
|
const [draft, setDraft] = (0, import_react4.useState)(null);
|
|
@@ -277,7 +277,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
277
277
|
live = false;
|
|
278
278
|
};
|
|
279
279
|
}, [library, brushId, profile]);
|
|
280
|
-
const
|
|
280
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
281
|
+
const colours = (0, import_react4.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
282
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
281
283
|
(0, import_react4.useEffect)(() => {
|
|
282
284
|
if (!draft || !renderPreview) return;
|
|
283
285
|
let live = true;
|
|
@@ -325,6 +327,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
325
327
|
brush: draft,
|
|
326
328
|
profile,
|
|
327
329
|
preview: renderPreview ? preview : void 0,
|
|
330
|
+
previewBackground: colours?.background,
|
|
328
331
|
onChange: (next) => {
|
|
329
332
|
setDraft(next);
|
|
330
333
|
setStatus(null);
|
package/dist/brushes/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrushLibraryEditor,
|
|
3
3
|
useBrushLibrary
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-THMOZMEE.js";
|
|
5
5
|
import {
|
|
6
6
|
BrushEditor,
|
|
7
7
|
BrushLibraryBrowser
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-XORL5PGL.js";
|
|
9
9
|
export {
|
|
10
10
|
BrushEditor,
|
|
11
11
|
BrushLibraryBrowser,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrushEditor,
|
|
3
3
|
button
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XORL5PGL.js";
|
|
5
5
|
|
|
6
6
|
// src/brushes/BrushLibraryEditor.tsx
|
|
7
7
|
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { brushPreviewColours, checkBrushEdit, newBrushFor, saveBrushEdit } from "@pixerate/editor/brushes";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
10
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
11
11
|
const [original, setOriginal] = useState(null);
|
|
12
12
|
const [builtin, setBuiltin] = useState(false);
|
|
13
13
|
const [draft, setDraft] = useState(null);
|
|
@@ -27,7 +27,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
27
27
|
live = false;
|
|
28
28
|
};
|
|
29
29
|
}, [library, brushId, profile]);
|
|
30
|
-
const
|
|
30
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
31
|
+
const colours = useMemo(() => draft ? brushPreviewColours(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
32
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
if (!draft || !renderPreview) return;
|
|
33
35
|
let live = true;
|
|
@@ -75,6 +77,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
75
77
|
brush: draft,
|
|
76
78
|
profile,
|
|
77
79
|
preview: renderPreview ? preview : void 0,
|
|
80
|
+
previewBackground: colours?.background,
|
|
78
81
|
onChange: (next) => {
|
|
79
82
|
setDraft(next);
|
|
80
83
|
setStatus(null);
|
|
@@ -44,10 +44,10 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
BrushLibraryEditor,
|
|
46
46
|
useBrushLibrary
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-THMOZMEE.js";
|
|
48
48
|
import {
|
|
49
49
|
BrushLibraryBrowser
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-XORL5PGL.js";
|
|
51
51
|
|
|
52
52
|
// src/image-editor/useImageEditor.ts
|
|
53
53
|
import { useRef, useState, useEffect, useCallback, useMemo } from "react";
|
|
@@ -143,7 +143,7 @@ var CommitColorInput = ({ value, label, onCommit, className }) => {
|
|
|
143
143
|
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
144
144
|
import { brushEditorScope, brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
|
|
145
145
|
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
146
|
-
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
146
|
+
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
147
147
|
const sections = useMemo2(() => brushEditorSections(brush, profile), [brush, profile]);
|
|
148
148
|
const scope = useMemo2(() => brushEditorScope(brush, profile), [brush, profile]);
|
|
149
149
|
const [problems, setProblems] = useState3(null);
|
|
@@ -163,7 +163,7 @@ var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSave,
|
|
|
163
163
|
if (r.brush !== brush) onChange(r.brush);
|
|
164
164
|
};
|
|
165
165
|
return /* @__PURE__ */ jsxs3("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
166
|
-
typeof preview === "string" ? /* @__PURE__ */ jsx3("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ jsx3(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
166
|
+
typeof preview === "string" ? /* @__PURE__ */ jsx3("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ jsx3(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
167
167
|
scope.note && /* @__PURE__ */ jsx3("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
168
168
|
sections.map((s) => /* @__PURE__ */ jsxs3("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
169
169
|
/* @__PURE__ */ jsx3("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -4713,7 +4713,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime26.
|
|
|
4713
4713
|
var import_react27 = require("react");
|
|
4714
4714
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
4715
4715
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4716
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
4716
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
4717
4717
|
const sections = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
4718
4718
|
const scope = (0, import_react27.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
4719
4719
|
const [problems, setProblems] = (0, import_react27.useState)(null);
|
|
@@ -4733,7 +4733,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
4733
4733
|
if (r.brush !== brush) onChange(r.brush);
|
|
4734
4734
|
};
|
|
4735
4735
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
4736
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
4736
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
4737
4737
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
4738
4738
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
4739
4739
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -4821,7 +4821,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
4821
4821
|
|
|
4822
4822
|
// src/brushes/BrushLibraryEditor.tsx
|
|
4823
4823
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4824
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
4824
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
4825
4825
|
const [original, setOriginal] = (0, import_react28.useState)(null);
|
|
4826
4826
|
const [builtin, setBuiltin] = (0, import_react28.useState)(false);
|
|
4827
4827
|
const [draft, setDraft] = (0, import_react28.useState)(null);
|
|
@@ -4841,7 +4841,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
4841
4841
|
live = false;
|
|
4842
4842
|
};
|
|
4843
4843
|
}, [library, brushId, profile]);
|
|
4844
|
-
const
|
|
4844
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
4845
|
+
const colours = (0, import_react28.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
4846
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
4845
4847
|
(0, import_react28.useEffect)(() => {
|
|
4846
4848
|
if (!draft || !renderPreview) return;
|
|
4847
4849
|
let live = true;
|
|
@@ -4889,6 +4891,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
4889
4891
|
brush: draft,
|
|
4890
4892
|
profile,
|
|
4891
4893
|
preview: renderPreview ? preview : void 0,
|
|
4894
|
+
previewBackground: colours?.background,
|
|
4892
4895
|
onChange: (next) => {
|
|
4893
4896
|
setDraft(next);
|
|
4894
4897
|
setStatus(null);
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
useImageEditor,
|
|
30
30
|
useImageEffectsTools,
|
|
31
31
|
useImageHistogram
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-WCSMREA4.js";
|
|
33
33
|
import {
|
|
34
34
|
ImageCheckbox,
|
|
35
35
|
ImageColor,
|
|
@@ -44,8 +44,8 @@ import "../chunk-5RPB4WGT.js";
|
|
|
44
44
|
import "../chunk-KIRIU53A.js";
|
|
45
45
|
import "../chunk-3I7FOSLF.js";
|
|
46
46
|
import "../chunk-W5CMGX3I.js";
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
47
|
+
import "../chunk-THMOZMEE.js";
|
|
48
|
+
import "../chunk-XORL5PGL.js";
|
|
49
49
|
export {
|
|
50
50
|
AdjustmentLayersPanel,
|
|
51
51
|
BrushOptionsBar,
|
package/dist/index.cjs
CHANGED
|
@@ -8477,7 +8477,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime43.
|
|
|
8477
8477
|
var import_react63 = require("react");
|
|
8478
8478
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
8479
8479
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8480
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
8480
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
8481
8481
|
const sections = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
8482
8482
|
const scope = (0, import_react63.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
8483
8483
|
const [problems, setProblems] = (0, import_react63.useState)(null);
|
|
@@ -8497,7 +8497,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
8497
8497
|
if (r.brush !== brush) onChange(r.brush);
|
|
8498
8498
|
};
|
|
8499
8499
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
8500
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
8500
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
8501
8501
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
8502
8502
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
8503
8503
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -8585,7 +8585,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
8585
8585
|
|
|
8586
8586
|
// src/brushes/BrushLibraryEditor.tsx
|
|
8587
8587
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8588
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
8588
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
8589
8589
|
const [original, setOriginal] = (0, import_react64.useState)(null);
|
|
8590
8590
|
const [builtin, setBuiltin] = (0, import_react64.useState)(false);
|
|
8591
8591
|
const [draft, setDraft] = (0, import_react64.useState)(null);
|
|
@@ -8605,7 +8605,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
8605
8605
|
live = false;
|
|
8606
8606
|
};
|
|
8607
8607
|
}, [library, brushId, profile]);
|
|
8608
|
-
const
|
|
8608
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
8609
|
+
const colours = (0, import_react64.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
8610
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
8609
8611
|
(0, import_react64.useEffect)(() => {
|
|
8610
8612
|
if (!draft || !renderPreview) return;
|
|
8611
8613
|
let live = true;
|
|
@@ -8653,6 +8655,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
8653
8655
|
brush: draft,
|
|
8654
8656
|
profile,
|
|
8655
8657
|
preview: renderPreview ? preview : void 0,
|
|
8658
|
+
previewBackground: colours?.background,
|
|
8656
8659
|
onChange: (next) => {
|
|
8657
8660
|
setDraft(next);
|
|
8658
8661
|
setStatus(null);
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
useImageEditor,
|
|
63
63
|
useImageEffectsTools,
|
|
64
64
|
useImageHistogram
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-WCSMREA4.js";
|
|
66
66
|
import {
|
|
67
67
|
ImageCheckbox,
|
|
68
68
|
ImageColor,
|
|
@@ -82,8 +82,8 @@ import {
|
|
|
82
82
|
useAgentPlayback,
|
|
83
83
|
usePlaybackSurface
|
|
84
84
|
} from "./chunk-W5CMGX3I.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
85
|
+
import "./chunk-THMOZMEE.js";
|
|
86
|
+
import "./chunk-XORL5PGL.js";
|
|
87
87
|
import {
|
|
88
88
|
CommandPalette,
|
|
89
89
|
useCommandPalette,
|
|
@@ -667,7 +667,7 @@ var import_brushes3 = require("@pixerate/editor/brushes");
|
|
|
667
667
|
var import_react5 = require("react");
|
|
668
668
|
var import_brushes = require("@pixerate/editor/brushes");
|
|
669
669
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
670
|
-
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
670
|
+
var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
671
671
|
const sections = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorSections)(brush, profile), [brush, profile]);
|
|
672
672
|
const scope = (0, import_react5.useMemo)(() => (0, import_brushes.brushEditorScope)(brush, profile), [brush, profile]);
|
|
673
673
|
const [problems, setProblems] = (0, import_react5.useState)(null);
|
|
@@ -687,7 +687,7 @@ var BrushEditor = ({ brush, profile = import_brushes.PAINT_PROFILE, onChange, pr
|
|
|
687
687
|
if (r.brush !== brush) onChange(r.brush);
|
|
688
688
|
};
|
|
689
689
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
690
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
690
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
691
691
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
692
692
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
693
693
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -1046,7 +1046,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1046
1046
|
const { brush, brushes } = state;
|
|
1047
1047
|
const paper = state.document.paper;
|
|
1048
1048
|
const thumbs = (0, import_react10.useMemo)(
|
|
1049
|
-
|
|
1049
|
+
// Each in a colour that reads on the paper (the brush's own default when it has one).
|
|
1050
|
+
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: (0, import_brushes3.brushPreviewColours)(controller.getBrushSpec(b.id), { paper: paper.color }).color })])),
|
|
1050
1051
|
// Thumbnails follow the library and the paper.
|
|
1051
1052
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1052
1053
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
chip,
|
|
30
30
|
panel,
|
|
31
31
|
useAttempt
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-XORL5PGL.js";
|
|
33
33
|
|
|
34
34
|
// src/paint-editor/usePaintEditor.ts
|
|
35
35
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -559,7 +559,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
559
559
|
// src/paint-editor/BrushPanel.tsx
|
|
560
560
|
import { useMemo as useMemo3, useRef as useRef4 } from "react";
|
|
561
561
|
import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
|
|
562
|
-
import { brushColourHex, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
562
|
+
import { brushColourHex, brushPreviewColours, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
563
563
|
|
|
564
564
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
565
565
|
import { PAINT_GRADIENT_KIT } from "@pixerate/editor/paint-editor";
|
|
@@ -598,7 +598,8 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
598
598
|
const { brush, brushes } = state;
|
|
599
599
|
const paper = state.document.paper;
|
|
600
600
|
const thumbs = useMemo3(
|
|
601
|
-
|
|
601
|
+
// Each in a colour that reads on the paper (the brush's own default when it has one).
|
|
602
|
+
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: brushPreviewColours(controller.getBrushSpec(b.id), { paper: paper.color }).color })])),
|
|
602
603
|
// Thumbnails follow the library and the paper.
|
|
603
604
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
604
605
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
package/dist/vector/index.cjs
CHANGED
|
@@ -1275,7 +1275,7 @@ var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime7.j
|
|
|
1275
1275
|
var import_react9 = require("react");
|
|
1276
1276
|
var import_brushes2 = require("@pixerate/editor/brushes");
|
|
1277
1277
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1278
|
-
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
1278
|
+
var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, className }) => {
|
|
1279
1279
|
const sections = (0, import_react9.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile), [brush, profile]);
|
|
1280
1280
|
const scope = (0, import_react9.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
|
|
1281
1281
|
const [problems, setProblems] = (0, import_react9.useState)(null);
|
|
@@ -1295,7 +1295,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
|
|
|
1295
1295
|
if (r.brush !== brush) onChange(r.brush);
|
|
1296
1296
|
};
|
|
1297
1297
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
1298
|
-
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1" } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
1298
|
+
typeof preview === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: preview, alt: "Brush preview", className: "rounded object-contain", style: { width: "100%", aspectRatio: "4 / 1", ...previewBackground ? { background: previewBackground } : {} } }) : preview !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
1299
1299
|
scope.note && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
|
|
1300
1300
|
sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
1301
1301
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
@@ -1383,7 +1383,7 @@ var EditorControl = ({ control: c, onSet }) => {
|
|
|
1383
1383
|
|
|
1384
1384
|
// src/brushes/BrushLibraryEditor.tsx
|
|
1385
1385
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1386
|
-
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview,
|
|
1386
|
+
var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
|
|
1387
1387
|
const [original, setOriginal] = (0, import_react10.useState)(null);
|
|
1388
1388
|
const [builtin, setBuiltin] = (0, import_react10.useState)(false);
|
|
1389
1389
|
const [draft, setDraft] = (0, import_react10.useState)(null);
|
|
@@ -1403,7 +1403,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
1403
1403
|
live = false;
|
|
1404
1404
|
};
|
|
1405
1405
|
}, [library, brushId, profile]);
|
|
1406
|
-
const
|
|
1406
|
+
const paper = renderPreview?.paper ?? previewPaper;
|
|
1407
|
+
const colours = (0, import_react10.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
|
|
1408
|
+
const colour = previewColor ?? colours?.color ?? "#475569";
|
|
1407
1409
|
(0, import_react10.useEffect)(() => {
|
|
1408
1410
|
if (!draft || !renderPreview) return;
|
|
1409
1411
|
let live = true;
|
|
@@ -1451,6 +1453,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewCol
|
|
|
1451
1453
|
brush: draft,
|
|
1452
1454
|
profile,
|
|
1453
1455
|
preview: renderPreview ? preview : void 0,
|
|
1456
|
+
previewBackground: colours?.background,
|
|
1454
1457
|
onChange: (next) => {
|
|
1455
1458
|
setDraft(next);
|
|
1456
1459
|
setStatus(null);
|
package/dist/vector/index.js
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
BrushLibraryEditor,
|
|
17
17
|
useBrushLibrary
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-THMOZMEE.js";
|
|
19
19
|
import {
|
|
20
20
|
BrushLibraryBrowser
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-XORL5PGL.js";
|
|
22
22
|
|
|
23
23
|
// src/vector/useVectorEditor.ts
|
|
24
24
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.181.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.265.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.265.0"
|
|
332
332
|
},
|
|
333
333
|
"scripts": {
|
|
334
334
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|