UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

30 lines 1.74 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { PureComponent } from 'react'; import MediaComponent from './MediaComponent'; import { default as ProviderFactory, WithProviders } from '../../providerFactory'; var Media = (function (_super) { tslib_1.__extends(Media, _super); function Media(props) { var _this = _super.call(this, props) || this; _this.renderWithProvider = function (providers) { var _a = _this.props, id = _a.id, type = _a.type, collection = _a.collection, cardDimensions = _a.cardDimensions, onClick = _a.onClick, onDelete = _a.onDelete, resizeMode = _a.resizeMode, editorView = _a.editorView, appearance = _a.appearance; return (React.createElement(MediaComponent, { id: id, mediaProvider: providers.mediaProvider, type: type, collection: collection, cardDimensions: cardDimensions, resizeMode: resizeMode, onDelete: onDelete, onClick: onClick, editorView: editorView, appearance: appearance })); }; _this.providerFactory = props.providers || new ProviderFactory(); return _this; } Media.prototype.componentWillUnmount = function () { if (!this.props.providers) { // new ProviderFactory is created if no `providers` has been set // in this case when component is unmounted it's safe to destroy this providerFactory this.providerFactory.destroy(); } }; Media.prototype.render = function () { return (React.createElement(WithProviders, { providers: ['mediaProvider'], providerFactory: this.providerFactory, renderNode: this.renderWithProvider })); }; return Media; }(PureComponent)); export default Media; //# sourceMappingURL=index.js.map