@anu3ev/fabric-image-editor 0.3.0 → 0.4.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.
Files changed (3) hide show
  1. package/dist/main.js +542 -494
  2. package/package.json +1 -1
  3. package/readme.md +67 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.03.00",
3
+ "version": "0.4.0",
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
@@ -10,6 +10,7 @@ A modern, powerful browser-based image editor built with [FabricJS](https://fabr
10
10
  - **Montage Area** - Dedicated workspace with clipping region for precise cropping
11
11
  - **Multi-layer Support** - Layer management with ordering, visibility, and locking
12
12
  - **History System** - Full undo/redo with state management
13
+ - **Rich Text Editing** - Text manager with typography controls, uppercase transforms, and history-aware updates
13
14
  - **Object Transformations** - Zoom, rotate, flip, fit, and scale operations
14
15
  - **Professional Tools** - Copy/paste, grouping, selection, and alignment
15
16
 
@@ -17,6 +18,7 @@ A modern, powerful browser-based image editor built with [FabricJS](https://fabr
17
18
  - **Background Management** - Color, gradient, and image backgrounds
18
19
  - **Image Import/Export** - Support for PNG, JPG, SVG, and PDF formats
19
20
  - **Web Worker Integration** - Heavy operations run in background threads
21
+ - **Font Loader** - FontManager handles Google Fonts + custom sources with automatic `@font-face` registration
20
22
  - **Configurable Toolbar** - Dynamic toolbar with context-sensitive actions
21
23
  - **Clipboard Integration** - Native copy/paste support with system clipboard
22
24
 
@@ -113,6 +115,66 @@ await editor.backgroundManager.setImageBackground({ imageSource: 'bg-image.jpg'
113
115
  editor.backgroundManager.removeBackground()
114
116
  ```
115
117
 
118
+ ### Working with Text
119
+
120
+ ```javascript
121
+ // Add a text layer with custom style
122
+ const textbox = editor.textManager.addText({
123
+ text: 'Привет, Fabric!',
124
+ fontFamily: 'Merriweather',
125
+ fontSize: 64,
126
+ bold: true,
127
+ align: 'center',
128
+ color: '#1f2933'
129
+ })
130
+
131
+ // Update existing text
132
+ editor.textManager.updateText({
133
+ target: textbox,
134
+ style: {
135
+ text: 'HELLO FABRIC',
136
+ uppercase: true,
137
+ strokeColor: '#2563eb',
138
+ strokeWidth: 2
139
+ }
140
+ })
141
+ ```
142
+
143
+ ### Configuring Fonts
144
+
145
+ By default the editor ships with a curated Google Fonts collection (Latin + Cyrillic coverage).
146
+ If you want to use your own fonts, supply a `fonts` array – the provided list will replace the defaults.
147
+
148
+ ```typescript
149
+ import initEditor from '@anu3ev/fabric-image-editor'
150
+
151
+ await initEditor('editor', {
152
+ fonts: [
153
+ {
154
+ family: 'Alegreya Sans',
155
+ source: "url('https://fonts.gstatic.com/s/alegreyasans/v26/5aUz9_-1phKLFgshYDvh6Vwt7VptvQ.woff2') format('woff2')",
156
+ descriptors: {
157
+ style: 'normal',
158
+ weight: '400',
159
+ display: 'swap'
160
+ }
161
+ },
162
+ {
163
+ family: 'My Custom Font',
164
+ source: "url('https://example.com/fonts/my-font.woff2') format('woff2')",
165
+ descriptors: {
166
+ style: 'normal',
167
+ weight: '400',
168
+ display: 'swap',
169
+ unicodeRange: 'U+0000-00FF'
170
+ }
171
+ }
172
+ ]
173
+ })
174
+ ```
175
+
176
+ > ℹ️ Leave `fonts` undefined to rely on the built-in defaults. Passing the property replaces that set with the fonts you specify.
177
+
116
178
  ## 🎮 Demo Application
117
179
 
118
180
  The repository includes a comprehensive demo showcasing all features:
@@ -134,6 +196,7 @@ The editor follows a modular architecture with specialized managers:
134
196
  - **`ImageManager`** - Image import/export, format handling, PDF generation
135
197
  - **`CanvasManager`** - Canvas sizing, scaling, and viewport management
136
198
  - **`HistoryManager`** - Undo/redo functionality with state persistence
199
+ - **`TextManager`** - Text object creation, styling, uppercase handling, and history integration
137
200
  - **`LayerManager`** - Object layering, z-index management, send to back/front
138
201
  - **`BackgroundManager`** - Background colors, gradients, and images
139
202
  - **`TransformManager`** - Object transformations, fitting, and scaling
@@ -146,6 +209,7 @@ The editor follows a modular architecture with specialized managers:
146
209
  - **`ShapeManager`** - Shape creation (rectangles, circles, triangles)
147
210
  - **`ObjectLockManager`** - Object locking and unlocking functionality
148
211
  - **`WorkerManager`** - Web Worker integration for heavy operations
212
+ - **`FontManager`** - Font loading via FontFace API or fallback @font-face injection
149
213
  - **`ModuleLoader`** - Dynamic module loading (jsPDF, etc.)
150
214
  - **`ErrorManager`** - Error handling and user notifications
151
215
 
@@ -318,10 +382,13 @@ src/
318
382
  │ ├── object-lock-manager/ # Object locking
319
383
  │ ├── selection-manager/ # Selection handling
320
384
  │ ├── shape-manager/ # Shape creation
385
+ │ ├── text-manager/ # Text objects and styling
386
+ │ ├── font-manager/ # Font loading utilities
321
387
  │ ├── transform-manager/ # Object transformations
322
388
  │ ├── worker-manager/ # Web Worker management
323
389
  │ ├── ui/ # UI components (toolbar)
324
390
  │ └── types/ # TypeScript definitions
391
+ ├── editor/default-fonts.ts # Built-in Google font presets
325
392
  ├── demo/ # Demo application
326
393
  specs/ # Test specifications
327
394
  docs/ # GitHub Pages build output
@@ -336,7 +403,6 @@ jest.config.ts # Jest test configuration
336
403
  The following features are planned for future releases:
337
404
 
338
405
  - **Drawing Mode** - Freehand drawing tools and brushes
339
- - **Text Support** - Text layers with formatting options (IText, Textbox)
340
406
  - **Snap/Alignment** - Snap to edges, centers, and guides
341
407
  - **Filters & Effects** - Image filters and visual effects
342
408
  - **Extended Shape Library** - Additional shapes beyond current rectangles, circles, and triangles