@univerjs/sheets-drawing-ui 0.15.0-insiders.20260107-3441c7a → 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 +63 -42
- package/lib/es/index.js +490 -476
- package/lib/facade.js +63 -42
- package/lib/index.js +490 -476
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +3 -2
- package/lib/types/facade/f-univer.d.ts +20 -1
- package/lib/types/services/batch-save-images.service.d.ts +16 -2
- 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
3
|
var W = (s, t, r) => Z(s, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { Inject 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 M, InsertSheetDrawingCommand as E, IBatchSaveImagesService as V, FileNamePart as b, SheetDrawingUpdateController as
|
|
9
|
-
import { SheetSkeletonManagerService as H, ISheetSelectionRenderService as x, convertPositionSheetOverGridToAbsolute as
|
|
10
|
-
import { ISheetDrawingService as w, SheetDrawingAnchorType as
|
|
11
|
-
import { transformComponentKey as
|
|
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
|
+
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 },
|
|
@@ -47,7 +47,7 @@ function he(s, t, r) {
|
|
|
47
47
|
_,
|
|
48
48
|
t,
|
|
49
49
|
r
|
|
50
|
-
), { sheetTransform: u, transform:
|
|
50
|
+
), { sheetTransform: u, transform: U } = l;
|
|
51
51
|
return {
|
|
52
52
|
...s,
|
|
53
53
|
sheetTransform: {
|
|
@@ -59,7 +59,7 @@ function he(s, t, r) {
|
|
|
59
59
|
skewY: m
|
|
60
60
|
},
|
|
61
61
|
transform: {
|
|
62
|
-
...
|
|
62
|
+
...U,
|
|
63
63
|
flipY: o,
|
|
64
64
|
flipX: d,
|
|
65
65
|
angle: g,
|
|
@@ -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;
|
|
@@ -478,16 +478,16 @@ let B = class {
|
|
|
478
478
|
throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
|
|
479
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, N
|
|
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
|
}
|
|
@@ -711,13 +711,13 @@ let I = class extends ne {
|
|
|
711
711
|
};
|
|
712
712
|
I = J([
|
|
713
713
|
P(1, K),
|
|
714
|
-
P(2, N
|
|
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;
|
|
720
|
-
const { unitId: n, subUnitId: i } = e, { rect: a } = e, o = a.getState(), { left: d = 0, top: g = 0, width: c = 0, height: m = 0, flipX: h = !1, flipY: _ = !1, angle: l = 0, skewX: u = 0, skewY:
|
|
720
|
+
const { unitId: n, subUnitId: i } = e, { rect: a } = e, o = a.getState(), { left: d = 0, top: g = 0, width: c = 0, height: m = 0, flipX: h = !1, flipY: _ = !1, angle: l = 0, skewX: u = 0, skewY: U = 0 } = o, R = this._injector.get(w).getDrawingByParam({
|
|
721
721
|
drawingId: e.id,
|
|
722
722
|
unitId: n,
|
|
723
723
|
subUnitId: i
|
|
@@ -732,7 +732,7 @@ class le extends $ {
|
|
|
732
732
|
flipY: _,
|
|
733
733
|
angle: l,
|
|
734
734
|
skewX: u,
|
|
735
|
-
skewY:
|
|
735
|
+
skewY: U
|
|
736
736
|
},
|
|
737
737
|
componentKey: R.componentKey,
|
|
738
738
|
allowTransform: R.allowTransform,
|
|
@@ -856,7 +856,7 @@ class le extends $ {
|
|
|
856
856
|
return this;
|
|
857
857
|
}
|
|
858
858
|
addFloatDomToPosition(t, r) {
|
|
859
|
-
const e = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: i, disposableCollection: a } =
|
|
859
|
+
const e = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: i, disposableCollection: a } = T(t, this._injector.get(G)), d = this._injector.get(p).addFloatDomToPosition({ ...t, componentKey: i, unitId: e, subUnitId: n }, r);
|
|
860
860
|
return d ? (a.add(d.dispose), {
|
|
861
861
|
id: d.id,
|
|
862
862
|
dispose: () => {
|
|
@@ -865,7 +865,7 @@ class le extends $ {
|
|
|
865
865
|
}) : (a.dispose(), null);
|
|
866
866
|
}
|
|
867
867
|
addFloatDomToRange(t, r, e, n) {
|
|
868
|
-
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } =
|
|
868
|
+
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } = T(r, this._injector.get(G)), c = this._injector.get(p).addFloatDomToRange(t.getRange(), { ...r, componentKey: o, unitId: i, subUnitId: a }, e, n);
|
|
869
869
|
return c ? (d.add(c.dispose), {
|
|
870
870
|
id: c.id,
|
|
871
871
|
dispose: () => {
|
|
@@ -874,7 +874,7 @@ class le extends $ {
|
|
|
874
874
|
}) : (d.dispose(), null);
|
|
875
875
|
}
|
|
876
876
|
addFloatDomToColumnHeader(t, r, e, n) {
|
|
877
|
-
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } =
|
|
877
|
+
const i = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), { key: o, disposableCollection: d } = T(r, this._injector.get(G)), c = this._injector.get(p).addFloatDomToColumnHeader(t, { ...r, componentKey: o, unitId: i, subUnitId: a }, e, n);
|
|
878
878
|
return c ? (d.add(c.dispose), {
|
|
879
879
|
id: c.id,
|
|
880
880
|
dispose: () => {
|
|
@@ -932,7 +932,7 @@ class le extends $ {
|
|
|
932
932
|
}
|
|
933
933
|
onImageInserted(t) {
|
|
934
934
|
const r = this._injector.get(w);
|
|
935
|
-
return
|
|
935
|
+
return A(r.add$.subscribe((e) => {
|
|
936
936
|
const n = e.map(
|
|
937
937
|
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
938
938
|
);
|
|
@@ -941,7 +941,7 @@ class le extends $ {
|
|
|
941
941
|
}
|
|
942
942
|
onImageDeleted(t) {
|
|
943
943
|
const r = this._injector.get(w);
|
|
944
|
-
return
|
|
944
|
+
return A(r.remove$.subscribe((e) => {
|
|
945
945
|
const n = e.map(
|
|
946
946
|
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
947
947
|
);
|
|
@@ -950,7 +950,7 @@ class le extends $ {
|
|
|
950
950
|
}
|
|
951
951
|
onImageChanged(t) {
|
|
952
952
|
const r = this._injector.get(w);
|
|
953
|
-
return
|
|
953
|
+
return A(r.update$.subscribe((e) => {
|
|
954
954
|
const n = e.map(
|
|
955
955
|
(i) => this._injector.createInstance(I, r.getDrawingByParam(i))
|
|
956
956
|
);
|
|
@@ -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 z {
|
|
|
993
993
|
return y;
|
|
994
994
|
}
|
|
995
995
|
get SheetDrawingAnchorType() {
|
|
996
|
-
return
|
|
996
|
+
return ge;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
-
z.extend(
|
|
1000
|
-
class
|
|
999
|
+
z.extend(fe);
|
|
1000
|
+
class we extends X {
|
|
1001
1001
|
get BeforeFloatDomAdd() {
|
|
1002
1002
|
return "BeforeFloatDomAdd";
|
|
1003
1003
|
}
|
|
@@ -1041,8 +1041,8 @@ class fe extends X {
|
|
|
1041
1041
|
return "OverGridImageSelected";
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
X.extend(
|
|
1045
|
-
class
|
|
1044
|
+
X.extend(we);
|
|
1045
|
+
class Ie extends Y {
|
|
1046
1046
|
/**
|
|
1047
1047
|
* @ignore
|
|
1048
1048
|
*/
|
|
@@ -1273,12 +1273,33 @@ class we extends Y {
|
|
|
1273
1273
|
_createFOverGridImage(t) {
|
|
1274
1274
|
return t.map((r) => this._injector.createInstance(I, r));
|
|
1275
1275
|
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Register a custom image downloader for URL images
|
|
1278
|
+
* @param downloader The downloader function that takes a URL and returns a base64 string
|
|
1279
|
+
* @returns A disposable object to unregister the downloader
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```ts
|
|
1282
|
+
* const disposable = univerAPI.registerURLImageDownloader(async (url) => {
|
|
1283
|
+
* const response = await fetch(url);
|
|
1284
|
+
* const blob = await response.blob();
|
|
1285
|
+
* const base64 = await new Promise<string>((resolve) => {
|
|
1286
|
+
* const reader = new FileReader();
|
|
1287
|
+
* reader.onloadend = () => resolve(reader.result as string);
|
|
1288
|
+
* reader.readAsDataURL(blob);
|
|
1289
|
+
* });
|
|
1290
|
+
* return base64;
|
|
1291
|
+
* });
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
registerURLImageDownloader(t) {
|
|
1295
|
+
return this._injector.get(te).registerURLImageDownloader(t);
|
|
1296
|
+
}
|
|
1276
1297
|
}
|
|
1277
|
-
Y.extend(
|
|
1278
|
-
class
|
|
1298
|
+
Y.extend(Ie);
|
|
1299
|
+
class ve extends q {
|
|
1279
1300
|
async insertCellImageAsync(t) {
|
|
1280
1301
|
var i;
|
|
1281
|
-
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);
|
|
1282
1303
|
if (!e)
|
|
1283
1304
|
return !1;
|
|
1284
1305
|
const n = {
|
|
@@ -1312,4 +1333,4 @@ class Ie extends q {
|
|
|
1312
1333
|
}
|
|
1313
1334
|
}
|
|
1314
1335
|
}
|
|
1315
|
-
q.extend(
|
|
1336
|
+
q.extend(ve);
|