UNPKG

@up-group-ui/react-controls

Version:
70 lines 2.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var jsx_runtime_1 = require("react/jsx-runtime"); var BaseControl_1 = require("../_Common/BaseControl/BaseControl"); var theming_1 = (0, tslib_1.__importDefault)(require("../../../Common/theming")); var CKEditor = (0, tslib_1.__importStar)(require("@ckeditor/ckeditor5-react")); var ClassicEditor = (0, tslib_1.__importStar)(require("@ckeditor/ckeditor5-build-classic")); var eventListener_1 = require("../../../Common/utils/eventListener"); var UpRichText = (function (_super) { (0, tslib_1.__extends)(UpRichText, _super); function UpRichText(p, c) { var _this = _super.call(this, p, c) || this; _this.getValue = _this.getValue.bind(_this); _this.state = { value: p.value, }; return _this; } UpRichText.prototype.showError = function () { return this.props.showError !== undefined ? typeof this.props.showError === 'function' ? this.props.showError(this.state) : this.props.showError === true : this.hasError; }; UpRichText.prototype.showSuccess = function () { return this.props.showSuccess; }; UpRichText.prototype.renderControl = function () { var _this = this; var configRTE = this.props.configRTE; return ((0, jsx_runtime_1.jsx)(CKEditor, { editor: ClassicEditor, data: this.state.value || '', name: this.props.name, config: this.props.configRTE, disabled: this.props.disabled, onInit: function (editor) { console.log('Editor is ready to use!', editor); }, tabIndex: this.props.tabIndex, onChange: function (event, editor) { var data = editor.getData(); _this.handleChangeEvent((0, eventListener_1.eventFactory)(_this.props.name, data), data); } }, void 0)); }; UpRichText.prototype.getValue = function (event) { return event != null && event.target != null ? event.target.value : event; }; UpRichText.defaultProps = { width: 'xlarge', showError: true, configRTE: { language: 'fr', enterMode: 2, shiftEnterMode: 1, toolbar: [ 'heading', 'bold', 'italic', 'fontFamily', 'fontSize', '|', 'link', 'blockQuote', 'numberedList', 'bulletedList', 'undo', 'redo', ], }, theme: theming_1.default, }; return UpRichText; }(BaseControl_1.BaseControlComponent)); exports.default = UpRichText; //# sourceMappingURL=UpRichText.js.map