@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
64 lines • 3.14 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/* eslint-disable @repo/internal/react/no-class-components */
import React, { PureComponent } from 'react';
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
import { ProviderFactory, WithProviders } from '../../provider-factory';
import { MentionWithProviders } from './mention-with-providers';
var MENTION_PROVIDERS = ['mentionProvider', 'profilecardProvider'];
var Mention = /*#__PURE__*/function (_PureComponent) {
function Mention(props) {
var _this;
_classCallCheck(this, Mention);
_this = _callSuper(this, Mention, [props]);
_defineProperty(_this, "renderWithProvider", function (providers) {
var _this$props = _this.props,
accessLevel = _this$props.accessLevel,
eventHandlers = _this$props.eventHandlers,
id = _this$props.id,
text = _this$props.text,
localId = _this$props.localId;
var mentionProvider = providers.mentionProvider,
profilecardProvider = providers.profilecardProvider;
return /*#__PURE__*/React.createElement(MentionWithProviders, {
id: id,
text: text,
accessLevel: accessLevel,
localId: localId,
eventHandlers: eventHandlers,
mentionProvider: mentionProvider,
profilecardProvider: profilecardProvider
});
});
_this.providerFactory = props.providers || new ProviderFactory();
return _this;
}
_inherits(Mention, _PureComponent);
return _createClass(Mention, [{
key: "componentWillUnmount",
value: function componentWillUnmount() {
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();
}
}
}, {
key: "render",
value: function render() {
var providers = expValEquals('platform_editor_perf_lint_cleanup', 'isEnabled', true) ? MENTION_PROVIDERS : ['mentionProvider', 'profilecardProvider'];
return /*#__PURE__*/React.createElement(WithProviders, {
providers: providers,
providerFactory: this.providerFactory,
renderNode: this.renderWithProvider
});
}
}]);
}(PureComponent);
export { Mention as default };