@univerjs-pro/docs-table 1.0.0-alpha.1 → 1.0.0-alpha.2

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.
Files changed (42) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/es/facade.js +1 -1
  4. package/lib/es/index.js +1 -1
  5. package/lib/facade.js +1 -1
  6. package/lib/index.js +1 -1
  7. package/lib/types/commands/copy-selection.command.d.ts +2 -2
  8. package/lib/types/commands/delete-columns.command.d.ts +2 -1
  9. package/lib/types/commands/delete-rows.command.d.ts +2 -1
  10. package/lib/types/commands/delete-table.command.d.ts +2 -1
  11. package/lib/types/commands/distribute-columns.command.d.ts +2 -1
  12. package/lib/types/commands/distribute-rows.command.d.ts +2 -1
  13. package/lib/types/commands/insert-columns.command.d.ts +2 -1
  14. package/lib/types/commands/insert-rows.command.d.ts +2 -1
  15. package/lib/types/commands/insert-table.command.d.ts +1 -0
  16. package/lib/types/commands/insert-title-row.command.d.ts +2 -1
  17. package/lib/types/commands/merge-cells.command.d.ts +2 -2
  18. package/lib/types/commands/move-columns.command.d.ts +2 -1
  19. package/lib/types/commands/move-rows.command.d.ts +2 -1
  20. package/lib/types/commands/move-table.command.d.ts +2 -1
  21. package/lib/types/commands/paste-without-formatting.command.d.ts +2 -2
  22. package/lib/types/commands/resize-column.command.d.ts +2 -1
  23. package/lib/types/commands/resize-row.command.d.ts +2 -1
  24. package/lib/types/commands/set-column-type.command.d.ts +2 -2
  25. package/lib/types/commands/set-header-row-count.command.d.ts +2 -1
  26. package/lib/types/commands/set-table-background.command.d.ts +2 -2
  27. package/lib/types/commands/set-table-border-color.command.d.ts +4 -4
  28. package/lib/types/commands/set-table-border-style.command.d.ts +2 -2
  29. package/lib/types/commands/set-table-border-width.command.d.ts +2 -2
  30. package/lib/types/commands/set-table-border.command.d.ts +2 -2
  31. package/lib/types/commands/set-table-vertical-align.command.d.ts +2 -2
  32. package/lib/types/commands/sort-table.command.d.ts +2 -1
  33. package/lib/types/commands/unmerge-cells.command.d.ts +2 -2
  34. package/lib/types/commands/utils.d.ts +10 -3
  35. package/lib/types/common/insert-table.d.ts +13 -3
  36. package/lib/types/common/type.d.ts +3 -0
  37. package/lib/types/facade/f-document-table.d.ts +27 -11
  38. package/lib/types/facade/f-document.d.ts +64 -16
  39. package/lib/types/services/docs-table-selection.service.d.ts +1 -0
  40. package/lib/umd/facade.js +1 -1
  41. package/lib/umd/index.js +1 -1
  42. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTableCopySelectionCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableCopySelectionCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  }
6
6
  export declare const DocsTableCopySelectionCommand: ICommand<IDocsTableCopySelectionCommandParams>;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableDeleteColumnsCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableDeleteColumnsCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  startColumn?: number;
5
6
  endColumn?: number;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableDeleteRowsCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableDeleteRowsCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  startRow?: number;
5
6
  endRow?: number;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableDeleteTableCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableDeleteTableCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  }
5
6
  export declare const DocsTableDeleteTableCommand: ICommand<IDocsTableDeleteTableCommandParams>;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableDistributeColumnsCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableDistributeColumnsCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  startColumn?: number;
5
6
  endColumn?: number;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableDistributeRowsCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableDistributeRowsCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  startRow?: number;
5
6
  endRow?: number;
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { DocsTableColumnInsertPosition } from '../common/actions';
3
- export interface IDocsTableInsertColumnsCommandParams {
3
+ import type { IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableInsertColumnsCommandParams extends IDocsTableSegmentOptions {
4
5
  tableId?: string;
5
6
  column?: number;
6
7
  count?: number;
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { DocsTableRowInsertPosition } from '../common/actions';
3
- export interface IDocsTableInsertRowsCommandParams {
3
+ import type { IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableInsertRowsCommandParams extends IDocsTableSegmentOptions {
4
5
  tableId?: string;
5
6
  row?: number;
6
7
  count?: number;
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { IDocsTableInsertOptions } from '../common/insert-table';
3
3
  export interface IDocsTableInsertTableCommandParams extends IDocsTableInsertOptions {
4
+ unitId?: string;
4
5
  rows?: number;
5
6
  columns?: number;
6
7
  }
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableInsertTitleRowCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableInsertTitleRowCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  }
5
6
  export declare const DocsTableInsertTitleRowCommand: ICommand<IDocsTableInsertTitleRowCommandParams>;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTableMergeCellsCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableMergeCellsCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  }
6
6
  export declare const DocsTableMergeCellsCommand: ICommand<IDocsTableMergeCellsCommandParams>;
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { DocsTableColumnInsertPosition } from '../common/actions';
3
- export interface IDocsTableMoveColumnsCommandParams {
3
+ import type { IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableMoveColumnsCommandParams extends IDocsTableSegmentOptions {
4
5
  tableId?: string;
5
6
  fromColumn?: number;
6
7
  toColumn: number;
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { DocsTableRowInsertPosition } from '../common/actions';
3
- export interface IDocsTableMoveRowsCommandParams {
3
+ import type { IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableMoveRowsCommandParams extends IDocsTableSegmentOptions {
4
5
  tableId?: string;
5
6
  fromRow?: number;
6
7
  toRow: number;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableMoveTableCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableMoveTableCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  deltaX?: number;
5
6
  deltaY?: number;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTablePasteWithoutFormattingCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTablePasteWithoutFormattingCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  text: string;
6
6
  }
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableResizeColumnCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableResizeColumnCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  column?: number;
5
6
  width: number;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableResizeRowCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableResizeRowCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  row?: number;
5
6
  height: number;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableColumnTypeConfig } from '../common/type';
3
- export interface IDocsTableSetColumnTypeCommandParams {
2
+ import type { IDocsTableColumnTypeConfig, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableSetColumnTypeCommandParams extends IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  column?: number;
6
6
  config: IDocsTableColumnTypeConfig;
@@ -1,5 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- export interface IDocsTableSetHeaderRowCountCommandParams {
2
+ import type { IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableSetHeaderRowCountCommandParams extends IDocsTableSegmentOptions {
3
4
  tableId?: string;
4
5
  headerRowCount?: number;
5
6
  row?: number;
@@ -1,7 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
3
  import { DocsTableSelectionService } from '../services/docs-table-selection.service';
4
- export interface IDocsTableSetTableBackgroundCommandParams extends Partial<IDocsTableCellRange> {
4
+ export interface IDocsTableSetTableBackgroundCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
5
5
  tableId?: string;
6
6
  color?: string | null;
7
7
  value?: string | null;
@@ -1,12 +1,12 @@
1
1
  import type { IAccessor, ICommand } from '@univerjs/core';
2
2
  import type { TTableBorderStylePatch } from '../common/border';
3
- import type { IDocsTableCellRange } from '../common/type';
4
- export interface IDocsTableSetTableBorderColorCommandParams extends Partial<IDocsTableCellRange> {
3
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableSetTableBorderColorCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
5
5
  tableId?: string;
6
6
  color?: string | null;
7
7
  value?: string | null;
8
8
  }
9
9
  export declare const DocsTableSetTableBorderColorCommand: ICommand<IDocsTableSetTableBorderColorCommandParams>;
10
- export declare function updateTableBorder(accessor: IAccessor, params: Partial<IDocsTableCellRange> & {
10
+ export declare function updateTableBorder(accessor: IAccessor, params: (Partial<IDocsTableCellRange> & IDocsTableSegmentOptions & {
11
11
  tableId?: string;
12
- } | undefined, border: TTableBorderStylePatch): Promise<boolean>;
12
+ }) | undefined, border: TTableBorderStylePatch): Promise<boolean>;
@@ -1,7 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
3
  import { DashStyleType } from '@univerjs/core';
4
- export interface IDocsTableSetTableBorderStyleCommandParams extends Partial<IDocsTableCellRange> {
4
+ export interface IDocsTableSetTableBorderStyleCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
5
5
  tableId?: string;
6
6
  dashStyle?: DashStyleType | DocsTableBorderStyleValue;
7
7
  value?: DashStyleType | DocsTableBorderStyleValue;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTableSetTableBorderWidthCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableSetTableBorderWidthCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  width?: number;
6
6
  value?: number;
@@ -1,7 +1,7 @@
1
1
  import type { ICommand, ITableCellBorder } from '@univerjs/core';
2
2
  import type { DocsTableBorderPreset } from '../common/border';
3
- import type { IDocsTableCellRange } from '../common/type';
4
- export interface IDocsTableSetTableBorderCommandParams extends Partial<IDocsTableCellRange> {
3
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableSetTableBorderCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
5
5
  tableId?: string;
6
6
  preset: DocsTableBorderPreset;
7
7
  border?: ITableCellBorder;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand, VerticalAlignmentType } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTableSetTableVerticalAlignCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableSetTableVerticalAlignCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  value: VerticalAlignmentType;
6
6
  }
@@ -1,6 +1,7 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
2
  import type { DocsTableSortDirection } from '../common/sort';
3
- export interface IDocsTableSortTableCommandParams {
3
+ import type { IDocsTableSegmentOptions } from '../common/type';
4
+ export interface IDocsTableSortTableCommandParams extends IDocsTableSegmentOptions {
4
5
  tableId?: string;
5
6
  column?: number;
6
7
  direction: DocsTableSortDirection;
@@ -1,6 +1,6 @@
1
1
  import type { ICommand } from '@univerjs/core';
2
- import type { IDocsTableCellRange } from '../common/type';
3
- export interface IDocsTableUnmergeCellsCommandParams extends Partial<IDocsTableCellRange> {
2
+ import type { IDocsTableCellRange, IDocsTableSegmentOptions } from '../common/type';
3
+ export interface IDocsTableUnmergeCellsCommandParams extends Partial<IDocsTableCellRange>, IDocsTableSegmentOptions {
4
4
  tableId?: string;
5
5
  }
6
6
  export declare const DocsTableUnmergeCellsCommand: ICommand<IDocsTableUnmergeCellsCommandParams>;
@@ -1,10 +1,17 @@
1
- import type { ICommandService, IDocumentData, JSONXActions } from '@univerjs/core';
1
+ import type { DocumentDataModel, ICommandService, IDocumentData, JSONXActions } from '@univerjs/core';
2
2
  import type { IRectRangeWithStyle } from '@univerjs/engine-render';
3
3
  import type { IDocsTableCellRange } from '../common/type';
4
4
  export interface IDocsTableMutationSelection extends IDocsTableCellRange {
5
5
  tableId: string;
6
6
  segmentId?: string;
7
7
  }
8
- export declare function buildReplaceDocumentTableActions(previousDocumentData: IDocumentData, nextDocumentData: IDocumentData): JSONXActions | null;
9
- export declare function executeRichTextTableMutation(commandService: ICommandService, unitId: string, previousDocumentData: IDocumentData, nextDocumentData: IDocumentData, selection?: IDocsTableMutationSelection): boolean;
8
+ export declare function getTableCommandSegmentId(params?: {
9
+ segmentId?: string;
10
+ } | null | void, selection?: {
11
+ segmentId?: string;
12
+ } | null | void): string;
13
+ export declare function getTableCommandRange(params?: Partial<IDocsTableCellRange> | null | void, selection?: Partial<IDocsTableCellRange> | null | void): IDocsTableCellRange | null;
14
+ export declare function getTableActionDocumentData(doc: DocumentDataModel, segmentId?: string): IDocumentData | null;
15
+ export declare function buildReplaceDocumentTableActions(previousDocumentData: IDocumentData, nextDocumentData: IDocumentData, segmentId?: string): JSONXActions | null;
16
+ export declare function executeRichTextTableMutation(commandService: ICommandService, unitId: string, previousDocumentData: IDocumentData, nextDocumentData: IDocumentData, selection?: IDocsTableMutationSelection, segmentId?: string): boolean;
10
17
  export declare function buildTableRectMutationRanges(documentData: IDocumentData, selection: IDocsTableMutationSelection): IRectRangeWithStyle[];
@@ -5,6 +5,9 @@ export declare enum DocsTableInsertTablePosition {
5
5
  DocumentEnd = "documentEnd",
6
6
  Offset = "offset"
7
7
  }
8
+ export declare class InvalidInsertTableRangeError extends Error {
9
+ constructor();
10
+ }
8
11
  export interface IDocsTableInsertOptions {
9
12
  /**
10
13
  * Custom table id for the inserted table. When omitted by command/facade callers,
@@ -12,15 +15,22 @@ export interface IDocsTableInsertOptions {
12
15
  */
13
16
  tableId?: string;
14
17
  /**
15
- * Requested insertion position. `Offset` uses `offset`; `DocumentEnd` appends
16
- * before the trailing section break; `Selection` is reserved for selection-based insertion.
18
+ * Requested insertion position. When `offset` is provided it takes priority.
19
+ * Otherwise `DocumentEnd` appends before the trailing section break, while
20
+ * `Offset` and `Selection` are resolved from the current cursor by the command.
17
21
  */
18
22
  position?: DocsTableInsertTablePosition;
19
23
  /**
20
24
  * Character offset in the document body data stream where the table should be inserted.
21
- * The value is clamped to the current data stream bounds and is honored whenever it is provided.
25
+ * The value is clamped to the current data stream bounds and is honored whenever
26
+ * it is provided.
22
27
  */
23
28
  offset?: number;
29
+ /**
30
+ * Header/footer segment id where the table should be inserted. Defaults to the
31
+ * main document body when omitted.
32
+ */
33
+ segmentId?: string;
24
34
  /**
25
35
  * Total table width. Also acts as the fallback source for column widths
26
36
  * by distributing `width / columnCount` when `columnWidths` is not provided.
@@ -42,6 +42,9 @@ export interface IDocsTableCellRange {
42
42
  startColumn: number;
43
43
  endColumn: number;
44
44
  }
45
+ export interface IDocsTableSegmentOptions {
46
+ segmentId?: string;
47
+ }
45
48
  export interface IDocsTableSelection extends IDocsTableCellRange {
46
49
  kind: DocsTableSelectionKind;
47
50
  unitId: string;
@@ -1,9 +1,8 @@
1
1
  import type { DocsTableColumnInsertPosition, DocsTableRowInsertPosition, DocsTableSortDirection, IDocsTableCellRange, IDocsTableColumnTypeConfig, IDocsTableMetadata, IDocsTableOffsetRange } from '@univerjs-pro/docs-table';
2
- import type { ITable } from '@univerjs/core';
2
+ import type { Injector, ITable } from '@univerjs/core';
3
3
  import type { FDocument } from '@univerjs/docs/facade';
4
4
  import type { IDocsTableBorderOptions, IDocsTableCellContentRange, IDocsTableDescription, IDocsTableInfo, IDocsTableStyle } from './types';
5
5
  import { DocsTableSelectionKind } from '@univerjs-pro/docs-table';
6
- import { Injector } from '@univerjs/core';
7
6
  import { FDocumentTableCell } from './f-document-table-cell';
8
7
  /**
9
8
  * Facade object for a single enhanced docs table.
@@ -22,11 +21,12 @@ import { FDocumentTableCell } from './f-document-table-cell';
22
21
  * ```
23
22
  */
24
23
  export declare class FDocumentTable {
25
- private _document;
26
- private _tableId;
27
- protected readonly _injector: Injector;
24
+ private readonly _document;
25
+ private readonly _tableId;
26
+ private readonly _segmentId;
27
+ private readonly _injector;
28
28
  private readonly _unitId;
29
- constructor(_document: FDocument, _tableId: string, _injector: Injector);
29
+ constructor(_document: FDocument, _tableId: string, _segmentId: string | undefined, _injector: Injector);
30
30
  /**
31
31
  * Returns the table id.
32
32
  * @returns {string} The table id stored in the document snapshot.
@@ -38,6 +38,19 @@ export declare class FDocumentTable {
38
38
  * ```
39
39
  */
40
40
  getId(): string;
41
+ /**
42
+ * Get the segment id of this table.
43
+ * The main body tables have an empty string segment id.
44
+ * The header and footer tables have a non-empty string segment id.
45
+ * @returns {string} The segment id.
46
+ * @example
47
+ * ```ts
48
+ * const fDocument = univerAPI.getActiveDocument();
49
+ * const table = fDocument?.findTableByText('Status');
50
+ * console.log(table?.getSegmentId());
51
+ * ```
52
+ */
53
+ getSegmentId(): string;
41
54
  /**
42
55
  * Returns compact table metadata for agents.
43
56
  * @returns {IDocsTableInfo} The id, row count, column count, metadata, and raw table source.
@@ -139,7 +152,7 @@ export declare class FDocumentTable {
139
152
  * ```ts
140
153
  * const fDocument = univerAPI.getActiveDocument();
141
154
  * const table = fDocument?.findTableByText('Status');
142
- * console.log(table?._getDocumentData());
155
+ * console.log(table?.getRange());
143
156
  * ```
144
157
  */
145
158
  getRange(): IDocsTableOffsetRange | null;
@@ -150,7 +163,7 @@ export declare class FDocumentTable {
150
163
  * ```ts
151
164
  * const fDocument = univerAPI.getActiveDocument();
152
165
  * const table = fDocument?.findTableByText('Status');
153
- * console.log(table?._getTableRange());
166
+ * console.log(table?.getTableRange());
154
167
  * ```
155
168
  */
156
169
  getTableRange(): IDocsTableCellRange;
@@ -896,16 +909,19 @@ export declare class FDocumentTable {
896
909
  */
897
910
  insertTitleRow(): boolean;
898
911
  /**
899
- * Sets the type of a specific column in the table.
912
+ * Sets the metadata type of a specific column in the table.
913
+ *
914
+ * The column type is used as the value parsing hint for table features such as sorting.
915
+ * It does not enable dedicated cell editors or rendering for date, checkbox, or dropdown columns.
900
916
  * @param {number} column The zero-based column index to set the type for.
901
917
  * @param {IDocsTableColumnTypeConfig} config The column type configuration, including the type and any additional options specific to the column type.
902
- * @returns {boolean} `true` if the column type was successfully set.
918
+ * @returns {boolean} `true` if the column type metadata was successfully set.
903
919
  * @example
904
920
  * ```ts
905
921
  * const fDocument = univerAPI.getActiveDocument();
906
922
  * const table = fDocument?.findTableByText('Status');
907
923
  *
908
- * // Sets column 2 as a date column with a specific date format
924
+ * // Sorts column 2 as date values when table sorting is applied.
909
925
  * table?.setColumnType(2, {
910
926
  * type: univerAPI.Enum.DocsTableColumnType.Date,
911
927
  * });
@@ -4,40 +4,55 @@ import { FDocument } from '@univerjs/docs/facade';
4
4
  import { FDocumentTable } from './f-document-table';
5
5
  export interface IFDocumentTableMixin {
6
6
  /**
7
- * Returns all enhanced docs tables in this document.
7
+ * Returns all enhanced docs tables in this document body or header/footer body by the segment id.
8
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
8
9
  * @returns {FDocumentTable[]} An array of FDocumentTable instances, or an empty array if the document contains no tables.
9
10
  * @example
10
11
  * ```ts
11
12
  * const fDocument = univerAPI.getActiveDocument();
12
13
  * const tables = fDocument.getTables();
13
14
  * console.log(tables);
15
+ *
16
+ * const headerSegmentId = fDocument.ensurePageHeader();
17
+ * const headerTables = fDocument.getTables(headerSegmentId);
18
+ * console.log(headerTables);
14
19
  * ```
15
20
  */
16
- getTables(): FDocumentTable[];
21
+ getTables(segmentId?: string): FDocumentTable[];
17
22
  /**
18
- * Returns a table by table id.
23
+ * Returns a table by table id in this document body or header/footer body by the segment id.
19
24
  * @param {string} tableId The table id stored in the document snapshot.
25
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
20
26
  * @returns {FDocumentTable | null} The FDocumentTable instance, or `null` if no table with the given id exists in the document.
21
27
  * @example
22
28
  * ```ts
23
29
  * const fDocument = univerAPI.getActiveDocument();
24
30
  * const table = fDocument.getTable('table-1');
25
31
  * console.log(table);
32
+ *
33
+ * const headerSegmentId = fDocument.ensurePageHeader();
34
+ * const headerTable = fDocument.getTable('table-1', headerSegmentId);
35
+ * console.log(headerTable);
26
36
  * ```
27
37
  */
28
- getTable(tableId: string): FDocumentTable | null;
38
+ getTable(tableId: string, segmentId?: string): FDocumentTable | null;
29
39
  /**
30
- * Returns a table by its order in the document.
40
+ * Returns a table by its order in this document body or header/footer body by the segment id.
31
41
  * @param {number} index The zero-based table index.
42
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
32
43
  * @returns {FDocumentTable | null} The FDocumentTable instance, or `null` if the index is out of bounds.
33
44
  * @example
34
45
  * ```ts
35
46
  * const fDocument = univerAPI.getActiveDocument();
36
47
  * const firstTable = fDocument.getTableAt(0);
37
48
  * console.log(firstTable);
49
+ *
50
+ * const footerSegmentId = fDocument.ensurePageFooter();
51
+ * const firstFooterTable = fDocument.getTableAt(0, footerSegmentId);
52
+ * console.log(firstFooterTable);
38
53
  * ```
39
54
  */
40
- getTableAt(index: number): FDocumentTable | null;
55
+ getTableAt(index: number, segmentId?: string): FDocumentTable | null;
41
56
  /**
42
57
  * Returns the table currently selected by the docs table selection service.
43
58
  * @returns {FDocumentTable | null} The FDocumentTable instance, or `null` if there is no current table selection.
@@ -46,36 +61,53 @@ export interface IFDocumentTableMixin {
46
61
  * const fDocument = univerAPI.getActiveDocument();
47
62
  * const selectedTable = fDocument.getTableAtSelection();
48
63
  * console.log(selectedTable);
64
+ * console.log(selectedTable?.getSegmentId());
49
65
  * ```
50
66
  */
51
67
  getTableAtSelection(): FDocumentTable | null;
52
68
  /**
53
- * Finds the first table whose data stream contains the given text.
69
+ * Finds the first table whose data stream contains the given text in this document body or header/footer body by the segment id.
54
70
  * @param {string} text Text to search inside table cells.
71
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
55
72
  * @returns {FDocumentTable | null} The first FDocumentTable instance matching the query, or `null` if no matches are found.
56
73
  * @example
57
74
  * ```ts
58
75
  * const fDocument = univerAPI.getActiveDocument();
59
76
  * const table = fDocument.findTableByText('Revenue');
60
77
  * console.log(table);
78
+ *
79
+ * const headerSegmentId = fDocument.ensurePageHeader();
80
+ * const headerTable = fDocument.findTableByText('Revenue', headerSegmentId);
81
+ * console.log(headerTable);
61
82
  * ```
62
83
  */
63
- findTableByText(text: string): FDocumentTable | null;
84
+ findTableByText(text: string, segmentId?: string): FDocumentTable | null;
64
85
  /**
65
- * Finds tables by text, id, header text, or title text.
86
+ * Finds tables by text, id, header text, or title text in this document body or header/footer body by the segment id.
66
87
  * @param {string | IDocsTableFindQuery} query A plain text query or a structured table query.
88
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
67
89
  * @returns {FDocumentTable[]} An array of FDocumentTable instances matching the query, or an empty array if no matches are found.
68
90
  * @example
69
91
  * ```ts
70
92
  * const fDocument = univerAPI.getActiveDocument();
71
93
  * const tablesWithText = fDocument.findTables('Revenue');
94
+ * console.log(tablesWithText);
95
+ *
72
96
  * const tablesWithId = fDocument.findTables({ tableId: 'table-1' });
97
+ * console.log(tablesWithId);
98
+ *
73
99
  * const tablesWithHeader = fDocument.findTables({ headerText: 'Q1' });
100
+ * console.log(tablesWithHeader);
101
+ *
74
102
  * const tablesWithTitle = fDocument.findTables({ titleText: 'Sales Data' });
75
- * console.log(tablesWithText, tablesWithId, tablesWithHeader, tablesWithTitle);
103
+ * console.log(tablesWithTitle);
104
+ *
105
+ * const footerSegmentId = fDocument.ensurePageFooter();
106
+ * const footerTablesWithText = fDocument.findTables('Revenue', footerSegmentId);
107
+ * console.log(footerTablesWithText);
76
108
  * ```
77
109
  */
78
- findTables(query: string | IDocsTableFindQuery): FDocumentTable[];
110
+ findTables(query: string | IDocsTableFindQuery, segmentId?: string): FDocumentTable[];
79
111
  /**
80
112
  * Inserts an empty table at the current document selection or at the position provided in options.
81
113
  * @param {number} rows The row count.
@@ -104,6 +136,12 @@ export interface IFDocumentTableMixin {
104
136
  * ['A3', 'B3', 'C3', 'D3'],
105
137
  * ],
106
138
  * });
139
+ *
140
+ * // Insert a 2x2 table into the page header
141
+ * const headerSegmentId = fDocument.ensurePageHeader();
142
+ * const headerTable = fDocument.insertTable(2, 2, {
143
+ * segmentId: headerSegmentId,
144
+ * });
107
145
  * ```
108
146
  */
109
147
  insertTable(rows: number, columns: number, options?: IDocsTableInsertOptions): FDocumentTable | null;
@@ -123,20 +161,30 @@ export interface IFDocumentTableMixin {
123
161
  * ], {
124
162
  * headerRowCount: 1,
125
163
  * });
164
+ *
165
+ * // Insert a table with data into the page footer
166
+ * const footerSegmentId = fDocument.ensurePageFooter();
167
+ * const footerTable = fDocument.insertTableFromData([
168
+ * ['Reviewed by', 'Date'],
169
+ * ['Docs Team', '2026-07-03'],
170
+ * ], {
171
+ * segmentId: footerSegmentId,
172
+ * });
126
173
  * ```
127
174
  */
128
175
  insertTableFromData(data: string[][], options?: IDocsTableInsertOptions): FDocumentTable | null;
129
176
  }
130
177
  export declare class FDocumentTableMixin extends FDocument implements IFDocumentTableMixin {
131
- getTables(): FDocumentTable[];
132
- getTable(tableId: string): FDocumentTable | null;
133
- getTableAt(index: number): FDocumentTable | null;
178
+ getTables(segmentId?: string): FDocumentTable[];
179
+ getTable(tableId: string, segmentId?: string): FDocumentTable | null;
180
+ getTableAt(index: number, segmentId?: string): FDocumentTable | null;
134
181
  getTableAtSelection(): FDocumentTable | null;
135
- findTableByText(text: string): FDocumentTable | null;
136
- findTables(query: string | IDocsTableFindQuery): FDocumentTable[];
182
+ findTableByText(text: string, segmentId?: string): FDocumentTable | null;
183
+ findTables(query: string | IDocsTableFindQuery, segmentId?: string): FDocumentTable[];
137
184
  insertTable(rows: number, columns: number, options?: IDocsTableInsertOptions): FDocumentTable | null;
138
185
  insertTableFromData(data: string[][], options?: IDocsTableInsertOptions): FDocumentTable | null;
139
186
  private _getTables;
187
+ private _getTableDocumentData;
140
188
  private _createFDocumentTable;
141
189
  private _tableContainsText;
142
190
  private _rowContainsText;
@@ -6,6 +6,7 @@ export type IDocsTableStructuralSelectionInput = Pick<IDocsTableSelection, 'kind
6
6
  export interface IDocsTableStructuralSelectionOptions {
7
7
  clearNativeSelection?: boolean;
8
8
  preserveOnTextSelection?: boolean;
9
+ segmentId?: string;
9
10
  }
10
11
  export interface IDocsTableClearSelectionOptions {
11
12
  clearNativeSelection?: boolean;