@univerjs-pro/sheets-shape 1.0.0-alpha.3 → 1.0.0-alpha.5

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