@flogeez/angular-tiptap-editor 2.0.2 → 2.1.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/CHANGELOG.md +268 -250
- package/LICENSE +21 -21
- package/README.md +805 -744
- package/fesm2022/flogeez-angular-tiptap-editor.mjs +1943 -1800
- package/fesm2022/flogeez-angular-tiptap-editor.mjs.map +1 -1
- package/index.d.ts +291 -167
- package/package.json +1 -1
- package/src/lib/styles/bubble-menu.global.css +52 -52
- package/src/lib/styles/index.css +40 -40
- package/src/lib/styles/material-symbols.css +17 -17
package/README.md
CHANGED
|
@@ -1,744 +1,805 @@
|
|
|
1
|
-
# Angular Tiptap Editor
|
|
2
|
-
|
|
3
|
-
A modern, customizable rich-text editor for Angular applications, built with Tiptap and featuring complete internationalization support.
|
|
4
|
-
|
|
5
|
-
[](https://flogeez.github.io/angular-tiptap-editor/) [](https://stackblitz.com/edit/angular-tiptap-editor)
|
|
6
|
-
|
|
7
|
-
## 🚀 Features
|
|
8
|
-
|
|
9
|
-
- **Modern Angular**: Built with Angular 18+ using Signals and modern patterns for peak performance.
|
|
10
|
-
- **Full Rich Text Power**: Powered by Tiptap v2 with extensive formatting and block capabilities.
|
|
11
|
-
- **Modern UX (Notion-like)**: Intuitive slash commands and bubble menus for a keyboard-first experience.
|
|
12
|
-
- **Highly Customizable**: Easily configure toolbars, bubble menus, and slash command items.
|
|
13
|
-
- **Signal-Based Reactivity**: Pure Signal architecture natively compatible with `ChangeDetectionStrategy.OnPush`.
|
|
14
|
-
- **Advanced Table Support**: Full table management with cell selection and context-aware bubble menus.
|
|
15
|
-
- **Professional Media**: Advanced image handling with resizing, auto-compression, and custom uploaders.
|
|
16
|
-
- **Built-in i18n**: English & French support with a reactive, extensible locale system.
|
|
17
|
-
- **Word/Character Count**: Real-time statistics with proper pluralization support.
|
|
18
|
-
- **Office-Ready**: Cleaned-up pasting from Microsoft Word and Excel to maintain layout integrity.
|
|
19
|
-
- **Service Driven**: Deep programmatic control via `EditorCommandsService` and isolated instances.
|
|
20
|
-
- **A11y First**: Built with accessibility best practices and full keyboard navigation.
|
|
21
|
-
|
|
22
|
-
## 💎 Why this editor?
|
|
23
|
-
|
|
24
|
-
Most Angular wrappers for Tiptap provide a basic component but leave the heavy lifting to you. **Angular Tiptap Editor** is built to solve common production hurdles:
|
|
25
|
-
|
|
26
|
-
- **True Scalability**: Thanks to **isolated services** provided at the component level, you can host multiple independent editors with different configurations and languages on the same page without a single state leak.
|
|
27
|
-
- **OnPush by Default**: The entire UI (toolbar, menus) is powered by **Angular Signals**. The `editorState` snapshot logic ensures that your components only re-render when necessary, even in complex `OnPush` applications.
|
|
28
|
-
- **Deep i18n & Extensibility**: Not just English/French — you can inject **custom translations** and **custom Tiptap extensions**. Our `DiscoveryCalculator` automatically tracks any new mark or node you add, making them reactive without extra code.
|
|
29
|
-
- **Clean Office UX**: Professional-grade pasting from **Word and Excel** plus smart image handling (auto-compression, resizing handles) ensures a polished experience for end-users.
|
|
30
|
-
|
|
31
|
-
## 🛠️ Extensions included
|
|
32
|
-
|
|
33
|
-
The library comes with a pre-configured set of standard and custom extensions:
|
|
34
|
-
|
|
35
|
-
- **Nodes**: `StarterKit`, `Heading`, `Table`, `Image`, `HorizontalRule`, `CodeBlock`.
|
|
36
|
-
- **Marks**: `Bold`, `Italic`, `Underline`, `Strike`, `Code`, `Link`, `Highlight`, `TextStyle`, `Color`, `Superscript`, `Subscript`.
|
|
37
|
-
- **Utilities**: `Placeholder`, `CharacterCount`, `Typography`, `Focus`, `BubbleMenu`, `Gapcursor`, `Dropcursor`, `ResizableImage` (Custom).
|
|
38
|
-
|
|
39
|
-
## 📦 Installation
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm install @flogeez/angular-tiptap-editor
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### CSS Styles
|
|
46
|
-
|
|
47
|
-
Add the required CSS to your `angular.json` file in the `styles` array:
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"styles": [
|
|
52
|
-
...
|
|
53
|
-
"node_modules/@fontsource/material-symbols-outlined/index.css",
|
|
54
|
-
"node_modules/@flogeez/angular-tiptap-editor/src/lib/styles/index.css",
|
|
55
|
-
...
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## 🎯 Quick Start
|
|
61
|
-
|
|
62
|
-
### 1. Basic Usage
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { Component } from "@angular/core";
|
|
66
|
-
import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
67
|
-
|
|
68
|
-
@Component({
|
|
69
|
-
selector: "app-example",
|
|
70
|
-
standalone: true,
|
|
71
|
-
imports: [AngularTiptapEditorComponent],
|
|
72
|
-
template: `
|
|
73
|
-
<angular-tiptap-editor
|
|
74
|
-
[content]="content"
|
|
75
|
-
(contentChange)="onContentChange($event)"
|
|
76
|
-
/>
|
|
77
|
-
`,
|
|
78
|
-
})
|
|
79
|
-
export class ExampleComponent {
|
|
80
|
-
content = "<p>Hello <strong>World</strong>!</p>";
|
|
81
|
-
|
|
82
|
-
onContentChange(newContent: string) {
|
|
83
|
-
this.content = newContent;
|
|
84
|
-
console.log("Content updated:", newContent);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 2. With Custom Configuration
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
[
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
- **
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
- **
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
- **
|
|
361
|
-
- **
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
- `
|
|
432
|
-
- `
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
###
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
|
475
|
-
|
|
|
476
|
-
| `
|
|
477
|
-
| `
|
|
478
|
-
| `
|
|
479
|
-
| `
|
|
480
|
-
| `
|
|
481
|
-
| `
|
|
482
|
-
| `
|
|
483
|
-
| `
|
|
484
|
-
| `
|
|
485
|
-
| `
|
|
486
|
-
| `
|
|
487
|
-
| `showBubbleMenu`
|
|
488
|
-
| `showImageBubbleMenu
|
|
489
|
-
| `
|
|
490
|
-
| `
|
|
491
|
-
| `enableSlashCommands
|
|
492
|
-
| `enableOfficePaste`
|
|
493
|
-
| `showCharacterCount`
|
|
494
|
-
| `showWordCount`
|
|
495
|
-
| `toolbar`
|
|
496
|
-
| `bubbleMenu`
|
|
497
|
-
| `
|
|
498
|
-
| `
|
|
499
|
-
| `
|
|
500
|
-
| `
|
|
501
|
-
| `
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
//
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
```css
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
--ate-
|
|
620
|
-
--ate-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
-
|
|
673
|
-
-
|
|
674
|
-
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
-
|
|
727
|
-
-
|
|
728
|
-
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
###
|
|
735
|
-
|
|
736
|
-
-
|
|
737
|
-
-
|
|
738
|
-
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
1
|
+
# Angular Tiptap Editor
|
|
2
|
+
|
|
3
|
+
A modern, customizable rich-text editor for Angular applications, built with Tiptap and featuring complete internationalization support.
|
|
4
|
+
|
|
5
|
+
[](https://flogeez.github.io/angular-tiptap-editor/) [](https://stackblitz.com/edit/angular-tiptap-editor)
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
- **Modern Angular**: Built with Angular 18+ using Signals and modern patterns for peak performance.
|
|
10
|
+
- **Full Rich Text Power**: Powered by Tiptap v2 with extensive formatting and block capabilities.
|
|
11
|
+
- **Modern UX (Notion-like)**: Intuitive slash commands and bubble menus for a keyboard-first experience.
|
|
12
|
+
- **Highly Customizable**: Easily configure toolbars, bubble menus, and slash command items.
|
|
13
|
+
- **Signal-Based Reactivity**: Pure Signal architecture natively compatible with `ChangeDetectionStrategy.OnPush`.
|
|
14
|
+
- **Advanced Table Support**: Full table management with cell selection and context-aware bubble menus.
|
|
15
|
+
- **Professional Media**: Advanced image handling with resizing, auto-compression, and custom uploaders.
|
|
16
|
+
- **Built-in i18n**: English & French support with a reactive, extensible locale system.
|
|
17
|
+
- **Word/Character Count**: Real-time statistics with proper pluralization support.
|
|
18
|
+
- **Office-Ready**: Cleaned-up pasting from Microsoft Word and Excel to maintain layout integrity.
|
|
19
|
+
- **Service Driven**: Deep programmatic control via `EditorCommandsService` and isolated instances.
|
|
20
|
+
- **A11y First**: Built with accessibility best practices and full keyboard navigation.
|
|
21
|
+
|
|
22
|
+
## 💎 Why this editor?
|
|
23
|
+
|
|
24
|
+
Most Angular wrappers for Tiptap provide a basic component but leave the heavy lifting to you. **Angular Tiptap Editor** is built to solve common production hurdles:
|
|
25
|
+
|
|
26
|
+
- **True Scalability**: Thanks to **isolated services** provided at the component level, you can host multiple independent editors with different configurations and languages on the same page without a single state leak.
|
|
27
|
+
- **OnPush by Default**: The entire UI (toolbar, menus) is powered by **Angular Signals**. The `editorState` snapshot logic ensures that your components only re-render when necessary, even in complex `OnPush` applications.
|
|
28
|
+
- **Deep i18n & Extensibility**: Not just English/French — you can inject **custom translations** and **custom Tiptap extensions**. Our `DiscoveryCalculator` automatically tracks any new mark or node you add, making them reactive without extra code.
|
|
29
|
+
- **Clean Office UX**: Professional-grade pasting from **Word and Excel** plus smart image handling (auto-compression, resizing handles) ensures a polished experience for end-users.
|
|
30
|
+
|
|
31
|
+
## 🛠️ Extensions included
|
|
32
|
+
|
|
33
|
+
The library comes with a pre-configured set of standard and custom extensions:
|
|
34
|
+
|
|
35
|
+
- **Nodes**: `StarterKit`, `Heading`, `Table`, `Image`, `HorizontalRule`, `CodeBlock`.
|
|
36
|
+
- **Marks**: `Bold`, `Italic`, `Underline`, `Strike`, `Code`, `Link`, `Highlight`, `TextStyle`, `Color`, `Superscript`, `Subscript`.
|
|
37
|
+
- **Utilities**: `Placeholder`, `CharacterCount`, `Typography`, `Focus`, `BubbleMenu`, `Gapcursor`, `Dropcursor`, `ResizableImage` (Custom).
|
|
38
|
+
|
|
39
|
+
## 📦 Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @flogeez/angular-tiptap-editor
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### CSS Styles
|
|
46
|
+
|
|
47
|
+
Add the required CSS to your `angular.json` file in the `styles` array:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"styles": [
|
|
52
|
+
...
|
|
53
|
+
"node_modules/@fontsource/material-symbols-outlined/index.css",
|
|
54
|
+
"node_modules/@flogeez/angular-tiptap-editor/src/lib/styles/index.css",
|
|
55
|
+
...
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🎯 Quick Start
|
|
61
|
+
|
|
62
|
+
### 1. Basic Usage
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from "@angular/core";
|
|
66
|
+
import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
67
|
+
|
|
68
|
+
@Component({
|
|
69
|
+
selector: "app-example",
|
|
70
|
+
standalone: true,
|
|
71
|
+
imports: [AngularTiptapEditorComponent],
|
|
72
|
+
template: `
|
|
73
|
+
<angular-tiptap-editor
|
|
74
|
+
[content]="content"
|
|
75
|
+
(contentChange)="onContentChange($event)"
|
|
76
|
+
/>
|
|
77
|
+
`,
|
|
78
|
+
})
|
|
79
|
+
export class ExampleComponent {
|
|
80
|
+
content = "<p>Hello <strong>World</strong>!</p>";
|
|
81
|
+
|
|
82
|
+
onContentChange(newContent: string) {
|
|
83
|
+
this.content = newContent;
|
|
84
|
+
console.log("Content updated:", newContent);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. With Custom Configuration
|
|
90
|
+
|
|
91
|
+
The editor can be fully configured using a single `[config]` object, which provides a clean and type-safe way to manage all settings.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { Component } from "@angular/core";
|
|
95
|
+
import {
|
|
96
|
+
AngularTiptapEditorComponent,
|
|
97
|
+
AteEditorConfig,
|
|
98
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
99
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
100
|
+
|
|
101
|
+
@Component({
|
|
102
|
+
selector: "app-advanced",
|
|
103
|
+
standalone: true,
|
|
104
|
+
imports: [AngularTiptapEditorComponent],
|
|
105
|
+
template: `
|
|
106
|
+
<angular-tiptap-editor
|
|
107
|
+
[content]="content"
|
|
108
|
+
[config]="editorConfig"
|
|
109
|
+
(contentChange)="onContentChange($event)"
|
|
110
|
+
/>
|
|
111
|
+
`,
|
|
112
|
+
})
|
|
113
|
+
export class AdvancedComponent {
|
|
114
|
+
content = "<h1>Welcome!</h1><p>Start editing...</p>";
|
|
115
|
+
|
|
116
|
+
editorConfig: AteEditorConfig = {
|
|
117
|
+
locale: "fr", // Force French (default is auto-detect)
|
|
118
|
+
height: "400px", // Set a fixed height
|
|
119
|
+
placeholder: "Commencez à rédiger...",
|
|
120
|
+
showWordCount: false, // Hide the word counter (default is true)
|
|
121
|
+
showEditToggle: true, // Show the button to toggle read-only mode (default is false)
|
|
122
|
+
|
|
123
|
+
// Customize the toolbar by enabling specific features
|
|
124
|
+
toolbar: {
|
|
125
|
+
...DEFAULT_TOOLBAR_CONFIG,
|
|
126
|
+
clear: true, // Enable the 'Clear' button
|
|
127
|
+
highlight: false, // Disable the highlight button
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// Only enable specific slash commands
|
|
131
|
+
slashCommands: {
|
|
132
|
+
heading1: true,
|
|
133
|
+
heading2: true,
|
|
134
|
+
image: true,
|
|
135
|
+
table: true,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
onContentChange(newContent: string) {
|
|
140
|
+
this.content = newContent;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 3. Registering Custom Extensions
|
|
146
|
+
|
|
147
|
+
Easily extend the editor with any standard Tiptap extension or your own custom marks/nodes via the `tiptapExtensions` input.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Component } from "@angular/core";
|
|
151
|
+
import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
152
|
+
|
|
153
|
+
@Component({
|
|
154
|
+
selector: "app-custom-extensions",
|
|
155
|
+
standalone: true,
|
|
156
|
+
imports: [AngularTiptapEditorComponent],
|
|
157
|
+
template: `
|
|
158
|
+
<angular-tiptap-editor
|
|
159
|
+
[content]="content"
|
|
160
|
+
[tiptapExtensions]="extensions"
|
|
161
|
+
(contentChange)="content = $event"
|
|
162
|
+
/>
|
|
163
|
+
`,
|
|
164
|
+
})
|
|
165
|
+
export class CustomExtensionsComponent {
|
|
166
|
+
content = "<p>Custom extensions example</p>";
|
|
167
|
+
|
|
168
|
+
extensions = [
|
|
169
|
+
// Add your custom TipTap extensions here
|
|
170
|
+
// Example: Custom extension configuration
|
|
171
|
+
// MyCustomExtension.configure({ /* options */ })
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 4. With Form Integration
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { Component } from "@angular/core";
|
|
180
|
+
import { FormControl, ReactiveFormsModule } from "@angular/forms";
|
|
181
|
+
import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
182
|
+
|
|
183
|
+
@Component({
|
|
184
|
+
selector: "app-form",
|
|
185
|
+
standalone: true,
|
|
186
|
+
imports: [AngularTiptapEditorComponent, ReactiveFormsModule],
|
|
187
|
+
template: `
|
|
188
|
+
<form>
|
|
189
|
+
<angular-tiptap-editor
|
|
190
|
+
[formControl]="contentControl"
|
|
191
|
+
placeholder="Enter your content here..."
|
|
192
|
+
[showCharacterCount]="true"
|
|
193
|
+
[showWordCount]="true"
|
|
194
|
+
/>
|
|
195
|
+
<button type="submit">Submit</button>
|
|
196
|
+
</form>
|
|
197
|
+
`,
|
|
198
|
+
})
|
|
199
|
+
export class FormComponent {
|
|
200
|
+
contentControl = new FormControl("<p>Initial content</p>");
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 5. Using EditorCommandsService
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { Component, inject } from "@angular/core";
|
|
208
|
+
import { EditorCommandsService } from "@flogeez/angular-tiptap-editor";
|
|
209
|
+
|
|
210
|
+
@Component({
|
|
211
|
+
selector: "app-commands",
|
|
212
|
+
standalone: true,
|
|
213
|
+
template: `
|
|
214
|
+
<div>
|
|
215
|
+
<div class="controls">
|
|
216
|
+
<button (click)="clearContent()">Clear Content</button>
|
|
217
|
+
<button (click)="focusEditor()">Focus Editor</button>
|
|
218
|
+
<button (click)="setContent()">Set Content</button>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<angular-tiptap-editor (editorCreated)="onEditorCreated($event)" />
|
|
222
|
+
</div>
|
|
223
|
+
`,
|
|
224
|
+
})
|
|
225
|
+
export class CommandsComponent {
|
|
226
|
+
private editorCommandsService = inject(EditorCommandsService);
|
|
227
|
+
private editor: Editor | null = null;
|
|
228
|
+
|
|
229
|
+
onEditorCreated(editor: Editor) {
|
|
230
|
+
this.editor = editor;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
clearContent() {
|
|
234
|
+
if (this.editor) {
|
|
235
|
+
this.editorCommandsService.clearContent(this.editor);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
focusEditor() {
|
|
240
|
+
if (this.editor) {
|
|
241
|
+
this.editorCommandsService.focus(this.editor);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
setContent() {
|
|
246
|
+
if (this.editor) {
|
|
247
|
+
this.editorCommandsService.setContent(
|
|
248
|
+
this.editor,
|
|
249
|
+
"<h1>New Content</h1>",
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 6. Extending Reactive Editor State
|
|
257
|
+
|
|
258
|
+
The editor features a dual-layer state architecture: **Automatic Tracking** for simple extensions and **Custom Calculators** for advanced needs.
|
|
259
|
+
|
|
260
|
+
#### A. Automatic Extension Tracking (Zero Config)
|
|
261
|
+
|
|
262
|
+
Any TipTap **Mark** or **Node** you add to `tiptapExtensions` is automatically tracked by our `DiscoveryCalculator`. You don't need to write any extra code to make them reactive.
|
|
263
|
+
|
|
264
|
+
- **For Marks**: `state().marks.yourExtensionName` (boolean) and `state().can.toggleYourExtensionName` (boolean).
|
|
265
|
+
- **For Nodes**: `state().nodes.yourExtensionName` (boolean).
|
|
266
|
+
|
|
267
|
+
#### B. Custom State Calculators (Advanced)
|
|
268
|
+
|
|
269
|
+
If you need to extract complex data (like attributes, depth, or custom logic), you can provide a custom `StateCalculator`.
|
|
270
|
+
|
|
271
|
+
1. **Define a Calculator**:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { StateCalculator } from "@flogeez/angular-tiptap-editor";
|
|
275
|
+
|
|
276
|
+
// This function will be called on every editor update
|
|
277
|
+
export const MyCustomCalculator: StateCalculator = (editor) => {
|
|
278
|
+
return {
|
|
279
|
+
custom: {
|
|
280
|
+
hasHighPriority: editor.isActive("priority"),
|
|
281
|
+
selectionDepth: editor.state.selection.$from.depth,
|
|
282
|
+
// Any data you need...
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
2. **Register it in the Template**:
|
|
289
|
+
|
|
290
|
+
```html
|
|
291
|
+
<angular-tiptap-editor [stateCalculators]="[MyCustomCalculator]" />
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
3. **Consume it anywhere**:
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
@Component({ ... })
|
|
298
|
+
export class MyToolbarComponent {
|
|
299
|
+
private editorCommands = inject(EditorCommandsService);
|
|
300
|
+
|
|
301
|
+
// Access your custom data reactively!
|
|
302
|
+
isHighPriority = computed(() => this.editorCommands.editorState().custom?.hasHighPriority);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## ✨ Key Features
|
|
307
|
+
|
|
308
|
+
### 📊 Table Management
|
|
309
|
+
|
|
310
|
+
Full table support with intuitive bubble menus:
|
|
311
|
+
|
|
312
|
+
- **Table Creation**: Insert tables via slash commands (`/table`)
|
|
313
|
+
- **Cell Selection**: Click and drag to select multiple cells
|
|
314
|
+
- **Bubble Menus**: Context-aware menus for table operations
|
|
315
|
+
- **Row/Column Management**: Add, remove, and merge cells
|
|
316
|
+
- **Styling**: Custom table styling with proper borders
|
|
317
|
+
|
|
318
|
+
### ⚡ Slash Commands
|
|
319
|
+
|
|
320
|
+
Quick content insertion with slash commands:
|
|
321
|
+
|
|
322
|
+
- **Headings**: `/h1`, `/h2`, `/h3`
|
|
323
|
+
- **Lists**: `/bullet`, `/numbered`
|
|
324
|
+
- **Blocks**: `/quote`, `/code`, `/line`
|
|
325
|
+
- **Media**: `/image`, `/table`
|
|
326
|
+
- **Fully Internationalized**: All commands translated
|
|
327
|
+
|
|
328
|
+
#### Custom Slash Commands
|
|
329
|
+
|
|
330
|
+
The `slashCommands` object also allows you to add completely custom command items:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
import { SlashCommandsConfig } from "@flogeez/angular-tiptap-editor";
|
|
334
|
+
|
|
335
|
+
slashCommands: SlashCommandsConfig = {
|
|
336
|
+
// Toggle native commands
|
|
337
|
+
heading1: true,
|
|
338
|
+
image: false,
|
|
339
|
+
// Add custom ones
|
|
340
|
+
custom: [
|
|
341
|
+
{
|
|
342
|
+
title: "Magic Action",
|
|
343
|
+
description: "Insert some AI magic",
|
|
344
|
+
icon: "auto_fix",
|
|
345
|
+
keywords: ["magic", "ai"],
|
|
346
|
+
command: (editor) => editor.commands.insertContent("✨ Magic happened!"),
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
};
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 🖼️ Advanced Image Handling
|
|
353
|
+
|
|
354
|
+
Professional image management:
|
|
355
|
+
|
|
356
|
+
- **Drag & Drop**: Drag images directly into the editor
|
|
357
|
+
- **File Selection**: Click to select images from device
|
|
358
|
+
- **Auto-Compression**: Images automatically compressed (max 1920x1080)
|
|
359
|
+
- **Resizable**: Images can be resized with handles
|
|
360
|
+
- **Bubble Menu**: Context menu for image operations
|
|
361
|
+
- **Custom Upload Handler**: Upload images to your own server instead of base64
|
|
362
|
+
|
|
363
|
+
#### Custom Image Upload Handler
|
|
364
|
+
|
|
365
|
+
By default, images are converted to base64 and embedded directly in the HTML content. You can provide a custom upload handler to upload images to your own server (S3, Cloudinary, custom API, etc.) and use the returned URL instead.
|
|
366
|
+
|
|
367
|
+
The handler can return either an **Observable** or a **Promise**.
|
|
368
|
+
|
|
369
|
+
#### Using Observable (recommended for Angular)
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { Component, inject } from "@angular/core";
|
|
373
|
+
import { HttpClient } from "@angular/common/http";
|
|
374
|
+
import { map } from "rxjs/operators";
|
|
375
|
+
import {
|
|
376
|
+
AngularTiptapEditorComponent,
|
|
377
|
+
ImageUploadHandler,
|
|
378
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
379
|
+
|
|
380
|
+
@Component({
|
|
381
|
+
selector: "app-custom-upload",
|
|
382
|
+
standalone: true,
|
|
383
|
+
imports: [AngularTiptapEditorComponent],
|
|
384
|
+
template: `
|
|
385
|
+
<angular-tiptap-editor
|
|
386
|
+
[content]="content"
|
|
387
|
+
[imageUploadHandler]="uploadHandler"
|
|
388
|
+
(contentChange)="onContentChange($event)"
|
|
389
|
+
/>
|
|
390
|
+
`,
|
|
391
|
+
})
|
|
392
|
+
export class CustomUploadComponent {
|
|
393
|
+
private http = inject(HttpClient);
|
|
394
|
+
content = "";
|
|
395
|
+
|
|
396
|
+
uploadHandler: ImageUploadHandler = (ctx) => {
|
|
397
|
+
const formData = new FormData();
|
|
398
|
+
formData.append("image", ctx.file);
|
|
399
|
+
|
|
400
|
+
return this.http
|
|
401
|
+
.post<{ url: string }>("/api/upload", formData)
|
|
402
|
+
.pipe(map((result) => ({ src: result.url })));
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
onContentChange(newContent: string) {
|
|
406
|
+
this.content = newContent;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### Using Promise (async/await)
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
uploadHandler: ImageUploadHandler = async (ctx) => {
|
|
415
|
+
const formData = new FormData();
|
|
416
|
+
formData.append("image", ctx.file);
|
|
417
|
+
|
|
418
|
+
const result = await firstValueFrom(
|
|
419
|
+
this.http.post<{ url: string }>("/api/upload", formData),
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
return { src: result.url };
|
|
423
|
+
};
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
The `ImageUploadContext` provides:
|
|
427
|
+
|
|
428
|
+
- `file`: The original File object
|
|
429
|
+
- `width`: Processed image width
|
|
430
|
+
- `height`: Processed image height
|
|
431
|
+
- `type`: MIME type (e.g., 'image/jpeg')
|
|
432
|
+
- `base64`: Base64 data URL of the processed image (fallback)
|
|
433
|
+
|
|
434
|
+
The handler must return an `ImageUploadHandlerResult` with at least a `src` property containing the image URL.
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
### 📝 Word & Character Counting
|
|
439
|
+
|
|
440
|
+
Real-time content statistics:
|
|
441
|
+
|
|
442
|
+
- **Live Updates**: Counters update as you type
|
|
443
|
+
- **Proper Pluralization**: "1 word" vs "2 words"
|
|
444
|
+
- **Separate Counts**: Independent word and character counts
|
|
445
|
+
- **Configurable**: Show/hide individual counters
|
|
446
|
+
|
|
447
|
+
## 🎨 Demo
|
|
448
|
+
|
|
449
|
+
### 🌐 Live Demo
|
|
450
|
+
|
|
451
|
+
Try the interactive demo online: **[https://flogeez.github.io/angular-tiptap-editor/](https://flogeez.github.io/angular-tiptap-editor/)**
|
|
452
|
+
|
|
453
|
+
### 🖥️ Run Locally
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
git clone https://github.com/FloGeez/angular-tiptap-editor.git
|
|
457
|
+
cd angular-tiptap-editor
|
|
458
|
+
npm install
|
|
459
|
+
npm start
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Open [http://localhost:4200](http://localhost:4200) to view the demo.
|
|
463
|
+
|
|
464
|
+
## 📖 Documentation
|
|
465
|
+
|
|
466
|
+
### API Reference
|
|
467
|
+
|
|
468
|
+
#### Inputs
|
|
469
|
+
|
|
470
|
+
| Input | Type | Default | Description |
|
|
471
|
+
| --------------------- | ------------------------------------------------ | ------------------- | --------------------------------------------- |
|
|
472
|
+
| `config` | `AteEditorConfig` | `{}` | **Global configuration object** (Recommended) |
|
|
473
|
+
| `content` | `string` | `""` | Initial HTML content |
|
|
474
|
+
| `placeholder` | `string` | `"Start typing..."` | Placeholder text (overrides config) |
|
|
475
|
+
| `locale` | `'en' \| 'fr'` | Auto-detect | Editor language (overrides config) |
|
|
476
|
+
| `editable` | `boolean` | `true` | Whether editor is editable |
|
|
477
|
+
| `height` | `string` | `undefined` | Editor height (e.g. '400px', 'auto') |
|
|
478
|
+
| `maxHeight` | `string` | `undefined` | Maximum height (e.g. '80vh') |
|
|
479
|
+
| `minHeight` | `string` | `undefined` | Minimum height |
|
|
480
|
+
| `maxCharacters` | `number` | `undefined` | Character limit |
|
|
481
|
+
| `fillContainer` | `boolean` | `false` | Fill parent container height |
|
|
482
|
+
| `autofocus` | `boolean \| 'start' \| 'end' \| 'all' \| number` | `false` | Auto-focus behavior |
|
|
483
|
+
| `disabled` | `boolean` | `false` | Disabled state (for forms) |
|
|
484
|
+
| `spellcheck` | `boolean` | `true` | Enable browser spellcheck |
|
|
485
|
+
| `showToolbar` | `boolean` | `true` | Show toolbar |
|
|
486
|
+
| `showFooter` | `boolean` | `true` | Show footer (counters) |
|
|
487
|
+
| `showBubbleMenu` | `boolean` | `true` | Show text bubble menu |
|
|
488
|
+
| `showImageBubbleMenu` | `boolean` | `true` | Show image bubble menu |
|
|
489
|
+
| `showTableMenu` | `boolean` | `true` | Show table bubble menu |
|
|
490
|
+
| `showCellMenu` | `boolean` | `true` | Show cell bubble menu |
|
|
491
|
+
| `enableSlashCommands` | `boolean` | `true` | Enable slash commands functionality |
|
|
492
|
+
| `enableOfficePaste` | `boolean` | `true` | Enable smart Office pasting |
|
|
493
|
+
| `showCharacterCount` | `boolean` | `true` | Show character counter |
|
|
494
|
+
| `showWordCount` | `boolean` | `true` | Show word counter |
|
|
495
|
+
| `toolbar` | `ToolbarConfig` | All enabled | Detailed toolbar configuration |
|
|
496
|
+
| `bubbleMenu` | `BubbleMenuConfig` | All enabled | Detailed bubble menu configuration |
|
|
497
|
+
| `slashCommands` | `SlashCommandsConfig` | All enabled | Detailed slash commands config |
|
|
498
|
+
| `imageUploadHandler` | `ImageUploadHandler` | `undefined` | Custom image upload function |
|
|
499
|
+
| `stateCalculators` | `StateCalculator[]` | `[]` | Custom reactive state logic |
|
|
500
|
+
| `tiptapExtensions` | `(Extension \| Node \| Mark)[]` | `[]` | Additional Tiptap extensions |
|
|
501
|
+
| `tiptapOptions` | `Partial<EditorOptions>` | `{}` | Additional Tiptap editor options |
|
|
502
|
+
|
|
503
|
+
> **Note on Precedence**: Values provided in individual inputs (e.g., `[editable]="false"`) always take precedence over values defined inside the `[config]` object.
|
|
504
|
+
|
|
505
|
+
#### AteEditorConfig Reference
|
|
506
|
+
|
|
507
|
+
The `AteEditorConfig` nested structure allows for complex configurations while remaining flat for core settings:
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
export interface AteEditorConfig {
|
|
511
|
+
// Core Settings
|
|
512
|
+
theme?: "light" | "dark" | "auto";
|
|
513
|
+
height?: string;
|
|
514
|
+
minHeight?: string;
|
|
515
|
+
maxHeight?: string;
|
|
516
|
+
fillContainer?: boolean;
|
|
517
|
+
autofocus?: "start" | "end" | "all" | boolean | number;
|
|
518
|
+
placeholder?: string;
|
|
519
|
+
editable?: boolean;
|
|
520
|
+
disabled?: boolean;
|
|
521
|
+
locale?: string;
|
|
522
|
+
spellcheck?: boolean;
|
|
523
|
+
enableOfficePaste?: boolean;
|
|
524
|
+
|
|
525
|
+
// Visibility Options
|
|
526
|
+
showToolbar?: boolean;
|
|
527
|
+
showFooter?: boolean;
|
|
528
|
+
showCharacterCount?: boolean;
|
|
529
|
+
showWordCount?: boolean;
|
|
530
|
+
showEditToggle?: boolean;
|
|
531
|
+
showBubbleMenu?: boolean;
|
|
532
|
+
showImageBubbleMenu?: boolean;
|
|
533
|
+
showTableMenu?: boolean;
|
|
534
|
+
showCellMenu?: boolean;
|
|
535
|
+
enableSlashCommands?: boolean;
|
|
536
|
+
maxCharacters?: number;
|
|
537
|
+
|
|
538
|
+
// Complex Modules
|
|
539
|
+
toolbar?: ToolbarConfig;
|
|
540
|
+
bubbleMenu?: BubbleMenuConfig;
|
|
541
|
+
imageBubbleMenu?: ImageBubbleMenuConfig;
|
|
542
|
+
tableBubbleMenu?: TableBubbleMenuConfig;
|
|
543
|
+
cellBubbleMenu?: CellBubbleMenuConfig;
|
|
544
|
+
slashCommands?: SlashCommandsConfig;
|
|
545
|
+
imageUpload?: AteImageUploadConfig;
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
#### Image Upload Configuration
|
|
550
|
+
|
|
551
|
+
The `imageUpload` property in `AteEditorConfig` provides fine-grained control over the image processing pipeline:
|
|
552
|
+
|
|
553
|
+
```typescript
|
|
554
|
+
export interface AteImageUploadConfig {
|
|
555
|
+
/** Custom handler to upload files to a server */
|
|
556
|
+
handler?: ImageUploadHandler;
|
|
557
|
+
/** Maximum file size in bytes (default: 10MB) */
|
|
558
|
+
maxFileSize?: number;
|
|
559
|
+
/** Accepted file types (default: 'image/*') */
|
|
560
|
+
accept?: string;
|
|
561
|
+
/** Whether to automatically compress images before upload (default: true) */
|
|
562
|
+
autoCompress?: boolean;
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
#### Outputs
|
|
567
|
+
|
|
568
|
+
| Output | Type | Description |
|
|
569
|
+
| --------------- | ----------------- | ------------------------------- |
|
|
570
|
+
| `contentChange` | `string` | Emitted when content changes |
|
|
571
|
+
| `editorCreated` | `Editor` | Emitted when editor is created |
|
|
572
|
+
| `editorUpdate` | `{editor, trans}` | Emitted on every editor update |
|
|
573
|
+
| `editorFocus` | `{editor, event}` | Emitted when editor gains focus |
|
|
574
|
+
| `editorBlur` | `{editor, event}` | Emitted when editor loses focus |
|
|
575
|
+
|
|
576
|
+
## 🌍 Internationalization
|
|
577
|
+
|
|
578
|
+
The editor comes with built-in support for **English (en)** and **French (fr)**, featuring automatic browser language detection.
|
|
579
|
+
|
|
580
|
+
### Basic Usage
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
583
|
+
// Force a specific language
|
|
584
|
+
<angular-tiptap-editor [locale]="'fr'" />
|
|
585
|
+
|
|
586
|
+
// Auto-detect (default)
|
|
587
|
+
<angular-tiptap-editor />
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### Adding Custom Languages
|
|
591
|
+
|
|
592
|
+
You can easily extend the editor with new languages or override existing labels using the `TiptapI18nService`:
|
|
593
|
+
|
|
594
|
+
```typescript
|
|
595
|
+
import { TiptapI18nService } from "@flogeez/angular-tiptap-editor";
|
|
596
|
+
|
|
597
|
+
@Component({ ... })
|
|
598
|
+
export class MyComponent {
|
|
599
|
+
constructor(private i18nService: TiptapI18nService) {
|
|
600
|
+
// Add Spanish support
|
|
601
|
+
this.i18nService.addTranslations('es', {
|
|
602
|
+
toolbar: { bold: 'Negrita', italic: 'Cursiva', ... },
|
|
603
|
+
editor: { placeholder: 'Empieza a escribir...' }
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// Switch to Spanish
|
|
607
|
+
this.i18nService.setLocale('es');
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### 🎨 CSS Custom Properties
|
|
613
|
+
|
|
614
|
+
Customize the editor appearance using CSS variables with the `--ate-` prefix:
|
|
615
|
+
|
|
616
|
+
```css
|
|
617
|
+
/* In your global styles or component styles */
|
|
618
|
+
angular-tiptap-editor {
|
|
619
|
+
--ate-primary: #2563eb;
|
|
620
|
+
--ate-primary-contrast: #ffffff;
|
|
621
|
+
--ate-primary-light: color-mix(in srgb, var(--ate-primary), transparent 90%);
|
|
622
|
+
--ate-primary-lighter: color-mix(
|
|
623
|
+
in srgb,
|
|
624
|
+
var(--ate-primary),
|
|
625
|
+
transparent 95%
|
|
626
|
+
);
|
|
627
|
+
--ate-primary-light-alpha: color-mix(
|
|
628
|
+
in srgb,
|
|
629
|
+
var(--ate-primary),
|
|
630
|
+
transparent 85%
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
--ate-surface: #ffffff;
|
|
634
|
+
--ate-surface-secondary: #f8f9fa;
|
|
635
|
+
--ate-surface-tertiary: #f1f5f9;
|
|
636
|
+
|
|
637
|
+
--ate-text: #2d3748;
|
|
638
|
+
--ate-text-secondary: #64748b;
|
|
639
|
+
--ate-text-muted: #a0aec0;
|
|
640
|
+
|
|
641
|
+
--ate-border: #e2e8f0;
|
|
642
|
+
|
|
643
|
+
/* And More... */
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
#### Dark Mode Support
|
|
648
|
+
|
|
649
|
+
The editor supports dark mode in two ways:
|
|
650
|
+
|
|
651
|
+
**1. With CSS Class**
|
|
652
|
+
|
|
653
|
+
```html
|
|
654
|
+
<angular-tiptap-editor [class.dark]="isDarkMode" />
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
**2. With Data Attribute**
|
|
658
|
+
|
|
659
|
+
```html
|
|
660
|
+
<angular-tiptap-editor [attr.data-theme]="isDarkMode ? 'dark' : null" />
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
#### Example: Custom Dark Theme
|
|
664
|
+
|
|
665
|
+
```css
|
|
666
|
+
angular-tiptap-editor.dark {
|
|
667
|
+
--ate-background: #1a1a2e;
|
|
668
|
+
--ate-border-color: #3d3d5c;
|
|
669
|
+
--ate-focus-color: #6366f1;
|
|
670
|
+
--ate-text-color: #e2e8f0;
|
|
671
|
+
--ate-placeholder-color: #64748b;
|
|
672
|
+
--ate-counter-background: #2d2d44;
|
|
673
|
+
--ate-counter-color: #94a3b8;
|
|
674
|
+
--ate-blockquote-background: #2d2d44;
|
|
675
|
+
--ate-code-background: #2d2d44;
|
|
676
|
+
}
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
#### Example: Custom Brand Colors
|
|
680
|
+
|
|
681
|
+
```css
|
|
682
|
+
angular-tiptap-editor {
|
|
683
|
+
--ate-focus-color: #8b5cf6;
|
|
684
|
+
--ate-image-selected-color: #8b5cf6;
|
|
685
|
+
--ate-border-radius: 12px;
|
|
686
|
+
}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### ⚡ Reactive State & OnPush
|
|
690
|
+
|
|
691
|
+
The library exposes a reactive `editorState` signal via the `EditorCommandsService`. This signal contains everything you need to build custom UIs around the editor:
|
|
692
|
+
|
|
693
|
+
- **Active State**: Check if `bold`, `italic`, or custom marks are active.
|
|
694
|
+
- **Commands Availability**: Check if `undo`, `redo`, or custom commands can be executed.
|
|
695
|
+
- **Structural Data**: Access table status, image attributes, or selection details.
|
|
696
|
+
|
|
697
|
+
Since it's built with Signals, your custom toolbar items or UI overlays will only re-render when the specific data they consume changes, making it extremely efficient for `OnPush` applications.
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
### 🧩 Custom Tiptap Extensions
|
|
702
|
+
|
|
703
|
+
You are not limited to the built-in extensions. Pass any Tiptap extension, mark, or node:
|
|
704
|
+
|
|
705
|
+
```html
|
|
706
|
+
<angular-tiptap-editor [tiptapExtensions]="[MyCustomExtension]" />
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Any custom extension is automatically detected and its state (active/can) is added to the reactive `editorState` snapshot.
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## 🏗️ Architecture
|
|
714
|
+
|
|
715
|
+
### Reactive State Management
|
|
716
|
+
|
|
717
|
+
The library uses a **Snapshot & Signal** pattern to bridge Tiptap and Angular.
|
|
718
|
+
|
|
719
|
+
1. **State Snapshot**: Every editor transaction triggers a set of "Calculators" that produce a single immutable state object.
|
|
720
|
+
2. **Specialized Calculators**: Logic is modularized into specialized functions (Marks, Table, Image, etc.) and a **Discovery Calculator** for automatic extension detection.
|
|
721
|
+
3. **Signals Integration**: This snapshot is stored in a single Angular Signal. Sub-components (toolbar, menus) consume this signal only where needed.
|
|
722
|
+
4. **Change Detection Optimization**: A custom equality check on the signal prevents unnecessary re-renders when the visual state of the editor hasn't changed.
|
|
723
|
+
|
|
724
|
+
### Core Services
|
|
725
|
+
|
|
726
|
+
- **`EditorCommandsService`**: Exposes the `editorState` signal and provides a centralized API for executing Tiptap commands.
|
|
727
|
+
- **`ImageService`**: Manages the image processing pipeline (selection, compression, and server-side upload handling).
|
|
728
|
+
- **`TiptapI18nService`**: Reactive translation service with support for browser locale auto-detection.
|
|
729
|
+
|
|
730
|
+
### Isolated Instances
|
|
731
|
+
|
|
732
|
+
Each component instance provides its own set of services (`EditorCommandsService`, `ImageService`, etc.) at the component level. This ensures that multiple editors on the same page maintain independent states and configurations without interference.
|
|
733
|
+
|
|
734
|
+
### Modern Angular Integration
|
|
735
|
+
|
|
736
|
+
- **Signals**: Native reactivity for efficient UI updates.
|
|
737
|
+
- **OnPush**: Designed for `ChangeDetectionStrategy.OnPush` throughout.
|
|
738
|
+
- **Typed State**: Fully typed interfaces for the editor state and configurations.
|
|
739
|
+
|
|
740
|
+
### Default Configurations
|
|
741
|
+
|
|
742
|
+
The library provides default configurations that can be imported and customized:
|
|
743
|
+
|
|
744
|
+
```typescript
|
|
745
|
+
import {
|
|
746
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
747
|
+
DEFAULT_BUBBLE_MENU_CONFIG,
|
|
748
|
+
DEFAULT_IMAGE_BUBBLE_MENU_CONFIG,
|
|
749
|
+
DEFAULT_TABLE_MENU_CONFIG,
|
|
750
|
+
SLASH_COMMAND_KEYS,
|
|
751
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
## 🔧 Development
|
|
755
|
+
|
|
756
|
+
### Build Library
|
|
757
|
+
|
|
758
|
+
```bash
|
|
759
|
+
npm run build:lib
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### Watch Mode (Development)
|
|
763
|
+
|
|
764
|
+
```bash
|
|
765
|
+
npm run dev
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
This runs the library in watch mode and starts the demo application.
|
|
769
|
+
|
|
770
|
+
### Available Scripts
|
|
771
|
+
|
|
772
|
+
- `npm start` - Start demo application
|
|
773
|
+
- `npm run build` - Build demo application
|
|
774
|
+
- `npm run build:lib` - Build library
|
|
775
|
+
- `npm run watch:lib` - Watch library changes
|
|
776
|
+
- `npm run dev` - Development mode (watch + serve)
|
|
777
|
+
|
|
778
|
+
## 📝 License
|
|
779
|
+
|
|
780
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
781
|
+
|
|
782
|
+
## 🤝 Contributing
|
|
783
|
+
|
|
784
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
785
|
+
|
|
786
|
+
## 🔗 Links
|
|
787
|
+
|
|
788
|
+
- 📖 [Tiptap Documentation](https://tiptap.dev/)
|
|
789
|
+
- 🅰️ [Angular Documentation](https://angular.dev/)
|
|
790
|
+
- 📦 [NPM Package](https://www.npmjs.com/package/@flogeez/angular-tiptap-editor)
|
|
791
|
+
- 📖 [Live Demo](https://flogeez.github.io/angular-tiptap-editor/)
|
|
792
|
+
- 🐛 [Report Issues](https://github.com/FloGeez/angular-tiptap-editor/issues)
|
|
793
|
+
- 💡 [Feature Requests](https://github.com/FloGeez/angular-tiptap-editor/issues)
|
|
794
|
+
|
|
795
|
+
## 🆕 What's New
|
|
796
|
+
|
|
797
|
+
### Latest Updates
|
|
798
|
+
|
|
799
|
+
- ✅ **Unified Configuration**: New unified `AteEditorConfig` system for cleaner, type-safe editor setup.
|
|
800
|
+
- ✅ **Enhanced Image Upload**: Advanced image handling with custom upload handlers and auto-compression.
|
|
801
|
+
- ✅ **Refactored Link Management**: Dedicated link bubble menu with smart UI anchoring and real-time URL sync.
|
|
802
|
+
|
|
803
|
+
---
|
|
804
|
+
|
|
805
|
+
Made with ❤️ by [FloGeez](https://github.com/FloGeez)
|