@atlaskit/editor-plugin-block-controls
Version:
Block controls plugin for @atlaskit/editor-core
20 lines (19 loc) • 1.17 kB
TypeScript
import type { BlockControlUIContext } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
/**
* Resolves to `T` only when `Compared` lists every key of `T`. Adding a field to the context types
* turns the comparators' parameters into `never`, so callers stop compiling until the comparison
* handles the new field.
*/
type ComparedFields<T, Compared extends keyof T> = Exclude<keyof T, Compared> extends never ? T : never;
/**
* `controlVisibility` is derived from component predicates after the context is created, never by
* `createBlockControlsSurfaceContextForPosition`, so it is not compared.
*/
type ComparedContext = ComparedFields<Omit<BlockControlUIContext, 'controlVisibility'>, 'activeControlKey' | 'activeNode' | 'rootNode' | 'targetNode'>;
/**
* Compares contexts produced by `createBlockControlsSurfaceContextForPosition`. Includes root and
* active-node context because controls can depend on more than the target itself, for example a
* changed containing block or a different active control.
*/
export declare const areBlockControlsSurfaceContextsEqual: (a: ComparedContext, b: ComparedContext) => boolean;
export {};