@univerjs/sheets-drawing 0.24.0 → 0.25.0-insiders.20260608-e4336f7
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/lib/cjs/facade.js +259 -32
- package/lib/cjs/index.js +7 -7
- package/lib/es/facade.js +261 -34
- package/lib/es/index.js +7 -7
- package/lib/facade.js +261 -34
- package/lib/index.js +7 -7
- package/lib/types/facade/f-over-grid-image.d.ts +62 -31
- package/lib/types/facade/f-worksheet.d.ts +183 -11
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
|
@@ -36,7 +36,8 @@ export declare class FOverGridImageBuilder {
|
|
|
36
36
|
* // create a new image builder and set initial image configuration.
|
|
37
37
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell.
|
|
38
38
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
39
|
-
* const fWorksheet = fWorkbook.
|
|
39
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
40
|
+
* if (!fWorksheet) return;
|
|
40
41
|
* const image = await fWorksheet.newOverGridImage()
|
|
41
42
|
* .setImage({
|
|
42
43
|
* drawingId: '123456',
|
|
@@ -63,7 +64,8 @@ export declare class FOverGridImageBuilder {
|
|
|
63
64
|
* // create a new image builder and set image source.
|
|
64
65
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell.
|
|
65
66
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
66
|
-
* const fWorksheet = fWorkbook.
|
|
67
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
68
|
+
* if (!fWorksheet) return;
|
|
67
69
|
* const image = await fWorksheet.newOverGridImage()
|
|
68
70
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
69
71
|
* .setColumn(5)
|
|
@@ -80,7 +82,8 @@ export declare class FOverGridImageBuilder {
|
|
|
80
82
|
* @example
|
|
81
83
|
* ```ts
|
|
82
84
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
83
|
-
* const fWorksheet = fWorkbook.
|
|
85
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
86
|
+
* if (!fWorksheet) return;
|
|
84
87
|
* const images = fWorksheet.getImages();
|
|
85
88
|
* images.forEach((image) => {
|
|
86
89
|
* console.log(image, image.toBuilder().getSource());
|
|
@@ -94,7 +97,8 @@ export declare class FOverGridImageBuilder {
|
|
|
94
97
|
* @example
|
|
95
98
|
* ```ts
|
|
96
99
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
97
|
-
* const fWorksheet = fWorkbook.
|
|
100
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
101
|
+
* if (!fWorksheet) return;
|
|
98
102
|
* const images = fWorksheet.getImages();
|
|
99
103
|
* images.forEach((image) => {
|
|
100
104
|
* console.log(image, image.toBuilder().getSourceType());
|
|
@@ -111,7 +115,8 @@ export declare class FOverGridImageBuilder {
|
|
|
111
115
|
* // create a new image builder and set image source.
|
|
112
116
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell.
|
|
113
117
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
114
|
-
* const fWorksheet = fWorkbook.
|
|
118
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
119
|
+
* if (!fWorksheet) return;
|
|
115
120
|
* const image = await fWorksheet.newOverGridImage()
|
|
116
121
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
117
122
|
* .setColumn(5)
|
|
@@ -130,7 +135,8 @@ export declare class FOverGridImageBuilder {
|
|
|
130
135
|
* // create a new image builder and set image source.
|
|
131
136
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell.
|
|
132
137
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
133
|
-
* const fWorksheet = fWorkbook.
|
|
138
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
139
|
+
* if (!fWorksheet) return;
|
|
134
140
|
* const image = await fWorksheet.newOverGridImage()
|
|
135
141
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
136
142
|
* .setColumn(5)
|
|
@@ -149,7 +155,8 @@ export declare class FOverGridImageBuilder {
|
|
|
149
155
|
* // create a new image builder and set image source.
|
|
150
156
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell and horizontal offset is 10px.
|
|
151
157
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
152
|
-
* const fWorksheet = fWorkbook.
|
|
158
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
159
|
+
* if (!fWorksheet) return;
|
|
153
160
|
* const image = await fWorksheet.newOverGridImage()
|
|
154
161
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
155
162
|
* .setColumn(5)
|
|
@@ -169,7 +176,8 @@ export declare class FOverGridImageBuilder {
|
|
|
169
176
|
* // create a new image builder and set image source.
|
|
170
177
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell and vertical offset is 10px.
|
|
171
178
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
172
|
-
* const fWorksheet = fWorkbook.
|
|
179
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
180
|
+
* if (!fWorksheet) return;
|
|
173
181
|
* const image = await fWorksheet.newOverGridImage()
|
|
174
182
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
175
183
|
* .setColumn(5)
|
|
@@ -189,7 +197,8 @@ export declare class FOverGridImageBuilder {
|
|
|
189
197
|
* // create a new image builder and set image source.
|
|
190
198
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, width is 120px and height is 50px.
|
|
191
199
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
192
|
-
* const fWorksheet = fWorkbook.
|
|
200
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
201
|
+
* if (!fWorksheet) return;
|
|
193
202
|
* const image = await fWorksheet.newOverGridImage()
|
|
194
203
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
195
204
|
* .setColumn(5)
|
|
@@ -210,7 +219,8 @@ export declare class FOverGridImageBuilder {
|
|
|
210
219
|
* // create a new image builder and set image source.
|
|
211
220
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, width is 120px and height is 50px.
|
|
212
221
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
213
|
-
* const fWorksheet = fWorkbook.
|
|
222
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
223
|
+
* if (!fWorksheet) return;
|
|
214
224
|
* const image = await fWorksheet.newOverGridImage()
|
|
215
225
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
216
226
|
* .setColumn(5)
|
|
@@ -229,7 +239,8 @@ export declare class FOverGridImageBuilder {
|
|
|
229
239
|
* @example
|
|
230
240
|
* ```ts
|
|
231
241
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
232
|
-
* const fWorksheet = fWorkbook.
|
|
242
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
243
|
+
* if (!fWorksheet) return;
|
|
233
244
|
*
|
|
234
245
|
* // image1 position is start from A6 cell, anchor type is Position.
|
|
235
246
|
* // Only the position of the drawing follows the cell changes. When rows or columns are inserted or deleted, the position of the drawing changes, but the size remains the same.
|
|
@@ -278,7 +289,8 @@ export declare class FOverGridImageBuilder {
|
|
|
278
289
|
* // create a new image builder and set image source.
|
|
279
290
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, top crop is 10px.
|
|
280
291
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
281
|
-
* const fWorksheet = fWorkbook.
|
|
292
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
293
|
+
* if (!fWorksheet) return;
|
|
282
294
|
* const image = await fWorksheet.newOverGridImage()
|
|
283
295
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
284
296
|
* .setColumn(5)
|
|
@@ -298,7 +310,8 @@ export declare class FOverGridImageBuilder {
|
|
|
298
310
|
* // create a new image builder and set image source.
|
|
299
311
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, left crop is 10px.
|
|
300
312
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
301
|
-
* const fWorksheet = fWorkbook.
|
|
313
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
314
|
+
* if (!fWorksheet) return;
|
|
302
315
|
* const image = await fWorksheet.newOverGridImage()
|
|
303
316
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
304
317
|
* .setColumn(5)
|
|
@@ -318,7 +331,8 @@ export declare class FOverGridImageBuilder {
|
|
|
318
331
|
* // create a new image builder and set image source.
|
|
319
332
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, bottom crop is 10px.
|
|
320
333
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
321
|
-
* const fWorksheet = fWorkbook.
|
|
334
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
335
|
+
* if (!fWorksheet) return;
|
|
322
336
|
* const image = await fWorksheet.newOverGridImage()
|
|
323
337
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
324
338
|
* .setColumn(5)
|
|
@@ -338,7 +352,8 @@ export declare class FOverGridImageBuilder {
|
|
|
338
352
|
* // create a new image builder and set image source.
|
|
339
353
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, right crop is 10px.
|
|
340
354
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
341
|
-
* const fWorksheet = fWorkbook.
|
|
355
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
356
|
+
* if (!fWorksheet) return;
|
|
342
357
|
* const image = await fWorksheet.newOverGridImage()
|
|
343
358
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
344
359
|
* .setColumn(5)
|
|
@@ -359,7 +374,8 @@ export declare class FOverGridImageBuilder {
|
|
|
359
374
|
* // create a new image builder and set image source.
|
|
360
375
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, rotate 90 degrees.
|
|
361
376
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
362
|
-
* const fWorksheet = fWorkbook.
|
|
377
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
378
|
+
* if (!fWorksheet) return;
|
|
363
379
|
* const image = await fWorksheet.newOverGridImage()
|
|
364
380
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
365
381
|
* .setColumn(5)
|
|
@@ -388,7 +404,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
388
404
|
* @example
|
|
389
405
|
* ```ts
|
|
390
406
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
391
|
-
* const fWorksheet = fWorkbook.
|
|
407
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
408
|
+
* if (!fWorksheet) return;
|
|
392
409
|
* const images = fWorksheet.getImages();
|
|
393
410
|
* images.forEach((image) => {
|
|
394
411
|
* console.log(image, image.getId());
|
|
@@ -402,7 +419,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
402
419
|
* @example
|
|
403
420
|
* ```ts
|
|
404
421
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
405
|
-
* const fWorksheet = fWorkbook.
|
|
422
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
423
|
+
* if (!fWorksheet) return;
|
|
406
424
|
* const images = fWorksheet.getImages();
|
|
407
425
|
* images.forEach((image) => {
|
|
408
426
|
* console.log(image, image.getType());
|
|
@@ -416,7 +434,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
416
434
|
* @example
|
|
417
435
|
* ```ts
|
|
418
436
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
419
|
-
* const fWorksheet = fWorkbook.
|
|
437
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
438
|
+
* if (!fWorksheet) return;
|
|
420
439
|
* const image = fWorksheet.getImages()[0];
|
|
421
440
|
* const result = image?.remove();
|
|
422
441
|
* console.log(result);
|
|
@@ -429,7 +448,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
429
448
|
* @example
|
|
430
449
|
* ```ts
|
|
431
450
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
432
|
-
* const fWorksheet = fWorkbook.
|
|
451
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
452
|
+
* if (!fWorksheet) return;
|
|
433
453
|
* const images = fWorksheet.getImages();
|
|
434
454
|
* images.forEach((image) => {
|
|
435
455
|
* console.log(image, image.toBuilder().getSource());
|
|
@@ -444,7 +464,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
444
464
|
* @example
|
|
445
465
|
* ```ts
|
|
446
466
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
447
|
-
* const fWorksheet = fWorkbook.
|
|
467
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
468
|
+
* if (!fWorksheet) return;
|
|
448
469
|
* const image = fWorksheet.getImages()[0];
|
|
449
470
|
* const result = image?.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4');
|
|
450
471
|
* console.log(result);
|
|
@@ -459,7 +480,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
459
480
|
* @example
|
|
460
481
|
* ```ts
|
|
461
482
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
462
|
-
* const fWorksheet = fWorkbook.
|
|
483
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
484
|
+
* if (!fWorksheet) return;
|
|
463
485
|
* const image = fWorksheet.getImages()[0];
|
|
464
486
|
* const result = image?.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL);
|
|
465
487
|
* console.log(result);
|
|
@@ -475,7 +497,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
475
497
|
* ```ts
|
|
476
498
|
* // set the position of the image, the start position is F6 cell.
|
|
477
499
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
478
|
-
* const fWorksheet = fWorkbook.
|
|
500
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
501
|
+
* if (!fWorksheet) return;
|
|
479
502
|
* const image = fWorksheet.getImages()[0];
|
|
480
503
|
* const result = image?.setPositionAsync(5, 5);
|
|
481
504
|
* console.log(result);
|
|
@@ -492,7 +515,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
492
515
|
* ```ts
|
|
493
516
|
* // set the position of the image, the start position is F6 cell, and the offset is 10px.
|
|
494
517
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
495
|
-
* const fWorksheet = fWorkbook.
|
|
518
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
519
|
+
* if (!fWorksheet) return;
|
|
496
520
|
* const image = fWorksheet.getImages()[0];
|
|
497
521
|
* const result = image?.setPositionAsync(5, 5, 10, 10);
|
|
498
522
|
* console.log(result);
|
|
@@ -508,7 +532,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
508
532
|
* ```ts
|
|
509
533
|
* // set the image width 120px and height 50px
|
|
510
534
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
511
|
-
* const fWorksheet = fWorkbook.
|
|
535
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
536
|
+
* if (!fWorksheet) return;
|
|
512
537
|
* const image = fWorksheet.getImages()[0];
|
|
513
538
|
* const result = image?.setSizeAsync(120, 50);
|
|
514
539
|
* console.log(result);
|
|
@@ -526,7 +551,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
526
551
|
* ```ts
|
|
527
552
|
* // set the crop of the image, top 10px, left 10px, bottom 10px, right 10px.
|
|
528
553
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
529
|
-
* const fWorksheet = fWorkbook.
|
|
554
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
555
|
+
* if (!fWorksheet) return;
|
|
530
556
|
* const image = fWorksheet.getImages()[0];
|
|
531
557
|
* const result = image?.setCrop(10, 10, 10, 10);
|
|
532
558
|
* console.log(result);
|
|
@@ -541,7 +567,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
541
567
|
* ```ts
|
|
542
568
|
* // set 90 degrees rotation of the image
|
|
543
569
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
544
|
-
* const fWorksheet = fWorkbook.
|
|
570
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
571
|
+
* if (!fWorksheet) return;
|
|
545
572
|
* const image = fWorksheet.getImages()[0];
|
|
546
573
|
* const result = image?.setRotate(90);
|
|
547
574
|
* console.log(result);
|
|
@@ -554,7 +581,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
554
581
|
* @example
|
|
555
582
|
* ```ts
|
|
556
583
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
557
|
-
* const fWorksheet = fWorkbook.
|
|
584
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
585
|
+
* if (!fWorksheet) return;
|
|
558
586
|
* const image = fWorksheet.getImages()[0];
|
|
559
587
|
* const result = image?.setForward();
|
|
560
588
|
* console.log(result);
|
|
@@ -567,7 +595,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
567
595
|
* @example
|
|
568
596
|
* ```ts
|
|
569
597
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
570
|
-
* const fWorksheet = fWorkbook.
|
|
598
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
599
|
+
* if (!fWorksheet) return;
|
|
571
600
|
* const image = fWorksheet.getImages()[0];
|
|
572
601
|
* const result = image?.setBackward();
|
|
573
602
|
* console.log(result);
|
|
@@ -580,7 +609,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
580
609
|
* @example
|
|
581
610
|
* ```ts
|
|
582
611
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
583
|
-
* const fWorksheet = fWorkbook.
|
|
612
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
613
|
+
* if (!fWorksheet) return;
|
|
584
614
|
* const image = fWorksheet.getImages()[0];
|
|
585
615
|
* const result = image?.setBack();
|
|
586
616
|
* console.log(result);
|
|
@@ -593,7 +623,8 @@ export declare class FOverGridImage extends FBase {
|
|
|
593
623
|
* @example
|
|
594
624
|
* ```ts
|
|
595
625
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
596
|
-
* const fWorksheet = fWorkbook.
|
|
626
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
627
|
+
* if (!fWorksheet) return;
|
|
597
628
|
* const image = fWorksheet.getImages()[0];
|
|
598
629
|
* const result = image?.setFront();
|
|
599
630
|
* console.log(result);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IFBlobSource } from '@univerjs/core/facade';
|
|
17
|
-
import type { ISheetImage } from '@univerjs/sheets-drawing';
|
|
17
|
+
import type { ISheetDrawing, ISheetImage } from '@univerjs/sheets-drawing';
|
|
18
18
|
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
19
19
|
import { FOverGridImage, FOverGridImageBuilder } from './f-over-grid-image';
|
|
20
20
|
/**
|
|
@@ -28,7 +28,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
30
30
|
* // Insert an image to the sheet, default position is A1
|
|
31
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
31
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
32
|
+
* if (!fWorksheet) return;
|
|
32
33
|
* const result = await fWorksheet.insertImage('https://avatars.githubusercontent.com/u/61444807?s=48&v=4');
|
|
33
34
|
* console.log(result);
|
|
34
35
|
* ```
|
|
@@ -42,7 +43,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
42
43
|
* @example
|
|
43
44
|
* ```ts
|
|
44
45
|
* // Insert an image to the sheet, position is F6
|
|
45
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
46
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
47
|
+
* if (!fWorksheet) return;
|
|
46
48
|
* const result = await fWorksheet.insertImage('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', 5, 5);
|
|
47
49
|
* console.log(result);
|
|
48
50
|
* ```
|
|
@@ -58,7 +60,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
58
60
|
* @example
|
|
59
61
|
* ```ts
|
|
60
62
|
* // Insert an image to the sheet, position is F6, offset is 10px
|
|
61
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
63
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
64
|
+
* if (!fWorksheet) return;
|
|
62
65
|
* const result = await fWorksheet.insertImage('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', 5, 5, 10, 10);
|
|
63
66
|
* console.log(result);
|
|
64
67
|
* ```
|
|
@@ -77,7 +80,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
77
80
|
* // create a new image builder and set image source.
|
|
78
81
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, width is 500px, height is 300px
|
|
79
82
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
80
|
-
* const fWorksheet = fWorkbook.
|
|
83
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
84
|
+
* if (!fWorksheet) return;
|
|
81
85
|
* const image = await fWorksheet.newOverGridImage()
|
|
82
86
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
83
87
|
* .setColumn(5)
|
|
@@ -101,7 +105,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
101
105
|
* @returns {FOverGridImage[]} The FOverGridImage instances
|
|
102
106
|
* @example
|
|
103
107
|
* ```ts
|
|
104
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
108
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
109
|
+
* if (!fWorksheet) return;
|
|
105
110
|
* const images = fWorksheet.getImages();
|
|
106
111
|
* images.forEach((image) => {
|
|
107
112
|
* console.log(image, image.getId());
|
|
@@ -115,7 +120,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
115
120
|
* @returns {FOverGridImage | null} The FOverGridImage instance
|
|
116
121
|
* @example
|
|
117
122
|
* ```ts
|
|
118
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
123
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
124
|
+
* if (!fWorksheet) return;
|
|
119
125
|
* const image = fWorksheet.getImageById('xxxx');
|
|
120
126
|
* console.log(image);
|
|
121
127
|
* ```
|
|
@@ -127,7 +133,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
127
133
|
* @returns {FWorksheet} The FWorksheet instance for chaining
|
|
128
134
|
* @example
|
|
129
135
|
* ```ts
|
|
130
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
136
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
137
|
+
* if (!fWorksheet) return;
|
|
131
138
|
* const image = fWorksheet.getImages()[0];
|
|
132
139
|
*
|
|
133
140
|
* // Delete the first image of the sheet
|
|
@@ -144,7 +151,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
144
151
|
* // create a new image builder and set image source.
|
|
145
152
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, width is 500px, height is 300px
|
|
146
153
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
147
|
-
* const fWorksheet = fWorkbook.
|
|
154
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
155
|
+
* if (!fWorksheet) return;
|
|
148
156
|
* const image = await fWorksheet.newOverGridImage()
|
|
149
157
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
150
158
|
* .setColumn(5)
|
|
@@ -168,7 +176,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
168
176
|
* @returns {FOverGridImage[]} The FOverGridImage instances
|
|
169
177
|
* @example
|
|
170
178
|
* ```ts
|
|
171
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().
|
|
179
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
180
|
+
* if (!fWorksheet) return;
|
|
172
181
|
* const images = fWorksheet.getActiveImages();
|
|
173
182
|
* images.forEach((image) => {
|
|
174
183
|
* console.log(image, image.getId());
|
|
@@ -184,7 +193,8 @@ export interface IFWorksheetDrawingMixin {
|
|
|
184
193
|
* // create a new image builder and set image source.
|
|
185
194
|
* // then build `ISheetImage` and insert it into the sheet, position is start from F6 cell, width is 500px, height is 300px
|
|
186
195
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
187
|
-
* const fWorksheet = fWorkbook.
|
|
196
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
197
|
+
* if (!fWorksheet) return;
|
|
188
198
|
* const image = await fWorksheet.newOverGridImage()
|
|
189
199
|
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
190
200
|
* .setColumn(5)
|
|
@@ -196,6 +206,161 @@ export interface IFWorksheetDrawingMixin {
|
|
|
196
206
|
* ```
|
|
197
207
|
*/
|
|
198
208
|
newOverGridImage(): FOverGridImageBuilder;
|
|
209
|
+
/**
|
|
210
|
+
* Group drawings on the current sheet.
|
|
211
|
+
* @param {string[]} drawingIds - The drawing ids to group. At least two drawings are required.
|
|
212
|
+
* @param {string} [groupId] - Optional group drawing id. If omitted, a new id will be generated.
|
|
213
|
+
* @returns {string | null} The group id if the operation succeeds, otherwise null.
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* // Group two over-grid images on the active sheet.
|
|
217
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
218
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
219
|
+
* const image1 = await fWorksheet.newOverGridImage()
|
|
220
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
221
|
+
* .setColumn(1)
|
|
222
|
+
* .setRow(1)
|
|
223
|
+
* .setWidth(100)
|
|
224
|
+
* .setHeight(100)
|
|
225
|
+
* .buildAsync();
|
|
226
|
+
* const image2 = await fWorksheet.newOverGridImage()
|
|
227
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
228
|
+
* .setColumn(3)
|
|
229
|
+
* .setRow(1)
|
|
230
|
+
* .setWidth(100)
|
|
231
|
+
* .setHeight(100)
|
|
232
|
+
* .buildAsync();
|
|
233
|
+
* fWorksheet.insertImages([image1, image2]);
|
|
234
|
+
* const groupId = fWorksheet.groupDrawings([image1.drawingId, image2.drawingId]);
|
|
235
|
+
* console.log(groupId);
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
groupDrawings(drawingIds: string[], groupId?: string): string | null;
|
|
239
|
+
/**
|
|
240
|
+
* Ungroup drawing groups on the current sheet.
|
|
241
|
+
* @param {string[]} groupIds - The group drawing ids to ungroup.
|
|
242
|
+
* @returns {boolean} true if the operation succeeds, otherwise false.
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* // Group two images, then ungroup the generated group.
|
|
246
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
247
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
248
|
+
* const image1 = await fWorksheet.newOverGridImage()
|
|
249
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
250
|
+
* .setColumn(1)
|
|
251
|
+
* .setRow(1)
|
|
252
|
+
* .setWidth(100)
|
|
253
|
+
* .setHeight(100)
|
|
254
|
+
* .buildAsync();
|
|
255
|
+
* const image2 = await fWorksheet.newOverGridImage()
|
|
256
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
257
|
+
* .setColumn(3)
|
|
258
|
+
* .setRow(1)
|
|
259
|
+
* .setWidth(100)
|
|
260
|
+
* .setHeight(100)
|
|
261
|
+
* .buildAsync();
|
|
262
|
+
* fWorksheet.insertImages([image1, image2]);
|
|
263
|
+
* const groupId = fWorksheet.groupDrawings([image1.drawingId, image2.drawingId]);
|
|
264
|
+
* if (groupId) {
|
|
265
|
+
* const result = fWorksheet.ungroupDrawings([groupId]);
|
|
266
|
+
* console.log(result);
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
ungroupDrawings(groupIds: string[]): boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Get children of a drawing group on the current sheet.
|
|
273
|
+
* @param {string} groupId - The group drawing id.
|
|
274
|
+
* @param {boolean} [recursive] - Whether to return all descendants.
|
|
275
|
+
* @returns {ISheetDrawing[]} The child drawings.
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* // Get the direct children of a drawing group.
|
|
279
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
280
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
281
|
+
* const image1 = await fWorksheet.newOverGridImage()
|
|
282
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
283
|
+
* .setColumn(1)
|
|
284
|
+
* .setRow(1)
|
|
285
|
+
* .setWidth(100)
|
|
286
|
+
* .setHeight(100)
|
|
287
|
+
* .buildAsync();
|
|
288
|
+
* const image2 = await fWorksheet.newOverGridImage()
|
|
289
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
290
|
+
* .setColumn(3)
|
|
291
|
+
* .setRow(1)
|
|
292
|
+
* .setWidth(100)
|
|
293
|
+
* .setHeight(100)
|
|
294
|
+
* .buildAsync();
|
|
295
|
+
* fWorksheet.insertImages([image1, image2]);
|
|
296
|
+
* const groupId = fWorksheet.groupDrawings([image1.drawingId, image2.drawingId]);
|
|
297
|
+
* if (groupId) {
|
|
298
|
+
* const children = fWorksheet.getDrawingGroupChildren(groupId);
|
|
299
|
+
* console.log(children.map((drawing) => drawing.drawingId));
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
getDrawingGroupChildren(groupId: string, recursive?: boolean): ISheetDrawing[];
|
|
304
|
+
/**
|
|
305
|
+
* Get the parent group of a drawing on the current sheet.
|
|
306
|
+
* @param {string} drawingId - The child drawing id.
|
|
307
|
+
* @returns {ISheetDrawing | null} The parent group drawing, or null if the drawing is not grouped.
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Get the parent group of a drawing.
|
|
311
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
312
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
313
|
+
* const image1 = await fWorksheet.newOverGridImage()
|
|
314
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
315
|
+
* .setColumn(1)
|
|
316
|
+
* .setRow(1)
|
|
317
|
+
* .setWidth(100)
|
|
318
|
+
* .setHeight(100)
|
|
319
|
+
* .buildAsync();
|
|
320
|
+
* const image2 = await fWorksheet.newOverGridImage()
|
|
321
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
322
|
+
* .setColumn(3)
|
|
323
|
+
* .setRow(1)
|
|
324
|
+
* .setWidth(100)
|
|
325
|
+
* .setHeight(100)
|
|
326
|
+
* .buildAsync();
|
|
327
|
+
* fWorksheet.insertImages([image1, image2]);
|
|
328
|
+
* fWorksheet.groupDrawings([image1.drawingId, image2.drawingId]);
|
|
329
|
+
* const parentGroup = fWorksheet.getDrawingParentGroup(image1.drawingId);
|
|
330
|
+
* console.log(parentGroup?.drawingId);
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
getDrawingParentGroup(drawingId: string): ISheetDrawing | null;
|
|
334
|
+
/**
|
|
335
|
+
* Returns whether a drawing is inside a group on the current sheet.
|
|
336
|
+
* @param {string} drawingId - The drawing id.
|
|
337
|
+
* @returns {boolean} true if the drawing has a parent group.
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* // Check whether a drawing is inside a group.
|
|
341
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
342
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
343
|
+
* const image1 = await fWorksheet.newOverGridImage()
|
|
344
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
345
|
+
* .setColumn(1)
|
|
346
|
+
* .setRow(1)
|
|
347
|
+
* .setWidth(100)
|
|
348
|
+
* .setHeight(100)
|
|
349
|
+
* .buildAsync();
|
|
350
|
+
* const image2 = await fWorksheet.newOverGridImage()
|
|
351
|
+
* .setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4', univerAPI.Enum.ImageSourceType.URL)
|
|
352
|
+
* .setColumn(3)
|
|
353
|
+
* .setRow(1)
|
|
354
|
+
* .setWidth(100)
|
|
355
|
+
* .setHeight(100)
|
|
356
|
+
* .buildAsync();
|
|
357
|
+
* fWorksheet.insertImages([image1, image2]);
|
|
358
|
+
* fWorksheet.groupDrawings([image1.drawingId, image2.drawingId]);
|
|
359
|
+
* const isGrouped = fWorksheet.isDrawingGrouped(image1.drawingId);
|
|
360
|
+
* console.log(isGrouped);
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
isDrawingGrouped(drawingId: string): boolean;
|
|
199
364
|
}
|
|
200
365
|
export declare class FWorksheetDrawingMixin extends FWorksheet implements IFWorksheetDrawingMixin {
|
|
201
366
|
insertImage(url: IFBlobSource | string, column?: number, row?: number, offsetX?: number, offsetY?: number): Promise<boolean>;
|
|
@@ -206,6 +371,13 @@ export declare class FWorksheetDrawingMixin extends FWorksheet implements IFWork
|
|
|
206
371
|
getActiveImages(): FOverGridImage[];
|
|
207
372
|
updateImages(sheetImages: ISheetImage[]): FWorksheet;
|
|
208
373
|
newOverGridImage(): FOverGridImageBuilder;
|
|
374
|
+
groupDrawings(drawingIds: string[], groupId?: string): string | null;
|
|
375
|
+
ungroupDrawings(groupIds: string[]): boolean;
|
|
376
|
+
getDrawingGroupChildren(groupId: string, recursive?: boolean): ISheetDrawing[];
|
|
377
|
+
getDrawingParentGroup(drawingId: string): ISheetDrawing | null;
|
|
378
|
+
isDrawingGrouped(drawingId: string): boolean;
|
|
379
|
+
private _applyGroupDrawingOperation;
|
|
380
|
+
private _invertGroupOperationObjects;
|
|
209
381
|
}
|
|
210
382
|
declare module '@univerjs/sheets/facade' {
|
|
211
383
|
interface FWorksheet extends IFWorksheetDrawingMixin {
|