UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

27 lines (26 loc) 1.26 kB
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model'; /** * 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; }