@anu3ev/fabric-image-editor 0.5.9 → 0.5.13
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/main.js +973 -918
- package/package.json +1 -1
- package/readme.md +27 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu3ev/fabric-image-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
|
|
5
5
|
"module": "dist/main.js",
|
|
6
6
|
"files": [
|
package/readme.md
CHANGED
|
@@ -15,8 +15,10 @@ A modern, powerful browser-based image editor built with [FabricJS](https://fabr
|
|
|
15
15
|
- **Professional Tools** - Copy/paste, grouping, selection, and alignment
|
|
16
16
|
|
|
17
17
|
### Advanced Capabilities
|
|
18
|
-
- **Background Management** - Color, gradient, and image backgrounds
|
|
18
|
+
- **Background Management** - Color, multi-stop gradient, and image backgrounds
|
|
19
19
|
- **Image Import/Export** - Support for PNG, JPG, SVG, and PDF formats
|
|
20
|
+
- **Precision Alignment** - Snapping to montage edges/centers and nearby objects with visual guides and spacing detection
|
|
21
|
+
- **Live Measurements** - Hold `Alt` with a selection to display distance guides to the hovered object or montage area
|
|
20
22
|
- **Web Worker Integration** - Heavy operations run in background threads
|
|
21
23
|
- **Font Loader** - FontManager handles Google Fonts + custom sources with automatic `@font-face` registration
|
|
22
24
|
- **Configurable Toolbar** - Dynamic toolbar with context-sensitive actions
|
|
@@ -93,14 +95,16 @@ const url = URL.createObjectURL(result.image)
|
|
|
93
95
|
// Set a color background
|
|
94
96
|
editor.backgroundManager.setColorBackground({ color: '#ff0000' })
|
|
95
97
|
|
|
96
|
-
// Set a gradient background
|
|
98
|
+
// Set a gradient background (supports multi-stop ramps)
|
|
97
99
|
editor.backgroundManager.setGradientBackground({
|
|
98
100
|
gradient: {
|
|
99
|
-
// 'linear' or 'radial'
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
type: 'linear', // 'linear' or 'radial'
|
|
102
|
+
angle: 120,
|
|
103
|
+
colorStops: [
|
|
104
|
+
{ offset: 0, color: '#ff8a00' },
|
|
105
|
+
{ offset: 45, color: '#e52e71' },
|
|
106
|
+
{ offset: 100, color: '#4a00e0' }
|
|
107
|
+
]
|
|
104
108
|
},
|
|
105
109
|
customData: {
|
|
106
110
|
customProperty: 'value'
|
|
@@ -108,6 +112,10 @@ editor.backgroundManager.setGradientBackground({
|
|
|
108
112
|
withoutSave: false
|
|
109
113
|
})
|
|
110
114
|
|
|
115
|
+
// Simple two-stop gradients still work:
|
|
116
|
+
// use startColor/endColor with optional startPosition/endPosition (0-100).
|
|
117
|
+
// For radial gradients pass centerX/centerY/radius in percentages.
|
|
118
|
+
|
|
111
119
|
// Set an image background
|
|
112
120
|
await editor.backgroundManager.setImageBackground({ imageSource: 'bg-image.jpg' })
|
|
113
121
|
|
|
@@ -115,6 +123,8 @@ await editor.backgroundManager.setImageBackground({ imageSource: 'bg-image.jpg'
|
|
|
115
123
|
editor.backgroundManager.removeBackground()
|
|
116
124
|
```
|
|
117
125
|
|
|
126
|
+
Offsets in `colorStops` use percentages from 0 to 100 and are normalized for Fabric gradients.
|
|
127
|
+
|
|
118
128
|
### Working with Text
|
|
119
129
|
|
|
120
130
|
```javascript
|
|
@@ -225,6 +235,7 @@ The editor follows a modular architecture with specialized managers:
|
|
|
225
235
|
- **`LayerManager`** - Object layering, z-index management, send to back/front
|
|
226
236
|
- **`BackgroundManager`** - Background colors, gradients, and images
|
|
227
237
|
- **`TransformManager`** - Object transformations, fitting, and scaling
|
|
238
|
+
- **`ZoomManager`** - Zoom limits, fit calculations, and smooth viewport centering
|
|
228
239
|
|
|
229
240
|
### Utility Managers
|
|
230
241
|
- **`SelectionManager`** - Object selection and multi-selection handling
|
|
@@ -233,6 +244,9 @@ The editor follows a modular architecture with specialized managers:
|
|
|
233
244
|
- **`DeletionManager`** - Object deletion with group handling
|
|
234
245
|
- **`ShapeManager`** - Shape creation (rectangles, circles, triangles)
|
|
235
246
|
- **`ObjectLockManager`** - Object locking and unlocking functionality
|
|
247
|
+
- **`SnappingManager`** - Alignment guides and equal-spacing snaps while moving objects
|
|
248
|
+
- **`MeasurementManager`** - ALT-triggered distance guides to hovered objects or the montage area
|
|
249
|
+
- **`PanConstraintManager`** - Constrains canvas panning relative to zoom and montage bounds
|
|
236
250
|
- **`WorkerManager`** - Web Worker integration for heavy operations
|
|
237
251
|
- **`FontManager`** - Font loading via FontFace API or fallback @font-face injection
|
|
238
252
|
- **`ModuleLoader`** - Dynamic module loading (jsPDF, etc.)
|
|
@@ -243,6 +257,7 @@ The editor follows a modular architecture with specialized managers:
|
|
|
243
257
|
- **`ToolbarManager`** - Dynamic toolbar with configurable actions
|
|
244
258
|
- **`CustomizedControls`** - Custom FabricJS controls and interactions
|
|
245
259
|
- **`InteractionBlocker`** - UI blocking during operations
|
|
260
|
+
- **`AngleIndicatorManager`** - Rotation angle badge shown while rotating selected objects (toggle via `showRotationAngle`)
|
|
246
261
|
|
|
247
262
|
## 📚 API Reference
|
|
248
263
|
|
|
@@ -336,6 +351,11 @@ editor.layerManager.sendBackwards(object)
|
|
|
336
351
|
editor.layerManager.bringForward(object)
|
|
337
352
|
```
|
|
338
353
|
|
|
354
|
+
#### Alignment & Guides
|
|
355
|
+
- Objects snap to montage area edges/centers and nearby objects while dragging, with guides for matches and equal spacing.
|
|
356
|
+
- Hold `Ctrl` during drag to temporarily disable snapping (movement still follows the configured move step).
|
|
357
|
+
- Hold `Alt` with an active selection to show measurement overlays to the hovered object or montage area; distances are labeled on the helper layer and the toolbar hides temporarily until guides clear.
|
|
358
|
+
|
|
339
359
|
#### History Control
|
|
340
360
|
```javascript
|
|
341
361
|
// Undo/Redo
|
|
@@ -446,7 +466,6 @@ jest.config.ts # Jest test configuration
|
|
|
446
466
|
The following features are planned for future releases:
|
|
447
467
|
|
|
448
468
|
- **Drawing Mode** - Freehand drawing tools and brushes
|
|
449
|
-
- **Snap/Alignment** - Snap to edges, centers, and guides
|
|
450
469
|
- **Filters & Effects** - Image filters and visual effects
|
|
451
470
|
- **Extended Shape Library** - Additional shapes beyond current rectangles, circles, and triangles
|
|
452
471
|
- **Multi-language** - Internationalization support
|