@univerjs/sheets-drawing-ui 0.5.3 → 0.5.4-nightly.202501131606
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/es/facade.js +675 -191
- package/lib/es/index.js +1098 -1103
- package/lib/types/controllers/drawing-popup-menu.controller.d.ts +3 -2
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +9 -0
- package/lib/types/facade/f-enum.d.ts +19 -0
- package/lib/types/facade/f-event.d.ts +236 -0
- package/lib/types/facade/f-over-grid-image.d.ts +275 -15
- package/lib/types/facade/f-univer.d.ts +13 -0
- package/lib/types/facade/f-worksheet.d.ts +53 -22
- package/lib/types/facade/index.d.ts +6 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +16 -15
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { getImageSize as
|
|
6
|
-
import { IRenderManagerService as
|
|
7
|
-
import { SetSheetDrawingCommand as
|
|
8
|
-
import { SheetSkeletonManagerService as
|
|
9
|
-
import { ISheetDrawingService as
|
|
10
|
-
import { transformComponentKey as
|
|
11
|
-
import { FWorksheet as
|
|
12
|
-
import { ComponentManager as
|
|
13
|
-
var
|
|
14
|
-
for (var n =
|
|
15
|
-
(
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
function
|
|
19
|
-
const { from:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ from:
|
|
1
|
+
var $ = Object.defineProperty;
|
|
2
|
+
var L = (i, t, e) => t in i ? $(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var D = (i, t, e) => L(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Inject as A, Injector as x, ICommandService as P, generateRandomId as X, DrawingTypeEnum as _, ImageSourceType as I, FBase as Y, ArrangeTypeEnum as f, toDisposable as C, FEnum as F, FEventName as W, FUniver as U } from "@univerjs/core";
|
|
5
|
+
import { getImageSize as H, SetDrawingSelectedOperation as B, IDrawingManagerService as u } from "@univerjs/drawing";
|
|
6
|
+
import { IRenderManagerService as j } from "@univerjs/engine-render";
|
|
7
|
+
import { SetSheetDrawingCommand as g, SetDrawingArrangeCommand as w, SheetCanvasFloatDomManagerService as K, InsertSheetDrawingCommand as S, RemoveSheetDrawingCommand as G } from "@univerjs/sheets-drawing-ui";
|
|
8
|
+
import { SheetSkeletonManagerService as T, ISheetSelectionRenderService as V, convertPositionSheetOverGridToAbsolute as q, convertPositionCellToSheetOverGrid as J } from "@univerjs/sheets-ui";
|
|
9
|
+
import { ISheetDrawingService as h, SheetDrawingAnchorType as Q } from "@univerjs/sheets-drawing";
|
|
10
|
+
import { transformComponentKey as Z } from "@univerjs/sheets-ui/facade";
|
|
11
|
+
import { FWorksheet as M } from "@univerjs/sheets/facade";
|
|
12
|
+
import { ComponentManager as ee } from "@univerjs/ui";
|
|
13
|
+
var te = Object.defineProperty, re = Object.getOwnPropertyDescriptor, z = (i, t, e, r) => {
|
|
14
|
+
for (var n = r > 1 ? void 0 : r ? re(t, e) : t, s = i.length - 1, a; s >= 0; s--)
|
|
15
|
+
(a = i[s]) && (n = (r ? a(t, e, n) : a(n)) || n);
|
|
16
|
+
return r && n && te(t, e, n), n;
|
|
17
|
+
}, E = (i, t) => (e, r) => t(e, r, i);
|
|
18
|
+
function ie(i, t) {
|
|
19
|
+
const { from: e, to: r, flipY: n = !1, flipX: s = !1, angle: a = 0, skewX: o = 0, skewY: c = 0 } = i.sheetTransform, { column: m, columnOffset: l, row: v, rowOffset: O } = e, p = q(
|
|
20
|
+
i.unitId,
|
|
21
|
+
i.subUnitId,
|
|
22
|
+
{ from: e, to: r },
|
|
23
23
|
t
|
|
24
|
-
), { left:
|
|
24
|
+
), { left: y, top: R, width: k, height: N } = p;
|
|
25
25
|
return {
|
|
26
|
-
...
|
|
27
|
-
column:
|
|
28
|
-
columnOffset:
|
|
29
|
-
row:
|
|
30
|
-
rowOffset:
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
26
|
+
...i,
|
|
27
|
+
column: m,
|
|
28
|
+
columnOffset: l,
|
|
29
|
+
row: v,
|
|
30
|
+
rowOffset: O,
|
|
31
|
+
width: k,
|
|
32
|
+
height: N,
|
|
33
33
|
flipY: n,
|
|
34
|
-
flipX:
|
|
35
|
-
angle:
|
|
36
|
-
skewX:
|
|
37
|
-
skewY:
|
|
34
|
+
flipX: s,
|
|
35
|
+
angle: a,
|
|
36
|
+
skewX: o,
|
|
37
|
+
skewY: c
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const { column:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{ column:
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
function ne(i, t, e) {
|
|
41
|
+
const { column: r, columnOffset: n, row: s, rowOffset: a, flipY: o = !1, flipX: c = !1, angle: m = 0, skewX: l = 0, skewY: v = 0, width: O, height: p } = i, y = J(
|
|
42
|
+
i.unitId,
|
|
43
|
+
i.subUnitId,
|
|
44
|
+
{ column: r, columnOffset: n, row: s, rowOffset: a },
|
|
45
|
+
O,
|
|
46
|
+
p,
|
|
47
47
|
t,
|
|
48
|
-
|
|
49
|
-
), { sheetTransform:
|
|
48
|
+
e
|
|
49
|
+
), { sheetTransform: R, transform: k } = y;
|
|
50
50
|
return {
|
|
51
|
-
...
|
|
51
|
+
...i,
|
|
52
52
|
sheetTransform: {
|
|
53
|
-
...
|
|
54
|
-
flipY:
|
|
55
|
-
flipX:
|
|
56
|
-
angle:
|
|
57
|
-
skewX:
|
|
58
|
-
skewY:
|
|
53
|
+
...R,
|
|
54
|
+
flipY: o,
|
|
55
|
+
flipX: c,
|
|
56
|
+
angle: m,
|
|
57
|
+
skewX: l,
|
|
58
|
+
skewY: v
|
|
59
59
|
},
|
|
60
60
|
transform: {
|
|
61
|
-
...
|
|
62
|
-
flipY:
|
|
63
|
-
flipX:
|
|
64
|
-
angle:
|
|
65
|
-
skewX:
|
|
66
|
-
skewY:
|
|
61
|
+
...k,
|
|
62
|
+
flipY: o,
|
|
63
|
+
flipX: c,
|
|
64
|
+
angle: m,
|
|
65
|
+
skewX: l,
|
|
66
|
+
skewY: v
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
let
|
|
71
|
-
constructor(
|
|
72
|
-
|
|
73
|
-
this._injector =
|
|
74
|
-
drawingId:
|
|
75
|
-
drawingType:
|
|
76
|
-
imageSourceType:
|
|
70
|
+
let b = class {
|
|
71
|
+
constructor(i, t, e) {
|
|
72
|
+
D(this, "_image");
|
|
73
|
+
this._injector = e, this._image = {
|
|
74
|
+
drawingId: X(6),
|
|
75
|
+
drawingType: _.DRAWING_IMAGE,
|
|
76
|
+
imageSourceType: I.BASE64,
|
|
77
77
|
source: "",
|
|
78
|
-
unitId:
|
|
78
|
+
unitId: i,
|
|
79
79
|
subUnitId: t,
|
|
80
80
|
column: 0,
|
|
81
81
|
columnOffset: 0,
|
|
@@ -85,16 +85,50 @@ let l = class {
|
|
|
85
85
|
height: 0
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Set the initial image configuration for the image builder.
|
|
90
|
+
* @param image The image to be set. {@link ISheetImage}
|
|
91
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* // create a new image builder.
|
|
95
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
96
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
97
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
98
|
+
* const param = await imageBuilder.setImage({
|
|
99
|
+
* drawingId: '123456',
|
|
100
|
+
* drawingType: univerAPI.Enum.DrawingType.DRAWING_IMAGE,
|
|
101
|
+
* imageSourceType: univerAPI.Enum.ImageSourceType.BASE64,
|
|
102
|
+
* source: 'https://avatars.githubusercontent.com/u/61444807?s=48&v=4',
|
|
103
|
+
* unitId: activeSpreadsheet.getId(),
|
|
104
|
+
* subUnitId: activeSheet.getSheetId(),
|
|
105
|
+
* }).setColumn(5).setRow(5).buildAsync();
|
|
106
|
+
* activeSheet.insertImages([param]);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
setImage(i) {
|
|
110
|
+
const e = this._injector.get(j).getRenderById(i.unitId);
|
|
111
|
+
if (!e)
|
|
112
|
+
throw new Error(`Render Unit with unitId ${i.unitId} not found`);
|
|
113
|
+
const r = e.with(T);
|
|
114
|
+
return i.sheetTransform == null && (i.sheetTransform = {
|
|
115
|
+
from: {
|
|
116
|
+
column: 0,
|
|
117
|
+
columnOffset: 0,
|
|
118
|
+
row: 0,
|
|
119
|
+
rowOffset: 0
|
|
120
|
+
},
|
|
121
|
+
to: {
|
|
122
|
+
column: 0,
|
|
123
|
+
columnOffset: 0,
|
|
124
|
+
row: 0,
|
|
125
|
+
rowOffset: 0
|
|
126
|
+
}
|
|
127
|
+
}), this._image = ie(i, r), this;
|
|
94
128
|
}
|
|
95
|
-
setSource(
|
|
96
|
-
const
|
|
97
|
-
return this._image.source =
|
|
129
|
+
setSource(i, t) {
|
|
130
|
+
const e = t != null ? t : I.URL;
|
|
131
|
+
return this._image.source = i, this._image.imageSourceType = e, this;
|
|
98
132
|
}
|
|
99
133
|
getsource() {
|
|
100
134
|
return this._image.source;
|
|
@@ -102,38 +136,192 @@ let l = class {
|
|
|
102
136
|
getSourceType() {
|
|
103
137
|
return this._image.imageSourceType;
|
|
104
138
|
}
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Set the position of the image
|
|
141
|
+
* @param column The sheet start column of the image
|
|
142
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* // create a new image builder.
|
|
146
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
147
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
148
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
149
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).buildAsync();
|
|
150
|
+
* activeSheet.insertImages([param]);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
setColumn(i) {
|
|
154
|
+
return this._image.column = i, this;
|
|
107
155
|
}
|
|
108
|
-
|
|
109
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Set the position of the image
|
|
158
|
+
* @param row The sheet start row of the image
|
|
159
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* // create a new image builder.
|
|
163
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
164
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
165
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
166
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).buildAsync();
|
|
167
|
+
* activeSheet.insertImages([param]);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
setRow(i) {
|
|
171
|
+
return this._image.row = i, this;
|
|
110
172
|
}
|
|
111
|
-
|
|
112
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Set the column offset of the image in a unit
|
|
175
|
+
* @param offset The offset in pixels
|
|
176
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* // create a new image builder.
|
|
180
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
181
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
182
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
183
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setColumnOffset(10).setRowOffset(10).buildAsync();
|
|
184
|
+
* activeSheet.insertImages([param]);
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
setColumnOffset(i) {
|
|
188
|
+
return this._image.columnOffset = i, this;
|
|
113
189
|
}
|
|
114
|
-
|
|
115
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Set the row offset of the image in a unit
|
|
192
|
+
* @param offset The offset in pixels
|
|
193
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* // create a new image builder.
|
|
197
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
198
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
199
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
200
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setColumnOffset(10).setRowOffset(10).buildAsync();
|
|
201
|
+
* activeSheet.insertImages([param]);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
setRowOffset(i) {
|
|
205
|
+
return this._image.rowOffset = i, this;
|
|
116
206
|
}
|
|
117
|
-
|
|
118
|
-
|
|
207
|
+
/**
|
|
208
|
+
* set the width of the image
|
|
209
|
+
* @param width The width of the image, in pixels
|
|
210
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* // create a new image builder.
|
|
214
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
215
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
216
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
217
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(120).setHeight(50).buildAsync();
|
|
218
|
+
* activeSheet.insertImages([param]);
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
setWidth(i) {
|
|
222
|
+
return this._image.width = i, this;
|
|
119
223
|
}
|
|
120
|
-
|
|
121
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Set the height of the image
|
|
226
|
+
* @param height The height of the image, in pixels
|
|
227
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* // create a new image builder.
|
|
231
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
232
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
233
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
234
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(120).setHeight(50).buildAsync();
|
|
235
|
+
* activeSheet.insertImages([param]);
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
setHeight(i) {
|
|
239
|
+
return this._image.height = i, this;
|
|
122
240
|
}
|
|
123
|
-
|
|
124
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Set the anchor type of the image, whether the position and size change with the cell
|
|
243
|
+
* @param anchorType The anchor type {@link SheetDrawingAnchorType}
|
|
244
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* // create a new image builder.
|
|
248
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
249
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
250
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
251
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setAnchorType(univerAPI.Enum.SheetDrawingAnchorType.None).buildAsync();
|
|
252
|
+
* activeSheet.insertImages([param]);
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
setAnchorType(i) {
|
|
256
|
+
return this._image.anchorType = i, this;
|
|
125
257
|
}
|
|
126
|
-
|
|
127
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Set the cropping region of the image by defining the top edges, thereby displaying the specific part of the image you want.
|
|
260
|
+
* @param top The number of pixels to crop from the top of the image.
|
|
261
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* // create a new image builder.
|
|
265
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
266
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
267
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
268
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setCropTop(10).setCropLeft(10).setCropBottom(10).setCropRight(10).buildAsync();
|
|
269
|
+
* activeSheet.insertImages([param]);
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
setCropTop(i) {
|
|
273
|
+
return this._initializeSrcRect(), this._image.srcRect.top = i, this;
|
|
128
274
|
}
|
|
129
|
-
|
|
130
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Set the cropping region of the image by defining the left edges, thereby displaying the specific part of the image you want.
|
|
277
|
+
* @param left The number of pixels to crop from the left side of the image.
|
|
278
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* // create a new image builder.
|
|
282
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
283
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
284
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
285
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setCropTop(10).setCropLeft(10).setCropBottom(10).setCropRight(10).buildAsync();
|
|
286
|
+
* activeSheet.insertImages([param]);
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
setCropLeft(i) {
|
|
290
|
+
return this._initializeSrcRect(), this._image.srcRect.left = i, this;
|
|
131
291
|
}
|
|
132
|
-
|
|
133
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Set the cropping region of the image by defining the bottom edges, thereby displaying the specific part of the image you want.
|
|
294
|
+
* @param bottom The number of pixels to crop from the bottom of the image.
|
|
295
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
296
|
+
* @example
|
|
297
|
+
* ```ts
|
|
298
|
+
* // create a new image builder.
|
|
299
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
300
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
301
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
302
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setCropTop(10).setCropLeft(10).setCropBottom(10).setCropRight(10).buildAsync();
|
|
303
|
+
* activeSheet.insertImages([param]);
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
setCropBottom(i) {
|
|
307
|
+
return this._initializeSrcRect(), this._image.srcRect.bottom = i, this;
|
|
134
308
|
}
|
|
135
|
-
|
|
136
|
-
|
|
309
|
+
/**
|
|
310
|
+
* Set the cropping region of the image by defining the right edges, thereby displaying the specific part of the image you want.
|
|
311
|
+
* @param right The number of pixels to crop from the right side of the image.
|
|
312
|
+
* @returns The builder. {@link FOverGridImageBuilder}
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* // create a new image builder.
|
|
316
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
317
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
318
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
319
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setCropTop(10).setCropLeft(10).setCropBottom(10).setCropRight(10).buildAsync();
|
|
320
|
+
* activeSheet.insertImages([param]);
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
setCropRight(i) {
|
|
324
|
+
return this._initializeSrcRect(), this._image.srcRect.right = i, this;
|
|
137
325
|
}
|
|
138
326
|
_initializeSrcRect() {
|
|
139
327
|
this._image.srcRect == null && (this._image.srcRect = {
|
|
@@ -146,39 +334,48 @@ let l = class {
|
|
|
146
334
|
/**
|
|
147
335
|
* Set the rotation angle of the image
|
|
148
336
|
* @param angle Degree of rotation of the image, for example, 90, 180, 270, etc.
|
|
149
|
-
* @returns The builder
|
|
337
|
+
* @returns The builder {@link FOverGridImageBuilder}
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* // create a new image builder.
|
|
341
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
342
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
343
|
+
* const imageBuilder = activeSheet.newOverGridImage();
|
|
344
|
+
* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setRotate(90).buildAsync();
|
|
345
|
+
* activeSheet.insertImages([param]);
|
|
346
|
+
* ```
|
|
150
347
|
*/
|
|
151
|
-
setRotate(
|
|
152
|
-
return this._image.angle =
|
|
348
|
+
setRotate(i) {
|
|
349
|
+
return this._image.angle = i, this;
|
|
153
350
|
}
|
|
154
351
|
// setPresetGeometry(prstGeom: PresetGeometryType): FOverGridImageBuilder {
|
|
155
352
|
// this._image.prstGeom = prstGeom;
|
|
156
353
|
// return this;
|
|
157
354
|
// }
|
|
158
|
-
setUnitId(
|
|
159
|
-
return this._image.unitId =
|
|
355
|
+
setUnitId(i) {
|
|
356
|
+
return this._image.unitId = i, this;
|
|
160
357
|
}
|
|
161
|
-
setSubUnitId(
|
|
162
|
-
return this._image.subUnitId =
|
|
358
|
+
setSubUnitId(i) {
|
|
359
|
+
return this._image.subUnitId = i, this;
|
|
163
360
|
}
|
|
164
|
-
async
|
|
165
|
-
const t = this._injector.get(
|
|
361
|
+
async buildAsync() {
|
|
362
|
+
const t = this._injector.get(j).getRenderById(this._image.unitId);
|
|
166
363
|
if (!t)
|
|
167
364
|
throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
|
|
168
|
-
const
|
|
365
|
+
const e = t.with(V), r = t.with(T);
|
|
169
366
|
if (this._image.width === 0 || this._image.height === 0) {
|
|
170
|
-
const n = await
|
|
171
|
-
this._image.width === 0 && (this._image.width =
|
|
367
|
+
const n = await H(this._image.source), s = n.width, a = n.height;
|
|
368
|
+
this._image.width === 0 && (this._image.width = s), this._image.height === 0 && (this._image.height = a);
|
|
172
369
|
}
|
|
173
|
-
return
|
|
370
|
+
return ne(this._image, e, r);
|
|
174
371
|
}
|
|
175
372
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
],
|
|
179
|
-
let
|
|
180
|
-
constructor(
|
|
181
|
-
super(), this._image =
|
|
373
|
+
b = z([
|
|
374
|
+
E(2, A(x))
|
|
375
|
+
], b);
|
|
376
|
+
let d = class extends Y {
|
|
377
|
+
constructor(i, t, e) {
|
|
378
|
+
super(), this._image = i, this._commandService = t, this._injector = e;
|
|
182
379
|
}
|
|
183
380
|
getId() {
|
|
184
381
|
return this._image.drawingId;
|
|
@@ -194,12 +391,12 @@ let c = class extends F {
|
|
|
194
391
|
* // remove the image from the sheet
|
|
195
392
|
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
196
393
|
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
197
|
-
* const image = activeSheet.getImages[0];
|
|
394
|
+
* const image = activeSheet.getImages()[0];
|
|
198
395
|
* console.log('Delete state is ', image?.remove());
|
|
199
396
|
* ```
|
|
200
397
|
*/
|
|
201
398
|
remove() {
|
|
202
|
-
return this._commandService.syncExecuteCommand(
|
|
399
|
+
return this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
203
400
|
}
|
|
204
401
|
/**
|
|
205
402
|
* Convert the image to a FOverGridImageBuilder
|
|
@@ -209,33 +406,44 @@ let c = class extends F {
|
|
|
209
406
|
* // convert the image to a builder
|
|
210
407
|
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
211
408
|
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
212
|
-
* const image = activeSheet.getImages[0];
|
|
409
|
+
* const image = activeSheet.getImages()[0];
|
|
213
410
|
* const builder = image.toBuilder();
|
|
214
|
-
* builder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).
|
|
215
|
-
* activeSheet.updateImages([
|
|
411
|
+
* const param = await builder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).buildAsync();
|
|
412
|
+
* activeSheet.updateImages([param]);
|
|
216
413
|
* ```
|
|
217
414
|
*/
|
|
218
415
|
toBuilder() {
|
|
219
|
-
const
|
|
220
|
-
return
|
|
416
|
+
const i = this._injector.createInstance(b);
|
|
417
|
+
return i.setImage(this._image), i;
|
|
221
418
|
}
|
|
222
|
-
setSource(
|
|
223
|
-
const
|
|
224
|
-
return this._image.source =
|
|
419
|
+
setSource(i, t) {
|
|
420
|
+
const e = t != null ? t : I.URL;
|
|
421
|
+
return this._image.source = i, this._image.imageSourceType = e, this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
225
422
|
}
|
|
226
|
-
|
|
423
|
+
async setPositionAsync(i, t, e, r) {
|
|
227
424
|
const n = this.toBuilder();
|
|
228
|
-
|
|
425
|
+
n.setColumn(t), n.setRow(i), e != null && n.setRowOffset(e), r != null && n.setColumnOffset(r);
|
|
426
|
+
const s = await n.buildAsync();
|
|
427
|
+
return this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [s] });
|
|
229
428
|
}
|
|
230
429
|
/**
|
|
231
430
|
* Set the size of the image
|
|
232
431
|
* @param width The width of the image
|
|
233
432
|
* @param height The height of the image
|
|
234
433
|
* @returns success or not
|
|
434
|
+
* @example
|
|
435
|
+
* ```ts
|
|
436
|
+
* // set the size of the image
|
|
437
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
438
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
439
|
+
* const image = activeSheet.getImages()[0];
|
|
440
|
+
* console.log('Set size state is ', image.setSize(50, 120));
|
|
235
441
|
*/
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
442
|
+
async setSizeAsync(i, t) {
|
|
443
|
+
const e = this.toBuilder();
|
|
444
|
+
e.setWidth(i), e.setHeight(t);
|
|
445
|
+
const r = await e.buildAsync();
|
|
446
|
+
return this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [r] });
|
|
239
447
|
}
|
|
240
448
|
/**
|
|
241
449
|
* 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.
|
|
@@ -249,17 +457,17 @@ let c = class extends F {
|
|
|
249
457
|
* // set the crop of the image
|
|
250
458
|
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
251
459
|
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
252
|
-
* const image = activeSheet.getImages[0];
|
|
253
|
-
* console.log('Set crop state is ', image.setCrop(
|
|
460
|
+
* const image = activeSheet.getImages()[0];
|
|
461
|
+
* console.log('Set crop state is ', image.setCrop(10, 10, 10, 10));
|
|
254
462
|
* ```
|
|
255
463
|
*/
|
|
256
|
-
setCrop(
|
|
464
|
+
setCrop(i, t, e, r) {
|
|
257
465
|
return this._image.srcRect == null && (this._image.srcRect = {
|
|
258
466
|
top: 0,
|
|
259
467
|
left: 0,
|
|
260
468
|
bottom: 0,
|
|
261
469
|
right: 0
|
|
262
|
-
}),
|
|
470
|
+
}), i != null && (this._image.srcRect.top = i), t != null && (this._image.srcRect.left = t), e != null && (this._image.srcRect.bottom = e), r != null && (this._image.srcRect.right = r), this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
263
471
|
}
|
|
264
472
|
// setPresetGeometry(prstGeom: PresetGeometryType): boolean {
|
|
265
473
|
// this._image.prstGeom = prstGeom;
|
|
@@ -269,103 +477,379 @@ let c = class extends F {
|
|
|
269
477
|
* Set the rotation angle of the image
|
|
270
478
|
* @param angle Degree of rotation of the image, for example, 90, 180, 270, etc.
|
|
271
479
|
* @returns success or not
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* // set the rotation angle of the image
|
|
483
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
484
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
485
|
+
* const image = activeSheet.getImages()[0];
|
|
486
|
+
* console.log('Set rotate state is ', image.setRotate(90));
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
setRotate(i) {
|
|
490
|
+
return this._image.sheetTransform.angle = i, this._commandService.syncExecuteCommand(g.id, { unitId: this._image.unitId, drawings: [this._image] });
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Move the image layer forward by one level
|
|
494
|
+
* @returns success or not
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* // move the image forward
|
|
498
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
499
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
500
|
+
* const image = activeSheet.getImages()[0];
|
|
501
|
+
* console.log('Move forward state is ', image.setForward());
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
setForward() {
|
|
505
|
+
return this._commandService.syncExecuteCommand(w.id, {
|
|
506
|
+
unitId: this._image.unitId,
|
|
507
|
+
subUnitId: this._image.subUnitId,
|
|
508
|
+
drawingIds: [this._image.drawingId],
|
|
509
|
+
arrangeType: f.forward
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Move the image layer backward by one level
|
|
514
|
+
* @returns success or not
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* // move the image backward
|
|
518
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
519
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
520
|
+
* const image = activeSheet.getImages()[0];
|
|
521
|
+
* console.log('Move backward state is ', image.setBackward());
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
setBackward() {
|
|
525
|
+
return this._commandService.syncExecuteCommand(w.id, {
|
|
526
|
+
unitId: this._image.unitId,
|
|
527
|
+
subUnitId: this._image.subUnitId,
|
|
528
|
+
drawingIds: [this._image.drawingId],
|
|
529
|
+
arrangeType: f.backward
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Move the image layer to the back
|
|
534
|
+
* @returns success or not
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* // move the image to the back
|
|
538
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
539
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
540
|
+
* const image = activeSheet.getImages()[0];
|
|
541
|
+
* console.log('Move back state is ', image.setBack());
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
setBack() {
|
|
545
|
+
return this._commandService.syncExecuteCommand(w.id, {
|
|
546
|
+
unitId: this._image.unitId,
|
|
547
|
+
subUnitId: this._image.subUnitId,
|
|
548
|
+
drawingIds: [this._image.drawingId],
|
|
549
|
+
arrangeType: f.back
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Move the image layer to the front
|
|
554
|
+
* @returns success or not
|
|
555
|
+
* @example
|
|
556
|
+
* ```ts
|
|
557
|
+
* // move the image to the front
|
|
558
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
559
|
+
* const activeSheet = activeSpreadsheet.getActiveSheet();
|
|
560
|
+
* const image = activeSheet.getImages()[0];
|
|
561
|
+
* console.log('Move front state is ', image.setFront());
|
|
562
|
+
* ```
|
|
272
563
|
*/
|
|
273
|
-
|
|
274
|
-
return this.
|
|
564
|
+
setFront() {
|
|
565
|
+
return this._commandService.syncExecuteCommand(w.id, {
|
|
566
|
+
unitId: this._image.unitId,
|
|
567
|
+
subUnitId: this._image.subUnitId,
|
|
568
|
+
drawingIds: [this._image.drawingId],
|
|
569
|
+
arrangeType: f.front
|
|
570
|
+
});
|
|
275
571
|
}
|
|
276
572
|
};
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
],
|
|
281
|
-
class
|
|
282
|
-
addFloatDomToPosition(t,
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
id:
|
|
573
|
+
d = z([
|
|
574
|
+
E(1, P),
|
|
575
|
+
E(2, A(x))
|
|
576
|
+
], d);
|
|
577
|
+
class se extends M {
|
|
578
|
+
addFloatDomToPosition(t, e) {
|
|
579
|
+
const r = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: s, disposableCollection: a } = Z(t, this._injector.get(ee)), c = this._injector.get(K).addFloatDomToPosition({ ...t, componentKey: s, unitId: r, subUnitId: n }, e);
|
|
580
|
+
return c ? (a.add(c.dispose), {
|
|
581
|
+
id: c.id,
|
|
286
582
|
dispose: () => {
|
|
287
|
-
|
|
583
|
+
a.dispose(), c.dispose();
|
|
288
584
|
}
|
|
289
|
-
}) : (
|
|
585
|
+
}) : (a.dispose(), null);
|
|
290
586
|
}
|
|
291
|
-
async insertImage(t,
|
|
292
|
-
const
|
|
587
|
+
async insertImage(t, e, r, n, s) {
|
|
588
|
+
const a = this.newOverGridImage();
|
|
293
589
|
if (typeof t == "string")
|
|
294
|
-
|
|
590
|
+
a.setSource(t);
|
|
295
591
|
else {
|
|
296
|
-
const
|
|
297
|
-
|
|
592
|
+
const m = await t.getBlob().getDataAsString();
|
|
593
|
+
a.setSource(m, I.BASE64);
|
|
298
594
|
}
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
return this._commandService.syncExecuteCommand(
|
|
595
|
+
e !== void 0 ? a.setColumn(e) : a.setColumn(0), r !== void 0 ? a.setRow(r) : a.setRow(0), n !== void 0 ? a.setColumnOffset(n) : a.setColumnOffset(0), s !== void 0 ? a.setRowOffset(s) : a.setRowOffset(0);
|
|
596
|
+
const o = await a.buildAsync();
|
|
597
|
+
return this._commandService.syncExecuteCommand(S.id, { unitId: this._fWorkbook.getId(), drawings: [o] });
|
|
302
598
|
}
|
|
303
599
|
insertImages(t) {
|
|
304
|
-
const
|
|
305
|
-
this._commandService.syncExecuteCommand(
|
|
600
|
+
const e = t.map((r) => (r.unitId = this._fWorkbook.getId(), r.subUnitId = this.getSheetId(), r));
|
|
601
|
+
return this._commandService.syncExecuteCommand(S.id, { unitId: this._fWorkbook.getId(), drawings: e }), this;
|
|
306
602
|
}
|
|
307
603
|
deleteImages(t) {
|
|
308
|
-
const
|
|
604
|
+
const e = t.map((r) => ({
|
|
309
605
|
unitId: this._fWorkbook.getId(),
|
|
310
|
-
drawingId:
|
|
606
|
+
drawingId: r.getId(),
|
|
311
607
|
subUnitId: this.getSheetId(),
|
|
312
|
-
drawingType:
|
|
608
|
+
drawingType: r.getType()
|
|
313
609
|
}));
|
|
314
|
-
this._commandService.syncExecuteCommand(
|
|
610
|
+
return this._commandService.syncExecuteCommand(G.id, { unitId: this._fWorkbook.getId(), drawings: e }), this;
|
|
315
611
|
}
|
|
316
612
|
getImages() {
|
|
317
|
-
const
|
|
318
|
-
for (const n in
|
|
319
|
-
const
|
|
320
|
-
s.push(this._injector.createInstance(
|
|
613
|
+
const e = this._injector.get(h).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), r = [];
|
|
614
|
+
for (const n in e) {
|
|
615
|
+
const s = e[n];
|
|
616
|
+
s.drawingType === _.DRAWING_IMAGE && r.push(this._injector.createInstance(d, s));
|
|
321
617
|
}
|
|
322
|
-
return
|
|
618
|
+
return r;
|
|
323
619
|
}
|
|
324
620
|
getImageById(t) {
|
|
325
|
-
const
|
|
326
|
-
return
|
|
621
|
+
const r = this._injector.get(h).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
|
|
622
|
+
return r && r.drawingType === _.DRAWING_IMAGE ? this._injector.createInstance(d, r) : null;
|
|
327
623
|
}
|
|
328
624
|
getActiveImages() {
|
|
329
|
-
const
|
|
330
|
-
for (const n in
|
|
331
|
-
const
|
|
332
|
-
|
|
625
|
+
const e = this._injector.get(h).getFocusDrawings(), r = [];
|
|
626
|
+
for (const n in e) {
|
|
627
|
+
const s = e[n];
|
|
628
|
+
r.push(this._injector.createInstance(d, s));
|
|
333
629
|
}
|
|
334
|
-
return
|
|
630
|
+
return r;
|
|
335
631
|
}
|
|
336
632
|
updateImages(t) {
|
|
337
|
-
this._commandService.syncExecuteCommand(
|
|
633
|
+
return this._commandService.syncExecuteCommand(g.id, { unitId: this._fWorkbook.getId(), drawings: t }), this;
|
|
338
634
|
}
|
|
339
635
|
onImageInserted(t) {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
const n =
|
|
343
|
-
(
|
|
636
|
+
const e = this._injector.get(h);
|
|
637
|
+
return C(e.add$.subscribe((r) => {
|
|
638
|
+
const n = r.map(
|
|
639
|
+
(s) => this._injector.createInstance(d, e.getDrawingByParam(s))
|
|
344
640
|
);
|
|
345
641
|
t(n);
|
|
346
|
-
});
|
|
642
|
+
}));
|
|
347
643
|
}
|
|
348
644
|
onImageDeleted(t) {
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const n =
|
|
352
|
-
(
|
|
645
|
+
const e = this._injector.get(h);
|
|
646
|
+
return C(e.remove$.subscribe((r) => {
|
|
647
|
+
const n = r.map(
|
|
648
|
+
(s) => this._injector.createInstance(d, e.getDrawingByParam(s))
|
|
353
649
|
);
|
|
354
650
|
t(n);
|
|
355
|
-
});
|
|
651
|
+
}));
|
|
356
652
|
}
|
|
357
653
|
onImageChanged(t) {
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const n =
|
|
361
|
-
(
|
|
654
|
+
const e = this._injector.get(h);
|
|
655
|
+
return C(e.update$.subscribe((r) => {
|
|
656
|
+
const n = r.map(
|
|
657
|
+
(s) => this._injector.createInstance(d, e.getDrawingByParam(s))
|
|
362
658
|
);
|
|
363
659
|
t(n);
|
|
364
|
-
});
|
|
660
|
+
}));
|
|
365
661
|
}
|
|
366
662
|
newOverGridImage() {
|
|
367
|
-
const t = this._fWorkbook.getId(),
|
|
368
|
-
return this._injector.createInstance(
|
|
663
|
+
const t = this._fWorkbook.getId(), e = this.getSheetId();
|
|
664
|
+
return this._injector.createInstance(b, t, e);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
M.extend(se);
|
|
668
|
+
class ae extends F {
|
|
669
|
+
get DrawingType() {
|
|
670
|
+
return _;
|
|
671
|
+
}
|
|
672
|
+
get ImageSourceType() {
|
|
673
|
+
return I;
|
|
674
|
+
}
|
|
675
|
+
get SheetDrawingAnchorType() {
|
|
676
|
+
return Q;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
F.extend(ae);
|
|
680
|
+
class oe extends W {
|
|
681
|
+
get BeforeOverGridImageChange() {
|
|
682
|
+
return "BeforeOverGridImageChange";
|
|
683
|
+
}
|
|
684
|
+
get OverGridImageChanged() {
|
|
685
|
+
return "OverGridImageChanged";
|
|
686
|
+
}
|
|
687
|
+
get BeforeOverGridImageInsert() {
|
|
688
|
+
return "BeforeOverGridImageInsert";
|
|
689
|
+
}
|
|
690
|
+
get OverGridImageInserted() {
|
|
691
|
+
return "OverGridImageInserted";
|
|
692
|
+
}
|
|
693
|
+
get BeforeOverGridImageRemove() {
|
|
694
|
+
return "BeforeOverGridImageRemove";
|
|
695
|
+
}
|
|
696
|
+
get OverGridImageRemoved() {
|
|
697
|
+
return "OverGridImageRemoved";
|
|
698
|
+
}
|
|
699
|
+
get BeforeOverGridImageSelect() {
|
|
700
|
+
return "BeforeOverGridImageSelect";
|
|
701
|
+
}
|
|
702
|
+
get OverGridImageSelected() {
|
|
703
|
+
return "OverGridImageSelected";
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
W.extend(oe);
|
|
707
|
+
class ce extends U {
|
|
708
|
+
_initialize(t) {
|
|
709
|
+
const e = t.get(P);
|
|
710
|
+
this.disposeWithMe(e.beforeCommandExecuted((r) => {
|
|
711
|
+
switch (r.id) {
|
|
712
|
+
case S.id:
|
|
713
|
+
this._beforeOverGridImageInsert(r.params);
|
|
714
|
+
break;
|
|
715
|
+
case G.id:
|
|
716
|
+
this._beforeOverGridImageRemove(r.params);
|
|
717
|
+
break;
|
|
718
|
+
case g.id:
|
|
719
|
+
this._beforeOverGridImageChange(r.params);
|
|
720
|
+
break;
|
|
721
|
+
case B.id:
|
|
722
|
+
this._beforeOverGridImageSelect(r.params);
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
})), this.disposeWithMe(e.onCommandExecuted((r) => {
|
|
726
|
+
switch (r.id) {
|
|
727
|
+
case S.id:
|
|
728
|
+
this._overGridImageInserted(r.params);
|
|
729
|
+
break;
|
|
730
|
+
case G.id:
|
|
731
|
+
this._overGridImageRemoved(r.params);
|
|
732
|
+
break;
|
|
733
|
+
case g.id:
|
|
734
|
+
this._overGridImageChanged(r.params);
|
|
735
|
+
break;
|
|
736
|
+
case B.id:
|
|
737
|
+
this._overGridImageSelected(r.params);
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
}));
|
|
741
|
+
}
|
|
742
|
+
_beforeOverGridImageInsert(t) {
|
|
743
|
+
if (!this.hasEventCallback(this.Event.BeforeOverGridImageInsert))
|
|
744
|
+
return;
|
|
745
|
+
const e = this.getActiveWorkbook();
|
|
746
|
+
if (e == null || t == null)
|
|
747
|
+
return;
|
|
748
|
+
const { drawings: r } = t, n = {
|
|
749
|
+
workbook: e,
|
|
750
|
+
insertImageParams: r
|
|
751
|
+
};
|
|
752
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageInsert, n), n.cancel)
|
|
753
|
+
throw new Error("Canceled by BeforeOverGridImageInsert event");
|
|
754
|
+
}
|
|
755
|
+
_overGridImageInserted(t) {
|
|
756
|
+
if (!this.hasEventCallback(this.Event.OverGridImageInserted))
|
|
757
|
+
return;
|
|
758
|
+
const e = this.getActiveWorkbook();
|
|
759
|
+
if (e == null || t == null)
|
|
760
|
+
return;
|
|
761
|
+
const { drawings: r } = t;
|
|
762
|
+
this.fireEvent(this.Event.OverGridImageInserted, {
|
|
763
|
+
workbook: e,
|
|
764
|
+
images: this._createFOverGridImage(r)
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
_beforeOverGridImageRemove(t) {
|
|
768
|
+
if (!this.hasEventCallback(this.Event.BeforeOverGridImageRemove))
|
|
769
|
+
return;
|
|
770
|
+
const e = this.getActiveWorkbook();
|
|
771
|
+
if (e == null || t == null)
|
|
772
|
+
return;
|
|
773
|
+
const { drawings: r } = t, n = this._injector.get(u), s = r.map((o) => n.getDrawingByParam(o)), a = {
|
|
774
|
+
workbook: e,
|
|
775
|
+
images: this._createFOverGridImage(s)
|
|
776
|
+
};
|
|
777
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageRemove, a), a.cancel)
|
|
778
|
+
throw new Error("Canceled by BeforeOverGridImageRemove event");
|
|
779
|
+
}
|
|
780
|
+
_overGridImageRemoved(t) {
|
|
781
|
+
if (!this.hasEventCallback(this.Event.OverGridImageRemoved))
|
|
782
|
+
return;
|
|
783
|
+
const e = this.getActiveWorkbook();
|
|
784
|
+
if (e == null || t == null)
|
|
785
|
+
return;
|
|
786
|
+
const { drawings: r } = t;
|
|
787
|
+
this.fireEvent(this.Event.OverGridImageRemoved, {
|
|
788
|
+
workbook: e,
|
|
789
|
+
removeImageParams: r
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
_beforeOverGridImageChange(t) {
|
|
793
|
+
if (!this.hasEventCallback(this.Event.BeforeOverGridImageChange))
|
|
794
|
+
return;
|
|
795
|
+
const e = this.getActiveWorkbook();
|
|
796
|
+
if (e == null || t == null)
|
|
797
|
+
return;
|
|
798
|
+
const { drawings: r } = t, n = this._injector.get(u), s = [];
|
|
799
|
+
r.forEach((o) => {
|
|
800
|
+
const c = n.getDrawingByParam(o);
|
|
801
|
+
c != null && s.push({
|
|
802
|
+
changeParam: o,
|
|
803
|
+
image: this._injector.createInstance(d, c)
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
const a = {
|
|
807
|
+
workbook: e,
|
|
808
|
+
images: s
|
|
809
|
+
};
|
|
810
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageChange, a), a.cancel)
|
|
811
|
+
throw n.updateNotification(r), new Error("Canceled by BeforeOverGridImageChange event");
|
|
812
|
+
}
|
|
813
|
+
_overGridImageChanged(t) {
|
|
814
|
+
if (!this.hasEventCallback(this.Event.OverGridImageChanged))
|
|
815
|
+
return;
|
|
816
|
+
const e = this.getActiveWorkbook();
|
|
817
|
+
if (e == null || t == null)
|
|
818
|
+
return;
|
|
819
|
+
const { drawings: r } = t, n = this._injector.get(u), s = r.map((a) => this._injector.createInstance(d, n.getDrawingByParam(a)));
|
|
820
|
+
this.fireEvent(this.Event.OverGridImageChanged, {
|
|
821
|
+
workbook: e,
|
|
822
|
+
images: s
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
_beforeOverGridImageSelect(t) {
|
|
826
|
+
if (!this.hasEventCallback(this.Event.BeforeOverGridImageSelect))
|
|
827
|
+
return;
|
|
828
|
+
const e = this._injector.get(u), r = this.getActiveWorkbook();
|
|
829
|
+
if (r == null)
|
|
830
|
+
return;
|
|
831
|
+
const n = e.getFocusDrawings(), s = t.map((o) => e.getDrawingByParam(o)), a = {
|
|
832
|
+
workbook: r,
|
|
833
|
+
selectedImages: this._createFOverGridImage(s),
|
|
834
|
+
oldSelectedImages: this._createFOverGridImage(n)
|
|
835
|
+
};
|
|
836
|
+
if (this.fireEvent(this.Event.BeforeOverGridImageSelect, a), a.cancel)
|
|
837
|
+
throw new Error("Canceled by BeforeOverGridImageSelect event");
|
|
838
|
+
}
|
|
839
|
+
_overGridImageSelected(t) {
|
|
840
|
+
if (!this.hasEventCallback(this.Event.OverGridImageSelected))
|
|
841
|
+
return;
|
|
842
|
+
const e = this.getActiveWorkbook(), r = this._injector.get(u);
|
|
843
|
+
if (e == null)
|
|
844
|
+
return;
|
|
845
|
+
const n = t.map((s) => r.getDrawingByParam(s));
|
|
846
|
+
this.fireEvent(this.Event.OverGridImageSelected, {
|
|
847
|
+
workbook: e,
|
|
848
|
+
selectedImages: this._createFOverGridImage(n)
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
_createFOverGridImage(t) {
|
|
852
|
+
return t.map((e) => this._injector.createInstance(d, e));
|
|
369
853
|
}
|
|
370
854
|
}
|
|
371
|
-
|
|
855
|
+
U.extend(ce);
|