@acorex/components 21.0.0-next.42 → 21.0.0-next.44

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.
@@ -4,6 +4,7 @@ import * as i0 from '@angular/core';
4
4
  import { viewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, signal, Injectable, input, inject, contentChild, PLATFORM_ID, afterNextRender, effect, forwardRef, HostBinding, NgModule } from '@angular/core';
5
5
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
6
6
  import { classes } from 'polytype';
7
+ import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html';
7
8
  import { AXDecoratorColorIndicatorComponent, AXDecoratorModule } from '@acorex/components/decorators';
8
9
  import { AXButtonModule } from '@acorex/components/button';
9
10
  import { AXColorPaletteModule } from '@acorex/components/color-palette';
@@ -74,12 +75,12 @@ class AXWysiwygContainerComponent extends classes((MXInputBaseValueComponent), M
74
75
  this.container = contentChild(AXWysiwygViewComponent, ...(ngDevMode ? [{ debugName: "container" }] : []));
75
76
  this.toolbar = contentChild(AXWysiwygToolbarComponent, ...(ngDevMode ? [{ debugName: "toolbar" }] : []));
76
77
  this.platformId = inject(PLATFORM_ID);
78
+ this.changeHandlerTimer = null;
77
79
  this.#init = afterNextRender(async () => {
78
80
  if (!isPlatformBrowser(this.platformId))
79
81
  return;
80
82
  const Quill = (await import('quill')).default;
81
83
  const icons = Quill.import('ui/icons');
82
- this.quillConvertor = (await import('quill-delta-to-html')).QuillDeltaToHtmlConverter;
83
84
  icons['bold'] = '<ax-icon class="ax-icon ax-icon-bold"></ax-icon>';
84
85
  icons['italic'] = '<ax-icon class="ax-icon ax-icon-italic"></ax-icon>';
85
86
  icons['underline'] = '<ax-icon class="ax-icon ax-icon-under-line"></ax-icon>';
@@ -197,29 +198,33 @@ class AXWysiwygContainerComponent extends classes((MXInputBaseValueComponent), M
197
198
  #effect1;
198
199
  #effect2;
199
200
  #effect3;
200
- /** @ignore */
201
- async changeHandler() {
201
+ changeHandler() {
202
202
  if (this.disabled)
203
203
  return;
204
- const value = this.wysiwyg()?.root.innerHTML;
205
- if (value === '<p><br></p>' || !value) {
206
- this.commitValue(null);
207
- if (this.isEditorClean())
208
- return;
209
- this.isEditorClean.set(true);
210
- }
211
- else {
212
- const delta = this.wysiwyg()?.getContents().ops;
213
- const converter = new this.quillConvertor(delta, {
214
- inlineStyles: true,
215
- allowBackgroundClasses: true,
216
- });
217
- const html = converter.convert();
218
- this.commitValue(html, true);
219
- if (!this.isEditorClean())
220
- return;
221
- this.isEditorClean.set(false);
204
+ if (this.changeHandlerTimer) {
205
+ clearTimeout(this.changeHandlerTimer);
222
206
  }
207
+ this.changeHandlerTimer = setTimeout(() => {
208
+ const value = this.wysiwyg()?.root.innerHTML;
209
+ if (value === '<p><br></p>' || !value) {
210
+ this.commitValue(null);
211
+ if (this.isEditorClean())
212
+ return;
213
+ this.isEditorClean.set(true);
214
+ }
215
+ else {
216
+ const delta = this.wysiwyg()?.getContents().ops;
217
+ const converter = new QuillDeltaToHtmlConverter(delta, {
218
+ inlineStyles: true,
219
+ allowBackgroundClasses: true,
220
+ });
221
+ const html = converter.convert();
222
+ this.commitValue(html, true);
223
+ if (!this.isEditorClean())
224
+ return;
225
+ this.isEditorClean.set(false);
226
+ }
227
+ }, 300);
223
228
  }
224
229
  /** @ignore */
225
230
  ngOnDestroy() {