@bensitu/image-editor 1.5.0 → 1.5.1

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
@@ -115,50 +115,83 @@ Use `dist/image-editor.js` or `dist/image-editor.min.js` for browser global scri
115
115
 
116
116
  ### JavaScript Implementation
117
117
 
118
+ The constructor options are optional. For the smallest setup, create an editor instance and bind it to a canvas element.
119
+
120
+ ```javascript
121
+ const editor = new ImageEditor();
122
+
123
+ editor.init({
124
+ canvas: "fabricCanvas"
125
+ });
126
+ ```
127
+
128
+ `canvas` is the only required DOM binding when your canvas element does not use the default ID `fabricCanvas`. All other DOM bindings are optional.
129
+
130
+ #### Optional Configuration
131
+
132
+ You can pass options to override the built-in defaults.
133
+
118
134
  ```javascript
119
- // Create instance
120
135
  const editor = new ImageEditor({
121
136
  canvasWidth: 800,
122
137
  canvasHeight: 600,
123
138
  backgroundColor: "#ffffff",
139
+ initialImageBase64: null
140
+ });
141
+ ```
142
+
143
+ These are common optional overrides, not required settings.
144
+
145
+ #### Demo-style Configuration
146
+
147
+ The docs demo uses an explicit configuration so the demo behavior is predictable. These options are not required for normal usage.
148
+
149
+ ```javascript
150
+ const editor = new ImageEditor({
151
+ // Layout mode. Enable only one layout mode at a time.
152
+ expandCanvasToImage: false,
153
+ fitImageToCanvas: true,
154
+ coverImageToCanvas: false,
155
+
156
+ // Image loading / performance.
157
+ downsampleOnLoad: true,
124
158
  initialImageBase64: null,
125
159
 
126
- onError: (error, message) => {
127
- console.error("[ImageEditor]", message, error);
128
- },
160
+ // Mask behavior.
161
+ maskRotatable: true,
162
+ maskLabelOnSelect: true,
163
+ maskLabelOffset: 5,
129
164
 
130
- onWarning: (error, message) => {
131
- console.warn("[ImageEditor]", message, error);
132
- },
165
+ // UI behavior.
166
+ backgroundColor: "transparent",
167
+ showPlaceholder: true,
168
+ animationDuration: 100,
169
+
170
+ // Export behavior.
171
+ exportImageAreaByDefault: true
133
172
  });
134
173
 
135
- try {
136
- editor.init({
137
- canvas: "fabricCanvas",
138
- zoomInButton: "zoomInButton",
139
- zoomOutButton: "zoomOutButton",
140
- rotateLeftButton: "rotateLeftButton",
141
- rotateLeftDegreesInput: "rotateLeftDegreesInput",
142
- rotateRightButton: "rotateRightButton",
143
- rotateRightDegreesInput: "rotateRightDegreesInput",
144
- createMaskButton: "createMaskButton",
145
- removeSelectedMaskButton: "removeSelectedMaskButton",
146
- removeAllMasksButton: "removeAllMasksButton",
147
- enterCropModeButton: "enterCropModeButton",
148
- applyCropButton: "applyCropButton",
149
- cancelCropButton: "cancelCropButton",
150
- undoButton: "undoButton",
151
- redoButton: "redoButton",
152
- mergeMasksButton: "mergeMasksButton",
153
- resetImageTransformButton: "resetImageTransformButton",
154
- downloadImageButton: "downloadImageButton",
155
- imageInput: "imageInput",
156
- });
157
- } catch (error) {
158
- console.error("Failed to initialize ImageEditor:", error);
159
- }
174
+ editor.init({
175
+ canvas: "fabricCanvas",
176
+ imagePlaceholder: "imagePlaceholder",
177
+ scalePercentageInput: "scalePercentageInput",
178
+ rotateLeftButton: "rotateLeftButton",
179
+ rotateRightButton: "rotateRightButton",
180
+ rotateLeftDegreesInput: "rotateLeftDegreesInput",
181
+ rotateRightDegreesInput: "rotateRightDegreesInput",
182
+ removeSelectedMaskButton: "removeSelectedMaskButton",
183
+ removeAllMasksButton: "removeAllMasksButton",
184
+ mergeMasksButton: "mergeMasksButton",
185
+ downloadImageButton: "downloadImageButton",
186
+ maskList: "maskList",
187
+ enterCropModeButton: "enterCropModeButton",
188
+ applyCropButton: "applyCropButton",
189
+ cancelCropButton: "cancelCropButton",
190
+ resetImageTransformButton: "resetImageTransformButton"
191
+ });
160
192
  ```
161
193
 
194
+
162
195
  ### Loading an Image Manually
163
196
 
164
197
  ```javascript
@@ -175,6 +208,8 @@ loadImageDataUrl("data:image/jpeg;base64,...");
175
208
 
176
209
  ## Configuration Options
177
210
 
211
+ All options are optional. If an option is not provided, the editor uses the default value listed below.
212
+
178
213
  When creating the editor instance, pass an options object to override defaults.
179
214
 
180
215
  | Option | Default | Description |