@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
40 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var image_1 = require("@atlaskit/icon/glyph/editor/image");
var React = require("react");
var react_1 = require("react");
var analytics_1 = require("../../analytics");
var ToolbarButton_1 = require("../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_1.default, { onClick: this.handleInsertImage, title: "Insert image", disabled: disabled, iconBefore: React.createElement(image_1.default, { label: "Add image" }) }));
};
return ToolbarImage;
}(react_1.PureComponent));
tslib_1.__decorate([
analytics_1.analyticsDecorator('atlassian.editor.image.button')
], ToolbarImage.prototype, "handleInsertImage", void 0);
exports.default = ToolbarImage;
//# sourceMappingURL=index.js.map