@phuong-tran-redoc/document-engine-angular 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -2,49 +2,51 @@
2
2
 
3
3
  [![npm angular](https://img.shields.io/npm/v/@phuong-tran-redoc/document-engine-angular?label=@phuong-tran-redoc/document-engine-angular&color=red)](https://www.npmjs.com/package/@phuong-tran-redoc/document-engine-angular) ![License](https://img.shields.io/npm/l/@phuong-tran-redoc/document-engine-core)
4
4
 
5
- Angular wrapper for [`@phuong-tran-redoc/document-engine-core`](https://www.npmjs.com/package/@phuong-tran-redoc/document-engine-core). This library provides Angular components, directives, and services to integrate the Document Engine into Angular applications.
5
+ Angular wrapper for [`@phuong-tran-redoc/document-engine-core`](https://www.npmjs.com/package/@phuong-tran-redoc/document-engine-core). Provides the `<document-engine-editor>` component, a `ControlValueAccessor` directive for Angular Forms, a configurable toolbar/footer, and supporting UI primitives.
6
6
 
7
7
  ---
8
8
 
9
9
  ## 🎯 Overview
10
10
 
11
- `document-engine-angular` is a comprehensive Angular wrapper that makes it easy to use the Document Engine in Angular applications. It provides pre-built components, reactive state management, and Angular-specific utilities.
11
+ `document-engine-angular` makes the framework-agnostic core usable in Angular apps. You drive features with a single `config` object, project a `tiptap-editor` directive for two-way binding, and get a toolbar, footer, and character count out of the box.
12
12
 
13
13
  ### Key Features
14
14
 
15
- - **Angular Components:** Ready-to-use `<document-editor>` component
16
- - **Reactive API:** RxJS-based state management
17
- - **Template-Driven:** Angular template syntax support
18
- - **Form Integration:** Works with Angular Forms (ngModel, Reactive Forms)
19
- - **Accessibility:** ARIA-compliant components
20
- - **Standalone Components:** Works with standalone Angular components
21
- - **Type Safety:** Full TypeScript support
15
+ - **Editor component:** `<document-engine-editor [config]="…">` with content projection.
16
+ - **Angular Forms:** the inner `tiptap-editor` directive implements `ControlValueAccessor` — works with `ngModel` and `formControl` (HTML or JSON output).
17
+ - **Config-driven features:** toggle bold/italic/underline, lists, headings, tables, indent, text-case, dynamic fields, restricted editing, … via `DocumentEngineConfig`.
18
+ - **UI building blocks:** toolbar, footer, character count, color picker, select, icon, buttons — all themeable.
19
+ - **SCSS design system:** import one stylesheet entry to get the editor styling.
22
20
 
23
21
  ---
24
22
 
25
23
  ## 📦 Installation
26
24
 
27
- > ⚠️ **This is a private package. Please contact an authorized person to install it.**
28
-
29
25
  ```bash
30
26
  npm install @phuong-tran-redoc/document-engine-angular
31
27
  # or
32
28
  pnpm add @phuong-tran-redoc/document-engine-angular
33
29
  ```
34
30
 
31
+ Published publicly on npm under the MIT license. The core package is installed automatically as a dependency.
32
+
35
33
  ### Peer Dependencies
36
34
 
37
35
  ```json
38
36
  {
39
- "@angular/core": "^17.0.0 || ^18.0.0",
40
- "@angular/common": "^17.0.0 || ^18.0.0",
41
- "@phuong-tran-redoc/document-engine-core": "^1.0.0"
37
+ "@angular/core": ">=16.0.0 <22.0.0",
38
+ "@angular/common": ">=16.0.0 <22.0.0",
39
+ "@angular/forms": ">=16.0.0 <22.0.0",
40
+ "@angular/platform-browser": ">=16.0.0 <22.0.0",
41
+ "rxjs": "^7.5.0"
42
42
  }
43
43
  ```
44
44
 
45
+ > Supports Angular **16 → 21**. Built against `@tiptap/* ^3.26.0` (pulled in via the core dependency).
46
+
45
47
  ### Importing Styles
46
48
 
47
- Add to your `angular.json` or import in your global styles:
49
+ Add the SCSS entry to your global styles (or `angular.json` styles array):
48
50
 
49
51
  ```scss
50
52
  // styles.scss
@@ -55,287 +57,149 @@ Add to your `angular.json` or import in your global styles:
55
57
 
56
58
  ## 🚀 Quick Start
57
59
 
58
- ### Basic Usage
60
+ The editor uses **content projection**: `<document-engine-editor>` owns the config + toolbar/footer and exposes the live `editor` instance; you project a `tiptap-editor` directive that binds the editor and provides Forms support.
59
61
 
60
- #### Standalone Component
62
+ ### Basic usage (`ngModel`)
61
63
 
62
64
  ```typescript
63
65
  import { Component } from '@angular/core';
64
- import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
66
+ import { FormsModule } from '@angular/forms';
67
+ import {
68
+ DocumentEditorModule,
69
+ DocumentEngineConfig,
70
+ Editor,
71
+ } from '@phuong-tran-redoc/document-engine-angular';
65
72
 
66
73
  @Component({
67
74
  selector: 'app-my-editor',
68
- standalone: true,
69
- imports: [DocumentEditorComponent],
70
- template: ` <document-editor [content]="content" (contentChange)="onContentChange($event)" /> `,
75
+ imports: [FormsModule, DocumentEditorModule],
76
+ template: `
77
+ <document-engine-editor #docEditor [config]="config" (editorReady)="onEditorReady($event)">
78
+ <tiptap-editor [editor]="docEditor.editor" [(ngModel)]="value"></tiptap-editor>
79
+ </document-engine-editor>
80
+ `,
71
81
  })
72
82
  export class MyEditorComponent {
73
- content = '<p>Hello World!</p>';
83
+ value = '<p>Hello World!</p>';
84
+
85
+ config: Partial<DocumentEngineConfig> = {
86
+ bold: true,
87
+ italic: true,
88
+ underline: true,
89
+ list: true,
90
+ heading: true,
91
+ textAlign: true,
92
+ showFooter: true,
93
+ characterCount: true,
94
+ };
74
95
 
75
- onContentChange(newContent: string) {
76
- console.log('Content changed:', newContent);
96
+ onEditorReady(editor: Editor) {
97
+ // `editor` is the Tiptap instance — read/write content via its API
98
+ console.log('HTML:', editor.getHTML());
99
+ console.log('JSON:', editor.getJSON());
77
100
  }
78
101
  }
79
102
  ```
80
103
 
81
- #### Module-Based
82
-
83
- ```typescript
84
- import { NgModule } from '@angular/core';
85
- import { DocumentEditorModule } from '@phuong-tran-redoc/document-engine-angular';
86
-
87
- @NgModule({
88
- imports: [DocumentEditorModule],
89
- // ...
90
- })
91
- export class AppModule {}
92
- ```
93
-
94
- ### With Angular Forms
95
-
96
- #### Template-Driven Forms
97
-
98
- ```typescript
99
- import { Component } from '@angular/core';
100
- import { FormsModule } from '@angular/forms';
101
- import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
102
-
103
- @Component({
104
- selector: 'app-form-editor',
105
- standalone: true,
106
- imports: [FormsModule, DocumentEditorComponent],
107
- template: `
108
- <document-editor [(ngModel)]="documentContent" />
109
- <pre>{{ documentContent }}</pre>
110
- `,
111
- })
112
- export class FormEditorComponent {
113
- documentContent = '<p>Edit me!</p>';
114
- }
115
- ```
104
+ > `DocumentEditorComponent` is **not** a standalone component — import `DocumentEditorModule` (which also exports `TiptapEditorDirective`).
116
105
 
117
- #### Reactive Forms
106
+ ### Reactive Forms (`formControl`)
118
107
 
119
108
  ```typescript
120
109
  import { Component } from '@angular/core';
121
110
  import { FormControl, ReactiveFormsModule } from '@angular/forms';
122
- import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
111
+ import { DocumentEditorModule, DocumentEngineConfig } from '@phuong-tran-redoc/document-engine-angular';
123
112
 
124
113
  @Component({
125
114
  selector: 'app-reactive-editor',
126
- standalone: true,
127
- imports: [ReactiveFormsModule, DocumentEditorComponent],
128
- template: ` <document-editor [formControl]="editorControl" /> `,
129
- })
130
- export class ReactiveEditorComponent {
131
- editorControl = new FormControl('<p>Content</p>');
132
- }
133
- ```
134
-
135
- ### Advanced Configuration
136
-
137
- ```typescript
138
- import { Component } from '@angular/core';
139
- import { DocumentEditorComponent, EditorConfig } from '@phuong-tran-redoc/document-engine-angular';
140
-
141
- @Component({
142
- selector: 'app-advanced-editor',
143
- standalone: true,
144
- imports: [DocumentEditorComponent],
115
+ imports: [ReactiveFormsModule, DocumentEditorModule],
145
116
  template: `
146
- <document-editor
147
- [config]="editorConfig"
148
- [readonly]="isReadonly"
149
- [showToolbar]="true"
150
- (ready)="onEditorReady($event)"
151
- />
117
+ <document-engine-editor #docEditor [config]="config">
118
+ <tiptap-editor [editor]="docEditor.editor" [formControl]="control" outputFormat="json"></tiptap-editor>
119
+ </document-engine-editor>
152
120
  `,
153
121
  })
154
- export class AdvancedEditorComponent {
155
- isReadonly = false;
156
-
157
- editorConfig: EditorConfig = {
158
- extensions: ['dynamic-fields', 'restricted-editing', 'tables'],
159
- placeholder: 'Start typing...',
160
- autoFocus: true,
161
- };
162
-
163
- onEditorReady(editor: Editor) {
164
- console.log('Editor is ready!', editor);
165
- }
122
+ export class ReactiveEditorComponent {
123
+ control = new FormControl('<p>Content</p>');
124
+ config: Partial<DocumentEngineConfig> = { bold: true, italic: true, list: true };
166
125
  }
167
126
  ```
168
127
 
169
- ---
170
-
171
- ## 🧩 Components
172
-
173
- ### DocumentEditorComponent
174
-
175
- The main editor component.
176
-
177
- **Inputs:**
178
-
179
- - `content: string | JSONContent` - Initial content (HTML or JSON)
180
- - `config: EditorConfig` - Editor configuration
181
- - `readonly: boolean` - Read-only mode
182
- - `showToolbar: boolean` - Show/hide toolbar
183
- - `placeholder: string` - Placeholder text
128
+ `outputFormat` accepts `'html'` (default) or `'json'`.
184
129
 
185
- **Outputs:**
186
-
187
- - `contentChange: EventEmitter<string>` - Emits when content changes
188
- - `ready: EventEmitter<Editor>` - Emits when editor is ready
189
- - `focus: EventEmitter<void>` - Emits when editor gains focus
190
- - `blur: EventEmitter<void>` - Emits when editor loses focus
191
-
192
- **Methods:**
193
-
194
- - `getContent(): string` - Get current content as HTML
195
- - `getJSON(): JSONContent` - Get current content as JSON
196
- - `setContent(content: string | JSONContent): void` - Set editor content
197
- - `focus(): void` - Focus the editor
198
-
199
- ### DocumentEditorToolbarComponent
200
-
201
- Customizable toolbar component.
130
+ ---
202
131
 
203
- ```typescript
204
- <document-editor-toolbar [editor]="editor" />
205
- ```
132
+ ## 🧩 Public API
206
133
 
207
- ### DynamicFieldPickerComponent
134
+ ### `DocumentEditorComponent`
208
135
 
209
- UI for inserting dynamic fields.
136
+ The wrapper that hosts config, toolbar, and footer.
210
137
 
211
- ```typescript
212
- <dynamic-field-picker
213
- [fields]="availableFields"
214
- (fieldSelect)="onFieldSelect($event)"
215
- />
216
- ```
138
+ - **Selector:** `document-engine-editor`
139
+ - **Input:** `config?: Partial<DocumentEngineConfig>`
140
+ - **Output:** `editorReady: EventEmitter<Editor>` — fires once the Tiptap editor is constructed
141
+ - **Exposed property:** `editor: Editor` (project into `tiptap-editor` and read content via the Tiptap API: `getHTML()`, `getJSON()`, `getText()`)
217
142
 
218
- ---
143
+ ### `TiptapEditorDirective`
219
144
 
220
- ## 📚 Services
145
+ The Forms-aware directive you project inside the wrapper.
221
146
 
222
- ### DocumentEditorService
147
+ - **Selector:** `tiptap[editor]`, `[tiptap][editor]`, `tiptap-editor[editor]`, `[tiptapEditor][editor]`
148
+ - **Inputs:** `editor: Editor`, `outputFormat: 'json' | 'html'` (default `'html'`)
149
+ - Implements `ControlValueAccessor` → `ngModel` / `formControl` support.
223
150
 
224
- Service for managing editor instances.
151
+ ### `DocumentEditorModule`
225
152
 
226
- ```typescript
227
- import { DocumentEditorService } from '@phuong-tran-redoc/document-engine-angular';
153
+ Declares `DocumentEditorComponent`; exports `DocumentEditorComponent` + `TiptapEditorDirective` (imports the toolbar/footer internally).
228
154
 
229
- export class MyComponent {
230
- constructor(private editorService: DocumentEditorService) {}
155
+ ### UI components & directives (standalone)
231
156
 
232
- createEditor() {
233
- const editor = this.editorService.create({
234
- // configuration
235
- });
236
- }
237
- }
238
- ```
157
+ `ToolbarComponent` (`document-engine-toolbar`), `FooterComponent` (`document-engine-footer`), `CharacterCountComponent` (`document-engine-character-count`), `ColorPickerComponent` (`document-engine-color-picker`), `SelectComponent` (`document-engine-select`), `IconComponent` (`document-engine-icon`), `ToggleGroupComponent`, `CheckboxComponent`, plus directives `ButtonDirective` (`button[documentEngineButton]`), `InputDirective`, `TiptapFloatingMenuDirective`, `TiptapDraggableDirective`, `PopoverDirective`.
239
158
 
240
- ### DynamicFieldService
159
+ ### Services & tokens
241
160
 
242
- Service for managing dynamic fields.
161
+ - `FocusTrapService`, `EventManager` (both `providedIn: 'root'`).
162
+ - DI tokens: `EDITOR_CONTENT_WRAPPER_CLASS`, `EDITOR_HTML_PREPROCESSOR`.
243
163
 
244
- ```typescript
245
- import { DynamicFieldService } from '@phuong-tran-redoc/document-engine-angular';
164
+ ### `DocumentEngineConfig`
246
165
 
247
- export class MyComponent {
248
- constructor(private fieldService: DynamicFieldService) {}
166
+ The feature-toggle object passed to `[config]`. Each key is a boolean or an options object — e.g. `undoRedo`, `bold`, `italic`, `underline`, `strike`, `subscript`, `superscript`, `code`, `codeBlock`, `blockquote`, `link`, `heading`, `fontSize`, `lineHeight`, `textCase`, `textAlign`, `indent`, `list`, `textStyleKit`, `resetFormat`, `image`, `showFooter`, `characterCount`, and more.
249
167
 
250
- replaceFields() {
251
- this.fieldService.replaceFields({
252
- customer_name: 'John Doe',
253
- loan_amount: '50000',
254
- });
255
- }
256
- }
257
- ```
168
+ > The package entry `index.ts` is the public contract — additive changes only between minor versions.
258
169
 
259
170
  ---
260
171
 
261
172
  ## 🎨 Styling
262
173
 
263
- ### Custom Themes
264
-
265
- ```scss
266
- // Override CSS variables
267
- :root {
268
- --doc-editor-bg: #ffffff;
269
- --doc-editor-text: #000000;
270
- --doc-editor-border: #e0e0e0;
271
- --doc-editor-focus: #007bff;
272
- }
273
- ```
274
-
275
- ### Custom CSS Classes
276
-
277
- ```html
278
- <document-editor class="my-custom-editor" />
279
- ```
280
-
281
- ```scss
282
- .my-custom-editor {
283
- // Your custom styles
284
- }
285
- ```
174
+ Import the SCSS entry (see [Installation](#importing-styles)). The editor ships a Tailwind + SCSS design system; theme it through your global stylesheet alongside your app's design tokens.
286
175
 
287
176
  ---
288
177
 
289
178
  ## 🔧 Development
290
179
 
291
- ### Building
292
-
293
- Build the library:
294
-
295
180
  ```bash
296
- nx build document-engine-angular
297
- ```
298
-
299
- ### Testing
300
-
301
- Run unit tests:
302
-
303
- ```bash
304
- nx test document-engine-angular
305
- ```
306
-
307
- ### Linting
308
-
309
- Lint the code:
310
-
311
- ```bash
312
- nx lint document-engine-angular
181
+ nx build @phuong-tran-redoc/document-engine-angular # build the library
182
+ nx test @phuong-tran-redoc/document-engine-angular # unit tests
183
+ nx lint @phuong-tran-redoc/document-engine-angular # lint
313
184
  ```
314
185
 
315
186
  ---
316
187
 
317
- ## 📖 Documentation
188
+ ## 🔗 Related
318
189
 
319
- - **[Live Demo](#)** - See the editor in action
320
- - **[API Reference](#)** - Detailed API documentation
321
- - **[Examples](#)** - Code examples and use cases
322
- - **[Migration Guide](#)** - Migrating from other editors
323
-
324
- ---
325
-
326
- ## 🔗 Related Packages
327
-
328
- - **Core Library:** [`@phuong-tran-redoc/document-engine-core`](../document-engine-core)
329
- - **Demo Application:** [document-engine](../../apps/document-engine)
190
+ - **Core library:** [`@phuong-tran-redoc/document-engine-core`](../document-engine-core/README.md)
191
+ - 📦 [npm package](https://www.npmjs.com/package/@phuong-tran-redoc/document-engine-angular)
192
+ - 📝 [Changelog](../../CHANGELOG.md)
193
+ - 🐙 [Repository](https://github.com/phuong-tran-redoc/document-engine)
194
+ - ▶️ [Demo app](https://github.com/phuong-tran-redoc/document-engine) — clone the repo and run `pnpm start` (http://localhost:4200)
330
195
 
331
196
  ---
332
197
 
333
198
  ## 🤝 Compatibility
334
199
 
335
- | Angular Version | Package Version |
336
- | --------------- | --------------- |
337
- | 17.x | 1.x |
338
- | 18.x | 1.x |
200
+ | Angular | Package |
201
+ | --- | --- |
202
+ | 16.x – 21.x | 0.x |
339
203
 
340
204
  ---
341
205
 
@@ -351,6 +215,4 @@ Developed by **Duc Phuong (Jack)**
351
215
 
352
216
  ## 📄 License
353
217
 
354
- **MIT License**
355
-
356
- See [LICENSE.md](./LICENSE.md) for full license text.
218
+ **MIT License** — see [LICENSE.md](./LICENSE.md).
@@ -0,0 +1,67 @@
1
+ THIRD-PARTY SOFTWARE NOTICES
2
+
3
+ The Document Engine packages bundle or depend on the third-party software listed
4
+ below (the full production dependency closure). Each is distributed under its own
5
+ license; the full license text ships within each package in node_modules and is
6
+ available at the linked repository.
7
+
8
+ ==============================================================================
9
+
10
+ @angular/cdk@20.2.12
11
+ license: MIT
12
+ repository: https://github.com/angular/components
13
+
14
+ @angular/common@20.3.10
15
+ license: MIT
16
+ repository: https://github.com/angular/angular
17
+ publisher: angular
18
+
19
+ @angular/compiler@20.3.10
20
+ license: MIT
21
+ repository: https://github.com/angular/angular
22
+ publisher: angular
23
+
24
+ @angular/core@20.3.10
25
+ license: MIT
26
+ repository: https://github.com/angular/angular
27
+ publisher: angular
28
+
29
+ @angular/forms@20.3.10
30
+ license: MIT
31
+ repository: https://github.com/angular/angular
32
+ publisher: angular
33
+
34
+ @angular/material@20.2.12
35
+ license: MIT
36
+ repository: https://github.com/angular/components
37
+
38
+ @angular/platform-browser-dynamic@20.3.10
39
+ license: MIT
40
+ repository: https://github.com/angular/angular
41
+ publisher: angular
42
+
43
+ @angular/platform-browser@20.3.10
44
+ license: MIT
45
+ repository: https://github.com/angular/angular
46
+ publisher: angular
47
+
48
+ @angular/router@20.3.10
49
+ license: MIT
50
+ repository: https://github.com/angular/angular
51
+ publisher: angular
52
+
53
+ lodash-es@4.17.21
54
+ license: MIT
55
+ repository: https://github.com/lodash/lodash
56
+ publisher: John-David Dalton
57
+
58
+ rxjs@7.8.2
59
+ license: Apache-2.0
60
+ repository: https://github.com/reactivex/rxjs
61
+ publisher: Ben Lesh
62
+
63
+ zone.js@0.15.1
64
+ license: MIT
65
+ repository: https://github.com/angular/angular
66
+ publisher: Brian Ford
67
+