@flogeez/angular-tiptap-editor 0.3.1 → 0.3.3
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 +229 -54
- package/fesm2022/flogeez-angular-tiptap-editor.mjs +241 -189
- package/fesm2022/flogeez-angular-tiptap-editor.mjs.map +1 -1
- package/index.d.ts +64 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,14 +6,19 @@ A modern, customizable rich-text editor for Angular applications, built with Tip
|
|
|
6
6
|
|
|
7
7
|
## 🚀 Features
|
|
8
8
|
|
|
9
|
-
- **Modern Angular**: Built with Angular 18+
|
|
10
|
-
- **Rich Text Editing**: Powered by Tiptap with extensive formatting options
|
|
9
|
+
- **Modern Angular**: Built with Angular 18+ with Signals and modern patterns
|
|
10
|
+
- **Rich Text Editing**: Powered by Tiptap v3.3.0 with extensive formatting options
|
|
11
|
+
- **Table Support**: Full table management with bubble menus and cell selection
|
|
12
|
+
- **Slash Commands**: Intuitive slash commands for quick content insertion
|
|
11
13
|
- **Internationalization**: Full i18n support (English & French) with auto-detection
|
|
12
14
|
- **Customizable**: Highly configurable toolbar, bubble menus, and slash commands
|
|
13
|
-
- **Image Support**: Advanced image handling with resizing and
|
|
15
|
+
- **Image Support**: Advanced image handling with resizing, compression, and bubble menus
|
|
14
16
|
- **Height Control**: Configurable editor height with scrolling
|
|
17
|
+
- **Word/Character Count**: Real-time word and character counting with proper pluralization
|
|
18
|
+
- **Office Paste**: Clean pasting from Microsoft Office applications
|
|
15
19
|
- **TypeScript**: Full TypeScript support with strict typing
|
|
16
20
|
- **Accessibility**: Built with accessibility best practices
|
|
21
|
+
- **Service Architecture**: Clean service-based architecture with `EditorCommandsService`
|
|
17
22
|
|
|
18
23
|
## 📦 Installation
|
|
19
24
|
|
|
@@ -69,7 +74,11 @@ export class ExampleComponent {
|
|
|
69
74
|
|
|
70
75
|
```typescript
|
|
71
76
|
import { Component } from "@angular/core";
|
|
72
|
-
import {
|
|
77
|
+
import {
|
|
78
|
+
AngularTiptapEditorComponent,
|
|
79
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
80
|
+
DEFAULT_BUBBLE_MENU_CONFIG,
|
|
81
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
73
82
|
|
|
74
83
|
@Component({
|
|
75
84
|
selector: "app-advanced",
|
|
@@ -80,9 +89,11 @@ import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
|
80
89
|
[content]="content"
|
|
81
90
|
[toolbar]="toolbarConfig"
|
|
82
91
|
[bubbleMenu]="bubbleMenuConfig"
|
|
92
|
+
[slashCommands]="slashCommandsConfig"
|
|
83
93
|
[locale]="'en'"
|
|
84
94
|
[height]="400"
|
|
85
95
|
[showCharacterCount]="true"
|
|
96
|
+
[showWordCount]="true"
|
|
86
97
|
(contentChange)="onContentChange($event)"
|
|
87
98
|
/>
|
|
88
99
|
`,
|
|
@@ -90,23 +101,19 @@ import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
|
90
101
|
export class AdvancedComponent {
|
|
91
102
|
content = "<h1>Welcome!</h1><p>Start editing...</p>";
|
|
92
103
|
|
|
104
|
+
// Use default configurations as base
|
|
93
105
|
toolbarConfig = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
underline: true,
|
|
97
|
-
heading1: true,
|
|
98
|
-
heading2: true,
|
|
99
|
-
bulletList: true,
|
|
100
|
-
orderedList: true,
|
|
101
|
-
link: true,
|
|
102
|
-
image: true,
|
|
106
|
+
...DEFAULT_TOOLBAR_CONFIG,
|
|
107
|
+
clear: true, // Add clear button
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
bubbleMenuConfig = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
...DEFAULT_BUBBLE_MENU_CONFIG,
|
|
112
|
+
table: true, // Enable table bubble menu
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
slashCommandsConfig = {
|
|
116
|
+
commands: [], // Will be populated by the library
|
|
110
117
|
};
|
|
111
118
|
|
|
112
119
|
onContentChange(newContent: string) {
|
|
@@ -131,6 +138,8 @@ import { AngularTiptapEditorComponent } from "@flogeez/angular-tiptap-editor";
|
|
|
131
138
|
<angular-tiptap-editor
|
|
132
139
|
[formControl]="contentControl"
|
|
133
140
|
placeholder="Enter your content here..."
|
|
141
|
+
[showCharacterCount]="true"
|
|
142
|
+
[showWordCount]="true"
|
|
134
143
|
/>
|
|
135
144
|
<button type="submit">Submit</button>
|
|
136
145
|
</form>
|
|
@@ -141,6 +150,95 @@ export class FormComponent {
|
|
|
141
150
|
}
|
|
142
151
|
```
|
|
143
152
|
|
|
153
|
+
### 4. Using EditorCommandsService
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { Component, inject } from "@angular/core";
|
|
157
|
+
import { EditorCommandsService } from "@flogeez/angular-tiptap-editor";
|
|
158
|
+
|
|
159
|
+
@Component({
|
|
160
|
+
selector: "app-commands",
|
|
161
|
+
standalone: true,
|
|
162
|
+
template: `
|
|
163
|
+
<div>
|
|
164
|
+
<button (click)="clearContent()">Clear Content</button>
|
|
165
|
+
<button (click)="focusEditor()">Focus Editor</button>
|
|
166
|
+
<button (click)="setContent()">Set Content</button>
|
|
167
|
+
</div>
|
|
168
|
+
`,
|
|
169
|
+
})
|
|
170
|
+
export class CommandsComponent {
|
|
171
|
+
private editorCommandsService = inject(EditorCommandsService);
|
|
172
|
+
private editor: Editor | null = null;
|
|
173
|
+
|
|
174
|
+
onEditorCreated(editor: Editor) {
|
|
175
|
+
this.editor = editor;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
clearContent() {
|
|
179
|
+
if (this.editor) {
|
|
180
|
+
this.editorCommandsService.clearContent(this.editor);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
focusEditor() {
|
|
185
|
+
if (this.editor) {
|
|
186
|
+
this.editorCommandsService.focus(this.editor);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
setContent() {
|
|
191
|
+
if (this.editor) {
|
|
192
|
+
this.editorCommandsService.setContent(
|
|
193
|
+
this.editor,
|
|
194
|
+
"<h1>New Content</h1>"
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## ✨ Key Features
|
|
202
|
+
|
|
203
|
+
### 📊 Table Management
|
|
204
|
+
|
|
205
|
+
Full table support with intuitive bubble menus:
|
|
206
|
+
|
|
207
|
+
- **Table Creation**: Insert tables via slash commands (`/table`)
|
|
208
|
+
- **Cell Selection**: Click and drag to select multiple cells
|
|
209
|
+
- **Bubble Menus**: Context-aware menus for table operations
|
|
210
|
+
- **Row/Column Management**: Add, remove, and merge cells
|
|
211
|
+
- **Styling**: Custom table styling with proper borders
|
|
212
|
+
|
|
213
|
+
### ⚡ Slash Commands
|
|
214
|
+
|
|
215
|
+
Quick content insertion with slash commands:
|
|
216
|
+
|
|
217
|
+
- **Headings**: `/h1`, `/h2`, `/h3`
|
|
218
|
+
- **Lists**: `/bullet`, `/numbered`
|
|
219
|
+
- **Blocks**: `/quote`, `/code`, `/line`
|
|
220
|
+
- **Media**: `/image`, `/table`
|
|
221
|
+
- **Fully Internationalized**: All commands translated
|
|
222
|
+
|
|
223
|
+
### 🖼️ Advanced Image Handling
|
|
224
|
+
|
|
225
|
+
Professional image management:
|
|
226
|
+
|
|
227
|
+
- **Drag & Drop**: Drag images directly into the editor
|
|
228
|
+
- **File Selection**: Click to select images from device
|
|
229
|
+
- **Auto-Compression**: Images automatically compressed (max 1920x1080)
|
|
230
|
+
- **Resizable**: Images can be resized with handles
|
|
231
|
+
- **Bubble Menu**: Context menu for image operations
|
|
232
|
+
|
|
233
|
+
### 📝 Word & Character Counting
|
|
234
|
+
|
|
235
|
+
Real-time content statistics:
|
|
236
|
+
|
|
237
|
+
- **Live Updates**: Counters update as you type
|
|
238
|
+
- **Proper Pluralization**: "1 word" vs "2 words"
|
|
239
|
+
- **Separate Counts**: Independent word and character counts
|
|
240
|
+
- **Configurable**: Show/hide individual counters
|
|
241
|
+
|
|
144
242
|
## 🎨 Demo
|
|
145
243
|
|
|
146
244
|
### 🌐 Live Demo
|
|
@@ -164,20 +262,22 @@ Open [http://localhost:4200](http://localhost:4200) to view the demo.
|
|
|
164
262
|
|
|
165
263
|
#### Inputs
|
|
166
264
|
|
|
167
|
-
| Input | Type
|
|
168
|
-
| -------------------- |
|
|
169
|
-
| `content` | `string`
|
|
170
|
-
| `placeholder` | `string`
|
|
171
|
-
| `locale` | `'en' \| 'fr'`
|
|
172
|
-
| `editable` | `boolean`
|
|
173
|
-
| `height` | `number`
|
|
174
|
-
| `maxHeight` | `number`
|
|
175
|
-
| `minHeight` | `number`
|
|
176
|
-
| `showToolbar` | `boolean`
|
|
177
|
-
| `showBubbleMenu` | `boolean`
|
|
178
|
-
| `showCharacterCount` | `boolean`
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
265
|
+
| Input | Type | Default | Description |
|
|
266
|
+
| -------------------- | --------------------- | ------------------- | ---------------------------- |
|
|
267
|
+
| `content` | `string` | `""` | Initial HTML content |
|
|
268
|
+
| `placeholder` | `string` | `"Start typing..."` | Placeholder text |
|
|
269
|
+
| `locale` | `'en' \| 'fr'` | Auto-detect | Editor language |
|
|
270
|
+
| `editable` | `boolean` | `true` | Whether editor is editable |
|
|
271
|
+
| `height` | `number` | `undefined` | Fixed height in pixels |
|
|
272
|
+
| `maxHeight` | `number` | `undefined` | Maximum height in pixels |
|
|
273
|
+
| `minHeight` | `number` | `200` | Minimum height in pixels |
|
|
274
|
+
| `showToolbar` | `boolean` | `true` | Show toolbar |
|
|
275
|
+
| `showBubbleMenu` | `boolean` | `true` | Show bubble menu |
|
|
276
|
+
| `showCharacterCount` | `boolean` | `true` | Show character counter |
|
|
277
|
+
| `showWordCount` | `boolean` | `true` | Show word counter |
|
|
278
|
+
| `toolbar` | `ToolbarConfig` | All enabled | Toolbar configuration |
|
|
279
|
+
| `bubbleMenu` | `BubbleMenuConfig` | All enabled | Bubble menu configuration |
|
|
280
|
+
| `slashCommands` | `SlashCommandsConfig` | All enabled | Slash commands configuration |
|
|
181
281
|
|
|
182
282
|
#### Outputs
|
|
183
283
|
|
|
@@ -191,6 +291,12 @@ Open [http://localhost:4200](http://localhost:4200) to view the demo.
|
|
|
191
291
|
### Configuration Examples
|
|
192
292
|
|
|
193
293
|
```typescript
|
|
294
|
+
import {
|
|
295
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
296
|
+
DEFAULT_BUBBLE_MENU_CONFIG,
|
|
297
|
+
SLASH_COMMAND_KEYS,
|
|
298
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
299
|
+
|
|
194
300
|
// Minimal toolbar
|
|
195
301
|
const minimalToolbar = {
|
|
196
302
|
bold: true,
|
|
@@ -198,25 +304,25 @@ const minimalToolbar = {
|
|
|
198
304
|
bulletList: true,
|
|
199
305
|
};
|
|
200
306
|
|
|
201
|
-
// Full toolbar
|
|
307
|
+
// Full toolbar with clear button
|
|
202
308
|
const fullToolbar = {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
horizontalRule: true,
|
|
217
|
-
undo: true,
|
|
218
|
-
redo: true,
|
|
309
|
+
...DEFAULT_TOOLBAR_CONFIG,
|
|
310
|
+
clear: true, // Add clear button
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// Bubble menu with table support
|
|
314
|
+
const bubbleMenuWithTable = {
|
|
315
|
+
...DEFAULT_BUBBLE_MENU_CONFIG,
|
|
316
|
+
table: true, // Enable table bubble menu
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// Slash commands configuration
|
|
320
|
+
const slashCommands = {
|
|
321
|
+
commands: [], // Will be populated by filterSlashCommands()
|
|
219
322
|
};
|
|
323
|
+
|
|
324
|
+
// Available slash command keys
|
|
325
|
+
console.log(SLASH_COMMAND_KEYS); // ["heading1", "heading2", "heading3", "bulletList", "orderedList", "blockquote", "code", "image", "horizontalRule", "table"]
|
|
220
326
|
```
|
|
221
327
|
|
|
222
328
|
## 🌍 Internationalization
|
|
@@ -234,6 +340,67 @@ The editor supports English and French with automatic browser language detection
|
|
|
234
340
|
<angular-tiptap-editor />
|
|
235
341
|
```
|
|
236
342
|
|
|
343
|
+
### Available Translations
|
|
344
|
+
|
|
345
|
+
- **English (en)**: Default language with complete translations
|
|
346
|
+
- **French (fr)**: Full French translation including:
|
|
347
|
+
- Toolbar buttons
|
|
348
|
+
- Bubble menu items
|
|
349
|
+
- Slash commands
|
|
350
|
+
- Placeholder text
|
|
351
|
+
- Error messages
|
|
352
|
+
- Word/character count (with proper pluralization)
|
|
353
|
+
|
|
354
|
+
### Custom Slash Commands
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
import {
|
|
358
|
+
filterSlashCommands,
|
|
359
|
+
SLASH_COMMAND_KEYS,
|
|
360
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
361
|
+
|
|
362
|
+
// Filter available slash commands
|
|
363
|
+
const activeCommands = new Set(["heading1", "heading2", "bulletList", "table"]);
|
|
364
|
+
const commands = filterSlashCommands(activeCommands);
|
|
365
|
+
|
|
366
|
+
// Use in component
|
|
367
|
+
slashCommandsConfig = {
|
|
368
|
+
commands: commands,
|
|
369
|
+
};
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## 🏗️ Architecture
|
|
373
|
+
|
|
374
|
+
### Service-Based Design
|
|
375
|
+
|
|
376
|
+
The library follows a clean service-based architecture:
|
|
377
|
+
|
|
378
|
+
- **`EditorCommandsService`**: Centralized service for all editor commands
|
|
379
|
+
- **`TiptapI18nService`**: Internationalization service with automatic language detection
|
|
380
|
+
- **`ImageService`**: Advanced image handling with compression and resizing
|
|
381
|
+
- **`filterSlashCommands()`**: Utility function for managing slash commands
|
|
382
|
+
|
|
383
|
+
### Modern Angular Patterns
|
|
384
|
+
|
|
385
|
+
- **Signals**: Used throughout for reactive state management
|
|
386
|
+
- **Dependency Injection**: Clean service injection with `inject()`
|
|
387
|
+
- **Standalone Components**: All components are standalone for better tree-shaking
|
|
388
|
+
- **TypeScript**: Strict typing with comprehensive interfaces
|
|
389
|
+
|
|
390
|
+
### Default Configurations
|
|
391
|
+
|
|
392
|
+
The library provides default configurations that can be imported and customized:
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
import {
|
|
396
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
397
|
+
DEFAULT_BUBBLE_MENU_CONFIG,
|
|
398
|
+
DEFAULT_IMAGE_BUBBLE_MENU_CONFIG,
|
|
399
|
+
DEFAULT_TABLE_MENU_CONFIG,
|
|
400
|
+
SLASH_COMMAND_KEYS,
|
|
401
|
+
} from "@flogeez/angular-tiptap-editor";
|
|
402
|
+
```
|
|
403
|
+
|
|
237
404
|
## 🔧 Development
|
|
238
405
|
|
|
239
406
|
### Build Library
|
|
@@ -266,18 +433,26 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
266
433
|
|
|
267
434
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
268
435
|
|
|
269
|
-
## 📞 Support
|
|
270
|
-
|
|
271
|
-
- 🐛 [Report Issues](https://github.com/flogeez/angular-tiptap-editor/issues)
|
|
272
|
-
- 💡 [Feature Requests](https://github.com/flogeez/angular-tiptap-editor/issues)
|
|
273
|
-
- 📖 [Documentation](https://github.com/flogeez/angular-tiptap-editor#readme)
|
|
274
|
-
|
|
275
436
|
## 🔗 Links
|
|
276
437
|
|
|
277
438
|
- 🎮 [Live Demo](https://flogeez.github.io/angular-tiptap-editor/)
|
|
278
439
|
- 📖 [Tiptap Documentation](https://tiptap.dev/)
|
|
279
440
|
- 🅰️ [Angular Documentation](https://angular.dev/)
|
|
280
441
|
- 📦 [NPM Package](https://www.npmjs.com/package/@flogeez/angular-tiptap-editor)
|
|
442
|
+
- 🐛 [Report Issues](https://github.com/FloGeez/angular-tiptap-editor/issues)
|
|
443
|
+
- 💡 [Feature Requests](https://github.com/FloGeez/angular-tiptap-editor/issues)
|
|
444
|
+
|
|
445
|
+
## 🆕 What's New
|
|
446
|
+
|
|
447
|
+
### Latest Updates
|
|
448
|
+
|
|
449
|
+
- ✅ **Table Support**: Full table management with bubble menus
|
|
450
|
+
- ✅ **Slash Commands**: Intuitive content insertion commands
|
|
451
|
+
- ✅ **Word/Character Count**: Real-time counting with proper pluralization
|
|
452
|
+
- ✅ **Service Architecture**: Clean `EditorCommandsService` for better maintainability
|
|
453
|
+
- ✅ **Default Configurations**: Importable default configs for easy customization
|
|
454
|
+
- ✅ **Office Paste**: Clean pasting from Microsoft Office applications
|
|
455
|
+
- ✅ **Enhanced i18n**: Improved internationalization with better architecture
|
|
281
456
|
|
|
282
457
|
---
|
|
283
458
|
|