@pixerate/editor-react 0.170.0 → 0.171.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/chunk-KYMDNWSX.js +51 -0
- package/dist/paint-editor/StickerPicker.d.cts +4 -4
- package/dist/paint-editor/StickerPicker.d.ts +4 -4
- package/dist/paint-editor/index.cjs +712 -692
- package/dist/paint-editor/index.js +31 -58
- package/dist/stickers/StickerInsertPanel.d.cts +16 -0
- package/dist/stickers/StickerInsertPanel.d.ts +16 -0
- package/dist/stickers/StickerLibraryPicker.d.cts +21 -0
- package/dist/stickers/StickerLibraryPicker.d.ts +21 -0
- package/dist/stickers/index.cjs +110 -0
- package/dist/stickers/index.d.cts +2 -0
- package/dist/stickers/index.d.ts +2 -0
- package/dist/stickers/index.js +38 -0
- package/package.json +13 -3
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StickerLibraryPicker
|
|
3
|
+
} from "../chunk-KYMDNWSX.js";
|
|
1
4
|
import {
|
|
2
5
|
LayerEffectsPanel,
|
|
3
6
|
PaintGradientEditorView
|
|
@@ -571,7 +574,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
571
574
|
};
|
|
572
575
|
|
|
573
576
|
// src/paint-editor/BrushPanel.tsx
|
|
574
|
-
import { useMemo as
|
|
577
|
+
import { useMemo as useMemo3, useRef as useRef4, useState as useState6 } from "react";
|
|
575
578
|
import {
|
|
576
579
|
BLEND_MENU_GROUPS,
|
|
577
580
|
BRUSH_ROTATIONS,
|
|
@@ -612,56 +615,26 @@ import { jsx as jsx4 } from "react/jsx-runtime";
|
|
|
612
615
|
var PaintGradientEditor = (props) => /* @__PURE__ */ jsx4(PaintGradientEditorView, { ...props, kit: PAINT_GRADIENT_KIT });
|
|
613
616
|
|
|
614
617
|
// src/paint-editor/StickerPicker.tsx
|
|
615
|
-
import { useEffect as useEffect4,
|
|
616
|
-
import { StickerBrowser } from "@pixerate/editor/paint-editor";
|
|
618
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
617
619
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
618
620
|
var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
useEffect4(() => browser.subscribe(() => setTick((n) => n + 1)), [browser]);
|
|
622
|
-
useEffect4(() => {
|
|
623
|
-
void browser.refresh();
|
|
624
|
-
return controller.stickers.subscribe(() => void browser.refresh());
|
|
625
|
-
}, [browser, controller]);
|
|
626
|
-
const s = browser.state;
|
|
621
|
+
const [provider, setProvider] = useState5(() => controller.stickersProvider);
|
|
622
|
+
useEffect4(() => controller.stickers.subscribe(setProvider), [controller]);
|
|
627
623
|
const failed = selected.map((ref) => ({ ref, ...controller.stickerArtStatus(ref) })).filter((x) => x.status === "failed");
|
|
628
|
-
return /* @__PURE__ */
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
"aria-pressed": on,
|
|
643
|
-
title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}`,
|
|
644
|
-
className: `flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
645
|
-
onClick: () => onPick(it.ref),
|
|
646
|
-
children: [
|
|
647
|
-
it.thumbnail && /* @__PURE__ */ jsx5("img", { src: it.thumbnail, alt: "", className: "h-4 w-4" }),
|
|
648
|
-
it.name
|
|
649
|
-
]
|
|
650
|
-
},
|
|
651
|
-
it.ref
|
|
652
|
-
);
|
|
653
|
-
}) }),
|
|
654
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between text-[10px] text-slate-500", children: [
|
|
655
|
-
/* @__PURE__ */ jsx5("span", { children: s.loading ? "Loading\u2026" : `${s.items.length} of ${s.total}` }),
|
|
656
|
-
s.hasMore && /* @__PURE__ */ jsx5("button", { type: "button", className: "text-indigo-300", onClick: () => void browser.more(), children: "More" })
|
|
657
|
-
] }),
|
|
658
|
-
s.error && /* @__PURE__ */ jsx5("p", { role: "alert", className: "text-[11px] text-rose-400", children: s.error }),
|
|
659
|
-
failed.map((f) => /* @__PURE__ */ jsxs4("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
660
|
-
f.ref,
|
|
661
|
-
": ",
|
|
662
|
-
f.error
|
|
663
|
-
] }, f.ref))
|
|
664
|
-
] });
|
|
624
|
+
return /* @__PURE__ */ jsx5(
|
|
625
|
+
StickerLibraryPicker,
|
|
626
|
+
{
|
|
627
|
+
provider,
|
|
628
|
+
selected,
|
|
629
|
+
label,
|
|
630
|
+
onPick: (it) => onPick(it.ref),
|
|
631
|
+
footer: failed.map((f) => /* @__PURE__ */ jsxs4("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
632
|
+
f.ref,
|
|
633
|
+
": ",
|
|
634
|
+
f.error
|
|
635
|
+
] }, f.ref))
|
|
636
|
+
}
|
|
637
|
+
);
|
|
665
638
|
};
|
|
666
639
|
|
|
667
640
|
// src/paint-editor/BrushPanel.tsx
|
|
@@ -673,7 +646,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
673
646
|
const fileRef = useRef4(null);
|
|
674
647
|
const { brush, brushes } = state;
|
|
675
648
|
const paper = state.document.paper;
|
|
676
|
-
const thumbs =
|
|
649
|
+
const thumbs = useMemo3(
|
|
677
650
|
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: "#26324a" })])),
|
|
678
651
|
// Thumbnails follow the library and the paper.
|
|
679
652
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -844,7 +817,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
844
817
|
};
|
|
845
818
|
|
|
846
819
|
// src/paint-editor/PaperPanel.tsx
|
|
847
|
-
import { useMemo as
|
|
820
|
+
import { useMemo as useMemo4 } from "react";
|
|
848
821
|
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath as patchPath2, readPath as readPath2, renderPaper } from "@pixerate/editor/paint-editor";
|
|
849
822
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
850
823
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
@@ -852,7 +825,7 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
852
825
|
const state = usePaintEditorState(controller);
|
|
853
826
|
const [error, attempt] = useAttempt();
|
|
854
827
|
const paper = state.document.paper;
|
|
855
|
-
const previews =
|
|
828
|
+
const previews = useMemo4(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
856
829
|
return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
857
830
|
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs6("div", { children: [
|
|
858
831
|
/* @__PURE__ */ jsx7("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
@@ -895,7 +868,7 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
895
868
|
};
|
|
896
869
|
|
|
897
870
|
// src/paint-editor/ColorPanel.tsx
|
|
898
|
-
import { useMemo as
|
|
871
|
+
import { useMemo as useMemo5, useRef as useRef5, useState as useState7 } from "react";
|
|
899
872
|
import {
|
|
900
873
|
HARMONY_KINDS,
|
|
901
874
|
MIXING_PAD_HEIGHT,
|
|
@@ -923,13 +896,13 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
923
896
|
const [parts, setParts] = useState7([1, 1]);
|
|
924
897
|
const [padName, setPadName] = useState7("");
|
|
925
898
|
const padPoints = useRef5(null);
|
|
926
|
-
const ring =
|
|
899
|
+
const ring = useMemo5(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
927
900
|
const color = state.color;
|
|
928
|
-
const harmony =
|
|
901
|
+
const harmony = useMemo5(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
929
902
|
const [r, g, b] = parseHexColor(color);
|
|
930
903
|
const hsv = rgbToHsv(r, g, b);
|
|
931
|
-
const effectWell =
|
|
932
|
-
const pad =
|
|
904
|
+
const effectWell = useMemo5(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
905
|
+
const pad = useMemo5(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
933
906
|
const R = wheelSize / 2;
|
|
934
907
|
const mid = R * 0.82;
|
|
935
908
|
const setHsv = (s, v) => controller.setColor(rgbToHexColor(...hsvToRgb(hsv.h, s, v)));
|
|
@@ -1440,7 +1413,7 @@ import { useRef as useRef7, useState as useState10 } from "react";
|
|
|
1440
1413
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1441
1414
|
|
|
1442
1415
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1443
|
-
import { useEffect as useEffect5, useMemo as
|
|
1416
|
+
import { useEffect as useEffect5, useMemo as useMemo6, useRef as useRef6, useState as useState9 } from "react";
|
|
1444
1417
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1445
1418
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1446
1419
|
function usePaintEffectsProvider(controller) {
|
|
@@ -1508,7 +1481,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1508
1481
|
if (!effectPaint) return;
|
|
1509
1482
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1510
1483
|
};
|
|
1511
|
-
const thumbnail =
|
|
1484
|
+
const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1512
1485
|
const run = (work) => attempt(() => {
|
|
1513
1486
|
setBusy(true);
|
|
1514
1487
|
return work().finally(() => setBusy(false));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { insertSticker, type StickerInsertHost, type StickerProvider } from '@pixerate/editor/stickers';
|
|
3
|
+
export interface StickerInsertPanelProps {
|
|
4
|
+
provider: StickerProvider;
|
|
5
|
+
/** Where stickers go: `createVectorStickerHost`, `createImageStickerHost`, `createCanvasStickerHost` or your own. */
|
|
6
|
+
host: StickerInsertHost;
|
|
7
|
+
/** Called with what was inserted (its id, ref, size and licence). */
|
|
8
|
+
onInserted?: (result: Awaited<ReturnType<typeof insertSticker>>) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Pick a sticker to insert it into an editor (one undo step), centred in the document at its
|
|
13
|
+
* natural size, with an optional tint for tintable stickers: the panel counterpart of
|
|
14
|
+
* `insert_sticker`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const StickerInsertPanel: React.FC<StickerInsertPanelProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { insertSticker, type StickerInsertHost, type StickerProvider } from '@pixerate/editor/stickers';
|
|
3
|
+
export interface StickerInsertPanelProps {
|
|
4
|
+
provider: StickerProvider;
|
|
5
|
+
/** Where stickers go: `createVectorStickerHost`, `createImageStickerHost`, `createCanvasStickerHost` or your own. */
|
|
6
|
+
host: StickerInsertHost;
|
|
7
|
+
/** Called with what was inserted (its id, ref, size and licence). */
|
|
8
|
+
onInserted?: (result: Awaited<ReturnType<typeof insertSticker>>) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Pick a sticker to insert it into an editor (one undo step), centred in the document at its
|
|
13
|
+
* natural size, with an optional tint for tintable stickers: the panel counterpart of
|
|
14
|
+
* `insert_sticker`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const StickerInsertPanel: React.FC<StickerInsertPanelProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StickerBrowserItem, type StickerProvider } from '@pixerate/editor/stickers';
|
|
3
|
+
export interface StickerLibraryPickerProps {
|
|
4
|
+
/** The sticker library (e.g. `editorStickers()`, a host's, or `combineStickerProviders([...])`). */
|
|
5
|
+
provider: StickerProvider;
|
|
6
|
+
/** Refs shown as chosen. */
|
|
7
|
+
selected?: readonly string[];
|
|
8
|
+
/** Called with a sticker when it is clicked. */
|
|
9
|
+
onPick: (sticker: StickerBrowserItem) => void;
|
|
10
|
+
/** Accessible name of the sticker list (default "Stickers"). */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Shown under the list (e.g. load errors). */
|
|
13
|
+
footer?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Stickers from a sticker library: searchable, by category and a page at a time, with each
|
|
18
|
+
* sticker's licence in its tooltip. Clicking one calls `onPick`. The same picker serves the paint
|
|
19
|
+
* editor's sticker brush and inserting stickers into the vector, image and canvas editors.
|
|
20
|
+
*/
|
|
21
|
+
export declare const StickerLibraryPicker: React.FC<StickerLibraryPickerProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StickerBrowserItem, type StickerProvider } from '@pixerate/editor/stickers';
|
|
3
|
+
export interface StickerLibraryPickerProps {
|
|
4
|
+
/** The sticker library (e.g. `editorStickers()`, a host's, or `combineStickerProviders([...])`). */
|
|
5
|
+
provider: StickerProvider;
|
|
6
|
+
/** Refs shown as chosen. */
|
|
7
|
+
selected?: readonly string[];
|
|
8
|
+
/** Called with a sticker when it is clicked. */
|
|
9
|
+
onPick: (sticker: StickerBrowserItem) => void;
|
|
10
|
+
/** Accessible name of the sticker list (default "Stickers"). */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Shown under the list (e.g. load errors). */
|
|
13
|
+
footer?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Stickers from a sticker library: searchable, by category and a page at a time, with each
|
|
18
|
+
* sticker's licence in its tooltip. Clicking one calls `onPick`. The same picker serves the paint
|
|
19
|
+
* editor's sticker brush and inserting stickers into the vector, image and canvas editors.
|
|
20
|
+
*/
|
|
21
|
+
export declare const StickerLibraryPicker: React.FC<StickerLibraryPickerProps>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stickers/index.ts
|
|
21
|
+
var stickers_exports = {};
|
|
22
|
+
__export(stickers_exports, {
|
|
23
|
+
StickerInsertPanel: () => StickerInsertPanel,
|
|
24
|
+
StickerLibraryPicker: () => StickerLibraryPicker
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(stickers_exports);
|
|
27
|
+
|
|
28
|
+
// src/stickers/StickerLibraryPicker.tsx
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_stickers = require("@pixerate/editor/stickers");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var StickerLibraryPicker = ({ provider, selected = [], onPick, label = "Stickers", footer, className }) => {
|
|
33
|
+
const browser = (0, import_react.useMemo)(() => new import_stickers.StickerBrowser(() => provider), [provider]);
|
|
34
|
+
const [, setTick] = (0, import_react.useState)(0);
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
const off = browser.subscribe(() => setTick((n) => n + 1));
|
|
37
|
+
void browser.refresh();
|
|
38
|
+
return off;
|
|
39
|
+
}, [browser]);
|
|
40
|
+
const s = browser.state;
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "sticker-picker", children: [
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
43
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "search", "aria-label": `Search ${label.toLowerCase()}`, placeholder: `Search ${s.provider}`, value: s.query, onChange: (e) => void browser.setQuery(e.target.value), className: "min-w-0 flex-1 rounded bg-slate-800 px-1 py-0.5" }),
|
|
44
|
+
s.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { "aria-label": "Sticker category", value: s.category, onChange: (e) => void browser.setCategory(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: [
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "All" }),
|
|
46
|
+
s.categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
47
|
+
] })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex max-h-32 flex-wrap gap-1 overflow-y-auto", role: "group", "aria-label": label, children: s.items.map((it) => {
|
|
50
|
+
const on = selected.includes(it.ref);
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
52
|
+
"button",
|
|
53
|
+
{
|
|
54
|
+
type: "button",
|
|
55
|
+
"aria-pressed": on,
|
|
56
|
+
title: `${it.name} (${it.ref}) \xB7 ${it.licence.name}${it.licence.attribution ? ` \xB7 ${it.licence.attribution}` : ""}`,
|
|
57
|
+
className: `flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
58
|
+
onClick: () => onPick(it),
|
|
59
|
+
children: [
|
|
60
|
+
it.thumbnail && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: it.thumbnail, alt: "", className: "h-4 w-4" }),
|
|
61
|
+
it.name
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
it.ref
|
|
65
|
+
);
|
|
66
|
+
}) }),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between text-[10px] text-slate-500", children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: s.loading ? "Loading\u2026" : `${s.items.length} of ${s.total}` }),
|
|
69
|
+
s.hasMore && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "text-indigo-300", onClick: () => void browser.more(), children: "More" })
|
|
70
|
+
] }),
|
|
71
|
+
s.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: s.error }),
|
|
72
|
+
footer
|
|
73
|
+
] });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/stickers/StickerInsertPanel.tsx
|
|
77
|
+
var import_react2 = require("react");
|
|
78
|
+
var import_stickers2 = require("@pixerate/editor/stickers");
|
|
79
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
80
|
+
var StickerInsertPanel = ({ provider, host, onInserted, className }) => {
|
|
81
|
+
const [tint, setTint] = (0, import_react2.useState)(null);
|
|
82
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
83
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs ${className ?? ""}`, "data-testid": "sticker-insert", children: [
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
86
|
+
StickerLibraryPicker,
|
|
87
|
+
{
|
|
88
|
+
provider,
|
|
89
|
+
label: "Insert sticker",
|
|
90
|
+
onPick: (it) => {
|
|
91
|
+
setBusy(true);
|
|
92
|
+
setError(null);
|
|
93
|
+
(0, import_stickers2.insertSticker)(provider, host, { ref: it.ref, ...tint && it.tintable ? { color: tint } : {} }).then((r) => onInserted?.(r)).catch((e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(false));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", "aria-label": "Tint stickers", checked: tint !== null, onChange: (e) => setTint(e.target.checked ? "#2563eb" : null) }),
|
|
99
|
+
" Tint",
|
|
100
|
+
tint !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "color", "aria-label": "Sticker tint", value: tint, onChange: (e) => setTint(e.target.value) }),
|
|
101
|
+
busy && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-slate-500", children: "Inserting\u2026" })
|
|
102
|
+
] }),
|
|
103
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: error })
|
|
104
|
+
] });
|
|
105
|
+
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
StickerInsertPanel,
|
|
109
|
+
StickerLibraryPicker
|
|
110
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StickerLibraryPicker
|
|
3
|
+
} from "../chunk-KYMDNWSX.js";
|
|
4
|
+
|
|
5
|
+
// src/stickers/StickerInsertPanel.tsx
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { insertSticker } from "@pixerate/editor/stickers";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var StickerInsertPanel = ({ provider, host, onInserted, className }) => {
|
|
10
|
+
const [tint, setTint] = useState(null);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const [busy, setBusy] = useState(false);
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-1.5 text-xs ${className ?? ""}`, "data-testid": "sticker-insert", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
StickerLibraryPicker,
|
|
16
|
+
{
|
|
17
|
+
provider,
|
|
18
|
+
label: "Insert sticker",
|
|
19
|
+
onPick: (it) => {
|
|
20
|
+
setBusy(true);
|
|
21
|
+
setError(null);
|
|
22
|
+
insertSticker(provider, host, { ref: it.ref, ...tint && it.tintable ? { color: tint } : {} }).then((r) => onInserted?.(r)).catch((e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(false));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2", children: [
|
|
27
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", "aria-label": "Tint stickers", checked: tint !== null, onChange: (e) => setTint(e.target.checked ? "#2563eb" : null) }),
|
|
28
|
+
" Tint",
|
|
29
|
+
tint !== null && /* @__PURE__ */ jsx("input", { type: "color", "aria-label": "Sticker tint", value: tint, onChange: (e) => setTint(e.target.value) }),
|
|
30
|
+
busy && /* @__PURE__ */ jsx("span", { className: "text-slate-500", children: "Inserting\u2026" })
|
|
31
|
+
] }),
|
|
32
|
+
error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-[11px] text-rose-400", children: error })
|
|
33
|
+
] });
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
StickerInsertPanel,
|
|
37
|
+
StickerLibraryPicker
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.171.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,16 @@
|
|
|
34
34
|
"default": "./dist/effects/index.cjs"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
+
"./stickers": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/stickers/index.d.ts",
|
|
40
|
+
"default": "./dist/stickers/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/stickers/index.d.cts",
|
|
44
|
+
"default": "./dist/stickers/index.cjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
37
47
|
"./spreadsheet": {
|
|
38
48
|
"import": {
|
|
39
49
|
"types": "./dist/spreadsheet/index.d.ts",
|
|
@@ -254,7 +264,7 @@
|
|
|
254
264
|
"dependencies": {},
|
|
255
265
|
"peerDependencies": {
|
|
256
266
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
267
|
+
"@pixerate/editor": ">=0.250.0 <1.0.0-0",
|
|
258
268
|
"@tiptap/core": "^2.27.3",
|
|
259
269
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
270
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +315,7 @@
|
|
|
305
315
|
"tsup": "^9.0.0",
|
|
306
316
|
"typescript": "^5.7.3",
|
|
307
317
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
318
|
+
"@pixerate/editor": "0.250.0"
|
|
309
319
|
},
|
|
310
320
|
"scripts": {
|
|
311
321
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|