import React from 'react'; import styled from 'styled-components'; import Button from '@atlaskit/button'; import Emoji from '@atlaskit/icon/glyph/editor/emoji'; import { EditorView } from 'prosemirror-view'; import { Popup, ProviderFactory, Providers, WithProviders, } from '@atlaskit/editor-common'; import { EmojiPicker, EmojiId } from '@atlaskit/emoji'; import Tooltip from '@atlaskit/tooltip'; // helps adjusts position of popup const EmojiPickerButtonWrapper = styled.div` position: relative; `; export type Props = { className?: string; view?: EditorView; idx?: number; providerFactory?: ProviderFactory; title?: string; onChange?: (emoji: EmojiId) => void; isSelected?: boolean; }; export type State = { isPopupOpen?: Boolean; activeIcon?: string; }; export const EmojiPickerButton = (props: Props) => { const buttonRef = React.useRef(null); const [isPopupOpen, setIsPopupOpen] = React.useState(false); const togglePopup = () => { setIsPopupOpen(!isPopupOpen); }; const updateEmoji = (emoji: EmojiId) => { setIsPopupOpen(false); props.onChange && props.onChange(emoji); }; const renderPicker = (providers: Providers) => { if (!providers.emojiProvider) { return null; } return ( {}} /> ); }; const renderPopup = () => { if (!buttonRef.current || !isPopupOpen) { return; } return ( ); }; const title = props.title || ''; return (