@univerjs/sheets-drawing-ui 0.15.0-insiders.20260107-3d1cfdf → 0.15.0-insiders.20260108-47c73e3
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 +52 -52
- package/lib/es/index.js +895 -895
- package/lib/facade.js +52 -52
- package/lib/index.js +895 -895
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +3 -2
- package/lib/types/services/batch-save-images.service.d.ts +6 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +13 -13
package/lib/es/facade.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
2
|
var Z = (s, t, r) => t in s ? Q(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
|
|
3
|
-
var
|
|
4
|
-
import { Inject as L, Injector as
|
|
5
|
-
import { FBase as
|
|
6
|
-
import { getImageSize as
|
|
7
|
-
import { IRenderManagerService as C, getCurrentTypeOfRenderer as
|
|
8
|
-
import { RemoveSheetDrawingCommand as k, SetSheetDrawingCommand as f, SetDrawingArrangeCommand as F, SheetCanvasFloatDomManagerService as p, transformToDrawingPosition as
|
|
9
|
-
import { SheetSkeletonManagerService as
|
|
10
|
-
import { ISheetDrawingService as w, SheetDrawingAnchorType as
|
|
3
|
+
var W = (s, t, r) => Z(s, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Inject as L, Injector as N, ICommandService as K, ImageSourceType as y, ArrangeTypeEnum as O, DrawingTypeEnum as v, generateRandomId as ee, toDisposable as A, CanceledError as D, IURLImageService as te, UniverInstanceType as re, IUniverInstanceService as ne } from "@univerjs/core";
|
|
5
|
+
import { FBase as ie, FEnum as z, FEventName as X, FUniver as Y } from "@univerjs/core/facade";
|
|
6
|
+
import { getImageSize as se, IDrawingManagerService as S, SetDrawingSelectedOperation as j } from "@univerjs/drawing";
|
|
7
|
+
import { IRenderManagerService as C, getCurrentTypeOfRenderer as oe } from "@univerjs/engine-render";
|
|
8
|
+
import { RemoveSheetDrawingCommand as k, SetSheetDrawingCommand as f, SetDrawingArrangeCommand as F, SheetCanvasFloatDomManagerService as p, transformToDrawingPosition as M, InsertSheetDrawingCommand as E, IBatchSaveImagesService as V, FileNamePart as b, SheetDrawingUpdateController as ae } from "@univerjs/sheets-drawing-ui";
|
|
9
|
+
import { SheetSkeletonManagerService as H, ISheetSelectionRenderService as x, convertPositionSheetOverGridToAbsolute as de, convertPositionCellToSheetOverGrid as ce } from "@univerjs/sheets-ui";
|
|
10
|
+
import { ISheetDrawingService as w, SheetDrawingAnchorType as ge } from "@univerjs/sheets-drawing";
|
|
11
11
|
import { transformComponentKey as T } from "@univerjs/sheets-ui/facade";
|
|
12
12
|
import { FWorksheet as $, FRange as q } from "@univerjs/sheets/facade";
|
|
13
13
|
import { ComponentManager as G } from "@univerjs/ui";
|
|
14
|
-
var
|
|
15
|
-
for (var n = e > 1 ? void 0 : e ?
|
|
14
|
+
var me = Object.getOwnPropertyDescriptor, J = (s, t, r, e) => {
|
|
15
|
+
for (var n = e > 1 ? void 0 : e ? me(t, r) : t, i = s.length - 1, a; i >= 0; i--)
|
|
16
16
|
(a = s[i]) && (n = a(n) || n);
|
|
17
17
|
return n;
|
|
18
18
|
}, P = (s, t) => (r, e) => t(r, e, s);
|
|
19
|
-
function
|
|
20
|
-
const { from: r, to: e, flipY: n = !1, flipX: i = !1, angle: a = 0, skewX: o = 0, skewY: d = 0 } = s.sheetTransform, { column: g, columnOffset: c, row: m, rowOffset: h } = r, _ =
|
|
19
|
+
function he(s, t) {
|
|
20
|
+
const { from: r, to: e, flipY: n = !1, flipX: i = !1, angle: a = 0, skewX: o = 0, skewY: d = 0 } = s.sheetTransform, { column: g, columnOffset: c, row: m, rowOffset: h } = r, _ = de(
|
|
21
21
|
s.unitId,
|
|
22
22
|
s.subUnitId,
|
|
23
23
|
{ from: r, to: e },
|
|
@@ -38,8 +38,8 @@ function me(s, t) {
|
|
|
38
38
|
skewY: d
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const { column: e, columnOffset: n, row: i, rowOffset: a, flipY: o = !1, flipX: d = !1, angle: g = 0, skewX: c = 0, skewY: m = 0, width: h, height: _ } = s, l =
|
|
41
|
+
function le(s, t, r) {
|
|
42
|
+
const { column: e, columnOffset: n, row: i, rowOffset: a, flipY: o = !1, flipX: d = !1, angle: g = 0, skewX: c = 0, skewY: m = 0, width: h, height: _ } = s, l = ce(
|
|
43
43
|
s.unitId,
|
|
44
44
|
s.subUnitId,
|
|
45
45
|
{ column: e, columnOffset: n, row: i, rowOffset: a },
|
|
@@ -70,7 +70,7 @@ function he(s, t, r) {
|
|
|
70
70
|
}
|
|
71
71
|
let B = class {
|
|
72
72
|
constructor(s, t, r) {
|
|
73
|
-
|
|
73
|
+
W(this, "_image");
|
|
74
74
|
this._injector = r, this._image = {
|
|
75
75
|
drawingId: ee(6),
|
|
76
76
|
drawingType: v.DRAWING_IMAGE,
|
|
@@ -115,7 +115,7 @@ let B = class {
|
|
|
115
115
|
const r = this._injector.get(C).getRenderById(s.unitId);
|
|
116
116
|
if (!r)
|
|
117
117
|
throw new Error(`Render Unit with unitId ${s.unitId} not found`);
|
|
118
|
-
const e = r.with(
|
|
118
|
+
const e = r.with(H);
|
|
119
119
|
return s.sheetTransform == null && (s.sheetTransform = {
|
|
120
120
|
from: {
|
|
121
121
|
column: 0,
|
|
@@ -129,7 +129,7 @@ let B = class {
|
|
|
129
129
|
row: 0,
|
|
130
130
|
rowOffset: 0
|
|
131
131
|
}
|
|
132
|
-
}), this._image =
|
|
132
|
+
}), this._image = he(s, e), this;
|
|
133
133
|
}
|
|
134
134
|
setSource(s, t) {
|
|
135
135
|
const r = t != null ? t : y.URL;
|
|
@@ -476,18 +476,18 @@ let B = class {
|
|
|
476
476
|
const t = this._injector.get(C).getRenderById(this._image.unitId);
|
|
477
477
|
if (!t)
|
|
478
478
|
throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
|
|
479
|
-
const r = t.with(x), e = t.with(
|
|
479
|
+
const r = t.with(x), e = t.with(H);
|
|
480
480
|
if (this._image.width === 0 || this._image.height === 0) {
|
|
481
|
-
const n = await
|
|
481
|
+
const n = await se(this._image.source), i = n.width, a = n.height;
|
|
482
482
|
this._image.width === 0 && (this._image.width = i), this._image.height === 0 && (this._image.height = a);
|
|
483
483
|
}
|
|
484
|
-
return
|
|
484
|
+
return le(this._image, r, e);
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
B = J([
|
|
488
|
-
P(2, L(
|
|
488
|
+
P(2, L(N))
|
|
489
489
|
], B);
|
|
490
|
-
let I = class extends
|
|
490
|
+
let I = class extends ie {
|
|
491
491
|
constructor(s, t, r) {
|
|
492
492
|
super(), this._image = s, this._commandService = t, this._injector = r;
|
|
493
493
|
}
|
|
@@ -710,10 +710,10 @@ let I = class extends ne {
|
|
|
710
710
|
}
|
|
711
711
|
};
|
|
712
712
|
I = J([
|
|
713
|
-
P(1,
|
|
714
|
-
P(2, L(
|
|
713
|
+
P(1, K),
|
|
714
|
+
P(2, L(N))
|
|
715
715
|
], I);
|
|
716
|
-
class
|
|
716
|
+
class ue extends $ {
|
|
717
717
|
getFloatDomById(t) {
|
|
718
718
|
const e = this._injector.get(p).getFloatDomInfo(t);
|
|
719
719
|
if (!e) return null;
|
|
@@ -785,7 +785,7 @@ class le extends $ {
|
|
|
785
785
|
componentKey: r.componentKey || o.componentKey,
|
|
786
786
|
allowTransform: r.allowTransform !== void 0 ? r.allowTransform : o.allowTransform,
|
|
787
787
|
data: r.data || o.data,
|
|
788
|
-
sheetTransform: r.position && (u =
|
|
788
|
+
sheetTransform: r.position && (u = M(
|
|
789
789
|
r.position,
|
|
790
790
|
m
|
|
791
791
|
)) != null ? u : o.sheetTransform,
|
|
@@ -820,7 +820,7 @@ class le extends $ {
|
|
|
820
820
|
componentKey: o.config.componentKey || m.componentKey,
|
|
821
821
|
allowTransform: o.config.allowTransform !== void 0 ? o.config.allowTransform : m.allowTransform,
|
|
822
822
|
data: o.config.data || m.data,
|
|
823
|
-
sheetTransform: o.config.position && (a =
|
|
823
|
+
sheetTransform: o.config.position && (a = M(
|
|
824
824
|
o.config.position,
|
|
825
825
|
l
|
|
826
826
|
)) != null ? a : m.sheetTransform,
|
|
@@ -892,11 +892,11 @@ class le extends $ {
|
|
|
892
892
|
}
|
|
893
893
|
r !== void 0 ? a.setColumn(r) : a.setColumn(0), e !== void 0 ? a.setRow(e) : a.setRow(0), n !== void 0 ? a.setColumnOffset(n) : a.setColumnOffset(0), i !== void 0 ? a.setRowOffset(i) : a.setRowOffset(0);
|
|
894
894
|
const o = await a.buildAsync();
|
|
895
|
-
return this._commandService.syncExecuteCommand(
|
|
895
|
+
return this._commandService.syncExecuteCommand(E.id, { unitId: this._fWorkbook.getId(), drawings: [o] });
|
|
896
896
|
}
|
|
897
897
|
insertImages(t) {
|
|
898
898
|
const r = t.map((e) => (e.unitId = this._fWorkbook.getId(), e.subUnitId = this.getSheetId(), e));
|
|
899
|
-
return this._commandService.syncExecuteCommand(
|
|
899
|
+
return this._commandService.syncExecuteCommand(E.id, { unitId: this._fWorkbook.getId(), drawings: r }), this;
|
|
900
900
|
}
|
|
901
901
|
deleteImages(t) {
|
|
902
902
|
const r = t.map((e) => ({
|
|
@@ -963,7 +963,7 @@ class le extends $ {
|
|
|
963
963
|
}
|
|
964
964
|
async saveCellImagesAsync(t, r) {
|
|
965
965
|
var m;
|
|
966
|
-
const e = this._injector.get(
|
|
966
|
+
const e = this._injector.get(V), n = this._fWorkbook.getId(), i = this.getSheetId(), a = r ? r.map((h) => h.getRange()) : [this._worksheet.getCellMatrix().getDataRange()], o = e.getCellImagesFromRanges(n, i, a);
|
|
967
967
|
if (o.length === 0)
|
|
968
968
|
return !1;
|
|
969
969
|
if (o.length === 1)
|
|
@@ -973,7 +973,7 @@ class le extends $ {
|
|
|
973
973
|
return console.error("Failed to download image:", h), !1;
|
|
974
974
|
}
|
|
975
975
|
const d = [], g = (m = t == null ? void 0 : t.useCellAddress) != null ? m : !0, c = t == null ? void 0 : t.useColumnIndex;
|
|
976
|
-
g && d.push(
|
|
976
|
+
g && d.push(b.CELL_ADDRESS), c !== void 0 && d.push(b.COLUMN_VALUE), d.length === 0 && d.push(b.CELL_ADDRESS);
|
|
977
977
|
try {
|
|
978
978
|
return await e.saveImagesWithContext(o, {
|
|
979
979
|
fileNameParts: d,
|
|
@@ -984,8 +984,8 @@ class le extends $ {
|
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
|
-
$.extend(
|
|
988
|
-
class
|
|
987
|
+
$.extend(ue);
|
|
988
|
+
class fe extends z {
|
|
989
989
|
get DrawingType() {
|
|
990
990
|
return v;
|
|
991
991
|
}
|
|
@@ -993,11 +993,11 @@ class ue extends X {
|
|
|
993
993
|
return y;
|
|
994
994
|
}
|
|
995
995
|
get SheetDrawingAnchorType() {
|
|
996
|
-
return
|
|
996
|
+
return ge;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
-
|
|
1000
|
-
class
|
|
999
|
+
z.extend(fe);
|
|
1000
|
+
class we extends X {
|
|
1001
1001
|
get BeforeFloatDomAdd() {
|
|
1002
1002
|
return "BeforeFloatDomAdd";
|
|
1003
1003
|
}
|
|
@@ -1041,18 +1041,18 @@ class fe extends Y {
|
|
|
1041
1041
|
return "OverGridImageSelected";
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
|
|
1045
|
-
class
|
|
1044
|
+
X.extend(we);
|
|
1045
|
+
class Ie extends Y {
|
|
1046
1046
|
/**
|
|
1047
1047
|
* @ignore
|
|
1048
1048
|
*/
|
|
1049
1049
|
// eslint-disable-next-line max-lines-per-function
|
|
1050
1050
|
_initialize(t) {
|
|
1051
|
-
const r = t.get(
|
|
1051
|
+
const r = t.get(K);
|
|
1052
1052
|
this.registerEventHandler(
|
|
1053
1053
|
this.Event.BeforeFloatDomAdd,
|
|
1054
1054
|
() => r.beforeCommandExecuted((e) => {
|
|
1055
|
-
if (e.id !==
|
|
1055
|
+
if (e.id !== E.id) return;
|
|
1056
1056
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1057
1057
|
if (i == null || n == null)
|
|
1058
1058
|
return;
|
|
@@ -1071,7 +1071,7 @@ class we extends V {
|
|
|
1071
1071
|
), this.registerEventHandler(
|
|
1072
1072
|
this.Event.FloatDomAdded,
|
|
1073
1073
|
() => r.onCommandExecuted((e) => {
|
|
1074
|
-
if (e.id !==
|
|
1074
|
+
if (e.id !== E.id) return;
|
|
1075
1075
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1076
1076
|
if (i == null || n == null)
|
|
1077
1077
|
return;
|
|
@@ -1086,7 +1086,7 @@ class we extends V {
|
|
|
1086
1086
|
), this.registerEventHandler(
|
|
1087
1087
|
this.Event.BeforeOverGridImageInsert,
|
|
1088
1088
|
() => r.beforeCommandExecuted((e) => {
|
|
1089
|
-
if (e.id !==
|
|
1089
|
+
if (e.id !== E.id) return;
|
|
1090
1090
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1091
1091
|
if (i == null || n == null)
|
|
1092
1092
|
return;
|
|
@@ -1204,7 +1204,7 @@ class we extends V {
|
|
|
1204
1204
|
), this.registerEventHandler(
|
|
1205
1205
|
this.Event.BeforeOverGridImageSelect,
|
|
1206
1206
|
() => r.beforeCommandExecuted((e) => {
|
|
1207
|
-
if (e.id !==
|
|
1207
|
+
if (e.id !== j.id) return;
|
|
1208
1208
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1209
1209
|
if (i == null)
|
|
1210
1210
|
return;
|
|
@@ -1219,7 +1219,7 @@ class we extends V {
|
|
|
1219
1219
|
), this.registerEventHandler(
|
|
1220
1220
|
this.Event.OverGridImageInserted,
|
|
1221
1221
|
() => r.onCommandExecuted((e) => {
|
|
1222
|
-
if (e.id !==
|
|
1222
|
+
if (e.id !== E.id) return;
|
|
1223
1223
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1224
1224
|
if (i == null || n == null)
|
|
1225
1225
|
return;
|
|
@@ -1258,7 +1258,7 @@ class we extends V {
|
|
|
1258
1258
|
), this.registerEventHandler(
|
|
1259
1259
|
this.Event.OverGridImageSelected,
|
|
1260
1260
|
() => r.onCommandExecuted((e) => {
|
|
1261
|
-
if (e.id !==
|
|
1261
|
+
if (e.id !== j.id) return;
|
|
1262
1262
|
const n = e.params, i = this.getActiveWorkbook();
|
|
1263
1263
|
if (i == null)
|
|
1264
1264
|
return;
|
|
@@ -1292,14 +1292,14 @@ class we extends V {
|
|
|
1292
1292
|
* ```
|
|
1293
1293
|
*/
|
|
1294
1294
|
registerURLImageDownloader(t) {
|
|
1295
|
-
return this._injector.get(
|
|
1295
|
+
return this._injector.get(te).registerURLImageDownloader(t);
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
|
-
|
|
1299
|
-
class
|
|
1298
|
+
Y.extend(Ie);
|
|
1299
|
+
class ve extends q {
|
|
1300
1300
|
async insertCellImageAsync(t) {
|
|
1301
1301
|
var i;
|
|
1302
|
-
const r = this._injector.get(C), e = (i =
|
|
1302
|
+
const r = this._injector.get(C), e = (i = oe(re.UNIVER_SHEET, this._injector.get(ne), r)) == null ? void 0 : i.with(ae);
|
|
1303
1303
|
if (!e)
|
|
1304
1304
|
return !1;
|
|
1305
1305
|
const n = {
|
|
@@ -1312,7 +1312,7 @@ class Ie extends q {
|
|
|
1312
1312
|
}
|
|
1313
1313
|
async saveCellImagesAsync(t) {
|
|
1314
1314
|
var c;
|
|
1315
|
-
const r = this._injector.get(
|
|
1315
|
+
const r = this._injector.get(V), e = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), i = this.getRange(), a = r.getCellImagesFromRanges(e, n, [i]);
|
|
1316
1316
|
if (a.length === 0)
|
|
1317
1317
|
return !1;
|
|
1318
1318
|
if (a.length === 1)
|
|
@@ -1322,7 +1322,7 @@ class Ie extends q {
|
|
|
1322
1322
|
return console.error("Failed to download image:", m), !1;
|
|
1323
1323
|
}
|
|
1324
1324
|
const o = [], d = (c = t == null ? void 0 : t.useCellAddress) != null ? c : !0, g = t == null ? void 0 : t.useColumnIndex;
|
|
1325
|
-
d && o.push(
|
|
1325
|
+
d && o.push(b.CELL_ADDRESS), g !== void 0 && o.push(b.COLUMN_VALUE), o.length === 0 && o.push(b.CELL_ADDRESS);
|
|
1326
1326
|
try {
|
|
1327
1327
|
return await r.saveImagesWithContext(a, {
|
|
1328
1328
|
fileNameParts: o,
|
|
@@ -1333,4 +1333,4 @@ class Ie extends q {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
1335
|
}
|
|
1336
|
-
q.extend(
|
|
1336
|
+
q.extend(ve);
|