matcha-components 20.236.0 → 20.238.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,
@@ -14568,58 +14569,91 @@ const DEFAULT_CONFIG = {
14568
14569
  showMarkdown: false,
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
+ };
14588
+ }
14589
+ function _buildButtonList(opts) {
14590
+ // Desktop toolbar — mirrors suneditor.html reference exactly
14591
+ const desktop = [['undo', 'redo']];
14592
+ if (opts.showFormats || opts.showFont) {
14593
+ desktop.push('|', ['blockStyle', 'font', 'fontSize']);
14594
+ }
14595
+ if (opts.showBold || opts.showItalic || opts.showUnderline || opts.showStrike) {
14596
+ desktop.push('|', ['bold', 'italic', 'underline', 'strike']);
14597
+ }
14598
+ if (opts.showFontColor || opts.showHiliteColor) {
14599
+ desktop.push('|', ['fontColor', 'backgroundColor']);
14600
+ }
14601
+ desktop.push('|', ['removeFormat'], '/');
14602
+ if (opts.showInOutDent || opts.showAlign || opts.showList) {
14603
+ desktop.push(['outdent', 'indent', 'align', 'list']);
14604
+ }
14605
+ if (opts.showTable || opts.showLink || opts.showImage || opts.showVideo) {
14606
+ desktop.push('|', ['table', 'link', 'image', 'video']);
14607
+ }
14608
+ const viewBtns = [
14609
+ ...(opts.showFullScreen ? ['fullScreen'] : []),
14610
+ ...(opts.showCodeView ? ['codeView'] : []),
14611
+ ];
14612
+ if (viewBtns.length)
14613
+ desktop.push('|', viewBtns);
14614
+ // Responsive breakpoints — mirrors suneditor.html reference exactly
14615
+ return [
14616
+ ...desktop,
14617
+ ['%992', [
14618
+ ['undo', 'redo'],
14619
+ '|',
14620
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize'],
14621
+ ['bold', 'italic', 'underline', 'strike'],
14622
+ '|',
14623
+ ['fontColor', 'backgroundColor'],
14624
+ '|',
14625
+ ['removeFormat'],
14626
+ '|',
14627
+ ['outdent', 'indent', 'align', 'list'],
14628
+ '|',
14629
+ ['table', 'link', 'image', 'video'],
14630
+ '|',
14631
+ ['fullScreen', 'codeView'],
14632
+ ]],
14633
+ ['%768', [
14634
+ ['undo', 'redo'],
14635
+ '|',
14636
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize', '|', 'removeFormat'],
14637
+ ['bold', 'italic', 'underline', 'strike'],
14638
+ '|',
14639
+ ['fontColor', 'backgroundColor'],
14640
+ ['outdent', 'indent', 'align', 'list'],
14641
+ '|',
14642
+ [':Insert-default.more_plus', 'table', 'link', 'image', 'video'],
14643
+ '|',
14644
+ ['fullScreen', 'codeView'],
14645
+ ]],
14646
+ ['%576', [
14647
+ ['undo', 'redo'],
14648
+ '|',
14649
+ [':Format-default.more_paragraph', 'blockStyle', 'font', 'fontSize'],
14650
+ [':Text-default.more_text', 'bold', 'italic', 'underline', 'strike', '|', 'fontColor', 'backgroundColor', '|', 'removeFormat'],
14651
+ ['outdent', 'indent', 'align', 'list'],
14652
+ '|',
14653
+ [':Insert-default.more_plus', 'table', 'link', 'image', 'video'],
14654
+ ['-right', 'fullScreen', 'codeView'],
14655
+ ]],
14656
+ ];
14623
14657
  }
14624
14658
 
14625
14659
  class MatchaSkeletonComponent {
@@ -14718,7 +14752,7 @@ class MatchaTextEditorComponent {
14718
14752
  this._el = _el;
14719
14753
  this.editorId = `matcha-text-editor-${Math.random().toString(36).substring(2, 11)}`;
14720
14754
  this.isLoading = true;
14721
- this._config = { ...DEFAULT_CONFIG };
14755
+ this._config = {};
14722
14756
  this.contentChange = new EventEmitter();
14723
14757
  this._editor = null;
14724
14758
  this._pendingValue = '';
@@ -14734,11 +14768,12 @@ class MatchaTextEditorComponent {
14734
14768
  this._initEditor();
14735
14769
  }
14736
14770
  catch (error) {
14737
- console.error('[TextEditor] Erro ao inicializar o SunEditor:', error);
14771
+ console.error('[matcha-text-editor] Falha ao inicializar o SunEditor:', error);
14738
14772
  }
14739
14773
  });
14740
14774
  }
14741
14775
  ngOnDestroy() {
14776
+ this._editor?.destroy();
14742
14777
  this._editor = null;
14743
14778
  }
14744
14779
  // ControlValueAccessor
@@ -14746,7 +14781,7 @@ class MatchaTextEditorComponent {
14746
14781
  const v = value || '';
14747
14782
  this._isSettingValue = true;
14748
14783
  if (this._editor) {
14749
- this._editor.setContent(v);
14784
+ this._editor.setContents(v);
14750
14785
  }
14751
14786
  else {
14752
14787
  this._pendingValue = v;
@@ -14761,9 +14796,9 @@ class MatchaTextEditorComponent {
14761
14796
  }
14762
14797
  setDisabledState(isDisabled) {
14763
14798
  this._disabled = isDisabled;
14764
- if (this._editor) {
14765
- isDisabled ? this._editor.disable() : this._editor.enable();
14766
- }
14799
+ if (!this._editor)
14800
+ return;
14801
+ isDisabled ? this._editor.disabled() : this._editor.enabled();
14767
14802
  }
14768
14803
  // Private
14769
14804
  _injectScript(id, url) {
@@ -14783,7 +14818,7 @@ class MatchaTextEditorComponent {
14783
14818
  script.id = id;
14784
14819
  script.src = url;
14785
14820
  script.onload = () => { script.setAttribute('data-loaded', 'true'); resolve(); };
14786
- script.onerror = () => { console.warn(`[TextEditor] Falha ao carregar: ${id}`); resolve(); };
14821
+ script.onerror = () => { console.warn(`[matcha-text-editor] Falha ao carregar: ${id}`); resolve(); };
14787
14822
  document.head.appendChild(script);
14788
14823
  });
14789
14824
  }
@@ -14803,62 +14838,70 @@ class MatchaTextEditorComponent {
14803
14838
  });
14804
14839
  }
14805
14840
  async _loadAssets() {
14806
- await this._injectStyle('suneditor-css', `${CDN_BASE}/css/suneditor.min.css`);
14841
+ // CSS loads in parallel
14842
+ await Promise.all([
14843
+ this._injectStyle('suneditor-css', `${CDN_BASE}/css/suneditor.min.css`),
14844
+ this._injectStyle('codemirror-css', `${CDN_BASE}/css/codemirror.min.css`),
14845
+ ]);
14846
+ // JS loads sequentially — order matters
14847
+ await this._injectScript('codemirror-js', `${CDN_BASE}/js/codemirror.min.js`);
14848
+ await this._injectScript('codemirror-xml', `${CDN_BASE}/js/xml.min.js`);
14849
+ await this._injectScript('codemirror-css-mode', `${CDN_BASE}/js/css.js`);
14850
+ await this._injectScript('codemirror-js-mode', `${CDN_BASE}/js/javascript.js`);
14851
+ await this._injectScript('codemirror-htmlmixed', `${CDN_BASE}/js/htmlmixed.js`);
14807
14852
  await this._injectScript('suneditor-js', `${CDN_BASE}/js/suneditor.min.js`);
14853
+ await this._injectScript('suneditor-lang-ptbr', `${CDN_BASE}/langs/pt-br.js`);
14808
14854
  }
14809
14855
  _reloadEditor() {
14810
- this._el.nativeElement.querySelectorAll('.sun-editor').forEach((el) => el.remove());
14811
- const content = this._editor?.getValue() ?? '';
14856
+ const content = this._editor?.getContents() ?? '';
14857
+ this._editor?.destroy();
14812
14858
  this._editor = null;
14813
14859
  this._pendingValue = content;
14814
14860
  this.isLoading = true;
14815
14861
  this._cdr.detectChanges();
14816
- this._ngZone.runOutsideAngular(() => {
14817
- this._initEditor();
14818
- });
14862
+ this._ngZone.runOutsideAngular(() => this._initEditor());
14819
14863
  }
14820
14864
  _initEditor() {
14821
14865
  const SUNEDITOR = window.SUNEDITOR;
14822
14866
  if (!SUNEDITOR) {
14823
- console.error('[TextEditor] SUNEDITOR global não encontrado após injeção!');
14867
+ console.error('[matcha-text-editor] SUNEDITOR global não encontrado após injeção.');
14824
14868
  return;
14825
14869
  }
14826
- if (!document.getElementById(this.editorId)) {
14870
+ const textarea = document.getElementById(this.editorId);
14871
+ if (!textarea) {
14827
14872
  requestAnimationFrame(() => this._ngZone.runOutsideAngular(() => this._initEditor()));
14828
14873
  return;
14829
14874
  }
14830
- const mergedConfig = { ...DEFAULT_CONFIG, ...this._config };
14831
- this._editor = SUNEDITOR.create(`#${this.editorId}`, {
14875
+ this._editor = SUNEDITOR.create(textarea, {
14832
14876
  plugins: SUNEDITOR.plugins,
14833
- buttonList: buildButtonList(mergedConfig),
14834
- height: mergedConfig.height || '400px',
14835
- width: mergedConfig.width,
14836
- imageWidth: mergedConfig.imageSize,
14837
- videoWidth: mergedConfig.videoX,
14838
- videoHeight: mergedConfig.videoY,
14877
+ lang: window.SUNEDITOR_LANG?.pt_br,
14878
+ externalLibs: {
14879
+ codeMirror: { src: window.CodeMirror },
14880
+ },
14881
+ toolbar_sticky: 0,
14882
+ ...buildSunEditorConfig(this._config),
14883
+ events: {
14884
+ onChange: ({ data }) => {
14885
+ if (this._isSettingValue)
14886
+ return;
14887
+ this._ngZone.run(() => {
14888
+ this._onChange(data);
14889
+ this.contentChange.emit(data);
14890
+ });
14891
+ },
14892
+ onBlur: () => this._ngZone.run(() => this._onTouched()),
14893
+ },
14839
14894
  });
14840
14895
  if (this._disabled) {
14841
- this._editor.disable();
14896
+ this._editor.disabled();
14842
14897
  }
14843
- // Hide immediately so the skeleton doesn't overlap the editor during initialization
14844
14898
  const sunEditorEl = this._el.nativeElement.querySelector('.sun-editor');
14845
14899
  if (sunEditorEl)
14846
14900
  sunEditorEl.style.display = 'none';
14847
- this._editor.on('onChange', (content) => {
14848
- if (this._isSettingValue)
14849
- return;
14850
- this._ngZone.run(() => {
14851
- this._onChange(content);
14852
- this.contentChange.emit(content);
14853
- });
14854
- });
14855
- this._editor.on('onBlur', () => {
14856
- this._ngZone.run(() => this._onTouched());
14857
- });
14858
14901
  setTimeout(() => {
14859
14902
  if (this._pendingValue) {
14860
14903
  this._isSettingValue = true;
14861
- this._editor.setContent(this._pendingValue);
14904
+ this._editor.setContents(this._pendingValue);
14862
14905
  this._pendingValue = '';
14863
14906
  setTimeout(() => { this._isSettingValue = false; }, 0);
14864
14907
  }
@@ -15746,5 +15789,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
15746
15789
  * Generated bundle index. Do not edit.
15747
15790
  */
15748
15791
 
15749
- 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 };
15792
+ 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 };
15750
15793
  //# sourceMappingURL=matcha-components.mjs.map