@univerjs-pro/sheets-shape-ui 0.15.5 → 0.16.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.
- package/README.md +30 -0
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -0
- package/lib/es/index.js +1 -1
- package/lib/es/locale/ca-ES.js +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/es-ES.js +1 -1
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/es/locale/fr-FR.js +1 -1
- package/lib/es/locale/ja-JP.js +1 -1
- package/lib/es/locale/ko-KR.js +1 -1
- package/lib/es/locale/ru-RU.js +1 -1
- package/lib/es/locale/sk-SK.js +1 -1
- package/lib/es/locale/vi-VN.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +1 -0
- package/lib/index.css +1 -0
- package/lib/index.js +1 -1
- package/lib/locale/ca-ES.js +1 -1
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/es-ES.js +1 -1
- package/lib/locale/fa-IR.js +1 -1
- package/lib/locale/fr-FR.js +1 -1
- package/lib/locale/ja-JP.js +1 -1
- package/lib/locale/ko-KR.js +1 -1
- package/lib/locale/ru-RU.js +1 -1
- package/lib/locale/sk-SK.js +1 -1
- package/lib/locale/vi-VN.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/commands/command/set-shape-drawing-data-command.d.ts +13 -0
- package/lib/types/controllers/shape-sheet-change.controller.d.ts +12 -0
- package/lib/types/controllers/shape-text-editing.render-controller.d.ts +3 -3
- package/lib/types/controllers/shape-update.controller.d.ts +1 -0
- package/lib/types/controllers/sheet-basic-shape-connection.controller.d.ts +3 -3
- package/lib/types/controllers/sheet-shape-adjust-controller.d.ts +3 -3
- package/lib/types/controllers/sheet-shape-clipboard.controller.d.ts +20 -0
- package/lib/types/controllers/sheet-shape-command-interceptor.controller.d.ts +3 -3
- package/lib/types/controllers/sheet-shape-connector.controller.d.ts +3 -3
- package/lib/types/controllers/sheet-shape-render.controller.d.ts +3 -3
- package/lib/types/controllers/sheets-shape-ui.controller.d.ts +3 -3
- package/lib/types/facade/f-connector-shape.d.ts +180 -0
- package/lib/types/facade/f-enum.d.ts +194 -0
- package/lib/types/facade/f-shape.d.ts +642 -0
- package/lib/types/facade/f-worksheet.d.ts +231 -0
- package/lib/types/facade/index.d.ts +13 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/views/shape-text-editor/index.d.ts +1 -2
- package/lib/types/views/shape-text-editor/position-wrapper.d.ts +1 -2
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +26 -16
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import { IShapeData, IShapePoint, IShapeRelationItem, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
|
|
2
|
+
import { Injector } from '@univerjs/core';
|
|
3
|
+
/**
|
|
4
|
+
* The shape builder info. It is the return value of the `build()` method. It contains all the information needed to insert a shape.
|
|
5
|
+
*/
|
|
6
|
+
export interface IShapeBuilderInfo {
|
|
7
|
+
/**
|
|
8
|
+
* @property {string} unitId The workbook id where the shape is located.
|
|
9
|
+
*/
|
|
10
|
+
unitId: string;
|
|
11
|
+
/**
|
|
12
|
+
* @property {string} subUnitId The worksheet id where the shape is located.
|
|
13
|
+
*/
|
|
14
|
+
subUnitId: string;
|
|
15
|
+
/**
|
|
16
|
+
* @property {string} shapeId The id of the shape.
|
|
17
|
+
*/
|
|
18
|
+
shapeId: string;
|
|
19
|
+
/**
|
|
20
|
+
* @property {ShapeTypeEnum} shapeType The type of the shape.
|
|
21
|
+
*/
|
|
22
|
+
shapeType: ShapeTypeEnum;
|
|
23
|
+
/**
|
|
24
|
+
* @property {IShapeData} [shapeData] The shape data containing fill and stroke styles.
|
|
25
|
+
*/
|
|
26
|
+
shapeData?: IShapeData;
|
|
27
|
+
/**
|
|
28
|
+
* @property {number} x The x-coordinate of the shape.
|
|
29
|
+
*/
|
|
30
|
+
x: number;
|
|
31
|
+
/**
|
|
32
|
+
* @property {number} y The y-coordinate of the shape.
|
|
33
|
+
*/
|
|
34
|
+
y: number;
|
|
35
|
+
/**
|
|
36
|
+
* @property {number} width The width of the shape.
|
|
37
|
+
*/
|
|
38
|
+
width: number;
|
|
39
|
+
/**
|
|
40
|
+
* @property {number} height The height of the shape.
|
|
41
|
+
*/
|
|
42
|
+
height: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The shape builder. It is used to create or update a shape in the sheet.
|
|
46
|
+
* All set methods store properties on the builder instance, and the `build()` method
|
|
47
|
+
* returns an `IShapeBuilderInfo` object that can be used with `fWorksheet.insertShape()`.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
52
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
53
|
+
*
|
|
54
|
+
* // Create a rectangle shape at cell B2 with offset
|
|
55
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
56
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
57
|
+
* .setPosition(1, 1, 0, 0)
|
|
58
|
+
* .setWidth(200)
|
|
59
|
+
* .setHeight(200)
|
|
60
|
+
* .setShapeSolidFill('#000000')
|
|
61
|
+
* .setStrokeColor('#000000')
|
|
62
|
+
* .setStrokeWidth(2)
|
|
63
|
+
* .build();
|
|
64
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class FShape {
|
|
68
|
+
/**
|
|
69
|
+
* @property {string} unitId The workbook id where the shape is located.
|
|
70
|
+
*/
|
|
71
|
+
unitId: string;
|
|
72
|
+
/**
|
|
73
|
+
* @property {string} subUnitId The worksheet id where the shape is located.
|
|
74
|
+
*/
|
|
75
|
+
subUnitId: string;
|
|
76
|
+
/**
|
|
77
|
+
* @property {string} drawId The id of the shape.
|
|
78
|
+
*/
|
|
79
|
+
drawId: string;
|
|
80
|
+
/**
|
|
81
|
+
* @property {number} x The x-coordinate of the shape. IF not set, it will default to 100 when building the shape info.
|
|
82
|
+
*/
|
|
83
|
+
x: number;
|
|
84
|
+
/**
|
|
85
|
+
* @property {number} y The y-coordinate of the shape. If not set, it will default to 100 when building the shape info.
|
|
86
|
+
*/
|
|
87
|
+
y: number;
|
|
88
|
+
/**
|
|
89
|
+
* @property {number} width The width of the shape in pixels.
|
|
90
|
+
*/
|
|
91
|
+
width: number;
|
|
92
|
+
/**
|
|
93
|
+
* @property {number} height The height of the shape in pixels.
|
|
94
|
+
*/
|
|
95
|
+
height: number;
|
|
96
|
+
/**
|
|
97
|
+
* @property {ShapeTypeEnum | undefined} shapeType The type of the shape.
|
|
98
|
+
*/
|
|
99
|
+
shapeType: ShapeTypeEnum | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* @property {IShapeData} shapeData The shape data containing fill and stroke styles.
|
|
102
|
+
*/
|
|
103
|
+
shapeData: IShapeData;
|
|
104
|
+
private _injector;
|
|
105
|
+
constructor(unitId: string, subUnitId: string, drawingId: string, injector: Injector);
|
|
106
|
+
/**
|
|
107
|
+
* Sets the position, changing where the shape appears on the sheet. anchorRowPos and anchorColPos are 0-indexed.
|
|
108
|
+
* @description The shape's start anchor position is the top left-hand corner of the shape. The rowOffset and columnOffset are the pixel offsets from the anchor position.
|
|
109
|
+
* @param {number} anchorRowPos The shape's top side is anchored in this row.
|
|
110
|
+
* @param {number} anchorColPos The shape's left side is anchored in this column.
|
|
111
|
+
* @param {number} rowOffset The shape's top left-hand corner is offset by this many pixels from the row.
|
|
112
|
+
* @param {number} columnOffset The shape's top left-hand corner is offset by this many pixels from the column.
|
|
113
|
+
* @returns {FShape} this builder, for chaining.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
118
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
119
|
+
*
|
|
120
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
121
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
122
|
+
* .setPosition(2, 5, 20, 20)
|
|
123
|
+
* .build();
|
|
124
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
setPosition(anchorRowPos: number, anchorColPos: number, rowOffset: number, columnOffset: number): this;
|
|
128
|
+
/**
|
|
129
|
+
* Sets the position by absolute pixel coordinates.
|
|
130
|
+
* @description The shape's start anchor position is the top left-hand corner of the shape.
|
|
131
|
+
* @param {number} x The x-coordinate of the shape's top left-hand corner.
|
|
132
|
+
* @param {number} y The y-coordinate of the shape's top left-hand corner.
|
|
133
|
+
* @returns {FShape} this builder, for chaining.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
138
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
139
|
+
*
|
|
140
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
141
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
142
|
+
* .setAbsolutePosition(100, 200)
|
|
143
|
+
* .build();
|
|
144
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
setAbsolutePosition(x: number, y: number): this;
|
|
148
|
+
/**
|
|
149
|
+
* Sets the type of the shape.
|
|
150
|
+
* @param {ShapeTypeEnum} shapeType The type of shape to create. Which can be found from `univerAPI.Enum.ShapeTypeEnum`.
|
|
151
|
+
* @returns {FShape} this builder, for chaining.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
156
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
157
|
+
*
|
|
158
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
159
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
160
|
+
* .setPosition(1, 1, 0, 0)
|
|
161
|
+
* .build();
|
|
162
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
setShapeType(shapeType: ShapeTypeEnum): this;
|
|
166
|
+
/**
|
|
167
|
+
* Sets the solid fill style for the shape.
|
|
168
|
+
* @param {string} color The fill color, e.g., '#ff0000'. If not specified, it will default to '#156082'.If the opacity is set both, the color string should be hex string or rgb string, the color like 'red' will not work.
|
|
169
|
+
* @param {number} [opacity] The opacity of the fill (0 to 1).
|
|
170
|
+
* @returns {FShape} this builder, for chaining.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
175
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
176
|
+
*
|
|
177
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
178
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
179
|
+
* .setShapeSolidFill('#f0f000', 0.8)
|
|
180
|
+
* .setPosition(1, 1, 0, 0)
|
|
181
|
+
* .build();
|
|
182
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
setShapeSolidFill(color: string, opacity?: number): this;
|
|
186
|
+
/**
|
|
187
|
+
* Sets the gradient fill style for the shape.
|
|
188
|
+
* @param {ShapeGradientTypeEnum} shapeGradientType The gradient type. Which can be found from `univerAPI.Enum.ShapeGradientTypeEnum`.
|
|
189
|
+
* @param {Array<{ position: number; color: string }>} colorStops An array of gradient color stops. Each stop has a `position` (0 to 1) and a `color` (e.g., '#ff0000').
|
|
190
|
+
* @param {number} [gradientAngle] The angle of the gradient in degrees (e.g., 0 for left-to-right, 90 for top-to-bottom).
|
|
191
|
+
* @returns {FShape} this builder, for chaining.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
196
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
197
|
+
* // Gradient fill with angle and color stops
|
|
198
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
199
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
200
|
+
* .setShapeGradientFill(
|
|
201
|
+
* univerAPI.Enum.ShapeGradientTypeEnum.Linear,
|
|
202
|
+
* [
|
|
203
|
+
* { position: 0, color: '#ff0000' },
|
|
204
|
+
* { position: 0.5, color: '#00ff00' },
|
|
205
|
+
* { position: 1, color: '#0000ff' },
|
|
206
|
+
* ],
|
|
207
|
+
* 90,
|
|
208
|
+
* )
|
|
209
|
+
* .setPosition(1, 1, 0, 0)
|
|
210
|
+
* .build();
|
|
211
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
setShapeGradientFill(shapeGradientType: ShapeGradientTypeEnum, colorStops: Array<{
|
|
215
|
+
position: number;
|
|
216
|
+
color: string;
|
|
217
|
+
}>, gradientAngle?: number): this;
|
|
218
|
+
/**
|
|
219
|
+
* Removes the fill from the shape, making it transparent.
|
|
220
|
+
* @returns {FShape} this builder, for chaining.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
225
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
226
|
+
*
|
|
227
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
228
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
229
|
+
* .setNoneFill()
|
|
230
|
+
* .setPosition(1, 1, 0, 0)
|
|
231
|
+
* .build();
|
|
232
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
setNoneFill(): this;
|
|
236
|
+
/**
|
|
237
|
+
* Sets the stroke color of the shape.
|
|
238
|
+
* @param {string} color The stroke color, e.g., '#ff0000'.
|
|
239
|
+
* @returns {FShape} this builder, for chaining.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
244
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
245
|
+
*
|
|
246
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
247
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
248
|
+
* .setStrokeColor('#ff0000')
|
|
249
|
+
* .setPosition(1, 1, 0, 0)
|
|
250
|
+
* .build();
|
|
251
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
setStrokeColor(color: string): this;
|
|
255
|
+
/**
|
|
256
|
+
* Sets the stroke width of the shape.
|
|
257
|
+
* @param {number} width The stroke width in pixels.
|
|
258
|
+
* @returns {FShape} this builder, for chaining.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
263
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
264
|
+
*
|
|
265
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
266
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
267
|
+
* .setStrokeWidth(3)
|
|
268
|
+
* .setPosition(1, 1, 0, 0)
|
|
269
|
+
* .build();
|
|
270
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
setStrokeWidth(width: number): this;
|
|
274
|
+
/**
|
|
275
|
+
* Sets the stroke line dash type of the shape.
|
|
276
|
+
* @param {ShapeLineDashEnum} lineDashType The line dash type.
|
|
277
|
+
* @returns {FShape} this builder, for chaining.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
282
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
283
|
+
*
|
|
284
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
285
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
286
|
+
* .setStrokeLineDashType(univerAPI.Enum.ShapeLineDashEnum.Dash)
|
|
287
|
+
* .setPosition(1, 1, 0, 0)
|
|
288
|
+
* .build();
|
|
289
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
setStrokeLineDashType(lineDashType: ShapeLineDashEnum): this;
|
|
293
|
+
/**
|
|
294
|
+
* Sets the stroke line join type of the shape.
|
|
295
|
+
* @param {ShapeLineJoinEnum} lineJoinType The line join type.
|
|
296
|
+
* @returns {FShape} this builder, for chaining.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
301
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
302
|
+
*
|
|
303
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
304
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
305
|
+
* .setStrokeLineJoinType(univerAPI.Enum.ShapeLineJoinEnum.Round)
|
|
306
|
+
* .setPosition(1, 1, 0, 0)
|
|
307
|
+
* .build();
|
|
308
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
setStrokeLineJoinType(lineJoinType: ShapeLineJoinEnum): this;
|
|
312
|
+
/**
|
|
313
|
+
* Sets the stroke line cap type of the shape.
|
|
314
|
+
* @param {ShapeLineCapEnum} lineCapType The line cap type.
|
|
315
|
+
* @returns {FShape} this builder, for chaining.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
320
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
321
|
+
*
|
|
322
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
323
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
324
|
+
* .setStrokeLineCapType(univerAPI.Enum.ShapeLineCapEnum.Round)
|
|
325
|
+
* .setPosition(1, 1, 0, 0)
|
|
326
|
+
* .build();
|
|
327
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
setStrokeLineCapType(lineCapType: ShapeLineCapEnum): this;
|
|
331
|
+
/**
|
|
332
|
+
* Sets the stroke opacity of the shape.
|
|
333
|
+
* @param {number} opacity The opacity of the stroke (0 to 1).
|
|
334
|
+
* @returns {FShape} this builder, for chaining.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
339
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
340
|
+
*
|
|
341
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
342
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
343
|
+
* .setStrokeColor('#ff0000')
|
|
344
|
+
* .setStrokeOpacity(0.5)
|
|
345
|
+
* .setPosition(1, 1, 0, 0)
|
|
346
|
+
* .build();
|
|
347
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
setStrokeOpacity(opacity: number): this;
|
|
351
|
+
/**
|
|
352
|
+
* Sets the stroke line type of the shape.
|
|
353
|
+
* @param {ShapeLineTypeEnum} lineType The line type. Which can be found from `univerAPI.Enum.ShapeLineTypeEnum`.
|
|
354
|
+
* @returns {FShape} this builder, for chaining.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts
|
|
358
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
359
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
360
|
+
*
|
|
361
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
362
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
363
|
+
* .setStrokeLineType(univerAPI.Enum.ShapeLineTypeEnum.SolidLine)
|
|
364
|
+
* .setStrokeColor('#000000')
|
|
365
|
+
* .setPosition(1, 1, 0, 0)
|
|
366
|
+
* .build();
|
|
367
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
setStrokeLineType(lineType: ShapeLineTypeEnum): this;
|
|
371
|
+
/**
|
|
372
|
+
* Sets the width of the shape in pixels.
|
|
373
|
+
* @param {number} width The width of the shape in pixels.
|
|
374
|
+
* @returns {FShape} this builder, for chaining.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
379
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
380
|
+
*
|
|
381
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
382
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
383
|
+
* .setWidth(300)
|
|
384
|
+
* .setHeight(200)
|
|
385
|
+
* .setPosition(1, 1, 0, 0)
|
|
386
|
+
* .build();
|
|
387
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
setWidth(width: number): this;
|
|
391
|
+
/**
|
|
392
|
+
* Sets the height of the shape in pixels.
|
|
393
|
+
* @param {number} height The height of the shape in pixels.
|
|
394
|
+
* @returns {FShape} this builder, for chaining.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
399
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
400
|
+
*
|
|
401
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
402
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
403
|
+
* .setWidth(300)
|
|
404
|
+
* .setHeight(200)
|
|
405
|
+
* .setPosition(1, 1, 0, 0)
|
|
406
|
+
* .build();
|
|
407
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
setHeight(height: number): this;
|
|
411
|
+
/**
|
|
412
|
+
* Returns whether this shape is a line/connector shape (e.g., straight connector, bent connector, curved connector).
|
|
413
|
+
* @returns {boolean} `true` if the shape is a line/connector shape, `false` otherwise.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
418
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
419
|
+
* const shapes = fWorksheet.getShapes();
|
|
420
|
+
*
|
|
421
|
+
* for (const shape of shapes) {
|
|
422
|
+
* console.log(`Shape ${shape.drawId} is line: ${shape.isLineShape()}`);
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
isLineShape(): boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Returns the connection sites (points where connectors can attach) for this shape.
|
|
429
|
+
* Connection sites are only available for non-connector (basic) shapes.
|
|
430
|
+
* The coordinates are in the shape's local coordinate space (relative to shape bounds).
|
|
431
|
+
* @returns {Array<{ x: number; y: number; index: number; ang: number }>} An array of connection site info.
|
|
432
|
+
* Each item contains `x`, `y` (local coordinates), `index` (site index), and `ang` (angle in 60000ths of a degree).
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```ts
|
|
436
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
437
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
438
|
+
* const shapes = fWorksheet.getShapes();
|
|
439
|
+
*
|
|
440
|
+
* const basicShape = shapes.find((s) => !s.isLineShape());
|
|
441
|
+
* if (basicShape) {
|
|
442
|
+
* const sites = basicShape.getConnectionSites();
|
|
443
|
+
* console.log('Connection sites:', sites);
|
|
444
|
+
* }
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
getConnectionSites(): Array<{
|
|
448
|
+
x: number;
|
|
449
|
+
y: number;
|
|
450
|
+
index: number;
|
|
451
|
+
ang: number;
|
|
452
|
+
}>;
|
|
453
|
+
/**
|
|
454
|
+
* Returns the adjust points (adjust handles) for this shape.
|
|
455
|
+
* Adjust points allow the user to change the geometry of the shape (e.g., corner radius, arrow size).
|
|
456
|
+
* The coordinates are in the shape's local coordinate space.
|
|
457
|
+
* @returns {Array<{ x: number; y: number; adjName: string }>} An array of adjust point info,
|
|
458
|
+
* each containing `x`, `y` (local coordinates) and `adjName` (the adjust parameter name).
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```ts
|
|
462
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
463
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
464
|
+
* const shapes = fWorksheet.getShapes();
|
|
465
|
+
*
|
|
466
|
+
* const shape = shapes[0];
|
|
467
|
+
* const adjustPoints = shape.getAdjustPoints();
|
|
468
|
+
* console.log('Adjust points:', adjustPoints);
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
getAdjustPoints(): Array<{
|
|
472
|
+
x: number;
|
|
473
|
+
y: number;
|
|
474
|
+
adjName: string;
|
|
475
|
+
}>;
|
|
476
|
+
/**
|
|
477
|
+
* Returns the connector line points for a line/connector shape.
|
|
478
|
+
* The coordinates are in the shape's local coordinate space.
|
|
479
|
+
* Returns an empty array if this shape is not a connector shape.
|
|
480
|
+
* @returns {IShapePoint[]} An array of line points `{ x, y }`.
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* ```ts
|
|
484
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
485
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
486
|
+
* const shapes = fWorksheet.getShapes();
|
|
487
|
+
*
|
|
488
|
+
* const lineShape = shapes.find((s) => s.isLineShape());
|
|
489
|
+
* if (lineShape) {
|
|
490
|
+
* const points = lineShape.getConnectorLinePoints();
|
|
491
|
+
* console.log('Connector points:', points);
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
getConnectorLinePoints(): IShapePoint[];
|
|
496
|
+
/**
|
|
497
|
+
* Returns the start connection info for a connector shape.
|
|
498
|
+
* If this connector's start point is connected to a basic shape, returns the target shape id and connection site index.
|
|
499
|
+
* @returns {IShapeRelationItem | null} The start connection info, or `null` if not connected.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* const lineShape = fWorksheet.getShapes().find((s) => s.isLineShape());
|
|
504
|
+
* if (lineShape) {
|
|
505
|
+
* const startInfo = lineShape.getStartConnectInfo();
|
|
506
|
+
* if (startInfo) {
|
|
507
|
+
* console.log(`Connected to shape ${startInfo.shapeId} at site ${startInfo.cxnIndex}`);
|
|
508
|
+
* }
|
|
509
|
+
* }
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
getStartConnectInfo(): IShapeRelationItem | null;
|
|
513
|
+
/**
|
|
514
|
+
* Returns the end connection info for a connector shape.
|
|
515
|
+
* If this connector's end point is connected to a basic shape, returns the target shape id and connection site index.
|
|
516
|
+
* @returns {IShapeRelationItem | null} The end connection info, or `null` if not connected.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```ts
|
|
520
|
+
* const lineShape = fWorksheet.getShapes().find((s) => s.isLineShape());
|
|
521
|
+
* if (lineShape) {
|
|
522
|
+
* const endInfo = lineShape.getEndConnectInfo();
|
|
523
|
+
* if (endInfo) {
|
|
524
|
+
* console.log(`Connected to shape ${endInfo.shapeId} at site ${endInfo.cxnIndex}`);
|
|
525
|
+
* }
|
|
526
|
+
* }
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
getEndConnectInfo(): IShapeRelationItem | null;
|
|
530
|
+
/**
|
|
531
|
+
* Builds the shape builder info. This method does not automatically draw the shape on top of the spreadsheet.
|
|
532
|
+
* A new shape must be inserted via `fWorksheet.insertShape(shapeInfo)`.
|
|
533
|
+
* @returns {IShapeBuilderInfo} The shape builder info containing all the accumulated properties.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
538
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
539
|
+
*
|
|
540
|
+
* const shapeInfo = fWorksheet.newShape()
|
|
541
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Rect)
|
|
542
|
+
* .setPosition(1, 1, 0, 0)
|
|
543
|
+
* .setWidth(300)
|
|
544
|
+
* .setHeight(200)
|
|
545
|
+
* .setStrokeColor('#000000')
|
|
546
|
+
* .setStrokeWidth(2)
|
|
547
|
+
* .build();
|
|
548
|
+
* await fWorksheet.insertShape(shapeInfo);
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
build(): IShapeBuilderInfo;
|
|
552
|
+
/**
|
|
553
|
+
* Returns the unique identifier of this shape.
|
|
554
|
+
* @returns {string} The shape id.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
559
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
560
|
+
* const shapes = fWorksheet.getShapes();
|
|
561
|
+
*
|
|
562
|
+
* if (shapes.length > 0) {
|
|
563
|
+
* console.log('Shape ID:', shapes[0].getShapeId());
|
|
564
|
+
* }
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
getShapeId(): string;
|
|
568
|
+
/**
|
|
569
|
+
* Returns the type of this shape.
|
|
570
|
+
* @returns {ShapeTypeEnum | undefined} The shape type, or `undefined` if not set.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```ts
|
|
574
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
575
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
576
|
+
* const shapes = fWorksheet.getShapes();
|
|
577
|
+
*
|
|
578
|
+
* if (shapes.length > 0) {
|
|
579
|
+
* console.log('Shape type:', shapes[0].getShapeType());
|
|
580
|
+
* }
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
getShapeType(): ShapeTypeEnum | undefined;
|
|
584
|
+
/**
|
|
585
|
+
* Returns the shape data containing fill and stroke styles.
|
|
586
|
+
* @returns {IShapeData} The shape data object.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
591
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
592
|
+
* const shapes = fWorksheet.getShapes();
|
|
593
|
+
*
|
|
594
|
+
* if (shapes.length > 0) {
|
|
595
|
+
* const data = shapes[0].getShapeData();
|
|
596
|
+
* console.log('Fill:', data.fill);
|
|
597
|
+
* console.log('Stroke:', data.stroke);
|
|
598
|
+
* }
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
getShapeData(): IShapeData;
|
|
602
|
+
/**
|
|
603
|
+
* Returns the absolute pixel position of this shape's top-left corner.
|
|
604
|
+
* @returns {{ x: number; y: number }} An object with `x` and `y` pixel coordinates.
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* ```ts
|
|
608
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
609
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
610
|
+
* const shapes = fWorksheet.getShapes();
|
|
611
|
+
*
|
|
612
|
+
* if (shapes.length > 0) {
|
|
613
|
+
* const pos = shapes[0].getPosition();
|
|
614
|
+
* console.log(`Position: (${pos.x}, ${pos.y})`);
|
|
615
|
+
* }
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
getPosition(): {
|
|
619
|
+
x: number;
|
|
620
|
+
y: number;
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* Returns the size of this shape in pixels.
|
|
624
|
+
* @returns {{ width: number; height: number }} An object with `width` and `height` in pixels.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```ts
|
|
628
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
629
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
630
|
+
* const shapes = fWorksheet.getShapes();
|
|
631
|
+
*
|
|
632
|
+
* if (shapes.length > 0) {
|
|
633
|
+
* const size = shapes[0].getSize();
|
|
634
|
+
* console.log(`Size: ${size.width} x ${size.height}`);
|
|
635
|
+
* }
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
getSize(): {
|
|
639
|
+
width: number;
|
|
640
|
+
height: number;
|
|
641
|
+
};
|
|
642
|
+
}
|