Skip to content

Commit 1a29f0e

Browse files
committed
feat: doc support table
1 parent 706aa04 commit 1a29f0e

File tree

3 files changed

+75
-41
lines changed

3 files changed

+75
-41
lines changed

packages/core/src/docs/data-model/types.ts

-9
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ export enum DataStreamTreeNodeType {
2525
TABLE_ROW,
2626
TABLE_CELL,
2727
CUSTOM_BLOCK, // \b 图片 mention 等不参与文档流的场景
28-
// TABLE_START, // \x1A 表格开始
29-
// TABLE_ROW_START, // \x1B 表格开始
30-
// TABLE_CELL_START, // \x1C 表格开始
31-
// TABLE_CELL_END, //* \x1D 表格开始
32-
// TABLE_ROW_END, // \x1E 表格开始
33-
// TABLE_END, // \x1F 表格结束
34-
// CUSTOM_RANGE_START, // \x1F 自定义范围开始
35-
// CUSTOM_RANGE_END, // \x1E 自定义范围结束
3628
}
3729

3830
export enum DataStreamTreeTokenType {
@@ -54,6 +46,5 @@ export enum DataStreamTreeTokenType {
5446
CUSTOM_BLOCK = '\b', // 图片 mention 等不参与文档流的场景
5547

5648
LETTER = '',
57-
5849
SPACE = ' ',
5950
}

packages/core/src/types/interfaces/i-document-data.ts

+75-26
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,36 @@ export interface IShading {
746746
backgroundColor: IColorStyle; // backgroundColor
747747
}
748748

749-
/**
750-
* Type of width
751-
*/
752-
export enum WidthType {
753-
EVENLY_DISTRIBUTED = '0',
754-
FIXED_WIDTH = '1',
749+
export interface IDistFromText {
750+
distT: INumberUnit; // distance between top text and table.
751+
distB: INumberUnit; // distance between bottom text and table.
752+
distL: INumberUnit; // distance between left text and table.
753+
distR: INumberUnit; // distance between right text and table.
754+
}
755+
756+
export interface IDocTablePosition {
757+
positionH: IObjectPositionH;
758+
positionV: IObjectPositionV;
759+
}
760+
761+
enum TableSizeType {
762+
UNSPECIFIED,
763+
SPECIFIED,
764+
}
765+
export interface IWidthInTableSize {
766+
type: TableSizeType;
767+
width: INumberUnit;
768+
}
769+
770+
enum TableHAlign {
771+
LEFT,
772+
CENTER,
773+
RIGHT,
774+
}
775+
776+
enum TableTextWrapType {
777+
NONE,
778+
WRAP,
755779
}
756780

757781
/**
@@ -763,8 +787,28 @@ export interface ITable {
763787
rows: number; // rows
764788
columns: number; // columns
765789
tableRows: ITableRow[]; // tableRows
766-
tableStyle: WidthType; // tableStyle
767-
width: number; // width
790+
tableColumns: ITableColumn[]; // tableColumns
791+
align: TableHAlign; // align
792+
leftIndent: INumberUnit; // leftIndent
793+
textWrap: TableTextWrapType;
794+
position: IDocTablePosition; // position
795+
dist: IDistFromText; // dist
796+
size: IWidthInTableSize;
797+
}
798+
799+
enum TableCellHeightRule {
800+
MIN,
801+
FIX,
802+
}
803+
804+
export interface ITableColumn {
805+
size: IWidthInTableSize;
806+
}
807+
808+
export interface ITableRowSize {
809+
type: TableSizeType;
810+
height: INumberUnit;
811+
heightRule: TableCellHeightRule;
768812
}
769813

770814
/**
@@ -774,22 +818,18 @@ export interface ITableRow {
774818
st: number; // startIndex
775819
ed: number; // endIndex
776820
tableCells: ITableCell[]; // tableCells
777-
tableRowStyle: ITableRowStyle; // tableRowStyle
778-
}
779-
780-
/**
781-
* Properties of style table row
782-
*/
783-
export interface ITableRowStyle {
784-
minRowHeight: number; // minRowHeight
821+
size: ITableRowSize; // tableRowStyle
822+
allowBreakAcrossPages: BooleanNumber; // allowBreakAcrossPages, the default is false.
823+
isFirstRow: BooleanNumber; // isFirstRow.
824+
repeatHeaderRow: BooleanNumber; // Show header row in different pages. only for the first row.
785825
}
786826

787827
/**
788828
* Properties of table cell
789829
*/
790830
export interface ITableCell {
791-
// st: number; // startIndex
792-
// ed: number; // endIndex
831+
st: number; // startIndex
832+
ed: number; // endIndex
793833
// content: IBlockElement[]; // content
794834
tableCellStyle: ITableCellStyle; // tableCellStyle
795835
}
@@ -805,32 +845,40 @@ export interface ITableCellStyle {
805845
borderRight: ITableCellBorder; // borderRight
806846
borderTop: ITableCellBorder; // borderTop
807847
borderBottom: ITableCellBorder; // borderBottom
808-
paddingLeft: number; // paddingLeft
809-
paddingRight: number; // paddingRight
810-
paddingTop: number; // paddingTop
811-
paddingBottom: number; // paddingBottom
812-
contentAlignment: ContentAlignment; // contentAlignment
848+
paddingLeft: INumberUnit; // paddingLeft
849+
paddingRight: INumberUnit; // paddingRight
850+
paddingTop: INumberUnit; // paddingTop
851+
paddingBottom: INumberUnit; // paddingBottom
852+
size: IWidthInTableSize; // size
853+
contentHAlignment: ContentHAlignment; // contentAlignment
854+
contentVAlignment: ContentVAlignment; // contentAlignment
813855
}
814856

815857
/**
816858
* Properties of cell border
817859
*/
818860
export interface ITableCellBorder {
819861
color: IColorStyle; // color
820-
width: number; // width
862+
width: INumberUnit; // width
821863
dashStyle: DashStyleType; // dashStyle
822864
}
823865
/**
824866
* The content alignments for a Shape or TableCell. The supported alignments correspond to predefined text anchoring types from the ECMA-376 standard.
825867
*/
826-
export enum ContentAlignment {
868+
export enum ContentVAlignment {
827869
CONTENT_ALIGNMENT_UNSPECIFIED, // An unspecified content alignment. The content alignment is inherited from the parent if one exists.
828-
CONTENT_ALIGNMENT_UNSUPPORTED, // An unsupported content alignment.
829870
TOP, // An alignment that aligns the content to the top of the content holder. Corresponds to ECMA-376 ST_TextAnchoringType 't'.
830871
MIDDLE, // An alignment that aligns the content to the middle of the content holder. Corresponds to ECMA-376 ST_TextAnchoringType 'ctr'.
831872
BOTTOM, // An alignment that aligns the content to the bottom of the content holder. Corresponds to ECMA-376 ST_TextAnchoringType 'b'.
832873
}
833874

875+
export enum ContentHAlignment {
876+
CONTENT_ALIGNMENT_UNSPECIFIED, // An unspecified content alignment. The content alignment is inherited from the parent if one exists.
877+
LEFT, // An alignment that aligns the content to the left of the content holder.
878+
CENTER, // An alignment that aligns the content to the center of the content holder.
879+
RIGHT, // An alignment that aligns the content to the right of the content holder.
880+
}
881+
834882
/**
835883
* Types of font style
836884
*/
@@ -889,6 +937,7 @@ export enum NumberUnitType {
889937
LINE,
890938
CHARACTER,
891939
PIXEL,
940+
PERCENT,
892941
}
893942

894943
// 20.4.3.1 ST_AlignH (Relative Horizontal Alignment Positions)

packages/engine-render/src/components/docs/view-model/data-stream-tree-node.ts

-6
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@ import {
2525

2626
export class DataStreamTreeNode {
2727
children: DataStreamTreeNode[] = [];
28-
2928
parent: Nullable<DataStreamTreeNode>;
30-
3129
startIndex: number = -1;
32-
3330
endIndex: number = -1;
34-
3531
// isBullet: boolean = false;
36-
3732
// isIndent: boolean = false;
38-
3933
blocks: number[] = [];
4034

4135
constructor(

0 commit comments

Comments
 (0)