UNPKG

@progress/kendo-react-editor

Version:
66 lines 3.74 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var react_dom_1 = require("react-dom"); var kendo_react_dialogs_1 = require("@progress/kendo-react-dialogs"); var kendo_react_buttons_1 = require("@progress/kendo-react-buttons"); var kendo_editor_common_1 = require("@progress/kendo-editor-common"); var kendo_react_intl_1 = require("@progress/kendo-react-intl"); var messages_1 = require("./../messages"); /** * @hidden */ var ViewHtmlDialog = /** @class */ (function (_super) { __extends(ViewHtmlDialog, _super); function ViewHtmlDialog() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.htmlArea = null; _this.onUpdate = function () { var _a = _this.props, view = _a.view, settings = _a.settings; kendo_editor_common_1.setHtml(_this.htmlArea ? _this.htmlArea.value : '', settings.commandName)(view.state, view.dispatch); _this.onClose(); }; _this.onClose = function () { _this.props.view.focus(); _this.props.onClose(); }; return _this; } /** * @hidden */ ViewHtmlDialog.prototype.render = function () { var _this = this; var _a = this.props, view = _a.view, settings = _a.settings, dir = _a.dir, render = _a.render; var localization = kendo_react_intl_1.provideLocalizationService(this); var _b = settings.messages, viewHtmlDialogTitle = _b.viewHtmlDialogTitle, viewHtmlCancel = _b.viewHtmlCancel, viewHtmlUpdate = _b.viewHtmlUpdate; var content = (React.createElement("textarea", { className: "k-textarea k-editor-textarea", style: { height: '280px', width: '490px' }, ref: function (e) { return _this.htmlArea = e; }, defaultValue: kendo_editor_common_1.indentHtml(kendo_editor_common_1.getHtml(view.state)), autoFocus: true })); var actionButtons = [(React.createElement(kendo_react_buttons_1.Button, { onClick: this.onClose, dir: dir, key: "cancel" }, localization.toLanguageString(viewHtmlCancel, messages_1.messages[viewHtmlCancel]))), (React.createElement(kendo_react_buttons_1.Button, { onClick: this.onUpdate, primary: true, dir: dir, key: "update" }, localization.toLanguageString(viewHtmlUpdate, messages_1.messages[viewHtmlUpdate]))) ]; var dialog = (React.createElement(kendo_react_dialogs_1.Dialog, { title: localization.toLanguageString(viewHtmlDialogTitle, messages_1.messages[viewHtmlDialogTitle]), onClose: this.onClose, key: "dialog", closeIcon: true, dir: dir, style: dir === 'rtl' ? { textAlign: 'right' } : undefined }, content, React.createElement(kendo_react_dialogs_1.DialogActionsBar, null, actionButtons))); return render ? render(dialog, { content: content, actionButtons: actionButtons }) : react_dom_1.createPortal(dialog, document.body); }; return ViewHtmlDialog; }(React.Component)); exports.ViewHtmlDialog = ViewHtmlDialog; kendo_react_intl_1.registerForLocalization(ViewHtmlDialog); //# sourceMappingURL=viewHtml.js.map