"use strict";
/**
 * @file RichText
 * @description
 * @author fex
 */
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
// @ts-ignore
var react_froala_wysiwyg_1 = (0, tslib_1.__importDefault)(require("react-froala-wysiwyg"));
// @ts-ignore
var froala_editor_min_js_1 = (0, tslib_1.__importDefault)(require("froala-editor/js/froala_editor.min.js"));
require("froala-editor/js/plugins/align.min");
require("froala-editor/js/plugins/colors.min");
require("froala-editor/js/plugins/char_counter.min");
require("froala-editor/js/plugins/code_view.min");
require("froala-editor/js/plugins/draggable.min");
require("froala-editor/js/plugins/entities.min");
require("froala-editor/js/plugins/font_family.min");
require("froala-editor/js/plugins/font_size.min");
require("froala-editor/js/plugins/forms.min");
require("froala-editor/js/plugins/fullscreen.min");
require("froala-editor/js/plugins/help.min");
require("froala-editor/js/plugins/image.min");
require("froala-editor/js/plugins/inline_class.min");
require("froala-editor/js/plugins/inline_style.min");
require("froala-editor/js/plugins/line_breaker.min");
require("froala-editor/js/plugins/line_height.min");
require("froala-editor/js/plugins/link.min");
require("froala-editor/js/plugins/lists.min");
require("froala-editor/js/plugins/paragraph_format.min");
require("froala-editor/js/plugins/paragraph_style.min");
require("froala-editor/js/plugins/print.min");
require("froala-editor/js/plugins/quick_insert.min");
require("froala-editor/js/plugins/quote.min");
require("froala-editor/js/plugins/save.min");
require("froala-editor/js/plugins/special_characters.min");
require("froala-editor/js/plugins/table.min");
require("froala-editor/js/plugins/url.min");
require("froala-editor/js/plugins/video.min");
require("froala-editor/js/plugins/word_paste.min");
require("froala-editor/js/languages/zh_cn.js");
// Require Editor CSS files.
require("froala-editor/css/froala_style.min.css");
require("froala-editor/css/froala_editor.pkgd.min.css");
var FroalaEditor = /** @class */ (function (_super) {
    (0, tslib_1.__extends)(FroalaEditor, _super);
    function FroalaEditor(props) {
        var _this = _super.call(this, props) || this;
        _this.oldModel = null;
        froala_editor_min_js_1.default.VIDEO_PROVIDERS = [
            {
                test_regex: /.*/,
                url_regex: '',
                url_text: '',
                html: '<span class="fr-video fr-dvb fr-draggable" contenteditable="false" draggable="true"><video class="fr-draggable" controls="" data-msg="ok" data-status="0" src="{url}" style="width: 600px;"></video></span>'
            }
        ];
        _this.state = {
            model: _this.props.model
        };
        _this.handleModelChange = _this.handleModelChange.bind(_this);
        return _this;
    }
    FroalaEditor.prototype.componentDidUpdate = function () {
        if (JSON.stringify(this.oldModel) == JSON.stringify(this.props.model)) {
            return;
        }
        this.handleModelChange(this.props.model);
    };
    FroalaEditor.prototype.handleModelChange = function (model) {
        if (!this.props.onModelChange) {
            return;
        }
        this.oldModel = model;
        this.props.onModelChange(model);
        this.setState({
            model: model
        });
    };
    FroalaEditor.prototype.render = function () {
        return (react_1.default.createElement(react_froala_wysiwyg_1.default, { tag: "textarea", config: this.props.config, model: this.state.model, onModelChange: this.handleModelChange }));
    };
    return FroalaEditor;
}(react_1.default.Component));
exports.default = FroalaEditor;
//# sourceMappingURL=./components/RichText.js.map
