@libs-ui/components-inputs-quill2x 0.2.357-7 → 0.2.357-9

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
@@ -101,8 +101,8 @@ import { LibsUiComponentsInputsQuill2xComponent } from '@libs-ui/components-inpu
101
101
  templateUrl: './my.component.html',
102
102
  })
103
103
  export class MyComponent {
104
- protected formData = signal<Record<string, string>>({
105
- content: '<p>Xin chào! Đây là nội dung ban đầu.</p>',
104
+ protected basicData = signal<Record<string, string>>({
105
+ content: '<p>Xin chào! Đây là trình soạn thảo <strong>Quill2x</strong>.</p>',
106
106
  });
107
107
 
108
108
  protected handlerChange(html: string): void {
@@ -115,9 +115,9 @@ export class MyComponent {
115
115
  ```html
116
116
  <!-- my.component.html -->
117
117
  <libs_ui-components-inputs-quill2x
118
- [(item)]="formData"
118
+ [(item)]="basicData"
119
119
  [fieldBind]="'content'"
120
- [placeholder]="'Nhập nội dung...'"
120
+ [placeholder]="'Nhập nội dung ngắn...'"
121
121
  (outChange)="handlerChange($event)">
122
122
  </libs_ui-components-inputs-quill2x>
123
123
  ```
@@ -136,11 +136,12 @@ import { LibsUiComponentsInputsQuill2xComponent, IQuill2xCustomConfig } from '@l
136
136
  templateUrl: './my.component.html',
137
137
  })
138
138
  export class MyComponent {
139
- protected articleData = signal<Record<string, string>>({
140
- body: '<h1>Tiêu đề bài viết</h1><p>Nội dung bài viết tại đây.</p>',
139
+ protected fullData = signal<Record<string, string>>({
140
+ content: '<h1>Tiêu đề lớn</h1><p>Nội dung với đầy đủ các công cụ hỗ trợ.</p><ul><li>Danh mục 1</li><li>Danh mục 2</li></ul>',
141
141
  });
142
142
 
143
- protected fullConfig: IQuill2xCustomConfig = {
143
+ // toolbar.type = 'all' hiển thị đầy đủ các nhóm công cụ; resize='vertical' cho phép kéo rộng editor
144
+ protected fullConfig = {
144
145
  toolbar: signal({
145
146
  type: signal<'all'>('all'),
146
147
  }),
@@ -158,8 +159,8 @@ export class MyComponent {
158
159
  ```html
159
160
  <!-- my.component.html -->
160
161
  <libs_ui-components-inputs-quill2x
161
- [(item)]="articleData"
162
- [fieldBind]="'body'"
162
+ [(item)]="fullData"
163
+ [fieldBind]="'content'"
163
164
  [quillCustomConfig]="fullConfig"
164
165
  [resize]="'vertical'"
165
166
  [minHeightEditorContentDefault]="150"
@@ -185,13 +186,13 @@ import { IMentionConfig } from '@libs-ui/components-inputs-mention';
185
186
  templateUrl: './my.component.html',
186
187
  })
187
188
  export class MyComponent {
188
- protected commentData = signal<Record<string, string>>({ comment: '' });
189
+ protected mentionData = signal<Record<string, string>>({ content: '<p>Thử gõ @ để mention...</p>' });
189
190
 
190
191
  protected mentionConfig: IMentionConfig = {
191
192
  items: [
192
- { id: '1', name: 'Anh Tuấn', username: 'tuan@company.com' },
193
- { id: '2', name: 'Bảo Ngọc', username: 'ngoc@company.com' },
194
- { id: '3', name: 'Công Thành', username: 'thanh@company.com' },
193
+ { id: '1', name: 'Anh Tuấn', username: 'tuan@example.com' },
194
+ { id: '2', name: 'Bảo Ngọc', username: 'ngoc@example.com' },
195
+ { id: '3', name: 'Công Thành', username: 'thanh@example.com' },
195
196
  ],
196
197
  triggerChar: '@',
197
198
  labelKey: 'name',
@@ -209,10 +210,9 @@ export class MyComponent {
209
210
  ```html
210
211
  <!-- my.component.html -->
211
212
  <libs_ui-components-inputs-quill2x
212
- [(item)]="commentData"
213
- [fieldBind]="'comment'"
214
- [dataConfigMention]="mentionConfig"
215
- [placeholder]="'Nhập bình luận, gõ @ để mention...'">
213
+ [(item)]="mentionData"
214
+ [fieldBind]="'content'"
215
+ [dataConfigMention]="mentionConfig">
216
216
  </libs_ui-components-inputs-quill2x>
217
217
  ```
218
218
 
@@ -278,12 +278,13 @@ import { LibsUiComponentsInputsQuill2xComponent, IQuill2xCustomConfig } from '@l
278
278
  export class MyComponent implements AfterViewInit {
279
279
  @ViewChild('triggerBtn') triggerBtn?: ElementRef<HTMLButtonElement>;
280
280
 
281
- protected floatingData = signal<Record<string, string>>({ content: '' });
282
- protected floatingConfig = signal<IQuill2xCustomConfig | undefined>(undefined);
281
+ protected positionFixedData = signal<Record<string, string>>({ content: '<p>Nội dung với toolbar floating...</p>' });
282
+ protected positionFixedConfig = signal<IQuill2xCustomConfig | undefined>(undefined);
283
283
 
284
+ // #triggerBtn dùng ViewChild — element phải tồn tại trước khi khởi tạo positionFixed
284
285
  ngAfterViewInit(): void {
285
286
  if (!this.triggerBtn) return;
286
- this.floatingConfig.set({
287
+ this.positionFixedConfig.set({
287
288
  toolbar: signal({
288
289
  type: signal<'default'>('default'),
289
290
  positionFixed: signal({
@@ -304,15 +305,17 @@ export class MyComponent implements AfterViewInit {
304
305
 
305
306
  ```html
306
307
  <!-- my.component.html -->
307
- <button #triggerBtn class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
308
- Mở toolbar
309
- </button>
310
- <libs_ui-components-inputs-quill2x
311
- [(item)]="floatingData"
312
- [fieldBind]="'content'"
313
- [quillCustomConfig]="floatingConfig()"
314
- [minHeightEditorContentDefault]="150">
315
- </libs_ui-components-inputs-quill2x>
308
+ <div>
309
+ <button #triggerBtn class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
310
+ Click để mở Quill Editor
311
+ </button>
312
+ <libs_ui-components-inputs-quill2x
313
+ [(item)]="positionFixedData"
314
+ [fieldBind]="'content'"
315
+ [quillCustomConfig]="positionFixedConfig()"
316
+ [displayToolbar]="true">
317
+ </libs_ui-components-inputs-quill2x>
318
+ </div>
316
319
  ```
317
320
 
318
321
  ### 6. Lập trình điều khiển editor qua FunctionsControl
@@ -399,7 +402,7 @@ export class MyComponent {
399
402
 
400
403
  | Output | Type | Mô tả | Handler TS | Binding HTML |
401
404
  |---|---|---|---|---|
402
- | `(outChange)` | `string` | Emit nội dung HTML (đã qua XSS filter) mỗi khi nội dung thay đổi. | `handlerChange(html: string): void { event.stopPropagation?.(); this.savedHtml = html; }` | `(outChange)="handlerChange($event)"` |
405
+ | `(outChange)` | `string` | Emit nội dung HTML (đã qua XSS filter) mỗi khi nội dung thay đổi. | `handlerChange(html: string): void { this.savedHtml = html; }` | `(outChange)="handlerChange($event)"` |
403
406
  | `(outFocus)` | `void` | Emit khi editor nhận focus. | `handlerFocus(): void { this.isEditing.set(true); }` | `(outFocus)="handlerFocus()"` |
404
407
  | `(outBlur)` | `void` | Emit khi editor mất focus. | `handlerBlur(): void { this.isEditing.set(false); }` | `(outBlur)="handlerBlur()"` |
405
408
  | `(outFunctionsControl)` | `IQuill2xFunctionControlEvent` | Emit ngay khi editor khởi tạo xong, trả về object chứa các hàm điều khiển editor. | `handlerFunctionsControl(ctrl: IQuill2xFunctionControlEvent): void { this.editorCtrl = ctrl; }` | `(outFunctionsControl)="handlerFunctionsControl($event)"` |
@@ -589,11 +592,3 @@ const delta = getDeltaOfQuill2xFromHTML(html);
589
592
  ⚠️ **Tính toán toolbar**: Toolbar tự tính toán độ rộng sau khi render. Nếu component cha có animation hoặc thay đổi kích thước, gọi `editorCtrl?.reCalculatorToolbar()` sau khi animation kết thúc để toolbar hiển thị đúng.
590
593
 
591
594
  ⚠️ **convertStandardList khi lưu**: HTML được lưu vào `item[fieldBind]` đã qua `convertStandardList()` để chuẩn hóa định dạng danh sách. Khi hiển thị lại nội dung, dùng component `@libs-ui/components-inputs-quill2x-preview` hoặc apply CSS Quill Snow theme.
592
-
593
- ## Demo
594
-
595
- ```bash
596
- npx nx serve core-ui
597
- ```
598
-
599
- Truy cập: http://localhost:4500/inputs/quill2x