matcha-components 20.267.0 → 20.269.0

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.
@@ -15616,14 +15616,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
15616
15616
  class MatchaPageBuilderComponent {
15617
15617
  set text(value) {
15618
15618
  this._text = value;
15619
- if (this.isEditorInitialized && this.editor && value) {
15620
- this.editor.setComponents(value);
15619
+ if (this.isEditorInitialized && this.editor) {
15620
+ if (value) {
15621
+ this.editor.setComponents(value);
15622
+ }
15623
+ else {
15624
+ this.editor.runCommand('core:canvas-clear');
15625
+ }
15621
15626
  }
15622
15627
  }
15623
15628
  constructor(ngZone) {
15624
15629
  this.ngZone = ngZone;
15625
- this.showControls = true;
15630
+ this.showControls = false;
15626
15631
  this.onSave = new EventEmitter();
15632
+ this.onChange = new EventEmitter();
15633
+ this._changeDebounceTimer = null;
15627
15634
  this.containerId = 'gjs-' + Math.random().toString(36).substring(2, 9);
15628
15635
  this.isLoading = true;
15629
15636
  this._text = '';
@@ -15734,7 +15741,8 @@ class MatchaPageBuilderComponent {
15734
15741
  this.editor = grapesjs.init({
15735
15742
  height: '100%',
15736
15743
  container: `#${this.containerId}`,
15737
- fromElement: true, // Changed from false to true
15744
+ fromElement: true,
15745
+ storageManager: false,
15738
15746
  showOffsets: true,
15739
15747
  assetManager: {
15740
15748
  embedAsBase64: true,
@@ -16113,7 +16121,20 @@ class MatchaPageBuilderComponent {
16113
16121
  if (this._text) {
16114
16122
  this.editor.setComponents(this._text);
16115
16123
  }
16124
+ else {
16125
+ this.editor.runCommand('core:canvas-clear');
16126
+ }
16116
16127
  this.ngZone.run(() => { this.isLoading = false; });
16128
+ editor.on('update', () => {
16129
+ clearTimeout(this._changeDebounceTimer);
16130
+ this._changeDebounceTimer = setTimeout(() => {
16131
+ const html = editor.getHtml();
16132
+ const css = editor.getCss();
16133
+ this.ngZone.run(() => {
16134
+ this.onChange.emit(`<style>${css}</style>${html}`);
16135
+ });
16136
+ }, 300);
16137
+ });
16117
16138
  });
16118
16139
  // Se o evento 'load' demorar, podemos tentar setar os componentes se já estiver inicializado
16119
16140
  if (this.editor && !this.isEditorInitialized && this._text) {
@@ -16134,16 +16155,17 @@ class MatchaPageBuilderComponent {
16134
16155
  this.onSave.emit(combinedOutput);
16135
16156
  }
16136
16157
  ngOnDestroy() {
16158
+ clearTimeout(this._changeDebounceTimer);
16137
16159
  if (this.editor) {
16138
16160
  this.editor.destroy();
16139
16161
  }
16140
16162
  }
16141
16163
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
16142
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: MatchaPageBuilderComponent, isStandalone: false, selector: "matcha-page-builder", inputs: { showControls: "showControls", text: "text" }, outputs: { onSave: "onSave" }, viewQueries: [{ propertyName: "gjsContainer", first: true, predicate: ["gjsContainer"], descendants: true }], ngImport: i0, template: "<div class=\"matcha-page-builder\">\n <matcha-spinner *ngIf=\"isLoading\"></matcha-spinner>\n <div class=\"editor-shell\" [style.display]=\"isLoading ? 'none' : 'block'\">\n <div [id]=\"containerId\"></div>\n </div>\n <div class=\"editor-controls\" *ngIf=\"showControls && !isLoading\">\n <button matcha-button (click)=\"save()\">Salvar</button>\n </div>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatchaButtonComponent, selector: "[matcha-button]", inputs: ["size", "size-xs", "size-sm", "size-md", "size-lg", "size-xl", "gap", "color", "basic", "outline", "alpha", "pill", "link", "icon", "badge"] }, { kind: "component", type: MatchaSpinnerComponent, selector: "matcha-spinner", inputs: ["progress", "color", "size", "size-xs", "size-sm", "size-md", "size-lg", "size-xl"] }], encapsulation: i0.ViewEncapsulation.None }); }
16164
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: MatchaPageBuilderComponent, isStandalone: false, selector: "matcha-page-builder", inputs: { showControls: "showControls", text: "text" }, outputs: { onSave: "onSave", onChange: "onChange" }, viewQueries: [{ propertyName: "gjsContainer", first: true, predicate: ["gjsContainer"], descendants: true }], ngImport: i0, template: "<div class=\"matcha-page-builder\">\n <matcha-skeleton *ngIf=\"isLoading\" height=\"600\" [amount]=\"1\" model=\"empty\"></matcha-skeleton>\n <div class=\"editor-shell\" [style.display]=\"isLoading ? 'none' : 'block'\">\n <div [id]=\"containerId\"></div>\n </div>\n <div class=\"editor-controls\" *ngIf=\"showControls && !isLoading\">\n <button matcha-button (click)=\"save()\">Salvar</button>\n </div>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatchaButtonComponent, selector: "[matcha-button]", inputs: ["size", "size-xs", "size-sm", "size-md", "size-lg", "size-xl", "gap", "color", "basic", "outline", "alpha", "pill", "link", "icon", "badge"] }, { kind: "component", type: MatchaSkeletonComponent, selector: "matcha-skeleton", inputs: ["amount", "grid", "height", "model", "gap"] }], encapsulation: i0.ViewEncapsulation.None }); }
16143
16165
  }
16144
16166
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderComponent, decorators: [{
16145
16167
  type: Component,
16146
- args: [{ selector: 'matcha-page-builder', encapsulation: ViewEncapsulation.None, standalone: false, template: "<div class=\"matcha-page-builder\">\n <matcha-spinner *ngIf=\"isLoading\"></matcha-spinner>\n <div class=\"editor-shell\" [style.display]=\"isLoading ? 'none' : 'block'\">\n <div [id]=\"containerId\"></div>\n </div>\n <div class=\"editor-controls\" *ngIf=\"showControls && !isLoading\">\n <button matcha-button (click)=\"save()\">Salvar</button>\n </div>\n</div>" }]
16168
+ args: [{ selector: 'matcha-page-builder', encapsulation: ViewEncapsulation.None, standalone: false, template: "<div class=\"matcha-page-builder\">\n <matcha-skeleton *ngIf=\"isLoading\" height=\"600\" [amount]=\"1\" model=\"empty\"></matcha-skeleton>\n <div class=\"editor-shell\" [style.display]=\"isLoading ? 'none' : 'block'\">\n <div [id]=\"containerId\"></div>\n </div>\n <div class=\"editor-controls\" *ngIf=\"showControls && !isLoading\">\n <button matcha-button (click)=\"save()\">Salvar</button>\n </div>\n</div>" }]
16147
16169
  }], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { gjsContainer: [{
16148
16170
  type: ViewChild,
16149
16171
  args: ['gjsContainer', { static: false }]
@@ -16151,6 +16173,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
16151
16173
  type: Input
16152
16174
  }], onSave: [{
16153
16175
  type: Output
16176
+ }], onChange: [{
16177
+ type: Output
16154
16178
  }], text: [{
16155
16179
  type: Input
16156
16180
  }] } });
@@ -16159,10 +16183,10 @@ class MatchaPageBuilderModule {
16159
16183
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
16160
16184
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderModule, declarations: [MatchaPageBuilderComponent], imports: [CommonModule,
16161
16185
  MatchaButtonModule,
16162
- MatchaSpinnerModule], exports: [MatchaPageBuilderComponent] }); }
16186
+ MatchaSkeletonModule], exports: [MatchaPageBuilderComponent] }); }
16163
16187
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderModule, imports: [CommonModule,
16164
16188
  MatchaButtonModule,
16165
- MatchaSpinnerModule] }); }
16189
+ MatchaSkeletonModule] }); }
16166
16190
  }
16167
16191
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MatchaPageBuilderModule, decorators: [{
16168
16192
  type: NgModule,
@@ -16171,7 +16195,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
16171
16195
  imports: [
16172
16196
  CommonModule,
16173
16197
  MatchaButtonModule,
16174
- MatchaSpinnerModule,
16198
+ MatchaSkeletonModule,
16175
16199
  ],
16176
16200
  exports: [MatchaPageBuilderComponent]
16177
16201
  }]