import { Component, Input } from '@angular/core';
var FormcontrolTinymceComponent = (function () {
    function FormcontrolTinymceComponent() {
    }
    FormcontrolTinymceComponent.prototype.ngAfterViewInit = function () {
        var _this = this;
        tinyMCE.baseURL = '/assets/tinymce/';
        tinymce.init({
            selector: "#tinymce-" + this.field,
            menubar: false,
            plugins: ['link', 'paste', 'lists', 'advlist'],
            toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright | bullist numlist outdent indent | link image',
            setup: function (editor) {
                _this.editor = editor;
                editor.on('keyup', function () {
                    var content = editor.getContent();
                    _this.form.get(_this.field).patchValue(content);
                });
                editor.on('blur', function () {
                    var content = editor.getContent();
                    _this.form.get(_this.field).patchValue(content);
                });
            },
        });
    };
    FormcontrolTinymceComponent.prototype.ngOnDestroy = function () {
        tinymce.remove(this.editor);
    };
    FormcontrolTinymceComponent.decorators = [
        { type: Component, args: [{
                    selector: 'app-formcontrol-tinymce',
                    template: "\n    <div [formGroup]=\"form\" class=\"form-group\">\n      <label class=\"col-sm-2 control-label\">{{displayName}}</label>\n      <div class=\"col-sm-10\">\n        <textarea id=\"tinymce-{{field}}\" [formControlName]=\"field\" class=\"form-control\"></textarea>\n      </div>\n    </div>\n  ",
                    styles: ["\n\n  "],
                },] },
    ];
    FormcontrolTinymceComponent.ctorParameters = function () { return []; };
    FormcontrolTinymceComponent.propDecorators = {
        'field': [{ type: Input },],
        'displayName': [{ type: Input },],
        'form': [{ type: Input },],
    };
    return FormcontrolTinymceComponent;
}());
export { FormcontrolTinymceComponent };
//# sourceMappingURL=formcontrol-tinymce.component.js.map