@univerjs/sheets-drawing-ui 0.5.5-nightly.202501210734 → 0.5.5-nightly.202501210925
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/es/facade.js +346 -330
- package/lib/es/index.js +2485 -2450
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/facade/f-over-grid-image.d.ts +6 -0
- package/lib/types/facade/f-univer.d.ts +6 -0
- package/package.json +12 -12
package/lib/es/facade.js
CHANGED
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Inject, Injector, ICommandService, generateRandomId, DrawingTypeEnum, ImageSourceType, FBase, ArrangeTypeEnum, toDisposable, FEnum, FEventName, FUniver } from "@univerjs/core";
|
|
6
|
+
import { getImageSize, SetDrawingSelectedOperation, IDrawingManagerService } from "@univerjs/drawing";
|
|
7
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
8
|
+
import { SetSheetDrawingCommand, SetDrawingArrangeCommand, SheetCanvasFloatDomManagerService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand } from "@univerjs/sheets-drawing-ui";
|
|
9
|
+
import { SheetSkeletonManagerService, ISheetSelectionRenderService, convertPositionSheetOverGridToAbsolute, convertPositionCellToSheetOverGrid } from "@univerjs/sheets-ui";
|
|
10
|
+
import { ISheetDrawingService, SheetDrawingAnchorType } from "@univerjs/sheets-drawing";
|
|
11
|
+
import { transformComponentKey } from "@univerjs/sheets-ui/facade";
|
|
12
|
+
import { FWorksheet } from "@univerjs/sheets/facade";
|
|
13
|
+
import { ComponentManager } from "@univerjs/ui";
|
|
14
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
15
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
17
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
18
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
19
|
+
function convertSheetImageToFOverGridImage(sheetImage, sheetSkeletonManagerService) {
|
|
20
|
+
const { from, to, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = sheetImage.sheetTransform, { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from, absolutePosition = convertPositionSheetOverGridToAbsolute(
|
|
21
|
+
sheetImage.unitId,
|
|
22
|
+
sheetImage.subUnitId,
|
|
23
|
+
{ from, to },
|
|
24
|
+
sheetSkeletonManagerService
|
|
25
|
+
), { left, top, width, height } = absolutePosition;
|
|
25
26
|
return {
|
|
26
|
-
...
|
|
27
|
-
column:
|
|
28
|
-
columnOffset:
|
|
29
|
-
row:
|
|
30
|
-
rowOffset:
|
|
31
|
-
width
|
|
32
|
-
height
|
|
33
|
-
flipY
|
|
34
|
-
flipX
|
|
35
|
-
angle
|
|
36
|
-
skewX
|
|
37
|
-
skewY
|
|
27
|
+
...sheetImage,
|
|
28
|
+
column: fromColumn,
|
|
29
|
+
columnOffset: fromColumnOffset,
|
|
30
|
+
row: fromRow,
|
|
31
|
+
rowOffset: fromRowOffset,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
flipY,
|
|
35
|
+
flipX,
|
|
36
|
+
angle,
|
|
37
|
+
skewX,
|
|
38
|
+
skewY
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
__name(convertSheetImageToFOverGridImage, "convertSheetImageToFOverGridImage");
|
|
42
|
+
function convertFOverGridImageToSheetImage(fOverGridImage, selectionRenderService, sheetSkeletonManagerService) {
|
|
43
|
+
const { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0, width, height } = fOverGridImage, absolutePosition = convertPositionCellToSheetOverGrid(
|
|
44
|
+
fOverGridImage.unitId,
|
|
45
|
+
fOverGridImage.subUnitId,
|
|
46
|
+
{ column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset },
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
selectionRenderService,
|
|
50
|
+
sheetSkeletonManagerService
|
|
51
|
+
), { sheetTransform, transform } = absolutePosition;
|
|
50
52
|
return {
|
|
51
|
-
...
|
|
53
|
+
...fOverGridImage,
|
|
52
54
|
sheetTransform: {
|
|
53
|
-
...
|
|
54
|
-
flipY
|
|
55
|
-
flipX
|
|
56
|
-
angle
|
|
57
|
-
skewX
|
|
58
|
-
skewY
|
|
55
|
+
...sheetTransform,
|
|
56
|
+
flipY,
|
|
57
|
+
flipX,
|
|
58
|
+
angle,
|
|
59
|
+
skewX,
|
|
60
|
+
skewY
|
|
59
61
|
},
|
|
60
62
|
transform: {
|
|
61
|
-
...
|
|
62
|
-
flipY
|
|
63
|
-
flipX
|
|
64
|
-
angle
|
|
65
|
-
skewX
|
|
66
|
-
skewY
|
|
63
|
+
...transform,
|
|
64
|
+
flipY,
|
|
65
|
+
flipX,
|
|
66
|
+
angle,
|
|
67
|
+
skewX,
|
|
68
|
+
skewY
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
__name(convertFOverGridImageToSheetImage, "convertFOverGridImageToSheetImage");
|
|
73
|
+
var _a;
|
|
74
|
+
let FOverGridImageBuilder = (_a = class {
|
|
75
|
+
constructor(unitId, subUnitId, _injector) {
|
|
76
|
+
__publicField(this, "_image");
|
|
77
|
+
this._injector = _injector, this._image = {
|
|
78
|
+
drawingId: generateRandomId(6),
|
|
79
|
+
drawingType: DrawingTypeEnum.DRAWING_IMAGE,
|
|
80
|
+
imageSourceType: ImageSourceType.BASE64,
|
|
77
81
|
source: "",
|
|
78
|
-
unitId
|
|
79
|
-
subUnitId
|
|
82
|
+
unitId,
|
|
83
|
+
subUnitId,
|
|
80
84
|
column: 0,
|
|
81
85
|
columnOffset: 0,
|
|
82
86
|
row: 0,
|
|
@@ -106,12 +110,12 @@ let b = class {
|
|
|
106
110
|
* activeSheet.insertImages([param]);
|
|
107
111
|
* ```
|
|
108
112
|
*/
|
|
109
|
-
setImage(
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
112
|
-
throw new Error(`Render Unit with unitId ${
|
|
113
|
-
const
|
|
114
|
-
return
|
|
113
|
+
setImage(image) {
|
|
114
|
+
const render = this._injector.get(IRenderManagerService).getRenderById(image.unitId);
|
|
115
|
+
if (!render)
|
|
116
|
+
throw new Error(`Render Unit with unitId ${image.unitId} not found`);
|
|
117
|
+
const skeletonManagerService = render.with(SheetSkeletonManagerService);
|
|
118
|
+
return image.sheetTransform == null && (image.sheetTransform = {
|
|
115
119
|
from: {
|
|
116
120
|
column: 0,
|
|
117
121
|
columnOffset: 0,
|
|
@@ -124,11 +128,11 @@ let b = class {
|
|
|
124
128
|
row: 0,
|
|
125
129
|
rowOffset: 0
|
|
126
130
|
}
|
|
127
|
-
}), this._image =
|
|
131
|
+
}), this._image = convertSheetImageToFOverGridImage(image, skeletonManagerService), this;
|
|
128
132
|
}
|
|
129
|
-
setSource(
|
|
130
|
-
const
|
|
131
|
-
return this._image.source =
|
|
133
|
+
setSource(source, sourceType) {
|
|
134
|
+
const sourceTypeVal = sourceType != null ? sourceType : ImageSourceType.URL;
|
|
135
|
+
return this._image.source = source, this._image.imageSourceType = sourceTypeVal, this;
|
|
132
136
|
}
|
|
133
137
|
getsource() {
|
|
134
138
|
return this._image.source;
|
|
@@ -150,8 +154,8 @@ let b = class {
|
|
|
150
154
|
* activeSheet.insertImages([param]);
|
|
151
155
|
* ```
|
|
152
156
|
*/
|
|
153
|
-
setColumn(
|
|
154
|
-
return this._image.column =
|
|
157
|
+
setColumn(column) {
|
|
158
|
+
return this._image.column = column, this;
|
|
155
159
|
}
|
|
156
160
|
/**
|
|
157
161
|
* Set the position of the image
|
|
@@ -167,8 +171,8 @@ let b = class {
|
|
|
167
171
|
* activeSheet.insertImages([param]);
|
|
168
172
|
* ```
|
|
169
173
|
*/
|
|
170
|
-
setRow(
|
|
171
|
-
return this._image.row =
|
|
174
|
+
setRow(row) {
|
|
175
|
+
return this._image.row = row, this;
|
|
172
176
|
}
|
|
173
177
|
/**
|
|
174
178
|
* Set the column offset of the image in a unit
|
|
@@ -184,8 +188,8 @@ let b = class {
|
|
|
184
188
|
* activeSheet.insertImages([param]);
|
|
185
189
|
* ```
|
|
186
190
|
*/
|
|
187
|
-
setColumnOffset(
|
|
188
|
-
return this._image.columnOffset =
|
|
191
|
+
setColumnOffset(offset) {
|
|
192
|
+
return this._image.columnOffset = offset, this;
|
|
189
193
|
}
|
|
190
194
|
/**
|
|
191
195
|
* Set the row offset of the image in a unit
|
|
@@ -201,8 +205,8 @@ let b = class {
|
|
|
201
205
|
* activeSheet.insertImages([param]);
|
|
202
206
|
* ```
|
|
203
207
|
*/
|
|
204
|
-
setRowOffset(
|
|
205
|
-
return this._image.rowOffset =
|
|
208
|
+
setRowOffset(offset) {
|
|
209
|
+
return this._image.rowOffset = offset, this;
|
|
206
210
|
}
|
|
207
211
|
/**
|
|
208
212
|
* set the width of the image
|
|
@@ -218,8 +222,8 @@ let b = class {
|
|
|
218
222
|
* activeSheet.insertImages([param]);
|
|
219
223
|
* ```
|
|
220
224
|
*/
|
|
221
|
-
setWidth(
|
|
222
|
-
return this._image.width =
|
|
225
|
+
setWidth(width) {
|
|
226
|
+
return this._image.width = width, this;
|
|
223
227
|
}
|
|
224
228
|
/**
|
|
225
229
|
* Set the height of the image
|
|
@@ -235,8 +239,8 @@ let b = class {
|
|
|
235
239
|
* activeSheet.insertImages([param]);
|
|
236
240
|
* ```
|
|
237
241
|
*/
|
|
238
|
-
setHeight(
|
|
239
|
-
return this._image.height =
|
|
242
|
+
setHeight(height) {
|
|
243
|
+
return this._image.height = height, this;
|
|
240
244
|
}
|
|
241
245
|
/**
|
|
242
246
|
* Set the anchor type of the image, whether the position and size change with the cell
|
|
@@ -252,8 +256,8 @@ let b = class {
|
|
|
252
256
|
* activeSheet.insertImages([param]);
|
|
253
257
|
* ```
|
|
254
258
|
*/
|
|
255
|
-
setAnchorType(
|
|
256
|
-
return this._image.anchorType =
|
|
259
|
+
setAnchorType(anchorType) {
|
|
260
|
+
return this._image.anchorType = anchorType, this;
|
|
257
261
|
}
|
|
258
262
|
/**
|
|
259
263
|
* Set the cropping region of the image by defining the top edges, thereby displaying the specific part of the image you want.
|
|
@@ -269,8 +273,8 @@ let b = class {
|
|
|
269
273
|
* activeSheet.insertImages([param]);
|
|
270
274
|
* ```
|
|
271
275
|
*/
|
|
272
|
-
setCropTop(
|
|
273
|
-
return this._initializeSrcRect(), this._image.srcRect.top =
|
|
276
|
+
setCropTop(top) {
|
|
277
|
+
return this._initializeSrcRect(), this._image.srcRect.top = top, this;
|
|
274
278
|
}
|
|
275
279
|
/**
|
|
276
280
|
* Set the cropping region of the image by defining the left edges, thereby displaying the specific part of the image you want.
|
|
@@ -286,8 +290,8 @@ let b = class {
|
|
|
286
290
|
* activeSheet.insertImages([param]);
|
|
287
291
|
* ```
|
|
288
292
|
*/
|
|
289
|
-
setCropLeft(
|
|
290
|
-
return this._initializeSrcRect(), this._image.srcRect.left =
|
|
293
|
+
setCropLeft(left) {
|
|
294
|
+
return this._initializeSrcRect(), this._image.srcRect.left = left, this;
|
|
291
295
|
}
|
|
292
296
|
/**
|
|
293
297
|
* Set the cropping region of the image by defining the bottom edges, thereby displaying the specific part of the image you want.
|
|
@@ -303,8 +307,8 @@ let b = class {
|
|
|
303
307
|
* activeSheet.insertImages([param]);
|
|
304
308
|
* ```
|
|
305
309
|
*/
|
|
306
|
-
setCropBottom(
|
|
307
|
-
return this._initializeSrcRect(), this._image.srcRect.bottom =
|
|
310
|
+
setCropBottom(bottom) {
|
|
311
|
+
return this._initializeSrcRect(), this._image.srcRect.bottom = bottom, this;
|
|
308
312
|
}
|
|
309
313
|
/**
|
|
310
314
|
* Set the cropping region of the image by defining the right edges, thereby displaying the specific part of the image you want.
|
|
@@ -320,8 +324,8 @@ let b = class {
|
|
|
320
324
|
* activeSheet.insertImages([param]);
|
|
321
325
|
* ```
|
|
322
326
|
*/
|
|
323
|
-
setCropRight(
|
|
324
|
-
return this._initializeSrcRect(), this._image.srcRect.right =
|
|
327
|
+
setCropRight(right) {
|
|
328
|
+
return this._initializeSrcRect(), this._image.srcRect.right = right, this;
|
|
325
329
|
}
|
|
326
330
|
_initializeSrcRect() {
|
|
327
331
|
this._image.srcRect == null && (this._image.srcRect = {
|
|
@@ -345,37 +349,38 @@ let b = class {
|
|
|
345
349
|
* activeSheet.insertImages([param]);
|
|
346
350
|
* ```
|
|
347
351
|
*/
|
|
348
|
-
setRotate(
|
|
349
|
-
return this._image.angle =
|
|
352
|
+
setRotate(angle) {
|
|
353
|
+
return this._image.angle = angle, this;
|
|
350
354
|
}
|
|
351
355
|
// setPresetGeometry(prstGeom: PresetGeometryType): FOverGridImageBuilder {
|
|
352
356
|
// this._image.prstGeom = prstGeom;
|
|
353
357
|
// return this;
|
|
354
358
|
// }
|
|
355
|
-
setUnitId(
|
|
356
|
-
return this._image.unitId =
|
|
359
|
+
setUnitId(unitId) {
|
|
360
|
+
return this._image.unitId = unitId, this;
|
|
357
361
|
}
|
|
358
|
-
setSubUnitId(
|
|
359
|
-
return this._image.subUnitId =
|
|
362
|
+
setSubUnitId(subUnitId) {
|
|
363
|
+
return this._image.subUnitId = subUnitId, this;
|
|
360
364
|
}
|
|
361
365
|
async buildAsync() {
|
|
362
|
-
const
|
|
363
|
-
if (!
|
|
366
|
+
const render = this._injector.get(IRenderManagerService).getRenderById(this._image.unitId);
|
|
367
|
+
if (!render)
|
|
364
368
|
throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
|
|
365
|
-
const
|
|
369
|
+
const selectionRenderService = render.with(ISheetSelectionRenderService), skeletonManagerService = render.with(SheetSkeletonManagerService);
|
|
366
370
|
if (this._image.width === 0 || this._image.height === 0) {
|
|
367
|
-
const
|
|
368
|
-
this._image.width === 0 && (this._image.width =
|
|
371
|
+
const size = await getImageSize(this._image.source), width = size.width, height = size.height;
|
|
372
|
+
this._image.width === 0 && (this._image.width = width), this._image.height === 0 && (this._image.height = height);
|
|
369
373
|
}
|
|
370
|
-
return
|
|
374
|
+
return convertFOverGridImageToSheetImage(this._image, selectionRenderService, skeletonManagerService);
|
|
371
375
|
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
],
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
}, __name(_a, "FOverGridImageBuilder"), _a);
|
|
377
|
+
FOverGridImageBuilder = __decorateClass([
|
|
378
|
+
__decorateParam(2, Inject(Injector))
|
|
379
|
+
], FOverGridImageBuilder);
|
|
380
|
+
var _a2;
|
|
381
|
+
let FOverGridImage = (_a2 = class extends FBase {
|
|
382
|
+
constructor(_image, _commandService, _injector) {
|
|
383
|
+
super(), this._image = _image, this._commandService = _commandService, this._injector = _injector;
|
|
379
384
|
}
|
|
380
385
|
getId() {
|
|
381
386
|
return this._image.drawingId;
|
|
@@ -396,7 +401,7 @@ let g = class extends V {
|
|
|
396
401
|
* ```
|
|
397
402
|
*/
|
|
398
403
|
remove() {
|
|
399
|
-
return this._commandService.syncExecuteCommand(
|
|
404
|
+
return this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
400
405
|
}
|
|
401
406
|
/**
|
|
402
407
|
* Convert the image to a FOverGridImageBuilder
|
|
@@ -413,18 +418,18 @@ let g = class extends V {
|
|
|
413
418
|
* ```
|
|
414
419
|
*/
|
|
415
420
|
toBuilder() {
|
|
416
|
-
const
|
|
417
|
-
return
|
|
421
|
+
const builder = this._injector.createInstance(FOverGridImageBuilder);
|
|
422
|
+
return builder.setImage(this._image), builder;
|
|
418
423
|
}
|
|
419
|
-
setSource(
|
|
420
|
-
const
|
|
421
|
-
return this._image.source =
|
|
424
|
+
setSource(source, sourceType) {
|
|
425
|
+
const sourceTypeVal = sourceType != null ? sourceType : ImageSourceType.URL;
|
|
426
|
+
return this._image.source = source, this._image.imageSourceType = sourceTypeVal, this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
422
427
|
}
|
|
423
|
-
async setPositionAsync(
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
const
|
|
427
|
-
return this._commandService.syncExecuteCommand(
|
|
428
|
+
async setPositionAsync(row, column, rowOffset, columnOffset) {
|
|
429
|
+
const builder = this.toBuilder();
|
|
430
|
+
builder.setColumn(column), builder.setRow(row), rowOffset != null && builder.setRowOffset(rowOffset), columnOffset != null && builder.setColumnOffset(columnOffset);
|
|
431
|
+
const param = await builder.buildAsync();
|
|
432
|
+
return this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [param] });
|
|
428
433
|
}
|
|
429
434
|
/**
|
|
430
435
|
* Set the size of the image
|
|
@@ -439,11 +444,11 @@ let g = class extends V {
|
|
|
439
444
|
* const image = activeSheet.getImages()[0];
|
|
440
445
|
* console.log('Set size state is ', image.setSize(50, 120));
|
|
441
446
|
*/
|
|
442
|
-
async setSizeAsync(
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
return this._commandService.syncExecuteCommand(
|
|
447
|
+
async setSizeAsync(width, height) {
|
|
448
|
+
const builder = this.toBuilder();
|
|
449
|
+
builder.setWidth(width), builder.setHeight(height);
|
|
450
|
+
const param = await builder.buildAsync();
|
|
451
|
+
return this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [param] });
|
|
447
452
|
}
|
|
448
453
|
/**
|
|
449
454
|
* Set the cropping region of the image by defining the top, bottom, left, and right edges, thereby displaying the specific part of the image you want.
|
|
@@ -461,13 +466,13 @@ let g = class extends V {
|
|
|
461
466
|
* console.log('Set crop state is ', image.setCrop(10, 10, 10, 10));
|
|
462
467
|
* ```
|
|
463
468
|
*/
|
|
464
|
-
setCrop(
|
|
469
|
+
setCrop(top, left, bottom, right) {
|
|
465
470
|
return this._image.srcRect == null && (this._image.srcRect = {
|
|
466
471
|
top: 0,
|
|
467
472
|
left: 0,
|
|
468
473
|
bottom: 0,
|
|
469
474
|
right: 0
|
|
470
|
-
}),
|
|
475
|
+
}), top != null && (this._image.srcRect.top = top), left != null && (this._image.srcRect.left = left), bottom != null && (this._image.srcRect.bottom = bottom), right != null && (this._image.srcRect.right = right), this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
471
476
|
}
|
|
472
477
|
// setPresetGeometry(prstGeom: PresetGeometryType): boolean {
|
|
473
478
|
// this._image.prstGeom = prstGeom;
|
|
@@ -486,8 +491,8 @@ let g = class extends V {
|
|
|
486
491
|
* console.log('Set rotate state is ', image.setRotate(90));
|
|
487
492
|
* ```
|
|
488
493
|
*/
|
|
489
|
-
setRotate(
|
|
490
|
-
return this._image.sheetTransform.angle =
|
|
494
|
+
setRotate(angle) {
|
|
495
|
+
return this._image.sheetTransform.angle = angle, this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
491
496
|
}
|
|
492
497
|
/**
|
|
493
498
|
* Move the image layer forward by one level
|
|
@@ -502,11 +507,11 @@ let g = class extends V {
|
|
|
502
507
|
* ```
|
|
503
508
|
*/
|
|
504
509
|
setForward() {
|
|
505
|
-
return this._commandService.syncExecuteCommand(
|
|
510
|
+
return this._commandService.syncExecuteCommand(SetDrawingArrangeCommand.id, {
|
|
506
511
|
unitId: this._image.unitId,
|
|
507
512
|
subUnitId: this._image.subUnitId,
|
|
508
513
|
drawingIds: [this._image.drawingId],
|
|
509
|
-
arrangeType:
|
|
514
|
+
arrangeType: ArrangeTypeEnum.forward
|
|
510
515
|
});
|
|
511
516
|
}
|
|
512
517
|
/**
|
|
@@ -522,11 +527,11 @@ let g = class extends V {
|
|
|
522
527
|
* ```
|
|
523
528
|
*/
|
|
524
529
|
setBackward() {
|
|
525
|
-
return this._commandService.syncExecuteCommand(
|
|
530
|
+
return this._commandService.syncExecuteCommand(SetDrawingArrangeCommand.id, {
|
|
526
531
|
unitId: this._image.unitId,
|
|
527
532
|
subUnitId: this._image.subUnitId,
|
|
528
533
|
drawingIds: [this._image.drawingId],
|
|
529
|
-
arrangeType:
|
|
534
|
+
arrangeType: ArrangeTypeEnum.backward
|
|
530
535
|
});
|
|
531
536
|
}
|
|
532
537
|
/**
|
|
@@ -542,11 +547,11 @@ let g = class extends V {
|
|
|
542
547
|
* ```
|
|
543
548
|
*/
|
|
544
549
|
setBack() {
|
|
545
|
-
return this._commandService.syncExecuteCommand(
|
|
550
|
+
return this._commandService.syncExecuteCommand(SetDrawingArrangeCommand.id, {
|
|
546
551
|
unitId: this._image.unitId,
|
|
547
552
|
subUnitId: this._image.subUnitId,
|
|
548
553
|
drawingIds: [this._image.drawingId],
|
|
549
|
-
arrangeType:
|
|
554
|
+
arrangeType: ArrangeTypeEnum.back
|
|
550
555
|
});
|
|
551
556
|
}
|
|
552
557
|
/**
|
|
@@ -562,140 +567,144 @@ let g = class extends V {
|
|
|
562
567
|
* ```
|
|
563
568
|
*/
|
|
564
569
|
setFront() {
|
|
565
|
-
return this._commandService.syncExecuteCommand(
|
|
570
|
+
return this._commandService.syncExecuteCommand(SetDrawingArrangeCommand.id, {
|
|
566
571
|
unitId: this._image.unitId,
|
|
567
572
|
subUnitId: this._image.subUnitId,
|
|
568
573
|
drawingIds: [this._image.drawingId],
|
|
569
|
-
arrangeType:
|
|
574
|
+
arrangeType: ArrangeTypeEnum.front
|
|
570
575
|
});
|
|
571
576
|
}
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
],
|
|
577
|
-
class
|
|
578
|
-
addFloatDomToPosition(
|
|
579
|
-
const
|
|
580
|
-
return
|
|
581
|
-
id:
|
|
582
|
-
dispose: () => {
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
}) : (
|
|
586
|
-
}
|
|
587
|
-
addFloatDomToRange(
|
|
588
|
-
const
|
|
589
|
-
return
|
|
590
|
-
id:
|
|
591
|
-
dispose: () => {
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
}) : (
|
|
595
|
-
}
|
|
596
|
-
addFloatDomToColumnHeader(
|
|
597
|
-
const
|
|
598
|
-
return
|
|
599
|
-
id:
|
|
600
|
-
dispose: () => {
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
}) : (
|
|
604
|
-
}
|
|
605
|
-
async insertImage(
|
|
606
|
-
const
|
|
607
|
-
if (typeof
|
|
608
|
-
|
|
577
|
+
}, __name(_a2, "FOverGridImage"), _a2);
|
|
578
|
+
FOverGridImage = __decorateClass([
|
|
579
|
+
__decorateParam(1, ICommandService),
|
|
580
|
+
__decorateParam(2, Inject(Injector))
|
|
581
|
+
], FOverGridImage);
|
|
582
|
+
const _FWorksheetLegacy = class _FWorksheetLegacy extends FWorksheet {
|
|
583
|
+
addFloatDomToPosition(layer, id) {
|
|
584
|
+
const unitId = this._workbook.getUnitId(), subUnitId = this._worksheet.getSheetId(), { key, disposableCollection } = transformComponentKey(layer, this._injector.get(ComponentManager)), res = this._injector.get(SheetCanvasFloatDomManagerService).addFloatDomToPosition({ ...layer, componentKey: key, unitId, subUnitId }, id);
|
|
585
|
+
return res ? (disposableCollection.add(res.dispose), {
|
|
586
|
+
id: res.id,
|
|
587
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
588
|
+
disposableCollection.dispose(), res.dispose();
|
|
589
|
+
}, "dispose")
|
|
590
|
+
}) : (disposableCollection.dispose(), null);
|
|
591
|
+
}
|
|
592
|
+
addFloatDomToRange(fRange, layer, domLayout, id) {
|
|
593
|
+
const unitId = this._workbook.getUnitId(), subUnitId = this._worksheet.getSheetId(), { key, disposableCollection } = transformComponentKey(layer, this._injector.get(ComponentManager)), res = this._injector.get(SheetCanvasFloatDomManagerService).addFloatDomToRange(fRange.getRange(), { ...layer, componentKey: key, unitId, subUnitId }, domLayout, id);
|
|
594
|
+
return res ? (disposableCollection.add(res.dispose), {
|
|
595
|
+
id: res.id,
|
|
596
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
597
|
+
disposableCollection.dispose(), res.dispose();
|
|
598
|
+
}, "dispose")
|
|
599
|
+
}) : (disposableCollection.dispose(), null);
|
|
600
|
+
}
|
|
601
|
+
addFloatDomToColumnHeader(column, layer, domLayout, id) {
|
|
602
|
+
const unitId = this._workbook.getUnitId(), subUnitId = this._worksheet.getSheetId(), { key, disposableCollection } = transformComponentKey(layer, this._injector.get(ComponentManager)), domRangeDispose = this._injector.get(SheetCanvasFloatDomManagerService).addFloatDomToColumnHeader(column, { ...layer, componentKey: key, unitId, subUnitId }, domLayout, id);
|
|
603
|
+
return domRangeDispose ? (disposableCollection.add(domRangeDispose.dispose), {
|
|
604
|
+
id: domRangeDispose.id,
|
|
605
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
606
|
+
disposableCollection.dispose(), domRangeDispose.dispose();
|
|
607
|
+
}, "dispose")
|
|
608
|
+
}) : (disposableCollection.dispose(), null);
|
|
609
|
+
}
|
|
610
|
+
async insertImage(url, column, row, offsetX, offsetY) {
|
|
611
|
+
const imageBuilder = this.newOverGridImage();
|
|
612
|
+
if (typeof url == "string")
|
|
613
|
+
imageBuilder.setSource(url);
|
|
609
614
|
else {
|
|
610
|
-
const
|
|
611
|
-
|
|
615
|
+
const base64 = await url.getBlob().getDataAsString();
|
|
616
|
+
imageBuilder.setSource(base64, ImageSourceType.BASE64);
|
|
612
617
|
}
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
return this._commandService.syncExecuteCommand(
|
|
618
|
+
column !== void 0 ? imageBuilder.setColumn(column) : imageBuilder.setColumn(0), row !== void 0 ? imageBuilder.setRow(row) : imageBuilder.setRow(0), offsetX !== void 0 ? imageBuilder.setColumnOffset(offsetX) : imageBuilder.setColumnOffset(0), offsetY !== void 0 ? imageBuilder.setRowOffset(offsetY) : imageBuilder.setRowOffset(0);
|
|
619
|
+
const param = await imageBuilder.buildAsync();
|
|
620
|
+
return this._commandService.syncExecuteCommand(InsertSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: [param] });
|
|
616
621
|
}
|
|
617
|
-
insertImages(
|
|
618
|
-
const
|
|
619
|
-
return this._commandService.syncExecuteCommand(
|
|
622
|
+
insertImages(sheetImages) {
|
|
623
|
+
const param = sheetImages.map((image) => (image.unitId = this._fWorkbook.getId(), image.subUnitId = this.getSheetId(), image));
|
|
624
|
+
return this._commandService.syncExecuteCommand(InsertSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: param }), this;
|
|
620
625
|
}
|
|
621
|
-
deleteImages(
|
|
622
|
-
const
|
|
626
|
+
deleteImages(sheetImages) {
|
|
627
|
+
const drawings = sheetImages.map((image) => ({
|
|
623
628
|
unitId: this._fWorkbook.getId(),
|
|
624
|
-
drawingId:
|
|
629
|
+
drawingId: image.getId(),
|
|
625
630
|
subUnitId: this.getSheetId(),
|
|
626
|
-
drawingType:
|
|
631
|
+
drawingType: image.getType()
|
|
627
632
|
}));
|
|
628
|
-
return this._commandService.syncExecuteCommand(
|
|
633
|
+
return this._commandService.syncExecuteCommand(RemoveSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings }), this;
|
|
629
634
|
}
|
|
630
635
|
getImages() {
|
|
631
|
-
const
|
|
632
|
-
for (const
|
|
633
|
-
const
|
|
634
|
-
|
|
636
|
+
const drawingData = this._injector.get(ISheetDrawingService).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), images = [];
|
|
637
|
+
for (const drawingId in drawingData) {
|
|
638
|
+
const drawing = drawingData[drawingId];
|
|
639
|
+
drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE && images.push(this._injector.createInstance(FOverGridImage, drawing));
|
|
635
640
|
}
|
|
636
|
-
return
|
|
641
|
+
return images;
|
|
637
642
|
}
|
|
638
|
-
getImageById(
|
|
639
|
-
const
|
|
640
|
-
return
|
|
643
|
+
getImageById(id) {
|
|
644
|
+
const drawing = this._injector.get(ISheetDrawingService).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: id });
|
|
645
|
+
return drawing && drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE ? this._injector.createInstance(FOverGridImage, drawing) : null;
|
|
641
646
|
}
|
|
642
647
|
getActiveImages() {
|
|
643
|
-
const
|
|
644
|
-
for (const
|
|
645
|
-
const
|
|
646
|
-
|
|
648
|
+
const drawingData = this._injector.get(ISheetDrawingService).getFocusDrawings(), images = [];
|
|
649
|
+
for (const drawingId in drawingData) {
|
|
650
|
+
const drawing = drawingData[drawingId];
|
|
651
|
+
images.push(this._injector.createInstance(FOverGridImage, drawing));
|
|
647
652
|
}
|
|
648
|
-
return
|
|
653
|
+
return images;
|
|
649
654
|
}
|
|
650
|
-
updateImages(
|
|
651
|
-
return this._commandService.syncExecuteCommand(
|
|
655
|
+
updateImages(sheetImages) {
|
|
656
|
+
return this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: sheetImages }), this;
|
|
652
657
|
}
|
|
653
|
-
onImageInserted(
|
|
654
|
-
const
|
|
655
|
-
return
|
|
656
|
-
const
|
|
657
|
-
(
|
|
658
|
+
onImageInserted(callback) {
|
|
659
|
+
const sheetDrawingService = this._injector.get(ISheetDrawingService);
|
|
660
|
+
return toDisposable(sheetDrawingService.add$.subscribe((drawingSearches) => {
|
|
661
|
+
const drawings = drawingSearches.map(
|
|
662
|
+
(drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch))
|
|
658
663
|
);
|
|
659
|
-
|
|
664
|
+
callback(drawings);
|
|
660
665
|
}));
|
|
661
666
|
}
|
|
662
|
-
onImageDeleted(
|
|
663
|
-
const
|
|
664
|
-
return
|
|
665
|
-
const
|
|
666
|
-
(
|
|
667
|
+
onImageDeleted(callback) {
|
|
668
|
+
const sheetDrawingService = this._injector.get(ISheetDrawingService);
|
|
669
|
+
return toDisposable(sheetDrawingService.remove$.subscribe((drawingSearches) => {
|
|
670
|
+
const drawings = drawingSearches.map(
|
|
671
|
+
(drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch))
|
|
667
672
|
);
|
|
668
|
-
|
|
673
|
+
callback(drawings);
|
|
669
674
|
}));
|
|
670
675
|
}
|
|
671
|
-
onImageChanged(
|
|
672
|
-
const
|
|
673
|
-
return
|
|
674
|
-
const
|
|
675
|
-
(
|
|
676
|
+
onImageChanged(callback) {
|
|
677
|
+
const sheetDrawingService = this._injector.get(ISheetDrawingService);
|
|
678
|
+
return toDisposable(sheetDrawingService.update$.subscribe((drawingSearches) => {
|
|
679
|
+
const drawings = drawingSearches.map(
|
|
680
|
+
(drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch))
|
|
676
681
|
);
|
|
677
|
-
|
|
682
|
+
callback(drawings);
|
|
678
683
|
}));
|
|
679
684
|
}
|
|
680
685
|
newOverGridImage() {
|
|
681
|
-
const
|
|
682
|
-
return this._injector.createInstance(
|
|
686
|
+
const unitId = this._fWorkbook.getId(), subUnitId = this.getSheetId();
|
|
687
|
+
return this._injector.createInstance(FOverGridImageBuilder, unitId, subUnitId);
|
|
683
688
|
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
689
|
+
};
|
|
690
|
+
__name(_FWorksheetLegacy, "FWorksheetLegacy");
|
|
691
|
+
let FWorksheetLegacy = _FWorksheetLegacy;
|
|
692
|
+
FWorksheet.extend(FWorksheetLegacy);
|
|
693
|
+
const _FDrawingEnumMixin = class _FDrawingEnumMixin extends FEnum {
|
|
687
694
|
get DrawingType() {
|
|
688
|
-
return
|
|
695
|
+
return DrawingTypeEnum;
|
|
689
696
|
}
|
|
690
697
|
get ImageSourceType() {
|
|
691
|
-
return
|
|
698
|
+
return ImageSourceType;
|
|
692
699
|
}
|
|
693
700
|
get SheetDrawingAnchorType() {
|
|
694
|
-
return
|
|
701
|
+
return SheetDrawingAnchorType;
|
|
695
702
|
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
|
|
703
|
+
};
|
|
704
|
+
__name(_FDrawingEnumMixin, "FDrawingEnumMixin");
|
|
705
|
+
let FDrawingEnumMixin = _FDrawingEnumMixin;
|
|
706
|
+
FEnum.extend(FDrawingEnumMixin);
|
|
707
|
+
const _FDrawingEventNameMixin = class _FDrawingEventNameMixin extends FEventName {
|
|
699
708
|
get BeforeOverGridImageChange() {
|
|
700
709
|
return "BeforeOverGridImageChange";
|
|
701
710
|
}
|
|
@@ -720,154 +729,161 @@ class ae extends z {
|
|
|
720
729
|
get OverGridImageSelected() {
|
|
721
730
|
return "OverGridImageSelected";
|
|
722
731
|
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
+
};
|
|
733
|
+
__name(_FDrawingEventNameMixin, "FDrawingEventNameMixin");
|
|
734
|
+
let FDrawingEventNameMixin = _FDrawingEventNameMixin;
|
|
735
|
+
FEventName.extend(FDrawingEventNameMixin);
|
|
736
|
+
const _FUniverDrawingMixin = class _FUniverDrawingMixin extends FUniver {
|
|
737
|
+
/**
|
|
738
|
+
* @ignore
|
|
739
|
+
*/
|
|
740
|
+
_initialize(injector) {
|
|
741
|
+
const commandService = injector.get(ICommandService);
|
|
742
|
+
this.disposeWithMe(commandService.beforeCommandExecuted((commandInfo) => {
|
|
743
|
+
switch (commandInfo.id) {
|
|
744
|
+
case InsertSheetDrawingCommand.id:
|
|
745
|
+
this._beforeOverGridImageInsert(commandInfo.params);
|
|
732
746
|
break;
|
|
733
|
-
case
|
|
734
|
-
this._beforeOverGridImageRemove(
|
|
747
|
+
case RemoveSheetDrawingCommand.id:
|
|
748
|
+
this._beforeOverGridImageRemove(commandInfo.params);
|
|
735
749
|
break;
|
|
736
|
-
case
|
|
737
|
-
this._beforeOverGridImageChange(
|
|
750
|
+
case SetSheetDrawingCommand.id:
|
|
751
|
+
this._beforeOverGridImageChange(commandInfo.params);
|
|
738
752
|
break;
|
|
739
|
-
case
|
|
740
|
-
this._beforeOverGridImageSelect(
|
|
753
|
+
case SetDrawingSelectedOperation.id:
|
|
754
|
+
this._beforeOverGridImageSelect(commandInfo.params);
|
|
741
755
|
break;
|
|
742
756
|
}
|
|
743
|
-
})), this.disposeWithMe(
|
|
744
|
-
switch (
|
|
745
|
-
case
|
|
746
|
-
this._overGridImageInserted(
|
|
757
|
+
})), this.disposeWithMe(commandService.onCommandExecuted((commandInfo) => {
|
|
758
|
+
switch (commandInfo.id) {
|
|
759
|
+
case InsertSheetDrawingCommand.id:
|
|
760
|
+
this._overGridImageInserted(commandInfo.params);
|
|
747
761
|
break;
|
|
748
|
-
case
|
|
749
|
-
this._overGridImageRemoved(
|
|
762
|
+
case RemoveSheetDrawingCommand.id:
|
|
763
|
+
this._overGridImageRemoved(commandInfo.params);
|
|
750
764
|
break;
|
|
751
|
-
case
|
|
752
|
-
this._overGridImageChanged(
|
|
765
|
+
case SetSheetDrawingCommand.id:
|
|
766
|
+
this._overGridImageChanged(commandInfo.params);
|
|
753
767
|
break;
|
|
754
|
-
case
|
|
755
|
-
this._overGridImageSelected(
|
|
768
|
+
case SetDrawingSelectedOperation.id:
|
|
769
|
+
this._overGridImageSelected(commandInfo.params);
|
|
756
770
|
break;
|
|
757
771
|
}
|
|
758
772
|
}));
|
|
759
773
|
}
|
|
760
|
-
_beforeOverGridImageInsert(
|
|
774
|
+
_beforeOverGridImageInsert(params) {
|
|
761
775
|
if (!this.hasEventCallback(this.Event.BeforeOverGridImageInsert))
|
|
762
776
|
return;
|
|
763
|
-
const
|
|
764
|
-
if (
|
|
777
|
+
const workbook = this.getActiveWorkbook();
|
|
778
|
+
if (workbook == null || params == null)
|
|
765
779
|
return;
|
|
766
|
-
const { drawings
|
|
767
|
-
workbook
|
|
768
|
-
insertImageParams:
|
|
780
|
+
const { drawings } = params, eventParams = {
|
|
781
|
+
workbook,
|
|
782
|
+
insertImageParams: drawings
|
|
769
783
|
};
|
|
770
|
-
if (this.fireEvent(this.Event.BeforeOverGridImageInsert,
|
|
784
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageInsert, eventParams), eventParams.cancel)
|
|
771
785
|
throw new Error("Canceled by BeforeOverGridImageInsert event");
|
|
772
786
|
}
|
|
773
|
-
_overGridImageInserted(
|
|
787
|
+
_overGridImageInserted(params) {
|
|
774
788
|
if (!this.hasEventCallback(this.Event.OverGridImageInserted))
|
|
775
789
|
return;
|
|
776
|
-
const
|
|
777
|
-
if (
|
|
790
|
+
const workbook = this.getActiveWorkbook();
|
|
791
|
+
if (workbook == null || params == null)
|
|
778
792
|
return;
|
|
779
|
-
const { drawings
|
|
793
|
+
const { drawings } = params;
|
|
780
794
|
this.fireEvent(this.Event.OverGridImageInserted, {
|
|
781
|
-
workbook
|
|
782
|
-
images: this._createFOverGridImage(
|
|
795
|
+
workbook,
|
|
796
|
+
images: this._createFOverGridImage(drawings)
|
|
783
797
|
});
|
|
784
798
|
}
|
|
785
|
-
_beforeOverGridImageRemove(
|
|
799
|
+
_beforeOverGridImageRemove(params) {
|
|
786
800
|
if (!this.hasEventCallback(this.Event.BeforeOverGridImageRemove))
|
|
787
801
|
return;
|
|
788
|
-
const
|
|
789
|
-
if (
|
|
802
|
+
const workbook = this.getActiveWorkbook();
|
|
803
|
+
if (workbook == null || params == null)
|
|
790
804
|
return;
|
|
791
|
-
const { drawings
|
|
792
|
-
workbook
|
|
793
|
-
images: this._createFOverGridImage(
|
|
805
|
+
const { drawings } = params, drawingManagerService = this._injector.get(IDrawingManagerService), willRemoveDrawings = drawings.map((drawing) => drawingManagerService.getDrawingByParam(drawing)), eventParams = {
|
|
806
|
+
workbook,
|
|
807
|
+
images: this._createFOverGridImage(willRemoveDrawings)
|
|
794
808
|
};
|
|
795
|
-
if (this.fireEvent(this.Event.BeforeOverGridImageRemove,
|
|
809
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageRemove, eventParams), eventParams.cancel)
|
|
796
810
|
throw new Error("Canceled by BeforeOverGridImageRemove event");
|
|
797
811
|
}
|
|
798
|
-
_overGridImageRemoved(
|
|
812
|
+
_overGridImageRemoved(params) {
|
|
799
813
|
if (!this.hasEventCallback(this.Event.OverGridImageRemoved))
|
|
800
814
|
return;
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
815
|
+
const workbook = this.getActiveWorkbook();
|
|
816
|
+
if (workbook == null || params == null)
|
|
803
817
|
return;
|
|
804
|
-
const { drawings
|
|
818
|
+
const { drawings } = params;
|
|
805
819
|
this.fireEvent(this.Event.OverGridImageRemoved, {
|
|
806
|
-
workbook
|
|
807
|
-
removeImageParams:
|
|
820
|
+
workbook,
|
|
821
|
+
removeImageParams: drawings
|
|
808
822
|
});
|
|
809
823
|
}
|
|
810
|
-
_beforeOverGridImageChange(
|
|
824
|
+
_beforeOverGridImageChange(params) {
|
|
811
825
|
if (!this.hasEventCallback(this.Event.BeforeOverGridImageChange))
|
|
812
826
|
return;
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
827
|
+
const workbook = this.getActiveWorkbook();
|
|
828
|
+
if (workbook == null || params == null)
|
|
815
829
|
return;
|
|
816
|
-
const { drawings
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
changeParam:
|
|
821
|
-
image: this._injector.createInstance(
|
|
830
|
+
const { drawings } = params, drawingManagerService = this._injector.get(IDrawingManagerService), images = [];
|
|
831
|
+
drawings.forEach((drawing) => {
|
|
832
|
+
const image = drawingManagerService.getDrawingByParam(drawing);
|
|
833
|
+
image != null && images.push({
|
|
834
|
+
changeParam: drawing,
|
|
835
|
+
image: this._injector.createInstance(FOverGridImage, image)
|
|
822
836
|
});
|
|
823
837
|
});
|
|
824
|
-
const
|
|
825
|
-
workbook
|
|
826
|
-
images
|
|
838
|
+
const eventParams = {
|
|
839
|
+
workbook,
|
|
840
|
+
images
|
|
827
841
|
};
|
|
828
|
-
if (this.fireEvent(this.Event.BeforeOverGridImageChange,
|
|
829
|
-
throw
|
|
842
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageChange, eventParams), eventParams.cancel)
|
|
843
|
+
throw drawingManagerService.updateNotification(drawings), new Error("Canceled by BeforeOverGridImageChange event");
|
|
830
844
|
}
|
|
831
|
-
_overGridImageChanged(
|
|
845
|
+
_overGridImageChanged(params) {
|
|
832
846
|
if (!this.hasEventCallback(this.Event.OverGridImageChanged))
|
|
833
847
|
return;
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
848
|
+
const workbook = this.getActiveWorkbook();
|
|
849
|
+
if (workbook == null || params == null)
|
|
836
850
|
return;
|
|
837
|
-
const { drawings
|
|
851
|
+
const { drawings } = params, drawingManagerService = this._injector.get(IDrawingManagerService), images = drawings.map((drawing) => this._injector.createInstance(FOverGridImage, drawingManagerService.getDrawingByParam(drawing)));
|
|
838
852
|
this.fireEvent(this.Event.OverGridImageChanged, {
|
|
839
|
-
workbook
|
|
840
|
-
images
|
|
853
|
+
workbook,
|
|
854
|
+
images
|
|
841
855
|
});
|
|
842
856
|
}
|
|
843
|
-
_beforeOverGridImageSelect(
|
|
857
|
+
_beforeOverGridImageSelect(drawings) {
|
|
844
858
|
if (!this.hasEventCallback(this.Event.BeforeOverGridImageSelect))
|
|
845
859
|
return;
|
|
846
|
-
const
|
|
847
|
-
if (
|
|
860
|
+
const drawingManagerService = this._injector.get(IDrawingManagerService), workbook = this.getActiveWorkbook();
|
|
861
|
+
if (workbook == null)
|
|
848
862
|
return;
|
|
849
|
-
const
|
|
850
|
-
workbook
|
|
851
|
-
selectedImages: this._createFOverGridImage(
|
|
852
|
-
oldSelectedImages: this._createFOverGridImage(
|
|
863
|
+
const oldSelectedDrawings = drawingManagerService.getFocusDrawings(), selectedDrawings = drawings.map((drawing) => drawingManagerService.getDrawingByParam(drawing)), eventParams = {
|
|
864
|
+
workbook,
|
|
865
|
+
selectedImages: this._createFOverGridImage(selectedDrawings),
|
|
866
|
+
oldSelectedImages: this._createFOverGridImage(oldSelectedDrawings)
|
|
853
867
|
};
|
|
854
|
-
if (this.fireEvent(this.Event.BeforeOverGridImageSelect,
|
|
868
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageSelect, eventParams), eventParams.cancel)
|
|
855
869
|
throw new Error("Canceled by BeforeOverGridImageSelect event");
|
|
856
870
|
}
|
|
857
|
-
_overGridImageSelected(
|
|
871
|
+
_overGridImageSelected(drawings) {
|
|
858
872
|
if (!this.hasEventCallback(this.Event.OverGridImageSelected))
|
|
859
873
|
return;
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
874
|
+
const workbook = this.getActiveWorkbook(), drawingManagerService = this._injector.get(IDrawingManagerService);
|
|
875
|
+
if (workbook == null)
|
|
862
876
|
return;
|
|
863
|
-
const
|
|
877
|
+
const selectedDrawings = drawings.map((drawing) => drawingManagerService.getDrawingByParam(drawing));
|
|
864
878
|
this.fireEvent(this.Event.OverGridImageSelected, {
|
|
865
|
-
workbook
|
|
866
|
-
selectedImages: this._createFOverGridImage(
|
|
879
|
+
workbook,
|
|
880
|
+
selectedImages: this._createFOverGridImage(selectedDrawings)
|
|
867
881
|
});
|
|
868
882
|
}
|
|
869
|
-
_createFOverGridImage(
|
|
870
|
-
return
|
|
883
|
+
_createFOverGridImage(drawings) {
|
|
884
|
+
return drawings.map((drawing) => this._injector.createInstance(FOverGridImage, drawing));
|
|
871
885
|
}
|
|
872
|
-
}
|
|
873
|
-
|
|
886
|
+
};
|
|
887
|
+
__name(_FUniverDrawingMixin, "FUniverDrawingMixin");
|
|
888
|
+
let FUniverDrawingMixin = _FUniverDrawingMixin;
|
|
889
|
+
FUniver.extend(FUniverDrawingMixin);
|