@lofcz/platejs-table 52.0.11 → 52.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import * as platejs56 from "platejs";
1
2
  import { Descendant, Editor, EditorAboveOptions, ElementEntry, InsertNodesOptions, NodeEntry, NormalizeInitialValue, OmitFirst, OverrideEditor, Path, PluginConfig, SlateEditor, TElement, TLocation, TRange, TTableCellBorder, TTableCellElement, TTableElement, TTableRowElement } from "platejs";
2
3
 
3
4
  //#region src/lib/utils/computeCellIndices.d.ts
@@ -26,7 +27,7 @@ declare const getCellRowIndexByPath: (cellPath: Path) => number;
26
27
  //#endregion
27
28
  //#region src/lib/utils/getCellType.d.ts
28
29
  /** Get td and th types */
29
- declare const getCellTypes: (editor: SlateEditor) => any;
30
+ declare const getCellTypes: (editor: SlateEditor) => string[];
30
31
  //#endregion
31
32
  //#region src/lib/types.d.ts
32
33
  type BorderDirection = 'bottom' | 'left' | 'right' | 'top';
@@ -43,8 +44,8 @@ declare const getEmptyCellNode: (editor: SlateEditor, {
43
44
  header,
44
45
  row
45
46
  }?: CreateCellOptions) => {
46
- children: any[];
47
- type: any;
47
+ children: platejs56.Descendant[];
48
+ type: string;
48
49
  };
49
50
  //#endregion
50
51
  //#region src/lib/api/getEmptyRowNode.d.ts
@@ -55,8 +56,11 @@ declare const getEmptyRowNode: (editor: SlateEditor, {
55
56
  colCount,
56
57
  ...cellOptions
57
58
  }?: GetEmptyRowNodeOptions) => {
58
- children: any[];
59
- type: any;
59
+ children: {
60
+ children: platejs56.Descendant[];
61
+ type: string;
62
+ }[];
63
+ type: string;
60
64
  };
61
65
  //#endregion
62
66
  //#region src/lib/api/getEmptyTableNode.d.ts
@@ -83,7 +87,7 @@ declare const deleteTableMergeRow: (editor: SlateEditor) => void;
83
87
  declare const deleteRowWhenExpanded: (editor: SlateEditor, [table, tablePath]: NodeEntry<TTableCellElement>) => void;
84
88
  //#endregion
85
89
  //#region src/lib/merge/findCellByIndexes.d.ts
86
- declare const findCellByIndexes: (editor: SlateEditor, table: TTableElement, searchRowIndex: number, searchColIndex: number) => any;
90
+ declare const findCellByIndexes: (editor: SlateEditor, table: TTableElement, searchRowIndex: number, searchColIndex: number) => TTableCellElement | undefined;
87
91
  //#endregion
88
92
  //#region src/lib/merge/getCellIndicesWithSpans.d.ts
89
93
  declare const getCellIndicesWithSpans: ({
@@ -98,7 +102,7 @@ declare const getCellIndicesWithSpans: ({
98
102
  };
99
103
  //#endregion
100
104
  //#region src/lib/merge/getCellPath.d.ts
101
- declare const getCellPath: (editor: SlateEditor, tableEntry: NodeEntry<TTableElement>, curRowIndex: number, curColIndex: number) => any;
105
+ declare const getCellPath: (editor: SlateEditor, tableEntry: NodeEntry<TTableElement>, curRowIndex: number, curColIndex: number) => number[];
102
106
  //#endregion
103
107
  //#region src/lib/merge/getSelectionWidth.d.ts
104
108
  declare const getSelectionWidth: <T extends [TTableCellElement, Path]>(cells: T[]) => number;
@@ -130,7 +134,7 @@ declare const getTableMergeGridByRange: <T extends FormatType>(editor: SlateEdit
130
134
  }: GetTableGridByRangeOptions$1<T>) => GetTableGridReturnType<T>;
131
135
  //#endregion
132
136
  //#region src/lib/merge/getTableMergedColumnCount.d.ts
133
- declare const getTableMergedColumnCount: (tableNode: TElement) => any;
137
+ declare const getTableMergedColumnCount: (tableNode: TElement) => number;
134
138
  //#endregion
135
139
  //#region src/lib/merge/insertTableColumn.d.ts
136
140
  declare const insertTableMergeColumn: (editor: SlateEditor, {
@@ -181,6 +185,17 @@ declare const mergeTableCells: (editor: SlateEditor) => void;
181
185
  //#region src/lib/merge/splitTableCell.d.ts
182
186
  declare const splitTableCell: (editor: SlateEditor) => void;
183
187
  //#endregion
188
+ //#region src/lib/queries/getAdjacentTableCell.d.ts
189
+ declare const getAdjacentTableCell: (editor: SlateEditor, {
190
+ at,
191
+ deltaCol,
192
+ deltaRow
193
+ }?: {
194
+ at?: Path;
195
+ deltaCol?: number;
196
+ deltaRow?: number;
197
+ }) => NodeEntry<TTableCellElement> | undefined;
198
+ //#endregion
184
199
  //#region src/lib/queries/getCellInNextTableRow.d.ts
185
200
  declare const getCellInNextTableRow: (editor: Editor, currentRowPath: Path) => NodeEntry | undefined;
186
201
  //#endregion
@@ -193,14 +208,14 @@ declare const getCellInPreviousTableRow: (editor: Editor, currentRowPath: Path)
193
208
  *
194
209
  * @default 1 if undefined.
195
210
  */
196
- declare const getColSpan: (cellElem: TTableCellElement) => any;
211
+ declare const getColSpan: (cellElem: TTableCellElement) => number;
197
212
  //#endregion
198
213
  //#region src/lib/queries/getLeftTableCell.d.ts
199
214
  declare const getLeftTableCell: (editor: SlateEditor, {
200
215
  at: cellPath
201
216
  }?: {
202
217
  at?: Path;
203
- }) => any;
218
+ }) => platejs56.NodeEntry<platejs56.TTableCellElement> | undefined;
204
219
  //#endregion
205
220
  //#region src/lib/queries/getNextTableCell.d.ts
206
221
  declare const getNextTableCell: (editor: Editor, _currentCell: NodeEntry, currentPath: Path, currentRow: NodeEntry) => NodeEntry | undefined;
@@ -214,7 +229,17 @@ declare const getPreviousTableCell: (editor: Editor, _currentCell: NodeEntry, cu
214
229
  *
215
230
  * @default 1 if undefined
216
231
  */
217
- declare const getRowSpan: (cellElem: TTableCellElement) => any;
232
+ declare const getRowSpan: (cellElem: TTableCellElement) => number;
233
+ //#endregion
234
+ //#region src/lib/queries/getSelectedCells.d.ts
235
+ declare const getSelectedCellEntries: (editor: SlateEditor) => ElementEntry[];
236
+ declare const getSelectedCells: (editor: SlateEditor) => TElement[] | null;
237
+ declare const getSelectedCellIds: (editor: SlateEditor) => string[] | null;
238
+ declare const getSelectedTableIds: (editor: SlateEditor) => string[] | null;
239
+ declare const getSelectedCell: (editor: SlateEditor, id?: string | null) => TElement | null;
240
+ declare const getSelectedTables: (editor: SlateEditor) => TElement[] | null;
241
+ declare const isCellSelected: (editor: SlateEditor, id?: string | null) => boolean;
242
+ declare const isSelectingCell: (editor: SlateEditor) => boolean;
218
243
  //#endregion
219
244
  //#region src/lib/queries/getSelectedCellsBorders.d.ts
220
245
  type GetSelectedCellsBordersOptions = {
@@ -269,7 +294,7 @@ declare function getSelectedCellsBoundingBox(editor: SlateEditor, cells: TTableC
269
294
  };
270
295
  //#endregion
271
296
  //#region src/lib/queries/getTableAbove.d.ts
272
- declare const getTableAbove: (editor: SlateEditor, options?: EditorAboveOptions) => any;
297
+ declare const getTableAbove: (editor: SlateEditor, options?: EditorAboveOptions) => platejs56.NodeEntry<platejs56.TElement> | undefined;
273
298
  //#endregion
274
299
  //#region src/lib/queries/getTableCellBorders.d.ts
275
300
  type BorderStylesDefault = {
@@ -301,7 +326,7 @@ declare const getTableCellSize: (editor: SlateEditor, {
301
326
  colSizes?: number[];
302
327
  rowSize?: number;
303
328
  }) => {
304
- minHeight: number | undefined;
329
+ minHeight: number;
305
330
  width: number;
306
331
  };
307
332
  //#endregion
@@ -322,9 +347,9 @@ declare const getTableEntries: (editor: SlateEditor, {
322
347
  }?: {
323
348
  at?: TLocation | null;
324
349
  }) => {
325
- cell: any;
326
- row: any;
327
- table: any;
350
+ cell: platejs56.NodeEntry<platejs56.TElement | platejs56.TText>;
351
+ row: platejs56.NodeEntry<platejs56.TElement | platejs56.Editor<platejs56.Value>>;
352
+ table: platejs56.NodeEntry<platejs56.TElement | platejs56.Editor<platejs56.Value>>;
328
353
  } | undefined;
329
354
  //#endregion
330
355
  //#region src/lib/queries/getTableGridByRange.d.ts
@@ -361,14 +386,14 @@ declare const getTableOverriddenColSizes: (tableNode: TTableElement, colSizeOver
361
386
  //#endregion
362
387
  //#region src/lib/queries/getTableRowIndex.d.ts
363
388
  /** Get table row index of a cell node. */
364
- declare const getTableRowIndex: (editor: Editor, cellNode: TElement) => any;
389
+ declare const getTableRowIndex: (editor: Editor, cellNode: TElement) => number;
365
390
  //#endregion
366
391
  //#region src/lib/queries/getTopTableCell.d.ts
367
392
  declare const getTopTableCell: (editor: SlateEditor, {
368
393
  at: cellPath
369
394
  }?: {
370
395
  at?: Path;
371
- }) => any;
396
+ }) => platejs56.NodeEntry<platejs56.TTableCellElement> | undefined;
372
397
  //#endregion
373
398
  //#region src/lib/queries/isTableBorderHidden.d.ts
374
399
  declare const isTableBorderHidden: (editor: SlateEditor, border: BorderDirection) => boolean;
@@ -439,13 +464,6 @@ declare const moveSelectionFromCell: (editor: SlateEditor, {
439
464
  reverse?: boolean;
440
465
  }) => true | undefined;
441
466
  //#endregion
442
- //#region src/lib/transforms/overrideSelectionFromCell.d.ts
443
- /**
444
- * Override the new selection if the previous selection and the new one are in
445
- * different cells.
446
- */
447
- declare const overrideSelectionFromCell: (editor: SlateEditor, newSelection?: TRange | null) => void;
448
- //#endregion
449
467
  //#region src/lib/transforms/setBorderSize.d.ts
450
468
  declare const setBorderSize: (editor: SlateEditor, size: number, {
451
469
  at,
@@ -486,19 +504,55 @@ declare const setTableRowSize: (editor: SlateEditor, {
486
504
  rowIndex: number;
487
505
  }, options?: EditorAboveOptions) => void;
488
506
  //#endregion
507
+ //#region src/lib/transforms/shouldMoveSelectionFromCell.d.ts
508
+ type TableMoveSelectionContext = {
509
+ blockPath: number[];
510
+ cellPath: number[];
511
+ point: {
512
+ offset: number;
513
+ path: number[];
514
+ };
515
+ };
516
+ declare const getTableMoveSelectionContext: (editor: SlateEditor, point?: platejs56.Point | undefined) => TableMoveSelectionContext | undefined;
517
+ declare const hasAdjacentBlockInCell: (editor: SlateEditor, {
518
+ blockPath,
519
+ cellPath,
520
+ reverse
521
+ }: Pick<TableMoveSelectionContext, "blockPath" | "cellPath"> & {
522
+ reverse: boolean;
523
+ }) => boolean;
524
+ declare const shouldMoveSelectionFromCell: (editor: SlateEditor, {
525
+ blockPath,
526
+ point,
527
+ reverse
528
+ }: {
529
+ blockPath: number[];
530
+ point: {
531
+ offset: number;
532
+ path: number[];
533
+ };
534
+ reverse: boolean;
535
+ }) => boolean;
536
+ //#endregion
489
537
  //#region src/lib/BaseTablePlugin.d.ts
490
- declare const BaseTableRowPlugin: any;
491
- declare const BaseTableCellPlugin: any;
492
- declare const BaseTableCellHeaderPlugin: any;
538
+ declare const BaseTableRowPlugin: platejs56.SlatePlugin<PluginConfig<"tr", {}, {}, {}, {}>>;
539
+ declare const BaseTableCellPlugin: platejs56.SlatePlugin<PluginConfig<"td", {}, {}, {}, {}>>;
540
+ declare const BaseTableCellHeaderPlugin: platejs56.SlatePlugin<PluginConfig<"th", {}, {}, {}, {}>>;
493
541
  type TableConfig = PluginConfig<'table', {
494
542
  /** @private Keeps Track of cell indices by id. */
495
543
  _cellIndices: Record<string, {
496
544
  col: number;
497
545
  row: number;
498
546
  }>;
499
- /** The currently selected cells. */
547
+ /** @private Keeps track of selected cell ids for cheap membership checks. */
548
+ _selectedCellIds: string[] | null | undefined;
549
+ /** @private Keeps track of selected table ids for cheap table checks. */
550
+ _selectedTableIds: string[] | null | undefined;
551
+ /** @private Forces selection-derived selectors to refresh. */
552
+ _selectionVersion: number;
553
+ /** Legacy selector key. Selected cells are derived from editor selection. */
500
554
  selectedCells: TElement[] | null;
501
- /** The currently selected tables. */
555
+ /** Legacy selector key. Selected tables are derived from editor selection. */
502
556
  selectedTables: TElement[] | null;
503
557
  /** Disable expanding the table when inserting cells. */
504
558
  disableExpandOnInsert?: boolean;
@@ -536,9 +590,16 @@ type TableConfig = PluginConfig<'table', {
536
590
  table: {
537
591
  getCellBorders: OmitFirst<typeof getTableCellBorders>;
538
592
  getCellSize: OmitFirst<typeof getTableCellSize>;
593
+ getSelectedCell: OmitFirst<typeof getSelectedCell>;
594
+ getSelectedCellIds: OmitFirst<typeof getSelectedCellIds>;
595
+ getSelectedCells: OmitFirst<typeof getSelectedCells>;
596
+ getSelectedTableIds: OmitFirst<typeof getSelectedTableIds>;
597
+ getSelectedTables: OmitFirst<typeof getSelectedTables>;
539
598
  getColSpan: typeof getColSpan;
540
599
  getRowSpan: typeof getRowSpan;
541
600
  getCellChildren: (cell: TTableCellElement) => Descendant[];
601
+ isCellSelected: OmitFirst<typeof isCellSelected>;
602
+ isSelectingCell: OmitFirst<typeof isSelectingCell>;
542
603
  };
543
604
  }, {
544
605
  insert: {
@@ -557,9 +618,102 @@ type TableConfig = PluginConfig<'table', {
557
618
  };
558
619
  }, {
559
620
  cellIndices?: (id: string) => CellIndices;
621
+ isCellSelected?: (id?: string | null) => boolean;
622
+ isSelectingCell?: () => boolean;
623
+ selectedCell?: (id?: string | null) => TElement | null;
624
+ selectedCellIds?: () => string[] | null;
625
+ selectedCells?: () => TElement[] | null;
626
+ selectedTableIds?: () => string[] | null;
627
+ selectedTables?: () => TElement[] | null;
560
628
  }>;
561
629
  /** Enables support for tables. */
562
- declare const BaseTablePlugin: any;
630
+ declare const BaseTablePlugin: platejs56.SlatePlugin<PluginConfig<"table", {
631
+ /** @private Keeps Track of cell indices by id. */
632
+ _cellIndices: Record<string, {
633
+ col: number;
634
+ row: number;
635
+ }>;
636
+ /** @private Keeps track of selected cell ids for cheap membership checks. */
637
+ _selectedCellIds: string[] | null | undefined;
638
+ /** @private Keeps track of selected table ids for cheap table checks. */
639
+ _selectedTableIds: string[] | null | undefined;
640
+ /** @private Forces selection-derived selectors to refresh. */
641
+ _selectionVersion: number;
642
+ /** Legacy selector key. Selected cells are derived from editor selection. */
643
+ selectedCells: TElement[] | null;
644
+ /** Legacy selector key. Selected tables are derived from editor selection. */
645
+ selectedTables: TElement[] | null;
646
+ /** Disable expanding the table when inserting cells. */
647
+ disableExpandOnInsert?: boolean;
648
+ disableMarginLeft?: boolean;
649
+ /**
650
+ * Disable cell merging functionality.
651
+ *
652
+ * @default false
653
+ */
654
+ disableMerge?: boolean;
655
+ /**
656
+ * Disable unsetting the first column width when the table has one column.
657
+ * Set it to true if you want to resize the table width when there is only
658
+ * one column. Keep it false if you have a full-width table.
659
+ */
660
+ enableUnsetSingleColSize?: boolean;
661
+ /**
662
+ * If defined, a normalizer will set each undefined table `colSizes` to this
663
+ * value divided by the number of columns. Merged cells not supported.
664
+ */
665
+ initialTableWidth?: number;
666
+ /**
667
+ * The minimum width of a column.
668
+ *
669
+ * @default 48
670
+ */
671
+ minColumnWidth?: number;
672
+ }, {
673
+ create: {
674
+ table: OmitFirst<typeof getEmptyTableNode>;
675
+ tableCell: OmitFirst<typeof getEmptyCellNode>;
676
+ tableRow: OmitFirst<typeof getEmptyRowNode>;
677
+ };
678
+ table: {
679
+ getCellBorders: OmitFirst<typeof getTableCellBorders>;
680
+ getCellSize: OmitFirst<typeof getTableCellSize>;
681
+ getSelectedCell: OmitFirst<typeof getSelectedCell>;
682
+ getSelectedCellIds: OmitFirst<typeof getSelectedCellIds>;
683
+ getSelectedCells: OmitFirst<typeof getSelectedCells>;
684
+ getSelectedTableIds: OmitFirst<typeof getSelectedTableIds>;
685
+ getSelectedTables: OmitFirst<typeof getSelectedTables>;
686
+ getColSpan: typeof getColSpan;
687
+ getRowSpan: typeof getRowSpan;
688
+ getCellChildren: (cell: TTableCellElement) => Descendant[];
689
+ isCellSelected: OmitFirst<typeof isCellSelected>;
690
+ isSelectingCell: OmitFirst<typeof isSelectingCell>;
691
+ };
692
+ }, {
693
+ insert: {
694
+ table: OmitFirst<typeof insertTable>;
695
+ tableColumn: OmitFirst<typeof insertTableColumn>;
696
+ tableRow: OmitFirst<typeof insertTableRow>;
697
+ };
698
+ remove: {
699
+ table: OmitFirst<typeof deleteTable>;
700
+ tableColumn: OmitFirst<typeof deleteColumn>;
701
+ tableRow: OmitFirst<typeof deleteRow>;
702
+ };
703
+ table: {
704
+ merge: OmitFirst<typeof mergeTableCells>;
705
+ split: OmitFirst<typeof splitTableCell>;
706
+ };
707
+ }, {
708
+ cellIndices?: (id: string) => CellIndices;
709
+ isCellSelected?: (id?: string | null) => boolean;
710
+ isSelectingCell?: () => boolean;
711
+ selectedCell?: (id?: string | null) => TElement | null;
712
+ selectedCellIds?: () => string[] | null;
713
+ selectedCells?: () => TElement[] | null;
714
+ selectedTableIds?: () => string[] | null;
715
+ selectedTables?: () => TElement[] | null;
716
+ }>>;
563
717
  //#endregion
564
718
  //#region src/lib/constants.d.ts
565
719
  declare const KEY_SHIFT_EDGES: {
@@ -634,5 +788,4 @@ declare const withTable: OverrideEditor<TableConfig>;
634
788
  //#region src/lib/withTableCellSelection.d.ts
635
789
  declare const withTableCellSelection: OverrideEditor<TableConfig>;
636
790
  //#endregion
637
- export { getRowSpan as $, deleteColumn as A, getCellRowIndexByPath as At, getTableColumnIndex as B, overrideSelectionFromCell as C, GetEmptyRowNodeOptions as Ct, insertTable as D, CreateCellOptions as Dt, insertTableColumn as E, BorderDirection as Et, GetTableGridAboveOptions as F, getTableAbove as G, getTableCellSize as H, getTableGridAbove as I, TableBorderStates as J, getSelectedCellsBoundingBox as K, GetTableGridByRangeOptions as L, getTopTableCell as M, getCellIndices as Mt, getTableRowIndex as N, computeCellIndices as Nt, deleteTable as O, TableStoreSizeOverrides as Ot, getTableOverriddenColSizes as P, isSelectedCellBordersOuter as Q, getTableGridByRange as R, setBorderSize as S, getEmptyTableNode as St, insertTableRow as T, getEmptyCellNode as Tt, BorderStylesDefault as U, getTableColumnCount as V, getTableCellBorders as W, isSelectedCellBorder as X, getSelectedCellsBorders as Y, isSelectedCellBordersNone as Z, TableConfig as _, deleteRowWhenExpanded as _t, withInsertTextTable as a, getCellInNextTableRow as at, setTableColSize as b, deleteTableMergeColumn as bt, preventDeleteTableCell as c, isTableRectangular as ct, normalizeInitialValueTable as d, getTableMergedColumnCount as dt, getPreviousTableCell as et, KEY_SHIFT_EDGES as f, getTableMergeGridByRange as ft, BaseTableRowPlugin as g, findCellByIndexes as gt, BaseTablePlugin as h, getCellIndicesWithSpans as ht, withNormalizeTable as i, getCellInPreviousTableRow as it, isTableBorderHidden as j, CellIndices as jt, deleteRow as k, getCellTypes as kt, withDeleteTable as l, insertTableMergeRow as lt, BaseTableCellPlugin as m, getCellPath as mt, withTable as n, getLeftTableCell as nt, withInsertFragmentTable as o, splitTableCell as ot, BaseTableCellHeaderPlugin as p, getSelectionWidth as pt, GetSelectedCellsBordersOptions as q, withSetFragmentDataTable as r, getColSpan as rt, withGetFragmentTable as s, mergeTableCells as st, withTableCellSelection as t, getNextTableCell as tt, withApplyTable as u, insertTableMergeColumn as ut, setTableRowSize as v, deleteTableMergeRow as vt, moveSelectionFromCell as w, getEmptyRowNode as wt, setCellBackground as x, GetEmptyTableNodeOptions as xt, setTableMarginLeft as y, deleteColumnWhenExpanded as yt, getTableEntries as z };
638
- //# sourceMappingURL=index-CbSGuAlP.d.ts.map
791
+ export { isSelectedCellBorder as $, insertTable as A, deleteTableMergeRow as At, GetTableGridByRangeOptions as B, TableStoreSizeOverrides as Bt, setTableMarginLeft as C, getTableMergedColumnCount as Ct, moveSelectionFromCell as D, getCellIndicesWithSpans as Dt, setBorderSize as E, getCellPath as Et, getTopTableCell as F, GetEmptyRowNodeOptions as Ft, getTableCellSize as G, computeCellIndices as Gt, getTableEntries as H, getCellRowIndexByPath as Ht, getTableRowIndex as I, getEmptyRowNode as It, getTableAbove as J, BorderStylesDefault as K, getTableOverriddenColSizes as L, getEmptyCellNode as Lt, deleteRow as M, deleteTableMergeColumn as Mt, deleteColumn as N, GetEmptyTableNodeOptions as Nt, insertTableRow as O, findCellByIndexes as Ot, isTableBorderHidden as P, getEmptyTableNode as Pt, getSelectedCellsBorders as Q, GetTableGridAboveOptions as R, BorderDirection as Rt, setTableRowSize as S, insertTableMergeColumn as St, setCellBackground as T, getSelectionWidth as Tt, getTableColumnIndex as U, CellIndices as Ut, getTableGridByRange as V, getCellTypes as Vt, getTableColumnCount as W, getCellIndices as Wt, GetSelectedCellsBordersOptions as X, getSelectedCellsBoundingBox as Y, TableBorderStates as Z, TableConfig as _, getAdjacentTableCell as _t, withInsertTextTable as a, getSelectedCells as at, hasAdjacentBlockInCell as b, isTableRectangular as bt, preventDeleteTableCell as c, isCellSelected as ct, normalizeInitialValueTable as d, getPreviousTableCell as dt, isSelectedCellBordersNone as et, KEY_SHIFT_EDGES as f, getNextTableCell as ft, BaseTableRowPlugin as g, getCellInNextTableRow as gt, BaseTablePlugin as h, getCellInPreviousTableRow as ht, withNormalizeTable as i, getSelectedCellIds as it, deleteTable as j, deleteColumnWhenExpanded as jt, insertTableColumn as k, deleteRowWhenExpanded as kt, withDeleteTable as l, isSelectingCell as lt, BaseTableCellPlugin as m, getColSpan as mt, withTable as n, getSelectedCell as nt, withInsertFragmentTable as o, getSelectedTableIds as ot, BaseTableCellHeaderPlugin as p, getLeftTableCell as pt, getTableCellBorders as q, withSetFragmentDataTable as r, getSelectedCellEntries as rt, withGetFragmentTable as s, getSelectedTables as st, withTableCellSelection as t, isSelectedCellBordersOuter as tt, withApplyTable as u, getRowSpan as ut, TableMoveSelectionContext as v, splitTableCell as vt, setTableColSize as w, getTableMergeGridByRange as wt, shouldMoveSelectionFromCell as x, insertTableMergeRow as xt, getTableMoveSelectionContext as y, mergeTableCells as yt, getTableGridAbove as z, CreateCellOptions as zt };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as getRowSpan, A as deleteColumn, At as getCellRowIndexByPath, B as getTableColumnIndex, C as overrideSelectionFromCell, Ct as GetEmptyRowNodeOptions, D as insertTable, Dt as CreateCellOptions, E as insertTableColumn, Et as BorderDirection, F as GetTableGridAboveOptions, G as getTableAbove, H as getTableCellSize, I as getTableGridAbove, J as TableBorderStates, K as getSelectedCellsBoundingBox, L as GetTableGridByRangeOptions, M as getTopTableCell, Mt as getCellIndices, N as getTableRowIndex, Nt as computeCellIndices, O as deleteTable, Ot as TableStoreSizeOverrides, P as getTableOverriddenColSizes, Q as isSelectedCellBordersOuter, R as getTableGridByRange, S as setBorderSize, St as getEmptyTableNode, T as insertTableRow, Tt as getEmptyCellNode, U as BorderStylesDefault, V as getTableColumnCount, W as getTableCellBorders, X as isSelectedCellBorder, Y as getSelectedCellsBorders, Z as isSelectedCellBordersNone, _ as TableConfig, _t as deleteRowWhenExpanded, a as withInsertTextTable, at as getCellInNextTableRow, b as setTableColSize, bt as deleteTableMergeColumn, c as preventDeleteTableCell, ct as isTableRectangular, d as normalizeInitialValueTable, dt as getTableMergedColumnCount, et as getPreviousTableCell, f as KEY_SHIFT_EDGES, ft as getTableMergeGridByRange, g as BaseTableRowPlugin, gt as findCellByIndexes, h as BaseTablePlugin, ht as getCellIndicesWithSpans, i as withNormalizeTable, it as getCellInPreviousTableRow, j as isTableBorderHidden, jt as CellIndices, k as deleteRow, kt as getCellTypes, l as withDeleteTable, lt as insertTableMergeRow, m as BaseTableCellPlugin, mt as getCellPath, n as withTable, nt as getLeftTableCell, o as withInsertFragmentTable, ot as splitTableCell, p as BaseTableCellHeaderPlugin, pt as getSelectionWidth, q as GetSelectedCellsBordersOptions, r as withSetFragmentDataTable, rt as getColSpan, s as withGetFragmentTable, st as mergeTableCells, t as withTableCellSelection, tt as getNextTableCell, u as withApplyTable, ut as insertTableMergeColumn, v as setTableRowSize, vt as deleteTableMergeRow, w as moveSelectionFromCell, wt as getEmptyRowNode, x as setCellBackground, xt as GetEmptyTableNodeOptions, y as setTableMarginLeft, yt as deleteColumnWhenExpanded, z as getTableEntries } from "./index-CbSGuAlP";
2
- export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, BorderDirection, BorderStylesDefault, CellIndices, CreateCellOptions, GetEmptyRowNodeOptions, GetEmptyTableNodeOptions, GetSelectedCellsBordersOptions, GetTableGridAboveOptions, GetTableGridByRangeOptions, KEY_SHIFT_EDGES, TableBorderStates, TableConfig, TableStoreSizeOverrides, computeCellIndices, deleteColumn, deleteColumnWhenExpanded, deleteRow, deleteRowWhenExpanded, deleteTable, deleteTableMergeColumn, deleteTableMergeRow, findCellByIndexes, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, 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, withNormalizeTable, withSetFragmentDataTable, withTable, withTableCellSelection };
1
+ import { $ as isSelectedCellBorder, A as insertTable, At as deleteTableMergeRow, B as GetTableGridByRangeOptions, Bt as TableStoreSizeOverrides, C as setTableMarginLeft, Ct as getTableMergedColumnCount, D as moveSelectionFromCell, Dt as getCellIndicesWithSpans, E as setBorderSize, Et as getCellPath, F as getTopTableCell, Ft as GetEmptyRowNodeOptions, G as getTableCellSize, Gt as computeCellIndices, H as getTableEntries, Ht as getCellRowIndexByPath, I as getTableRowIndex, It as getEmptyRowNode, J as getTableAbove, K as BorderStylesDefault, L as getTableOverriddenColSizes, Lt as getEmptyCellNode, M as deleteRow, Mt as deleteTableMergeColumn, N as deleteColumn, Nt as GetEmptyTableNodeOptions, O as insertTableRow, Ot as findCellByIndexes, P as isTableBorderHidden, Pt as getEmptyTableNode, Q as getSelectedCellsBorders, R as GetTableGridAboveOptions, Rt as BorderDirection, S as setTableRowSize, St as insertTableMergeColumn, T as setCellBackground, Tt as getSelectionWidth, U as getTableColumnIndex, Ut as CellIndices, V as getTableGridByRange, Vt as getCellTypes, W as getTableColumnCount, Wt as getCellIndices, X as GetSelectedCellsBordersOptions, Y as getSelectedCellsBoundingBox, Z as TableBorderStates, _ as TableConfig, _t as getAdjacentTableCell, a as withInsertTextTable, at as getSelectedCells, b as hasAdjacentBlockInCell, bt as isTableRectangular, c as preventDeleteTableCell, ct as isCellSelected, d as normalizeInitialValueTable, dt as getPreviousTableCell, et as isSelectedCellBordersNone, f as KEY_SHIFT_EDGES, ft as getNextTableCell, g as BaseTableRowPlugin, gt as getCellInNextTableRow, h as BaseTablePlugin, ht as getCellInPreviousTableRow, i as withNormalizeTable, it as getSelectedCellIds, j as deleteTable, jt as deleteColumnWhenExpanded, k as insertTableColumn, kt as deleteRowWhenExpanded, l as withDeleteTable, lt as isSelectingCell, m as BaseTableCellPlugin, mt as getColSpan, n as withTable, nt as getSelectedCell, o as withInsertFragmentTable, ot as getSelectedTableIds, p as BaseTableCellHeaderPlugin, pt as getLeftTableCell, q as getTableCellBorders, r as withSetFragmentDataTable, rt as getSelectedCellEntries, s as withGetFragmentTable, st as getSelectedTables, t as withTableCellSelection, tt as isSelectedCellBordersOuter, u as withApplyTable, ut as getRowSpan, v as TableMoveSelectionContext, vt as splitTableCell, w as setTableColSize, wt as getTableMergeGridByRange, x as shouldMoveSelectionFromCell, xt as insertTableMergeRow, y as getTableMoveSelectionContext, yt as mergeTableCells, z as getTableGridAbove, zt as CreateCellOptions } from "./index-CU48xuSN";
2
+ export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, BorderDirection, BorderStylesDefault, CellIndices, CreateCellOptions, GetEmptyRowNodeOptions, GetEmptyTableNodeOptions, GetSelectedCellsBordersOptions, GetTableGridAboveOptions, GetTableGridByRangeOptions, KEY_SHIFT_EDGES, TableBorderStates, TableConfig, TableMoveSelectionContext, TableStoreSizeOverrides, computeCellIndices, deleteColumn, deleteColumnWhenExpanded, deleteRow, deleteRowWhenExpanded, deleteTable, deleteTableMergeColumn, deleteTableMergeRow, findCellByIndexes, getAdjacentTableCell, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, getCellIndicesWithSpans, getCellPath, getCellRowIndexByPath, getCellTypes, getColSpan, getEmptyCellNode, getEmptyRowNode, getEmptyTableNode, getLeftTableCell, getNextTableCell, getPreviousTableCell, getRowSpan, getSelectedCell, getSelectedCellEntries, getSelectedCellIds, getSelectedCells, getSelectedCellsBorders, getSelectedCellsBoundingBox, getSelectedTableIds, getSelectedTables, getSelectionWidth, getTableAbove, getTableCellBorders, getTableCellSize, getTableColumnCount, getTableColumnIndex, getTableEntries, getTableGridAbove, getTableGridByRange, getTableMergeGridByRange, getTableMergedColumnCount, getTableMoveSelectionContext, getTableOverriddenColSizes, getTableRowIndex, getTopTableCell, hasAdjacentBlockInCell, insertTable, insertTableColumn, insertTableMergeColumn, insertTableMergeRow, insertTableRow, isCellSelected, isSelectedCellBorder, isSelectedCellBordersNone, isSelectedCellBordersOuter, isSelectingCell, isTableBorderHidden, isTableRectangular, mergeTableCells, moveSelectionFromCell, normalizeInitialValueTable, preventDeleteTableCell, setBorderSize, setCellBackground, setTableColSize, setTableMarginLeft, setTableRowSize, shouldMoveSelectionFromCell, splitTableCell, withApplyTable, withDeleteTable, withGetFragmentTable, withInsertFragmentTable, withInsertTextTable, withNormalizeTable, withSetFragmentDataTable, withTable, withTableCellSelection };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as isSelectedCellBordersNone, A as mergeTableCells, B as getTableOverriddenColSizes, C as insertTableColumn, D as deleteColumn, E as deleteRow, F as deleteTableMergeRow, G as getCellIndicesWithSpans, H as getTableGridByRange, I as deleteRowWhenExpanded, J as getTableCellSize, K as getTableEntries, L as deleteTableMergeColumn, M as insertTableMergeRow, N as insertTableMergeColumn, O as normalizeInitialValueTable, P as getTableMergedColumnCount, Q as isSelectedCellBorder, R as getCellPath, S as insertTableRow, T as deleteTable, U as getTableMergeGridByRange, V as getTableGridAbove, W as findCellByIndexes, X as getTableAbove, Y as getTableCellBorders, Z as getSelectedCellsBorders, _ as setTableMarginLeft, a as BaseTableRowPlugin, at as getNextTableCell, b as overrideSelectionFromCell, c as withSetFragmentDataTable, ct as getCellRowIndexByPath, d as withInsertFragmentTable, dt as getColSpan, et as isSelectedCellBordersOuter, f as withGetFragmentTable, ft as getCellInPreviousTableRow, g as setTableRowSize, gt as getEmptyCellNode, h as withApplyTable, ht as getEmptyRowNode, i as BaseTablePlugin, it as getPreviousTableCell, j as isTableRectangular, k as splitTableCell, l as withNormalizeTable, lt as getCellIndices, m as withDeleteTable, mt as getEmptyTableNode, n as BaseTableCellHeaderPlugin, nt as getSelectedCellsBoundingBox, o as withTable, ot as getLeftTableCell, p as preventDeleteTableCell, pt as getCellInNextTableRow, q as getTableColumnCount, r as BaseTableCellPlugin, rt as getRowSpan, s as withTableCellSelection, st as getCellTypes, t as KEY_SHIFT_EDGES, tt as getTopTableCell, u as withInsertTextTable, ut as computeCellIndices, v as setTableColSize, w as insertTable, x as moveSelectionFromCell, y as setBorderSize, z as deleteColumnWhenExpanded } from "./constants-B6Sm9BNa.js";
1
+ import { $ as getSelectedCellEntries, A as normalizeInitialValueTable, B as deleteColumnWhenExpanded, C as moveSelectionFromCell, Ct as getColSpan, D as deleteTable, E as insertTable, Et as getEmptyCellNode, F as getTableMergedColumnCount, G as getTableAbove, H as getTableColumnCount, I as deleteTableMergeRow, J as isSelectedCellBordersNone, K as getSelectedCellsBorders, L as deleteRowWhenExpanded, M as mergeTableCells, N as insertTableMergeRow, O as deleteRow, P as insertTableMergeColumn, Q as getSelectedCell, R as deleteTableMergeColumn, S as setBorderSize, St as getRowSpan, T as insertTableColumn, Tt as getEmptyRowNode, U as getTableCellSize, V as getTableOverriddenColSizes, W as getTableCellBorders, X as getTopTableCell, Y as isSelectedCellBordersOuter, Z as getSelectedCellsBoundingBox, _ as hasAdjacentBlockInCell, _t as getCellTypes, a as BaseTableRowPlugin, at as isSelectingCell, b as setTableMarginLeft, bt as computeCellIndices, c as withSetFragmentDataTable, ct as getTableMergeGridByRange, d as withInsertFragmentTable, dt as getNextTableCell, et as getSelectedCellIds, f as withGetFragmentTable, ft as getLeftTableCell, g as getTableMoveSelectionContext, gt as getTableEntries, h as withApplyTable, ht as getAdjacentTableCell, i as BaseTablePlugin, it as isCellSelected, j as splitTableCell, k as deleteColumn, l as withNormalizeTable, lt as findCellByIndexes, m as withDeleteTable, mt as getCellInNextTableRow, n as BaseTableCellHeaderPlugin, nt as getSelectedTableIds, o as withTable, ot as getTableGridAbove, p as preventDeleteTableCell, pt as getCellInPreviousTableRow, q as isSelectedCellBorder, r as BaseTableCellPlugin, rt as getSelectedTables, s as withTableCellSelection, st as getTableGridByRange, t as KEY_SHIFT_EDGES, tt as getSelectedCells, u as withInsertTextTable, ut as getPreviousTableCell, v as shouldMoveSelectionFromCell, vt as getCellRowIndexByPath, w as insertTableRow, wt as getEmptyTableNode, x as setTableColSize, xt as getCellIndicesWithSpans, y as setTableRowSize, yt as getCellIndices, z as getCellPath } from "./constants-DGdhsla3.js";
2
2
  import { PathApi } from "platejs";
3
3
 
4
4
  //#region src/lib/queries/getTableColumnIndex.ts
@@ -50,18 +50,39 @@ const getSelectionWidth = (cells) => {
50
50
  let total = 0;
51
51
  cells.forEach(([cell, cellPath]) => {
52
52
  const currentCellRowIndex = getCellRowIndexByPath(cellPath);
53
- if (currentCellRowIndex === lastCellRowIndex) {
54
- const colSpan = cell.colSpan ?? cell.attributes?.colspan;
55
- total += colSpan ? Number(colSpan) : 1;
56
- } else {
53
+ const colSpan = cell.colSpan ?? cell.attributes?.colspan;
54
+ const colSpanNumbered = colSpan ? Number(colSpan) : 1;
55
+ if (currentCellRowIndex === lastCellRowIndex) total += colSpanNumbered;
56
+ else {
57
57
  max = Math.max(total, max);
58
- total = 0;
58
+ total = colSpanNumbered;
59
59
  }
60
60
  lastCellRowIndex = currentCellRowIndex;
61
61
  });
62
62
  return Math.max(total, max);
63
63
  };
64
64
 
65
+ //#endregion
66
+ //#region src/lib/merge/isTableRectangular.ts
67
+ const allEqual = (arr) => arr.every((val) => val === arr[0]);
68
+ /**
69
+ * Checks if the given table is rectangular, meaning all rows have the same
70
+ * effective number of cells, considering colspan and rowspan.
71
+ */
72
+ const isTableRectangular = (table) => {
73
+ const arr = [];
74
+ table?.children?.forEach((row, rI) => {
75
+ row.children?.forEach((cell) => {
76
+ const cellElem = cell;
77
+ Array.from({ length: getRowSpan(cellElem) || 1 }).forEach((_, i) => {
78
+ if (!arr[rI + i]) arr[rI + i] = 0;
79
+ arr[rI + i] += getColSpan(cellElem);
80
+ });
81
+ });
82
+ });
83
+ return allEqual(arr);
84
+ };
85
+
65
86
  //#endregion
66
87
  //#region src/lib/transforms/setCellBackground.ts
67
88
  const setCellBackground = (editor, options) => {
@@ -81,5 +102,4 @@ const setCellBackground = (editor, options) => {
81
102
  };
82
103
 
83
104
  //#endregion
84
- export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, KEY_SHIFT_EDGES, computeCellIndices, deleteColumn, deleteColumnWhenExpanded, deleteRow, deleteRowWhenExpanded, deleteTable, deleteTableMergeColumn, deleteTableMergeRow, findCellByIndexes, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, 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, withNormalizeTable, withSetFragmentDataTable, withTable, withTableCellSelection };
85
- //# sourceMappingURL=index.js.map
105
+ export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, KEY_SHIFT_EDGES, computeCellIndices, deleteColumn, deleteColumnWhenExpanded, deleteRow, deleteRowWhenExpanded, deleteTable, deleteTableMergeColumn, deleteTableMergeRow, findCellByIndexes, getAdjacentTableCell, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, getCellIndicesWithSpans, getCellPath, getCellRowIndexByPath, getCellTypes, getColSpan, getEmptyCellNode, getEmptyRowNode, getEmptyTableNode, getLeftTableCell, getNextTableCell, getPreviousTableCell, getRowSpan, getSelectedCell, getSelectedCellEntries, getSelectedCellIds, getSelectedCells, getSelectedCellsBorders, getSelectedCellsBoundingBox, getSelectedTableIds, getSelectedTables, getSelectionWidth, getTableAbove, getTableCellBorders, getTableCellSize, getTableColumnCount, getTableColumnIndex, getTableEntries, getTableGridAbove, getTableGridByRange, getTableMergeGridByRange, getTableMergedColumnCount, getTableMoveSelectionContext, getTableOverriddenColSizes, getTableRowIndex, getTopTableCell, hasAdjacentBlockInCell, insertTable, insertTableColumn, insertTableMergeColumn, insertTableMergeRow, insertTableRow, isCellSelected, isSelectedCellBorder, isSelectedCellBordersNone, isSelectedCellBordersOuter, isSelectingCell, isTableBorderHidden, isTableRectangular, mergeTableCells, moveSelectionFromCell, normalizeInitialValueTable, preventDeleteTableCell, setBorderSize, setCellBackground, setTableColSize, setTableMarginLeft, setTableRowSize, shouldMoveSelectionFromCell, splitTableCell, withApplyTable, withDeleteTable, withGetFragmentTable, withInsertFragmentTable, withInsertTextTable, withNormalizeTable, withSetFragmentDataTable, withTable, withTableCellSelection };