matcha-components 20.237.0 → 20.239.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.
@@ -14547,8 +14547,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
14547
14547
  }]
14548
14548
  }] });
14549
14549
 
14550
- const DEFAULT_CONFIG = {
14550
+ const DEFAULT_OPTIONS = {
14551
14551
  height: '400px',
14552
+ width: '100%',
14552
14553
  showFont: true,
14553
14554
  showFormats: true,
14554
14555
  showBold: true,
@@ -14565,61 +14566,96 @@ const DEFAULT_CONFIG = {
14565
14566
  showLink: true,
14566
14567
  showImage: true,
14567
14568
  showVideo: true,
14568
- showMarkdown: false,
14569
+ showMarkdown: true,
14569
14570
  showFullScreen: true,
14570
14571
  showCodeView: true,
14572
+ addFont: [],
14571
14573
  videoX: 560,
14572
14574
  videoY: 315,
14573
14575
  imageSize: '350px',
14574
14576
  };
14575
- function buildButtonList(options) {
14576
- const groups = [['undo', 'redo']];
14577
- const formats = [
14578
- options.showFont && 'font',
14579
- options.showFormats && 'blockStyle',
14580
- ].filter(Boolean);
14581
- if (formats.length)
14582
- groups.push(formats);
14583
- const inline = [
14584
- options.showBold && 'bold',
14585
- options.showItalic && 'italic',
14586
- options.showUnderline && 'underline',
14587
- options.showStrike && 'strike',
14588
- ].filter(Boolean);
14589
- if (inline.length)
14590
- groups.push(inline);
14591
- const colors = [
14592
- options.showFontColor && 'fontColor',
14593
- options.showHiliteColor && 'backgroundColor',
14594
- ].filter(Boolean);
14595
- if (colors.length)
14596
- groups.push(colors);
14597
- const para = [
14598
- options.showInOutDent && 'outdent',
14599
- options.showInOutDent && 'indent',
14600
- options.showAlign && 'align',
14601
- options.showList && 'list',
14602
- options.showLine && 'hr',
14603
- ].filter(Boolean);
14604
- if (para.length)
14605
- groups.push(para);
14606
- const insert = [
14607
- options.showTable && 'table',
14608
- options.showLink && 'link',
14609
- options.showImage && 'image',
14610
- options.showVideo && 'video',
14611
- ].filter(Boolean);
14612
- if (insert.length)
14613
- groups.push(insert);
14614
- if (options.showMarkdown)
14615
- groups.push(['markdownView']);
14616
- const view = [
14617
- options.showFullScreen && 'fullScreen',
14618
- options.showCodeView && 'codeView',
14619
- ].filter(Boolean);
14620
- if (view.length)
14621
- groups.push(view);
14622
- return groups;
14577
+ function buildSunEditorConfig(options = {}) {
14578
+ const opts = { ...DEFAULT_OPTIONS, ...options };
14579
+ return {
14580
+ height: opts.height,
14581
+ width: opts.width,
14582
+ buttonList: _buildButtonList(opts),
14583
+ imageWidth: opts.imageSize,
14584
+ videoWidth: opts.videoX,
14585
+ videoHeight: opts.videoY,
14586
+ font: opts.addFont?.length ? opts.addFont.map(f => f.value) : undefined,
14587
+ defaultStyle: 'font-family: Arial, sans-serif; font-size: 16px;',
14588
+ };
14589
+ }
14590
+ function _buildButtonList(opts) {
14591
+ // Desktop toolbar — mirrors suneditor.html reference exactly
14592
+ const desktop = [['undo', 'redo']];
14593
+ if (opts.showFormats || opts.showFont) {
14594
+ desktop.push('|', ['blockStyle', 'font', 'fontSize']);
14595
+ }
14596
+ if (opts.showBold || opts.showItalic || opts.showUnderline || opts.showStrike) {
14597
+ desktop.push('|', ['bold', 'italic', 'underline', 'strike']);
14598
+ }
14599
+ if (opts.showFontColor || opts.showHiliteColor) {
14600
+ desktop.push('|', ['fontColor', 'backgroundColor']);
14601
+ }
14602
+ desktop.push('|', ['removeFormat'], '/');
14603
+ if (opts.showInOutDent || opts.showAlign || opts.showList) {
14604
+ desktop.push(['outdent', 'indent', 'align', 'list']);
14605
+ }
14606
+ if (opts.showTable || opts.showLink || opts.showImage || opts.showVideo) {
14607
+ desktop.push('|', ['table', 'link', 'image', 'video']);
14608
+ }
14609
+ const viewBtns = [
14610
+ ...(opts.showFullScreen ? ['fullScreen'] : []),
14611
+ ...(opts.showCodeView ? ['codeView'] : []),
14612
+ ...(opts.showMarkdown ? ['markdownView'] : []),
14613
+ ];
14614
+ if (viewBtns.length)
14615
+ desktop.push('|', viewBtns);
14616
+ // Responsive breakpoints — mirrors suneditor.html reference exactly
14617
+ return [
14618
+ ...desktop,
14619
+ ['%992', [
14620
+ ['undo', 'redo'],
14621
+ '|',
14622
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize'],
14623
+ ['bold', 'italic', 'underline', 'strike'],
14624
+ '|',
14625
+ ['fontColor', 'backgroundColor'],
14626
+ '|',
14627
+ ['removeFormat'],
14628
+ '|',
14629
+ ['outdent', 'indent', 'align', 'list'],
14630
+ '|',
14631
+ ['table', 'link', 'image', 'video'],
14632
+ '|',
14633
+ ['fullScreen', 'codeView', 'markdownView'],
14634
+ ]],
14635
+ ['%768', [
14636
+ ['undo', 'redo'],
14637
+ '|',
14638
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize', '|', 'removeFormat'],
14639
+ ['bold', 'italic', 'underline', 'strike'],
14640
+ '|',
14641
+ ['fontColor', 'backgroundColor'],
14642
+ ['outdent', 'indent', 'align', 'list'],
14643
+ '|',
14644
+ [':Insert-default.more_plus', 'table', 'link', 'image', 'video'],
14645
+ '|',
14646
+ ['fullScreen', 'codeView', 'markdownView'],
14647
+ ]],
14648
+ ['%576', [
14649
+ ['undo', 'redo'],
14650
+ '|',
14651
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize'],
14652
+ [':Text-default.more_text', 'bold', 'italic', 'underline', 'strike', '|', 'fontColor', 'backgroundColor', '|', 'removeFormat'],
14653
+ ['outdent', 'indent', 'align', 'list'],
14654
+ '|',
14655
+ [':Insert-default.more_plus', 'table', 'link', 'image', 'video'],
14656
+ ['-right', 'fullScreen', 'codeView', 'markdownView'],
14657
+ ]],
14658
+ ];
14623
14659
  }
14624
14660
 
14625
14661
  class MatchaSkeletonComponent {
@@ -14718,7 +14754,7 @@ class MatchaTextEditorComponent {
14718
14754
  this._el = _el;
14719
14755
  this.editorId = `matcha-text-editor-${Math.random().toString(36).substring(2, 11)}`;
14720
14756
  this.isLoading = true;
14721
- this._config = { ...DEFAULT_CONFIG };
14757
+ this._config = {};
14722
14758
  this.contentChange = new EventEmitter();
14723
14759
  this._editor = null;
14724
14760
  this._pendingValue = '';
@@ -14734,11 +14770,12 @@ class MatchaTextEditorComponent {
14734
14770
  this._initEditor();
14735
14771
  }
14736
14772
  catch (error) {
14737
- console.error('[TextEditor] Erro ao inicializar o SunEditor:', error);
14773
+ console.error('[matcha-text-editor] Falha ao inicializar o SunEditor:', error);
14738
14774
  }
14739
14775
  });
14740
14776
  }
14741
14777
  ngOnDestroy() {
14778
+ this._editor?.destroy();
14742
14779
  this._editor = null;
14743
14780
  }
14744
14781
  // ControlValueAccessor
@@ -14746,7 +14783,7 @@ class MatchaTextEditorComponent {
14746
14783
  const v = value || '';
14747
14784
  this._isSettingValue = true;
14748
14785
  if (this._editor) {
14749
- this._editor.$.html.set(v);
14786
+ this._editor.html.set(v);
14750
14787
  }
14751
14788
  else {
14752
14789
  this._pendingValue = v;
@@ -14761,17 +14798,9 @@ class MatchaTextEditorComponent {
14761
14798
  }
14762
14799
  setDisabledState(isDisabled) {
14763
14800
  this._disabled = isDisabled;
14764
- if (this._editor) {
14765
- const wysiwyg = this._editor.$.frameContext.get('wysiwyg');
14766
- if (isDisabled) {
14767
- this._editor.$.toolbar.disable();
14768
- wysiwyg?.setAttribute('contenteditable', 'false');
14769
- }
14770
- else {
14771
- this._editor.$.toolbar.enable();
14772
- wysiwyg?.setAttribute('contenteditable', 'true');
14773
- }
14774
- }
14801
+ if (!this._editor)
14802
+ return;
14803
+ isDisabled ? this._editor.toolbar.disable() : this._editor.toolbar.enable();
14775
14804
  }
14776
14805
  // Private
14777
14806
  _injectScript(id, url) {
@@ -14791,7 +14820,7 @@ class MatchaTextEditorComponent {
14791
14820
  script.id = id;
14792
14821
  script.src = url;
14793
14822
  script.onload = () => { script.setAttribute('data-loaded', 'true'); resolve(); };
14794
- script.onerror = () => { console.warn(`[TextEditor] Falha ao carregar: ${id}`); resolve(); };
14823
+ script.onerror = () => { console.warn(`[matcha-text-editor] Falha ao carregar: ${id}`); resolve(); };
14795
14824
  document.head.appendChild(script);
14796
14825
  });
14797
14826
  }
@@ -14811,39 +14840,48 @@ class MatchaTextEditorComponent {
14811
14840
  });
14812
14841
  }
14813
14842
  async _loadAssets() {
14814
- await this._injectStyle('suneditor-css', `${CDN_BASE}/css/suneditor.min.css`);
14843
+ // CSS loads in parallel
14844
+ await Promise.all([
14845
+ this._injectStyle('suneditor-css', `${CDN_BASE}/css/suneditor.min.css`),
14846
+ this._injectStyle('codemirror-css', `${CDN_BASE}/css/codemirror.min.css`),
14847
+ ]);
14848
+ // JS loads sequentially — order matters
14849
+ await this._injectScript('codemirror-js', `${CDN_BASE}/js/codemirror.min.js`);
14850
+ await this._injectScript('codemirror-xml', `${CDN_BASE}/js/xml.min.js`);
14851
+ await this._injectScript('codemirror-css-mode', `${CDN_BASE}/js/css.js`);
14852
+ await this._injectScript('codemirror-js-mode', `${CDN_BASE}/js/javascript.js`);
14853
+ await this._injectScript('codemirror-htmlmixed', `${CDN_BASE}/js/htmlmixed.js`);
14815
14854
  await this._injectScript('suneditor-js', `${CDN_BASE}/js/suneditor.min.js`);
14855
+ await this._injectScript('suneditor-lang-ptbr', `${CDN_BASE}/langs/pt-br.js`);
14816
14856
  }
14817
14857
  _reloadEditor() {
14818
- this._el.nativeElement.querySelectorAll('.sun-editor').forEach((el) => el.remove());
14819
- const content = this._editor?.$.html.get() ?? '';
14858
+ const content = this._editor?.html.get() ?? '';
14859
+ this._editor?.destroy();
14820
14860
  this._editor = null;
14821
14861
  this._pendingValue = content;
14822
14862
  this.isLoading = true;
14823
14863
  this._cdr.detectChanges();
14824
- this._ngZone.runOutsideAngular(() => {
14825
- this._initEditor();
14826
- });
14864
+ this._ngZone.runOutsideAngular(() => this._initEditor());
14827
14865
  }
14828
14866
  _initEditor() {
14829
14867
  const SUNEDITOR = window.SUNEDITOR;
14830
14868
  if (!SUNEDITOR) {
14831
- console.error('[TextEditor] SUNEDITOR global não encontrado após injeção!');
14869
+ console.error('[matcha-text-editor] SUNEDITOR global não encontrado após injeção.');
14832
14870
  return;
14833
14871
  }
14834
- if (!document.getElementById(this.editorId)) {
14872
+ const textarea = document.getElementById(this.editorId);
14873
+ if (!textarea) {
14835
14874
  requestAnimationFrame(() => this._ngZone.runOutsideAngular(() => this._initEditor()));
14836
14875
  return;
14837
14876
  }
14838
- const mergedConfig = { ...DEFAULT_CONFIG, ...this._config };
14839
- this._editor = SUNEDITOR.create(`#${this.editorId}`, {
14877
+ this._editor = SUNEDITOR.create(textarea, {
14840
14878
  plugins: SUNEDITOR.plugins,
14841
- buttonList: buildButtonList(mergedConfig),
14842
- height: mergedConfig.height || '400px',
14843
- width: mergedConfig.width,
14844
- imageWidth: mergedConfig.imageSize,
14845
- videoWidth: mergedConfig.videoX,
14846
- videoHeight: mergedConfig.videoY,
14879
+ lang: window.SUNEDITOR_LANG?.pt_br,
14880
+ externalLibs: {
14881
+ codeMirror: { src: window.CodeMirror },
14882
+ },
14883
+ toolbar_sticky: 0,
14884
+ ...buildSunEditorConfig(this._config),
14847
14885
  events: {
14848
14886
  onChange: ({ data }) => {
14849
14887
  if (this._isSettingValue)
@@ -14853,24 +14891,19 @@ class MatchaTextEditorComponent {
14853
14891
  this.contentChange.emit(data);
14854
14892
  });
14855
14893
  },
14856
- onBlur: () => {
14857
- this._ngZone.run(() => this._onTouched());
14858
- },
14894
+ onBlur: () => this._ngZone.run(() => this._onTouched()),
14859
14895
  },
14860
14896
  });
14861
14897
  if (this._disabled) {
14862
- const wysiwyg = this._editor.$.frameContext.get('wysiwyg');
14863
- this._editor.$.toolbar.disable();
14864
- wysiwyg?.setAttribute('contenteditable', 'false');
14898
+ this._editor.toolbar.disable();
14865
14899
  }
14866
- // Hide immediately so the skeleton doesn't overlap the editor during initialization
14867
14900
  const sunEditorEl = this._el.nativeElement.querySelector('.sun-editor');
14868
14901
  if (sunEditorEl)
14869
14902
  sunEditorEl.style.display = 'none';
14870
14903
  setTimeout(() => {
14871
14904
  if (this._pendingValue) {
14872
14905
  this._isSettingValue = true;
14873
- this._editor.$.html.set(this._pendingValue);
14906
+ this._editor.html.set(this._pendingValue);
14874
14907
  this._pendingValue = '';
14875
14908
  setTimeout(() => { this._isSettingValue = false; }, 0);
14876
14909
  }
@@ -15758,5 +15791,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
15758
15791
  * Generated bundle index. Do not edit.
15759
15792
  */
15760
15793
 
15761
- export { CopyButtonComponent, DEFAULT_CONFIG, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipComponent, MatchaChipListComponent, MatchaChipModule, MatchaComponentsModule, MatchaDateComponent, MatchaDateModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaListComponent, MatchaListItemComponent, MatchaListModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuItemDirective, MatchaMenuModule, MatchaMenuTriggerDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaMsgBoxActionsComponent, MatchaMsgBoxComponent, MatchaMsgBoxModule, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaProgressBarComponent, MatchaProgressBarModule, MatchaRadioComponent, MatchaRadioGroupComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSnackBarComponent, MatchaSnackBarModule, MatchaSnackBarService, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaSubmenuTriggerDirective, MatchaTabItemComponent, MatchaTableComponent, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTextEditorComponent, MatchaTextEditorModule, MatchaTimeComponent, MatchaTimeModule, MatchaTimeRangeComponent, MatchaTimeRangeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, buildButtonList, compatibleOptions, initialConfig, timeMasks, withoutValidation };
15794
+ export { CopyButtonComponent, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipComponent, MatchaChipListComponent, MatchaChipModule, MatchaComponentsModule, MatchaDateComponent, MatchaDateModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaListComponent, MatchaListItemComponent, MatchaListModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuItemDirective, MatchaMenuModule, MatchaMenuTriggerDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaMsgBoxActionsComponent, MatchaMsgBoxComponent, MatchaMsgBoxModule, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaProgressBarComponent, MatchaProgressBarModule, MatchaRadioComponent, MatchaRadioGroupComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSnackBarComponent, MatchaSnackBarModule, MatchaSnackBarService, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaSubmenuTriggerDirective, MatchaTabItemComponent, MatchaTableComponent, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTextEditorComponent, MatchaTextEditorModule, MatchaTimeComponent, MatchaTimeModule, MatchaTimeRangeComponent, MatchaTimeRangeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, buildSunEditorConfig, compatibleOptions, initialConfig, timeMasks, withoutValidation };
15762
15795
  //# sourceMappingURL=matcha-components.mjs.map