UNPKG

@progress/kendo-react-editor

Version:
73 lines 3.54 kB
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 __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; return t; }; import * as React from 'react'; import { canInsert } from '@progress/kendo-editor-common'; import { Button } from '@progress/kendo-react-buttons'; import { onDownPreventDefault } from './utils'; import { EditorDialogs } from '../dialogs/main'; import { registerForLocalization, provideLocalizationService } from '@progress/kendo-react-intl'; import { messages } from './../messages'; /** * @hidden */ export var createInsertImageTool = function (settings) { var Tool = /** @class */ (function (_super) { __extends(InsertImageTool, _super); function InsertImageTool() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { openedDialog: false }; _this.toggleDialog = function () { _this.setState({ openedDialog: !_this.state.openedDialog }); }; return _this; } InsertImageTool.prototype.render = function () { var _a = this.props, view = _a.view, render = _a.render, buttonProps = __rest(_a, ["view", "render"]); var state = view && view.state; var nodeType = state ? state.schema.nodes[settings.node] : undefined; var localization = provideLocalizationService(this); var insertImage = settings.messages.insertImage; var rendering = [(React.createElement(Button, __assign({ onClick: this.toggleDialog, key: "insertImage", disabled: !nodeType || !state || !canInsert(state, nodeType) }, onDownPreventDefault, { title: localization.toLanguageString(insertImage, messages[insertImage]) }, settings.props, buttonProps))), (this.state.openedDialog && view && (React.createElement(EditorDialogs.InsertImageDialog, { key: "insertImageDialog", view: view, settings: settings, dir: buttonProps.dir, onClose: this.toggleDialog })) || null)]; return render ? render.call(undefined, rendering, { view: view }) : rendering; }; return InsertImageTool; }(React.Component)); registerForLocalization(Tool); return Tool; }; //# sourceMappingURL=insertImage.js.map