@pixerate/editor-react 0.122.0 → 0.123.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-VR3JON4V.js → chunk-UNKMMYPZ.js} +37 -1
- package/dist/image-editor/ChannelsPanel.d.cts +3 -2
- package/dist/image-editor/ChannelsPanel.d.ts +3 -2
- package/dist/image-editor/index.cjs +36 -0
- package/dist/image-editor/index.js +1 -1
- package/dist/index.cjs +36 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -3114,7 +3114,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
3114
3114
|
|
|
3115
3115
|
// src/image-editor/ChannelsPanel.tsx
|
|
3116
3116
|
import { useEffect as useEffect10, useRef as useRef7, useState as useState13 } from "react";
|
|
3117
|
-
import { channelThumbnail, selectionModeFromModifiers } from "@pixerate/editor/image-editor";
|
|
3117
|
+
import { MASK_FILE_ACCEPT, channelThumbnail, downloadMaskImage, openMaskFile, selectionModeFromModifiers } from "@pixerate/editor/image-editor";
|
|
3118
3118
|
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3119
3119
|
var btn2 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
3120
3120
|
var ChannelThumb = ({ channel, size }) => {
|
|
@@ -3138,6 +3138,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
3138
3138
|
const [activeId, setActiveId] = useState13(null);
|
|
3139
3139
|
const [renaming, setRenaming] = useState13(null);
|
|
3140
3140
|
const [error, setError] = useState13(null);
|
|
3141
|
+
const fileInput = useRef7(null);
|
|
3141
3142
|
const channels = controller.getChannels();
|
|
3142
3143
|
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
3143
3144
|
const hasSelection = Boolean(controller.getSelection());
|
|
@@ -3150,6 +3151,15 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
3150
3151
|
setError(err instanceof Error ? err.message : String(err));
|
|
3151
3152
|
}
|
|
3152
3153
|
};
|
|
3154
|
+
const importFile = async (file) => {
|
|
3155
|
+
if (!file) return;
|
|
3156
|
+
setError(null);
|
|
3157
|
+
try {
|
|
3158
|
+
setActiveId((await openMaskFile(controller, file)).id);
|
|
3159
|
+
} catch (err) {
|
|
3160
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
3161
|
+
}
|
|
3162
|
+
};
|
|
3153
3163
|
return /* @__PURE__ */ jsxs15("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
3154
3164
|
/* @__PURE__ */ jsxs15("div", { className: "flex items-center justify-between", children: [
|
|
3155
3165
|
/* @__PURE__ */ jsx17("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
@@ -3221,6 +3231,32 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
3221
3231
|
}),
|
|
3222
3232
|
children: "Delete"
|
|
3223
3233
|
}
|
|
3234
|
+
),
|
|
3235
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: btn2(), title: "Load a mask image (white = selected) into a new channel", onClick: () => fileInput.current?.click(), children: "Import\u2026" }),
|
|
3236
|
+
/* @__PURE__ */ jsx17(
|
|
3237
|
+
"button",
|
|
3238
|
+
{
|
|
3239
|
+
type: "button",
|
|
3240
|
+
className: btn2(),
|
|
3241
|
+
disabled: !active && !hasSelection,
|
|
3242
|
+
title: active ? "Save the channel as a greyscale PNG" : "Save the selection as a greyscale PNG",
|
|
3243
|
+
onClick: () => attempt(() => downloadMaskImage(controller, active ? { channelId: active.id } : "selection", active?.name ?? "selection")),
|
|
3244
|
+
children: "Export PNG"
|
|
3245
|
+
}
|
|
3246
|
+
),
|
|
3247
|
+
/* @__PURE__ */ jsx17(
|
|
3248
|
+
"input",
|
|
3249
|
+
{
|
|
3250
|
+
ref: fileInput,
|
|
3251
|
+
type: "file",
|
|
3252
|
+
accept: MASK_FILE_ACCEPT,
|
|
3253
|
+
hidden: true,
|
|
3254
|
+
"data-testid": "channel-import-input",
|
|
3255
|
+
onChange: (e) => {
|
|
3256
|
+
void importFile(e.currentTarget.files?.[0]);
|
|
3257
|
+
e.currentTarget.value = "";
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3224
3260
|
)
|
|
3225
3261
|
] }),
|
|
3226
3262
|
error && /* @__PURE__ */ jsx17("p", { role: "alert", className: "text-destructive", children: error })
|
|
@@ -9,7 +9,8 @@ export interface ChannelsPanelProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* The Channels panel: the alpha channels (saved selections) with thumbnails, an eye to show
|
|
11
11
|
* each as a tint, click to load it as the selection (Shift adds, Alt subtracts, both
|
|
12
|
-
* intersect), double-click to rename; Save Selection, Duplicate and Delete;
|
|
13
|
-
*
|
|
12
|
+
* intersect), double-click to rename; Save Selection, Duplicate and Delete; Import (a mask
|
|
13
|
+
* image into a new channel) and Export PNG (the active channel, else the selection); and the
|
|
14
|
+
* Quick Mask mode switch (Q on the canvas). Every change is one undo step on the controller.
|
|
14
15
|
*/
|
|
15
16
|
export declare const ChannelsPanel: React.FC<ChannelsPanelProps>;
|
|
@@ -9,7 +9,8 @@ export interface ChannelsPanelProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* The Channels panel: the alpha channels (saved selections) with thumbnails, an eye to show
|
|
11
11
|
* each as a tint, click to load it as the selection (Shift adds, Alt subtracts, both
|
|
12
|
-
* intersect), double-click to rename; Save Selection, Duplicate and Delete;
|
|
13
|
-
*
|
|
12
|
+
* intersect), double-click to rename; Save Selection, Duplicate and Delete; Import (a mask
|
|
13
|
+
* image into a new channel) and Export PNG (the active channel, else the selection); and the
|
|
14
|
+
* Quick Mask mode switch (Q on the canvas). Every change is one undo step on the controller.
|
|
14
15
|
*/
|
|
15
16
|
export declare const ChannelsPanel: React.FC<ChannelsPanelProps>;
|
|
@@ -5067,6 +5067,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
5067
5067
|
const [activeId, setActiveId] = (0, import_react27.useState)(null);
|
|
5068
5068
|
const [renaming, setRenaming] = (0, import_react27.useState)(null);
|
|
5069
5069
|
const [error, setError] = (0, import_react27.useState)(null);
|
|
5070
|
+
const fileInput = (0, import_react27.useRef)(null);
|
|
5070
5071
|
const channels = controller.getChannels();
|
|
5071
5072
|
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
5072
5073
|
const hasSelection = Boolean(controller.getSelection());
|
|
@@ -5079,6 +5080,15 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
5079
5080
|
setError(err instanceof Error ? err.message : String(err));
|
|
5080
5081
|
}
|
|
5081
5082
|
};
|
|
5083
|
+
const importFile = async (file) => {
|
|
5084
|
+
if (!file) return;
|
|
5085
|
+
setError(null);
|
|
5086
|
+
try {
|
|
5087
|
+
setActiveId((await (0, import_image_editor16.openMaskFile)(controller, file)).id);
|
|
5088
|
+
} catch (err) {
|
|
5089
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
5090
|
+
}
|
|
5091
|
+
};
|
|
5082
5092
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
5083
5093
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
5084
5094
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
@@ -5150,6 +5160,32 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
5150
5160
|
}),
|
|
5151
5161
|
children: "Delete"
|
|
5152
5162
|
}
|
|
5163
|
+
),
|
|
5164
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", className: btn2(), title: "Load a mask image (white = selected) into a new channel", onClick: () => fileInput.current?.click(), children: "Import\u2026" }),
|
|
5165
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5166
|
+
"button",
|
|
5167
|
+
{
|
|
5168
|
+
type: "button",
|
|
5169
|
+
className: btn2(),
|
|
5170
|
+
disabled: !active && !hasSelection,
|
|
5171
|
+
title: active ? "Save the channel as a greyscale PNG" : "Save the selection as a greyscale PNG",
|
|
5172
|
+
onClick: () => attempt(() => (0, import_image_editor16.downloadMaskImage)(controller, active ? { channelId: active.id } : "selection", active?.name ?? "selection")),
|
|
5173
|
+
children: "Export PNG"
|
|
5174
|
+
}
|
|
5175
|
+
),
|
|
5176
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5177
|
+
"input",
|
|
5178
|
+
{
|
|
5179
|
+
ref: fileInput,
|
|
5180
|
+
type: "file",
|
|
5181
|
+
accept: import_image_editor16.MASK_FILE_ACCEPT,
|
|
5182
|
+
hidden: true,
|
|
5183
|
+
"data-testid": "channel-import-input",
|
|
5184
|
+
onChange: (e) => {
|
|
5185
|
+
void importFile(e.currentTarget.files?.[0]);
|
|
5186
|
+
e.currentTarget.value = "";
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
5153
5189
|
)
|
|
5154
5190
|
] }),
|
|
5155
5191
|
error && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
package/dist/index.cjs
CHANGED
|
@@ -8781,6 +8781,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
8781
8781
|
const [activeId, setActiveId] = (0, import_react63.useState)(null);
|
|
8782
8782
|
const [renaming, setRenaming] = (0, import_react63.useState)(null);
|
|
8783
8783
|
const [error, setError] = (0, import_react63.useState)(null);
|
|
8784
|
+
const fileInput = (0, import_react63.useRef)(null);
|
|
8784
8785
|
const channels = controller.getChannels();
|
|
8785
8786
|
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
8786
8787
|
const hasSelection = Boolean(controller.getSelection());
|
|
@@ -8793,6 +8794,15 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
8793
8794
|
setError(err instanceof Error ? err.message : String(err));
|
|
8794
8795
|
}
|
|
8795
8796
|
};
|
|
8797
|
+
const importFile = async (file) => {
|
|
8798
|
+
if (!file) return;
|
|
8799
|
+
setError(null);
|
|
8800
|
+
try {
|
|
8801
|
+
setActiveId((await (0, import_image_editor16.openMaskFile)(controller, file)).id);
|
|
8802
|
+
} catch (err) {
|
|
8803
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
8804
|
+
}
|
|
8805
|
+
};
|
|
8796
8806
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
8797
8807
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
8798
8808
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
@@ -8864,6 +8874,32 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
8864
8874
|
}),
|
|
8865
8875
|
children: "Delete"
|
|
8866
8876
|
}
|
|
8877
|
+
),
|
|
8878
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), title: "Load a mask image (white = selected) into a new channel", onClick: () => fileInput.current?.click(), children: "Import\u2026" }),
|
|
8879
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8880
|
+
"button",
|
|
8881
|
+
{
|
|
8882
|
+
type: "button",
|
|
8883
|
+
className: btn2(),
|
|
8884
|
+
disabled: !active && !hasSelection,
|
|
8885
|
+
title: active ? "Save the channel as a greyscale PNG" : "Save the selection as a greyscale PNG",
|
|
8886
|
+
onClick: () => attempt(() => (0, import_image_editor16.downloadMaskImage)(controller, active ? { channelId: active.id } : "selection", active?.name ?? "selection")),
|
|
8887
|
+
children: "Export PNG"
|
|
8888
|
+
}
|
|
8889
|
+
),
|
|
8890
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8891
|
+
"input",
|
|
8892
|
+
{
|
|
8893
|
+
ref: fileInput,
|
|
8894
|
+
type: "file",
|
|
8895
|
+
accept: import_image_editor16.MASK_FILE_ACCEPT,
|
|
8896
|
+
hidden: true,
|
|
8897
|
+
"data-testid": "channel-import-input",
|
|
8898
|
+
onChange: (e) => {
|
|
8899
|
+
void importFile(e.currentTarget.files?.[0]);
|
|
8900
|
+
e.currentTarget.value = "";
|
|
8901
|
+
}
|
|
8902
|
+
}
|
|
8867
8903
|
)
|
|
8868
8904
|
] }),
|
|
8869
8905
|
error && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.123.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.187.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.187.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|