import { Button as MantineButton, CheckIcon as MantineCheckIcon, Menu as MantineMenu, } from "@mantine/core"; import { assertEmpty, isSafari } from "@blocknote/core"; import { ComponentProps } from "@blocknote/react"; import { forwardRef } from "react"; import { HiChevronDown } from "react-icons/hi"; // TODO: Turn into select? export const ToolbarSelect = forwardRef< HTMLDivElement, ComponentProps["FormattingToolbar"]["Select"] >((props, ref) => { const { className, items, isDisabled, ...rest } = props; assertEmpty(rest); const selectedItem = items.filter((p) => p.isSelected)[0]; if (!selectedItem) { return null; } return ( { if (isSafari()) { (e.currentTarget as HTMLButtonElement).focus(); } }} leftSection={selectedItem.icon} rightSection={} size={"xs"} variant={"subtle"} disabled={isDisabled}> {selectedItem.text} {items.map((item) => ( ) : ( // Ensures space for tick even if item isn't currently selected.
) } disabled={item.isDisabled}> {item.text} ))} ); });