UNPKG

@atlaskit/editor-plugin-insert-block

Version:

Insert block plugin for @atlaskit/editor-core

53 lines • 1.83 kB
import React from 'react'; import Popup from '@atlaskit/editor-common/Popup'; import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react'; import withOuterListeners from '@atlaskit/editor-common/ui-react/with-react-editor-view-outer-listeners'; import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles/constants'; import AkEmojiPicker from '@atlaskit/emoji/emoji-picker'; const EmojiPicker = props => { const setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext); return /*#__PURE__*/React.createElement(AkEmojiPicker, { contentId: props.contentId, onPickerRef: setOutsideClickTargetRef, emojiProvider: props.emojiProvider, onSelection: props.onSelection }); }; const EmojiPickerWithListeners = withOuterListeners(EmojiPicker); export const EmojiPickerPopup = ({ contentId, 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, { contentId: contentId, emojiProvider: emojiProvider, onSelection: onSelection, handleClickOutside: onClickOutside, handleEscapeKeydown: onEscapeKeydown })); };