@bensitu/image-editor 1.5.2 → 2.0.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/README.md +367 -518
- package/dist/cjs/index.cjs +5422 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/animation/animation-queue.js +67 -0
- package/dist/esm/animation/animation-queue.js.map +1 -0
- package/dist/esm/core/callback-reporter.js +23 -0
- package/dist/esm/core/callback-reporter.js.map +1 -0
- package/dist/esm/core/default-options.js +322 -0
- package/dist/esm/core/default-options.js.map +1 -0
- package/dist/esm/core/errors.js +156 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/operation-guard.js +129 -0
- package/dist/esm/core/operation-guard.js.map +1 -0
- package/dist/esm/core/public-types.js +4 -0
- package/dist/esm/core/public-types.js.map +1 -0
- package/dist/esm/core/state-serializer.js +251 -0
- package/dist/esm/core/state-serializer.js.map +1 -0
- package/dist/esm/crop/crop-controller.js +403 -0
- package/dist/esm/crop/crop-controller.js.map +1 -0
- package/dist/esm/export/export-format.js +53 -0
- package/dist/esm/export/export-format.js.map +1 -0
- package/dist/esm/export/export-service.js +596 -0
- package/dist/esm/export/export-service.js.map +1 -0
- package/dist/esm/fabric/fabric-adapter.js +37 -0
- package/dist/esm/fabric/fabric-adapter.js.map +1 -0
- package/dist/esm/fabric/fabric-animation.js +37 -0
- package/dist/esm/fabric/fabric-animation.js.map +1 -0
- package/dist/esm/history/command.js +2 -0
- package/dist/esm/history/command.js.map +1 -0
- package/dist/esm/history/history-manager.js +103 -0
- package/dist/esm/history/history-manager.js.map +1 -0
- package/dist/esm/image/image-loader.js +245 -0
- package/dist/esm/image/image-loader.js.map +1 -0
- package/dist/esm/image/image-resampler.js +55 -0
- package/dist/esm/image/image-resampler.js.map +1 -0
- package/dist/esm/image/layout-manager.js +224 -0
- package/dist/esm/image/layout-manager.js.map +1 -0
- package/dist/esm/image/transform-controller.js +132 -0
- package/dist/esm/image/transform-controller.js.map +1 -0
- package/dist/esm/image-editor.js +1740 -0
- package/dist/esm/image-editor.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mask/mask-factory.js +332 -0
- package/dist/esm/mask/mask-factory.js.map +1 -0
- package/dist/esm/mask/mask-label-manager.js +120 -0
- package/dist/esm/mask/mask-label-manager.js.map +1 -0
- package/dist/esm/mask/mask-list.js +47 -0
- package/dist/esm/mask/mask-list.js.map +1 -0
- package/dist/esm/mask/mask-style.js +182 -0
- package/dist/esm/mask/mask-style.js.map +1 -0
- package/dist/esm/ui/dom-bindings.js +60 -0
- package/dist/esm/ui/dom-bindings.js.map +1 -0
- package/dist/esm/ui/ui-state.js +25 -0
- package/dist/esm/ui/ui-state.js.map +1 -0
- package/dist/esm/ui/visibility-state.js +11 -0
- package/dist/esm/ui/visibility-state.js.map +1 -0
- package/dist/esm/utils/canvas-region.js +100 -0
- package/dist/esm/utils/canvas-region.js.map +1 -0
- package/dist/esm/utils/dom.js +6 -0
- package/dist/esm/utils/dom.js.map +1 -0
- package/dist/esm/utils/file.js +53 -0
- package/dist/esm/utils/file.js.map +1 -0
- package/dist/esm/utils/number.js +24 -0
- package/dist/esm/utils/number.js.map +1 -0
- package/dist/esm/utils/timeout.js +17 -0
- package/dist/esm/utils/timeout.js.map +1 -0
- package/dist/types/animation/animation-queue.d.ts +111 -0
- package/dist/types/animation/animation-queue.d.ts.map +1 -0
- package/dist/types/core/callback-reporter.d.ts +125 -0
- package/dist/types/core/callback-reporter.d.ts.map +1 -0
- package/dist/types/core/default-options.d.ts +56 -0
- package/dist/types/core/default-options.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +142 -0
- package/dist/types/core/errors.d.ts.map +1 -0
- package/dist/types/core/operation-guard.d.ts +192 -0
- package/dist/types/core/operation-guard.d.ts.map +1 -0
- package/dist/types/core/public-types.d.ts +678 -0
- package/dist/types/core/public-types.d.ts.map +1 -0
- package/dist/types/core/state-serializer.d.ts +301 -0
- package/dist/types/core/state-serializer.d.ts.map +1 -0
- package/dist/types/crop/crop-controller.d.ts +407 -0
- package/dist/types/crop/crop-controller.d.ts.map +1 -0
- package/dist/types/export/export-format.d.ts +136 -0
- package/dist/types/export/export-format.d.ts.map +1 -0
- package/dist/types/export/export-service.d.ts +333 -0
- package/dist/types/export/export-service.d.ts.map +1 -0
- package/dist/types/fabric/fabric-adapter.d.ts +74 -0
- package/dist/types/fabric/fabric-adapter.d.ts.map +1 -0
- package/dist/types/fabric/fabric-animation.d.ts +141 -0
- package/dist/types/fabric/fabric-animation.d.ts.map +1 -0
- package/dist/types/history/command.d.ts +16 -0
- package/dist/types/history/command.d.ts.map +1 -0
- package/dist/types/history/history-manager.d.ts +129 -0
- package/dist/types/history/history-manager.d.ts.map +1 -0
- package/dist/types/image/image-loader.d.ts +265 -0
- package/dist/types/image/image-loader.d.ts.map +1 -0
- package/dist/types/image/image-resampler.d.ts +139 -0
- package/dist/types/image/image-resampler.d.ts.map +1 -0
- package/dist/types/image/layout-manager.d.ts +255 -0
- package/dist/types/image/layout-manager.d.ts.map +1 -0
- package/dist/types/image/transform-controller.d.ts +287 -0
- package/dist/types/image/transform-controller.d.ts.map +1 -0
- package/dist/types/image-editor.d.ts +650 -0
- package/dist/types/image-editor.d.ts.map +1 -0
- package/dist/types/index.d.cts +31 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mask/mask-factory.d.ts +209 -0
- package/dist/types/mask/mask-factory.d.ts.map +1 -0
- package/dist/types/mask/mask-label-manager.d.ts +171 -0
- package/dist/types/mask/mask-label-manager.d.ts.map +1 -0
- package/dist/types/mask/mask-list.d.ts +144 -0
- package/dist/types/mask/mask-list.d.ts.map +1 -0
- package/dist/types/mask/mask-style.d.ts +338 -0
- package/dist/types/mask/mask-style.d.ts.map +1 -0
- package/dist/types/ui/dom-bindings.d.ts +103 -0
- package/dist/types/ui/dom-bindings.d.ts.map +1 -0
- package/dist/types/ui/ui-state.d.ts +112 -0
- package/dist/types/ui/ui-state.d.ts.map +1 -0
- package/dist/types/ui/visibility-state.d.ts +77 -0
- package/dist/types/ui/visibility-state.d.ts.map +1 -0
- package/dist/types/utils/canvas-region.d.ts +177 -0
- package/dist/types/utils/canvas-region.d.ts.map +1 -0
- package/dist/types/utils/dom.d.ts +26 -0
- package/dist/types/utils/dom.d.ts.map +1 -0
- package/dist/types/utils/file.d.ts +80 -0
- package/dist/types/utils/file.d.ts.map +1 -0
- package/dist/types/utils/number.d.ts +132 -0
- package/dist/types/utils/number.d.ts.map +1 -0
- package/dist/types/utils/timeout.d.ts +84 -0
- package/dist/types/utils/timeout.d.ts.map +1 -0
- package/dist/umd/image-editor.umd.js +2 -0
- package/dist/umd/image-editor.umd.js.map +1 -0
- package/package.json +72 -66
- package/dist/image-editor.cjs +0 -4407
- package/dist/image-editor.cjs.map +0 -7
- package/dist/image-editor.esm.js +0 -4376
- package/dist/image-editor.esm.js.map +0 -7
- package/dist/image-editor.esm.min.js +0 -9
- package/dist/image-editor.esm.min.js.map +0 -7
- package/dist/image-editor.esm.min.mjs +0 -9
- package/dist/image-editor.esm.min.mjs.map +0 -7
- package/dist/image-editor.esm.mjs +0 -4376
- package/dist/image-editor.esm.mjs.map +0 -7
- package/dist/image-editor.js +0 -4373
- package/dist/image-editor.js.map +0 -7
- package/dist/image-editor.min.js +0 -9
- package/dist/image-editor.min.js.map +0 -7
- package/image-editor.d.ts +0 -271
- package/src/browser.js +0 -11
- package/src/esm.js +0 -9
- package/src/image-editor.js +0 -5013
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public interfaces and types for `@bensitu/image-editor`.
|
|
3
|
+
*
|
|
4
|
+
* All types declared here are re-exported from the package root
|
|
5
|
+
* (`src/index.ts`) so consumers can import them directly:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import type { ImageEditorOptions, MaskConfig } from '@bensitu/image-editor';
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type * as FabricNS from 'fabric';
|
|
14
|
+
/**
|
|
15
|
+
* The full Fabric.js v7 module type (i.e. `import * as fabric from 'fabric'`).
|
|
16
|
+
* Used when consumers need to type the value they pass into
|
|
17
|
+
* `new ImageEditor(fabric, options)`.
|
|
18
|
+
*/
|
|
19
|
+
export type FabricModule = Omit<typeof FabricNS, 'default'> & {
|
|
20
|
+
default?: unknown;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Mutually exclusive image layout mode used by {@link ImageEditor.setLayoutMode}.
|
|
24
|
+
*
|
|
25
|
+
* - `'fit'` scales the image down to fit inside the visible workspace.
|
|
26
|
+
* - `'cover'` scales large images down to cover the visible workspace and
|
|
27
|
+
* keeps overflowing axes scrollable.
|
|
28
|
+
* - `'expand'` grows the canvas to fit the loaded image.
|
|
29
|
+
*/
|
|
30
|
+
export type LayoutMode = 'fit' | 'cover' | 'expand';
|
|
31
|
+
/**
|
|
32
|
+
* Canonical alpha-aware MIME types supported by export and downsample paths.
|
|
33
|
+
*
|
|
34
|
+
* Used by `ImageEditorOptions.downsampleMimeType` and by the
|
|
35
|
+
* export pipeline when emitting MIME strings.
|
|
36
|
+
*/
|
|
37
|
+
export type ImageMimeType = 'image/jpeg' | 'image/png' | 'image/webp';
|
|
38
|
+
/**
|
|
39
|
+
* Accepted file-type tokens for `Base64ExportOptions` and
|
|
40
|
+
* `ImageFileExportOptions`. The export pipeline normalizes `'jpg'` to
|
|
41
|
+
* `'jpeg'` and accepts both bare format tokens (`'png'`) and full MIME types
|
|
42
|
+
* (`'image/png'`) for ergonomic interop.
|
|
43
|
+
*/
|
|
44
|
+
export type ImageFileType = 'jpeg' | 'jpg' | 'png' | 'webp' | 'image/jpeg' | 'image/png' | 'image/webp';
|
|
45
|
+
/**
|
|
46
|
+
* Normalized format token after collapsing `'jpg'` to `'jpeg'` and stripping
|
|
47
|
+
* the `image/` MIME prefix. Produced by `export/export-format.ts` and consumed
|
|
48
|
+
* by Fabric's `format` argument.
|
|
49
|
+
*/
|
|
50
|
+
export type NormalizedImageFormat = 'jpeg' | 'png' | 'webp';
|
|
51
|
+
/**
|
|
52
|
+
* Export region for base64, File, and download exports.
|
|
53
|
+
*
|
|
54
|
+
* - `'image'` clips to the current image bounding box.
|
|
55
|
+
* - `'canvas'` exports the full Fabric canvas.
|
|
56
|
+
*/
|
|
57
|
+
export type ExportArea = 'image' | 'canvas';
|
|
58
|
+
/**
|
|
59
|
+
* Intermediate raster format used by `applyCrop`.
|
|
60
|
+
*
|
|
61
|
+
* `'source'` preserves the MIME type of the image currently committed to
|
|
62
|
+
* the Fabric canvas when it is known, falling back to PNG otherwise.
|
|
63
|
+
*/
|
|
64
|
+
export type CropExportFileType = ImageFileType | 'source';
|
|
65
|
+
/**
|
|
66
|
+
* A Fabric.js object augmented with mask-specific runtime properties.
|
|
67
|
+
* Returned from {@link ImageEditor.createMask} and exposed in mask-related
|
|
68
|
+
* event callbacks.
|
|
69
|
+
*
|
|
70
|
+
* The marker flags `isCropRect` and `maskLabel` identify session-only objects
|
|
71
|
+
* (the active crop rectangle and label overlays). They are filtered out of
|
|
72
|
+
* history snapshots by the state serializer.
|
|
73
|
+
*/
|
|
74
|
+
export interface MaskObject extends FabricNS.FabricObject {
|
|
75
|
+
/** Unique numeric identifier assigned at creation time. */
|
|
76
|
+
maskId: number;
|
|
77
|
+
/** Stable internal identifier used to restore overlapping masks deterministically. */
|
|
78
|
+
maskUid?: string;
|
|
79
|
+
/** Human-readable label shown in the mask list (`maskName` option + id). */
|
|
80
|
+
maskName: string;
|
|
81
|
+
/** Original opacity stored to support hover highlight / restore. */
|
|
82
|
+
originalAlpha: number;
|
|
83
|
+
/** Original stroke captured for hover/selection style restore. */
|
|
84
|
+
originalStroke?: FabricNS.TFiller | string | null;
|
|
85
|
+
/** Original stroke width captured for hover/selection style restore. */
|
|
86
|
+
originalStrokeWidth?: number;
|
|
87
|
+
/** Active label overlay object, if currently displayed. */
|
|
88
|
+
labelObject?: FabricNS.FabricObject;
|
|
89
|
+
/** Marker flag — `true` only on the crop rectangle, never on real masks. */
|
|
90
|
+
isCropRect?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Marker flag set on label-overlay text objects so the state serializer
|
|
93
|
+
* can exclude them from history snapshots.
|
|
94
|
+
*/
|
|
95
|
+
maskLabel?: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Type guard — returns `true` when `object` carries the runtime mask metadata
|
|
99
|
+
* (`maskId: number`) so consumers can filter `canvas.getObjects`
|
|
100
|
+
* deterministically.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isMaskObject(object: FabricNS.FabricObject): object is MaskObject;
|
|
103
|
+
/**
|
|
104
|
+
* Public operation/reason associated with lifecycle and state callbacks.
|
|
105
|
+
*/
|
|
106
|
+
export type ImageEditorOperation = 'init' | 'loadImage' | 'loadFromState' | 'saveState' | 'scaleImage' | 'rotateImage' | 'resetImageTransform' | 'createMask' | 'removeSelectedMask' | 'removeAllMasks' | 'mergeMasks' | 'enterCropMode' | 'applyCrop' | 'cancelCrop' | 'undo' | 'redo' | 'exportImageBase64' | 'exportImageFile' | 'downloadImage' | 'dispose';
|
|
107
|
+
/**
|
|
108
|
+
* Context passed to lifecycle and state callbacks.
|
|
109
|
+
*/
|
|
110
|
+
export interface ImageEditorCallbackContext {
|
|
111
|
+
/** Public operation/reason that caused this notification. */
|
|
112
|
+
operation: ImageEditorOperation;
|
|
113
|
+
/**
|
|
114
|
+
* True when the callback was caused by an internal composite operation
|
|
115
|
+
* such as merge, crop, undo, or redo.
|
|
116
|
+
*/
|
|
117
|
+
isInternalOperation?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Snapshot of the currently committed image and its display geometry.
|
|
121
|
+
*/
|
|
122
|
+
export interface ImageInfo {
|
|
123
|
+
width: number;
|
|
124
|
+
height: number;
|
|
125
|
+
displayWidth: number;
|
|
126
|
+
displayHeight: number;
|
|
127
|
+
scale: number;
|
|
128
|
+
rotation: number;
|
|
129
|
+
canvasWidth: number;
|
|
130
|
+
canvasHeight: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Safe snapshot of externally visible editor state.
|
|
134
|
+
*/
|
|
135
|
+
export interface ImageEditorState {
|
|
136
|
+
hasImage: boolean;
|
|
137
|
+
image: ImageInfo | null;
|
|
138
|
+
maskCount: number;
|
|
139
|
+
currentScale: number;
|
|
140
|
+
currentRotation: number;
|
|
141
|
+
isBusy: boolean;
|
|
142
|
+
isCropMode: boolean;
|
|
143
|
+
canUndo: boolean;
|
|
144
|
+
canRedo: boolean;
|
|
145
|
+
canvasWidth: number;
|
|
146
|
+
canvasHeight: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Public selection payload for mask selection changes.
|
|
150
|
+
*/
|
|
151
|
+
export interface ImageEditorSelection {
|
|
152
|
+
selectedMask: MaskObject | null;
|
|
153
|
+
selectedMasks: MaskObject[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Configuration for the label shown above a selected mask.
|
|
157
|
+
*
|
|
158
|
+
* Consumers can either tweak label text via `getText` and `textOptions`, or
|
|
159
|
+
* fully take over rendering via `create`. `textOptions` is deep-merged with
|
|
160
|
+
* the editor's defaults so unspecified keys remain.
|
|
161
|
+
*/
|
|
162
|
+
export interface LabelConfig {
|
|
163
|
+
/**
|
|
164
|
+
* Returns the text to render for a given mask.
|
|
165
|
+
*
|
|
166
|
+
* The `maskIndex` argument is the stable creation index (`mask.maskId - 1`)
|
|
167
|
+
* rather than the live list position.
|
|
168
|
+
*
|
|
169
|
+
* @default `(mask) => mask.maskName`
|
|
170
|
+
*/
|
|
171
|
+
getText?: (mask: MaskObject, maskIndex: number) => string;
|
|
172
|
+
/**
|
|
173
|
+
* Fabric.js text property overrides for the label text object.
|
|
174
|
+
* Merged with sensible defaults (monospace 12px white on dark bg).
|
|
175
|
+
*/
|
|
176
|
+
textOptions?: Partial<FabricNS.TextProps>;
|
|
177
|
+
/**
|
|
178
|
+
* Advanced: supply a factory that builds the label object directly.
|
|
179
|
+
* When provided, `getText` and `textOptions` are ignored.
|
|
180
|
+
*
|
|
181
|
+
* @returns A Fabric.js Text instance, or `null` to fall back to defaults.
|
|
182
|
+
*/
|
|
183
|
+
create?: (mask: MaskObject, fabric: FabricModule) => FabricNS.FabricText | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Crop-mode configuration. Defaults are applied by `core/default-options.ts`.
|
|
187
|
+
*
|
|
188
|
+
* Defaults are applied by `core/default-options.ts`.
|
|
189
|
+
*/
|
|
190
|
+
export interface CropConfig {
|
|
191
|
+
/** Minimum crop rect width in pixels. @default 100 */
|
|
192
|
+
minWidth?: number;
|
|
193
|
+
/** Minimum crop rect height in pixels. @default 100 */
|
|
194
|
+
minHeight?: number;
|
|
195
|
+
/** Inset from the image bounding box when entering crop mode. @default 10 */
|
|
196
|
+
padding?: number;
|
|
197
|
+
/** Whether to hide masks during crop preview. @default true */
|
|
198
|
+
hideMasksDuringCrop?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Whether to keep masks (relative to the new image) after applying crop.
|
|
201
|
+
* @default false
|
|
202
|
+
*/
|
|
203
|
+
preserveMasksAfterCrop?: boolean;
|
|
204
|
+
/** Whether the crop rect itself can be rotated. @default false */
|
|
205
|
+
allowRotationOfCropRect?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Format used for the intermediate image generated by applyCrop().
|
|
208
|
+
*
|
|
209
|
+
* - `'source'` keeps the currently loaded image's actual MIME format
|
|
210
|
+
* when known.
|
|
211
|
+
* - `'png'` uses a lossless PNG intermediate.
|
|
212
|
+
* - `'jpeg'` / `'jpg'` / `'webp'` use lossy intermediates with
|
|
213
|
+
* crop export quality.
|
|
214
|
+
*
|
|
215
|
+
* @default 'source'
|
|
216
|
+
*/
|
|
217
|
+
exportFileType?: CropExportFileType;
|
|
218
|
+
/**
|
|
219
|
+
* Lossy quality used when crop export format resolves to jpeg/webp.
|
|
220
|
+
* Ignored for PNG.
|
|
221
|
+
* @default options.downsampleQuality
|
|
222
|
+
*/
|
|
223
|
+
exportQuality?: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Crop configuration after defaults are applied. `exportQuality` remains
|
|
227
|
+
* optional so `undefined` can continue to mean "fall back to
|
|
228
|
+
* `downsampleQuality`".
|
|
229
|
+
*/
|
|
230
|
+
export type ResolvedCropConfig = Required<Omit<CropConfig, 'exportQuality'>> & Pick<CropConfig, 'exportQuality'>;
|
|
231
|
+
/**
|
|
232
|
+
* A numeric property that may be provided as:
|
|
233
|
+
* - a plain `number` in canvas pixels,
|
|
234
|
+
* - a CSS-style percentage string (`"50%"`) — resolved against the canvas
|
|
235
|
+
* width or height depending on the field's axis,
|
|
236
|
+
* - or a factory `(canvas, ResolvedOptions) => number` invoked at apply
|
|
237
|
+
* time.
|
|
238
|
+
*/
|
|
239
|
+
export type MaskNumericProp = number | `${number}%` | string | ((canvas: FabricNS.Canvas, options: ResolvedOptions) => number);
|
|
240
|
+
/**
|
|
241
|
+
* Polygon vertex accepted by `MaskConfig.points`. Coerced to `{ x, y }`
|
|
242
|
+
* internally regardless of input form.
|
|
243
|
+
*/
|
|
244
|
+
export type PolygonPoint = {
|
|
245
|
+
x: number;
|
|
246
|
+
y: number;
|
|
247
|
+
} | [number, number];
|
|
248
|
+
/**
|
|
249
|
+
* Configuration object passed to {@link ImageEditor.createMask}.
|
|
250
|
+
*
|
|
251
|
+
* Falsy values (`0`, `false`, `null`, `''`, `NaN`) supplied via `styles` and
|
|
252
|
+
* via the boolean flags below are applied verbatim — the editor never
|
|
253
|
+
* substitutes a default in their place.
|
|
254
|
+
*/
|
|
255
|
+
export interface MaskConfig {
|
|
256
|
+
/** Shape type. @default 'rect' */
|
|
257
|
+
shape?: 'rect' | 'circle' | 'ellipse' | 'polygon' | string;
|
|
258
|
+
/**
|
|
259
|
+
* Polygon vertex array. Required when `shape === 'polygon'`.
|
|
260
|
+
* Each element may be `{ x, y }` or `[x, y]`.
|
|
261
|
+
*/
|
|
262
|
+
points?: PolygonPoint[];
|
|
263
|
+
/** Mask width (rect) / used as diameter hint for circle. */
|
|
264
|
+
width?: MaskNumericProp;
|
|
265
|
+
/** Mask height (rect/ellipse). */
|
|
266
|
+
height?: MaskNumericProp;
|
|
267
|
+
/** Horizontal border-radius for Rect, or x-radius for Ellipse. */
|
|
268
|
+
rx?: MaskNumericProp;
|
|
269
|
+
/** Vertical border-radius for Rect, or y-radius for Ellipse. */
|
|
270
|
+
ry?: MaskNumericProp;
|
|
271
|
+
/** Radius for Circle. Defaults to `min(width, height) / 2`. */
|
|
272
|
+
radius?: MaskNumericProp;
|
|
273
|
+
/**
|
|
274
|
+
* Left position. Supports number, `"50%"`, or a factory. Percentages are
|
|
275
|
+
* resolved against canvas width.
|
|
276
|
+
* If omitted and a previous mask exists, auto-placed to its right.
|
|
277
|
+
*/
|
|
278
|
+
left?: MaskNumericProp;
|
|
279
|
+
/**
|
|
280
|
+
* Top position. Same flexibility as `left`. Percentages are resolved
|
|
281
|
+
* against canvas height.
|
|
282
|
+
*/
|
|
283
|
+
top?: MaskNumericProp;
|
|
284
|
+
/** Rotation angle in degrees. @default 0 */
|
|
285
|
+
angle?: number;
|
|
286
|
+
/** CSS fill color. @default 'rgba(0,0,0,0.5)' */
|
|
287
|
+
color?: string;
|
|
288
|
+
/** Opacity 0–1. @default 0.5 */
|
|
289
|
+
alpha?: number;
|
|
290
|
+
/** Pixel gap between auto-placed masks. @default 5 */
|
|
291
|
+
gap?: number;
|
|
292
|
+
/** Whether the mask can be selected and moved. @default true */
|
|
293
|
+
selectable?: boolean;
|
|
294
|
+
/** Whether the mask receives Fabric pointer events. @default true */
|
|
295
|
+
evented?: boolean;
|
|
296
|
+
/** Whether transform handles are shown. @default true */
|
|
297
|
+
hasControls?: boolean;
|
|
298
|
+
/** Keep stroke width visually uniform regardless of scale. @default true */
|
|
299
|
+
strokeUniform?: boolean;
|
|
300
|
+
/** Selection border color. @default 'red' */
|
|
301
|
+
borderColor?: string;
|
|
302
|
+
/** Control corner color. @default 'black' */
|
|
303
|
+
cornerColor?: string;
|
|
304
|
+
/** Control corner size in pixels. @default 8 */
|
|
305
|
+
cornerSize?: number;
|
|
306
|
+
/** Transparent corners. @default false */
|
|
307
|
+
transparentCorners?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Additional raw Fabric.js object properties merged into the shape.
|
|
310
|
+
* May include `stroke`, `strokeWidth`, `strokeDashArray`, etc. Falsy
|
|
311
|
+
* values are preserved verbatim.
|
|
312
|
+
*/
|
|
313
|
+
styles?: Partial<FabricNS.FabricObjectProps>;
|
|
314
|
+
/**
|
|
315
|
+
* Called synchronously after the mask is created, added to the canvas,
|
|
316
|
+
* and `saveState` has run.
|
|
317
|
+
*/
|
|
318
|
+
onCreate?: (mask: MaskObject, canvas: FabricNS.Canvas) => void;
|
|
319
|
+
/**
|
|
320
|
+
* Advanced: bypass the built-in shape logic and supply your own Fabric.js
|
|
321
|
+
* object. Receives the fully resolved config, the canvas, and the
|
|
322
|
+
* resolved editor options.
|
|
323
|
+
*/
|
|
324
|
+
fabricGenerator?: (config: ResolvedMaskConfig, canvas: FabricNS.Canvas, options: ResolvedOptions) => FabricNS.FabricObject;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Fully resolved mask config produced after defaults and percentage resolution
|
|
328
|
+
* have been applied. Exposed because consumers may receive it via
|
|
329
|
+
* `MaskConfig.fabricGenerator`.
|
|
330
|
+
*/
|
|
331
|
+
export interface ResolvedMaskConfig extends MaskConfig {
|
|
332
|
+
shape: NonNullable<MaskConfig['shape']>;
|
|
333
|
+
width: number;
|
|
334
|
+
height: number;
|
|
335
|
+
color: string;
|
|
336
|
+
alpha: number;
|
|
337
|
+
gap: number;
|
|
338
|
+
angle: number;
|
|
339
|
+
selectable: boolean;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Options accepted by `ImageEditor.loadImage(imageBase64, options?)`.
|
|
343
|
+
*/
|
|
344
|
+
export interface LoadImageOptions {
|
|
345
|
+
/**
|
|
346
|
+
* When `true`, the editor preserves the container's scroll position
|
|
347
|
+
* across both the successful load and rollback paths.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
preserveScroll?: boolean;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Options accepted by `ImageEditor.removeAllMasks(options?)`.
|
|
354
|
+
*/
|
|
355
|
+
export interface RemoveAllMasksOptions {
|
|
356
|
+
/**
|
|
357
|
+
* When `true`, push a single history entry for the bulk removal. When
|
|
358
|
+
* `false`, remove masks without creating a history entry — used by
|
|
359
|
+
* internal merge/crop pipelines that already record one enclosing entry.
|
|
360
|
+
* @default true
|
|
361
|
+
*/
|
|
362
|
+
saveHistory?: boolean;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Mapping from logical control names to actual DOM element IDs on the page.
|
|
366
|
+
* Any key may be omitted; the default ID is the same as the key name.
|
|
367
|
+
* Unknown or missing element IDs are ignored safely by `ui/dom-bindings.ts`.
|
|
368
|
+
*/
|
|
369
|
+
export interface ElementIdMap {
|
|
370
|
+
/** The `<canvas>` element. @default 'canvas' */
|
|
371
|
+
canvas?: string;
|
|
372
|
+
/**
|
|
373
|
+
* Scrollable viewport container that wraps the canvas.
|
|
374
|
+
* Used to determine the visible size for canvas-sizing decisions.
|
|
375
|
+
* If omitted, `canvas.parentElement` is used.
|
|
376
|
+
*/
|
|
377
|
+
canvasContainer?: string | null;
|
|
378
|
+
/** Empty-state placeholder element. @default 'imagePlaceholder' */
|
|
379
|
+
imagePlaceholder?: string | null;
|
|
380
|
+
/** Scale percentage input/display. @default 'scalePercentageInput' */
|
|
381
|
+
scalePercentageInput?: string | null;
|
|
382
|
+
/** Left-rotation step input. @default 'rotateLeftDegreesInput' */
|
|
383
|
+
rotateLeftDegreesInput?: string | null;
|
|
384
|
+
/** Right-rotation step input. @default 'rotateRightDegreesInput' */
|
|
385
|
+
rotateRightDegreesInput?: string | null;
|
|
386
|
+
/** Rotate left button. @default 'rotateLeftButton' */
|
|
387
|
+
rotateLeftButton?: string | null;
|
|
388
|
+
/** Rotate right button. @default 'rotateRightButton' */
|
|
389
|
+
rotateRightButton?: string | null;
|
|
390
|
+
/** Add mask button. @default 'createMaskButton' */
|
|
391
|
+
createMaskButton?: string | null;
|
|
392
|
+
/** Remove selected mask button. @default 'removeSelectedMaskButton' */
|
|
393
|
+
removeSelectedMaskButton?: string | null;
|
|
394
|
+
/** Remove all masks button. @default 'removeAllMasksButton' */
|
|
395
|
+
removeAllMasksButton?: string | null;
|
|
396
|
+
/** Merge masks into image button. @default 'mergeMasksButton' */
|
|
397
|
+
mergeMasksButton?: string | null;
|
|
398
|
+
/** Download image button. @default 'downloadImageButton' */
|
|
399
|
+
downloadImageButton?: string | null;
|
|
400
|
+
/** Mask list container (`<ul>` or `<ol>`). @default 'maskList' */
|
|
401
|
+
maskList?: string | null;
|
|
402
|
+
/** Zoom in button. @default 'zoomInButton' */
|
|
403
|
+
zoomInButton?: string | null;
|
|
404
|
+
/** Zoom out button. @default 'zoomOutButton' */
|
|
405
|
+
zoomOutButton?: string | null;
|
|
406
|
+
/** Reset transform button. @default 'resetImageTransformButton' */
|
|
407
|
+
resetImageTransformButton?: string | null;
|
|
408
|
+
/** Undo button. @default 'undoButton' */
|
|
409
|
+
undoButton?: string | null;
|
|
410
|
+
/** Redo button. @default 'redoButton' */
|
|
411
|
+
redoButton?: string | null;
|
|
412
|
+
/** File input for image selection. @default 'imageInput' */
|
|
413
|
+
imageInput?: string | null;
|
|
414
|
+
/** Enter crop mode button. @default 'enterCropModeButton' */
|
|
415
|
+
enterCropModeButton?: string | null;
|
|
416
|
+
/** Apply crop button. @default 'applyCropButton' */
|
|
417
|
+
applyCropButton?: string | null;
|
|
418
|
+
/** Cancel crop button. @default 'cancelCropButton' */
|
|
419
|
+
cancelCropButton?: string | null;
|
|
420
|
+
/** Clickable upload area (delegates to imageInput). @default 'uploadArea' */
|
|
421
|
+
uploadArea?: string | null;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Options for {@link ImageEditor.exportImageBase64}.
|
|
425
|
+
*
|
|
426
|
+
* Both `fileType` and `format` are accepted — when both are provided,
|
|
427
|
+
* `fileType` wins. The export pipeline normalizes `'jpg'` to `'jpeg'`,
|
|
428
|
+
* derives the MIME type via `export/export-format.ts`, and clamps `quality`
|
|
429
|
+
* to `[0, 1]`. PNG ignores `quality` because it is
|
|
430
|
+
* lossless.
|
|
431
|
+
*/
|
|
432
|
+
export interface Base64ExportOptions {
|
|
433
|
+
/** Whether masks are flattened into the exported result. @default true */
|
|
434
|
+
mergeMask?: boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Which region to export. `'image'` clips to the image bounding box;
|
|
437
|
+
* `'canvas'` exports the full canvas.
|
|
438
|
+
* @default 'image'
|
|
439
|
+
*/
|
|
440
|
+
exportArea?: ExportArea;
|
|
441
|
+
/**
|
|
442
|
+
* Output resolution multiplier (e.g. `2` for 2× retina).
|
|
443
|
+
* @default `options.exportMultiplier`
|
|
444
|
+
*/
|
|
445
|
+
multiplier?: number;
|
|
446
|
+
/** Lossy quality 0–1. Ignored for PNG. @default `options.downsampleQuality` */
|
|
447
|
+
quality?: number;
|
|
448
|
+
/** Output format. Defaults to `'jpeg'`. */
|
|
449
|
+
fileType?: ImageFileType;
|
|
450
|
+
/** Alias for `fileType` accepted for ergonomic interop. */
|
|
451
|
+
format?: ImageFileType;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Options for {@link ImageEditor.exportImageFile}.
|
|
455
|
+
*
|
|
456
|
+
* `fileName` falls back to `options.defaultDownloadFileName` when omitted.
|
|
457
|
+
* `fileType` follows the same normalization rules as
|
|
458
|
+
* {@link Base64ExportOptions}.
|
|
459
|
+
*/
|
|
460
|
+
export interface ImageFileExportOptions {
|
|
461
|
+
/** Bake masks into the exported image. @default true */
|
|
462
|
+
mergeMask?: boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Which region to export. `'image'` clips to the image bounding box;
|
|
465
|
+
* `'canvas'` exports the full canvas.
|
|
466
|
+
* @default 'image'
|
|
467
|
+
*/
|
|
468
|
+
exportArea?: ExportArea;
|
|
469
|
+
/** Output format. @default 'jpeg' */
|
|
470
|
+
fileType?: ImageFileType;
|
|
471
|
+
/** Lossy quality 0–1. Ignored for PNG. @default `options.downsampleQuality` */
|
|
472
|
+
quality?: number;
|
|
473
|
+
/** Resolution multiplier. @default `options.exportMultiplier` */
|
|
474
|
+
multiplier?: number;
|
|
475
|
+
/** Filename for the resulting `File` object. */
|
|
476
|
+
fileName?: string;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Configuration passed to the {@link ImageEditor} constructor.
|
|
480
|
+
*
|
|
481
|
+
* All properties are optional; sensible defaults are applied internally by
|
|
482
|
+
* `core/default-options.ts`. Unknown keys are
|
|
483
|
+
* ignored without throwing.
|
|
484
|
+
*/
|
|
485
|
+
export interface ImageEditorOptions {
|
|
486
|
+
/** Initial and hidden-container fallback canvas width in pixels. @default 800 */
|
|
487
|
+
canvasWidth?: number;
|
|
488
|
+
/** Initial and hidden-container fallback canvas height in pixels. @default 600 */
|
|
489
|
+
canvasHeight?: number;
|
|
490
|
+
/** Fabric canvas background color. @default 'transparent' */
|
|
491
|
+
backgroundColor?: string;
|
|
492
|
+
/** Duration of scale/rotate animations in ms. @default 300 */
|
|
493
|
+
animationDuration?: number;
|
|
494
|
+
/** Minimum allowed scale factor. @default 0.1 */
|
|
495
|
+
minScale?: number;
|
|
496
|
+
/** Maximum allowed scale factor. @default 5.0 */
|
|
497
|
+
maxScale?: number;
|
|
498
|
+
/** Scale delta per zoom step. @default 0.05 */
|
|
499
|
+
scaleStep?: number;
|
|
500
|
+
/** Rotation step in degrees. Non-finite values fall back to the default. @default 90 */
|
|
501
|
+
rotationStep?: number;
|
|
502
|
+
/**
|
|
503
|
+
* Expand the canvas to fit the loaded image (no scroll required for
|
|
504
|
+
* images smaller than their natural size). @default true
|
|
505
|
+
*/
|
|
506
|
+
expandCanvasToImage?: boolean;
|
|
507
|
+
/** Scale the image down to fit inside the visible workspace. @default false */
|
|
508
|
+
fitImageToCanvas?: boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Scale large images down to cover the visible workspace, cap at native
|
|
511
|
+
* size, and expand overflowing canvas axes so the container can scroll.
|
|
512
|
+
* @default false
|
|
513
|
+
*/
|
|
514
|
+
coverImageToCanvas?: boolean;
|
|
515
|
+
/** Downsample very large images on load. @default true */
|
|
516
|
+
downsampleOnLoad?: boolean;
|
|
517
|
+
/** Max pixel width before downsampling kicks in. @default 4000 */
|
|
518
|
+
downsampleMaxWidth?: number;
|
|
519
|
+
/** Max pixel height before downsampling kicks in. @default 3000 */
|
|
520
|
+
downsampleMaxHeight?: number;
|
|
521
|
+
/** Lossy quality used when downsampling and exporting. @default 0.92 */
|
|
522
|
+
downsampleQuality?: number | null;
|
|
523
|
+
/**
|
|
524
|
+
* When `true`, alpha-capable source MIME types (`image/png`,
|
|
525
|
+
* `image/webp`) are preserved through downsampling unless
|
|
526
|
+
* `downsampleMimeType` is explicitly set.
|
|
527
|
+
* @default true
|
|
528
|
+
*/
|
|
529
|
+
preserveSourceFormat?: boolean;
|
|
530
|
+
/**
|
|
531
|
+
* Explicit MIME type to use for downsampled output. When set, overrides
|
|
532
|
+
* `preserveSourceFormat` and forces the resampler to emit this MIME using
|
|
533
|
+
* `downsampleQuality`.
|
|
534
|
+
* @default null
|
|
535
|
+
*/
|
|
536
|
+
downsampleMimeType?: ImageMimeType | null;
|
|
537
|
+
/**
|
|
538
|
+
* Maximum duration (ms) for both decode and Fabric image creation steps
|
|
539
|
+
* during `loadImage`. @default 30000
|
|
540
|
+
*/
|
|
541
|
+
imageLoadTimeoutMs?: number;
|
|
542
|
+
/**
|
|
543
|
+
* Maximum number of undo/redo snapshots retained in memory.
|
|
544
|
+
* Each entry stores a full serialized canvas snapshot. When the loaded
|
|
545
|
+
* image is represented as a data URL, that data can be duplicated in
|
|
546
|
+
* every retained snapshot, so lower this for large images or
|
|
547
|
+
* memory-constrained hosts.
|
|
548
|
+
* Values are normalized to a positive integer. @default 50
|
|
549
|
+
*/
|
|
550
|
+
maxHistorySize?: number;
|
|
551
|
+
/** Output resolution multiplier for exports. @default 1 */
|
|
552
|
+
exportMultiplier?: number;
|
|
553
|
+
/**
|
|
554
|
+
* Maximum output pixel count after applying the export multiplier.
|
|
555
|
+
* Invalid values fall back to the default guard. @default 50000000
|
|
556
|
+
*/
|
|
557
|
+
maxExportPixels?: number | null;
|
|
558
|
+
/**
|
|
559
|
+
* Default export region for exportImageBase64/exportImageFile/downloadImage.
|
|
560
|
+
* @default 'image'
|
|
561
|
+
*/
|
|
562
|
+
exportAreaByDefault?: ExportArea;
|
|
563
|
+
/**
|
|
564
|
+
* Default mask compositing behavior for
|
|
565
|
+
* exportImageBase64/exportImageFile/downloadImage.
|
|
566
|
+
* @default true
|
|
567
|
+
*/
|
|
568
|
+
mergeMaskByDefault?: boolean;
|
|
569
|
+
/** Default width for new rect/ellipse masks. @default 50 */
|
|
570
|
+
defaultMaskWidth?: number;
|
|
571
|
+
/** Default height for new rect/ellipse masks. @default 80 */
|
|
572
|
+
defaultMaskHeight?: number;
|
|
573
|
+
/** Allow masks to be rotated by the user. @default false */
|
|
574
|
+
maskRotatable?: boolean;
|
|
575
|
+
/** Show a name label above a selected mask. @default true */
|
|
576
|
+
maskLabelOnSelect?: boolean;
|
|
577
|
+
/** Pixel offset of the label from the mask's top-left corner. @default 3 */
|
|
578
|
+
maskLabelOffset?: number;
|
|
579
|
+
/** Name prefix for auto-generated mask names. @default 'mask' */
|
|
580
|
+
maskName?: string;
|
|
581
|
+
/** Allow multi-object group selection on the canvas. @default false */
|
|
582
|
+
groupSelection?: boolean;
|
|
583
|
+
/** Show a placeholder when no image is loaded. @default true */
|
|
584
|
+
showPlaceholder?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Base64 data URL to auto-load when the editor is initialized.
|
|
587
|
+
* @default null
|
|
588
|
+
*/
|
|
589
|
+
initialImageBase64?: string | null;
|
|
590
|
+
/** Default filename used by {@link ImageEditor.downloadImage}. @default 'edited_image.jpg' */
|
|
591
|
+
defaultDownloadFileName?: string;
|
|
592
|
+
/** Called when a valid image load is about to start. */
|
|
593
|
+
onImageLoadStart?: (context: ImageEditorCallbackContext) => void;
|
|
594
|
+
/** Called after an image is successfully loaded onto the canvas. */
|
|
595
|
+
onImageLoaded?: (imageInfo: ImageInfo, context: ImageEditorCallbackContext) => void;
|
|
596
|
+
/** Called when a previously loaded image stops being current. */
|
|
597
|
+
onImageCleared?: (previousImage: FabricNS.FabricImage | null, context: ImageEditorCallbackContext) => void;
|
|
598
|
+
/** Called after externally visible editor state changes. */
|
|
599
|
+
onImageChanged?: (state: ImageEditorState, context: ImageEditorCallbackContext) => void;
|
|
600
|
+
/** Called when the public busy state changes. */
|
|
601
|
+
onBusyChange?: (isBusy: boolean, context: ImageEditorCallbackContext) => void;
|
|
602
|
+
/** Called once after `dispose()` tears down the editor. */
|
|
603
|
+
onEditorDisposed?: (context: ImageEditorCallbackContext) => void;
|
|
604
|
+
/** Called after the mask collection changes. */
|
|
605
|
+
onMasksChanged?: (masks: MaskObject[], context: ImageEditorCallbackContext) => void;
|
|
606
|
+
/** Called after mask selection changes. */
|
|
607
|
+
onSelectionChange?: (selection: ImageEditorSelection, context: ImageEditorCallbackContext) => void;
|
|
608
|
+
/**
|
|
609
|
+
* Called when the editor reports an error.
|
|
610
|
+
*
|
|
611
|
+
* Argument order is `(error, message)` so the original thrown value is
|
|
612
|
+
* preserved as the first argument and a human-readable description is
|
|
613
|
+
* the second. Callback exceptions are caught and
|
|
614
|
+
* logged without masking the original editor error.
|
|
615
|
+
*/
|
|
616
|
+
onError?: (error: unknown, message: string) => void;
|
|
617
|
+
/**
|
|
618
|
+
* Called when the editor reports a recoverable warning. Same
|
|
619
|
+
* `(error, message)` argument order as `onError`.
|
|
620
|
+
*/
|
|
621
|
+
onWarning?: (error: unknown, message: string) => void;
|
|
622
|
+
/** Selected-mask label configuration. */
|
|
623
|
+
label?: LabelConfig;
|
|
624
|
+
/** Crop-mode configuration. */
|
|
625
|
+
crop?: CropConfig;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Fully resolved options with every required field guaranteed present.
|
|
629
|
+
* Produced by `core/default-options.ts` after merging defaults with the
|
|
630
|
+
* user-supplied partial options.
|
|
631
|
+
*/
|
|
632
|
+
export interface ResolvedOptions extends Required<Omit<ImageEditorOptions, 'label' | 'crop' | 'onImageLoadStart' | 'onImageLoaded' | 'onImageCleared' | 'onImageChanged' | 'onBusyChange' | 'onEditorDisposed' | 'onMasksChanged' | 'onSelectionChange' | 'onError' | 'onWarning' | 'downsampleQuality' | 'maxExportPixels'>> {
|
|
633
|
+
downsampleQuality: number;
|
|
634
|
+
maxExportPixels: number;
|
|
635
|
+
label: LabelConfig;
|
|
636
|
+
crop: ResolvedCropConfig;
|
|
637
|
+
onImageLoadStart: ((context: ImageEditorCallbackContext) => void) | null;
|
|
638
|
+
onImageLoaded: ((imageInfo: ImageInfo, context: ImageEditorCallbackContext) => void) | null;
|
|
639
|
+
onImageCleared: ((previousImage: FabricNS.FabricImage | null, context: ImageEditorCallbackContext) => void) | null;
|
|
640
|
+
onImageChanged: ((state: ImageEditorState, context: ImageEditorCallbackContext) => void) | null;
|
|
641
|
+
onBusyChange: ((isBusy: boolean, context: ImageEditorCallbackContext) => void) | null;
|
|
642
|
+
onEditorDisposed: ((context: ImageEditorCallbackContext) => void) | null;
|
|
643
|
+
onMasksChanged: ((masks: MaskObject[], context: ImageEditorCallbackContext) => void) | null;
|
|
644
|
+
onSelectionChange: ((selection: ImageEditorSelection, context: ImageEditorCallbackContext) => void) | null;
|
|
645
|
+
onError: ((error: unknown, message: string) => void) | null;
|
|
646
|
+
onWarning: ((error: unknown, message: string) => void) | null;
|
|
647
|
+
}
|
|
648
|
+
/** DOM event subscription pair retained so teardown can remove the listener. */
|
|
649
|
+
export interface BoundHandler {
|
|
650
|
+
event: string;
|
|
651
|
+
handler: EventListener;
|
|
652
|
+
}
|
|
653
|
+
/** Crop-session handler registry entry for crop rectangle events. */
|
|
654
|
+
export interface CropHandler {
|
|
655
|
+
target: MaskObject | FabricNS.Rect;
|
|
656
|
+
handlers: Array<{
|
|
657
|
+
eventName: string;
|
|
658
|
+
callback: () => void;
|
|
659
|
+
}>;
|
|
660
|
+
}
|
|
661
|
+
/** Previous Fabric interaction flags captured before crop mode freezes objects. */
|
|
662
|
+
export interface CropPrevEvented {
|
|
663
|
+
object: FabricNS.FabricObject;
|
|
664
|
+
evented: boolean;
|
|
665
|
+
selectable: boolean;
|
|
666
|
+
}
|
|
667
|
+
/** Full mask style snapshot used to restore hover, selection, and crop styles. */
|
|
668
|
+
export interface MaskBackup {
|
|
669
|
+
object: MaskObject;
|
|
670
|
+
opacity: number;
|
|
671
|
+
fill: FabricNS.TFiller | string | null;
|
|
672
|
+
strokeWidth: number;
|
|
673
|
+
stroke: FabricNS.TFiller | string | null;
|
|
674
|
+
selectable: boolean;
|
|
675
|
+
evented: boolean;
|
|
676
|
+
lockRotation: boolean;
|
|
677
|
+
}
|
|
678
|
+
//# sourceMappingURL=public-types.d.ts.map
|