@univerjs/sheets-drawing-ui 0.12.3 → 0.12.4
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 +1 -1
- package/lib/cjs/index.js +2 -2
- 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/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 +439 -395
- package/lib/es/index.js +1786 -1234
- package/lib/es/locale/ca-ES.js +15 -2
- package/lib/es/locale/en-US.js +13 -0
- package/lib/es/locale/es-ES.js +13 -0
- package/lib/es/locale/fa-IR.js +13 -0
- package/lib/es/locale/fr-FR.js +13 -0
- package/lib/es/locale/ja-JP.js +13 -0
- package/lib/es/locale/ko-KR.js +13 -0
- package/lib/es/locale/ru-RU.js +13 -0
- package/lib/es/locale/vi-VN.js +13 -0
- package/lib/es/locale/zh-CN.js +13 -0
- package/lib/es/locale/zh-TW.js +17 -4
- package/lib/facade.js +439 -395
- package/lib/index.css +1 -1
- package/lib/index.js +1786 -1234
- package/lib/locale/ca-ES.js +15 -2
- package/lib/locale/en-US.js +13 -0
- package/lib/locale/es-ES.js +13 -0
- package/lib/locale/fa-IR.js +13 -0
- package/lib/locale/fr-FR.js +13 -0
- package/lib/locale/ja-JP.js +13 -0
- package/lib/locale/ko-KR.js +13 -0
- package/lib/locale/ru-RU.js +13 -0
- package/lib/locale/vi-VN.js +13 -0
- package/lib/locale/zh-CN.js +13 -0
- package/lib/locale/zh-TW.js +17 -4
- package/lib/types/commands/commands/save-cell-images.command.d.ts +2 -0
- package/lib/types/facade/f-range.d.ts +40 -0
- package/lib/types/facade/f-worksheet.d.ts +29 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/locale/en-US.d.ts +13 -0
- package/lib/types/services/batch-save-images.service.d.ts +148 -0
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -0
- package/lib/types/views/batch-save-images/BatchSaveImagesDialog.d.ts +16 -0
- package/lib/types/views/batch-save-images/component-name.d.ts +16 -0
- package/lib/types/views/batch-save-images/index.d.ts +17 -0
- package/lib/types/views/menu/save-images.menu.d.ts +4 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- 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/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 +16 -15
package/lib/es/facade.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { FBase as
|
|
6
|
-
import { getImageSize as
|
|
7
|
-
import { IRenderManagerService as
|
|
8
|
-
import { RemoveSheetDrawingCommand as k, SetSheetDrawingCommand as f, SetDrawingArrangeCommand as
|
|
9
|
-
import { SheetSkeletonManagerService as
|
|
10
|
-
import { ISheetDrawingService as w, SheetDrawingAnchorType as
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var Z = (s, t, r) => t in s ? Q(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
|
|
3
|
+
var W = (s, t, r) => Z(s, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Inject as N, Injector as L, ICommandService as K, ImageSourceType as y, ArrangeTypeEnum as O, DrawingTypeEnum as v, generateRandomId as ee, toDisposable as T, CanceledError as D, UniverInstanceType as te, IUniverInstanceService as re } from "@univerjs/core";
|
|
5
|
+
import { FBase as ne, FEnum as z, FEventName as X, FUniver as Y } from "@univerjs/core/facade";
|
|
6
|
+
import { getImageSize as ie, IDrawingManagerService as S, SetDrawingSelectedOperation as j } from "@univerjs/drawing";
|
|
7
|
+
import { IRenderManagerService as C, getCurrentTypeOfRenderer as se } from "@univerjs/engine-render";
|
|
8
|
+
import { RemoveSheetDrawingCommand as k, SetSheetDrawingCommand as f, SetDrawingArrangeCommand as F, SheetCanvasFloatDomManagerService as p, transformToDrawingPosition as M, InsertSheetDrawingCommand as E, IBatchSaveImagesService as V, FileNamePart as b, SheetDrawingUpdateController as oe } from "@univerjs/sheets-drawing-ui";
|
|
9
|
+
import { SheetSkeletonManagerService as H, ISheetSelectionRenderService as x, convertPositionSheetOverGridToAbsolute as ae, convertPositionCellToSheetOverGrid as de } from "@univerjs/sheets-ui";
|
|
10
|
+
import { ISheetDrawingService as w, SheetDrawingAnchorType as ce } from "@univerjs/sheets-drawing";
|
|
11
11
|
import { transformComponentKey as U } from "@univerjs/sheets-ui/facade";
|
|
12
|
-
import { FWorksheet as $, FRange as
|
|
12
|
+
import { FWorksheet as $, FRange as q } from "@univerjs/sheets/facade";
|
|
13
13
|
import { ComponentManager as G } from "@univerjs/ui";
|
|
14
|
-
var
|
|
15
|
-
for (var
|
|
16
|
-
(
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
function
|
|
20
|
-
const { from:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{ from:
|
|
24
|
-
|
|
25
|
-
), { width:
|
|
14
|
+
var ge = Object.getOwnPropertyDescriptor, J = (s, t, r, e) => {
|
|
15
|
+
for (var n = e > 1 ? void 0 : e ? ge(t, r) : t, i = s.length - 1, a; i >= 0; i--)
|
|
16
|
+
(a = s[i]) && (n = a(n) || n);
|
|
17
|
+
return n;
|
|
18
|
+
}, P = (s, t) => (r, e) => t(r, e, s);
|
|
19
|
+
function me(s, t) {
|
|
20
|
+
const { from: r, to: e, flipY: n = !1, flipX: i = !1, angle: a = 0, skewX: o = 0, skewY: d = 0 } = s.sheetTransform, { column: g, columnOffset: c, row: m, rowOffset: h } = r, _ = ae(
|
|
21
|
+
s.unitId,
|
|
22
|
+
s.subUnitId,
|
|
23
|
+
{ from: r, to: e },
|
|
24
|
+
t
|
|
25
|
+
), { width: l, height: u } = _;
|
|
26
26
|
return {
|
|
27
|
-
...
|
|
27
|
+
...s,
|
|
28
28
|
column: g,
|
|
29
29
|
columnOffset: c,
|
|
30
30
|
row: m,
|
|
31
|
-
rowOffset:
|
|
32
|
-
width:
|
|
31
|
+
rowOffset: h,
|
|
32
|
+
width: l,
|
|
33
33
|
height: u,
|
|
34
|
-
flipY:
|
|
35
|
-
flipX:
|
|
36
|
-
angle:
|
|
37
|
-
skewX:
|
|
34
|
+
flipY: n,
|
|
35
|
+
flipX: i,
|
|
36
|
+
angle: a,
|
|
37
|
+
skewX: o,
|
|
38
38
|
skewY: d
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const { column: e, columnOffset:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{ column: e, columnOffset:
|
|
46
|
-
|
|
41
|
+
function he(s, t, r) {
|
|
42
|
+
const { column: e, columnOffset: n, row: i, rowOffset: a, flipY: o = !1, flipX: d = !1, angle: g = 0, skewX: c = 0, skewY: m = 0, width: h, height: _ } = s, l = de(
|
|
43
|
+
s.unitId,
|
|
44
|
+
s.subUnitId,
|
|
45
|
+
{ column: e, columnOffset: n, row: i, rowOffset: a },
|
|
46
|
+
h,
|
|
47
47
|
_,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
), { sheetTransform: u, transform:
|
|
48
|
+
t,
|
|
49
|
+
r
|
|
50
|
+
), { sheetTransform: u, transform: A } = l;
|
|
51
51
|
return {
|
|
52
|
-
...
|
|
52
|
+
...s,
|
|
53
53
|
sheetTransform: {
|
|
54
54
|
...u,
|
|
55
|
-
flipY:
|
|
55
|
+
flipY: o,
|
|
56
56
|
flipX: d,
|
|
57
57
|
angle: g,
|
|
58
58
|
skewX: c,
|
|
59
59
|
skewY: m
|
|
60
60
|
},
|
|
61
61
|
transform: {
|
|
62
|
-
...
|
|
63
|
-
flipY:
|
|
62
|
+
...A,
|
|
63
|
+
flipY: o,
|
|
64
64
|
flipX: d,
|
|
65
65
|
angle: g,
|
|
66
66
|
skewX: c,
|
|
@@ -68,16 +68,16 @@ function ge(o, r, t) {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
let
|
|
72
|
-
constructor(
|
|
73
|
-
|
|
74
|
-
this._injector =
|
|
75
|
-
drawingId:
|
|
76
|
-
drawingType:
|
|
77
|
-
imageSourceType:
|
|
71
|
+
let B = class {
|
|
72
|
+
constructor(s, t, r) {
|
|
73
|
+
W(this, "_image");
|
|
74
|
+
this._injector = r, this._image = {
|
|
75
|
+
drawingId: ee(6),
|
|
76
|
+
drawingType: v.DRAWING_IMAGE,
|
|
77
|
+
imageSourceType: y.BASE64,
|
|
78
78
|
source: "",
|
|
79
|
-
unitId:
|
|
80
|
-
subUnitId:
|
|
79
|
+
unitId: s,
|
|
80
|
+
subUnitId: t,
|
|
81
81
|
column: 0,
|
|
82
82
|
columnOffset: 0,
|
|
83
83
|
row: 0,
|
|
@@ -111,12 +111,12 @@ let F = class {
|
|
|
111
111
|
* fWorksheet.insertImages([image]);
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
114
|
-
setImage(
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
throw new Error(`Render Unit with unitId ${
|
|
118
|
-
const e =
|
|
119
|
-
return
|
|
114
|
+
setImage(s) {
|
|
115
|
+
const r = this._injector.get(C).getRenderById(s.unitId);
|
|
116
|
+
if (!r)
|
|
117
|
+
throw new Error(`Render Unit with unitId ${s.unitId} not found`);
|
|
118
|
+
const e = r.with(H);
|
|
119
|
+
return s.sheetTransform == null && (s.sheetTransform = {
|
|
120
120
|
from: {
|
|
121
121
|
column: 0,
|
|
122
122
|
columnOffset: 0,
|
|
@@ -129,11 +129,11 @@ let F = class {
|
|
|
129
129
|
row: 0,
|
|
130
130
|
rowOffset: 0
|
|
131
131
|
}
|
|
132
|
-
}), this._image =
|
|
132
|
+
}), this._image = me(s, e), this;
|
|
133
133
|
}
|
|
134
|
-
setSource(
|
|
135
|
-
const
|
|
136
|
-
return this._image.source =
|
|
134
|
+
setSource(s, t) {
|
|
135
|
+
const r = t != null ? t : y.URL;
|
|
136
|
+
return this._image.source = s, this._image.imageSourceType = r, this;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Get the source of the image
|
|
@@ -185,8 +185,8 @@ let F = class {
|
|
|
185
185
|
* fWorksheet.insertImages([image]);
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
|
-
setColumn(
|
|
189
|
-
return this._image.column =
|
|
188
|
+
setColumn(s) {
|
|
189
|
+
return this._image.column = s, this;
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
192
|
* Set the vertical position of the image
|
|
@@ -206,8 +206,8 @@ let F = class {
|
|
|
206
206
|
* fWorksheet.insertImages([image]);
|
|
207
207
|
* ```
|
|
208
208
|
*/
|
|
209
|
-
setRow(
|
|
210
|
-
return this._image.row =
|
|
209
|
+
setRow(s) {
|
|
210
|
+
return this._image.row = s, this;
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* Set the horizontal offset of the image
|
|
@@ -228,8 +228,8 @@ let F = class {
|
|
|
228
228
|
* fWorksheet.insertImages([image]);
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
|
-
setColumnOffset(
|
|
232
|
-
return this._image.columnOffset =
|
|
231
|
+
setColumnOffset(s) {
|
|
232
|
+
return this._image.columnOffset = s, this;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* Set the vertical offset of the image
|
|
@@ -250,8 +250,8 @@ let F = class {
|
|
|
250
250
|
* fWorksheet.insertImages([image]);
|
|
251
251
|
* ```
|
|
252
252
|
*/
|
|
253
|
-
setRowOffset(
|
|
254
|
-
return this._image.rowOffset =
|
|
253
|
+
setRowOffset(s) {
|
|
254
|
+
return this._image.rowOffset = s, this;
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
257
|
* Set the width of the image
|
|
@@ -273,8 +273,8 @@ let F = class {
|
|
|
273
273
|
* fWorksheet.insertImages([image]);
|
|
274
274
|
* ```
|
|
275
275
|
*/
|
|
276
|
-
setWidth(
|
|
277
|
-
return this._image.width =
|
|
276
|
+
setWidth(s) {
|
|
277
|
+
return this._image.width = s, this;
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
280
|
* Set the height of the image
|
|
@@ -296,8 +296,8 @@ let F = class {
|
|
|
296
296
|
* fWorksheet.insertImages([image]);
|
|
297
297
|
* ```
|
|
298
298
|
*/
|
|
299
|
-
setHeight(
|
|
300
|
-
return this._image.height =
|
|
299
|
+
setHeight(s) {
|
|
300
|
+
return this._image.height = s, this;
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* Set the anchor type of the image, whether the position and size change with the cell
|
|
@@ -345,8 +345,8 @@ let F = class {
|
|
|
345
345
|
* }, 2000);
|
|
346
346
|
* ```
|
|
347
347
|
*/
|
|
348
|
-
setAnchorType(
|
|
349
|
-
return this._image.anchorType =
|
|
348
|
+
setAnchorType(s) {
|
|
349
|
+
return this._image.anchorType = s, this;
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Set the cropping region of the image by defining the top edges, thereby displaying the specific part of the image you want.
|
|
@@ -367,8 +367,8 @@ let F = class {
|
|
|
367
367
|
* fWorksheet.insertImages([image]);
|
|
368
368
|
* ```
|
|
369
369
|
*/
|
|
370
|
-
setCropTop(
|
|
371
|
-
return this._initializeSrcRect(), this._image.srcRect.top =
|
|
370
|
+
setCropTop(s) {
|
|
371
|
+
return this._initializeSrcRect(), this._image.srcRect.top = s, this;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* Set the cropping region of the image by defining the left edges, thereby displaying the specific part of the image you want.
|
|
@@ -389,8 +389,8 @@ let F = class {
|
|
|
389
389
|
* fWorksheet.insertImages([image]);
|
|
390
390
|
* ```
|
|
391
391
|
*/
|
|
392
|
-
setCropLeft(
|
|
393
|
-
return this._initializeSrcRect(), this._image.srcRect.left =
|
|
392
|
+
setCropLeft(s) {
|
|
393
|
+
return this._initializeSrcRect(), this._image.srcRect.left = s, this;
|
|
394
394
|
}
|
|
395
395
|
/**
|
|
396
396
|
* Set the cropping region of the image by defining the bottom edges, thereby displaying the specific part of the image you want.
|
|
@@ -411,8 +411,8 @@ let F = class {
|
|
|
411
411
|
* fWorksheet.insertImages([image]);
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
414
|
-
setCropBottom(
|
|
415
|
-
return this._initializeSrcRect(), this._image.srcRect.bottom =
|
|
414
|
+
setCropBottom(s) {
|
|
415
|
+
return this._initializeSrcRect(), this._image.srcRect.bottom = s, this;
|
|
416
416
|
}
|
|
417
417
|
/**
|
|
418
418
|
* Set the cropping region of the image by defining the right edges, thereby displaying the specific part of the image you want.
|
|
@@ -433,8 +433,8 @@ let F = class {
|
|
|
433
433
|
* fWorksheet.insertImages([image]);
|
|
434
434
|
* ```
|
|
435
435
|
*/
|
|
436
|
-
setCropRight(
|
|
437
|
-
return this._initializeSrcRect(), this._image.srcRect.right =
|
|
436
|
+
setCropRight(s) {
|
|
437
|
+
return this._initializeSrcRect(), this._image.srcRect.right = s, this;
|
|
438
438
|
}
|
|
439
439
|
_initializeSrcRect() {
|
|
440
440
|
this._image.srcRect == null && (this._image.srcRect = {
|
|
@@ -463,33 +463,33 @@ let F = class {
|
|
|
463
463
|
* fWorksheet.insertImages([image]);
|
|
464
464
|
* ```
|
|
465
465
|
*/
|
|
466
|
-
setRotate(
|
|
467
|
-
return this._image.angle =
|
|
466
|
+
setRotate(s) {
|
|
467
|
+
return this._image.angle = s, this;
|
|
468
468
|
}
|
|
469
|
-
setUnitId(
|
|
470
|
-
return this._image.unitId =
|
|
469
|
+
setUnitId(s) {
|
|
470
|
+
return this._image.unitId = s, this;
|
|
471
471
|
}
|
|
472
|
-
setSubUnitId(
|
|
473
|
-
return this._image.subUnitId =
|
|
472
|
+
setSubUnitId(s) {
|
|
473
|
+
return this._image.subUnitId = s, this;
|
|
474
474
|
}
|
|
475
475
|
async buildAsync() {
|
|
476
|
-
const
|
|
477
|
-
if (!
|
|
476
|
+
const t = this._injector.get(C).getRenderById(this._image.unitId);
|
|
477
|
+
if (!t)
|
|
478
478
|
throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
|
|
479
|
-
const
|
|
479
|
+
const r = t.with(x), e = t.with(H);
|
|
480
480
|
if (this._image.width === 0 || this._image.height === 0) {
|
|
481
|
-
const
|
|
482
|
-
this._image.width === 0 && (this._image.width =
|
|
481
|
+
const n = await ie(this._image.source), i = n.width, a = n.height;
|
|
482
|
+
this._image.width === 0 && (this._image.width = i), this._image.height === 0 && (this._image.height = a);
|
|
483
483
|
}
|
|
484
|
-
return
|
|
484
|
+
return he(this._image, r, e);
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
],
|
|
490
|
-
let
|
|
491
|
-
constructor(
|
|
492
|
-
super(), this._image =
|
|
487
|
+
B = J([
|
|
488
|
+
P(2, N(L))
|
|
489
|
+
], B);
|
|
490
|
+
let I = class extends ne {
|
|
491
|
+
constructor(s, t, r) {
|
|
492
|
+
super(), this._image = s, this._commandService = t, this._injector = r;
|
|
493
493
|
}
|
|
494
494
|
/**
|
|
495
495
|
* Get the id of the image
|
|
@@ -552,18 +552,18 @@ let v = class extends te {
|
|
|
552
552
|
* ```
|
|
553
553
|
*/
|
|
554
554
|
toBuilder() {
|
|
555
|
-
const
|
|
556
|
-
return
|
|
555
|
+
const s = this._injector.createInstance(B);
|
|
556
|
+
return s.setImage(this._image), s;
|
|
557
557
|
}
|
|
558
|
-
setSource(
|
|
559
|
-
const
|
|
560
|
-
return this._image.source =
|
|
558
|
+
setSource(s, t) {
|
|
559
|
+
const r = t != null ? t : y.URL;
|
|
560
|
+
return this._image.source = s, this._image.imageSourceType = r, this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
561
561
|
}
|
|
562
|
-
async setPositionAsync(
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
const
|
|
566
|
-
return this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [
|
|
562
|
+
async setPositionAsync(s, t, r, e) {
|
|
563
|
+
const n = this.toBuilder();
|
|
564
|
+
n.setColumn(t), n.setRow(s), r != null && n.setRowOffset(r), e != null && n.setColumnOffset(e);
|
|
565
|
+
const i = await n.buildAsync();
|
|
566
|
+
return this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [i] });
|
|
567
567
|
}
|
|
568
568
|
/**
|
|
569
569
|
* Set the size of the image
|
|
@@ -580,10 +580,10 @@ let v = class extends te {
|
|
|
580
580
|
* console.log(result);
|
|
581
581
|
* ```
|
|
582
582
|
*/
|
|
583
|
-
async setSizeAsync(
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
const e = await
|
|
583
|
+
async setSizeAsync(s, t) {
|
|
584
|
+
const r = this.toBuilder();
|
|
585
|
+
r.setWidth(s), r.setHeight(t);
|
|
586
|
+
const e = await r.buildAsync();
|
|
587
587
|
return this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [e] });
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
@@ -603,13 +603,13 @@ let v = class extends te {
|
|
|
603
603
|
* console.log(result);
|
|
604
604
|
* ```
|
|
605
605
|
*/
|
|
606
|
-
setCrop(
|
|
606
|
+
setCrop(s, t, r, e) {
|
|
607
607
|
return this._image.srcRect == null && (this._image.srcRect = {
|
|
608
608
|
top: 0,
|
|
609
609
|
left: 0,
|
|
610
610
|
bottom: 0,
|
|
611
611
|
right: 0
|
|
612
|
-
}),
|
|
612
|
+
}), s != null && (this._image.srcRect.top = s), t != null && (this._image.srcRect.left = t), r != null && (this._image.srcRect.bottom = r), e != null && (this._image.srcRect.right = e), this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
613
613
|
}
|
|
614
614
|
/**
|
|
615
615
|
* Set the rotation angle of the image
|
|
@@ -625,8 +625,8 @@ let v = class extends te {
|
|
|
625
625
|
* console.log(result);
|
|
626
626
|
* ```
|
|
627
627
|
*/
|
|
628
|
-
setRotate(
|
|
629
|
-
return this._image.sheetTransform.angle =
|
|
628
|
+
setRotate(s) {
|
|
629
|
+
return this._image.sheetTransform.angle = s, this._image.transform && (this._image.transform.angle = s), this._commandService.syncExecuteCommand(f.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
632
632
|
* Move the image layer forward by one level
|
|
@@ -641,11 +641,11 @@ let v = class extends te {
|
|
|
641
641
|
* ```
|
|
642
642
|
*/
|
|
643
643
|
setForward() {
|
|
644
|
-
return this._commandService.syncExecuteCommand(
|
|
644
|
+
return this._commandService.syncExecuteCommand(F.id, {
|
|
645
645
|
unitId: this._image.unitId,
|
|
646
646
|
subUnitId: this._image.subUnitId,
|
|
647
647
|
drawingIds: [this._image.drawingId],
|
|
648
|
-
arrangeType:
|
|
648
|
+
arrangeType: O.forward
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
@@ -661,11 +661,11 @@ let v = class extends te {
|
|
|
661
661
|
* ```
|
|
662
662
|
*/
|
|
663
663
|
setBackward() {
|
|
664
|
-
return this._commandService.syncExecuteCommand(
|
|
664
|
+
return this._commandService.syncExecuteCommand(F.id, {
|
|
665
665
|
unitId: this._image.unitId,
|
|
666
666
|
subUnitId: this._image.subUnitId,
|
|
667
667
|
drawingIds: [this._image.drawingId],
|
|
668
|
-
arrangeType:
|
|
668
|
+
arrangeType: O.backward
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
671
|
/**
|
|
@@ -681,11 +681,11 @@ let v = class extends te {
|
|
|
681
681
|
* ```
|
|
682
682
|
*/
|
|
683
683
|
setBack() {
|
|
684
|
-
return this._commandService.syncExecuteCommand(
|
|
684
|
+
return this._commandService.syncExecuteCommand(F.id, {
|
|
685
685
|
unitId: this._image.unitId,
|
|
686
686
|
subUnitId: this._image.subUnitId,
|
|
687
687
|
drawingIds: [this._image.drawingId],
|
|
688
|
-
arrangeType:
|
|
688
|
+
arrangeType: O.back
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
691
|
/**
|
|
@@ -701,171 +701,171 @@ let v = class extends te {
|
|
|
701
701
|
* ```
|
|
702
702
|
*/
|
|
703
703
|
setFront() {
|
|
704
|
-
return this._commandService.syncExecuteCommand(
|
|
704
|
+
return this._commandService.syncExecuteCommand(F.id, {
|
|
705
705
|
unitId: this._image.unitId,
|
|
706
706
|
subUnitId: this._image.subUnitId,
|
|
707
707
|
drawingIds: [this._image.drawingId],
|
|
708
|
-
arrangeType:
|
|
708
|
+
arrangeType: O.front
|
|
709
709
|
});
|
|
710
710
|
}
|
|
711
711
|
};
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
],
|
|
716
|
-
class
|
|
717
|
-
getFloatDomById(
|
|
718
|
-
const e = this._injector.get(
|
|
712
|
+
I = J([
|
|
713
|
+
P(1, K),
|
|
714
|
+
P(2, N(L))
|
|
715
|
+
], I);
|
|
716
|
+
class le extends $ {
|
|
717
|
+
getFloatDomById(t) {
|
|
718
|
+
const e = this._injector.get(p).getFloatDomInfo(t);
|
|
719
719
|
if (!e) return null;
|
|
720
|
-
const { unitId:
|
|
720
|
+
const { unitId: n, subUnitId: i } = e, { rect: a } = e, o = a.getState(), { left: d = 0, top: g = 0, width: c = 0, height: m = 0, flipX: h = !1, flipY: _ = !1, angle: l = 0, skewX: u = 0, skewY: A = 0 } = o, R = this._injector.get(w).getDrawingByParam({
|
|
721
721
|
drawingId: e.id,
|
|
722
|
-
unitId:
|
|
723
|
-
subUnitId:
|
|
722
|
+
unitId: n,
|
|
723
|
+
subUnitId: i
|
|
724
724
|
});
|
|
725
|
-
return
|
|
725
|
+
return R ? {
|
|
726
726
|
position: {
|
|
727
727
|
left: d,
|
|
728
728
|
top: g,
|
|
729
729
|
width: c,
|
|
730
730
|
height: m,
|
|
731
|
-
flipX:
|
|
731
|
+
flipX: h,
|
|
732
732
|
flipY: _,
|
|
733
|
-
angle:
|
|
733
|
+
angle: l,
|
|
734
734
|
skewX: u,
|
|
735
|
-
skewY:
|
|
735
|
+
skewY: A
|
|
736
736
|
},
|
|
737
|
-
componentKey:
|
|
738
|
-
allowTransform:
|
|
739
|
-
data:
|
|
737
|
+
componentKey: R.componentKey,
|
|
738
|
+
allowTransform: R.allowTransform,
|
|
739
|
+
data: R.data,
|
|
740
740
|
id: e.id
|
|
741
741
|
} : null;
|
|
742
742
|
}
|
|
743
743
|
getAllFloatDoms() {
|
|
744
|
-
const
|
|
745
|
-
return Array.from(
|
|
746
|
-
const { rect:
|
|
747
|
-
drawingId:
|
|
748
|
-
unitId:
|
|
744
|
+
const t = this._injector.get(p), r = this._workbook.getUnitId(), e = this._worksheet.getSheetId();
|
|
745
|
+
return Array.from(t.getFloatDomsBySubUnitId(r, e).values()).map((n) => {
|
|
746
|
+
const { rect: i } = n, a = this._injector.get(w).getDrawingByParam({
|
|
747
|
+
drawingId: n.id,
|
|
748
|
+
unitId: r,
|
|
749
749
|
subUnitId: e
|
|
750
|
-
}), { left:
|
|
750
|
+
}), { left: o, top: d, width: g, height: c, flipX: m, flipY: h, angle: _, skewX: l, skewY: u } = i.getState();
|
|
751
751
|
return {
|
|
752
752
|
position: {
|
|
753
|
-
left:
|
|
753
|
+
left: o,
|
|
754
754
|
top: d,
|
|
755
755
|
width: g,
|
|
756
756
|
height: c,
|
|
757
757
|
flipX: m,
|
|
758
|
-
flipY:
|
|
758
|
+
flipY: h,
|
|
759
759
|
angle: _,
|
|
760
|
-
skewX:
|
|
760
|
+
skewX: l,
|
|
761
761
|
skewY: u
|
|
762
762
|
},
|
|
763
|
-
componentKey:
|
|
764
|
-
allowTransform:
|
|
765
|
-
data:
|
|
766
|
-
id:
|
|
763
|
+
componentKey: a.componentKey,
|
|
764
|
+
allowTransform: a.allowTransform,
|
|
765
|
+
data: a.data,
|
|
766
|
+
id: n.id
|
|
767
767
|
};
|
|
768
768
|
});
|
|
769
769
|
}
|
|
770
|
-
updateFloatDom(
|
|
771
|
-
var
|
|
772
|
-
const
|
|
773
|
-
if (!
|
|
774
|
-
const { unitId:
|
|
775
|
-
unitId:
|
|
776
|
-
subUnitId:
|
|
777
|
-
drawingId:
|
|
778
|
-
}), d = this._injector.get(
|
|
779
|
-
if (!d.getRenderById(
|
|
770
|
+
updateFloatDom(t, r) {
|
|
771
|
+
var l, u;
|
|
772
|
+
const n = this._injector.get(p).getFloatDomInfo(t);
|
|
773
|
+
if (!n) return this;
|
|
774
|
+
const { unitId: i, subUnitId: a } = n, o = this._injector.get(w).getDrawingByParam({
|
|
775
|
+
unitId: i,
|
|
776
|
+
subUnitId: a,
|
|
777
|
+
drawingId: t
|
|
778
|
+
}), d = this._injector.get(C);
|
|
779
|
+
if (!d.getRenderById(i)) return this;
|
|
780
780
|
if (!this.getSkeleton()) return this;
|
|
781
|
-
const m = (
|
|
781
|
+
const m = (l = d.getRenderById(this.getWorkbook().getUnitId())) == null ? void 0 : l.with(x);
|
|
782
782
|
if (!m) return this;
|
|
783
|
-
const
|
|
784
|
-
...
|
|
785
|
-
componentKey:
|
|
786
|
-
allowTransform:
|
|
787
|
-
data:
|
|
788
|
-
sheetTransform:
|
|
789
|
-
|
|
783
|
+
const h = {
|
|
784
|
+
...o,
|
|
785
|
+
componentKey: r.componentKey || o.componentKey,
|
|
786
|
+
allowTransform: r.allowTransform !== void 0 ? r.allowTransform : o.allowTransform,
|
|
787
|
+
data: r.data || o.data,
|
|
788
|
+
sheetTransform: r.position && (u = M(
|
|
789
|
+
r.position,
|
|
790
790
|
m
|
|
791
|
-
)) != null ? u :
|
|
791
|
+
)) != null ? u : o.sheetTransform,
|
|
792
792
|
transform: {
|
|
793
|
-
...
|
|
794
|
-
...
|
|
793
|
+
...o.transform,
|
|
794
|
+
...r.position
|
|
795
795
|
// Merge with existing transform
|
|
796
796
|
}
|
|
797
797
|
};
|
|
798
|
-
if (!this._commandService.syncExecuteCommand(f.id, { unitId:
|
|
798
|
+
if (!this._commandService.syncExecuteCommand(f.id, { unitId: i, subUnitId: a, drawings: [h] }))
|
|
799
799
|
throw new Error("updateFloatDom failed");
|
|
800
800
|
return this;
|
|
801
801
|
}
|
|
802
|
-
batchUpdateFloatDoms(
|
|
803
|
-
var
|
|
804
|
-
const
|
|
805
|
-
for (const
|
|
806
|
-
const d =
|
|
802
|
+
batchUpdateFloatDoms(t) {
|
|
803
|
+
var a;
|
|
804
|
+
const r = this._injector.get(p), e = this._injector.get(w), n = this._injector.get(C), i = [];
|
|
805
|
+
for (const o of t) {
|
|
806
|
+
const d = r.getFloatDomInfo(o.id);
|
|
807
807
|
if (!d) continue;
|
|
808
808
|
const { unitId: g, subUnitId: c } = d, m = e.getDrawingByParam({
|
|
809
809
|
unitId: g,
|
|
810
810
|
subUnitId: c,
|
|
811
|
-
drawingId:
|
|
811
|
+
drawingId: o.id
|
|
812
812
|
});
|
|
813
813
|
if (!m) continue;
|
|
814
|
-
const
|
|
815
|
-
if (!
|
|
816
|
-
const
|
|
817
|
-
if (!
|
|
814
|
+
const h = n.getRenderById(g);
|
|
815
|
+
if (!h || !this.getSkeleton()) continue;
|
|
816
|
+
const l = h.with(x);
|
|
817
|
+
if (!l) return this;
|
|
818
818
|
const u = {
|
|
819
819
|
...m,
|
|
820
|
-
componentKey:
|
|
821
|
-
allowTransform:
|
|
822
|
-
data:
|
|
823
|
-
sheetTransform:
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
)) != null ?
|
|
820
|
+
componentKey: o.config.componentKey || m.componentKey,
|
|
821
|
+
allowTransform: o.config.allowTransform !== void 0 ? o.config.allowTransform : m.allowTransform,
|
|
822
|
+
data: o.config.data || m.data,
|
|
823
|
+
sheetTransform: o.config.position && (a = M(
|
|
824
|
+
o.config.position,
|
|
825
|
+
l
|
|
826
|
+
)) != null ? a : m.sheetTransform,
|
|
827
827
|
transform: {
|
|
828
828
|
...m.transform,
|
|
829
|
-
...
|
|
829
|
+
...o.config.position
|
|
830
830
|
// Merge with existing transform
|
|
831
831
|
}
|
|
832
832
|
};
|
|
833
|
-
|
|
833
|
+
i.push(u);
|
|
834
834
|
}
|
|
835
|
-
if (
|
|
836
|
-
const
|
|
837
|
-
if (!this._commandService.syncExecuteCommand(f.id, { unitId:
|
|
835
|
+
if (i.length > 0) {
|
|
836
|
+
const o = this._workbook.getUnitId(), d = this._worksheet.getSheetId();
|
|
837
|
+
if (!this._commandService.syncExecuteCommand(f.id, { unitId: o, subUnitId: d, drawings: i }))
|
|
838
838
|
throw new Error("batchUpdateFloatDoms failed");
|
|
839
839
|
}
|
|
840
840
|
return this;
|
|
841
841
|
}
|
|
842
|
-
removeFloatDom(
|
|
843
|
-
const e = this._injector.get(
|
|
842
|
+
removeFloatDom(t) {
|
|
843
|
+
const e = this._injector.get(p).getFloatDomInfo(t);
|
|
844
844
|
if (!e) return this;
|
|
845
|
-
const { unitId:
|
|
846
|
-
unitId:
|
|
847
|
-
subUnitId:
|
|
848
|
-
drawingId:
|
|
845
|
+
const { unitId: n, subUnitId: i } = e, o = this._injector.get(w).getDrawingByParam({
|
|
846
|
+
unitId: n,
|
|
847
|
+
subUnitId: i,
|
|
848
|
+
drawingId: t
|
|
849
849
|
});
|
|
850
|
-
if (!
|
|
850
|
+
if (!o) return this;
|
|
851
851
|
if (!this._commandService.syncExecuteCommand(k.id, {
|
|
852
|
-
unitId:
|
|
853
|
-
drawings: [
|
|
852
|
+
unitId: n,
|
|
853
|
+
drawings: [o]
|
|
854
854
|
}))
|
|
855
855
|
throw new Error("removeFloatDom failed");
|
|
856
856
|
return this;
|
|
857
857
|
}
|
|
858
|
-
addFloatDomToPosition(
|
|
859
|
-
const e = this._workbook.getUnitId(),
|
|
860
|
-
return d ? (
|
|
858
|
+
addFloatDomToPosition(t, r) {
|
|
859
|
+
const e = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: i, disposableCollection: a } = U(t, this._injector.get(G)), d = this._injector.get(p).addFloatDomToPosition({ ...t, componentKey: i, unitId: e, subUnitId: n }, r);
|
|
860
|
+
return d ? (a.add(d.dispose), {
|
|
861
861
|
id: d.id,
|
|
862
862
|
dispose: () => {
|
|
863
|
-
|
|
863
|
+
a.dispose(), d.dispose();
|
|
864
864
|
}
|
|
865
|
-
}) : (
|
|
865
|
+
}) : (a.dispose(), null);
|
|
866
866
|
}
|
|
867
|
-
addFloatDomToRange(
|
|
868
|
-
const
|
|
867
|
+
addFloatDomToRange(t, r, e, n) {
|
|
868
|
+
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } = U(r, this._injector.get(G)), c = this._injector.get(p).addFloatDomToRange(t.getRange(), { ...r, componentKey: o, unitId: i, subUnitId: a }, e, n);
|
|
869
869
|
return c ? (d.add(c.dispose), {
|
|
870
870
|
id: c.id,
|
|
871
871
|
dispose: () => {
|
|
@@ -873,8 +873,8 @@ class me extends $ {
|
|
|
873
873
|
}
|
|
874
874
|
}) : (d.dispose(), null);
|
|
875
875
|
}
|
|
876
|
-
addFloatDomToColumnHeader(
|
|
877
|
-
const
|
|
876
|
+
addFloatDomToColumnHeader(t, r, e, n) {
|
|
877
|
+
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } = U(r, this._injector.get(G)), c = this._injector.get(p).addFloatDomToColumnHeader(t, { ...r, componentKey: o, unitId: i, subUnitId: a }, e, n);
|
|
878
878
|
return c ? (d.add(c.dispose), {
|
|
879
879
|
id: c.id,
|
|
880
880
|
dispose: () => {
|
|
@@ -882,100 +882,122 @@ class me extends $ {
|
|
|
882
882
|
}
|
|
883
883
|
}) : (d.dispose(), null);
|
|
884
884
|
}
|
|
885
|
-
async insertImage(
|
|
886
|
-
const
|
|
887
|
-
if (typeof
|
|
888
|
-
|
|
885
|
+
async insertImage(t, r, e, n, i) {
|
|
886
|
+
const a = this.newOverGridImage();
|
|
887
|
+
if (typeof t == "string")
|
|
888
|
+
a.setSource(t);
|
|
889
889
|
else {
|
|
890
|
-
const g = await
|
|
891
|
-
|
|
890
|
+
const g = await t.getBlob().getDataAsString();
|
|
891
|
+
a.setSource(g, y.BASE64);
|
|
892
892
|
}
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
return this._commandService.syncExecuteCommand(
|
|
893
|
+
r !== void 0 ? a.setColumn(r) : a.setColumn(0), e !== void 0 ? a.setRow(e) : a.setRow(0), n !== void 0 ? a.setColumnOffset(n) : a.setColumnOffset(0), i !== void 0 ? a.setRowOffset(i) : a.setRowOffset(0);
|
|
894
|
+
const o = await a.buildAsync();
|
|
895
|
+
return this._commandService.syncExecuteCommand(E.id, { unitId: this._fWorkbook.getId(), drawings: [o] });
|
|
896
896
|
}
|
|
897
|
-
insertImages(
|
|
898
|
-
const
|
|
899
|
-
return this._commandService.syncExecuteCommand(
|
|
897
|
+
insertImages(t) {
|
|
898
|
+
const r = t.map((e) => (e.unitId = this._fWorkbook.getId(), e.subUnitId = this.getSheetId(), e));
|
|
899
|
+
return this._commandService.syncExecuteCommand(E.id, { unitId: this._fWorkbook.getId(), drawings: r }), this;
|
|
900
900
|
}
|
|
901
|
-
deleteImages(
|
|
902
|
-
const
|
|
901
|
+
deleteImages(t) {
|
|
902
|
+
const r = t.map((e) => ({
|
|
903
903
|
unitId: this._fWorkbook.getId(),
|
|
904
904
|
drawingId: e.getId(),
|
|
905
905
|
subUnitId: this.getSheetId(),
|
|
906
906
|
drawingType: e.getType()
|
|
907
907
|
}));
|
|
908
|
-
return this._commandService.syncExecuteCommand(k.id, { unitId: this._fWorkbook.getId(), drawings:
|
|
908
|
+
return this._commandService.syncExecuteCommand(k.id, { unitId: this._fWorkbook.getId(), drawings: r }), this;
|
|
909
909
|
}
|
|
910
910
|
getImages() {
|
|
911
|
-
const
|
|
912
|
-
for (const
|
|
913
|
-
const
|
|
914
|
-
|
|
911
|
+
const r = this._injector.get(w).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), e = [];
|
|
912
|
+
for (const n in r) {
|
|
913
|
+
const i = r[n];
|
|
914
|
+
i.drawingType === v.DRAWING_IMAGE && e.push(this._injector.createInstance(I, i));
|
|
915
915
|
}
|
|
916
916
|
return e;
|
|
917
917
|
}
|
|
918
|
-
getImageById(
|
|
919
|
-
const e = this._injector.get(w).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId:
|
|
920
|
-
return e && e.drawingType ===
|
|
918
|
+
getImageById(t) {
|
|
919
|
+
const e = this._injector.get(w).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
|
|
920
|
+
return e && e.drawingType === v.DRAWING_IMAGE ? this._injector.createInstance(I, e) : null;
|
|
921
921
|
}
|
|
922
922
|
getActiveImages() {
|
|
923
|
-
const
|
|
924
|
-
for (const
|
|
925
|
-
const
|
|
926
|
-
e.push(this._injector.createInstance(
|
|
923
|
+
const r = this._injector.get(w).getFocusDrawings(), e = [];
|
|
924
|
+
for (const n in r) {
|
|
925
|
+
const i = r[n];
|
|
926
|
+
e.push(this._injector.createInstance(I, i));
|
|
927
927
|
}
|
|
928
928
|
return e;
|
|
929
929
|
}
|
|
930
|
-
updateImages(
|
|
931
|
-
return this._commandService.syncExecuteCommand(f.id, { unitId: this._fWorkbook.getId(), drawings:
|
|
930
|
+
updateImages(t) {
|
|
931
|
+
return this._commandService.syncExecuteCommand(f.id, { unitId: this._fWorkbook.getId(), drawings: t }), this;
|
|
932
932
|
}
|
|
933
|
-
onImageInserted(
|
|
934
|
-
const
|
|
935
|
-
return T(
|
|
936
|
-
const
|
|
937
|
-
(
|
|
933
|
+
onImageInserted(t) {
|
|
934
|
+
const r = this._injector.get(w);
|
|
935
|
+
return T(r.add$.subscribe((e) => {
|
|
936
|
+
const n = e.map(
|
|
937
|
+
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
938
938
|
);
|
|
939
|
-
|
|
939
|
+
t(n);
|
|
940
940
|
}));
|
|
941
941
|
}
|
|
942
|
-
onImageDeleted(
|
|
943
|
-
const
|
|
944
|
-
return T(
|
|
945
|
-
const
|
|
946
|
-
(
|
|
942
|
+
onImageDeleted(t) {
|
|
943
|
+
const r = this._injector.get(w);
|
|
944
|
+
return T(r.remove$.subscribe((e) => {
|
|
945
|
+
const n = e.map(
|
|
946
|
+
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
947
947
|
);
|
|
948
|
-
|
|
948
|
+
t(n);
|
|
949
949
|
}));
|
|
950
950
|
}
|
|
951
|
-
onImageChanged(
|
|
952
|
-
const
|
|
953
|
-
return T(
|
|
954
|
-
const
|
|
955
|
-
(
|
|
951
|
+
onImageChanged(t) {
|
|
952
|
+
const r = this._injector.get(w);
|
|
953
|
+
return T(r.update$.subscribe((e) => {
|
|
954
|
+
const n = e.map(
|
|
955
|
+
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
956
956
|
);
|
|
957
|
-
|
|
957
|
+
t(n);
|
|
958
958
|
}));
|
|
959
959
|
}
|
|
960
960
|
newOverGridImage() {
|
|
961
|
-
const
|
|
962
|
-
return this._injector.createInstance(
|
|
961
|
+
const t = this._fWorkbook.getId(), r = this.getSheetId();
|
|
962
|
+
return this._injector.createInstance(B, t, r);
|
|
963
|
+
}
|
|
964
|
+
async saveCellImagesAsync(t, r) {
|
|
965
|
+
var m;
|
|
966
|
+
const e = this._injector.get(V), n = this._fWorkbook.getId(), i = this.getSheetId(), a = r ? r.map((h) => h.getRange()) : [this._worksheet.getCellMatrix().getDataRange()], o = e.getCellImagesFromRanges(n, i, a);
|
|
967
|
+
if (o.length === 0)
|
|
968
|
+
return !1;
|
|
969
|
+
if (o.length === 1)
|
|
970
|
+
try {
|
|
971
|
+
return await e.downloadSingleImage(o[0]), !0;
|
|
972
|
+
} catch (h) {
|
|
973
|
+
return console.error("Failed to download image:", h), !1;
|
|
974
|
+
}
|
|
975
|
+
const d = [], g = (m = t == null ? void 0 : t.useCellAddress) != null ? m : !0, c = t == null ? void 0 : t.useColumnIndex;
|
|
976
|
+
g && d.push(b.CELL_ADDRESS), c !== void 0 && d.push(b.COLUMN_VALUE), d.length === 0 && d.push(b.CELL_ADDRESS);
|
|
977
|
+
try {
|
|
978
|
+
return await e.saveImagesWithContext(o, {
|
|
979
|
+
fileNameParts: d,
|
|
980
|
+
columnIndex: c
|
|
981
|
+
}, n, i), !0;
|
|
982
|
+
} catch (h) {
|
|
983
|
+
return console.error("Failed to save images:", h), !1;
|
|
984
|
+
}
|
|
963
985
|
}
|
|
964
986
|
}
|
|
965
|
-
$.extend(
|
|
966
|
-
class
|
|
987
|
+
$.extend(le);
|
|
988
|
+
class ue extends z {
|
|
967
989
|
get DrawingType() {
|
|
968
|
-
return
|
|
990
|
+
return v;
|
|
969
991
|
}
|
|
970
992
|
get ImageSourceType() {
|
|
971
|
-
return
|
|
993
|
+
return y;
|
|
972
994
|
}
|
|
973
995
|
get SheetDrawingAnchorType() {
|
|
974
|
-
return
|
|
996
|
+
return ce;
|
|
975
997
|
}
|
|
976
998
|
}
|
|
977
|
-
z.extend(
|
|
978
|
-
class
|
|
999
|
+
z.extend(ue);
|
|
1000
|
+
class fe extends X {
|
|
979
1001
|
get BeforeFloatDomAdd() {
|
|
980
1002
|
return "BeforeFloatDomAdd";
|
|
981
1003
|
}
|
|
@@ -1019,253 +1041,275 @@ class le extends X {
|
|
|
1019
1041
|
return "OverGridImageSelected";
|
|
1020
1042
|
}
|
|
1021
1043
|
}
|
|
1022
|
-
X.extend(
|
|
1023
|
-
class
|
|
1044
|
+
X.extend(fe);
|
|
1045
|
+
class we extends Y {
|
|
1024
1046
|
/**
|
|
1025
1047
|
* @ignore
|
|
1026
1048
|
*/
|
|
1027
1049
|
// eslint-disable-next-line max-lines-per-function
|
|
1028
|
-
_initialize(
|
|
1029
|
-
const
|
|
1050
|
+
_initialize(t) {
|
|
1051
|
+
const r = t.get(K);
|
|
1030
1052
|
this.registerEventHandler(
|
|
1031
1053
|
this.Event.BeforeFloatDomAdd,
|
|
1032
|
-
() =>
|
|
1033
|
-
if (e.id !==
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1054
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1055
|
+
if (e.id !== E.id) return;
|
|
1056
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1057
|
+
if (i == null || n == null)
|
|
1036
1058
|
return;
|
|
1037
|
-
const { drawings:
|
|
1038
|
-
(g) => g.drawingType ===
|
|
1059
|
+
const { drawings: a } = n, o = a.filter(
|
|
1060
|
+
(g) => g.drawingType === v.DRAWING_DOM
|
|
1039
1061
|
);
|
|
1040
|
-
if (
|
|
1062
|
+
if (o.length === 0)
|
|
1041
1063
|
return;
|
|
1042
1064
|
const d = {
|
|
1043
|
-
workbook:
|
|
1044
|
-
drawings:
|
|
1065
|
+
workbook: i,
|
|
1066
|
+
drawings: o
|
|
1045
1067
|
};
|
|
1046
1068
|
if (this.fireEvent(this.Event.BeforeFloatDomAdd, d), d.cancel)
|
|
1047
|
-
throw new
|
|
1069
|
+
throw new D();
|
|
1048
1070
|
})
|
|
1049
1071
|
), this.registerEventHandler(
|
|
1050
1072
|
this.Event.FloatDomAdded,
|
|
1051
|
-
() =>
|
|
1052
|
-
if (e.id !==
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1073
|
+
() => r.onCommandExecuted((e) => {
|
|
1074
|
+
if (e.id !== E.id) return;
|
|
1075
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1076
|
+
if (i == null || n == null)
|
|
1055
1077
|
return;
|
|
1056
|
-
const { drawings:
|
|
1057
|
-
(d) => d.drawingType ===
|
|
1078
|
+
const { drawings: a } = n, o = a.filter(
|
|
1079
|
+
(d) => d.drawingType === v.DRAWING_DOM
|
|
1058
1080
|
);
|
|
1059
|
-
|
|
1060
|
-
workbook:
|
|
1061
|
-
drawings:
|
|
1081
|
+
o.length !== 0 && this.fireEvent(this.Event.FloatDomAdded, {
|
|
1082
|
+
workbook: i,
|
|
1083
|
+
drawings: o
|
|
1062
1084
|
});
|
|
1063
1085
|
})
|
|
1064
1086
|
), this.registerEventHandler(
|
|
1065
1087
|
this.Event.BeforeOverGridImageInsert,
|
|
1066
|
-
() =>
|
|
1067
|
-
if (e.id !==
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1088
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1089
|
+
if (e.id !== E.id) return;
|
|
1090
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1091
|
+
if (i == null || n == null)
|
|
1070
1092
|
return;
|
|
1071
|
-
const { drawings:
|
|
1072
|
-
workbook:
|
|
1073
|
-
insertImageParams:
|
|
1093
|
+
const { drawings: a } = n, o = {
|
|
1094
|
+
workbook: i,
|
|
1095
|
+
insertImageParams: a
|
|
1074
1096
|
};
|
|
1075
|
-
if (this.fireEvent(this.Event.BeforeOverGridImageInsert,
|
|
1076
|
-
throw new
|
|
1097
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageInsert, o), o.cancel)
|
|
1098
|
+
throw new D();
|
|
1077
1099
|
})
|
|
1078
1100
|
), this.registerEventHandler(
|
|
1079
1101
|
this.Event.BeforeOverGridImageRemove,
|
|
1080
|
-
() =>
|
|
1102
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1081
1103
|
if (e.id !== k.id) return;
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1104
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1105
|
+
if (i == null || n == null)
|
|
1084
1106
|
return;
|
|
1085
|
-
const
|
|
1086
|
-
workbook:
|
|
1107
|
+
const a = t.get(S), { drawings: o } = n, d = o.map((c) => a.getDrawingByParam(c)), g = {
|
|
1108
|
+
workbook: i,
|
|
1087
1109
|
images: this._createFOverGridImage(d)
|
|
1088
1110
|
};
|
|
1089
1111
|
if (this.fireEvent(this.Event.BeforeOverGridImageRemove, g), g.cancel)
|
|
1090
|
-
throw new
|
|
1112
|
+
throw new D();
|
|
1091
1113
|
})
|
|
1092
1114
|
), this.registerEventHandler(
|
|
1093
1115
|
this.Event.BeforeOverGridImageChange,
|
|
1094
|
-
() =>
|
|
1116
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1095
1117
|
if (e.id !== f.id) return;
|
|
1096
|
-
const
|
|
1097
|
-
if (
|
|
1118
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1119
|
+
if (i == null || n == null)
|
|
1098
1120
|
return;
|
|
1099
|
-
const { drawings:
|
|
1100
|
-
|
|
1101
|
-
const m =
|
|
1121
|
+
const { drawings: a } = n, o = t.get(S), d = [];
|
|
1122
|
+
a.forEach((c) => {
|
|
1123
|
+
const m = o.getDrawingByParam(c);
|
|
1102
1124
|
m != null && d.push({
|
|
1103
1125
|
changeParam: c,
|
|
1104
|
-
image: this._injector.createInstance(
|
|
1126
|
+
image: this._injector.createInstance(I, m)
|
|
1105
1127
|
});
|
|
1106
1128
|
});
|
|
1107
1129
|
const g = {
|
|
1108
|
-
workbook:
|
|
1130
|
+
workbook: i,
|
|
1109
1131
|
images: d
|
|
1110
1132
|
};
|
|
1111
1133
|
if (this.fireEvent(this.Event.BeforeOverGridImageChange, g), g.cancel)
|
|
1112
|
-
throw
|
|
1134
|
+
throw o.updateNotification(a), new D();
|
|
1113
1135
|
})
|
|
1114
1136
|
), this.registerEventHandler(
|
|
1115
1137
|
this.Event.BeforeFloatDomUpdate,
|
|
1116
|
-
() =>
|
|
1138
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1117
1139
|
if (e.id !== f.id) return;
|
|
1118
|
-
const
|
|
1119
|
-
if (
|
|
1140
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1141
|
+
if (i == null || n == null)
|
|
1120
1142
|
return;
|
|
1121
|
-
const { drawings:
|
|
1122
|
-
if (
|
|
1123
|
-
const m =
|
|
1124
|
-
(m == null ? void 0 : m.drawingType) ===
|
|
1143
|
+
const { drawings: a } = n, o = t.get(S), d = [];
|
|
1144
|
+
if (a.forEach((c) => {
|
|
1145
|
+
const m = o.getDrawingByParam(c);
|
|
1146
|
+
(m == null ? void 0 : m.drawingType) === v.DRAWING_DOM && d.push(m);
|
|
1125
1147
|
}), d.length === 0)
|
|
1126
1148
|
return;
|
|
1127
1149
|
const g = {
|
|
1128
|
-
workbook:
|
|
1150
|
+
workbook: i,
|
|
1129
1151
|
drawings: d
|
|
1130
1152
|
};
|
|
1131
1153
|
if (this.fireEvent(this.Event.BeforeFloatDomUpdate, g), g.cancel)
|
|
1132
|
-
throw
|
|
1154
|
+
throw o.updateNotification(a), new D();
|
|
1133
1155
|
})
|
|
1134
1156
|
), this.registerEventHandler(
|
|
1135
1157
|
this.Event.FloatDomUpdated,
|
|
1136
|
-
() =>
|
|
1158
|
+
() => r.onCommandExecuted((e) => {
|
|
1137
1159
|
if (e.id !== f.id) return;
|
|
1138
|
-
const
|
|
1139
|
-
if (
|
|
1160
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1161
|
+
if (i == null || n == null)
|
|
1140
1162
|
return;
|
|
1141
|
-
const { drawings:
|
|
1142
|
-
|
|
1143
|
-
const c =
|
|
1144
|
-
(c == null ? void 0 : c.drawingType) ===
|
|
1163
|
+
const { drawings: a } = n, o = t.get(S), d = [];
|
|
1164
|
+
a.forEach((g) => {
|
|
1165
|
+
const c = o.getDrawingByParam(g);
|
|
1166
|
+
(c == null ? void 0 : c.drawingType) === v.DRAWING_DOM && d.push(c);
|
|
1145
1167
|
}), d.length !== 0 && this.fireEvent(this.Event.FloatDomUpdated, {
|
|
1146
|
-
workbook:
|
|
1168
|
+
workbook: i,
|
|
1147
1169
|
drawings: d
|
|
1148
1170
|
});
|
|
1149
1171
|
})
|
|
1150
1172
|
), this.registerEventHandler(
|
|
1151
1173
|
this.Event.BeforeFloatDomDelete,
|
|
1152
|
-
() =>
|
|
1174
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1153
1175
|
if (e.id !== k.id) return;
|
|
1154
|
-
const
|
|
1155
|
-
if (
|
|
1176
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1177
|
+
if (i == null || n == null)
|
|
1156
1178
|
return;
|
|
1157
|
-
const
|
|
1158
|
-
(c) => (c == null ? void 0 : c.drawingType) ===
|
|
1179
|
+
const a = t.get(S), { drawings: o } = n, d = o.map((c) => a.getDrawingByParam(c)).filter(
|
|
1180
|
+
(c) => (c == null ? void 0 : c.drawingType) === v.DRAWING_DOM
|
|
1159
1181
|
);
|
|
1160
1182
|
if (d.length === 0)
|
|
1161
1183
|
return;
|
|
1162
1184
|
const g = {
|
|
1163
|
-
workbook:
|
|
1185
|
+
workbook: i,
|
|
1164
1186
|
drawings: d
|
|
1165
1187
|
};
|
|
1166
1188
|
if (this.fireEvent(this.Event.BeforeFloatDomDelete, g), g.cancel)
|
|
1167
|
-
throw new
|
|
1189
|
+
throw new D();
|
|
1168
1190
|
})
|
|
1169
1191
|
), this.registerEventHandler(
|
|
1170
1192
|
this.Event.FloatDomDeleted,
|
|
1171
|
-
() =>
|
|
1193
|
+
() => r.onCommandExecuted((e) => {
|
|
1172
1194
|
if (e.id !== k.id) return;
|
|
1173
|
-
const
|
|
1174
|
-
if (
|
|
1195
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1196
|
+
if (i == null || n == null)
|
|
1175
1197
|
return;
|
|
1176
|
-
const { drawings:
|
|
1198
|
+
const { drawings: a } = n;
|
|
1177
1199
|
this.fireEvent(this.Event.FloatDomDeleted, {
|
|
1178
|
-
workbook:
|
|
1179
|
-
drawings:
|
|
1200
|
+
workbook: i,
|
|
1201
|
+
drawings: a.filter((o) => o.drawingType === v.DRAWING_DOM).map((o) => o.drawingId)
|
|
1180
1202
|
});
|
|
1181
1203
|
})
|
|
1182
1204
|
), this.registerEventHandler(
|
|
1183
1205
|
this.Event.BeforeOverGridImageSelect,
|
|
1184
|
-
() =>
|
|
1185
|
-
if (e.id !==
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1206
|
+
() => r.beforeCommandExecuted((e) => {
|
|
1207
|
+
if (e.id !== j.id) return;
|
|
1208
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1209
|
+
if (i == null)
|
|
1188
1210
|
return;
|
|
1189
|
-
const
|
|
1190
|
-
workbook:
|
|
1211
|
+
const a = t.get(S), o = a.getFocusDrawings(), d = n.map((c) => a.getDrawingByParam(c)), g = {
|
|
1212
|
+
workbook: i,
|
|
1191
1213
|
selectedImages: this._createFOverGridImage(d),
|
|
1192
|
-
oldSelectedImages: this._createFOverGridImage(
|
|
1214
|
+
oldSelectedImages: this._createFOverGridImage(o)
|
|
1193
1215
|
};
|
|
1194
1216
|
if (this.fireEvent(this.Event.BeforeOverGridImageSelect, g), g.cancel)
|
|
1195
|
-
throw new
|
|
1217
|
+
throw new D();
|
|
1196
1218
|
})
|
|
1197
1219
|
), this.registerEventHandler(
|
|
1198
1220
|
this.Event.OverGridImageInserted,
|
|
1199
|
-
() =>
|
|
1200
|
-
if (e.id !==
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1221
|
+
() => r.onCommandExecuted((e) => {
|
|
1222
|
+
if (e.id !== E.id) return;
|
|
1223
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1224
|
+
if (i == null || n == null)
|
|
1203
1225
|
return;
|
|
1204
|
-
const { drawings:
|
|
1226
|
+
const { drawings: a } = n;
|
|
1205
1227
|
this.fireEvent(this.Event.OverGridImageInserted, {
|
|
1206
|
-
workbook:
|
|
1207
|
-
images: this._createFOverGridImage(
|
|
1228
|
+
workbook: i,
|
|
1229
|
+
images: this._createFOverGridImage(a)
|
|
1208
1230
|
});
|
|
1209
1231
|
})
|
|
1210
1232
|
), this.registerEventHandler(
|
|
1211
1233
|
this.Event.OverGridImageRemoved,
|
|
1212
|
-
() =>
|
|
1234
|
+
() => r.onCommandExecuted((e) => {
|
|
1213
1235
|
if (e.id !== k.id) return;
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1236
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1237
|
+
if (i == null || n == null)
|
|
1216
1238
|
return;
|
|
1217
|
-
const { drawings:
|
|
1239
|
+
const { drawings: a } = n;
|
|
1218
1240
|
this.fireEvent(this.Event.OverGridImageRemoved, {
|
|
1219
|
-
workbook:
|
|
1220
|
-
removeImageParams:
|
|
1241
|
+
workbook: i,
|
|
1242
|
+
removeImageParams: a
|
|
1221
1243
|
});
|
|
1222
1244
|
})
|
|
1223
1245
|
), this.registerEventHandler(
|
|
1224
1246
|
this.Event.OverGridImageChanged,
|
|
1225
|
-
() =>
|
|
1247
|
+
() => r.onCommandExecuted((e) => {
|
|
1226
1248
|
if (e.id !== f.id) return;
|
|
1227
|
-
const
|
|
1228
|
-
if (
|
|
1249
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1250
|
+
if (i == null || n == null)
|
|
1229
1251
|
return;
|
|
1230
|
-
const { drawings:
|
|
1252
|
+
const { drawings: a } = n, o = t.get(S), d = a.map((g) => this._injector.createInstance(I, o.getDrawingByParam(g)));
|
|
1231
1253
|
this.fireEvent(this.Event.OverGridImageChanged, {
|
|
1232
|
-
workbook:
|
|
1254
|
+
workbook: i,
|
|
1233
1255
|
images: d
|
|
1234
1256
|
});
|
|
1235
1257
|
})
|
|
1236
1258
|
), this.registerEventHandler(
|
|
1237
1259
|
this.Event.OverGridImageSelected,
|
|
1238
|
-
() =>
|
|
1239
|
-
if (e.id !==
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1260
|
+
() => r.onCommandExecuted((e) => {
|
|
1261
|
+
if (e.id !== j.id) return;
|
|
1262
|
+
const n = e.params, i = this.getActiveWorkbook();
|
|
1263
|
+
if (i == null)
|
|
1242
1264
|
return;
|
|
1243
|
-
const
|
|
1265
|
+
const a = t.get(S), o = n.map((d) => a.getDrawingByParam(d));
|
|
1244
1266
|
this.fireEvent(this.Event.OverGridImageSelected, {
|
|
1245
|
-
workbook:
|
|
1246
|
-
selectedImages: this._createFOverGridImage(
|
|
1267
|
+
workbook: i,
|
|
1268
|
+
selectedImages: this._createFOverGridImage(o)
|
|
1247
1269
|
});
|
|
1248
1270
|
})
|
|
1249
1271
|
);
|
|
1250
1272
|
}
|
|
1251
|
-
_createFOverGridImage(
|
|
1252
|
-
return
|
|
1273
|
+
_createFOverGridImage(t) {
|
|
1274
|
+
return t.map((r) => this._injector.createInstance(I, r));
|
|
1253
1275
|
}
|
|
1254
1276
|
}
|
|
1255
|
-
Y.extend(
|
|
1256
|
-
class
|
|
1257
|
-
async insertCellImageAsync(
|
|
1258
|
-
var
|
|
1259
|
-
const
|
|
1277
|
+
Y.extend(we);
|
|
1278
|
+
class Ie extends q {
|
|
1279
|
+
async insertCellImageAsync(t) {
|
|
1280
|
+
var i;
|
|
1281
|
+
const r = this._injector.get(C), e = (i = se(te.UNIVER_SHEET, this._injector.get(re), r)) == null ? void 0 : i.with(oe);
|
|
1260
1282
|
if (!e)
|
|
1261
1283
|
return !1;
|
|
1262
|
-
const
|
|
1284
|
+
const n = {
|
|
1263
1285
|
unitId: this._workbook.getUnitId(),
|
|
1264
1286
|
subUnitId: this._worksheet.getSheetId(),
|
|
1265
1287
|
row: this.getRow(),
|
|
1266
1288
|
col: this.getColumn()
|
|
1267
1289
|
};
|
|
1268
|
-
return typeof
|
|
1290
|
+
return typeof t == "string" ? e.insertCellImageByUrl(t, n) : e.insertCellImageByFile(t, n);
|
|
1291
|
+
}
|
|
1292
|
+
async saveCellImagesAsync(t) {
|
|
1293
|
+
var c;
|
|
1294
|
+
const r = this._injector.get(V), e = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), i = this.getRange(), a = r.getCellImagesFromRanges(e, n, [i]);
|
|
1295
|
+
if (a.length === 0)
|
|
1296
|
+
return !1;
|
|
1297
|
+
if (a.length === 1)
|
|
1298
|
+
try {
|
|
1299
|
+
return await r.downloadSingleImage(a[0]), !0;
|
|
1300
|
+
} catch (m) {
|
|
1301
|
+
return console.error("Failed to download image:", m), !1;
|
|
1302
|
+
}
|
|
1303
|
+
const o = [], d = (c = t == null ? void 0 : t.useCellAddress) != null ? c : !0, g = t == null ? void 0 : t.useColumnIndex;
|
|
1304
|
+
d && o.push(b.CELL_ADDRESS), g !== void 0 && o.push(b.COLUMN_VALUE), o.length === 0 && o.push(b.CELL_ADDRESS);
|
|
1305
|
+
try {
|
|
1306
|
+
return await r.saveImagesWithContext(a, {
|
|
1307
|
+
fileNameParts: o,
|
|
1308
|
+
columnIndex: g
|
|
1309
|
+
}, e, n), !0;
|
|
1310
|
+
} catch (m) {
|
|
1311
|
+
return console.error("Failed to save images:", m), !1;
|
|
1312
|
+
}
|
|
1269
1313
|
}
|
|
1270
1314
|
}
|
|
1271
|
-
|
|
1315
|
+
q.extend(Ie);
|