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