Skip to content

Commit

Permalink
fix(plex): detiene bug en evento de editor html
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed Jan 7, 2025
1 parent e9b56ec commit 1b40a31
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/lib/text/text.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnInit, Optional, Output, Renderer2, Self, ViewChild } from '@angular/core';
import { ControlValueAccessor, FormControl, NgControl } from '@angular/forms';
import { BOLD_BUTTON, EditorConfig, FONT_SIZE_SELECT, ITALIC_BUTTON, JUSTIFY_CENTER_BUTTON, JUSTIFY_LEFT_BUTTON, JUSTIFY_RIGHT_BUTTON, UNDERLINE_BUTTON } from 'ngx-simple-text-editor';
import { hasRequiredValidator } from '../core/validator.functions';
import { EditorConfig, BOLD_BUTTON, ITALIC_BUTTON, FONT_SIZE_SELECT, JUSTIFY_LEFT_BUTTON, JUSTIFY_CENTER_BUTTON, JUSTIFY_RIGHT_BUTTON, UNDERLINE_BUTTON } from 'ngx-simple-text-editor';

@Component({
selector: 'plex-text',
Expand Down Expand Up @@ -39,7 +39,9 @@ import { EditorConfig, BOLD_BUTTON, ITALIC_BUTTON, FONT_SIZE_SELECT, JUSTIFY_LEF
</textarea>
<!-- HTML Editor -->
<st-editor #htmlEditor class="text-editor" *ngIf="html" [config]="config" [(ngModel)]="richText" (ngModelChange)="onChange($event)"></st-editor>
<div #htmlEditor>
<st-editor class="text-editor" *ngIf="html" [config]="config" [(ngModel)]="richText"></st-editor>
</div>
<!-- Validación / Descripción ARIA -->
<plex-validation-messages [mensaje]="mensaje" id="{{ ariaDescribedby.id }}" *ngIf="hasDanger()" [control]="control"></plex-validation-messages>
Expand All @@ -65,7 +67,7 @@ export class PlexTextComponent implements OnInit, AfterViewInit, ControlValueAcc

@ViewChild('input', { static: true }) private input: ElementRef;
@ViewChild('textarea', { static: true }) private textarea: ElementRef;
@ViewChild('htmlEditor', { static: true }) private htmlEditor: ElementRef;
@ViewChild('htmlEditor', { static: false }) private htmlEditor: ElementRef;

public get esRequerido(): boolean {
return hasRequiredValidator(this.control as any);
Expand Down Expand Up @@ -169,6 +171,16 @@ export class PlexTextComponent implements OnInit, AfterViewInit, ControlValueAcc
const element = this.multiline ? this.textarea.nativeElement : this.input.nativeElement;
element.focus();
}

const editorElement = this.htmlEditor?.nativeElement;
const selectElement = editorElement.querySelector('select');

if (selectElement) {
selectElement.addEventListener('change', (event: Event) => {
event.stopPropagation();
event.preventDefault();
});
}
}
// Actualización Modelo -> Vista
writeValue(value: any) {
Expand Down

0 comments on commit 1b40a31

Please sign in to comment.