@anu3ev/fabric-image-editor 0.3.0 → 0.3.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.
Files changed (3) hide show
  1. package/dist/main.js +529 -483
  2. package/package.json +1 -1
  3. package/readme.md +64 -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.03.01",
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,63 @@ 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(textbox, {
133
+ text: 'HELLO FABRIC',
134
+ uppercase: true,
135
+ strokeColor: '#2563eb',
136
+ strokeWidth: 2
137
+ })
138
+ ```
139
+
140
+ ### Configuring Fonts
141
+
142
+ By default the editor ships with a curated Google Fonts collection (Latin + Cyrillic coverage).
143
+ If you want to use your own fonts, supply a `fonts` array – the provided list will replace the defaults.
144
+
145
+ ```typescript
146
+ import initEditor from '@anu3ev/fabric-image-editor'
147
+
148
+ await initEditor('editor', {
149
+ fonts: [
150
+ {
151
+ family: 'Alegreya Sans',
152
+ source: "url('https://fonts.gstatic.com/s/alegreyasans/v26/5aUz9_-1phKLFgshYDvh6Vwt7VptvQ.woff2') format('woff2')",
153
+ descriptors: {
154
+ style: 'normal',
155
+ weight: '400',
156
+ display: 'swap'
157
+ }
158
+ },
159
+ {
160
+ family: 'My Custom Font',
161
+ source: "url('https://example.com/fonts/my-font.woff2') format('woff2')",
162
+ descriptors: {
163
+ style: 'normal',
164
+ weight: '400',
165
+ display: 'swap',
166
+ unicodeRange: 'U+0000-00FF'
167
+ }
168
+ }
169
+ ]
170
+ })
171
+ ```
172
+
173
+ > ℹ️ Leave `fonts` undefined to rely on the built-in defaults. Passing the property replaces that set with the fonts you specify.
174
+
116
175
  ## 🎮 Demo Application
117
176
 
118
177
  The repository includes a comprehensive demo showcasing all features:
@@ -134,6 +193,7 @@ The editor follows a modular architecture with specialized managers:
134
193
  - **`ImageManager`** - Image import/export, format handling, PDF generation
135
194
  - **`CanvasManager`** - Canvas sizing, scaling, and viewport management
136
195
  - **`HistoryManager`** - Undo/redo functionality with state persistence
196
+ - **`TextManager`** - Text object creation, styling, uppercase handling, and history integration
137
197
  - **`LayerManager`** - Object layering, z-index management, send to back/front
138
198
  - **`BackgroundManager`** - Background colors, gradients, and images
139
199
  - **`TransformManager`** - Object transformations, fitting, and scaling
@@ -146,6 +206,7 @@ The editor follows a modular architecture with specialized managers:
146
206
  - **`ShapeManager`** - Shape creation (rectangles, circles, triangles)
147
207
  - **`ObjectLockManager`** - Object locking and unlocking functionality
148
208
  - **`WorkerManager`** - Web Worker integration for heavy operations
209
+ - **`FontManager`** - Font loading via FontFace API or fallback @font-face injection
149
210
  - **`ModuleLoader`** - Dynamic module loading (jsPDF, etc.)
150
211
  - **`ErrorManager`** - Error handling and user notifications
151
212
 
@@ -318,10 +379,13 @@ src/
318
379
  │ ├── object-lock-manager/ # Object locking
319
380
  │ ├── selection-manager/ # Selection handling
320
381
  │ ├── shape-manager/ # Shape creation
382
+ │ ├── text-manager/ # Text objects and styling
383
+ │ ├── font-manager/ # Font loading utilities
321
384
  │ ├── transform-manager/ # Object transformations
322
385
  │ ├── worker-manager/ # Web Worker management
323
386
  │ ├── ui/ # UI components (toolbar)
324
387
  │ └── types/ # TypeScript definitions
388
+ ├── editor/default-fonts.ts # Built-in Google font presets
325
389
  ├── demo/ # Demo application
326
390
  specs/ # Test specifications
327
391
  docs/ # GitHub Pages build output
@@ -336,7 +400,6 @@ jest.config.ts # Jest test configuration
336
400
  The following features are planned for future releases:
337
401
 
338
402
  - **Drawing Mode** - Freehand drawing tools and brushes
339
- - **Text Support** - Text layers with formatting options (IText, Textbox)
340
403
  - **Snap/Alignment** - Snap to edges, centers, and guides
341
404
  - **Filters & Effects** - Image filters and visual effects
342
405
  - **Extended Shape Library** - Additional shapes beyond current rectangles, circles, and triangles