UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

28 lines (27 loc) • 1.85 kB
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { BlockControlsPlugin } from '../blockControlsPluginType'; /** * Whether the element under the pointer can be part of a block's left gutter: a container block's * own padding (panel, layout, list…) or an editor wrapper around the content. Text and leaf blocks * have no gutter inside them. Table and cell padding shows the table's controls, but containers * nested inside cells can own gutters for their children, as in the legacy hover zones. Elements * rendered beside the editor (title, popups, toolbars) cover any gutter beneath them. */ export declare const isPossibleGutterElement: (view: EditorView, hoveredElement: EventTarget | null) => hoveredElement is Element; /** Returns a function that finds the block whose legacy hover zone contains the pointer. */ export declare const createGutterBlockFinder: (view: EditorView, api: ExtractInjectionAPI<BlockControlsPlugin> | undefined) => ((event: MouseEvent) => Element | null); /** * Shows block controls for the block the pointer hovers under sparse surfaces, including the empty * space to a block's left (the gutter). This is the only hover handler for sparse surfaces. * * Reaching text or a leaf block shows its controls straight away. Over an element that can be part * of a gutter, only the latest pointer event is kept, and it is resolved once after the frame * renders so that reading positions never forces a layout. * * Returns an unbind function, or `undefined` when the editor's document has no window. */ export declare const bindSparseGutterHover: ({ api, view, }: { api: ExtractInjectionAPI<BlockControlsPlugin> | undefined; view: EditorView; }) => (() => void) | undefined;