@atlaskit/editor-plugin-insert-block
Version:
Insert block plugin for @atlaskit/editor-core
49 lines • 1.71 kB
JavaScript
import React from 'react';
import { Popup } from '@atlaskit/editor-common/ui';
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
import { EmojiPicker as AkEmojiPicker } from '@atlaskit/emoji/picker';
const EmojiPicker = props => {
const setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
return /*#__PURE__*/React.createElement(AkEmojiPicker, {
onPickerRef: setOutsideClickTargetRef,
emojiProvider: props.emojiProvider,
onSelection: props.onSelection
});
};
const EmojiPickerWithListeners = withOuterListeners(EmojiPicker);
export const EmojiPickerPopup = ({
isOpen,
targetRef,
emojiProvider,
onSelection,
onClickOutside,
onEscapeKeydown,
onUnmount,
popupsMountPoint,
popupsBoundariesElement,
popupsScrollableElement
}) => {
if (!isOpen || !targetRef.current || !emojiProvider) {
return null;
}
return /*#__PURE__*/React.createElement(Popup, {
target: targetRef.current,
fitHeight: 350,
fitWidth: 350
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
,
offset: [0, 3],
mountTo: popupsMountPoint,
boundariesElement: popupsBoundariesElement,
scrollableElement: popupsScrollableElement,
onUnmount: onUnmount,
focusTrap: true,
zIndex: akEditorMenuZIndex
}, /*#__PURE__*/React.createElement(EmojiPickerWithListeners, {
emojiProvider: emojiProvider,
onSelection: onSelection,
handleClickOutside: onClickOutside,
handleEscapeKeydown: onEscapeKeydown
}));
};