@univerjs/sheets-drawing 0.10.14-nightly.202511031023 → 0.10.14-nightly.202511070640
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/index.js +1 -1
- package/lib/es/index.js +70 -70
- package/lib/index.js +70 -70
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),U=require("@univerjs/drawing"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),U=require("@univerjs/drawing"),l=require("@univerjs/sheets");var b=(e=>(e.Position="0",e.Both="1",e.None="2",e))(b||{});class R extends U.UnitDrawingService{}const D=s.createIdentifier("sheets-drawing.sheet-drawing.service");var h=(e=>(e[e.INSERT=0]="INSERT",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE",e[e.ARRANGE=3]="ARRANGE",e[e.GROUP=4]="GROUP",e[e.UNGROUP=5]="UNGROUP",e))(h||{});const g={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,i)=>{const t=e.get(U.IDrawingManagerService),r=e.get(D),{op:n,unitId:a,subUnitId:c,type:d,objects:o}=i;switch(t.applyJson1(a,c,n),r.applyJson1(a,c,n),d){case 0:t.addNotification(o),r.addNotification(o);break;case 1:t.removeNotification(o),r.removeNotification(o);break;case 2:t.updateNotification(o),r.updateNotification(o);break;case 3:t.orderNotification(o),r.orderNotification(o);break;case 4:t.groupUpdateNotification(o);break;case 5:t.ungroupUpdateNotification(o);break}return!0}};var P=Object.getOwnPropertyDescriptor,C=(e,i,t,r)=>{for(var n=r>1?void 0:r?P(i,t):i,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},u=(e,i)=>(t,r)=>i(t,r,e);const E="SHEET_DRAWING_PLUGIN";let p=class extends s.Disposable{constructor(e,i,t,r,n,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=i,this._commandService=t,this._sheetDrawingService=r,this._drawingManagerService=n,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,r)=>{const n=r||this._sheetDrawingService.getDrawingDataForUnit(t);return n?JSON.stringify(n):""},i=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:E,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(t,r)=>e(t,r),parseJson:t=>i(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,r)=>{this._sheetDrawingService.registerDrawingData(t,r),this._drawingManagerService.registerDrawingData(t,r)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var i;if(e.id===l.RemoveSheetCommand.id){const t=e.params,r=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!r||!n)return{redos:[],undos:[]};const a=this._sheetDrawingService.getDrawingData(r,n),c=Object.values(a).filter(_=>_.drawingType!==s.DrawingTypeEnum.DRAWING_CHART);if(c.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchRemoveOp(c),{unitId:o,subUnitId:v,undo:S,redo:f,objects:I}=d;return{redos:[{id:g.id,params:{op:f,unitId:o,subUnitId:v,objects:I,type:h.REMOVE}}],undos:[{id:g.id,params:{op:S,unitId:o,subUnitId:v,objects:I,type:h.INSERT}}]}}else if(e.id===l.CopySheetCommand.id){const t=e.params,{unitId:r,subUnitId:n,targetSubUnitId:a}=t;if(!r||!n||!a)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(r,n),d=Object.values(c).filter(w=>w.drawingType!==s.DrawingTypeEnum.DRAWING_CHART).map(w=>({...w,subUnitId:a,drawingId:s.generateRandomId(6)}));if(d.length===0)return{redos:[],undos:[]};const o=this._sheetDrawingService.getBatchAddOp(d),{unitId:v,subUnitId:S,undo:f,redo:I,objects:_}=o;return{redos:[{id:g.id,params:{op:I,unitId:v,subUnitId:S,objects:_,type:h.INSERT}}],undos:[{id:g.id,params:{op:f,unitId:v,subUnitId:S,objects:_,type:h.REMOVE}}]}}return{redos:[],undos:[]}}}))}};p=C([u(0,s.Inject(l.SheetInterceptorService)),u(1,s.Inject(s.IUniverInstanceService)),u(2,s.ICommandService),u(3,D),u(4,U.IDrawingManagerService),u(5,s.IResourceManagerService)],p);const M="sheets-drawing.config",N={};var j=Object.defineProperty,T=Object.getOwnPropertyDescriptor,G=(e,i,t)=>i in e?j(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,H=(e,i,t,r)=>{for(var n=r>1?void 0:r?T(i,t):i,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},m=(e,i)=>(t,r)=>i(t,r,e),O=(e,i,t)=>G(e,typeof i!="symbol"?i+"":i,t);exports.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(i=N,t,r){super(),this._config=i,this._injector=t,this._configService=r;const{...n}=s.merge({},N,this._config);this._configService.setConfig(M,n)}onStarting(){[[p],[D,{useClass:R}]].forEach(i=>this._injector.add(i)),this._injector.get(p)}};O(exports.UniverSheetsDrawingPlugin,"pluginName",E);O(exports.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=H([s.DependentOn(U.UniverDrawingPlugin),m(1,s.Inject(s.Injector)),m(2,s.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=h;exports.ISheetDrawingService=D;exports.SHEET_DRAWING_PLUGIN=E;exports.SetDrawingApplyMutation=g;exports.SheetDrawingAnchorType=b;
|
package/lib/es/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { createIdentifier as
|
|
2
|
-
import { UnitDrawingService as
|
|
1
|
+
import { createIdentifier as P, CommandType as C, Inject as N, IUniverInstanceService as M, ICommandService as j, IResourceManagerService as G, Disposable as T, UniverInstanceType as I, DrawingTypeEnum as D, generateRandomId as H, DependentOn as J, Injector as V, IConfigService as W, Plugin as L, merge as F } from "@univerjs/core";
|
|
2
|
+
import { UnitDrawingService as x, IDrawingManagerService as O, UniverDrawingPlugin as A } from "@univerjs/drawing";
|
|
3
3
|
import { SheetInterceptorService as B, RemoveSheetCommand as $, CopySheetCommand as K } from "@univerjs/sheets";
|
|
4
4
|
var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
|
|
5
|
-
class k extends
|
|
5
|
+
class k extends x {
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const E = P("sheets-drawing.sheet-drawing.service");
|
|
8
8
|
var h = /* @__PURE__ */ ((e) => (e[e.INSERT = 0] = "INSERT", e[e.REMOVE = 1] = "REMOVE", e[e.UPDATE = 2] = "UPDATE", e[e.ARRANGE = 3] = "ARRANGE", e[e.GROUP = 4] = "GROUP", e[e.UNGROUP = 5] = "UNGROUP", e))(h || {});
|
|
9
9
|
const g = {
|
|
10
10
|
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type:
|
|
12
|
-
handler: (e,
|
|
13
|
-
const t = e.get(O),
|
|
14
|
-
switch (t.applyJson1(s, o, n),
|
|
11
|
+
type: C.MUTATION,
|
|
12
|
+
handler: (e, i) => {
|
|
13
|
+
const t = e.get(O), r = e.get(E), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
|
|
14
|
+
switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
|
|
15
15
|
case 0:
|
|
16
|
-
t.addNotification(a),
|
|
16
|
+
t.addNotification(a), r.addNotification(a);
|
|
17
17
|
break;
|
|
18
18
|
case 1:
|
|
19
|
-
t.removeNotification(a),
|
|
19
|
+
t.removeNotification(a), r.removeNotification(a);
|
|
20
20
|
break;
|
|
21
21
|
case 2:
|
|
22
|
-
t.updateNotification(a),
|
|
22
|
+
t.updateNotification(a), r.updateNotification(a);
|
|
23
23
|
break;
|
|
24
24
|
case 3:
|
|
25
|
-
t.orderNotification(a),
|
|
25
|
+
t.orderNotification(a), r.orderNotification(a);
|
|
26
26
|
break;
|
|
27
27
|
case 4:
|
|
28
28
|
t.groupUpdateNotification(a);
|
|
@@ -34,21 +34,21 @@ const g = {
|
|
|
34
34
|
return !0;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var q = Object.getOwnPropertyDescriptor, z = (e,
|
|
38
|
-
for (var n =
|
|
37
|
+
var q = Object.getOwnPropertyDescriptor, z = (e, i, t, r) => {
|
|
38
|
+
for (var n = r > 1 ? void 0 : r ? q(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
39
39
|
(o = e[s]) && (n = o(n) || n);
|
|
40
40
|
return n;
|
|
41
|
-
}, d = (e,
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
constructor(e,
|
|
45
|
-
super(), this._sheetInterceptorService = e, this._univerInstanceService =
|
|
41
|
+
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
+
const R = "SHEET_DRAWING_PLUGIN";
|
|
43
|
+
let p = class extends T {
|
|
44
|
+
constructor(e, i, t, r, n, s) {
|
|
45
|
+
super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
|
|
46
46
|
}
|
|
47
47
|
_initSnapshot() {
|
|
48
|
-
const e = (t,
|
|
49
|
-
const n =
|
|
48
|
+
const e = (t, r) => {
|
|
49
|
+
const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
|
|
50
50
|
return n ? JSON.stringify(n) : "";
|
|
51
|
-
},
|
|
51
|
+
}, i = (t) => {
|
|
52
52
|
if (!t)
|
|
53
53
|
return {};
|
|
54
54
|
try {
|
|
@@ -59,15 +59,15 @@ let I = class extends G {
|
|
|
59
59
|
};
|
|
60
60
|
this.disposeWithMe(
|
|
61
61
|
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName:
|
|
63
|
-
businesses: [
|
|
64
|
-
toJson: (t,
|
|
65
|
-
parseJson: (t) =>
|
|
62
|
+
pluginName: R,
|
|
63
|
+
businesses: [I.UNIVER_SHEET],
|
|
64
|
+
toJson: (t, r) => e(t, r),
|
|
65
|
+
parseJson: (t) => i(t),
|
|
66
66
|
onUnLoad: (t) => {
|
|
67
67
|
this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
|
|
68
68
|
},
|
|
69
|
-
onLoad: (t,
|
|
70
|
-
this._sheetDrawingService.registerDrawingData(t,
|
|
69
|
+
onLoad: (t, r) => {
|
|
70
|
+
this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
|
|
71
71
|
}
|
|
72
72
|
})
|
|
73
73
|
);
|
|
@@ -78,12 +78,12 @@ let I = class extends G {
|
|
|
78
78
|
this._sheetInterceptorService.interceptCommand({
|
|
79
79
|
// eslint-disable-next-line max-lines-per-function
|
|
80
80
|
getMutations: (e) => {
|
|
81
|
-
var
|
|
81
|
+
var i;
|
|
82
82
|
if (e.id === $.id) {
|
|
83
|
-
const t = e.params,
|
|
84
|
-
if (!
|
|
83
|
+
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
|
|
84
|
+
if (!r || !n)
|
|
85
85
|
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(
|
|
86
|
+
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
|
|
87
87
|
if (o.length === 0)
|
|
88
88
|
return { redos: [], undos: [] };
|
|
89
89
|
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
|
|
@@ -114,17 +114,17 @@ let I = class extends G {
|
|
|
114
114
|
]
|
|
115
115
|
};
|
|
116
116
|
} else if (e.id === K.id) {
|
|
117
|
-
const t = e.params, { unitId:
|
|
118
|
-
if (!
|
|
117
|
+
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
|
+
if (!r || !n || !s)
|
|
119
119
|
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(
|
|
121
|
-
...
|
|
120
|
+
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
|
|
121
|
+
...m,
|
|
122
122
|
subUnitId: s,
|
|
123
|
-
drawingId:
|
|
123
|
+
drawingId: H(6)
|
|
124
124
|
}));
|
|
125
125
|
if (c.length === 0)
|
|
126
126
|
return { redos: [], undos: [] };
|
|
127
|
-
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects:
|
|
127
|
+
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
|
|
128
128
|
return {
|
|
129
129
|
redos: [
|
|
130
130
|
{
|
|
@@ -133,7 +133,7 @@ let I = class extends G {
|
|
|
133
133
|
op: S,
|
|
134
134
|
unitId: u,
|
|
135
135
|
subUnitId: v,
|
|
136
|
-
objects:
|
|
136
|
+
objects: _,
|
|
137
137
|
type: h.INSERT
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -145,7 +145,7 @@ let I = class extends G {
|
|
|
145
145
|
op: U,
|
|
146
146
|
unitId: u,
|
|
147
147
|
subUnitId: v,
|
|
148
|
-
objects:
|
|
148
|
+
objects: _,
|
|
149
149
|
type: h.REMOVE
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -158,49 +158,49 @@ let I = class extends G {
|
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
d(0,
|
|
163
|
-
d(1,
|
|
164
|
-
d(2,
|
|
165
|
-
d(3,
|
|
161
|
+
p = z([
|
|
162
|
+
d(0, N(B)),
|
|
163
|
+
d(1, N(M)),
|
|
164
|
+
d(2, j),
|
|
165
|
+
d(3, E),
|
|
166
166
|
d(4, O),
|
|
167
|
-
d(5,
|
|
168
|
-
],
|
|
169
|
-
const
|
|
170
|
-
var
|
|
171
|
-
for (var n =
|
|
167
|
+
d(5, G)
|
|
168
|
+
], p);
|
|
169
|
+
const Q = "sheets-drawing.config", b = {};
|
|
170
|
+
var X = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, y = (e, i, t) => i in e ? X(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ee = (e, i, t, r) => {
|
|
171
|
+
for (var n = r > 1 ? void 0 : r ? Z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
172
172
|
(o = e[s]) && (n = o(n) || n);
|
|
173
173
|
return n;
|
|
174
|
-
},
|
|
175
|
-
let
|
|
176
|
-
constructor(e =
|
|
177
|
-
super(), this._config = e, this._injector =
|
|
178
|
-
const { ...
|
|
174
|
+
}, w = (e, i) => (t, r) => i(t, r, e), l = (e, i, t) => y(e, typeof i != "symbol" ? i + "" : i, t);
|
|
175
|
+
let f = class extends L {
|
|
176
|
+
constructor(e = b, i, t) {
|
|
177
|
+
super(), this._config = e, this._injector = i, this._configService = t;
|
|
178
|
+
const { ...r } = F(
|
|
179
179
|
{},
|
|
180
|
-
|
|
180
|
+
b,
|
|
181
181
|
this._config
|
|
182
182
|
);
|
|
183
|
-
this._configService.setConfig(
|
|
183
|
+
this._configService.setConfig(Q, r);
|
|
184
184
|
}
|
|
185
185
|
onStarting() {
|
|
186
186
|
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(
|
|
187
|
+
[p],
|
|
188
|
+
[E, { useClass: k }]
|
|
189
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(p);
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
],
|
|
192
|
+
l(f, "pluginName", R);
|
|
193
|
+
l(f, "type", I.UNIVER_SHEET);
|
|
194
|
+
f = ee([
|
|
195
|
+
J(A),
|
|
196
|
+
w(1, N(V)),
|
|
197
|
+
w(2, W)
|
|
198
|
+
], f);
|
|
199
199
|
export {
|
|
200
200
|
h as DrawingApplyType,
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
E as ISheetDrawingService,
|
|
202
|
+
R as SHEET_DRAWING_PLUGIN,
|
|
203
203
|
g as SetDrawingApplyMutation,
|
|
204
204
|
Y as SheetDrawingAnchorType,
|
|
205
|
-
|
|
205
|
+
f as UniverSheetsDrawingPlugin
|
|
206
206
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { createIdentifier as
|
|
2
|
-
import { UnitDrawingService as
|
|
1
|
+
import { createIdentifier as P, CommandType as C, Inject as N, IUniverInstanceService as M, ICommandService as j, IResourceManagerService as G, Disposable as T, UniverInstanceType as I, DrawingTypeEnum as D, generateRandomId as H, DependentOn as J, Injector as V, IConfigService as W, Plugin as L, merge as F } from "@univerjs/core";
|
|
2
|
+
import { UnitDrawingService as x, IDrawingManagerService as O, UniverDrawingPlugin as A } from "@univerjs/drawing";
|
|
3
3
|
import { SheetInterceptorService as B, RemoveSheetCommand as $, CopySheetCommand as K } from "@univerjs/sheets";
|
|
4
4
|
var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
|
|
5
|
-
class k extends
|
|
5
|
+
class k extends x {
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const E = P("sheets-drawing.sheet-drawing.service");
|
|
8
8
|
var h = /* @__PURE__ */ ((e) => (e[e.INSERT = 0] = "INSERT", e[e.REMOVE = 1] = "REMOVE", e[e.UPDATE = 2] = "UPDATE", e[e.ARRANGE = 3] = "ARRANGE", e[e.GROUP = 4] = "GROUP", e[e.UNGROUP = 5] = "UNGROUP", e))(h || {});
|
|
9
9
|
const g = {
|
|
10
10
|
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type:
|
|
12
|
-
handler: (e,
|
|
13
|
-
const t = e.get(O),
|
|
14
|
-
switch (t.applyJson1(s, o, n),
|
|
11
|
+
type: C.MUTATION,
|
|
12
|
+
handler: (e, i) => {
|
|
13
|
+
const t = e.get(O), r = e.get(E), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
|
|
14
|
+
switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
|
|
15
15
|
case 0:
|
|
16
|
-
t.addNotification(a),
|
|
16
|
+
t.addNotification(a), r.addNotification(a);
|
|
17
17
|
break;
|
|
18
18
|
case 1:
|
|
19
|
-
t.removeNotification(a),
|
|
19
|
+
t.removeNotification(a), r.removeNotification(a);
|
|
20
20
|
break;
|
|
21
21
|
case 2:
|
|
22
|
-
t.updateNotification(a),
|
|
22
|
+
t.updateNotification(a), r.updateNotification(a);
|
|
23
23
|
break;
|
|
24
24
|
case 3:
|
|
25
|
-
t.orderNotification(a),
|
|
25
|
+
t.orderNotification(a), r.orderNotification(a);
|
|
26
26
|
break;
|
|
27
27
|
case 4:
|
|
28
28
|
t.groupUpdateNotification(a);
|
|
@@ -34,21 +34,21 @@ const g = {
|
|
|
34
34
|
return !0;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var q = Object.getOwnPropertyDescriptor, z = (e,
|
|
38
|
-
for (var n =
|
|
37
|
+
var q = Object.getOwnPropertyDescriptor, z = (e, i, t, r) => {
|
|
38
|
+
for (var n = r > 1 ? void 0 : r ? q(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
39
39
|
(o = e[s]) && (n = o(n) || n);
|
|
40
40
|
return n;
|
|
41
|
-
}, d = (e,
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
constructor(e,
|
|
45
|
-
super(), this._sheetInterceptorService = e, this._univerInstanceService =
|
|
41
|
+
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
+
const R = "SHEET_DRAWING_PLUGIN";
|
|
43
|
+
let p = class extends T {
|
|
44
|
+
constructor(e, i, t, r, n, s) {
|
|
45
|
+
super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
|
|
46
46
|
}
|
|
47
47
|
_initSnapshot() {
|
|
48
|
-
const e = (t,
|
|
49
|
-
const n =
|
|
48
|
+
const e = (t, r) => {
|
|
49
|
+
const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
|
|
50
50
|
return n ? JSON.stringify(n) : "";
|
|
51
|
-
},
|
|
51
|
+
}, i = (t) => {
|
|
52
52
|
if (!t)
|
|
53
53
|
return {};
|
|
54
54
|
try {
|
|
@@ -59,15 +59,15 @@ let I = class extends G {
|
|
|
59
59
|
};
|
|
60
60
|
this.disposeWithMe(
|
|
61
61
|
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName:
|
|
63
|
-
businesses: [
|
|
64
|
-
toJson: (t,
|
|
65
|
-
parseJson: (t) =>
|
|
62
|
+
pluginName: R,
|
|
63
|
+
businesses: [I.UNIVER_SHEET],
|
|
64
|
+
toJson: (t, r) => e(t, r),
|
|
65
|
+
parseJson: (t) => i(t),
|
|
66
66
|
onUnLoad: (t) => {
|
|
67
67
|
this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
|
|
68
68
|
},
|
|
69
|
-
onLoad: (t,
|
|
70
|
-
this._sheetDrawingService.registerDrawingData(t,
|
|
69
|
+
onLoad: (t, r) => {
|
|
70
|
+
this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
|
|
71
71
|
}
|
|
72
72
|
})
|
|
73
73
|
);
|
|
@@ -78,12 +78,12 @@ let I = class extends G {
|
|
|
78
78
|
this._sheetInterceptorService.interceptCommand({
|
|
79
79
|
// eslint-disable-next-line max-lines-per-function
|
|
80
80
|
getMutations: (e) => {
|
|
81
|
-
var
|
|
81
|
+
var i;
|
|
82
82
|
if (e.id === $.id) {
|
|
83
|
-
const t = e.params,
|
|
84
|
-
if (!
|
|
83
|
+
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
|
|
84
|
+
if (!r || !n)
|
|
85
85
|
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(
|
|
86
|
+
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
|
|
87
87
|
if (o.length === 0)
|
|
88
88
|
return { redos: [], undos: [] };
|
|
89
89
|
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
|
|
@@ -114,17 +114,17 @@ let I = class extends G {
|
|
|
114
114
|
]
|
|
115
115
|
};
|
|
116
116
|
} else if (e.id === K.id) {
|
|
117
|
-
const t = e.params, { unitId:
|
|
118
|
-
if (!
|
|
117
|
+
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
|
+
if (!r || !n || !s)
|
|
119
119
|
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(
|
|
121
|
-
...
|
|
120
|
+
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
|
|
121
|
+
...m,
|
|
122
122
|
subUnitId: s,
|
|
123
|
-
drawingId:
|
|
123
|
+
drawingId: H(6)
|
|
124
124
|
}));
|
|
125
125
|
if (c.length === 0)
|
|
126
126
|
return { redos: [], undos: [] };
|
|
127
|
-
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects:
|
|
127
|
+
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
|
|
128
128
|
return {
|
|
129
129
|
redos: [
|
|
130
130
|
{
|
|
@@ -133,7 +133,7 @@ let I = class extends G {
|
|
|
133
133
|
op: S,
|
|
134
134
|
unitId: u,
|
|
135
135
|
subUnitId: v,
|
|
136
|
-
objects:
|
|
136
|
+
objects: _,
|
|
137
137
|
type: h.INSERT
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -145,7 +145,7 @@ let I = class extends G {
|
|
|
145
145
|
op: U,
|
|
146
146
|
unitId: u,
|
|
147
147
|
subUnitId: v,
|
|
148
|
-
objects:
|
|
148
|
+
objects: _,
|
|
149
149
|
type: h.REMOVE
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -158,49 +158,49 @@ let I = class extends G {
|
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
d(0,
|
|
163
|
-
d(1,
|
|
164
|
-
d(2,
|
|
165
|
-
d(3,
|
|
161
|
+
p = z([
|
|
162
|
+
d(0, N(B)),
|
|
163
|
+
d(1, N(M)),
|
|
164
|
+
d(2, j),
|
|
165
|
+
d(3, E),
|
|
166
166
|
d(4, O),
|
|
167
|
-
d(5,
|
|
168
|
-
],
|
|
169
|
-
const
|
|
170
|
-
var
|
|
171
|
-
for (var n =
|
|
167
|
+
d(5, G)
|
|
168
|
+
], p);
|
|
169
|
+
const Q = "sheets-drawing.config", b = {};
|
|
170
|
+
var X = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, y = (e, i, t) => i in e ? X(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ee = (e, i, t, r) => {
|
|
171
|
+
for (var n = r > 1 ? void 0 : r ? Z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
172
172
|
(o = e[s]) && (n = o(n) || n);
|
|
173
173
|
return n;
|
|
174
|
-
},
|
|
175
|
-
let
|
|
176
|
-
constructor(e =
|
|
177
|
-
super(), this._config = e, this._injector =
|
|
178
|
-
const { ...
|
|
174
|
+
}, w = (e, i) => (t, r) => i(t, r, e), l = (e, i, t) => y(e, typeof i != "symbol" ? i + "" : i, t);
|
|
175
|
+
let f = class extends L {
|
|
176
|
+
constructor(e = b, i, t) {
|
|
177
|
+
super(), this._config = e, this._injector = i, this._configService = t;
|
|
178
|
+
const { ...r } = F(
|
|
179
179
|
{},
|
|
180
|
-
|
|
180
|
+
b,
|
|
181
181
|
this._config
|
|
182
182
|
);
|
|
183
|
-
this._configService.setConfig(
|
|
183
|
+
this._configService.setConfig(Q, r);
|
|
184
184
|
}
|
|
185
185
|
onStarting() {
|
|
186
186
|
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(
|
|
187
|
+
[p],
|
|
188
|
+
[E, { useClass: k }]
|
|
189
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(p);
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
],
|
|
192
|
+
l(f, "pluginName", R);
|
|
193
|
+
l(f, "type", I.UNIVER_SHEET);
|
|
194
|
+
f = ee([
|
|
195
|
+
J(A),
|
|
196
|
+
w(1, N(V)),
|
|
197
|
+
w(2, W)
|
|
198
|
+
], f);
|
|
199
199
|
export {
|
|
200
200
|
h as DrawingApplyType,
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
E as ISheetDrawingService,
|
|
202
|
+
R as SHEET_DRAWING_PLUGIN,
|
|
203
203
|
g as SetDrawingApplyMutation,
|
|
204
204
|
Y as SheetDrawingAnchorType,
|
|
205
|
-
|
|
205
|
+
f as UniverSheetsDrawingPlugin
|
|
206
206
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,
|
|
1
|
+
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/sheets"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing,a.UniverSheets))})(this,(function(a,r,I,w){"use strict";var l=(e=>(e.Position="0",e.Both="1",e.None="2",e))(l||{});class P extends I.UnitDrawingService{}const _=r.createIdentifier("sheets-drawing.sheet-drawing.service");var c=(e=>(e[e.INSERT=0]="INSERT",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE",e[e.ARRANGE=3]="ARRANGE",e[e.GROUP=4]="GROUP",e[e.UNGROUP=5]="UNGROUP",e))(c||{});const g={id:"sheet.mutation.set-drawing-apply",type:r.CommandType.MUTATION,handler:(e,n)=>{const t=e.get(I.IDrawingManagerService),i=e.get(_),{op:s,unitId:o,subUnitId:u,type:h,objects:d}=n;switch(t.applyJson1(o,u,s),i.applyJson1(o,u,s),h){case 0:t.addNotification(d),i.addNotification(d);break;case 1:t.removeNotification(d),i.removeNotification(d);break;case 2:t.updateNotification(d),i.updateNotification(d);break;case 3:t.orderNotification(d),i.orderNotification(d);break;case 4:t.groupUpdateNotification(d);break;case 5:t.ungroupUpdateNotification(d);break}return!0}};var j=Object.getOwnPropertyDescriptor,C=(e,n,t,i)=>{for(var s=i>1?void 0:i?j(n,t):n,o=e.length-1,u;o>=0;o--)(u=e[o])&&(s=u(s)||s);return s},v=(e,n)=>(t,i)=>n(t,i,e);const m="SHEET_DRAWING_PLUGIN";let U=class extends r.Disposable{constructor(e,n,t,i,s,o){super(),this._sheetInterceptorService=e,this._univerInstanceService=n,this._commandService=t,this._sheetDrawingService=i,this._drawingManagerService=s,this._resourceManagerService=o,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,i)=>{const s=i||this._sheetDrawingService.getDrawingDataForUnit(t);return s?JSON.stringify(s):""},n=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:m,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:(t,i)=>e(t,i),parseJson:t=>n(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,i)=>{this._sheetDrawingService.registerDrawingData(t,i),this._drawingManagerService.registerDrawingData(t,i)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===w.RemoveSheetCommand.id){const t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=t.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!s)return{redos:[],undos:[]};const o=this._sheetDrawingService.getDrawingData(i,s),u=Object.values(o).filter(D=>D.drawingType!==r.DrawingTypeEnum.DRAWING_CHART);if(u.length===0)return{redos:[],undos:[]};const h=this._sheetDrawingService.getBatchRemoveOp(u),{unitId:d,subUnitId:S,undo:f,redo:E,objects:p}=h;return{redos:[{id:g.id,params:{op:E,unitId:d,subUnitId:S,objects:p,type:c.REMOVE}}],undos:[{id:g.id,params:{op:f,unitId:d,subUnitId:S,objects:p,type:c.INSERT}}]}}else if(e.id===w.CopySheetCommand.id){const t=e.params,{unitId:i,subUnitId:s,targetSubUnitId:o}=t;if(!i||!s||!o)return{redos:[],undos:[]};const u=this._sheetDrawingService.getDrawingData(i,s),h=Object.values(u).filter(N=>N.drawingType!==r.DrawingTypeEnum.DRAWING_CHART).map(N=>({...N,subUnitId:o,drawingId:r.generateRandomId(6)}));if(h.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchAddOp(h),{unitId:S,subUnitId:f,undo:E,redo:p,objects:D}=d;return{redos:[{id:g.id,params:{op:p,unitId:S,subUnitId:f,objects:D,type:c.INSERT}}],undos:[{id:g.id,params:{op:E,unitId:S,subUnitId:f,objects:D,type:c.REMOVE}}]}}return{redos:[],undos:[]}}}))}};U=C([v(0,r.Inject(w.SheetInterceptorService)),v(1,r.Inject(r.IUniverInstanceService)),v(2,r.ICommandService),v(3,_),v(4,I.IDrawingManagerService),v(5,r.IResourceManagerService)],U);const M="sheets-drawing.config",b={};var T=Object.defineProperty,G=Object.getOwnPropertyDescriptor,y=(e,n,t)=>n in e?T(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,H=(e,n,t,i)=>{for(var s=i>1?void 0:i?G(n,t):n,o=e.length-1,u;o>=0;o--)(u=e[o])&&(s=u(s)||s);return s},O=(e,n)=>(t,i)=>n(t,i,e),R=(e,n,t)=>y(e,typeof n!="symbol"?n+"":n,t);a.UniverSheetsDrawingPlugin=class extends r.Plugin{constructor(n=b,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{...s}=r.merge({},b,this._config);this._configService.setConfig(M,s)}onStarting(){[[U],[_,{useClass:P}]].forEach(n=>this._injector.add(n)),this._injector.get(U)}},R(a.UniverSheetsDrawingPlugin,"pluginName",m),R(a.UniverSheetsDrawingPlugin,"type",r.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=H([r.DependentOn(I.UniverDrawingPlugin),O(1,r.Inject(r.Injector)),O(2,r.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=c,a.ISheetDrawingService=_,a.SHEET_DRAWING_PLUGIN=m,a.SetDrawingApplyMutation=g,a.SheetDrawingAnchorType=l,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing",
|
|
3
|
-
"version": "0.10.14-nightly.
|
|
3
|
+
"version": "0.10.14-nightly.202511070640",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"lib"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@univerjs/core": "0.10.14-nightly.
|
|
47
|
-
"@univerjs/
|
|
48
|
-
"@univerjs/
|
|
46
|
+
"@univerjs/core": "0.10.14-nightly.202511070640",
|
|
47
|
+
"@univerjs/drawing": "0.10.14-nightly.202511070640",
|
|
48
|
+
"@univerjs/sheets": "0.10.14-nightly.202511070640"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^5.9.3",
|