@bensitu/image-editor 1.2.1 → 1.3.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 CHANGED
@@ -126,12 +126,13 @@ When creating the editor instance, you can pass an options object to override de
126
126
  | `scaleStep` | `0.05` | Scale step for zoom buttons |
127
127
  | `rotationStep` | `90` | Default rotation step in degrees |
128
128
  | `expandCanvasToImage` | `true` | Expand canvas to image size on load |
129
- | `fitImageToCanvas` | `false` | Fit image to current canvas size |
129
+ | `fitImageToCanvas` | `false` | Fit image to the visible canvas viewport |
130
130
  | `coverImageToCanvas` | `false` | Fit image to cover canvas (at least one side fits, allowing overflow). |
131
131
  | `downsampleOnLoad` | `true` | Downsample large images before rendering |
132
132
  | `downsampleMaxWidth` | `4000` | Max width count before downsampling |
133
133
  | `downsampleMaxHeight` | `3000` | Max height count before downsampling |
134
134
  | `downsampleQuality` | `0.92` | JPEG quality when downsampling |
135
+ | `imageLoadTimeoutMs` | `30000` | Timeout for image decode operations |
135
136
  | `exportMultiplier` | `1` | Scale factor for export |
136
137
  | `exportImageAreaByDefault` | `true` | Export only the image area (clipped to masks) |
137
138
  | `defaultMaskWidth` | `50` | Default mask width (px) |
@@ -140,33 +141,39 @@ When creating the editor instance, you can pass an options object to override de
140
141
  | `maskLabelOnSelect` | `true` | Show label when mask is selected |
141
142
  | `maskLabelOffset` | `3` | Offset for mask labels from top-left corner |
142
143
  | `maskName` | `mask` | Prefix for mask names/labels |
144
+ | `label.getText` | `(mask) => mask.maskName` | Callback for custom label text. The second argument is the mask's stable zero-based creation index (`mask.maskId - 1`). |
143
145
  | `showPlaceholder` | `true` | Shows placeholder when no image is loaded |
144
146
  | `initialImageBase64` | `null` | Base64 string to auto-load as initial image |
145
147
  | `defaultDownloadFileName` | `edited_image.jpg` | Default file name for downloads |
146
- | `crop.preserveMasksAfterCrop` | `false` | Applying crop removes unmerged masks. Merge masks first if they should be baked into the cropped image. |
148
+ | `crop.preserveMasksAfterCrop` | `false` | Keep masks that intersect the crop area, shifted into the cropped canvas. Merge masks first if they should be baked into the image pixels. |
149
+
150
+ `expandCanvasToImage`, `fitImageToCanvas`, and `coverImageToCanvas` are mutually exclusive layout modes. If more than one is enabled, the editor reports a warning and uses the first active mode in its existing load order.
147
151
 
148
152
  ## API Methods
149
153
 
150
154
  | Method | Description |
151
155
  |--------|-------------|
152
156
  | `init(idMap)` | Bind the editor to DOM elements. Pass IDs in an object (optional). |
153
- | `loadImage(base64)` | Load an image from a base64 data string. Resolves after the Fabric image is on the canvas. |
157
+ | `loadImage(imageBase64, options)` | Load an image from a base64 data string. Resolves after the Fabric image is on the canvas. |
154
158
  | `scaleImage(factor)` | Scale image to the given factor (relative to base scale). |
155
159
  | `rotateImage(degrees)` | Rotate image to the given angle in degrees. |
156
- | `reset()` | Reset scale to 1 and rotation to 0. |
157
- | `undo()` | Undo the last state change. |
158
- | `redo()` | Redo the next state change. |
159
- | `addMask(config)` | Add a mask to the canvas. Config can include width, height, color. |
160
+ | `resetImageTransform()` | Reset scale to 1 and rotation to 0. |
161
+ | `undo()` | Undo the last state change. Resolves after the canvas state is restored. |
162
+ | `redo()` | Redo the next state change. Resolves after the canvas state is restored. |
163
+ | `createMask(config)` | Create a mask on the canvas. Config can include width, height, color. |
160
164
  | `removeSelectedMask()` | Remove the currently selected mask. |
161
165
  | `removeAllMasks()` | Remove all masks from the canvas. |
162
166
  | `enterCropMode()` | Create a resizable/movable selection rect on top of the image. |
163
167
  | `cancelCrop()` | Cancel crop mode and remove the temporary selection rect. |
164
168
  | `applyCrop()` | Apply the current crop rectangle in the canvas. |
165
- | `merge()` | Merge masks with the base image in the canvas. |
169
+ | `mergeMasks()` | Merge masks with the base image in the canvas. |
166
170
  | `downloadImage()` | Download the merged image as a file. |
167
- | `exportImageFile(options)` | Exports the current canvas (with or without masks) as a `File` object. |
171
+ | `exportImageBase64(options)` | Export an image data URL. `fileType` can be `jpeg`, `png`, or `webp`. |
172
+ | `exportImageFile(options)` | Exports the current canvas (with or without masks) as a `File` object. `fileType` is exported directly when supported. |
173
+
174
+ Deprecated aliases are still available for compatibility and will be removed in `v2.0.0`: `reset()`, `addMask(config)`, `merge()`, and `getImageBase64(options)`.
168
175
 
169
- Applying crop removes unmerged masks. Use `merge()` before cropping when masks should become part of the image pixels.
176
+ By default, applying crop removes unmerged masks. Set `crop.preserveMasksAfterCrop` to keep intersecting masks, or use `mergeMasks()` before cropping when masks should become part of the image pixels.
170
177
 
171
178
  ## Example Workflow
172
179
 
@@ -206,23 +213,6 @@ The package build targets these modern browsers and uses modern DOM and JavaScri
206
213
 
207
214
  IE11 and old mobile Safari are not supported by the distributed build. If you need them, transpile the package and provide any required DOM or JavaScript polyfills in your application.
208
215
 
209
- ## Automated npm Publishing
210
-
211
- This repository publishes to npm through GitHub Actions when a matching version tag is pushed. The workflow uses npm Trusted Publishing with GitHub Actions OIDC, so no long-lived npm token is required.
212
-
213
- Setup:
214
-
215
- 1. Configure npm Trusted Publishing for this repository and the `publish-npm.yml` workflow.
216
- 2. Commit the version bump, changelog, source, and generated `dist/` files.
217
- 3. Push a tag that matches the package version:
218
-
219
- ```bash
220
- git tag v<package-version>
221
- git push origin v<package-version>
222
- ```
223
-
224
- The workflow validates the tag, runs checks, verifies package contents, and publishes to npm.
225
-
226
216
  ## Dependencies
227
217
 
228
218
  - **fabric.js v5.x** — Must be loaded before ImageEditor