UNPKG

@atlaskit/editor-plugin-paste-options-toolbar

Version:

Paste options toolbar for @atlaskit/editor-core

47 lines (44 loc) 1.62 kB
/* PasteOptionsDropdownButton.tsx generated by @compiled/babel-plugin v0.39.1 */ import { ax, ix } from "@compiled/react/runtime"; import React, { useCallback } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import DropdownMenu from '@atlaskit/dropdown-menu'; import { ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar'; /** * A compact dropdown button for paste options, styled like floating toolbar buttons. * Renders as a ToolbarButton with an icon and dropdown caret that opens a * dropdown menu below. Used when AI actions are not visible and the paste * options menu is the only content. */ export const PasteOptionsDropdownButton = ({ children, elemBefore, elemAfter, label, testId, tooltipContent }) => { const trigger = useCallback(triggerProps => { const button = /*#__PURE__*/React.createElement(ToolbarButton, { ref: triggerProps.triggerRef, isSelected: triggerProps.isSelected, "aria-expanded": triggerProps['aria-expanded'], "aria-haspopup": triggerProps['aria-haspopup'], onClick: triggerProps.onClick, testId: testId, iconBefore: elemBefore, label: label }, elemAfter); if (tooltipContent) { return /*#__PURE__*/React.createElement(ToolbarTooltip, { content: tooltipContent, position: "top" }, button); } return button; }, [testId, elemBefore, elemAfter, label, tooltipContent]); return /*#__PURE__*/React.createElement(DropdownMenu, { placement: "bottom-start", trigger: trigger }, children); };