Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 22x 22x 22x 78x 78x 78x 78x 82x 77x 82x 82x 4x 4x 4x 33x 82x 82x | import { Directive, inject, Input, OnInit } from "@angular/core";
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
import { EditorComponent } from "@tinymce/tinymce-angular";
@Directive()
export abstract class BaseInputComponent implements OnInit {
@Input({required: true}) form!: FormGroup;
@Input() controlName!: string;
@Input() initialValue: string | undefined;
protected fb = inject(FormBuilder);
public control: FormControl | null = null;
// for rich text editors
init: EditorComponent['init'] = {
plugins: ['link', 'autolink', 'lists'],
toolbar: 'undo redo | bold italic | link | bullist',
promotion: false,
menubar: 'null',
statusbar: false
};
constructor(protected defaultControlName: string){
}
ngOnInit(): void {
if(!this.controlName) {
this.controlName = this.defaultControlName;
}
this.control = this.fb.control(this.initialValue, this.getValidators());
this.getForm().addControl(this.controlName, this.control);
}
updateRichText(event: any) :boolean {
Eif(this.control !== null) {
this.control.setValue(event.editor.getContent());
}
return true;
}
protected getValidators(): any[] {
return [];
}
protected getForm(): FormGroup {
if (this.form instanceof FormGroup) {
return this.form;
} else E{
throw new Error('Form is not a FormGroup');
}
}
} |