@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
69 lines (68 loc) • 2.6 kB
JavaScript
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React from 'react';
// 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
import { css, jsx } from '@emotion/react';
import isEqual from 'lodash/isEqual';
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
import { ErrorBoundary } from '../ErrorBoundary';
import { MountPluginHooks } from './mount-plugin-hooks';
var pluginsComponentsWrapper = 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 jsx(ErrorBoundary, {
component: ACTION_SUBJECT.PLUGIN_SLOT,
fallbackComponent: null
}, jsx(MountPluginHooks, {
editorView: editorView,
pluginHooks: pluginHooks,
containerElement: containerElement
}), 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.cloneElement(element, props);
})));
};
var PluginSlotComponent = /*#__PURE__*/React.memo(PluginSlot, isEqual);
PluginSlotComponent.displayName = 'PluginSlot';
export default PluginSlotComponent;