@phuong-tran-redoc/document-engine-angular 0.0.12
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/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Realestatedoc (Redoc).
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the βSoftwareβ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED βAS ISβ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# document-engine-angular
|
|
2
|
+
|
|
3
|
+
Angular wrapper for [`@phuong-tran-redoc/document-engine-core`](../document-engine-core). This library provides Angular components, directives, and services to integrate the Document Engine into Angular applications.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## π― Overview
|
|
8
|
+
|
|
9
|
+
`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.
|
|
10
|
+
|
|
11
|
+
### Key Features
|
|
12
|
+
|
|
13
|
+
- **Angular Components:** Ready-to-use `<document-editor>` component
|
|
14
|
+
- **Reactive API:** RxJS-based state management
|
|
15
|
+
- **Template-Driven:** Angular template syntax support
|
|
16
|
+
- **Form Integration:** Works with Angular Forms (ngModel, Reactive Forms)
|
|
17
|
+
- **Accessibility:** ARIA-compliant components
|
|
18
|
+
- **Standalone Components:** Works with standalone Angular components
|
|
19
|
+
- **Type Safety:** Full TypeScript support
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## π¦ Installation
|
|
24
|
+
|
|
25
|
+
> β οΈ **This is a private package. Please contact an authorized person to install it.**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @phuong-tran-redoc/document-engine-angular
|
|
29
|
+
# or
|
|
30
|
+
pnpm add @phuong-tran-redoc/document-engine-angular
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Peer Dependencies
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"@angular/core": "^17.0.0 || ^18.0.0",
|
|
38
|
+
"@angular/common": "^17.0.0 || ^18.0.0",
|
|
39
|
+
"@phuong-tran-redoc/document-engine-core": "^1.0.0"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Importing Styles
|
|
44
|
+
|
|
45
|
+
Add to your `angular.json` or import in your global styles:
|
|
46
|
+
|
|
47
|
+
```scss
|
|
48
|
+
// styles.scss
|
|
49
|
+
@import '@phuong-tran-redoc/document-engine-angular/styles';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## π Quick Start
|
|
55
|
+
|
|
56
|
+
### Basic Usage
|
|
57
|
+
|
|
58
|
+
#### Standalone Component
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Component } from '@angular/core';
|
|
62
|
+
import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'app-my-editor',
|
|
66
|
+
standalone: true,
|
|
67
|
+
imports: [DocumentEditorComponent],
|
|
68
|
+
template: ` <document-editor [content]="content" (contentChange)="onContentChange($event)" /> `,
|
|
69
|
+
})
|
|
70
|
+
export class MyEditorComponent {
|
|
71
|
+
content = '<p>Hello World!</p>';
|
|
72
|
+
|
|
73
|
+
onContentChange(newContent: string) {
|
|
74
|
+
console.log('Content changed:', newContent);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Module-Based
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { NgModule } from '@angular/core';
|
|
83
|
+
import { DocumentEditorModule } from '@phuong-tran-redoc/document-engine-angular';
|
|
84
|
+
|
|
85
|
+
@NgModule({
|
|
86
|
+
imports: [DocumentEditorModule],
|
|
87
|
+
// ...
|
|
88
|
+
})
|
|
89
|
+
export class AppModule {}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### With Angular Forms
|
|
93
|
+
|
|
94
|
+
#### Template-Driven Forms
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { Component } from '@angular/core';
|
|
98
|
+
import { FormsModule } from '@angular/forms';
|
|
99
|
+
import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
|
|
100
|
+
|
|
101
|
+
@Component({
|
|
102
|
+
selector: 'app-form-editor',
|
|
103
|
+
standalone: true,
|
|
104
|
+
imports: [FormsModule, DocumentEditorComponent],
|
|
105
|
+
template: `
|
|
106
|
+
<document-editor [(ngModel)]="documentContent" />
|
|
107
|
+
<pre>{{ documentContent }}</pre>
|
|
108
|
+
`,
|
|
109
|
+
})
|
|
110
|
+
export class FormEditorComponent {
|
|
111
|
+
documentContent = '<p>Edit me!</p>';
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Reactive Forms
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Component } from '@angular/core';
|
|
119
|
+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
120
|
+
import { DocumentEditorComponent } from '@phuong-tran-redoc/document-engine-angular';
|
|
121
|
+
|
|
122
|
+
@Component({
|
|
123
|
+
selector: 'app-reactive-editor',
|
|
124
|
+
standalone: true,
|
|
125
|
+
imports: [ReactiveFormsModule, DocumentEditorComponent],
|
|
126
|
+
template: ` <document-editor [formControl]="editorControl" /> `,
|
|
127
|
+
})
|
|
128
|
+
export class ReactiveEditorComponent {
|
|
129
|
+
editorControl = new FormControl('<p>Content</p>');
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Advanced Configuration
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { Component } from '@angular/core';
|
|
137
|
+
import { DocumentEditorComponent, EditorConfig } from '@phuong-tran-redoc/document-engine-angular';
|
|
138
|
+
|
|
139
|
+
@Component({
|
|
140
|
+
selector: 'app-advanced-editor',
|
|
141
|
+
standalone: true,
|
|
142
|
+
imports: [DocumentEditorComponent],
|
|
143
|
+
template: `
|
|
144
|
+
<document-editor
|
|
145
|
+
[config]="editorConfig"
|
|
146
|
+
[readonly]="isReadonly"
|
|
147
|
+
[showToolbar]="true"
|
|
148
|
+
(ready)="onEditorReady($event)"
|
|
149
|
+
/>
|
|
150
|
+
`,
|
|
151
|
+
})
|
|
152
|
+
export class AdvancedEditorComponent {
|
|
153
|
+
isReadonly = false;
|
|
154
|
+
|
|
155
|
+
editorConfig: EditorConfig = {
|
|
156
|
+
extensions: ['dynamic-fields', 'restricted-editing', 'tables'],
|
|
157
|
+
placeholder: 'Start typing...',
|
|
158
|
+
autoFocus: true,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
onEditorReady(editor: Editor) {
|
|
162
|
+
console.log('Editor is ready!', editor);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## π§© Components
|
|
170
|
+
|
|
171
|
+
### DocumentEditorComponent
|
|
172
|
+
|
|
173
|
+
The main editor component.
|
|
174
|
+
|
|
175
|
+
**Inputs:**
|
|
176
|
+
|
|
177
|
+
- `content: string | JSONContent` - Initial content (HTML or JSON)
|
|
178
|
+
- `config: EditorConfig` - Editor configuration
|
|
179
|
+
- `readonly: boolean` - Read-only mode
|
|
180
|
+
- `showToolbar: boolean` - Show/hide toolbar
|
|
181
|
+
- `placeholder: string` - Placeholder text
|
|
182
|
+
|
|
183
|
+
**Outputs:**
|
|
184
|
+
|
|
185
|
+
- `contentChange: EventEmitter<string>` - Emits when content changes
|
|
186
|
+
- `ready: EventEmitter<Editor>` - Emits when editor is ready
|
|
187
|
+
- `focus: EventEmitter<void>` - Emits when editor gains focus
|
|
188
|
+
- `blur: EventEmitter<void>` - Emits when editor loses focus
|
|
189
|
+
|
|
190
|
+
**Methods:**
|
|
191
|
+
|
|
192
|
+
- `getContent(): string` - Get current content as HTML
|
|
193
|
+
- `getJSON(): JSONContent` - Get current content as JSON
|
|
194
|
+
- `setContent(content: string | JSONContent): void` - Set editor content
|
|
195
|
+
- `focus(): void` - Focus the editor
|
|
196
|
+
|
|
197
|
+
### DocumentEditorToolbarComponent
|
|
198
|
+
|
|
199
|
+
Customizable toolbar component.
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
<document-editor-toolbar [editor]="editor" />
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### DynamicFieldPickerComponent
|
|
206
|
+
|
|
207
|
+
UI for inserting dynamic fields.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
<dynamic-field-picker
|
|
211
|
+
[fields]="availableFields"
|
|
212
|
+
(fieldSelect)="onFieldSelect($event)"
|
|
213
|
+
/>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## π Services
|
|
219
|
+
|
|
220
|
+
### DocumentEditorService
|
|
221
|
+
|
|
222
|
+
Service for managing editor instances.
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { DocumentEditorService } from '@phuong-tran-redoc/document-engine-angular';
|
|
226
|
+
|
|
227
|
+
export class MyComponent {
|
|
228
|
+
constructor(private editorService: DocumentEditorService) {}
|
|
229
|
+
|
|
230
|
+
createEditor() {
|
|
231
|
+
const editor = this.editorService.create({
|
|
232
|
+
// configuration
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### DynamicFieldService
|
|
239
|
+
|
|
240
|
+
Service for managing dynamic fields.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { DynamicFieldService } from '@phuong-tran-redoc/document-engine-angular';
|
|
244
|
+
|
|
245
|
+
export class MyComponent {
|
|
246
|
+
constructor(private fieldService: DynamicFieldService) {}
|
|
247
|
+
|
|
248
|
+
replaceFields() {
|
|
249
|
+
this.fieldService.replaceFields({
|
|
250
|
+
customer_name: 'John Doe',
|
|
251
|
+
loan_amount: '50000',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## π¨ Styling
|
|
260
|
+
|
|
261
|
+
### Custom Themes
|
|
262
|
+
|
|
263
|
+
```scss
|
|
264
|
+
// Override CSS variables
|
|
265
|
+
:root {
|
|
266
|
+
--doc-editor-bg: #ffffff;
|
|
267
|
+
--doc-editor-text: #000000;
|
|
268
|
+
--doc-editor-border: #e0e0e0;
|
|
269
|
+
--doc-editor-focus: #007bff;
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Custom CSS Classes
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<document-editor class="my-custom-editor" />
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
```scss
|
|
280
|
+
.my-custom-editor {
|
|
281
|
+
// Your custom styles
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## π§ Development
|
|
288
|
+
|
|
289
|
+
### Building
|
|
290
|
+
|
|
291
|
+
Build the library:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
nx build document-engine-angular
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Testing
|
|
298
|
+
|
|
299
|
+
Run unit tests:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
nx test document-engine-angular
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Linting
|
|
306
|
+
|
|
307
|
+
Lint the code:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
nx lint document-engine-angular
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## π Documentation
|
|
316
|
+
|
|
317
|
+
- **[Live Demo](#)** - See the editor in action
|
|
318
|
+
- **[API Reference](#)** - Detailed API documentation
|
|
319
|
+
- **[Examples](#)** - Code examples and use cases
|
|
320
|
+
- **[Migration Guide](#)** - Migrating from other editors
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## π Related Packages
|
|
325
|
+
|
|
326
|
+
- **Core Library:** [`@phuong-tran-redoc/document-engine-core`](../document-engine-core)
|
|
327
|
+
- **Demo Application:** [document-engine](../../apps/document-engine)
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## π€ Compatibility
|
|
332
|
+
|
|
333
|
+
| Angular Version | Package Version |
|
|
334
|
+
| --------------- | --------------- |
|
|
335
|
+
| 17.x | 1.x |
|
|
336
|
+
| 18.x | 1.x |
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## π€ Author
|
|
341
|
+
|
|
342
|
+
Developed by **Duc Phuong (Jack)**
|
|
343
|
+
|
|
344
|
+
- πΌ [LinkedIn](https://www.linkedin.com/in/tdp1999/)
|
|
345
|
+
- π [GitHub](https://github.com/tdp1999)
|
|
346
|
+
- π§ [Email](mailto:tdp99.business@gmail.com)
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## π License
|
|
351
|
+
|
|
352
|
+
**MIT License**
|
|
353
|
+
|
|
354
|
+
See [LICENSE.md](./LICENSE.md) for full license text.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generated bundle index. Do not edit.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./index"), exports);
|
|
8
|
+
//# sourceMappingURL=phuong-tran-redoc-document-engine-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phuong-tran-redoc-document-engine-angular.mjs","sources":["../../../../libs/document-engine-angular/src/phuong-tran-redoc-document-engine-angular.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";AAAA;;AAEG;;;AAEH,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA,CAAA"}
|