UNPKG

@atlaskit/editor-plugin-block-menu

Version:

BlockMenu plugin for @atlaskit/editor-core

38 lines (37 loc) • 1.71 kB
import React from 'react'; import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { BlockMenuPlugin } from '../blockMenuPluginType'; import { type BlockMenuAnchorMetrics } from './utils/fixBlockMenuPositionAndScroll'; export type Direction = 'moveUp' | 'moveDown'; type BlockMenuProviderProps = { api: ExtractInjectionAPI<BlockMenuPlugin> | undefined; children: React.ReactNode; editorView: EditorView | undefined; }; export type BlockMenuContextType = { /** * Drag handle and popup geometry as laid out when the menu opened. */ anchorMetricsRef: React.MutableRefObject<BlockMenuAnchorMetrics | undefined>; getFirstSelectedDomNode: () => Element | undefined; /** * The top level block a move transaction has just moved. */ getMovedBlockDomNode: () => Element | undefined; /** * The top level block the block menu is open for, which is what the drag handle is anchored to. */ getSelectedBlockDomNode: () => Element | undefined; moveDownRef: React.MutableRefObject<HTMLButtonElement | null>; moveUpRef: React.MutableRefObject<HTMLButtonElement | null>; /** * Callback for when the dropdown is open/closed. Receives an object with `isOpen` state. * * If the dropdown was closed programmatically, the `event` parameter will be `null`. */ onDropdownOpenChanged: (isOpen: boolean) => void; }; export declare const useBlockMenu: () => BlockMenuContextType; export declare const BlockMenuProvider: ({ children, api, editorView, }: BlockMenuProviderProps) => React.JSX.Element; export {};