@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
70 lines (69 loc) • 2.09 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';
const pluginsComponentsWrapper = css({
display: 'flex'
});
const PluginSlot = ({
items,
editorView,
editorActions,
eventDispatcher,
providerFactory,
appearance,
popupsMountPoint,
popupsBoundariesElement,
popupsScrollableElement,
containerElement,
disabled,
dispatchAnalyticsEvent,
wrapperElement,
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((component, key) => {
const props = {
key
};
const element = component({
editorView: editorView,
editorActions: editorActions,
eventDispatcher: eventDispatcher,
providerFactory,
dispatchAnalyticsEvent,
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
appearance: appearance,
popupsMountPoint,
popupsBoundariesElement,
popupsScrollableElement,
containerElement,
disabled,
wrapperElement
});
return element && /*#__PURE__*/React.cloneElement(element, props);
})));
};
const PluginSlotComponent = /*#__PURE__*/React.memo(PluginSlot, isEqual);
PluginSlotComponent.displayName = 'PluginSlot';
export default PluginSlotComponent;