import * as _udecode_plate_core from '@udecode/plate-core'; import { SlateEditor, TTableCellElement, TTableElement, Path, NodeEntry, TRange, ElementEntry, TElement, Editor, EditorAboveOptions, TLocation, PluginConfig, OmitFirst, Descendant, NormalizeInitialValue, OverrideEditor } from '@udecode/plate'; import { B as BorderDirection, T as TableStoreSizeOverrides, g as getEmptyTableNode, a as getEmptyCellNode, b as getEmptyRowNode, c as getTableCellBorders, d as getTableCellSize, e as getColSpan, f as getRowSpan, i as insertTable, h as insertTableColumn, j as insertTableRow, k as deleteTable, l as deleteColumn, m as deleteRow, n as mergeTableCells, s as splitTableCell, C as CellIndices } from './insertTableRow-CNdYcZsW.js'; export { q as BorderStylesDefault, o as CreateCellOptions, G as GetEmptyRowNodeOptions, p as GetEmptyTableNodeOptions, r as getCellIndices } from './insertTableRow-CNdYcZsW.js'; import * as _udecode_slate from '@udecode/slate'; declare function computeCellIndices(editor: SlateEditor, { all, cellNode, tableNode, }: { all?: boolean; cellNode?: TTableCellElement; tableNode?: TTableElement; }): { col: number; row: number; } | undefined; declare const getCellRowIndexByPath: (cellPath: Path) => number; /** Get td and th types */ declare const getCellTypes: (editor: SlateEditor) => string[]; declare const deleteTableMergeColumn: (editor: SlateEditor) => void; declare const deleteColumnWhenExpanded: (editor: SlateEditor, tableEntry: NodeEntry) => void; declare const deleteTableMergeRow: (editor: SlateEditor) => void; declare const deleteRowWhenExpanded: (editor: SlateEditor, [table, tablePath]: NodeEntry) => void; declare const findCellByIndexes: (editor: SlateEditor, table: TTableElement, searchRowIndex: number, searchColIndex: number) => TTableCellElement | undefined; declare const getCellIndicesWithSpans: ({ col, row }: { col: number; row: number; }, endCell: TTableCellElement) => { col: number; row: number; }; declare const getCellPath: (editor: SlateEditor, tableEntry: NodeEntry, curRowIndex: number, curColIndex: number) => number[]; declare const getSelectionWidth: (cells: T[]) => number; type FormatType = 'all' | 'cell' | 'table'; interface GetTableGridByRangeOptions$1 { at: TRange; /** * Format of the output: * * - Table element * - Array of cells */ format?: T; } type GetTableGridReturnType = T extends 'all' ? TableGridEntries : ElementEntry[]; interface TableGridEntries { cellEntries: ElementEntry[]; tableEntries: ElementEntry[]; } /** * Get sub table between 2 cell paths. Ensure that the selection is always a * valid table grid. */ declare const getTableMergeGridByRange: (editor: SlateEditor, { at, format }: GetTableGridByRangeOptions$1) => GetTableGridReturnType; declare const getTableMergedColumnCount: (tableNode: TElement) => number; declare const insertTableMergeColumn: (editor: SlateEditor, { at, before, fromCell, header, select: shouldSelect, }?: { /** Exact path of the cell to insert the column at. Will overrule `fromCell`. */ at?: Path; /** Insert the column before the current column instead of after */ before?: boolean; /** Path of the cell to insert the column from. */ fromCell?: Path; header?: boolean; select?: boolean; }) => void; declare const insertTableMergeRow: (editor: SlateEditor, { at, before, fromRow, header, select: shouldSelect, }?: { /** Exact path of the row to insert the column at. Will overrule `fromRow`. */ at?: Path; /** Insert the row before the current row instead of after */ before?: boolean; fromRow?: Path; header?: boolean; select?: boolean; }) => void; /** * Checks if the given table is rectangular, meaning all rows have the same * effective number of cells, considering colspan and rowspan. */ declare const isTableRectangular: (table?: TTableElement) => boolean; declare const getCellInNextTableRow: (editor: Editor, currentRowPath: Path) => NodeEntry | undefined; declare const getCellInPreviousTableRow: (editor: Editor, currentRowPath: Path) => NodeEntry | undefined; declare const getLeftTableCell: (editor: SlateEditor, { at: cellPath, }?: { at?: Path; }) => _udecode_slate.NodeEntry | undefined; declare const getNextTableCell: (editor: Editor, currentCell: NodeEntry, currentPath: Path, currentRow: NodeEntry) => NodeEntry | undefined; declare const getPreviousTableCell: (editor: Editor, currentCell: NodeEntry, currentPath: Path, currentRow: NodeEntry) => NodeEntry | undefined; interface GetSelectedCellsBordersOptions { select?: { none?: boolean; outer?: boolean; side?: boolean; }; } interface TableBorderStates { bottom: boolean; left: boolean; none: boolean; outer: boolean; right: boolean; top: boolean; } /** * Get all border states for the selected cells at once. Returns an object with * boolean flags for each border state: * * - Top/bottom/left/right: true if border is visible (size > 0) * - Outer: true if all outer borders are visible * - None: true if all borders are hidden (size === 0) */ declare const getSelectedCellsBorders: (editor: SlateEditor, selectedCells?: TElement[] | null, options?: GetSelectedCellsBordersOptions) => TableBorderStates; /** * Tells if the entire selection is currently borderless (size=0 on all edges). * If **any** edge is > 0, returns false. */ declare function isSelectedCellBordersNone(editor: SlateEditor, cells: TTableCellElement[]): boolean; /** * Tells if the bounding rectangle for the entire selection is fully set for the * **outer** edges, i.e. top/left/bottom/right edges have size=1. We ignore * internal edges, only bounding rectangle edges. */ declare function isSelectedCellBordersOuter(editor: SlateEditor, cells: TTableCellElement[]): boolean; /** * Tells if the bounding rectangle for the entire selection is fully set for * that single side. Example: border='top' => if every cell that sits along the * top boundary has top=1. */ declare function isSelectedCellBorder(editor: SlateEditor, cells: TTableCellElement[], side: BorderDirection): boolean; /** Return bounding box [minRow..maxRow, minCol..maxCol] of all selected cells. */ declare function getSelectedCellsBoundingBox(editor: SlateEditor, cells: TTableCellElement[]): { maxCol: number; maxRow: number; minCol: number; minRow: number; }; declare const getTableAbove: (editor: SlateEditor, options?: EditorAboveOptions) => _udecode_slate.NodeEntry<_udecode_slate.TElement> | undefined; declare const getTableColumnCount: (tableNode: TElement) => number; /** Get table column index of a cell node. */ declare const getTableColumnIndex: (editor: Editor, cellNode: TElement) => number; /** * If at (default = selection) is in table>tr>td|th, return table, row, and cell * node entries. */ declare const getTableEntries: (editor: SlateEditor, { at }?: { at?: TLocation | null; }) => { cell: _udecode_slate.NodeEntry<_udecode_slate.TElement | _udecode_slate.TText>; row: _udecode_slate.NodeEntry<_udecode_slate.TElement | _udecode_slate.Editor<_udecode_slate.Value>>; table: _udecode_slate.NodeEntry<_udecode_slate.TElement | _udecode_slate.Editor<_udecode_slate.Value>>; } | undefined; interface GetTableGridByRangeOptions { at: TRange; /** * Format of the output: * * - Table element * - Array of cells */ format?: 'cell' | 'table'; } /** Get sub table between 2 cell paths. */ declare const getTableGridByRange: (editor: SlateEditor, { at, format }: GetTableGridByRangeOptions) => ElementEntry[]; type GetTableGridAboveOptions = EditorAboveOptions & Pick; /** Get sub table above anchor and focus. Format: tables or cells. */ declare const getTableGridAbove: (editor: SlateEditor, { format, ...options }?: GetTableGridAboveOptions) => ElementEntry[]; /** * Returns node.colSizes if it exists, applying overrides, otherwise returns a * 0-filled array. */ declare const getTableOverriddenColSizes: (tableNode: TTableElement, colSizeOverrides?: TableStoreSizeOverrides) => number[]; /** Get table row index of a cell node. */ declare const getTableRowIndex: (editor: Editor, cellNode: TElement) => number; declare const getTopTableCell: (editor: SlateEditor, { at: cellPath, }?: { at?: Path; }) => _udecode_slate.NodeEntry | undefined; declare const isTableBorderHidden: (editor: SlateEditor, border: BorderDirection) => boolean; /** Move selection by cell unit. */ declare const moveSelectionFromCell: (editor: SlateEditor, { at, edge, fromOneCell, reverse, }?: { at?: TLocation; /** Expand cell selection to an edge. */ edge?: "bottom" | "left" | "right" | "top"; /** Move selection from one selected cell */ fromOneCell?: boolean; /** False: move selection to cell below true: move selection to cell above */ reverse?: boolean; }) => true | undefined; /** * Override the new selection if the previous selection and the new one are in * different cells. */ declare const overrideSelectionFromCell: (editor: SlateEditor, newSelection?: TRange | null) => void; declare const setBorderSize: (editor: SlateEditor, size: number, { at, border, }?: { at?: Path; border?: BorderDirection | "all"; }) => void; declare const setCellBackground: (editor: SlateEditor, options: { color: string | null; selectedCells?: TElement[]; }) => void; declare const setTableColSize: (editor: SlateEditor, { colIndex, width }: { colIndex: number; width: number; }, options?: EditorAboveOptions) => void; declare const setTableMarginLeft: (editor: SlateEditor, { marginLeft }: { marginLeft: number; }, options?: EditorAboveOptions) => void; declare const setTableRowSize: (editor: SlateEditor, { height, rowIndex }: { height: number; rowIndex: number; }, options?: EditorAboveOptions) => void; declare const BaseTableRowPlugin: _udecode_plate_core.SlatePlugin>; declare const BaseTableCellPlugin: _udecode_plate_core.SlatePlugin>; declare const BaseTableCellHeaderPlugin: _udecode_plate_core.SlatePlugin>; type TableConfig = PluginConfig<'table', { /** @private Keeps Track of cell indices by id. */ _cellIndices: Record; /** The currently selected cells. */ selectedCells: TElement[] | null; /** The currently selected tables. */ selectedTables: TElement[] | null; /** Disable expanding the table when inserting cells. */ disableExpandOnInsert?: boolean; disableMarginLeft?: boolean; /** * Disable cell merging functionality. * * @default false */ disableMerge?: boolean; /** * Disable unsetting the first column width when the table has one column. * Set it to true if you want to resize the table width when there is only * one column. Keep it false if you have a full-width table. */ enableUnsetSingleColSize?: boolean; /** * If defined, a normalizer will set each undefined table `colSizes` to this * value divided by the number of columns. Merged cells not supported. */ initialTableWidth?: number; /** * The minimum width of a column. * * @default 48 */ minColumnWidth?: number; }, { create: { table: OmitFirst; /** Cell node factory used each time a cell is created. */ tableCell: OmitFirst; tableRow: OmitFirst; }; table: { getCellBorders: OmitFirst; getCellSize: OmitFirst; getColSpan: typeof getColSpan; getRowSpan: typeof getRowSpan; getCellChildren: (cell: TTableCellElement) => Descendant[]; }; }, { insert: { table: OmitFirst; tableColumn: OmitFirst; tableRow: OmitFirst; }; remove: { table: OmitFirst; tableColumn: OmitFirst; tableRow: OmitFirst; }; table: { merge: OmitFirst; split: OmitFirst; }; }, { cellIndices?: (id: string) => CellIndices; }>; /** Enables support for tables. */ declare const BaseTablePlugin: _udecode_plate_core.SlatePlugin; /** The currently selected cells. */ selectedCells: TElement[] | null; /** The currently selected tables. */ selectedTables: TElement[] | null; /** Disable expanding the table when inserting cells. */ disableExpandOnInsert?: boolean; disableMarginLeft?: boolean; /** * Disable cell merging functionality. * * @default false */ disableMerge?: boolean; /** * Disable unsetting the first column width when the table has one column. * Set it to true if you want to resize the table width when there is only * one column. Keep it false if you have a full-width table. */ enableUnsetSingleColSize?: boolean; /** * If defined, a normalizer will set each undefined table `colSizes` to this * value divided by the number of columns. Merged cells not supported. */ initialTableWidth?: number; /** * The minimum width of a column. * * @default 48 */ minColumnWidth?: number; }, { create: { table: OmitFirst; tableCell: OmitFirst; tableRow: OmitFirst; }; table: { getCellBorders: OmitFirst; getCellSize: OmitFirst; getColSpan: typeof getColSpan; getRowSpan: typeof getRowSpan; getCellChildren: (cell: TTableCellElement) => Descendant[]; }; }, { insert: { table: OmitFirst; tableColumn: OmitFirst; tableRow: OmitFirst; }; remove: { table: OmitFirst; tableColumn: OmitFirst; tableRow: OmitFirst; }; table: { merge: OmitFirst; split: OmitFirst; }; }, { cellIndices?: (id: string) => CellIndices; }>>; declare const KEY_SHIFT_EDGES: { 'shift+down': string; 'shift+left': string; 'shift+right': string; 'shift+up': string; }; declare const normalizeInitialValueTable: NormalizeInitialValue; /** * Selection table: * * - If anchor is in table, focus in a block before: set focus to start of table * - If anchor is in table, focus in a block after: set focus to end of table * - If focus is in table, anchor in a block before: set focus to end of table * - If focus is in table, anchor in a block after: set focus to the point before * start of table */ declare const withApplyTable: OverrideEditor; /** * Return true if: * * - At start/end of a cell. * - Next to a table cell. Move selection to the table cell. */ declare const preventDeleteTableCell: (editor: SlateEditor, { reverse, unit, }: { reverse?: boolean; unit?: "block" | "character" | "line" | "word"; }) => true | undefined; /** Prevent cell deletion. */ declare const withDeleteTable: OverrideEditor; /** If selection is in a table, get subtable above. */ declare const withGetFragmentTable: OverrideEditor; /** * If inserting a table, If block above anchor is a table, * * - Replace each cell above by the inserted table until out of bounds. * - Select the inserted cells. */ declare const withInsertFragmentTable: OverrideEditor; declare const withInsertTextTable: OverrideEditor; declare const withMarkTable: OverrideEditor; /** * Normalize table: * * - Wrap cell children in a paragraph if they are texts. */ declare const withNormalizeTable: OverrideEditor; declare const withSetFragmentDataTable: OverrideEditor; declare const withTable: OverrideEditor; export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, BorderDirection, CellIndices, type GetSelectedCellsBordersOptions, type GetTableGridAboveOptions, type GetTableGridByRangeOptions, KEY_SHIFT_EDGES, type TableBorderStates, type TableConfig, TableStoreSizeOverrides, computeCellIndices, deleteColumn, deleteColumnWhenExpanded, deleteRow, deleteRowWhenExpanded, deleteTable, deleteTableMergeColumn, deleteTableMergeRow, findCellByIndexes, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndicesWithSpans, getCellPath, getCellRowIndexByPath, getCellTypes, getColSpan, getEmptyCellNode, getEmptyRowNode, getEmptyTableNode, getLeftTableCell, getNextTableCell, getPreviousTableCell, getRowSpan, getSelectedCellsBorders, getSelectedCellsBoundingBox, getSelectionWidth, getTableAbove, getTableCellBorders, getTableCellSize, getTableColumnCount, getTableColumnIndex, getTableEntries, getTableGridAbove, getTableGridByRange, getTableMergeGridByRange, getTableMergedColumnCount, getTableOverriddenColSizes, getTableRowIndex, getTopTableCell, insertTable, insertTableColumn, insertTableMergeColumn, insertTableMergeRow, insertTableRow, isSelectedCellBorder, isSelectedCellBordersNone, isSelectedCellBordersOuter, isTableBorderHidden, isTableRectangular, mergeTableCells, moveSelectionFromCell, normalizeInitialValueTable, overrideSelectionFromCell, preventDeleteTableCell, setBorderSize, setCellBackground, setTableColSize, setTableMarginLeft, setTableRowSize, splitTableCell, withApplyTable, withDeleteTable, withGetFragmentTable, withInsertFragmentTable, withInsertTextTable, withMarkTable, withNormalizeTable, withSetFragmentDataTable, withTable };