import type { HotkeyProps, IconProps, QAProps } from '@gravity-ui/uikit'; import type { ClassNameProps } from "../classname.js"; export type ToolbarBaseProps = ClassNameProps & QAProps & { editor: E; focus(): void; onClick?(id: string, attrs?: { [key: string]: any; }): void; display?: ToolbarDisplay; disableTooltip?: boolean; disablePreview?: boolean; disableHotkey?: boolean; }; export type ToolbarIconData = Pick; export type ToolbarGroupData = Array>; export type ToolbarData = ToolbarGroupData[]; export type ToolbarDisplay = 'shrink' | 'scroll'; export type ToolbarItemData = QAProps & { id: string; icon: ToolbarIconData; title: string | (() => string); hint?: string | (() => string); hotkey?: HotkeyProps['value']; preview?: React.ReactNode; theme?: 'normal' | 'danger'; /** * Alternative IDs that can be used to find this command */ aliases?: string[]; /** * Show hint when _isEnable()_ returns false * * `false` – don't show hint; * * `true` – show default hint; * * `string` or `() => string` – show hint with custom message. * @default true */ hintWhenDisabled?: boolean | string | (() => string); exec(editor: E): void; isActive(editor: E): boolean; isEnable(editor: E): boolean; }; export declare enum ToolbarDataType { SingleButton = "s-button", ListButton = "list-b", ButtonPopup = "b-popup", /** @deprecated Use ReactComponent type instead */ ReactNode = "r-node", /** @deprecated Use ReactComponent type instead */ ReactNodeFn = "r-node-fn", ReactComponent = "r-component" } export type ToolbarGroupItemData = ToolbarSingleItemData | ToolbarButtonPopupData | ToolbarListItemData | ToolbarReactNodeData | ToolbarReactNodeFnData | ToolbarReactComponentData; export type ToolbarSingleItemData = ToolbarItemData & { id: string; type: ToolbarDataType.SingleButton; className?: string; }; export type ToolbarListItemData = ToolbarListButtonData & { id: string; type: ToolbarDataType.ListButton; className?: string; }; export type ToolbarReactComponentData = { id: string; type: ToolbarDataType.ReactComponent; width: number; className?: string; component: React.ComponentType>; noRerenderOnUpdate?: boolean; props?: object; }; export type ToolbarButtonPopupData = ToolbarItemData & { /** not used, may be an empty function */ exec: ToolbarItemData['exec']; type: ToolbarDataType.ButtonPopup; renderPopup: (props: ToolbarBaseProps & { hide: () => void; anchorElement: HTMLElement | null; }) => React.ReactNode; className?: string; }; export type ToolbarListButtonItemData = ToolbarItemData & { doNotActivateList?: boolean; }; export type ToolbarListButtonData = { icon: ToolbarIconData; title: string | (() => string); withArrow?: boolean; data: ToolbarListButtonItemData[]; alwaysActive?: boolean; hideDisabled?: boolean; /** When state changes to active, replace default icon with icon of first active item */ replaceActiveIcon?: boolean; }; /** * @deprecated Use ReactComponent type instead */ export type ToolbarReactNodeData = { id: string; type: ToolbarDataType.ReactNode; width: number; content: React.ReactNode; noRerenderOnUpdate?: boolean; }; /** * @deprecated Use ReactComponent type instead */ export type ToolbarReactNodeFnData = { id: string; type: ToolbarDataType.ReactNodeFn; width: number; content: (e: E) => React.ReactNode; noRerenderOnUpdate?: boolean; };