@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
77 lines (74 loc) • 2.99 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@emotion/react");
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _analytics = require("@atlaskit/editor-common/analytics");
var _ErrorBoundary = require("../ErrorBoundary");
var _mountPluginHooks = require("./mount-plugin-hooks");
/**
* @jsxRuntime classic
* @jsx jsx
*/
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
var pluginsComponentsWrapper = (0, _react2.css)({
display: 'flex'
});
var PluginSlot = function PluginSlot(_ref) {
var items = _ref.items,
editorView = _ref.editorView,
editorActions = _ref.editorActions,
eventDispatcher = _ref.eventDispatcher,
providerFactory = _ref.providerFactory,
appearance = _ref.appearance,
popupsMountPoint = _ref.popupsMountPoint,
popupsBoundariesElement = _ref.popupsBoundariesElement,
popupsScrollableElement = _ref.popupsScrollableElement,
containerElement = _ref.containerElement,
disabled = _ref.disabled,
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
wrapperElement = _ref.wrapperElement,
pluginHooks = _ref.pluginHooks;
if (!items && !pluginHooks) {
return null;
}
return (0, _react2.jsx)(_ErrorBoundary.ErrorBoundary, {
component: _analytics.ACTION_SUBJECT.PLUGIN_SLOT,
fallbackComponent: null
}, (0, _react2.jsx)(_mountPluginHooks.MountPluginHooks, {
editorView: editorView,
pluginHooks: pluginHooks,
containerElement: containerElement
}), (0, _react2.jsx)("div", {
css: pluginsComponentsWrapper,
"data-testid": "plugins-components-wrapper"
}, items === null || items === void 0 ? void 0 : items.map(function (component, key) {
var props = {
key: key
};
var element = component({
editorView: editorView,
editorActions: editorActions,
eventDispatcher: eventDispatcher,
providerFactory: providerFactory,
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
appearance: appearance,
popupsMountPoint: popupsMountPoint,
popupsBoundariesElement: popupsBoundariesElement,
popupsScrollableElement: popupsScrollableElement,
containerElement: containerElement,
disabled: disabled,
wrapperElement: wrapperElement
});
return element && /*#__PURE__*/_react.default.cloneElement(element, props);
})));
};
var PluginSlotComponent = /*#__PURE__*/_react.default.memo(PluginSlot, _isEqual.default);
PluginSlotComponent.displayName = 'PluginSlot';
var _default = exports.default = PluginSlotComponent;