@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
50 lines (49 loc) • 1.64 kB
TypeScript
import type { Node as PmNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
/**
* Returns an array of column widths (0 if column width is undefined) of a given table node by scanning the **entire table**.
*
* Warning: the entire table is scanned and should only be used if where the table can be in a broken state such that rows have different number of cells (e.g. in **renderer**).
* @param node - Table node
* @example
* ```ts
* const columnWidths = getColumnWidths(tableNode);
* console.log(columnWidths);
* // Output: [100, 200, 300]
* ```
* @returns Array<number>
*/
export declare function getColumnWidths(node: PmNode): number[];
/**
* Returns an array of column widths (0 if column width is undefined) of a given table node by scanning the **first row**.
*
* Warning: is preferred and should be used if the table is not in a broken state (e.g. in **editor**).
* @param node - Table node
* @example
* ```ts
* const columnWidths = calcTableColumnWidths(tableNode);
* console.log(columnWidths);
* // Output: [100, 200, 300]
* ```
* @returns Array<number>
*/
export declare function calcTableColumnWidths(node: PmNode): number[];
/**
*
* @param tableNode
* @example
*/
export declare function hasMergedCell(tableNode: PmNode): boolean;
/**
*
* @param tableNode
* @example
*/
export declare function convertProsemirrorTableNodeToArrayOfRows(tableNode: PmNode): Array<Array<PmNode | null>>;
/**
*
* @param pos
* @param schema
* @param direction
* @example
*/
export declare function isPositionNearTableRow(pos: ResolvedPos, schema: Schema, direction: 'before' | 'after'): boolean;