@acorex/components 20.2.49 → 20.2.51

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,6 +75,7 @@ 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;
@@ -196,30 +198,33 @@ class AXWysiwygContainerComponent extends classes((MXInputBaseValueComponent), M
196
198
  #effect1;
197
199
  #effect2;
198
200
  #effect3;
199
- /** @ignore */
200
- async changeHandler() {
201
+ changeHandler() {
201
202
  if (this.disabled)
202
203
  return;
203
- const value = this.wysiwyg()?.root.innerHTML;
204
- if (value === '<p><br></p>' || !value) {
205
- this.commitValue(null);
206
- if (this.isEditorClean())
207
- return;
208
- this.isEditorClean.set(true);
209
- }
210
- else {
211
- const delta = this.wysiwyg()?.getContents().ops;
212
- const { QuillDeltaToHtmlConverter } = await import('quill-delta-to-html');
213
- const converter = new QuillDeltaToHtmlConverter(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() {