UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

38 lines 1.67 kB
import * as tslib_1 from "tslib"; import ImageIcon from '@atlaskit/icon/glyph/editor/image'; import * as React from 'react'; import { PureComponent } from 'react'; import { analyticsDecorator as analytics } from '../../analytics'; import ToolbarButton from '../ToolbarButton'; var ToolbarImage = (function (_super) { tslib_1.__extends(ToolbarImage, _super); function ToolbarImage() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { disabled: false }; _this.handlePluginStateChange = function (pluginState) { _this.setState({ disabled: !pluginState.enabled }); }; _this.handleInsertImage = function () { return _this.props.pluginState.handleImageUpload(_this.props.editorView); }; return _this; } ToolbarImage.prototype.componentDidMount = function () { this.props.pluginState.subscribe(this.handlePluginStateChange); }; ToolbarImage.prototype.componentWillUnmount = function () { this.props.pluginState.unsubscribe(this.handlePluginStateChange); }; ToolbarImage.prototype.render = function () { var disabled = this.state.disabled; return (React.createElement(ToolbarButton, { onClick: this.handleInsertImage, title: "Insert image", disabled: disabled, iconBefore: React.createElement(ImageIcon, { label: "Add image" }) })); }; return ToolbarImage; }(PureComponent)); export default ToolbarImage; tslib_1.__decorate([ analytics('atlassian.editor.image.button') ], ToolbarImage.prototype, "handleInsertImage", void 0); //# sourceMappingURL=index.js.map