import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {PluginEditEvent} from "./base-plugin.form.component"; import {AlertModal} from "../../../utils/modal/alert"; import {UntypedFormBuilder, UntypedFormGroup} from "@angular/forms"; @Component({ selector: 'plugin-field-edit', template: `
open editor
`, styles: [` :host >>> textarea.input { border: solid 1px #3e3e3e3e !important; } `] }) export class PluginFieldEditComponent { @Input() type; @Input() value; @Input() field; @Input() placeholder; @Input() switchToHTMLEditor; @Output() editClicked: EventEmitter = new EventEmitter(); @Output() changed: EventEmitter = new EventEmitter(); htmlEditorView = false; @ViewChild('HTMLEditorModal') HTMLEditorModal: AlertModal; HTMLForm: UntypedFormGroup = this._fb.group({ value: this._fb.control("") }); constructor(private _fb: UntypedFormBuilder) { } updateObject(value) { console.log(value) this.value = value; this.changed.emit({field: this.field, value: this.value, type: this.type}); } openHTMLEditor() { this.HTMLForm.get('value').setValue(this.value) this.htmlEditorView = true; this.HTMLEditorModal.alertTitle = "HTML Editor"; this.HTMLEditorModal.open(); } closeHTMLEditor() { this.htmlEditorView = false; this.updateObject(this.HTMLForm.get('value').value) } }