@univerjs-pro/sheets-shape 0.19.0 → 0.20.0

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.
@@ -0,0 +1,181 @@
1
+ import type { ICxnShapeData, IShapeRelationItem, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
2
+ import type { Injector } from '@univerjs/core';
3
+ import type { IShapeBuilderInfo } from './f-shape';
4
+ import { FShape } from './f-shape';
5
+ /**
6
+ * The connector shape builder. It extends `FShape` and adds connector-specific properties
7
+ * such as start/end arrow types and sizes. Use `fWorksheet.newConnector()` to create a new connector builder.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const fWorkbook = univerAPI.getActiveWorkbook();
12
+ * const fWorksheet = fWorkbook.getActiveSheet();
13
+ *
14
+ * // Create a straight connector with arrows
15
+ * const connectorInfo = fWorksheet.newConnector()
16
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
17
+ * .setPosition(1, 1, 0, 0)
18
+ * .setWidth(200)
19
+ * .setHeight(100)
20
+ * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
21
+ * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
22
+ * .setStrokeColor('#000000')
23
+ * .setStrokeWidth(2)
24
+ * .build();
25
+ * await fWorksheet.insertShape(connectorInfo);
26
+ * ```
27
+ */
28
+ export declare class FConnectorShape extends FShape {
29
+ /**
30
+ * @property {ICxnShapeData} shapeData The connector shape data containing line styles, arrow settings, and connection info.
31
+ */
32
+ shapeData: ICxnShapeData;
33
+ constructor(unitId: string, subUnitId: string, drawingId: string, injector: Injector);
34
+ setShapeType(shapeType: ShapeTypeEnum): this;
35
+ /**
36
+ * Sets the start arrow type of the connector line.
37
+ * @param {ShapeArrowTypeEnum} arrowType The arrow type for the start point. Which can be found from `univerAPI.Enum.ShapeArrowTypeEnum`.
38
+ * @returns {FConnectorShape} this builder, for chaining.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const fWorkbook = univerAPI.getActiveWorkbook();
43
+ * const fWorksheet = fWorkbook.getActiveSheet();
44
+ *
45
+ * const connectorInfo = fWorksheet.newConnector()
46
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
47
+ * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
48
+ * .setPosition(1, 1, 0, 0)
49
+ * .build();
50
+ * await fWorksheet.insertShape(connectorInfo);
51
+ * ```
52
+ */
53
+ setStartArrowType(arrowType: ShapeArrowTypeEnum): this;
54
+ /**
55
+ * Sets the end arrow type of the connector line.
56
+ * @param {ShapeArrowTypeEnum} arrowType The arrow type for the end point. Which can be found from `univerAPI.Enum.ShapeArrowTypeEnum`.
57
+ * @returns {FConnectorShape} this builder, for chaining.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const fWorkbook = univerAPI.getActiveWorkbook();
62
+ * const fWorksheet = fWorkbook.getActiveSheet();
63
+ *
64
+ * const connectorInfo = fWorksheet.newConnector()
65
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
66
+ * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.StealthArrow)
67
+ * .setPosition(1, 1, 0, 0)
68
+ * .build();
69
+ * await fWorksheet.insertShape(connectorInfo);
70
+ * ```
71
+ */
72
+ setEndArrowType(arrowType: ShapeArrowTypeEnum): this;
73
+ /**
74
+ * Sets the start arrow size of the connector line.
75
+ * @param {ShapeArrowSizeEnum} arrowSize The arrow size for the start point.
76
+ * @returns {FConnectorShape} this builder, for chaining.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const fWorkbook = univerAPI.getActiveWorkbook();
81
+ * const fWorksheet = fWorkbook.getActiveSheet();
82
+ *
83
+ * const connectorInfo = fWorksheet.newConnector()
84
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
85
+ * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.OvalArrow)
86
+ * .setStartArrowSize(univerAPI.Enum.ShapeArrowSizeEnum.Large)
87
+ * .setPosition(1, 1, 0, 0)
88
+ * .setWidth(200)
89
+ * .build();
90
+ * await fWorksheet.insertShape(connectorInfo);
91
+ * ```
92
+ */
93
+ setStartArrowSize(arrowSize: ShapeArrowSizeEnum): this;
94
+ /**
95
+ * Sets the end arrow size of the connector line.
96
+ * @param {ShapeArrowSizeEnum} arrowSize The arrow size for the end point.
97
+ * @returns {FConnectorShape} this builder, for chaining.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const fWorkbook = univerAPI.getActiveWorkbook();
102
+ * const fWorksheet = fWorkbook.getActiveSheet();
103
+ *
104
+ * const connectorInfo = fWorksheet.newConnector()
105
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
106
+ * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
107
+ * .setEndArrowSize(univerAPI.Enum.ShapeArrowSizeEnum.Large)
108
+ * .setStrokeWidth(3)
109
+ * .setPosition(1, 1, 0, 0)
110
+ * .build();
111
+ * await fWorksheet.insertShape(connectorInfo);
112
+ * ```
113
+ */
114
+ setEndArrowSize(arrowSize: ShapeArrowSizeEnum): this;
115
+ /**
116
+ * Builds the connector shape builder info. This method does not automatically draw the connector on top of the spreadsheet.
117
+ * A new connector must be inserted via `fWorksheet.insertShape(shapeInfo)`.
118
+ * @returns {IShapeBuilderInfo} The shape builder info containing all the accumulated properties.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const fWorkbook = univerAPI.getActiveWorkbook();
123
+ * const fWorksheet = fWorkbook.getActiveSheet();
124
+ *
125
+ * const connectorInfo = fWorksheet.newConnector()
126
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
127
+ * .setPosition(1, 1, 0, 0)
128
+ * .setWidth(200)
129
+ * .setHeight(100)
130
+ * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
131
+ * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
132
+ * .setStrokeColor('#000000')
133
+ * .setStrokeWidth(2)
134
+ * .build();
135
+ * await fWorksheet.insertShape(connectorInfo);
136
+ * ```
137
+ */
138
+ build(): IShapeBuilderInfo;
139
+ /**
140
+ * Returns the end connection info for this connector shape.
141
+ * If this connector's end point is connected to a basic shape, returns the target shape id and connection site index.
142
+ * @returns {IShapeRelationItem | null} The end connection info, or `null` if not connected.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const fWorkbook = univerAPI.getActiveWorkbook();
147
+ * const fWorksheet = fWorkbook.getActiveSheet();
148
+ * const shapes = fWorksheet.getShapes();
149
+ * const connector = shapes.find((s) => s.isLineShape());
150
+ *
151
+ * if (connector) {
152
+ * const endInfo = connector.getEndConnectInfo();
153
+ * if (endInfo) {
154
+ * console.log(`End connected to shape ${endInfo.shapeId} at site ${endInfo.cxnIndex}`);
155
+ * }
156
+ * }
157
+ * ```
158
+ */
159
+ getEndConnectInfo(): IShapeRelationItem | null;
160
+ /**
161
+ * Returns the start connection info for this connector shape.
162
+ * If this connector's start point is connected to a basic shape, returns the target shape id and connection site index.
163
+ * @returns {IShapeRelationItem | null} The start connection info, or `null` if not connected.
164
+ *
165
+ * @example
166
+ * ```ts
167
+ * const fWorkbook = univerAPI.getActiveWorkbook();
168
+ * const fWorksheet = fWorkbook.getActiveSheet();
169
+ * const shapes = fWorksheet.getShapes();
170
+ * const connector = shapes.find((s) => s.isLineShape());
171
+ *
172
+ * if (connector) {
173
+ * const startInfo = connector.getStartConnectInfo();
174
+ * if (startInfo) {
175
+ * console.log(`Start connected to shape ${startInfo.shapeId} at site ${startInfo.cxnIndex}`);
176
+ * }
177
+ * }
178
+ * ```
179
+ */
180
+ getStartConnectInfo(): IShapeRelationItem | null;
181
+ }
@@ -0,0 +1,194 @@
1
+ import { ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
2
+ /**
3
+ * @ignore
4
+ */
5
+ export interface IFSheetsShapeEnumMixin {
6
+ /**
7
+ * Represents the type of the shape. {@link ShapeTypeEnum}
8
+ * @description This enum defines almost all Excel supported shape types, including basic shapes, block arrows, flowchart shapes, callouts, stars and banners, symbols, and lines.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const fWorkbook = univerAPI.getActiveWorkbook();
13
+ * const fWorksheet = fWorkbook.getActiveSheet();
14
+ *
15
+ * // Create a rectangle shape.
16
+ * const shapeInfo = fWorksheet.newShape()
17
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Diamond)
18
+ * .setPosition(1, 1, 0, 0)
19
+ * .build();
20
+ * await fWorksheet.insertShape(shapeInfo);
21
+ * ```
22
+ */
23
+ ShapeTypeEnum: typeof ShapeTypeEnum;
24
+ /**
25
+ * Represents the fill type of the shape. {@link ShapeFillEnum}
26
+ * The possible values are: NoFill, SolidFil, GradientFill, PatternFill, PictureFill.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const fWorkbook = univerAPI.getActiveWorkbook();
31
+ * const fWorksheet = fWorkbook.getActiveSheet();
32
+ *
33
+ * // Create a rectangle shape with solid fill.
34
+ * const shapeInfo = fWorksheet.newShape()
35
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
36
+ * .setShapeSolidFill('#ff0000')
37
+ * .setPosition(1, 1, 0, 0)
38
+ * .build();
39
+ * await fWorksheet.insertShape(shapeInfo);
40
+ * ```
41
+ */
42
+ ShapeFillEnum: typeof ShapeFillEnum;
43
+ /**
44
+ * Represents the gradient type of the shape fill. {@link ShapeGradientTypeEnum}
45
+ * The possible values are: Linear, Radial, Angular, Diamond.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const fWorkbook = univerAPI.getActiveWorkbook();
50
+ * const fWorksheet = fWorkbook.getActiveSheet();
51
+ *
52
+ * // Create a rectangle shape with linear gradient fill.
53
+ * const shapeInfo = fWorksheet.newShape()
54
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
55
+ * .setShapeGradientFill(univerAPI.Enum.ShapeGradientTypeEnum.Linear, [{
56
+ * position: 0,
57
+ * color: '#ff0000'
58
+ * }, {
59
+ * position: 0.5,
60
+ * color: '#00ff00'
61
+ * }, {
62
+ * position: 1,
63
+ * color: '#0000ff'
64
+ * }], 90 )
65
+ * .setPosition(1, 1, 0, 0)
66
+ * .build();
67
+ * await fWorksheet.insertShape(shapeInfo);
68
+ * ```
69
+ */
70
+ ShapeGradientTypeEnum: typeof ShapeGradientTypeEnum;
71
+ /**
72
+ * Represents the line fill type of the shape stroke. {@link ShapeLineTypeEnum}
73
+ * The possible values are: NoLine, SolidLine, GradientLine.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const fWorkbook = univerAPI.getActiveWorkbook();
78
+ * const fWorksheet = fWorkbook.getActiveSheet();
79
+ *
80
+ * // Create a rectangle shape with solid line stroke type.
81
+ * const shapeInfo = fWorksheet.newShape()
82
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
83
+ * .setStrokeLineType(univerAPI.Enum.ShapeLineTypeEnum.SolidLine)
84
+ * .setStrokeColor('#000000')
85
+ * .setPosition(1, 1, 0, 0)
86
+ * .build();
87
+ * await fWorksheet.insertShape(shapeInfo);
88
+ * ```
89
+ */
90
+ ShapeLineTypeEnum: typeof ShapeLineTypeEnum;
91
+ /**
92
+ * Represents the line dash type of the shape stroke. {@link ShapeLineDashEnum}
93
+ * The possible values are: Solid, RoundDot, SquareDot, Dash, DashDot, LongDash, LongDashDot, LongDashDotDot.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const fWorkbook = univerAPI.getActiveWorkbook();
98
+ * const fWorksheet = fWorkbook.getActiveSheet();
99
+ *
100
+ * // Create a rectangle shape with dashed stroke.
101
+ * const shapeInfo = fWorksheet.newShape()
102
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
103
+ * .setStrokeLineDashType(univerAPI.Enum.ShapeLineDashEnum.Dash)
104
+ * .setPosition(1, 1, 0, 0)
105
+ * .build();
106
+ * await fWorksheet.insertShape(shapeInfo);
107
+ * ```
108
+ */
109
+ ShapeLineDashEnum: typeof ShapeLineDashEnum;
110
+ /**
111
+ * Represents the line cap type of the shape stroke. {@link ShapeLineCapEnum}
112
+ * The possible values are: Flat, Round, Square.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const fWorkbook = univerAPI.getActiveWorkbook();
117
+ * const fWorksheet = fWorkbook.getActiveSheet();
118
+ *
119
+ * // Create a rectangle shape with round line cap.
120
+ * const shapeInfo = fWorksheet.newShape()
121
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
122
+ * .setStrokeLineCapType(univerAPI.Enum.ShapeLineCapEnum.Round)
123
+ * .setPosition(1, 1, 0, 0)
124
+ * .build();
125
+ * await fWorksheet.insertShape(shapeInfo);
126
+ * ```
127
+ */
128
+ ShapeLineCapEnum: typeof ShapeLineCapEnum;
129
+ /**
130
+ * Represents the line join type of the shape stroke. {@link ShapeLineJoinEnum}
131
+ * The possible values are: Miter, Round, Bevel.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const fWorkbook = univerAPI.getActiveWorkbook();
136
+ * const fWorksheet = fWorkbook.getActiveSheet();
137
+ *
138
+ * // Create a rectangle shape with round line join.
139
+ * const shapeInfo = fWorksheet.newShape()
140
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
141
+ * .setStrokeLineJoinType(univerAPI.Enum.ShapeLineJoinEnum.Round)
142
+ * .setPosition(1, 1, 0, 0)
143
+ * .build();
144
+ * await fWorksheet.insertShape(shapeInfo);
145
+ * ```
146
+ */
147
+ ShapeLineJoinEnum: typeof ShapeLineJoinEnum;
148
+ /**
149
+ * Represents the arrow type of connector line shape. {@link ShapeArrowTypeEnum}
150
+ * The possible values are: None, Arrow, OpenArrow, DiamondArrow, StealthArrow, OvalArrow.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const fWorkbook = univerAPI.getActiveWorkbook();
155
+ * const fWorksheet = fWorkbook.getActiveSheet();
156
+ *
157
+ * // Create a line shape with arrow type.
158
+ * const shapeInfo = fWorksheet.newConnector()
159
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1)
160
+ * .setPosition(1, 1, 0, 0)
161
+ * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow)
162
+ * .setStrokeWidth(3)
163
+ * .build();
164
+ * await fWorksheet.insertShape(shapeInfo);
165
+ * ```
166
+ */
167
+ ShapeArrowTypeEnum: typeof ShapeArrowTypeEnum;
168
+ /**
169
+ * Represents the arrow size of connector line shape. {@link ShapeArrowSizeEnum}
170
+ * The possible values are:Small, Medium, Large.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const fWorkbook = univerAPI.getActiveWorkbook();
175
+ * const fWorksheet = fWorkbook.getActiveSheet();
176
+ * // Create a line shape with arrow size.
177
+ * const shapeInfo = fWorksheet.newConnector()
178
+ * .setShapeType(univerAPI.Enum.ShapeTypeEnum.BentConnector3)
179
+ * .setPosition(1, 1, 0, 0)
180
+ * .setStartArrowSize(univerAPI.Enum.ShapeArrowSizeEnum.Medium)
181
+ * .setStrokeWidth(3)
182
+ * .build();
183
+ * await fWorksheet.insertShape(shapeInfo);
184
+ * ```
185
+ */
186
+ ShapeArrowSizeEnum: typeof ShapeArrowSizeEnum;
187
+ }
188
+ /**
189
+ * @ignore
190
+ */
191
+ declare module '@univerjs/core/facade' {
192
+ interface FEnum extends IFSheetsShapeEnumMixin {
193
+ }
194
+ }