@univerjs/sheets-drawing-ui 0.6.0-nightly.202502181606 → 0.6.0-nightly.202502201606

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