UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

43 lines (42 loc) 1.96 kB
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model'; type RoundedTableCellEdgeState = { reachesBottom: boolean; reachesLeft: boolean; reachesRight: boolean; reachesTop: boolean; }; /** * Returns the rounded-edge membership for a cell offset. * * The first lookup for a table scans only the TableMap's four borders and caches edge cells. * Interior cells have no cache entry and require no DOM attributes. Subsequent cell nodeview * constructors perform an O(1) lookup. The cache is keyed by the immutable table node, so * structural document changes naturally create a fresh entry. */ export declare const getRoundedTableCellEdgeState: (tableNode: PmNode, cellOffset: number) => RoundedTableCellEdgeState | undefined; /** * Keeps a table's rounded-corner edge attributes in sync as its shape changes. * * Each TableCell node view refreshes its own edge attrs when its cell attrs change. However, * when the table's shape changes (e.g. a new row is inserted below the last row) or cells are * reordered (e.g. dragging a row/column to a new position), ProseMirror may reuse the existing * neighbouring cells as-is, so those cells never get a chance to update their edge attrs on * their own. This controller covers those cases from the table node view. * * Callers are responsible for feature-gating each call site. */ export declare class RoundedTableEdges { private readonly getTableElement; private refreshHandle; private prevSignature; constructor(getTableElement: () => HTMLElement | undefined, node: PmNode); /** * Call from the node view's `update()` after `super.update()`. When the border signature * changes it schedules a refresh of the edge attrs on the next animation frame. */ handleUpdate(node: PmNode): void; /** Call from the node view's `destroy()` to cancel any pending refresh. */ destroy(): void; private scheduleRefresh; } export {};