@bensitu/image-editor 1.4.0 → 1.4.2
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/image-editor.esm.js +551 -185
- package/dist/image-editor.esm.js.map +3 -3
- package/dist/image-editor.esm.min.js +3 -3
- package/dist/image-editor.esm.min.js.map +3 -3
- package/dist/image-editor.esm.min.mjs +3 -3
- package/dist/image-editor.esm.min.mjs.map +3 -3
- package/dist/image-editor.esm.mjs +551 -185
- package/dist/image-editor.esm.mjs.map +3 -3
- package/dist/image-editor.js +551 -185
- package/dist/image-editor.js.map +3 -3
- package/dist/image-editor.min.js +2 -2
- package/dist/image-editor.min.js.map +3 -3
- package/image-editor.d.ts +24 -12
- package/package.json +3 -4
- package/src/image-editor.js +608 -188
package/image-editor.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
// image-editor.d.ts - TypeScript declarations for @bensitu/image-editor
|
|
2
2
|
|
|
3
3
|
declare module '@bensitu/image-editor' {
|
|
4
|
-
|
|
4
|
+
export interface FabricCanvas {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface FabricObject {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FabricImage extends FabricObject {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
5
16
|
|
|
6
17
|
export interface LabelOptions {
|
|
7
18
|
/** Receives the mask and its stable zero-based creation index (`mask.maskId - 1`). */
|
|
@@ -38,7 +49,7 @@ declare module '@bensitu/image-editor' {
|
|
|
38
49
|
downsampleOnLoad?: boolean;
|
|
39
50
|
downsampleMaxWidth?: number;
|
|
40
51
|
downsampleMaxHeight?: number;
|
|
41
|
-
downsampleQuality?: number;
|
|
52
|
+
downsampleQuality?: number | null;
|
|
42
53
|
preserveSourceFormat?: boolean;
|
|
43
54
|
downsampleMimeType?: 'jpeg' | 'jpg' | 'png' | 'webp' | 'image/jpeg' | 'image/png' | 'image/webp' | null;
|
|
44
55
|
imageLoadTimeoutMs?: number;
|
|
@@ -96,17 +107,17 @@ declare module '@bensitu/image-editor' {
|
|
|
96
107
|
|
|
97
108
|
export interface MaskConfig {
|
|
98
109
|
shape?: 'rect' | 'circle' | 'ellipse' | 'polygon' | string;
|
|
99
|
-
width?: number | string | ((canvas:
|
|
100
|
-
height?: number | string | ((canvas:
|
|
101
|
-
radius?: number | string | ((canvas:
|
|
102
|
-
rx?: number | string | ((canvas:
|
|
103
|
-
ry?: number | string | ((canvas:
|
|
110
|
+
width?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
111
|
+
height?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
112
|
+
radius?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
113
|
+
rx?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
114
|
+
ry?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
104
115
|
points?: Array<{ x: number; y: number }> | Array<[number, number]>;
|
|
105
116
|
color?: string;
|
|
106
117
|
alpha?: number;
|
|
107
118
|
gap?: number;
|
|
108
|
-
left?: number | string | ((canvas:
|
|
109
|
-
top?: number | string | ((canvas:
|
|
119
|
+
left?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
120
|
+
top?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
110
121
|
angle?: number;
|
|
111
122
|
selectable?: boolean;
|
|
112
123
|
hasControls?: boolean;
|
|
@@ -116,8 +127,8 @@ declare module '@bensitu/image-editor' {
|
|
|
116
127
|
transparentCorners?: boolean;
|
|
117
128
|
strokeUniform?: boolean;
|
|
118
129
|
styles?: Record<string, any>;
|
|
119
|
-
fabricGenerator?: (config: MaskConfig, canvas:
|
|
120
|
-
onCreate?: (mask: MaskObject, canvas:
|
|
130
|
+
fabricGenerator?: (config: MaskConfig, canvas: FabricCanvas, options: ImageEditorOptions) => FabricObject;
|
|
131
|
+
onCreate?: (mask: MaskObject, canvas: FabricCanvas) => void;
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
export interface MaskObject extends FabricObject {
|
|
@@ -153,7 +164,7 @@ declare module '@bensitu/image-editor' {
|
|
|
153
164
|
|
|
154
165
|
export class ImageEditor {
|
|
155
166
|
readonly options: ImageEditorOptions;
|
|
156
|
-
readonly canvas:
|
|
167
|
+
readonly canvas: FabricCanvas | null;
|
|
157
168
|
readonly canvasElement: HTMLCanvasElement | null;
|
|
158
169
|
readonly containerElement: HTMLElement | null;
|
|
159
170
|
readonly placeholderElement: HTMLElement | null;
|
|
@@ -175,6 +186,7 @@ declare module '@bensitu/image-editor' {
|
|
|
175
186
|
init(idMap?: ElementIdMap): void;
|
|
176
187
|
loadImage(imageBase64: string, options?: LoadImageOptions): Promise<void>;
|
|
177
188
|
isImageLoaded(): boolean;
|
|
189
|
+
isBusy(): boolean;
|
|
178
190
|
|
|
179
191
|
/** Public callers should pass only `factor`; internal history control options are intentionally not exposed. */
|
|
180
192
|
scaleImage(factor: number): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bensitu/image-editor",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Lightweight canvas-based image editor",
|
|
5
5
|
"main": "./dist/image-editor.js",
|
|
6
6
|
"module": "./dist/image-editor.esm.mjs",
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"fabric": "^5.5.2"
|
|
35
35
|
},
|
|
36
|
-
"overrides": {
|
|
37
|
-
"canvas": "^3.2.3"
|
|
38
|
-
},
|
|
39
36
|
"publishConfig": {
|
|
40
37
|
"access": "public"
|
|
41
38
|
},
|
|
@@ -44,9 +41,11 @@
|
|
|
44
41
|
"@babel/core": "^7.22.9",
|
|
45
42
|
"@babel/preset-env": "^7.22.9",
|
|
46
43
|
"@eslint/js": "^10.0.1",
|
|
44
|
+
"canvas": "^3.2.3",
|
|
47
45
|
"esbuild": "^0.28.0",
|
|
48
46
|
"esbuild-plugin-babel": "^0.2.3",
|
|
49
47
|
"eslint": "^10.4.0",
|
|
48
|
+
"fabric": "^5.5.2",
|
|
50
49
|
"globals": "^17.6.0"
|
|
51
50
|
},
|
|
52
51
|
"browserslist": [
|