@sdcorejs/angular 21.3.0 → 21.3.2

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.
Files changed (199) hide show
  1. package/README.md +2 -2
  2. package/assets/STYLE-GUIDE.md +25 -5
  3. package/assets/THEME.md +237 -5
  4. package/assets/licenses/tiptap-oss-NOTICES.txt +332 -0
  5. package/assets/scss/ckeditor5.scss +2 -88
  6. package/assets/scss/core/_control.scss +39 -0
  7. package/assets/scss/core/form.scss +156 -45
  8. package/assets/scss/core/view.scss +24 -0
  9. package/assets/scss/editor-content.scss +173 -0
  10. package/assets/scss/sd-core.scss +1 -0
  11. package/assets/scss/themes/_component-tokens.scss +93 -31
  12. package/assets/scss/themes/_material-tokens.scss +112 -0
  13. package/assets/scss/themes/_presets.scss +25 -0
  14. package/assets/scss/themes/_scales.scss +10 -0
  15. package/assets/scss/themes/_semantic.scss +13 -0
  16. package/assets/scss/themes/default.scss +8 -2
  17. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +5 -5
  18. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -1
  19. package/fesm2022/sdcorejs-angular-components-avatar.mjs +142 -11
  20. package/fesm2022/sdcorejs-angular-components-avatar.mjs.map +1 -1
  21. package/fesm2022/sdcorejs-angular-components-badge.mjs +542 -24
  22. package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
  23. package/fesm2022/sdcorejs-angular-components-button.mjs +31 -3
  24. package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
  25. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs +5 -20
  26. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs.map +1 -1
  27. package/fesm2022/sdcorejs-angular-components-data-state.mjs +1 -1
  28. package/fesm2022/sdcorejs-angular-components-data-state.mjs.map +1 -1
  29. package/fesm2022/sdcorejs-angular-components-editor-engine.mjs +1872 -0
  30. package/fesm2022/sdcorejs-angular-components-editor-engine.mjs.map +1 -0
  31. package/fesm2022/sdcorejs-angular-components-editor.mjs +457 -756
  32. package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
  33. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs +2209 -106
  34. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs.map +1 -1
  35. package/fesm2022/sdcorejs-angular-components-form-generic.mjs +2616 -1054
  36. package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
  37. package/fesm2022/sdcorejs-angular-components-history.mjs +5 -2
  38. package/fesm2022/sdcorejs-angular-components-history.mjs.map +1 -1
  39. package/fesm2022/sdcorejs-angular-components-image-editor.mjs +1 -1
  40. package/fesm2022/sdcorejs-angular-components-image-editor.mjs.map +1 -1
  41. package/fesm2022/sdcorejs-angular-components-import-excel.mjs +21 -6
  42. package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
  43. package/fesm2022/sdcorejs-angular-components-inform.mjs +1 -1
  44. package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
  45. package/fesm2022/sdcorejs-angular-components-kanban.mjs +451 -0
  46. package/fesm2022/sdcorejs-angular-components-kanban.mjs.map +1 -0
  47. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs +177 -283
  48. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs.map +1 -1
  49. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +1 -308
  50. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
  51. package/fesm2022/sdcorejs-angular-components-modal.mjs +2 -2
  52. package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
  53. package/fesm2022/sdcorejs-angular-components-operator.mjs +260 -43
  54. package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
  55. package/fesm2022/sdcorejs-angular-components-query-bar.mjs +12 -12
  56. package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
  57. package/fesm2022/sdcorejs-angular-components-query-builder.mjs +1 -1
  58. package/fesm2022/sdcorejs-angular-components-query-builder.mjs.map +1 -1
  59. package/fesm2022/sdcorejs-angular-components-section.mjs +5 -4
  60. package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
  61. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +2 -2
  62. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
  63. package/fesm2022/sdcorejs-angular-components-stepper.mjs +5 -1
  64. package/fesm2022/sdcorejs-angular-components-stepper.mjs.map +1 -1
  65. package/fesm2022/sdcorejs-angular-components-tab-router.mjs +192 -42
  66. package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
  67. package/fesm2022/sdcorejs-angular-components-tab.mjs +12 -4
  68. package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
  69. package/fesm2022/sdcorejs-angular-components-table.mjs +564 -110
  70. package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
  71. package/fesm2022/sdcorejs-angular-components-tree.mjs +1 -1
  72. package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
  73. package/fesm2022/sdcorejs-angular-components-upload-file.mjs +1 -1
  74. package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
  75. package/fesm2022/sdcorejs-angular-components-view.mjs +2 -2
  76. package/fesm2022/sdcorejs-angular-components-view.mjs.map +1 -1
  77. package/fesm2022/sdcorejs-angular-components-window.mjs +484 -0
  78. package/fesm2022/sdcorejs-angular-components-window.mjs.map +1 -0
  79. package/fesm2022/sdcorejs-angular-components.mjs +2 -0
  80. package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
  81. package/fesm2022/sdcorejs-angular-configurations.mjs.map +1 -1
  82. package/fesm2022/sdcorejs-angular-directives.mjs +18 -1
  83. package/fesm2022/sdcorejs-angular-directives.mjs.map +1 -1
  84. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +15 -2
  85. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
  86. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +2 -2
  87. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
  88. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +454 -125
  89. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
  90. package/fesm2022/sdcorejs-angular-forms-date-range.mjs +75 -13
  91. package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
  92. package/fesm2022/sdcorejs-angular-forms-date.mjs +71 -18
  93. package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
  94. package/fesm2022/sdcorejs-angular-forms-datetime.mjs +75 -16
  95. package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
  96. package/fesm2022/sdcorejs-angular-forms-directives.mjs +82 -2
  97. package/fesm2022/sdcorejs-angular-forms-directives.mjs.map +1 -1
  98. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs +2 -2
  99. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs.map +1 -1
  100. package/fesm2022/sdcorejs-angular-forms-input-color.mjs +1 -1
  101. package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
  102. package/fesm2022/sdcorejs-angular-forms-input-number.mjs +40 -5
  103. package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
  104. package/fesm2022/sdcorejs-angular-forms-input.mjs +50 -7
  105. package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
  106. package/fesm2022/sdcorejs-angular-forms-models.mjs +88 -5
  107. package/fesm2022/sdcorejs-angular-forms-models.mjs.map +1 -1
  108. package/fesm2022/sdcorejs-angular-forms-radio.mjs +2 -2
  109. package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
  110. package/fesm2022/sdcorejs-angular-forms-segmented.mjs +243 -0
  111. package/fesm2022/sdcorejs-angular-forms-segmented.mjs.map +1 -0
  112. package/fesm2022/sdcorejs-angular-forms-select.mjs +63 -15
  113. package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
  114. package/fesm2022/sdcorejs-angular-forms-switch.mjs +2 -2
  115. package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
  116. package/fesm2022/sdcorejs-angular-forms-textarea.mjs +2 -2
  117. package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
  118. package/fesm2022/sdcorejs-angular-forms-time.mjs +2 -2
  119. package/fesm2022/sdcorejs-angular-forms-time.mjs.map +1 -1
  120. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs +1 -1
  121. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs.map +1 -1
  122. package/fesm2022/sdcorejs-angular-forms.mjs +8 -0
  123. package/fesm2022/sdcorejs-angular-forms.mjs.map +1 -1
  124. package/fesm2022/sdcorejs-angular-i18n.mjs +1830 -17
  125. package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
  126. package/fesm2022/sdcorejs-angular-interceptors.mjs +1 -1
  127. package/fesm2022/sdcorejs-angular-interceptors.mjs.map +1 -1
  128. package/fesm2022/sdcorejs-angular-modules-generic-generic-configuration.page-MlNJ6DDc.mjs +478 -0
  129. package/fesm2022/sdcorejs-angular-modules-generic-generic-configuration.page-MlNJ6DDc.mjs.map +1 -0
  130. package/fesm2022/sdcorejs-angular-modules-generic-generic-form-host.page-_PcU75h9.mjs +214 -0
  131. package/fesm2022/sdcorejs-angular-modules-generic-generic-form-host.page-_PcU75h9.mjs.map +1 -0
  132. package/fesm2022/sdcorejs-angular-modules-generic-generic-list.page-qcvv7QK6.mjs +277 -0
  133. package/fesm2022/sdcorejs-angular-modules-generic-generic-list.page-qcvv7QK6.mjs.map +1 -0
  134. package/fesm2022/sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-B1fYY5yX.mjs +1556 -0
  135. package/fesm2022/sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-B1fYY5yX.mjs.map +1 -0
  136. package/fesm2022/sdcorejs-angular-modules-generic.mjs +2 -0
  137. package/fesm2022/sdcorejs-angular-modules-generic.mjs.map +1 -0
  138. package/fesm2022/sdcorejs-angular-modules-icon.mjs +96 -3
  139. package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
  140. package/fesm2022/sdcorejs-angular-modules-layout.mjs +1825 -62
  141. package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
  142. package/fesm2022/sdcorejs-angular-modules.mjs +1 -0
  143. package/fesm2022/sdcorejs-angular-modules.mjs.map +1 -1
  144. package/fesm2022/sdcorejs-angular-pipes.mjs +27 -7
  145. package/fesm2022/sdcorejs-angular-pipes.mjs.map +1 -1
  146. package/fesm2022/sdcorejs-angular-services-confirm.mjs +2 -2
  147. package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
  148. package/fesm2022/sdcorejs-angular-services-date-time.mjs +143 -0
  149. package/fesm2022/sdcorejs-angular-services-date-time.mjs.map +1 -0
  150. package/fesm2022/sdcorejs-angular-services-storage.mjs +44 -8
  151. package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
  152. package/fesm2022/sdcorejs-angular-services.mjs +1 -0
  153. package/fesm2022/sdcorejs-angular-services.mjs.map +1 -1
  154. package/fesm2022/sdcorejs-angular-utilities-read-state.mjs +4 -0
  155. package/fesm2022/sdcorejs-angular-utilities-read-state.mjs.map +1 -1
  156. package/fesm2022/sdcorejs-angular-utilities-theme.mjs +10 -0
  157. package/fesm2022/sdcorejs-angular-utilities-theme.mjs.map +1 -1
  158. package/package.json +48 -7
  159. package/types/sdcorejs-angular-components-avatar.d.ts +67 -2
  160. package/types/sdcorejs-angular-components-badge.d.ts +188 -6
  161. package/types/sdcorejs-angular-components-button.d.ts +20 -1
  162. package/types/sdcorejs-angular-components-ckeditor-styles.d.ts +3 -18
  163. package/types/sdcorejs-angular-components-editor-engine.d.ts +246 -0
  164. package/types/sdcorejs-angular-components-editor.d.ts +20 -17
  165. package/types/sdcorejs-angular-components-file-explorer.d.ts +449 -57
  166. package/types/sdcorejs-angular-components-form-generic.d.ts +301 -37
  167. package/types/sdcorejs-angular-components-kanban.d.ts +179 -0
  168. package/types/sdcorejs-angular-components-mini-editor.d.ts +33 -70
  169. package/types/sdcorejs-angular-components-modal-resizable.d.ts +1 -124
  170. package/types/sdcorejs-angular-components-operator.d.ts +137 -8
  171. package/types/sdcorejs-angular-components-section.d.ts +2 -1
  172. package/types/sdcorejs-angular-components-tab-router.d.ts +31 -18
  173. package/types/sdcorejs-angular-components-tab.d.ts +3 -1
  174. package/types/sdcorejs-angular-components-table.d.ts +84 -6
  175. package/types/sdcorejs-angular-components-window.d.ts +81 -0
  176. package/types/sdcorejs-angular-components.d.ts +2 -0
  177. package/types/sdcorejs-angular-configurations.d.ts +8 -1
  178. package/types/sdcorejs-angular-forms-autocomplete.d.ts +5 -0
  179. package/types/sdcorejs-angular-forms-chip-calendar.d.ts +163 -18
  180. package/types/sdcorejs-angular-forms-date-range.d.ts +24 -2
  181. package/types/sdcorejs-angular-forms-date.d.ts +23 -2
  182. package/types/sdcorejs-angular-forms-directives.d.ts +47 -2
  183. package/types/sdcorejs-angular-forms-input-number.d.ts +23 -2
  184. package/types/sdcorejs-angular-forms-input.d.ts +23 -2
  185. package/types/sdcorejs-angular-forms-models.d.ts +38 -3
  186. package/types/sdcorejs-angular-forms-segmented.d.ts +90 -0
  187. package/types/sdcorejs-angular-forms-select.d.ts +32 -2
  188. package/types/sdcorejs-angular-forms.d.ts +8 -6
  189. package/types/sdcorejs-angular-i18n.d.ts +360 -1
  190. package/types/sdcorejs-angular-modules-generic.d.ts +316 -0
  191. package/types/sdcorejs-angular-modules-icon.d.ts +37 -6
  192. package/types/sdcorejs-angular-modules-layout.d.ts +536 -86
  193. package/types/sdcorejs-angular-modules.d.ts +1 -0
  194. package/types/sdcorejs-angular-pipes.d.ts +2 -0
  195. package/types/sdcorejs-angular-services-date-time.d.ts +57 -0
  196. package/types/sdcorejs-angular-services-storage.d.ts +8 -1
  197. package/types/sdcorejs-angular-services.d.ts +1 -0
  198. package/types/sdcorejs-angular-utilities-read-state.d.ts +2 -0
  199. package/types/sdcorejs-angular-utilities-theme.d.ts +1 -1
@@ -1,337 +1,231 @@
1
- import { CommonModule } from '@angular/common';
2
1
  import * as i0 from '@angular/core';
3
- import { output, input, forwardRef, Input, HostBinding, Component } from '@angular/core';
4
- import * as i1 from '@ckeditor/ckeditor5-angular';
5
- import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
6
- import { SdCKEditorStyles } from '@sdcorejs/angular/components/ckeditor-styles';
7
- import { ClassicEditor, Essentials, FontColor, Paragraph, Bold, Italic, Underline, Link, List, Undo, Widget, Markdown, Mention, HtmlDataProcessor } from 'ckeditor5';
8
- import { Subscription, Subject } from 'rxjs';
9
- import { throttleTime } from 'rxjs/operators';
2
+ import { input, output, signal, computed, inject, ChangeDetectorRef, effect, forwardRef, HostBinding, Input, Component } from '@angular/core';
10
3
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
11
- import { sdSanitizeEditorHtml } from '@sdcorejs/angular/utilities/extensions';
4
+ import { SdEditorSurface } from '@sdcorejs/angular/components/editor-engine';
5
+ export { SdEditorImportError } from '@sdcorejs/angular/components/editor-engine';
12
6
 
13
- /**
14
- * Component sd-mini-editor - Editor đơn giản cho comment input
15
- * Sử dụng CKEditor với chế độ đơn giản (bold, italic, link)
16
- * Hỗ trợ mention và output format (html/markdown)
17
- *
18
- * @example
19
- * ```html
20
- * <sd-mini-editor
21
- * [option]="editorOption"
22
- * [(ngModel)]="content"
23
- * (contentChange)="onContentChange($event)"
24
- * >
25
- * </sd-mini-editor>
26
- * ```
27
- */
7
+ /** Compact Core toolbar with the same document schema as SdEditor. */
28
8
  class SdMiniEditor {
29
- /** Cấu hình option cho editor */
30
9
  option;
31
- get maxEditorHeight() {
32
- return this.option?.maxHeight;
33
- }
34
- /** NgModel binding - nội dung HTML/Markdown */
35
10
  value = '';
11
+ disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
36
12
  valueChange = output();
37
- /** Event emitter khi content thay đổi */
38
13
  contentChange = output();
39
- /** Event emitter khi blur */
40
14
  blur = output();
41
- /** Event emitter khi focus */
42
15
  focus = output();
43
- /** Disabled state */
44
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
45
- Editor = ClassicEditor;
46
- #editor;
47
- #subscription = new Subscription();
48
- #contentChangeSubject = new Subject();
49
- // Build editor config dynamically
50
- get editorConfig() {
51
- const enableMention = this.option?.enableMention ?? false;
52
- const useMarkdown = this.option?.outputFormat === 'markdown';
53
- const plugins = [Essentials, FontColor, Paragraph, Bold, Italic, Underline, Link, List, Undo, Widget];
54
- // Add Markdown plugin if outputFormat is markdown
55
- if (useMarkdown) {
56
- plugins.push(Markdown);
57
- }
58
- // Add Mention plugin if enabled
59
- if (enableMention) {
60
- plugins.push(Mention);
61
- }
62
- // Build base config
63
- const config = {
64
- licenseKey: 'GPL',
65
- getOption: () => this.option,
66
- plugins,
67
- toolbar: {
68
- items: ['bold', 'italic', 'underline', '|', 'fontColor', '|', 'bulletedList', 'numberedList', '|', 'link'],
69
- shouldNotGroupWhenFull: true,
70
- },
71
- placeholder: this.option?.placeholder,
72
- link: {
73
- addTargetToExternalLinks: true,
74
- defaultProtocol: 'https://',
75
- // why: mặc định CKEditor cho cả ftp/ftps; link trong bình luận chỉ cần web, mail và điện thoại.
76
- allowedProtocols: ['https', 'http', 'mailto', 'tel'],
77
- },
78
- fontColor: {
79
- columns: 5,
80
- documentColors: 10,
81
- colorPicker: { format: 'hex' },
82
- },
83
- };
84
- // Add mention configuration if enabled
85
- if (enableMention && this.option?.mentionConfig?.feeds) {
86
- config.mention = {
87
- feeds: this.option.mentionConfig.feeds,
88
- };
89
- }
90
- return config;
16
+ importWarning = output();
17
+ #diagnostics = signal([], ...(ngDevMode ? [{ debugName: "#diagnostics" }] : /* istanbul ignore next */ []));
18
+ importDiagnostics = this.#diagnostics.asReadonly();
19
+ surfaceContent = signal('', ...(ngDevMode ? [{ debugName: "surfaceContent" }] : /* istanbul ignore next */ []));
20
+ #formDisabled = signal(false, ...(ngDevMode ? [{ debugName: "#formDisabled" }] : /* istanbul ignore next */ []));
21
+ effectiveDisabled = computed(() => this.disabled() || this.#formDisabled(), ...(ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []));
22
+ #cdRef = inject(ChangeDetectorRef);
23
+ #engine;
24
+ #timer;
25
+ #trailing;
26
+ #deadline;
27
+ #composing = false;
28
+ #formatPending = false;
29
+ #destroyed = false;
30
+ #onChange = () => { };
31
+ #onTouched = () => { };
32
+ get maxEditorHeight() {
33
+ return this.option?.maxHeight;
91
34
  }
92
35
  constructor() {
93
- // Setup debounce cho content change
94
- this.#subscription.add(this.#contentChangeSubject.pipe(throttleTime(500, undefined, { leading: true, trailing: true })).subscribe(() => {
95
- const output = this.#convertOutput();
96
- this.value = output;
97
- this.#onChange(output);
98
- this.valueChange.emit(output);
99
- this.contentChange.emit(output);
100
- this.option?.onChange?.(output);
101
- }));
36
+ effect(() => {
37
+ if (this.effectiveDisabled())
38
+ this.onSourceChange();
39
+ });
102
40
  }
103
- ngOnDestroy() {
104
- this.#subscription.unsubscribe();
105
- this.#editor?.destroy?.();
41
+ ngOnChanges(changes) {
42
+ if (changes['value'])
43
+ this.setContent(this.value);
106
44
  }
107
- /**
108
- * Kiểm tra có nên enable mention plugin không
109
- */
110
- #shouldEnableMention() {
111
- return this.option?.enableMention ?? false;
45
+ onEngineReady(engine) {
46
+ this.onSourceChange();
47
+ this.#composing = false;
48
+ this.#engine = engine;
112
49
  }
113
- /**
114
- * Xử lý khi editor ready
115
- */
116
- onReady(editor) {
117
- this.#editor = editor;
118
- // Set initial content
119
- if (this.value) {
120
- this.setContent(this.value);
50
+ /** Cancel a stale throttle window before replacing an authoritative source. */
51
+ onSourceChange(reason = 'source') {
52
+ this.#clearTimer();
53
+ if (reason === 'format') {
54
+ this.#formatPending = true;
55
+ return;
121
56
  }
122
- // Lắng nghe sự kiện thay đổi nội dung
123
- editor.model.document.on('change:data', () => {
124
- this.#contentChangeSubject.next();
125
- });
126
- // Lắng nghe focus/blur events
127
- editor.editing.view.document.on('focus', evt => {
128
- const domEvent = evt.domEvent;
129
- this.focus.emit(domEvent);
130
- this.option?.onFocus?.(domEvent);
131
- });
132
- editor.editing.view.document.on('blur', evt => {
133
- const domEvent = evt.domEvent;
134
- this.blur.emit(domEvent);
135
- this.option?.onBlur?.(domEvent);
136
- });
137
- // Lắng nghe sự kiện mention được chọn
138
- if (this.#shouldEnableMention()) {
139
- editor.commands.get('mention')?.on('execute', (_evt, data) => {
140
- const mentionData = data[0];
141
- this.option?.onMentionSelect?.(mentionData.mention);
142
- // Trigger content change sau khi insert mention
143
- this.#contentChangeSubject.next();
144
- });
145
- // Custom downcast converter để thay đổi cấu trúc mention HTML
146
- editor.conversion.for('downcast').attributeToElement({
147
- model: 'mention',
148
- view: (mentionData, { writer }) => {
149
- const data = mentionData;
150
- const rawId = data?.id || '';
151
- const marker = rawId[0];
152
- const cleanId = rawId.slice(1);
153
- return writer.createAttributeElement('span', {
154
- class: 'ck-custom-mention',
155
- 'data-id': cleanId,
156
- 'data-marker': marker,
157
- contenteditable: 'false',
158
- });
159
- },
160
- converterPriority: 'highest',
161
- });
162
- // Xử lý keyboard để xóa mention 1 lần
163
- editor.editing.view.document.on('keydown', (evt, data) => {
164
- const keyEvent = data;
165
- // Delete (46) hoặc Backspace (8)
166
- if (keyEvent.keyCode === 46 || keyEvent.keyCode === 8) {
167
- const model = editor.model;
168
- const selection = model.document.selection;
169
- const position = selection.getFirstPosition();
170
- if (!position)
171
- return;
172
- // Tìm text node có mention attribute
173
- const node = position.textNode || position.nodeBefore || position.nodeAfter;
174
- if (node && node.is('$text')) {
175
- const mentionAttr = node.getAttribute('mention');
176
- if (mentionAttr) {
177
- // Xóa toàn bộ text node chứa mention
178
- model.change(writer => {
179
- writer.remove(node);
180
- });
181
- evt.stop();
182
- }
183
- }
184
- }
185
- });
57
+ this.#formatPending = false;
58
+ this.#deadline = undefined;
59
+ this.#trailing = undefined;
60
+ }
61
+ onFormatChange(value) {
62
+ if (this.#destroyed || this.effectiveDisabled())
63
+ return;
64
+ // A refused conversion stays paused until a supported representation is
65
+ // restored. Retain the live pending edit without exporting stale HTML.
66
+ if (value === undefined)
67
+ return;
68
+ this.#formatPending = false;
69
+ this.#trailing = undefined;
70
+ if (value !== this.value)
71
+ this.onSurfaceChange(value);
72
+ if (this.#deadline !== undefined)
73
+ this.#scheduleWindow();
74
+ }
75
+ onSurfaceChange(value) {
76
+ if (this.#destroyed || this.effectiveDisabled())
77
+ return;
78
+ if (this.#composing || this.#formatPending) {
79
+ this.#trailing = value;
80
+ return;
81
+ }
82
+ if (this.#deadline === undefined) {
83
+ // App callbacks can replace content synchronously; establish the window first.
84
+ this.#startWindow();
85
+ this.#emit(value);
186
86
  }
87
+ else
88
+ this.#trailing = value;
187
89
  }
188
- /**
189
- * Nội dung phát ra ngoài theo `outputFormat`: HTML đã lọc, hoặc Markdown dựng từ HTML đã lọc.
190
- * Là điểm ra duy nhất cho cả luồng throttle (valueChange/contentChange/form) lẫn `getContent()` (D-032).
191
- */
192
- #convertOutput() {
193
- const editor = this.#editor;
194
- if (!editor)
195
- return '';
196
- const html = this.#readSanitizedHtml(editor);
197
- if (!this.#isMarkdown())
198
- return html;
199
- // why: dựng Markdown từ HTML ĐÃ lọc, để `[text](javascript:...)` không thể lọt vào chuỗi Markdown.
200
- const htmlProcessor = new HtmlDataProcessor(editor.data.viewDocument);
201
- return editor.data.processor.toData(htmlProcessor.toView(html));
90
+ #startWindow() {
91
+ this.#deadline = Date.now() + 500;
92
+ this.#scheduleWindow();
202
93
  }
203
- #isMarkdown() {
204
- return this.option?.outputFormat === 'markdown';
94
+ #scheduleWindow() {
95
+ if (this.#deadline === undefined || this.#composing || this.#formatPending || this.#destroyed)
96
+ return;
97
+ this.#clearTimer();
98
+ this.#timer = setTimeout(() => {
99
+ this.#timer = undefined;
100
+ this.#deadline = undefined;
101
+ const trailing = this.#trailing;
102
+ this.#trailing = undefined;
103
+ if (trailing !== undefined && !this.#destroyed && !this.#composing && !this.effectiveDisabled()) {
104
+ this.#startWindow();
105
+ this.#emit(trailing);
106
+ }
107
+ }, Math.max(0, this.#deadline - Date.now()));
108
+ }
109
+ onCompositionChange(composing) {
110
+ this.#composing = composing;
111
+ this.#clearTimer();
112
+ if (composing || this.#formatPending || this.#destroyed || this.effectiveDisabled())
113
+ return;
114
+ if (this.#deadline !== undefined)
115
+ this.#scheduleWindow();
116
+ else if (this.#trailing !== undefined) {
117
+ const value = this.#trailing;
118
+ this.#trailing = undefined;
119
+ this.#startWindow();
120
+ this.#emit(value);
121
+ }
122
+ }
123
+ #clearTimer() {
124
+ if (this.#timer !== undefined)
125
+ clearTimeout(this.#timer);
126
+ this.#timer = undefined;
127
+ }
128
+ #emit(value) {
129
+ this.value = value;
130
+ this.#onChange(value);
131
+ this.valueChange.emit(value);
132
+ this.contentChange.emit(value);
133
+ this.option?.onChange?.(value);
134
+ this.#cdRef.markForCheck();
205
135
  }
206
- /** HTML hiện tại của editor (kể cả ở chế độ Markdown), đã qua `sdSanitizeEditorHtml`. */
207
- #readSanitizedHtml(editor) {
208
- if (!this.#isMarkdown())
209
- return sdSanitizeEditorHtml(editor.getData());
210
- // why: với plugin Markdown, `getData()` trả Markdown. Lấy HTML từ data view (đúng thứ getData() dùng)
211
- // để lọc trước khi chuyển.
212
- const root = editor.model.document.getRoot();
213
- if (!root)
214
- return '';
215
- const htmlProcessor = new HtmlDataProcessor(editor.data.viewDocument);
216
- return sdSanitizeEditorHtml(htmlProcessor.toData(editor.data.toView(root)));
136
+ onSurfaceFocus(event) {
137
+ this.focus.emit(event);
138
+ this.option?.onFocus?.(event);
139
+ }
140
+ onSurfaceBlur(event) {
141
+ this.#onTouched();
142
+ this.blur.emit(event);
143
+ this.option?.onBlur?.(event);
144
+ this.#cdRef.markForCheck();
145
+ }
146
+ onDiagnostics(diagnostics) {
147
+ this.#diagnostics.set(diagnostics);
148
+ this.importWarning.emit(diagnostics);
149
+ }
150
+ onMentionSelected(item) {
151
+ this.option?.onMentionSelect?.(item);
217
152
  }
218
- /**
219
- * Set nội dung cho editor
220
- */
221
153
  setContent(content) {
222
- this.#editor?.setData?.(content);
154
+ const value = content ?? '';
155
+ this.value = value;
156
+ // Consumer echoes must not replay content or reset the current selection/history.
157
+ if (this.#isCurrentContent(value))
158
+ return;
159
+ this.onSourceChange();
160
+ this.surfaceContent.set(value);
161
+ this.#engine?.setContent(value, this.option?.outputFormat ?? 'html');
162
+ this.#cdRef.markForCheck();
163
+ }
164
+ #isCurrentContent(value) {
165
+ if (!this.#engine)
166
+ return value === this.surfaceContent();
167
+ try {
168
+ return this.#engine.format === (this.option?.outputFormat ?? 'html') && value === this.#engine.getContent();
169
+ }
170
+ catch {
171
+ return false;
172
+ }
223
173
  }
224
- /**
225
- * Get nội dung từ editor
226
- */
227
174
  getContent() {
228
- return this.#convertOutput();
175
+ return this.#engine?.getContent() ?? '';
229
176
  }
230
- /**
231
- * Nội dung dạng HTML (đã lọc), bất kể `outputFormat`.
232
- */
233
177
  getHtmlContent() {
234
- return this.#editor ? this.#readSanitizedHtml(this.#editor) : '';
178
+ return this.#engine?.getHtml() ?? '';
235
179
  }
236
- /**
237
- * Focus vào editor
238
- */
239
180
  focusEditor() {
240
- this.#editor?.editing?.view?.focus?.();
181
+ if (!this.effectiveDisabled())
182
+ this.#engine?.focus();
241
183
  }
242
- /**
243
- * Insert mention vào vị trí con trỏ hiện tại
244
- */
245
184
  insertMention(item) {
246
- if (!this.#editor)
185
+ if (!this.#engine || !this.option?.enableMention || this.effectiveDisabled() || this.importDiagnostics().length)
247
186
  return;
248
- const firstFeed = this.option?.mentionConfig?.feeds?.[0];
249
- const marker = item.marker || firstFeed?.marker || '@';
250
- // Sử dụng CKEditor mention command
251
- this.#editor.execute('mention', {
252
- marker,
253
- mention: {
254
- id: item.id,
255
- text: `${marker}${item.name}`,
256
- },
257
- });
187
+ const marker = item.marker ?? this.option.mentionConfig?.feeds?.[0]?.marker ?? '@';
188
+ this.#engine.insertMention({ ...item, marker });
189
+ this.option.onMentionSelect?.({ id: item.id, name: item.name, text: `${marker}${item.name}` });
258
190
  }
259
- /**
260
- * Get danh sách mentions trong nội dung
261
- */
262
191
  getMentions() {
263
- if (!this.#editor)
264
- return [];
265
- const mentions = [];
266
- const root = this.#editor.model.document.getRoot();
267
- if (!root)
268
- return mentions;
269
- const range = this.#editor.model.createRangeIn(root);
270
- for (const item of range.getItems()) {
271
- if (item.is('$text')) {
272
- const mentionAttr = item.getAttribute('mention');
273
- if (mentionAttr) {
274
- const text = item.data;
275
- const marker = text.charAt(0);
276
- const name = text.substring(1);
277
- const id = item.getAttribute('data-user-id');
278
- mentions.push({ id, name, marker });
279
- }
280
- }
281
- }
282
- return mentions;
192
+ return this.#engine?.getMentions() ?? [];
283
193
  }
284
- /**
285
- * ControlValueAccessor: Write value
286
- */
287
194
  writeValue(value) {
288
- this.value = value || '';
289
- if (this.#editor) {
290
- this.setContent(this.value);
291
- }
195
+ this.setContent(value || '');
292
196
  }
293
- /**
294
- * ControlValueAccessor: Register change callback
295
- */
296
197
  registerOnChange(fn) {
297
198
  this.#onChange = fn;
298
199
  }
299
- /**
300
- * ControlValueAccessor: Register touched callback
301
- */
302
200
  registerOnTouched(fn) {
303
201
  this.#onTouched = fn;
304
202
  }
305
- /** ControlValueAccessor callbacks */
306
- #onChange = () => { };
307
- #onTouched = () => { };
203
+ setDisabledState(disabled) {
204
+ this.#formDisabled.set(disabled);
205
+ if (disabled)
206
+ this.onSourceChange();
207
+ this.#cdRef.markForCheck();
208
+ }
209
+ ngOnDestroy() {
210
+ this.#destroyed = true;
211
+ this.onSourceChange();
212
+ this.#engine = undefined; // Surface owns engine destruction.
213
+ }
308
214
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: SdMiniEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
309
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.17", type: SdMiniEditor, isStandalone: true, selector: "sd-mini-editor", inputs: { option: { classPropertyName: "option", publicName: "option", isSignal: false, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", contentChange: "contentChange", blur: "blur", focus: "focus" }, host: { properties: { "style.--sd-mini-editor-max-height": "this.maxEditorHeight" } }, providers: [
310
- {
311
- provide: NG_VALUE_ACCESSOR,
312
- useExisting: forwardRef(() => SdMiniEditor),
313
- multi: true,
314
- },
315
- ], ngImport: i0, template: "<sd-ckeditor-styles />\n<ckeditor class=\"sd-mini-editor\" [editor]=\"Editor\" [config]=\"editorConfig\" [disabled]=\"disabled()\" (ready)=\"onReady($event)\"> </ckeditor>\n", styles: [".sd-mini-editor{display:block}::ng-deep .ck-powered-by-balloon{display:none!important}::ng-deep .ck-mentions .ck-button.ck-on{background:var(--sd-primary)!important;color:var(--sd-text-on-solid, #ffffff)!important}::ng-deep .ck-mentions .ck-button.ck-on *{color:var(--sd-text-on-solid, #ffffff)!important}:host ::ng-deep .ck-editor{--ck-content-font-size: 14px;--ck-content-line-height: 1.5}:host ::ng-deep .ck-editor__editable_inline{border:var(--ck-focus-ring);border-top-left-radius:0!important;border-top-right-radius:0!important;max-height:var(--sd-mini-editor-max-height);overflow:auto}:host ::ng-deep .ck-toolbar{border-radius:0;border:0!important}:host ::ng-deep .ck-content img{max-width:100%!important;height:auto!important;object-fit:contain}:host ::ng-deep .ck-content p{margin-bottom:var(--ck-spacing-large);text-indent:0}:host ::ng-deep .ck-content ul,:host ::ng-deep .ck-content ol{padding-left:20px!important;margin-left:0!important}:host ::ng-deep .ck-custom-mention{font-weight:var(--sd-font-weight-semibold, 600);padding:0 2px;display:inline-block;pointer-events:none;-webkit-user-select:none;user-select:none;color:var(--sd-primary, #005cbb)}:host ::ng-deep .ck-custom-mention:before{content:attr(data-marker)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: CKEditorModule }, { kind: "component", type: i1.CKEditorComponent, selector: "ckeditor", inputs: ["editor", "config", "data", "tagName", "watchdog", "editorWatchdogConfig", "disableWatchdog", "disableTwoWayDataBinding", "disabled"], outputs: ["ready", "change", "blur", "focus", "error"] }, { kind: "component", type: SdCKEditorStyles, selector: "sd-ckeditor-styles" }] });
215
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.17", type: SdMiniEditor, isStandalone: true, selector: "sd-mini-editor", inputs: { option: { classPropertyName: "option", publicName: "option", isSignal: false, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", contentChange: "contentChange", blur: "blur", focus: "focus", importWarning: "importWarning" }, host: { properties: { "style.--sd-mini-editor-max-height": "this.maxEditorHeight" } }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SdMiniEditor), multi: true }], usesOnChanges: true, ngImport: i0, template: "<sd-editor-surface\n class=\"sd-mini-editor\"\n variant=\"compact\"\n [content]=\"surfaceContent()\"\n [format]=\"option?.outputFormat ?? 'html'\"\n [editable]=\"!effectiveDisabled()\"\n [placeholder]=\"option?.placeholder\"\n [disabled]=\"effectiveDisabled()\"\n [height]=\"option?.height\"\n [maxHeight]=\"option?.maxHeight\"\n [mentionFeeds]=\"option?.enableMention ? option?.mentionConfig?.feeds : undefined\"\n (engineReady)=\"onEngineReady($event)\"\n (sourceChange)=\"onSourceChange($event)\"\n (formatChange)=\"onFormatChange($event)\"\n (compositionChange)=\"onCompositionChange($event)\"\n (change)=\"onSurfaceChange($event)\"\n (focus)=\"onSurfaceFocus($event)\"\n (blur)=\"onSurfaceBlur($event)\"\n (diagnostics)=\"onDiagnostics($event)\"\n (mentionSelected)=\"onMentionSelected($event)\" />\n", styles: [":host,.sd-mini-editor{display:block}\n"], dependencies: [{ kind: "component", type: SdEditorSurface, selector: "sd-editor-surface", inputs: ["content", "format", "variant", "editable", "disabled", "readonly", "placeholder", "mentionFeeds", "uploadEnabled", "height", "maxHeight", "label", "describedBy", "invalid", "id"], outputs: ["engineReady", "change", "focus", "blur", "diagnostics", "sourceChange", "formatChange", "compositionChange", "mentionSelected", "filesSelected"] }] });
316
216
  }
317
217
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: SdMiniEditor, decorators: [{
318
218
  type: Component,
319
- args: [{ selector: 'sd-mini-editor', standalone: true, imports: [CommonModule, CKEditorModule, SdCKEditorStyles], providers: [
320
- {
321
- provide: NG_VALUE_ACCESSOR,
322
- useExisting: forwardRef(() => SdMiniEditor),
323
- multi: true,
324
- },
325
- ], template: "<sd-ckeditor-styles />\n<ckeditor class=\"sd-mini-editor\" [editor]=\"Editor\" [config]=\"editorConfig\" [disabled]=\"disabled()\" (ready)=\"onReady($event)\"> </ckeditor>\n", styles: [".sd-mini-editor{display:block}::ng-deep .ck-powered-by-balloon{display:none!important}::ng-deep .ck-mentions .ck-button.ck-on{background:var(--sd-primary)!important;color:var(--sd-text-on-solid, #ffffff)!important}::ng-deep .ck-mentions .ck-button.ck-on *{color:var(--sd-text-on-solid, #ffffff)!important}:host ::ng-deep .ck-editor{--ck-content-font-size: 14px;--ck-content-line-height: 1.5}:host ::ng-deep .ck-editor__editable_inline{border:var(--ck-focus-ring);border-top-left-radius:0!important;border-top-right-radius:0!important;max-height:var(--sd-mini-editor-max-height);overflow:auto}:host ::ng-deep .ck-toolbar{border-radius:0;border:0!important}:host ::ng-deep .ck-content img{max-width:100%!important;height:auto!important;object-fit:contain}:host ::ng-deep .ck-content p{margin-bottom:var(--ck-spacing-large);text-indent:0}:host ::ng-deep .ck-content ul,:host ::ng-deep .ck-content ol{padding-left:20px!important;margin-left:0!important}:host ::ng-deep .ck-custom-mention{font-weight:var(--sd-font-weight-semibold, 600);padding:0 2px;display:inline-block;pointer-events:none;-webkit-user-select:none;user-select:none;color:var(--sd-primary, #005cbb)}:host ::ng-deep .ck-custom-mention:before{content:attr(data-marker)}\n"] }]
219
+ args: [{ selector: 'sd-mini-editor', standalone: true, imports: [SdEditorSurface], providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SdMiniEditor), multi: true }], template: "<sd-editor-surface\n class=\"sd-mini-editor\"\n variant=\"compact\"\n [content]=\"surfaceContent()\"\n [format]=\"option?.outputFormat ?? 'html'\"\n [editable]=\"!effectiveDisabled()\"\n [placeholder]=\"option?.placeholder\"\n [disabled]=\"effectiveDisabled()\"\n [height]=\"option?.height\"\n [maxHeight]=\"option?.maxHeight\"\n [mentionFeeds]=\"option?.enableMention ? option?.mentionConfig?.feeds : undefined\"\n (engineReady)=\"onEngineReady($event)\"\n (sourceChange)=\"onSourceChange($event)\"\n (formatChange)=\"onFormatChange($event)\"\n (compositionChange)=\"onCompositionChange($event)\"\n (change)=\"onSurfaceChange($event)\"\n (focus)=\"onSurfaceFocus($event)\"\n (blur)=\"onSurfaceBlur($event)\"\n (diagnostics)=\"onDiagnostics($event)\"\n (mentionSelected)=\"onMentionSelected($event)\" />\n", styles: [":host,.sd-mini-editor{display:block}\n"] }]
326
220
  }], ctorParameters: () => [], propDecorators: { option: [{
327
221
  type: Input,
328
222
  args: [{ required: true }]
329
- }], maxEditorHeight: [{
330
- type: HostBinding,
331
- args: ['style.--sd-mini-editor-max-height']
332
223
  }], value: [{
333
224
  type: Input
334
- }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], contentChange: [{ type: i0.Output, args: ["contentChange"] }], blur: [{ type: i0.Output, args: ["blur"] }], focus: [{ type: i0.Output, args: ["focus"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
225
+ }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], contentChange: [{ type: i0.Output, args: ["contentChange"] }], blur: [{ type: i0.Output, args: ["blur"] }], focus: [{ type: i0.Output, args: ["focus"] }], importWarning: [{ type: i0.Output, args: ["importWarning"] }], maxEditorHeight: [{
226
+ type: HostBinding,
227
+ args: ['style.--sd-mini-editor-max-height']
228
+ }] } });
335
229
 
336
230
  /**
337
231
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"sdcorejs-angular-components-mini-editor.mjs","sources":["../../../projects/sdcorejs-angular/components/mini-editor/src/mini-editor.component.ts","../../../projects/sdcorejs-angular/components/mini-editor/src/mini-editor.component.html","../../../projects/sdcorejs-angular/components/mini-editor/sdcorejs-angular-components-mini-editor.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, HostBinding, Input, forwardRef, OnDestroy, input, output } from '@angular/core';\nimport { CKEditorModule } from '@ckeditor/ckeditor5-angular';\nimport { SdCKEditorStyles } from '@sdcorejs/angular/components/ckeditor-styles';\nimport {\n Bold,\n ClassicEditor,\n Essentials,\n Italic,\n Link,\n List,\n FontColor,\n HtmlDataProcessor,\n Markdown,\n Mention,\n Paragraph,\n Underline,\n Undo,\n Widget,\n} from 'ckeditor5';\nimport { Subject, Subscription } from 'rxjs';\nimport { throttleTime } from 'rxjs/operators';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport { sdSanitizeEditorHtml } from '@sdcorejs/angular/utilities/extensions';\n\nimport { SdMiniEditorOption, SdMiniEditorConfig, SdMiniEditorMentionItem } from './mini-editor.model';\n\n/**\n * Component sd-mini-editor - Editor đơn giản cho comment input\n * Sử dụng CKEditor với chế độ đơn giản (bold, italic, link)\n * Hỗ trợ mention và output format (html/markdown)\n *\n * @example\n * ```html\n * <sd-mini-editor\n * [option]=\"editorOption\"\n * [(ngModel)]=\"content\"\n * (contentChange)=\"onContentChange($event)\"\n * >\n * </sd-mini-editor>\n * ```\n */\n@Component({\n selector: 'sd-mini-editor',\n standalone: true,\n imports: [CommonModule, CKEditorModule, SdCKEditorStyles],\n templateUrl: './mini-editor.component.html',\n styleUrl: './mini-editor.component.scss',\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SdMiniEditor),\n multi: true,\n },\n ],\n})\nexport class SdMiniEditor implements ControlValueAccessor, OnDestroy {\n /** Cấu hình option cho editor */\n @Input({ required: true }) option!: SdMiniEditorOption;\n\n @HostBinding('style.--sd-mini-editor-max-height')\n get maxEditorHeight(): string | undefined {\n return this.option?.maxHeight;\n }\n\n /** NgModel binding - nội dung HTML/Markdown */\n @Input() value = '';\n readonly valueChange = output<string>();\n\n /** Event emitter khi content thay đổi */\n readonly contentChange = output<string>();\n\n /** Event emitter khi blur */\n readonly blur = output<FocusEvent>();\n\n /** Event emitter khi focus */\n readonly focus = output<FocusEvent>();\n\n /** Disabled state */\n readonly disabled = input(false);\n\n Editor = ClassicEditor;\n #editor!: ClassicEditor;\n #subscription = new Subscription();\n #contentChangeSubject = new Subject<void>();\n\n // Build editor config dynamically\n get editorConfig(): SdMiniEditorConfig {\n const enableMention = this.option?.enableMention ?? false;\n const useMarkdown = this.option?.outputFormat === 'markdown';\n const plugins: any[] = [Essentials, FontColor, Paragraph, Bold, Italic, Underline, Link, List, Undo, Widget];\n\n // Add Markdown plugin if outputFormat is markdown\n if (useMarkdown) {\n plugins.push(Markdown);\n }\n\n // Add Mention plugin if enabled\n if (enableMention) {\n plugins.push(Mention);\n }\n\n // Build base config\n const config: SdMiniEditorConfig = {\n licenseKey: 'GPL',\n getOption: () => this.option,\n plugins,\n toolbar: {\n items: ['bold', 'italic', 'underline', '|', 'fontColor', '|', 'bulletedList', 'numberedList', '|', 'link'],\n shouldNotGroupWhenFull: true,\n },\n placeholder: this.option?.placeholder,\n link: {\n addTargetToExternalLinks: true,\n defaultProtocol: 'https://',\n // why: mặc định CKEditor cho cả ftp/ftps; link trong bình luận chỉ cần web, mail và điện thoại.\n allowedProtocols: ['https', 'http', 'mailto', 'tel'],\n },\n fontColor: {\n columns: 5,\n documentColors: 10,\n colorPicker: { format: 'hex' },\n },\n };\n\n // Add mention configuration if enabled\n if (enableMention && this.option?.mentionConfig?.feeds) {\n config.mention = {\n feeds: this.option.mentionConfig.feeds,\n };\n }\n\n return config;\n }\n\n constructor() {\n // Setup debounce cho content change\n this.#subscription.add(\n this.#contentChangeSubject.pipe(throttleTime(500, undefined, { leading: true, trailing: true })).subscribe(() => {\n const output = this.#convertOutput();\n this.value = output;\n this.#onChange(output);\n this.valueChange.emit(output);\n this.contentChange.emit(output);\n this.option?.onChange?.(output);\n })\n );\n }\n\n ngOnDestroy() {\n this.#subscription.unsubscribe();\n this.#editor?.destroy?.();\n }\n\n /**\n * Kiểm tra có nên enable mention plugin không\n */\n #shouldEnableMention(): boolean {\n return this.option?.enableMention ?? false;\n }\n\n /**\n * Xử lý khi editor ready\n */\n onReady(editor: ClassicEditor) {\n this.#editor = editor;\n\n // Set initial content\n if (this.value) {\n this.setContent(this.value);\n }\n\n // Lắng nghe sự kiện thay đổi nội dung\n editor.model.document.on('change:data', () => {\n this.#contentChangeSubject.next();\n });\n\n // Lắng nghe focus/blur events\n editor.editing.view.document.on('focus', evt => {\n const domEvent = (evt as any).domEvent as FocusEvent;\n this.focus.emit(domEvent);\n this.option?.onFocus?.(domEvent);\n });\n\n editor.editing.view.document.on('blur', evt => {\n const domEvent = (evt as any).domEvent as FocusEvent;\n this.blur.emit(domEvent);\n this.option?.onBlur?.(domEvent);\n });\n\n // Lắng nghe sự kiện mention được chọn\n if (this.#shouldEnableMention()) {\n editor.commands.get('mention')?.on('execute', (_evt, data: any) => {\n const mentionData = data[0];\n this.option?.onMentionSelect?.(mentionData.mention);\n // Trigger content change sau khi insert mention\n this.#contentChangeSubject.next();\n });\n\n // Custom downcast converter để thay đổi cấu trúc mention HTML\n editor.conversion.for('downcast').attributeToElement({\n model: 'mention',\n view: (mentionData, { writer }) => {\n const data = mentionData as SdMiniEditorMentionItem;\n const rawId = data?.id || '';\n const marker = rawId[0];\n const cleanId = rawId.slice(1);\n\n return writer.createAttributeElement('span', {\n class: 'ck-custom-mention',\n 'data-id': cleanId,\n 'data-marker': marker,\n contenteditable: 'false',\n });\n },\n converterPriority: 'highest',\n });\n\n // Xử lý keyboard để xóa mention 1 lần\n editor.editing.view.document.on('keydown', (evt, data) => {\n const keyEvent = data as { keyCode: number; domEvent: KeyboardEvent };\n // Delete (46) hoặc Backspace (8)\n if (keyEvent.keyCode === 46 || keyEvent.keyCode === 8) {\n const model = editor.model;\n const selection = model.document.selection;\n const position = selection.getFirstPosition();\n if (!position) return;\n\n // Tìm text node có mention attribute\n const node = position.textNode || position.nodeBefore || position.nodeAfter;\n if (node && node.is('$text')) {\n const mentionAttr = node.getAttribute('mention');\n if (mentionAttr) {\n // Xóa toàn bộ text node chứa mention\n model.change(writer => {\n writer.remove(node);\n });\n evt.stop();\n }\n }\n }\n });\n }\n }\n\n /**\n * Nội dung phát ra ngoài theo `outputFormat`: HTML đã lọc, hoặc Markdown dựng từ HTML đã lọc.\n * Là điểm ra duy nhất cho cả luồng throttle (valueChange/contentChange/form) lẫn `getContent()` (D-032).\n */\n #convertOutput(): string {\n const editor = this.#editor;\n if (!editor) return '';\n const html = this.#readSanitizedHtml(editor);\n if (!this.#isMarkdown()) return html;\n // why: dựng Markdown từ HTML ĐÃ lọc, để `[text](javascript:...)` không thể lọt vào chuỗi Markdown.\n const htmlProcessor = new HtmlDataProcessor(editor.data.viewDocument);\n return editor.data.processor.toData(htmlProcessor.toView(html));\n }\n\n #isMarkdown(): boolean {\n return this.option?.outputFormat === 'markdown';\n }\n\n /** HTML hiện tại của editor (kể cả ở chế độ Markdown), đã qua `sdSanitizeEditorHtml`. */\n #readSanitizedHtml(editor: ClassicEditor): string {\n if (!this.#isMarkdown()) return sdSanitizeEditorHtml(editor.getData());\n // why: với plugin Markdown, `getData()` trả Markdown. Lấy HTML từ data view (đúng thứ getData() dùng)\n // để lọc trước khi chuyển.\n const root = editor.model.document.getRoot();\n if (!root) return '';\n const htmlProcessor = new HtmlDataProcessor(editor.data.viewDocument);\n return sdSanitizeEditorHtml(htmlProcessor.toData(editor.data.toView(root)));\n }\n\n /**\n * Set nội dung cho editor\n */\n setContent(content: string) {\n this.#editor?.setData?.(content);\n }\n\n /**\n * Get nội dung từ editor\n */\n getContent(): string {\n return this.#convertOutput();\n }\n\n /**\n * Nội dung dạng HTML (đã lọc), bất kể `outputFormat`.\n */\n getHtmlContent(): string {\n return this.#editor ? this.#readSanitizedHtml(this.#editor) : '';\n }\n\n /**\n * Focus vào editor\n */\n focusEditor() {\n this.#editor?.editing?.view?.focus?.();\n }\n\n /**\n * Insert mention vào vị trí con trỏ hiện tại\n */\n insertMention(item: { id: string; name: string; marker?: string }) {\n if (!this.#editor) return;\n\n const firstFeed = this.option?.mentionConfig?.feeds?.[0];\n const marker = item.marker || (firstFeed as any)?.marker || '@';\n\n // Sử dụng CKEditor mention command\n this.#editor.execute('mention', {\n marker,\n mention: {\n id: item.id,\n text: `${marker}${item.name}`,\n },\n });\n }\n\n /**\n * Get danh sách mentions trong nội dung\n */\n getMentions(): { id: string; name: string; marker: string }[] {\n if (!this.#editor) return [];\n\n const mentions: { id: string; name: string; marker: string }[] = [];\n const root = this.#editor.model.document.getRoot();\n if (!root) return mentions;\n\n const range = this.#editor.model.createRangeIn(root);\n\n for (const item of range.getItems()) {\n if (item.is('$text')) {\n const mentionAttr = item.getAttribute('mention');\n if (mentionAttr) {\n const text = (item as any).data as string;\n const marker = text.charAt(0);\n const name = text.substring(1);\n const id = item.getAttribute('data-user-id') as string;\n\n mentions.push({ id, name, marker });\n }\n }\n }\n\n return mentions;\n }\n\n /**\n * ControlValueAccessor: Write value\n */\n writeValue(value: string): void {\n this.value = value || '';\n if (this.#editor) {\n this.setContent(this.value);\n }\n }\n\n /**\n * ControlValueAccessor: Register change callback\n */\n registerOnChange(fn: (value: string) => void): void {\n this.#onChange = fn;\n }\n\n /**\n * ControlValueAccessor: Register touched callback\n */\n registerOnTouched(fn: () => void): void {\n this.#onTouched = fn;\n }\n\n /** ControlValueAccessor callbacks */\n #onChange: (value: string) => void = () => {};\n #onTouched: () => void = () => {};\n}\n","<sd-ckeditor-styles />\n<ckeditor class=\"sd-mini-editor\" [editor]=\"Editor\" [config]=\"editorConfig\" [disabled]=\"disabled()\" (ready)=\"onReady($event)\"> </ckeditor>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA;;;;;;;;;;;;;;AAcG;MAeU,YAAY,CAAA;;AAEI,IAAA,MAAM;AAEjC,IAAA,IACI,eAAe,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,MAAM,EAAE,SAAS;IAC/B;;IAGS,KAAK,GAAG,EAAE;IACV,WAAW,GAAG,MAAM,EAAU;;IAG9B,aAAa,GAAG,MAAM,EAAU;;IAGhC,IAAI,GAAG,MAAM,EAAc;;IAG3B,KAAK,GAAG,MAAM,EAAc;;AAG5B,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,+EAAC;IAEhC,MAAM,GAAG,aAAa;AACtB,IAAA,OAAO;AACP,IAAA,aAAa,GAAG,IAAI,YAAY,EAAE;AAClC,IAAA,qBAAqB,GAAG,IAAI,OAAO,EAAQ;;AAG3C,IAAA,IAAI,YAAY,GAAA;QACd,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,aAAa,IAAI,KAAK;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,KAAK,UAAU;QAC5D,MAAM,OAAO,GAAU,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;;QAG5G,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,UAAU,CAAC,kBAAkB,CAAC;AAC3C,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA,EAAA,QAAA,EAAA,+KAAA,EAAA,MAAA,EAAA,CAAA,ktCAAA,CAAA,EAAA;;sBAIA,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBAExB,WAAW;uBAAC,mCAAmC;;sBAM/C;;;AEnEH;;AAEG;;;;"}
1
+ {"version":3,"file":"sdcorejs-angular-components-mini-editor.mjs","sources":["../../../projects/sdcorejs-angular/components/mini-editor/src/mini-editor.component.ts","../../../projects/sdcorejs-angular/components/mini-editor/src/mini-editor.component.html","../../../projects/sdcorejs-angular/components/mini-editor/sdcorejs-angular-components-mini-editor.ts"],"sourcesContent":["import {\n ChangeDetectorRef,\n Component,\n HostBinding,\n Input,\n OnChanges,\n OnDestroy,\n SimpleChanges,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport {\n SdEditorEngine,\n SdEditorImportDiagnostic,\n SdEditorMentionItem,\n SdEditorSourceChangeReason,\n SdEditorSurface,\n} from '@sdcorejs/angular/components/editor-engine';\nimport { SdMiniEditorOption } from './mini-editor.model';\n\n/** Compact Core toolbar with the same document schema as SdEditor. */\n@Component({\n selector: 'sd-mini-editor',\n standalone: true,\n imports: [SdEditorSurface],\n templateUrl: './mini-editor.component.html',\n styleUrl: './mini-editor.component.scss',\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SdMiniEditor), multi: true }],\n})\nexport class SdMiniEditor implements ControlValueAccessor, OnChanges, OnDestroy {\n @Input({ required: true }) option!: SdMiniEditorOption;\n @Input() value = '';\n readonly disabled = input(false);\n readonly valueChange = output<string>();\n readonly contentChange = output<string>();\n readonly blur = output<FocusEvent>();\n readonly focus = output<FocusEvent>();\n readonly importWarning = output<readonly SdEditorImportDiagnostic[]>();\n readonly #diagnostics = signal<readonly SdEditorImportDiagnostic[]>([]);\n readonly importDiagnostics = this.#diagnostics.asReadonly();\n readonly surfaceContent = signal('');\n readonly #formDisabled = signal(false);\n readonly effectiveDisabled = computed(() => this.disabled() || this.#formDisabled());\n readonly #cdRef = inject(ChangeDetectorRef);\n #engine?: SdEditorEngine;\n #timer?: ReturnType<typeof setTimeout>;\n #trailing?: string;\n #deadline?: number;\n #composing = false;\n #formatPending = false;\n #destroyed = false;\n #onChange: (value: string) => void = () => {};\n #onTouched: () => void = () => {};\n\n @HostBinding('style.--sd-mini-editor-max-height')\n get maxEditorHeight(): string | undefined {\n return this.option?.maxHeight;\n }\n\n constructor() {\n effect(() => {\n if (this.effectiveDisabled()) this.onSourceChange();\n });\n }\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['value']) this.setContent(this.value);\n }\n onEngineReady(engine: SdEditorEngine): void {\n this.onSourceChange();\n this.#composing = false;\n this.#engine = engine;\n }\n /** Cancel a stale throttle window before replacing an authoritative source. */\n onSourceChange(reason: SdEditorSourceChangeReason = 'source'): void {\n this.#clearTimer();\n if (reason === 'format') {\n this.#formatPending = true;\n return;\n }\n this.#formatPending = false;\n this.#deadline = undefined;\n this.#trailing = undefined;\n }\n onFormatChange(value: string | undefined): void {\n if (this.#destroyed || this.effectiveDisabled()) return;\n // A refused conversion stays paused until a supported representation is\n // restored. Retain the live pending edit without exporting stale HTML.\n if (value === undefined) return;\n this.#formatPending = false;\n this.#trailing = undefined;\n if (value !== this.value) this.onSurfaceChange(value);\n if (this.#deadline !== undefined) this.#scheduleWindow();\n }\n onSurfaceChange(value: string): void {\n if (this.#destroyed || this.effectiveDisabled()) return;\n if (this.#composing || this.#formatPending) {\n this.#trailing = value;\n return;\n }\n if (this.#deadline === undefined) {\n // App callbacks can replace content synchronously; establish the window first.\n this.#startWindow();\n this.#emit(value);\n } else this.#trailing = value;\n }\n #startWindow(): void {\n this.#deadline = Date.now() + 500;\n this.#scheduleWindow();\n }\n #scheduleWindow(): void {\n if (this.#deadline === undefined || this.#composing || this.#formatPending || this.#destroyed) return;\n this.#clearTimer();\n this.#timer = setTimeout(\n () => {\n this.#timer = undefined;\n this.#deadline = undefined;\n const trailing = this.#trailing;\n this.#trailing = undefined;\n if (trailing !== undefined && !this.#destroyed && !this.#composing && !this.effectiveDisabled()) {\n this.#startWindow();\n this.#emit(trailing);\n }\n },\n Math.max(0, this.#deadline - Date.now())\n );\n }\n onCompositionChange(composing: boolean): void {\n this.#composing = composing;\n this.#clearTimer();\n if (composing || this.#formatPending || this.#destroyed || this.effectiveDisabled()) return;\n if (this.#deadline !== undefined) this.#scheduleWindow();\n else if (this.#trailing !== undefined) {\n const value = this.#trailing;\n this.#trailing = undefined;\n this.#startWindow();\n this.#emit(value);\n }\n }\n #clearTimer(): void {\n if (this.#timer !== undefined) clearTimeout(this.#timer);\n this.#timer = undefined;\n }\n #emit(value: string): void {\n this.value = value;\n this.#onChange(value);\n this.valueChange.emit(value);\n this.contentChange.emit(value);\n this.option?.onChange?.(value);\n this.#cdRef.markForCheck();\n }\n onSurfaceFocus(event: FocusEvent): void {\n this.focus.emit(event);\n this.option?.onFocus?.(event);\n }\n onSurfaceBlur(event: FocusEvent): void {\n this.#onTouched();\n this.blur.emit(event);\n this.option?.onBlur?.(event);\n this.#cdRef.markForCheck();\n }\n onDiagnostics(diagnostics: readonly SdEditorImportDiagnostic[]): void {\n this.#diagnostics.set(diagnostics);\n this.importWarning.emit(diagnostics);\n }\n onMentionSelected(item: SdEditorMentionItem): void {\n this.option?.onMentionSelect?.(item);\n }\n setContent(content: string): void {\n const value = content ?? '';\n this.value = value;\n // Consumer echoes must not replay content or reset the current selection/history.\n if (this.#isCurrentContent(value)) return;\n this.onSourceChange();\n this.surfaceContent.set(value);\n this.#engine?.setContent(value, this.option?.outputFormat ?? 'html');\n this.#cdRef.markForCheck();\n }\n #isCurrentContent(value: string): boolean {\n if (!this.#engine) return value === this.surfaceContent();\n try {\n return this.#engine.format === (this.option?.outputFormat ?? 'html') && value === this.#engine.getContent();\n } catch {\n return false;\n }\n }\n getContent(): string {\n return this.#engine?.getContent() ?? '';\n }\n getHtmlContent(): string {\n return this.#engine?.getHtml() ?? '';\n }\n focusEditor(): void {\n if (!this.effectiveDisabled()) this.#engine?.focus();\n }\n insertMention(item: { id: string; name: string; marker?: string }): void {\n if (!this.#engine || !this.option?.enableMention || this.effectiveDisabled() || this.importDiagnostics().length) return;\n const marker = item.marker ?? this.option.mentionConfig?.feeds?.[0]?.marker ?? '@';\n this.#engine.insertMention({ ...item, marker });\n this.option.onMentionSelect?.({ id: item.id, name: item.name, text: `${marker}${item.name}` });\n }\n getMentions(): { id: string; name: string; marker: string }[] {\n return this.#engine?.getMentions() ?? [];\n }\n writeValue(value: string): void {\n this.setContent(value || '');\n }\n registerOnChange(fn: (value: string) => void): void {\n this.#onChange = fn;\n }\n registerOnTouched(fn: () => void): void {\n this.#onTouched = fn;\n }\n setDisabledState(disabled: boolean): void {\n this.#formDisabled.set(disabled);\n if (disabled) this.onSourceChange();\n this.#cdRef.markForCheck();\n }\n ngOnDestroy(): void {\n this.#destroyed = true;\n this.onSourceChange();\n this.#engine = undefined; // Surface owns engine destruction.\n }\n}\n","<sd-editor-surface\n class=\"sd-mini-editor\"\n variant=\"compact\"\n [content]=\"surfaceContent()\"\n [format]=\"option?.outputFormat ?? 'html'\"\n [editable]=\"!effectiveDisabled()\"\n [placeholder]=\"option?.placeholder\"\n [disabled]=\"effectiveDisabled()\"\n [height]=\"option?.height\"\n [maxHeight]=\"option?.maxHeight\"\n [mentionFeeds]=\"option?.enableMention ? option?.mentionConfig?.feeds : undefined\"\n (engineReady)=\"onEngineReady($event)\"\n (sourceChange)=\"onSourceChange($event)\"\n (formatChange)=\"onFormatChange($event)\"\n (compositionChange)=\"onCompositionChange($event)\"\n (change)=\"onSurfaceChange($event)\"\n (focus)=\"onSurfaceFocus($event)\"\n (blur)=\"onSurfaceBlur($event)\"\n (diagnostics)=\"onDiagnostics($event)\"\n (mentionSelected)=\"onMentionSelected($event)\" />\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AA0BA;MASa,YAAY,CAAA;AACI,IAAA,MAAM;IACxB,KAAK,GAAG,EAAE;AACV,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,+EAAC;IACvB,WAAW,GAAG,MAAM,EAAU;IAC9B,aAAa,GAAG,MAAM,EAAU;IAChC,IAAI,GAAG,MAAM,EAAc;IAC3B,KAAK,GAAG,MAAM,EAAc;IAC5B,aAAa,GAAG,MAAM,EAAuC;AAC7D,IAAA,YAAY,GAAG,MAAM,CAAsC,EAAE,mFAAC;AAC9D,IAAA,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE;AAClD,IAAA,cAAc,GAAG,MAAM,CAAC,EAAE,qFAAC;AAC3B,IAAA,aAAa,GAAG,MAAM,CAAC,KAAK,oFAAC;AAC7B,IAAA,iBAAiB,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,wFAAC;AAC3E,IAAA,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC3C,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,SAAS;IACT,UAAU,GAAG,KAAK;IAClB,cAAc,GAAG,KAAK;IACtB,UAAU,GAAG,KAAK;AAClB,IAAA,SAAS,GAA4B,MAAK,EAAE,CAAC;AAC7C,IAAA,UAAU,GAAe,MAAK,EAAE,CAAC;AAEjC,IAAA,IACI,eAAe,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,MAAM,EAAE,SAAS;IAC/B;AAEA,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;YACV,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAAE,IAAI,CAAC,cAAc,EAAE;AACrD,QAAA,CAAC,CAAC;IACJ;AACA,IAAA,WAAW,CAAC,OAAsB,EA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