@progress/kendo-react-editor
Version:
Kendo UI for React Editor package
64 lines • 3.44 kB
JavaScript
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 __());
};
})();
import * as React from 'react';
import { createPortal } from 'react-dom';
import { Dialog, DialogActionsBar } from '@progress/kendo-react-dialogs';
import { Button } from '@progress/kendo-react-buttons';
import { getHtml, setHtml, indentHtml } from '@progress/kendo-editor-common';
import { registerForLocalization, provideLocalizationService } from '@progress/kendo-react-intl';
import { messages } from './../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;
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 = 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: indentHtml(getHtml(view.state)), autoFocus: true }));
var actionButtons = [(React.createElement(Button, { onClick: this.onClose, dir: dir, key: "cancel" }, localization.toLanguageString(viewHtmlCancel, messages[viewHtmlCancel]))), (React.createElement(Button, { onClick: this.onUpdate, primary: true, dir: dir, key: "update" }, localization.toLanguageString(viewHtmlUpdate, messages[viewHtmlUpdate])))
];
var dialog = (React.createElement(Dialog, { title: localization.toLanguageString(viewHtmlDialogTitle, messages[viewHtmlDialogTitle]), onClose: this.onClose, key: "dialog", closeIcon: true, dir: dir, style: dir === 'rtl' ? { textAlign: 'right' } : undefined },
content,
React.createElement(DialogActionsBar, null, actionButtons)));
return render ? render(dialog, { content: content, actionButtons: actionButtons }) :
createPortal(dialog, document.body);
};
return ViewHtmlDialog;
}(React.Component));
export { ViewHtmlDialog };
registerForLocalization(ViewHtmlDialog);
//# sourceMappingURL=viewHtml.js.map