@univerjs-pro/docs-table 0.24.0-insiders.20260528-29f582d
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.
- package/README.md +77 -0
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/facade.js +1 -0
- package/lib/es/index.js +1 -0
- package/lib/facade.js +1 -0
- package/lib/index.js +1 -0
- package/lib/types/commands/copy-selection.command.d.ts +6 -0
- package/lib/types/commands/delete-columns.command.d.ts +7 -0
- package/lib/types/commands/delete-rows.command.d.ts +7 -0
- package/lib/types/commands/delete-table.command.d.ts +5 -0
- package/lib/types/commands/distribute-columns.command.d.ts +7 -0
- package/lib/types/commands/distribute-rows.command.d.ts +7 -0
- package/lib/types/commands/insert-columns.command.d.ts +9 -0
- package/lib/types/commands/insert-rows.command.d.ts +9 -0
- package/lib/types/commands/insert-table.command.d.ts +7 -0
- package/lib/types/commands/insert-title-row.command.d.ts +5 -0
- package/lib/types/commands/merge-cells.command.d.ts +6 -0
- package/lib/types/commands/move-columns.command.d.ts +9 -0
- package/lib/types/commands/move-rows.command.d.ts +9 -0
- package/lib/types/commands/move-table.command.d.ts +8 -0
- package/lib/types/commands/paste-without-formatting.command.d.ts +7 -0
- package/lib/types/commands/resize-column.command.d.ts +7 -0
- package/lib/types/commands/resize-row.command.d.ts +7 -0
- package/lib/types/commands/set-column-type.command.d.ts +8 -0
- package/lib/types/commands/set-header-row-count.command.d.ts +7 -0
- package/lib/types/commands/set-table-background.command.d.ts +10 -0
- package/lib/types/commands/set-table-border-color.command.d.ts +11 -0
- package/lib/types/commands/set-table-border-style.command.d.ts +11 -0
- package/lib/types/commands/set-table-border-width.command.d.ts +8 -0
- package/lib/types/commands/set-table-border.command.d.ts +9 -0
- package/lib/types/commands/sort-table.command.d.ts +8 -0
- package/lib/types/commands/unmerge-cells.command.d.ts +6 -0
- package/lib/types/commands/utils.d.ts +10 -0
- package/lib/types/common/actions.d.ts +73 -0
- package/lib/types/common/border.d.ts +25 -0
- package/lib/types/common/cell-text.d.ts +12 -0
- package/lib/types/common/clipboard.d.ts +38 -0
- package/lib/types/common/const.d.ts +2 -0
- package/lib/types/common/insert-table.d.ts +27 -0
- package/lib/types/common/layout.d.ts +56 -0
- package/lib/types/common/merge.d.ts +21 -0
- package/lib/types/common/metadata.d.ts +5 -0
- package/lib/types/common/selection-remap.d.ts +12 -0
- package/lib/types/common/sort.d.ts +14 -0
- package/lib/types/common/table-fixture.d.ts +3 -0
- package/lib/types/common/table-range.d.ts +31 -0
- package/lib/types/common/type.d.ts +33 -0
- package/lib/types/controllers/config.schema.d.ts +5 -0
- package/lib/types/controllers/docs-table-resource.controller.d.ts +8 -0
- package/lib/types/facade/f-docs-table-cell.d.ts +83 -0
- package/lib/types/facade/f-docs-table.d.ts +130 -0
- package/lib/types/facade/f-document.d.ts +88 -0
- package/lib/types/facade/index.d.ts +5 -0
- package/lib/types/facade/types.d.ts +52 -0
- package/lib/types/index.d.ts +80 -0
- package/lib/types/models/docs-table-model.d.ts +19 -0
- package/lib/types/plugin.d.ts +15 -0
- package/lib/types/services/docs-table-selection.service.d.ts +32 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ICommand, ITableCellBorder } from '@univerjs/core';
|
|
2
|
+
import type { DocsTableBorderPreset } from '../common/border';
|
|
3
|
+
import type { IDocsTableCellRange } from '../common/type';
|
|
4
|
+
export interface IDocsTableSetTableBorderCommandParams extends Partial<IDocsTableCellRange> {
|
|
5
|
+
tableId?: string;
|
|
6
|
+
preset: DocsTableBorderPreset;
|
|
7
|
+
border?: ITableCellBorder;
|
|
8
|
+
}
|
|
9
|
+
export declare const DocsTableSetTableBorderCommand: ICommand<IDocsTableSetTableBorderCommandParams>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ICommand } from '@univerjs/core';
|
|
2
|
+
import type { DocsTableSortDirection } from '../common/sort';
|
|
3
|
+
export interface IDocsTableSortTableCommandParams {
|
|
4
|
+
tableId?: string;
|
|
5
|
+
column?: number;
|
|
6
|
+
direction: DocsTableSortDirection;
|
|
7
|
+
}
|
|
8
|
+
export declare const DocsTableSortTableCommand: ICommand<IDocsTableSortTableCommandParams>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ICommand } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableCellRange } from '../common/type';
|
|
3
|
+
export interface IDocsTableUnmergeCellsCommandParams extends Partial<IDocsTableCellRange> {
|
|
4
|
+
tableId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const DocsTableUnmergeCellsCommand: ICommand<IDocsTableUnmergeCellsCommandParams>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ICommandService, IDocumentData, JSONXActions } from '@univerjs/core';
|
|
2
|
+
import type { IRectRangeWithStyle } from '@univerjs/engine-render';
|
|
3
|
+
import type { IDocsTableCellRange } from '../common/type';
|
|
4
|
+
export interface IDocsTableMutationSelection extends IDocsTableCellRange {
|
|
5
|
+
tableId: string;
|
|
6
|
+
segmentId?: string;
|
|
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;
|
|
10
|
+
export declare function buildTableRectMutationRanges(documentData: IDocumentData, selection: IDocsTableMutationSelection): IRectRangeWithStyle[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableMetadataResource } from './type';
|
|
3
|
+
export type DocsTableInsertPosition = 'above' | 'below' | 'left' | 'right';
|
|
4
|
+
export interface IDocsTableActionCursor {
|
|
5
|
+
row: number;
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IDocsTableActionBuildResult {
|
|
9
|
+
nextDocumentData: IDocumentData;
|
|
10
|
+
nextMetadata?: IDocsTableMetadataResource;
|
|
11
|
+
cursor: IDocsTableActionCursor;
|
|
12
|
+
deleteTable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface IInsertRowsActionParams {
|
|
15
|
+
documentData: IDocumentData;
|
|
16
|
+
metadata?: IDocsTableMetadataResource;
|
|
17
|
+
tableId: string;
|
|
18
|
+
row: number;
|
|
19
|
+
count: number;
|
|
20
|
+
position: Extract<DocsTableInsertPosition, 'above' | 'below'>;
|
|
21
|
+
}
|
|
22
|
+
export interface IInsertColumnsActionParams {
|
|
23
|
+
documentData: IDocumentData;
|
|
24
|
+
metadata?: IDocsTableMetadataResource;
|
|
25
|
+
tableId: string;
|
|
26
|
+
column: number;
|
|
27
|
+
count: number;
|
|
28
|
+
position: Extract<DocsTableInsertPosition, 'left' | 'right'>;
|
|
29
|
+
}
|
|
30
|
+
export interface IDeleteRowsActionParams {
|
|
31
|
+
documentData: IDocumentData;
|
|
32
|
+
metadata?: IDocsTableMetadataResource;
|
|
33
|
+
tableId: string;
|
|
34
|
+
startRow: number;
|
|
35
|
+
endRow: number;
|
|
36
|
+
}
|
|
37
|
+
export interface IDeleteColumnsActionParams {
|
|
38
|
+
documentData: IDocumentData;
|
|
39
|
+
metadata?: IDocsTableMetadataResource;
|
|
40
|
+
tableId: string;
|
|
41
|
+
startColumn: number;
|
|
42
|
+
endColumn: number;
|
|
43
|
+
}
|
|
44
|
+
export interface IDeleteTableActionParams {
|
|
45
|
+
documentData: IDocumentData;
|
|
46
|
+
metadata?: IDocsTableMetadataResource;
|
|
47
|
+
tableId: string;
|
|
48
|
+
}
|
|
49
|
+
export interface IMoveRowsActionParams {
|
|
50
|
+
documentData: IDocumentData;
|
|
51
|
+
metadata?: IDocsTableMetadataResource;
|
|
52
|
+
tableId: string;
|
|
53
|
+
fromRow: number;
|
|
54
|
+
toRow: number;
|
|
55
|
+
count?: number;
|
|
56
|
+
position: Extract<DocsTableInsertPosition, 'above' | 'below'>;
|
|
57
|
+
}
|
|
58
|
+
export interface IMoveColumnsActionParams {
|
|
59
|
+
documentData: IDocumentData;
|
|
60
|
+
metadata?: IDocsTableMetadataResource;
|
|
61
|
+
tableId: string;
|
|
62
|
+
fromColumn: number;
|
|
63
|
+
toColumn: number;
|
|
64
|
+
count?: number;
|
|
65
|
+
position: Extract<DocsTableInsertPosition, 'left' | 'right'>;
|
|
66
|
+
}
|
|
67
|
+
export declare function buildInsertRowsActions(params: IInsertRowsActionParams): IDocsTableActionBuildResult;
|
|
68
|
+
export declare function buildInsertColumnsActions(params: IInsertColumnsActionParams): IDocsTableActionBuildResult;
|
|
69
|
+
export declare function buildDeleteRowsActions(params: IDeleteRowsActionParams): IDocsTableActionBuildResult;
|
|
70
|
+
export declare function buildDeleteColumnsActions(params: IDeleteColumnsActionParams): IDocsTableActionBuildResult;
|
|
71
|
+
export declare function buildDeleteTableActions(params: IDeleteTableActionParams): IDocsTableActionBuildResult;
|
|
72
|
+
export declare function buildMoveRowsActions(params: IMoveRowsActionParams): IDocsTableActionBuildResult;
|
|
73
|
+
export declare function buildMoveColumnsActions(params: IMoveColumnsActionParams): IDocsTableActionBuildResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IDocumentData, ITableCellBorder } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableCellRange } from './type';
|
|
3
|
+
export type DocsTableBorderPreset = 'all' | 'inner' | 'outer' | 'top' | 'bottom' | 'left' | 'right' | 'none' | 'innerHorizontal' | 'innerVertical';
|
|
4
|
+
export interface ISetTableBorderActionParams extends IDocsTableCellRange {
|
|
5
|
+
documentData: IDocumentData;
|
|
6
|
+
tableId: string;
|
|
7
|
+
preset: DocsTableBorderPreset;
|
|
8
|
+
border?: ITableCellBorder;
|
|
9
|
+
}
|
|
10
|
+
export interface ISetTableBorderActionResult {
|
|
11
|
+
nextDocumentData: IDocumentData;
|
|
12
|
+
}
|
|
13
|
+
export interface ISetTableCellBackgroundActionParams extends IDocsTableCellRange {
|
|
14
|
+
documentData: IDocumentData;
|
|
15
|
+
tableId: string;
|
|
16
|
+
color: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IUpdateTableBorderStyleActionParams extends IDocsTableCellRange {
|
|
19
|
+
documentData: IDocumentData;
|
|
20
|
+
tableId: string;
|
|
21
|
+
border: Partial<ITableCellBorder>;
|
|
22
|
+
}
|
|
23
|
+
export declare function buildSetTableBorderActions(params: ISetTableBorderActionParams): ISetTableBorderActionResult;
|
|
24
|
+
export declare function buildSetTableCellBackgroundActions(params: ISetTableCellBackgroundActionParams): ISetTableBorderActionResult;
|
|
25
|
+
export declare function buildUpdateTableBorderStyleActions(params: IUpdateTableBorderStyleActionParams): ISetTableBorderActionResult;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
export interface ISetTableCellTextActionParams {
|
|
3
|
+
documentData: IDocumentData;
|
|
4
|
+
tableId: string;
|
|
5
|
+
row: number;
|
|
6
|
+
column: number;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ISetTableCellTextActionResult {
|
|
10
|
+
nextDocumentData: IDocumentData;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildSetTableCellTextActions(params: ISetTableCellTextActionParams): ISetTableCellTextActionResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableCellRange } from './type';
|
|
3
|
+
export interface ITableClipboardParams extends IDocsTableCellRange {
|
|
4
|
+
documentData: IDocumentData;
|
|
5
|
+
tableId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IPastePlainTextTableParams extends ITableClipboardParams {
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IPastePlainTextTableResult {
|
|
11
|
+
nextDocumentData: IDocumentData;
|
|
12
|
+
}
|
|
13
|
+
export interface IPasteHtmlTableParams extends ITableClipboardParams {
|
|
14
|
+
html: string;
|
|
15
|
+
}
|
|
16
|
+
export interface IPasteHtmlTableResult {
|
|
17
|
+
nextDocumentData: IDocumentData;
|
|
18
|
+
}
|
|
19
|
+
export interface IParsedHtmlTableCell {
|
|
20
|
+
text: string;
|
|
21
|
+
rowSpan: number;
|
|
22
|
+
colSpan: number;
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
borderColor?: string;
|
|
25
|
+
borderWidth?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface IParsedHtmlTableRow {
|
|
28
|
+
cells: Array<IParsedHtmlTableCell | null>;
|
|
29
|
+
height?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface IParsedHtmlTableClipboard {
|
|
32
|
+
rows: IParsedHtmlTableRow[];
|
|
33
|
+
columnWidths: Array<number | undefined>;
|
|
34
|
+
}
|
|
35
|
+
export declare function serializeTableSelectionAsPlainText(params: ITableClipboardParams): string;
|
|
36
|
+
export declare function buildPastePlainTextTableActions(params: IPastePlainTextTableParams): IPastePlainTextTableResult;
|
|
37
|
+
export declare function buildPasteHtmlTableActions(params: IPasteHtmlTableParams): IPasteHtmlTableResult;
|
|
38
|
+
export declare function parseHtmlTableClipboard(html: string): IParsedHtmlTableClipboard;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableColumnTypeConfig, IDocsTableMetadataResource } from './type';
|
|
3
|
+
export interface IDocsTableInsertOptions {
|
|
4
|
+
tableId?: string;
|
|
5
|
+
position?: 'selection' | 'documentEnd' | 'offset';
|
|
6
|
+
offset?: number;
|
|
7
|
+
width?: number;
|
|
8
|
+
columnWidths?: number[];
|
|
9
|
+
rowHeights?: number[];
|
|
10
|
+
titleRow?: boolean;
|
|
11
|
+
headerRowCount?: number;
|
|
12
|
+
values?: string[][];
|
|
13
|
+
columnTypes?: Record<number, IDocsTableColumnTypeConfig>;
|
|
14
|
+
}
|
|
15
|
+
export interface IDocsTableInsertActionParams extends IDocsTableInsertOptions {
|
|
16
|
+
documentData: IDocumentData;
|
|
17
|
+
metadata?: IDocsTableMetadataResource;
|
|
18
|
+
rows?: number;
|
|
19
|
+
columns?: number;
|
|
20
|
+
tableId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface IDocsTableInsertActionResult {
|
|
23
|
+
nextDocumentData: IDocumentData;
|
|
24
|
+
nextMetadata: IDocsTableMetadataResource;
|
|
25
|
+
tableId: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function buildInsertTableActions(params: IDocsTableInsertActionParams): IDocsTableInsertActionResult;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableMetadataResource } from './type';
|
|
3
|
+
export interface IDocsTableLayoutActionResult {
|
|
4
|
+
nextDocumentData: IDocumentData;
|
|
5
|
+
nextMetadata?: IDocsTableMetadataResource;
|
|
6
|
+
}
|
|
7
|
+
export interface IInsertTitleRowActionParams {
|
|
8
|
+
documentData: IDocumentData;
|
|
9
|
+
metadata?: IDocsTableMetadataResource;
|
|
10
|
+
tableId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ISetHeaderRowCountActionParams {
|
|
13
|
+
documentData: IDocumentData;
|
|
14
|
+
metadata?: IDocsTableMetadataResource;
|
|
15
|
+
tableId: string;
|
|
16
|
+
headerRowCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface IDistributeRowsActionParams {
|
|
19
|
+
documentData: IDocumentData;
|
|
20
|
+
tableId: string;
|
|
21
|
+
startRow: number;
|
|
22
|
+
endRow: number;
|
|
23
|
+
}
|
|
24
|
+
export interface IDistributeColumnsActionParams {
|
|
25
|
+
documentData: IDocumentData;
|
|
26
|
+
tableId: string;
|
|
27
|
+
startColumn: number;
|
|
28
|
+
endColumn: number;
|
|
29
|
+
}
|
|
30
|
+
export interface IResizeRowActionParams {
|
|
31
|
+
documentData: IDocumentData;
|
|
32
|
+
tableId: string;
|
|
33
|
+
row: number;
|
|
34
|
+
height: number;
|
|
35
|
+
}
|
|
36
|
+
export interface IResizeColumnActionParams {
|
|
37
|
+
documentData: IDocumentData;
|
|
38
|
+
tableId: string;
|
|
39
|
+
column: number;
|
|
40
|
+
width: number;
|
|
41
|
+
}
|
|
42
|
+
export interface IMoveTableActionParams {
|
|
43
|
+
documentData: IDocumentData;
|
|
44
|
+
tableId: string;
|
|
45
|
+
deltaX?: number;
|
|
46
|
+
deltaY?: number;
|
|
47
|
+
targetOffset?: number;
|
|
48
|
+
}
|
|
49
|
+
export declare function buildInsertTitleRowActions(params: IInsertTitleRowActionParams): IDocsTableLayoutActionResult;
|
|
50
|
+
export declare function buildSetHeaderRowCountActions(params: ISetHeaderRowCountActionParams): IDocsTableLayoutActionResult;
|
|
51
|
+
export declare function buildDistributeRowsActions(params: IDistributeRowsActionParams): IDocsTableLayoutActionResult;
|
|
52
|
+
export declare function buildDistributeColumnsActions(params: IDistributeColumnsActionParams): IDocsTableLayoutActionResult;
|
|
53
|
+
export declare function buildResizeRowActions(params: IResizeRowActionParams): IDocsTableLayoutActionResult;
|
|
54
|
+
export declare function buildResizeColumnActions(params: IResizeColumnActionParams): IDocsTableLayoutActionResult;
|
|
55
|
+
export declare function buildMoveTableActions(params: IMoveTableActionParams): IDocsTableLayoutActionResult;
|
|
56
|
+
export declare function getPinnedHeaderRowCount(metadata: IDocsTableMetadataResource | undefined, tableId: string): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IDocumentData, ITable } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableCellRange } from './type';
|
|
3
|
+
export interface IDocsTableMergeActionParams extends IDocsTableCellRange {
|
|
4
|
+
documentData: IDocumentData;
|
|
5
|
+
tableId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IDocsTableMergeActionResult {
|
|
8
|
+
nextDocumentData: IDocumentData;
|
|
9
|
+
range: IDocsTableCellRange;
|
|
10
|
+
}
|
|
11
|
+
export declare function canMergeCells(documentData: IDocumentData, tableId: string, range: IDocsTableCellRange): boolean;
|
|
12
|
+
export declare function canUnmergeCells(documentData: IDocumentData, tableId: string, range: IDocsTableCellRange): boolean;
|
|
13
|
+
export declare function buildMergeCellsActions(params: IDocsTableMergeActionParams): IDocsTableMergeActionResult;
|
|
14
|
+
export declare function buildUnmergeCellsActions(params: IDocsTableMergeActionParams): IDocsTableMergeActionResult;
|
|
15
|
+
export declare function findMergeRange(table: ITable, row: number, column: number): IDocsTableCellRange | null;
|
|
16
|
+
export declare function expandRangeByMergedCells(table: ITable, range: IDocsTableCellRange): IDocsTableCellRange;
|
|
17
|
+
export declare function updateMergedCellsForInsertRows(table: ITable, insertIndex: number, count: number, ranges?: IDocsTableCellRange[]): void;
|
|
18
|
+
export declare function updateMergedCellsForInsertColumns(table: ITable, insertIndex: number, count: number, ranges?: IDocsTableCellRange[]): void;
|
|
19
|
+
export declare function updateMergedCellsForDeleteRows(table: ITable, startRow: number, endRow: number, ranges?: IDocsTableCellRange[]): void;
|
|
20
|
+
export declare function updateMergedCellsForDeleteColumns(table: ITable, startColumn: number, endColumn: number, ranges?: IDocsTableCellRange[]): void;
|
|
21
|
+
export declare function collectMergedCellRanges(table: ITable): IDocsTableCellRange[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IDocsTableColumnTypeConfig, IDocsTableMetadataResource } from './type';
|
|
2
|
+
export declare function normalizeDocsTableMetadataResource(resource?: Partial<IDocsTableMetadataResource> | null): IDocsTableMetadataResource;
|
|
3
|
+
export declare function setHeaderRowCountInMetadata(resource: Partial<IDocsTableMetadataResource> | undefined, tableId: string, headerRowCount: number): IDocsTableMetadataResource;
|
|
4
|
+
export declare function setTitleRowInMetadata(resource: Partial<IDocsTableMetadataResource> | undefined, tableId: string, titleRow: boolean): IDocsTableMetadataResource;
|
|
5
|
+
export declare function setColumnTypeInMetadata(resource: Partial<IDocsTableMetadataResource> | undefined, tableId: string, column: number, config: IDocsTableColumnTypeConfig): IDocsTableMetadataResource;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableSelection } from './type';
|
|
3
|
+
export type DocsTableSelectionRemapOperation = {
|
|
4
|
+
kind: 'insert-rows' | 'insert-columns' | 'delete-rows' | 'delete-columns';
|
|
5
|
+
tableId: string;
|
|
6
|
+
index: number;
|
|
7
|
+
count: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'delete-table';
|
|
10
|
+
tableId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function remapDocsTableSelection(selection: IDocsTableSelection | null, documentData: IDocumentData, operation: DocsTableSelectionRemapOperation): IDocsTableSelection | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
2
|
+
import type { IDocsTableMetadataResource } from './type';
|
|
3
|
+
export type DocsTableSortDirection = 'asc' | 'desc';
|
|
4
|
+
export interface ISortTableActionParams {
|
|
5
|
+
documentData: IDocumentData;
|
|
6
|
+
metadata?: IDocsTableMetadataResource;
|
|
7
|
+
tableId: string;
|
|
8
|
+
column: number;
|
|
9
|
+
direction: DocsTableSortDirection;
|
|
10
|
+
}
|
|
11
|
+
export interface ISortTableActionResult {
|
|
12
|
+
nextDocumentData: IDocumentData;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildSortTableActions(params: ISortTableActionParams): ISortTableActionResult;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IDocumentData, ITable } from '@univerjs/core';
|
|
2
|
+
export interface IDocsTableCellOffsetRange {
|
|
3
|
+
row: number;
|
|
4
|
+
column: number;
|
|
5
|
+
startOffset: number;
|
|
6
|
+
endOffset: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IDocsTableRowOffsetRange {
|
|
9
|
+
row: number;
|
|
10
|
+
startOffset: number;
|
|
11
|
+
endOffset: number;
|
|
12
|
+
cells: IDocsTableCellOffsetRange[];
|
|
13
|
+
}
|
|
14
|
+
export interface IDocsTableColumnOffsetRange {
|
|
15
|
+
column: number;
|
|
16
|
+
startOffset: number;
|
|
17
|
+
endOffset: number;
|
|
18
|
+
cells: IDocsTableCellOffsetRange[];
|
|
19
|
+
}
|
|
20
|
+
export interface IDocsTableOffsetRange {
|
|
21
|
+
tableId: string;
|
|
22
|
+
startOffset: number;
|
|
23
|
+
endOffset: number;
|
|
24
|
+
rowCount: number;
|
|
25
|
+
columnCount: number;
|
|
26
|
+
tableSource: ITable;
|
|
27
|
+
rows: IDocsTableRowOffsetRange[];
|
|
28
|
+
}
|
|
29
|
+
export declare function getTableRangeById(documentData: IDocumentData, tableId: string): IDocsTableOffsetRange | null;
|
|
30
|
+
export declare function getRowRange(table: IDocsTableOffsetRange, row: number): IDocsTableRowOffsetRange;
|
|
31
|
+
export declare function getColumnRange(table: IDocsTableOffsetRange, column: number): IDocsTableColumnOffsetRange;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type DocsTableColumnType = 'text' | 'number' | 'date' | 'checkbox' | 'dropdown';
|
|
2
|
+
export interface IDocsTableDropdownOption {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IDocsTableColumnTypeConfig {
|
|
8
|
+
type: DocsTableColumnType;
|
|
9
|
+
dropdownOptions?: IDocsTableDropdownOption[];
|
|
10
|
+
}
|
|
11
|
+
export interface IDocsTableMetadata {
|
|
12
|
+
titleRow?: boolean;
|
|
13
|
+
headerRowCount?: number;
|
|
14
|
+
columnTypes?: Record<number, IDocsTableColumnTypeConfig>;
|
|
15
|
+
}
|
|
16
|
+
export interface IDocsTableMetadataResource {
|
|
17
|
+
tables: Record<string, IDocsTableMetadata>;
|
|
18
|
+
}
|
|
19
|
+
export type DocsTableSelectionKind = 'none' | 'text' | 'cell' | 'range' | 'row' | 'column' | 'table';
|
|
20
|
+
export interface IDocsTableCellRange {
|
|
21
|
+
startRow: number;
|
|
22
|
+
endRow: number;
|
|
23
|
+
startColumn: number;
|
|
24
|
+
endColumn: number;
|
|
25
|
+
}
|
|
26
|
+
export interface IDocsTableSelection extends IDocsTableCellRange {
|
|
27
|
+
kind: DocsTableSelectionKind;
|
|
28
|
+
unitId: string;
|
|
29
|
+
segmentId: string;
|
|
30
|
+
tableId: string;
|
|
31
|
+
startOffset: number;
|
|
32
|
+
endOffset: number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Disposable, IResourceManagerService } from '@univerjs/core';
|
|
2
|
+
import { DocsTableModel } from '../models/docs-table-model';
|
|
3
|
+
export declare class DocsTableResourceController extends Disposable {
|
|
4
|
+
private readonly _resourceManagerService;
|
|
5
|
+
private readonly _docsTableModel;
|
|
6
|
+
constructor(_resourceManagerService: IResourceManagerService, _docsTableModel: DocsTableModel);
|
|
7
|
+
private _initResource;
|
|
8
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { FDocsTable } from './f-docs-table';
|
|
2
|
+
import type { IDocsTableBorderOptions, IDocsTableCellContentRange, IDocsTableCellStyle } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Facade object for a single docs table cell.
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const cell = table.getCell(0, 0);
|
|
8
|
+
* cell?.setText('Owner');
|
|
9
|
+
* cell?.setBackgroundColor('#E8F1FF');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class FDocsTableCell {
|
|
13
|
+
private readonly _table;
|
|
14
|
+
private readonly _row;
|
|
15
|
+
private readonly _column;
|
|
16
|
+
constructor(_table: FDocsTable, _row: number, _column: number);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the parent table facade.
|
|
19
|
+
* @returns {FDocsTable} The parent table.
|
|
20
|
+
*/
|
|
21
|
+
getTable(): FDocsTable;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the zero-based row index.
|
|
24
|
+
* @returns {number} The row index.
|
|
25
|
+
*/
|
|
26
|
+
getRowIndex(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the zero-based column index.
|
|
29
|
+
* @returns {number} The column index.
|
|
30
|
+
*/
|
|
31
|
+
getColumnIndex(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Returns plain text in this cell.
|
|
34
|
+
* @returns {string} The cell text.
|
|
35
|
+
*/
|
|
36
|
+
getText(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the editable document range inside this cell.
|
|
39
|
+
* @returns {IDocsTableCellContentRange | null} The cell content range, or `null` if the cell does not exist.
|
|
40
|
+
*/
|
|
41
|
+
getContentRange(): IDocsTableCellContentRange | null;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the offset before this cell's final section break.
|
|
44
|
+
* @returns {number | null} The insertion offset, or `null` if the cell does not exist.
|
|
45
|
+
*/
|
|
46
|
+
getInsertOffset(): number | null;
|
|
47
|
+
/**
|
|
48
|
+
* Replaces the cell text.
|
|
49
|
+
* @param {string} text The new cell text.
|
|
50
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
51
|
+
*/
|
|
52
|
+
setText(text: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the cell background color.
|
|
55
|
+
* @param {string} color CSS color string, for example `#E8F1FF`.
|
|
56
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
57
|
+
*/
|
|
58
|
+
setBackgroundColor(color: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Applies supported cell style options.
|
|
61
|
+
* @param {IDocsTableCellStyle} style Cell style options.
|
|
62
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
63
|
+
*/
|
|
64
|
+
setStyle(style: IDocsTableCellStyle): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Applies border options to this cell.
|
|
67
|
+
* @param {IDocsTableBorderOptions} border Border preset and style options.
|
|
68
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
69
|
+
*/
|
|
70
|
+
setBorder(border: IDocsTableBorderOptions): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Merges this cell with a rectangular span starting from this cell.
|
|
73
|
+
* @param {number} rowSpan Number of rows to include.
|
|
74
|
+
* @param {number} columnSpan Number of columns to include.
|
|
75
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
76
|
+
*/
|
|
77
|
+
mergeTo(rowSpan: number, columnSpan: number): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Unmerges the merged range containing this cell.
|
|
80
|
+
* @returns {boolean} Whether the mutation succeeded.
|
|
81
|
+
*/
|
|
82
|
+
unmerge(): boolean;
|
|
83
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { ICommandService, IDocumentData, ITable } from '@univerjs/core';
|
|
2
|
+
import type { DocsTableSortDirection } from '../common/sort';
|
|
3
|
+
import type { IDocsTableOffsetRange } from '../common/table-range';
|
|
4
|
+
import type { IDocsTableColumnTypeConfig, IDocsTableMetadata } from '../common/type';
|
|
5
|
+
import type { DocsTableModel } from '../models/docs-table-model';
|
|
6
|
+
import type { DocsTableSelectionService } from '../services/docs-table-selection.service';
|
|
7
|
+
import type { IDocsTableBorderOptions, IDocsTableCellContentRange, IDocsTableCellStyle, IDocsTableDescription, IDocsTableInfo, IDocsTableRange, IDocsTableStyle } from './types';
|
|
8
|
+
import { FDocsTableCell } from './f-docs-table-cell';
|
|
9
|
+
export interface IFDocsTableContext {
|
|
10
|
+
unitId: string;
|
|
11
|
+
tableId: string;
|
|
12
|
+
getDocumentData: () => IDocumentData;
|
|
13
|
+
commandService: ICommandService;
|
|
14
|
+
model?: DocsTableModel;
|
|
15
|
+
selectionService?: DocsTableSelectionService;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Facade object for a single enhanced docs table.
|
|
19
|
+
*
|
|
20
|
+
* All mutating methods execute synchronously through the Univer command service and return
|
|
21
|
+
* `true` when the underlying document mutation succeeds.
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import '@univerjs-pro/docs-table/facade';
|
|
25
|
+
*
|
|
26
|
+
* const doc = univerAPI.getActiveDocument();
|
|
27
|
+
* const table = doc?.findTableByText('Status');
|
|
28
|
+
* table?.setCellText(1, 1, 'Done');
|
|
29
|
+
* table?.setTableBorder({ color: '#3367D6', width: 1 });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class FDocsTable {
|
|
33
|
+
private readonly _context;
|
|
34
|
+
constructor(_context: IFDocsTableContext);
|
|
35
|
+
/**
|
|
36
|
+
* Returns the table id.
|
|
37
|
+
* @returns {string} The table id stored in the document snapshot.
|
|
38
|
+
*/
|
|
39
|
+
getId(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns compact table metadata for agents.
|
|
42
|
+
* @returns {IDocsTableInfo} The id, row count, column count, metadata, and raw table source.
|
|
43
|
+
*/
|
|
44
|
+
getInfo(): IDocsTableInfo;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a human-readable table summary with sample rows.
|
|
47
|
+
* @returns {IDocsTableDescription} A compact description suitable for agents or logs.
|
|
48
|
+
*/
|
|
49
|
+
describe(): IDocsTableDescription;
|
|
50
|
+
getRowCount(): number;
|
|
51
|
+
getColumnCount(): number;
|
|
52
|
+
getCell(row: number, column: number): FDocsTableCell | null;
|
|
53
|
+
getCellText(row: number, column: number): string;
|
|
54
|
+
getMetadata(): IDocsTableMetadata | undefined;
|
|
55
|
+
getSource(): ITable | undefined;
|
|
56
|
+
getRange(): IDocsTableOffsetRange | null;
|
|
57
|
+
getTableRange(): IDocsTableRange;
|
|
58
|
+
getCellRange(row: number, column: number): IDocsTableRange;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the editable document range inside a table cell.
|
|
61
|
+
* The range excludes the table cell tokens and the final section break, so block/list facades
|
|
62
|
+
* can use it as their `startOffset`/`endOffset` target.
|
|
63
|
+
* @param {number} row The zero-based row index.
|
|
64
|
+
* @param {number} column The zero-based column index.
|
|
65
|
+
* @returns {IDocsTableCellContentRange | null} The cell content range, or `null` if the cell does not exist.
|
|
66
|
+
*/
|
|
67
|
+
getCellContentRange(row: number, column: number): IDocsTableCellContentRange | null;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the offset before the cell's final section break.
|
|
70
|
+
* Use this offset to insert an empty callout, quote, code block, or paragraph in the cell.
|
|
71
|
+
* @param {number} row The zero-based row index.
|
|
72
|
+
* @param {number} column The zero-based column index.
|
|
73
|
+
* @returns {number | null} The insertion offset, or `null` if the cell does not exist.
|
|
74
|
+
*/
|
|
75
|
+
getCellInsertOffset(row: number, column: number): number | null;
|
|
76
|
+
getRowRange(row: number): IDocsTableRange;
|
|
77
|
+
getRowsRange(startRow: number, count?: number): IDocsTableRange;
|
|
78
|
+
getColumnRange(column: number): IDocsTableRange;
|
|
79
|
+
getColumnsRange(startColumn: number, count?: number): IDocsTableRange;
|
|
80
|
+
selectTable(): boolean;
|
|
81
|
+
selectRow(row: number): boolean;
|
|
82
|
+
selectRows(startRow: number, count?: number): boolean;
|
|
83
|
+
selectColumn(column: number): boolean;
|
|
84
|
+
selectColumns(startColumn: number, count?: number): boolean;
|
|
85
|
+
selectCell(row: number, column: number): boolean;
|
|
86
|
+
selectRange(range: IDocsTableRange, kind?: 'cell' | 'range' | 'row' | 'column' | 'table'): boolean;
|
|
87
|
+
insertRowBefore(row: number): boolean;
|
|
88
|
+
insertRowAfter(row: number): boolean;
|
|
89
|
+
insertRowsBefore(row: number, count: number): boolean;
|
|
90
|
+
insertRowsAfter(row: number, count: number): boolean;
|
|
91
|
+
appendRow(): boolean;
|
|
92
|
+
insertColumnBefore(column: number): boolean;
|
|
93
|
+
insertColumnAfter(column: number): boolean;
|
|
94
|
+
insertColumnsBefore(column: number, count: number): boolean;
|
|
95
|
+
insertColumnsAfter(column: number, count: number): boolean;
|
|
96
|
+
appendColumn(): boolean;
|
|
97
|
+
deleteRow(row: number): boolean;
|
|
98
|
+
deleteRows(startRow: number, count?: number): boolean;
|
|
99
|
+
deleteColumn(column: number): boolean;
|
|
100
|
+
deleteColumns(startColumn: number, count?: number): boolean;
|
|
101
|
+
deleteTable(): boolean;
|
|
102
|
+
moveTableBy(deltaX: number, deltaY: number): boolean;
|
|
103
|
+
moveTableToOffset(offset: number): boolean;
|
|
104
|
+
moveRow(row: number, targetRow: number, position?: 'before' | 'after'): boolean;
|
|
105
|
+
moveRows(startRow: number, count: number, targetRow: number, position?: 'before' | 'after'): boolean;
|
|
106
|
+
moveColumn(column: number, targetColumn: number, position?: 'before' | 'after'): boolean;
|
|
107
|
+
moveColumns(startColumn: number, count: number, targetColumn: number, position?: 'before' | 'after'): boolean;
|
|
108
|
+
mergeCells(range: IDocsTableRange): boolean;
|
|
109
|
+
unmergeCells(range: IDocsTableRange): boolean;
|
|
110
|
+
setCellText(row: number, column: number, text: string): boolean;
|
|
111
|
+
setCellStyle(range: IDocsTableRange, style: IDocsTableCellStyle): boolean;
|
|
112
|
+
setCellBackground(range: IDocsTableRange, color: string): boolean;
|
|
113
|
+
setBorder(range: IDocsTableRange, options: IDocsTableBorderOptions): boolean;
|
|
114
|
+
setTableBackground(color: string): boolean;
|
|
115
|
+
setTableBorder(border: IDocsTableBorderOptions): boolean;
|
|
116
|
+
setTableStyle(style: IDocsTableStyle): boolean;
|
|
117
|
+
setRowHeight(row: number, height: number): boolean;
|
|
118
|
+
setColumnWidth(column: number, width: number): boolean;
|
|
119
|
+
distributeRows(startRow?: number, count?: number): boolean;
|
|
120
|
+
distributeColumns(startColumn?: number, count?: number): boolean;
|
|
121
|
+
getHeaderRowCount(): number;
|
|
122
|
+
setHeaderRowCount(count: number): boolean;
|
|
123
|
+
pinHeaderRows(count: number): boolean;
|
|
124
|
+
hasTitleRow(): boolean;
|
|
125
|
+
insertTitleRow(): boolean;
|
|
126
|
+
setColumnType(column: number, config: IDocsTableColumnTypeConfig): boolean;
|
|
127
|
+
sortByColumn(column: number, direction: DocsTableSortDirection): boolean;
|
|
128
|
+
private _documentData;
|
|
129
|
+
private _mutate;
|
|
130
|
+
}
|