@univerjs/sheets-drawing 0.16.1 → 0.17.0
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 +79 -74
- package/lib/index.js +79 -74
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/types/services/sheet-drawing.service.d.ts +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
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"),m=require("@univerjs/sheets");var O=(e=>(e.Position="0",e.Both="1",e.None="2",e))(O||{});class R extends U.UnitDrawingService{}const w=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),n=e.get(w),{op:i,unitId:a,subUnitId:c,type:d,objects:o}=r;switch(t.applyJson1(a,c,i),n.applyJson1(a,c,i),d){case 0:t.addNotification(o),n.addNotification(o);break;case 1:t.removeNotification(o),n.removeNotification(o);break;case 2:t.updateNotification(o),n.updateNotification(o);break;case 3:t.orderNotification(o),n.orderNotification(o);break;case 4:t.groupUpdateNotification(o);break;case 5:t.ungroupUpdateNotification(o);break}return!0}};var C=Object.getOwnPropertyDescriptor,M=(e,r,t,n)=>{for(var i=n>1?void 0:n?C(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(i=c(i)||i);return i},u=(e,r)=>(t,n)=>r(t,n,e);const N="SHEET_DRAWING_PLUGIN";let p=class extends s.Disposable{constructor(e,r,t,n,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=r,this._commandService=t,this._sheetDrawingService=n,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,n)=>{const i=n||this._sheetDrawingService.getDrawingDataForUnit(t);return i?JSON.stringify(i):""},r=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:t=>r(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,n)=>{this._sheetDrawingService.registerDrawingData(t,n),this._drawingManagerService.registerDrawingData(t,n)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var r;if(e.id===m.RemoveSheetCommand.id){const t=e.params,n=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),i=t.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!n||!i)return{redos:[],undos:[]};const a=this._sheetDrawingService.getDrawingData(n,i),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===m.CopySheetCommand.id){const t=e.params,{unitId:n,subUnitId:i,targetSubUnitId:a}=t;if(!n||!i||!a)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(n,i),d=Object.values(c).filter(l=>l.drawingType!==s.DrawingTypeEnum.DRAWING_CHART).map(l=>({...l,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=M([u(0,s.Inject(m.SheetInterceptorService)),u(1,s.Inject(s.IUniverInstanceService)),u(2,s.ICommandService),u(3,w),u(4,U.IDrawingManagerService),u(5,s.IResourceManagerService)],p);const j="@univerjs/sheets-drawing",T="0.17.0",P={name:j,version:T},G="sheets-drawing.config",E={};var H=Object.defineProperty,W=Object.getOwnPropertyDescriptor,y=(e,r,t)=>r in e?H(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,A=(e,r,t,n)=>{for(var i=n>1?void 0:n?W(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(i=c(i)||i);return i},b=(e,r)=>(t,n)=>r(t,n,e),D=(e,r,t)=>y(e,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=E,t,n){super(),this._config=r,this._injector=t,this._configService=n;const{...i}=s.merge({},E,this._config);this._configService.setConfig(G,i)}onStarting(){[[p],[w,{useClass:R}]].forEach(r=>this._injector.add(r)),this._injector.get(p)}};D(exports.UniverSheetsDrawingPlugin,"pluginName",N);D(exports.UniverSheetsDrawingPlugin,"packageName",P.name);D(exports.UniverSheetsDrawingPlugin,"version",P.version);D(exports.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=A([s.DependentOn(U.UniverDrawingPlugin),b(1,s.Inject(s.Injector)),b(2,s.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=h;exports.ISheetDrawingService=w;exports.SHEET_DRAWING_PLUGIN=N;exports.SetDrawingApplyMutation=g;exports.SheetDrawingAnchorType=O;
|
package/lib/es/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createIdentifier as
|
|
2
|
-
import { UnitDrawingService as
|
|
3
|
-
import { SheetInterceptorService as
|
|
1
|
+
import { createIdentifier as C, CommandType as M, Inject as E, IUniverInstanceService as j, ICommandService as G, IResourceManagerService as T, Disposable as H, UniverInstanceType as p, DrawingTypeEnum as D, generateRandomId as J, DependentOn as V, Injector as W, IConfigService as L, Plugin as F, merge as x } from "@univerjs/core";
|
|
2
|
+
import { UnitDrawingService as A, IDrawingManagerService as R, UniverDrawingPlugin as B } from "@univerjs/drawing";
|
|
3
|
+
import { SheetInterceptorService as $, RemoveSheetCommand as k, 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
|
|
5
|
+
class q extends A {
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
const
|
|
7
|
+
const w = C("sheets-drawing.sheet-drawing.service");
|
|
8
|
+
var v = /* @__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))(v || {});
|
|
9
|
+
const h = {
|
|
10
10
|
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type:
|
|
11
|
+
type: M.MUTATION,
|
|
12
12
|
handler: (e, i) => {
|
|
13
|
-
const t = e.get(
|
|
13
|
+
const t = e.get(R), r = e.get(w), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
|
|
14
14
|
switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
|
|
15
15
|
case 0:
|
|
16
16
|
t.addNotification(a), r.addNotification(a);
|
|
@@ -34,15 +34,15 @@ const g = {
|
|
|
34
34
|
return !0;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var
|
|
38
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
37
|
+
var z = Object.getOwnPropertyDescriptor, Q = (e, i, t, r) => {
|
|
38
|
+
for (var n = r > 1 ? void 0 : r ? z(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
41
|
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
-
const
|
|
43
|
-
let
|
|
42
|
+
const l = "SHEET_DRAWING_PLUGIN";
|
|
43
|
+
let f = class extends H {
|
|
44
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(
|
|
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(h));
|
|
46
46
|
}
|
|
47
47
|
_initSnapshot() {
|
|
48
48
|
const e = (t, r) => {
|
|
@@ -59,8 +59,8 @@ let p = class extends T {
|
|
|
59
59
|
};
|
|
60
60
|
this.disposeWithMe(
|
|
61
61
|
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName:
|
|
63
|
-
businesses: [
|
|
62
|
+
pluginName: l,
|
|
63
|
+
businesses: [p.UNIVER_SHEET],
|
|
64
64
|
toJson: (t, r) => e(t, r),
|
|
65
65
|
parseJson: (t) => i(t),
|
|
66
66
|
onUnLoad: (t) => {
|
|
@@ -79,36 +79,36 @@ let p = class extends T {
|
|
|
79
79
|
// eslint-disable-next-line max-lines-per-function
|
|
80
80
|
getMutations: (e) => {
|
|
81
81
|
var i;
|
|
82
|
-
if (e.id ===
|
|
83
|
-
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(
|
|
82
|
+
if (e.id === k.id) {
|
|
83
|
+
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
|
|
84
84
|
if (!r || !n)
|
|
85
85
|
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((
|
|
86
|
+
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
|
|
87
87
|
if (o.length === 0)
|
|
88
88
|
return { redos: [], undos: [] };
|
|
89
|
-
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId:
|
|
89
|
+
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
|
|
90
90
|
return {
|
|
91
91
|
redos: [
|
|
92
92
|
{
|
|
93
|
-
id:
|
|
93
|
+
id: h.id,
|
|
94
94
|
params: {
|
|
95
95
|
op: U,
|
|
96
96
|
unitId: a,
|
|
97
|
-
subUnitId:
|
|
98
|
-
objects:
|
|
99
|
-
type:
|
|
97
|
+
subUnitId: g,
|
|
98
|
+
objects: _,
|
|
99
|
+
type: v.REMOVE
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
],
|
|
103
103
|
undos: [
|
|
104
104
|
{
|
|
105
|
-
id:
|
|
105
|
+
id: h.id,
|
|
106
106
|
params: {
|
|
107
|
-
op:
|
|
107
|
+
op: S,
|
|
108
108
|
unitId: a,
|
|
109
|
-
subUnitId:
|
|
110
|
-
objects:
|
|
111
|
-
type:
|
|
109
|
+
subUnitId: g,
|
|
110
|
+
objects: _,
|
|
111
|
+
type: v.INSERT
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
]
|
|
@@ -117,36 +117,36 @@ let p = class extends T {
|
|
|
117
117
|
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
118
|
if (!r || !n || !s)
|
|
119
119
|
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((
|
|
121
|
-
...
|
|
120
|
+
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
|
|
121
|
+
...N,
|
|
122
122
|
subUnitId: s,
|
|
123
|
-
drawingId:
|
|
123
|
+
drawingId: J(6)
|
|
124
124
|
}));
|
|
125
125
|
if (c.length === 0)
|
|
126
126
|
return { redos: [], undos: [] };
|
|
127
|
-
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId:
|
|
127
|
+
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
|
|
128
128
|
return {
|
|
129
129
|
redos: [
|
|
130
130
|
{
|
|
131
|
-
id:
|
|
131
|
+
id: h.id,
|
|
132
132
|
params: {
|
|
133
|
-
op:
|
|
134
|
-
unitId:
|
|
135
|
-
subUnitId:
|
|
136
|
-
objects:
|
|
137
|
-
type:
|
|
133
|
+
op: _,
|
|
134
|
+
unitId: g,
|
|
135
|
+
subUnitId: S,
|
|
136
|
+
objects: I,
|
|
137
|
+
type: v.INSERT
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
undos: [
|
|
142
142
|
{
|
|
143
|
-
id:
|
|
143
|
+
id: h.id,
|
|
144
144
|
params: {
|
|
145
145
|
op: U,
|
|
146
|
-
unitId:
|
|
147
|
-
subUnitId:
|
|
148
|
-
objects:
|
|
149
|
-
type:
|
|
146
|
+
unitId: g,
|
|
147
|
+
subUnitId: S,
|
|
148
|
+
objects: I,
|
|
149
|
+
type: v.REMOVE
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
]
|
|
@@ -158,49 +158,54 @@ let p = class extends T {
|
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
d(0,
|
|
163
|
-
d(1,
|
|
164
|
-
d(2,
|
|
165
|
-
d(3,
|
|
166
|
-
d(4,
|
|
167
|
-
d(5,
|
|
168
|
-
],
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
161
|
+
f = Q([
|
|
162
|
+
d(0, E($)),
|
|
163
|
+
d(1, E(j)),
|
|
164
|
+
d(2, G),
|
|
165
|
+
d(3, w),
|
|
166
|
+
d(4, R),
|
|
167
|
+
d(5, T)
|
|
168
|
+
], f);
|
|
169
|
+
const X = "@univerjs/sheets-drawing", Z = "0.17.0", P = {
|
|
170
|
+
name: X,
|
|
171
|
+
version: Z
|
|
172
|
+
}, y = "sheets-drawing.config", b = {};
|
|
173
|
+
var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, re = (e, i, t) => i in e ? ee(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ie = (e, i, t, r) => {
|
|
174
|
+
for (var n = r > 1 ? void 0 : r ? te(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
172
175
|
(o = e[s]) && (n = o(n) || n);
|
|
173
176
|
return n;
|
|
174
|
-
},
|
|
175
|
-
let
|
|
177
|
+
}, O = (e, i) => (t, r) => i(t, r, e), m = (e, i, t) => re(e, typeof i != "symbol" ? i + "" : i, t);
|
|
178
|
+
let u = class extends F {
|
|
176
179
|
constructor(e = b, i, t) {
|
|
177
180
|
super(), this._config = e, this._injector = i, this._configService = t;
|
|
178
|
-
const { ...r } =
|
|
181
|
+
const { ...r } = x(
|
|
179
182
|
{},
|
|
180
183
|
b,
|
|
181
184
|
this._config
|
|
182
185
|
);
|
|
183
|
-
this._configService.setConfig(
|
|
186
|
+
this._configService.setConfig(y, r);
|
|
184
187
|
}
|
|
185
188
|
onStarting() {
|
|
186
189
|
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(
|
|
190
|
+
[f],
|
|
191
|
+
[w, { useClass: q }]
|
|
192
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(f);
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
m(u, "pluginName", l);
|
|
196
|
+
m(u, "packageName", P.name);
|
|
197
|
+
m(u, "version", P.version);
|
|
198
|
+
m(u, "type", p.UNIVER_SHEET);
|
|
199
|
+
u = ie([
|
|
200
|
+
V(B),
|
|
201
|
+
O(1, E(W)),
|
|
202
|
+
O(2, L)
|
|
203
|
+
], u);
|
|
199
204
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
v as DrawingApplyType,
|
|
206
|
+
w as ISheetDrawingService,
|
|
207
|
+
l as SHEET_DRAWING_PLUGIN,
|
|
208
|
+
h as SetDrawingApplyMutation,
|
|
204
209
|
Y as SheetDrawingAnchorType,
|
|
205
|
-
|
|
210
|
+
u as UniverSheetsDrawingPlugin
|
|
206
211
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createIdentifier as
|
|
2
|
-
import { UnitDrawingService as
|
|
3
|
-
import { SheetInterceptorService as
|
|
1
|
+
import { createIdentifier as C, CommandType as M, Inject as E, IUniverInstanceService as j, ICommandService as G, IResourceManagerService as T, Disposable as H, UniverInstanceType as p, DrawingTypeEnum as D, generateRandomId as J, DependentOn as V, Injector as W, IConfigService as L, Plugin as F, merge as x } from "@univerjs/core";
|
|
2
|
+
import { UnitDrawingService as A, IDrawingManagerService as R, UniverDrawingPlugin as B } from "@univerjs/drawing";
|
|
3
|
+
import { SheetInterceptorService as $, RemoveSheetCommand as k, 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
|
|
5
|
+
class q extends A {
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
const
|
|
7
|
+
const w = C("sheets-drawing.sheet-drawing.service");
|
|
8
|
+
var v = /* @__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))(v || {});
|
|
9
|
+
const h = {
|
|
10
10
|
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type:
|
|
11
|
+
type: M.MUTATION,
|
|
12
12
|
handler: (e, i) => {
|
|
13
|
-
const t = e.get(
|
|
13
|
+
const t = e.get(R), r = e.get(w), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
|
|
14
14
|
switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
|
|
15
15
|
case 0:
|
|
16
16
|
t.addNotification(a), r.addNotification(a);
|
|
@@ -34,15 +34,15 @@ const g = {
|
|
|
34
34
|
return !0;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var
|
|
38
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
37
|
+
var z = Object.getOwnPropertyDescriptor, Q = (e, i, t, r) => {
|
|
38
|
+
for (var n = r > 1 ? void 0 : r ? z(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
41
|
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
-
const
|
|
43
|
-
let
|
|
42
|
+
const l = "SHEET_DRAWING_PLUGIN";
|
|
43
|
+
let f = class extends H {
|
|
44
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(
|
|
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(h));
|
|
46
46
|
}
|
|
47
47
|
_initSnapshot() {
|
|
48
48
|
const e = (t, r) => {
|
|
@@ -59,8 +59,8 @@ let p = class extends T {
|
|
|
59
59
|
};
|
|
60
60
|
this.disposeWithMe(
|
|
61
61
|
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName:
|
|
63
|
-
businesses: [
|
|
62
|
+
pluginName: l,
|
|
63
|
+
businesses: [p.UNIVER_SHEET],
|
|
64
64
|
toJson: (t, r) => e(t, r),
|
|
65
65
|
parseJson: (t) => i(t),
|
|
66
66
|
onUnLoad: (t) => {
|
|
@@ -79,36 +79,36 @@ let p = class extends T {
|
|
|
79
79
|
// eslint-disable-next-line max-lines-per-function
|
|
80
80
|
getMutations: (e) => {
|
|
81
81
|
var i;
|
|
82
|
-
if (e.id ===
|
|
83
|
-
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(
|
|
82
|
+
if (e.id === k.id) {
|
|
83
|
+
const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
|
|
84
84
|
if (!r || !n)
|
|
85
85
|
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((
|
|
86
|
+
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
|
|
87
87
|
if (o.length === 0)
|
|
88
88
|
return { redos: [], undos: [] };
|
|
89
|
-
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId:
|
|
89
|
+
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
|
|
90
90
|
return {
|
|
91
91
|
redos: [
|
|
92
92
|
{
|
|
93
|
-
id:
|
|
93
|
+
id: h.id,
|
|
94
94
|
params: {
|
|
95
95
|
op: U,
|
|
96
96
|
unitId: a,
|
|
97
|
-
subUnitId:
|
|
98
|
-
objects:
|
|
99
|
-
type:
|
|
97
|
+
subUnitId: g,
|
|
98
|
+
objects: _,
|
|
99
|
+
type: v.REMOVE
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
],
|
|
103
103
|
undos: [
|
|
104
104
|
{
|
|
105
|
-
id:
|
|
105
|
+
id: h.id,
|
|
106
106
|
params: {
|
|
107
|
-
op:
|
|
107
|
+
op: S,
|
|
108
108
|
unitId: a,
|
|
109
|
-
subUnitId:
|
|
110
|
-
objects:
|
|
111
|
-
type:
|
|
109
|
+
subUnitId: g,
|
|
110
|
+
objects: _,
|
|
111
|
+
type: v.INSERT
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
]
|
|
@@ -117,36 +117,36 @@ let p = class extends T {
|
|
|
117
117
|
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
118
|
if (!r || !n || !s)
|
|
119
119
|
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((
|
|
121
|
-
...
|
|
120
|
+
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
|
|
121
|
+
...N,
|
|
122
122
|
subUnitId: s,
|
|
123
|
-
drawingId:
|
|
123
|
+
drawingId: J(6)
|
|
124
124
|
}));
|
|
125
125
|
if (c.length === 0)
|
|
126
126
|
return { redos: [], undos: [] };
|
|
127
|
-
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId:
|
|
127
|
+
const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
|
|
128
128
|
return {
|
|
129
129
|
redos: [
|
|
130
130
|
{
|
|
131
|
-
id:
|
|
131
|
+
id: h.id,
|
|
132
132
|
params: {
|
|
133
|
-
op:
|
|
134
|
-
unitId:
|
|
135
|
-
subUnitId:
|
|
136
|
-
objects:
|
|
137
|
-
type:
|
|
133
|
+
op: _,
|
|
134
|
+
unitId: g,
|
|
135
|
+
subUnitId: S,
|
|
136
|
+
objects: I,
|
|
137
|
+
type: v.INSERT
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
undos: [
|
|
142
142
|
{
|
|
143
|
-
id:
|
|
143
|
+
id: h.id,
|
|
144
144
|
params: {
|
|
145
145
|
op: U,
|
|
146
|
-
unitId:
|
|
147
|
-
subUnitId:
|
|
148
|
-
objects:
|
|
149
|
-
type:
|
|
146
|
+
unitId: g,
|
|
147
|
+
subUnitId: S,
|
|
148
|
+
objects: I,
|
|
149
|
+
type: v.REMOVE
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
]
|
|
@@ -158,49 +158,54 @@ let p = class extends T {
|
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
d(0,
|
|
163
|
-
d(1,
|
|
164
|
-
d(2,
|
|
165
|
-
d(3,
|
|
166
|
-
d(4,
|
|
167
|
-
d(5,
|
|
168
|
-
],
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
161
|
+
f = Q([
|
|
162
|
+
d(0, E($)),
|
|
163
|
+
d(1, E(j)),
|
|
164
|
+
d(2, G),
|
|
165
|
+
d(3, w),
|
|
166
|
+
d(4, R),
|
|
167
|
+
d(5, T)
|
|
168
|
+
], f);
|
|
169
|
+
const X = "@univerjs/sheets-drawing", Z = "0.17.0", P = {
|
|
170
|
+
name: X,
|
|
171
|
+
version: Z
|
|
172
|
+
}, y = "sheets-drawing.config", b = {};
|
|
173
|
+
var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, re = (e, i, t) => i in e ? ee(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ie = (e, i, t, r) => {
|
|
174
|
+
for (var n = r > 1 ? void 0 : r ? te(i, t) : i, s = e.length - 1, o; s >= 0; s--)
|
|
172
175
|
(o = e[s]) && (n = o(n) || n);
|
|
173
176
|
return n;
|
|
174
|
-
},
|
|
175
|
-
let
|
|
177
|
+
}, O = (e, i) => (t, r) => i(t, r, e), m = (e, i, t) => re(e, typeof i != "symbol" ? i + "" : i, t);
|
|
178
|
+
let u = class extends F {
|
|
176
179
|
constructor(e = b, i, t) {
|
|
177
180
|
super(), this._config = e, this._injector = i, this._configService = t;
|
|
178
|
-
const { ...r } =
|
|
181
|
+
const { ...r } = x(
|
|
179
182
|
{},
|
|
180
183
|
b,
|
|
181
184
|
this._config
|
|
182
185
|
);
|
|
183
|
-
this._configService.setConfig(
|
|
186
|
+
this._configService.setConfig(y, r);
|
|
184
187
|
}
|
|
185
188
|
onStarting() {
|
|
186
189
|
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(
|
|
190
|
+
[f],
|
|
191
|
+
[w, { useClass: q }]
|
|
192
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(f);
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
m(u, "pluginName", l);
|
|
196
|
+
m(u, "packageName", P.name);
|
|
197
|
+
m(u, "version", P.version);
|
|
198
|
+
m(u, "type", p.UNIVER_SHEET);
|
|
199
|
+
u = ie([
|
|
200
|
+
V(B),
|
|
201
|
+
O(1, E(W)),
|
|
202
|
+
O(2, L)
|
|
203
|
+
], u);
|
|
199
204
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
v as DrawingApplyType,
|
|
206
|
+
w as ISheetDrawingService,
|
|
207
|
+
l as SHEET_DRAWING_PLUGIN,
|
|
208
|
+
h as SetDrawingApplyMutation,
|
|
204
209
|
Y as SheetDrawingAnchorType,
|
|
205
|
-
|
|
210
|
+
u as UniverSheetsDrawingPlugin
|
|
206
211
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { DrawingApplyType, type ISetDrawingApplyMutationParams, SetDrawingApplyMutation } from './commands/mutations/set-drawing-apply.mutation';
|
|
17
|
-
export type { IUniverSheetsDrawingConfig } from './
|
|
17
|
+
export type { IUniverSheetsDrawingConfig } from './config/config';
|
|
18
18
|
export { SHEET_DRAWING_PLUGIN } from './controllers/sheet-drawing.controller';
|
|
19
19
|
export { UniverSheetsDrawingPlugin } from './plugin';
|
|
20
20
|
export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { IUniverSheetsDrawingConfig } from './
|
|
1
|
+
import { IUniverSheetsDrawingConfig } from './config/config';
|
|
2
2
|
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
3
|
export declare class UniverSheetsDrawingPlugin extends Plugin {
|
|
4
4
|
private readonly _config;
|
|
5
5
|
readonly _injector: Injector;
|
|
6
6
|
private readonly _configService;
|
|
7
7
|
static pluginName: string;
|
|
8
|
+
static packageName: string;
|
|
9
|
+
static version: string;
|
|
8
10
|
static type: UniverInstanceType;
|
|
9
11
|
constructor(_config: Partial<IUniverSheetsDrawingConfig> | undefined, _injector: Injector, _configService: IConfigService);
|
|
10
12
|
onStarting(): void;
|
|
@@ -37,8 +37,8 @@ export interface IFloatDomData extends IDrawingParam {
|
|
|
37
37
|
data?: Serializable;
|
|
38
38
|
allowTransform?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* this property is used to store the excel drawing axis alignment position, which is not always the same as the sheetTransform.
|
|
41
|
+
*/
|
|
42
42
|
axisAlignSheetTransform: ISheetDrawingPosition;
|
|
43
43
|
}
|
|
44
44
|
export interface ISheetFloatDom extends IFloatDomData, ISheetDrawingBase {
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,m){"use strict";var b=(e=>(e.Position="0",e.Both="1",e.None="2",e))(b||{});class j 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,i)=>{const t=e.get(I.IDrawingManagerService),n=e.get(_),{op:s,unitId:o,subUnitId:d,type:h,objects:u}=i;switch(t.applyJson1(o,d,s),n.applyJson1(o,d,s),h){case 0:t.addNotification(u),n.addNotification(u);break;case 1:t.removeNotification(u),n.removeNotification(u);break;case 2:t.updateNotification(u),n.updateNotification(u);break;case 3:t.orderNotification(u),n.orderNotification(u);break;case 4:t.groupUpdateNotification(u);break;case 5:t.ungroupUpdateNotification(u);break}return!0}};var C=Object.getOwnPropertyDescriptor,M=(e,i,t,n)=>{for(var s=n>1?void 0:n?C(i,t):i,o=e.length-1,d;o>=0;o--)(d=e[o])&&(s=d(s)||s);return s},v=(e,i)=>(t,n)=>i(t,n,e);const N="SHEET_DRAWING_PLUGIN";let U=class extends r.Disposable{constructor(e,i,t,n,s,o){super(),this._sheetInterceptorService=e,this._univerInstanceService=i,this._commandService=t,this._sheetDrawingService=n,this._drawingManagerService=s,this._resourceManagerService=o,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,n)=>{const s=n||this._sheetDrawingService.getDrawingDataForUnit(t);return s?JSON.stringify(s):""},i=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:t=>i(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,n)=>{this._sheetDrawingService.registerDrawingData(t,n),this._drawingManagerService.registerDrawingData(t,n)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var i;if(e.id===m.RemoveSheetCommand.id){const t=e.params,n=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!n||!s)return{redos:[],undos:[]};const o=this._sheetDrawingService.getDrawingData(n,s),d=Object.values(o).filter(w=>w.drawingType!==r.DrawingTypeEnum.DRAWING_CHART);if(d.length===0)return{redos:[],undos:[]};const h=this._sheetDrawingService.getBatchRemoveOp(d),{unitId:u,subUnitId:S,undo:p,redo:E,objects:D}=h;return{redos:[{id:g.id,params:{op:E,unitId:u,subUnitId:S,objects:D,type:c.REMOVE}}],undos:[{id:g.id,params:{op:p,unitId:u,subUnitId:S,objects:D,type:c.INSERT}}]}}else if(e.id===m.CopySheetCommand.id){const t=e.params,{unitId:n,subUnitId:s,targetSubUnitId:o}=t;if(!n||!s||!o)return{redos:[],undos:[]};const d=this._sheetDrawingService.getDrawingData(n,s),h=Object.values(d).filter(l=>l.drawingType!==r.DrawingTypeEnum.DRAWING_CHART).map(l=>({...l,subUnitId:o,drawingId:r.generateRandomId(6)}));if(h.length===0)return{redos:[],undos:[]};const u=this._sheetDrawingService.getBatchAddOp(h),{unitId:S,subUnitId:p,undo:E,redo:D,objects:w}=u;return{redos:[{id:g.id,params:{op:D,unitId:S,subUnitId:p,objects:w,type:c.INSERT}}],undos:[{id:g.id,params:{op:E,unitId:S,subUnitId:p,objects:w,type:c.REMOVE}}]}}return{redos:[],undos:[]}}}))}};U=M([v(0,r.Inject(m.SheetInterceptorService)),v(1,r.Inject(r.IUniverInstanceService)),v(2,r.ICommandService),v(3,_),v(4,I.IDrawingManagerService),v(5,r.IResourceManagerService)],U);const O={name:"@univerjs/sheets-drawing",version:"0.17.0"},T="sheets-drawing.config",P={};var G=Object.defineProperty,y=Object.getOwnPropertyDescriptor,H=(e,i,t)=>i in e?G(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,W=(e,i,t,n)=>{for(var s=n>1?void 0:n?y(i,t):i,o=e.length-1,d;o>=0;o--)(d=e[o])&&(s=d(s)||s);return s},R=(e,i)=>(t,n)=>i(t,n,e),f=(e,i,t)=>H(e,typeof i!="symbol"?i+"":i,t);a.UniverSheetsDrawingPlugin=class extends r.Plugin{constructor(i=P,t,n){super(),this._config=i,this._injector=t,this._configService=n;const{...s}=r.merge({},P,this._config);this._configService.setConfig(T,s)}onStarting(){[[U],[_,{useClass:j}]].forEach(i=>this._injector.add(i)),this._injector.get(U)}},f(a.UniverSheetsDrawingPlugin,"pluginName",N),f(a.UniverSheetsDrawingPlugin,"packageName",O.name),f(a.UniverSheetsDrawingPlugin,"version",O.version),f(a.UniverSheetsDrawingPlugin,"type",r.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=W([r.DependentOn(I.UniverDrawingPlugin),R(1,r.Inject(r.Injector)),R(2,r.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=c,a.ISheetDrawingService=_,a.SHEET_DRAWING_PLUGIN=N,a.SetDrawingApplyMutation=g,a.SheetDrawingAnchorType=b,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.
|
|
3
|
+
"version": "0.17.0",
|
|
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.
|
|
47
|
-
"@univerjs/sheets": "0.
|
|
48
|
-
"@univerjs/drawing": "0.
|
|
46
|
+
"@univerjs/core": "0.17.0",
|
|
47
|
+
"@univerjs/sheets": "0.17.0",
|
|
48
|
+
"@univerjs/drawing": "0.17.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"vite": "^7.3.1",
|
|
53
53
|
"vitest": "^4.0.18",
|
|
54
|
-
"@univerjs-infra/shared": "0.
|
|
54
|
+
"@univerjs-infra/shared": "0.17.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "vitest run",
|
|
File without changes
|