@univerjs/sheets-drawing 0.17.0 → 0.18.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 +1 -211
- package/lib/index.js +1 -211
- package/lib/types/commands/mutations/set-drawing-apply.mutation.d.ts +17 -2
- package/lib/types/controllers/sheet-drawing.controller.d.ts +15 -0
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/sheet-drawing.service.d.ts +20 -4
- package/lib/umd/index.js +1 -1
- package/package.json +9 -8
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`),n=require(`@univerjs/sheets`),r=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var i=class extends t.UnitDrawingService{};const a=(0,e.createIdentifier)(`sheets-drawing.sheet-drawing.service`);let o=function(e){return 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}({});const s={id:`sheet.mutation.set-drawing-apply`,type:e.CommandType.MUTATION,handler:(e,n)=>{let r=e.get(t.IDrawingManagerService),i=e.get(a),{op:s,unitId:c,subUnitId:l,type:u,objects:d}=n;switch(r.applyJson1(c,l,s),i.applyJson1(c,l,s),u){case o.INSERT:r.addNotification(d),i.addNotification(d);break;case o.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case o.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case o.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case o.GROUP:r.groupUpdateNotification(d);break;case o.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const u=`SHEET_DRAWING_PLUGIN`;let d=class extends e.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(s))}_initSnapshot(){let t=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[e.UniverInstanceType.UNIVER_SHEET],toJson:(e,n)=>t(e,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===n.RemoveSheetCommand.id){var r;let n=t.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let c=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(c).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:s.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:o.REMOVE}}],undos:[{id:s.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:o.INSERT}}]}}else if(t.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=t.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),c=Object.values(a).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART).map(t=>({...t,subUnitId:i,drawingId:(0,e.generateRandomId)(6)}));if(c.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(c);return{redos:[{id:s.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:o.INSERT}}],undos:[{id:s.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:o.REMOVE}}]}}return{redos:[],undos:[]}}}))}};d=l([c(0,(0,e.Inject)(n.SheetInterceptorService)),c(1,(0,e.Inject)(e.IUniverInstanceService)),c(2,e.ICommandService),c(3,a),c(4,t.IDrawingManagerService),c(5,e.IResourceManagerService)],d);var f=`@univerjs/sheets-drawing`,p=`0.18.0`;const m=`sheets-drawing.config`;Symbol(m);const h={};function g(e){"@babel/helpers - typeof";return g=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends e.Plugin{constructor(t=h,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},h,this._config);this._configService.setConfig(m,i)}onStarting(){[[d],[a,{useClass:i}]].forEach(e=>this._injector.add(e)),this._injector.get(d)}};y(b,`pluginName`,u),y(b,`packageName`,f),y(b,`version`,p),y(b,`type`,e.UniverInstanceType.UNIVER_SHEET),b=l([(0,e.DependentOn)(t.UniverDrawingPlugin),c(1,(0,e.Inject)(e.Injector)),c(2,e.IConfigService)],b),exports.DrawingApplyType=o,exports.ISheetDrawingService=a,exports.SHEET_DRAWING_PLUGIN=u,exports.SetDrawingApplyMutation=s,exports.SheetDrawingAnchorType=r,Object.defineProperty(exports,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return b}});
|
package/lib/es/index.js
CHANGED
|
@@ -1,211 +1 @@
|
|
|
1
|
-
import
|
|
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
|
-
var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
|
|
5
|
-
class q extends A {
|
|
6
|
-
}
|
|
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
|
-
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type: M.MUTATION,
|
|
12
|
-
handler: (e, i) => {
|
|
13
|
-
const t = e.get(R), r = e.get(w), { 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
|
-
case 0:
|
|
16
|
-
t.addNotification(a), r.addNotification(a);
|
|
17
|
-
break;
|
|
18
|
-
case 1:
|
|
19
|
-
t.removeNotification(a), r.removeNotification(a);
|
|
20
|
-
break;
|
|
21
|
-
case 2:
|
|
22
|
-
t.updateNotification(a), r.updateNotification(a);
|
|
23
|
-
break;
|
|
24
|
-
case 3:
|
|
25
|
-
t.orderNotification(a), r.orderNotification(a);
|
|
26
|
-
break;
|
|
27
|
-
case 4:
|
|
28
|
-
t.groupUpdateNotification(a);
|
|
29
|
-
break;
|
|
30
|
-
case 5:
|
|
31
|
-
t.ungroupUpdateNotification(a);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
return !0;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
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
|
-
(o = e[s]) && (n = o(n) || n);
|
|
40
|
-
return n;
|
|
41
|
-
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
-
const l = "SHEET_DRAWING_PLUGIN";
|
|
43
|
-
let f = class extends H {
|
|
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(h));
|
|
46
|
-
}
|
|
47
|
-
_initSnapshot() {
|
|
48
|
-
const e = (t, r) => {
|
|
49
|
-
const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
|
|
50
|
-
return n ? JSON.stringify(n) : "";
|
|
51
|
-
}, i = (t) => {
|
|
52
|
-
if (!t)
|
|
53
|
-
return {};
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(t);
|
|
56
|
-
} catch {
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
this.disposeWithMe(
|
|
61
|
-
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName: l,
|
|
63
|
-
businesses: [p.UNIVER_SHEET],
|
|
64
|
-
toJson: (t, r) => e(t, r),
|
|
65
|
-
parseJson: (t) => i(t),
|
|
66
|
-
onUnLoad: (t) => {
|
|
67
|
-
this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
|
|
68
|
-
},
|
|
69
|
-
onLoad: (t, r) => {
|
|
70
|
-
this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
|
|
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 i;
|
|
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
|
-
if (!r || !n)
|
|
85
|
-
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
|
|
87
|
-
if (o.length === 0)
|
|
88
|
-
return { redos: [], undos: [] };
|
|
89
|
-
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
|
|
90
|
-
return {
|
|
91
|
-
redos: [
|
|
92
|
-
{
|
|
93
|
-
id: h.id,
|
|
94
|
-
params: {
|
|
95
|
-
op: U,
|
|
96
|
-
unitId: a,
|
|
97
|
-
subUnitId: g,
|
|
98
|
-
objects: _,
|
|
99
|
-
type: v.REMOVE
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
undos: [
|
|
104
|
-
{
|
|
105
|
-
id: h.id,
|
|
106
|
-
params: {
|
|
107
|
-
op: S,
|
|
108
|
-
unitId: a,
|
|
109
|
-
subUnitId: g,
|
|
110
|
-
objects: _,
|
|
111
|
-
type: v.INSERT
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
};
|
|
116
|
-
} else if (e.id === K.id) {
|
|
117
|
-
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
|
-
if (!r || !n || !s)
|
|
119
|
-
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
|
|
121
|
-
...N,
|
|
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: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
|
|
128
|
-
return {
|
|
129
|
-
redos: [
|
|
130
|
-
{
|
|
131
|
-
id: h.id,
|
|
132
|
-
params: {
|
|
133
|
-
op: _,
|
|
134
|
-
unitId: g,
|
|
135
|
-
subUnitId: S,
|
|
136
|
-
objects: I,
|
|
137
|
-
type: v.INSERT
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
undos: [
|
|
142
|
-
{
|
|
143
|
-
id: h.id,
|
|
144
|
-
params: {
|
|
145
|
-
op: U,
|
|
146
|
-
unitId: g,
|
|
147
|
-
subUnitId: S,
|
|
148
|
-
objects: I,
|
|
149
|
-
type: v.REMOVE
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return { redos: [], undos: [] };
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
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--)
|
|
175
|
-
(o = e[s]) && (n = o(n) || n);
|
|
176
|
-
return n;
|
|
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 {
|
|
179
|
-
constructor(e = b, i, t) {
|
|
180
|
-
super(), this._config = e, this._injector = i, this._configService = t;
|
|
181
|
-
const { ...r } = x(
|
|
182
|
-
{},
|
|
183
|
-
b,
|
|
184
|
-
this._config
|
|
185
|
-
);
|
|
186
|
-
this._configService.setConfig(y, r);
|
|
187
|
-
}
|
|
188
|
-
onStarting() {
|
|
189
|
-
[
|
|
190
|
-
[f],
|
|
191
|
-
[w, { useClass: q }]
|
|
192
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(f);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
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);
|
|
204
|
-
export {
|
|
205
|
-
v as DrawingApplyType,
|
|
206
|
-
w as ISheetDrawingService,
|
|
207
|
-
l as SHEET_DRAWING_PLUGIN,
|
|
208
|
-
h as SetDrawingApplyMutation,
|
|
209
|
-
Y as SheetDrawingAnchorType,
|
|
210
|
-
u as UniverSheetsDrawingPlugin
|
|
211
|
-
};
|
|
1
|
+
import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return 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}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const O=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.18.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};function P(e){"@babel/helpers - typeof";return P=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},P(e)}function F(e,t){if(P(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(P(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
|
package/lib/index.js
CHANGED
|
@@ -1,211 +1 @@
|
|
|
1
|
-
import
|
|
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
|
-
var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
|
|
5
|
-
class q extends A {
|
|
6
|
-
}
|
|
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
|
-
id: "sheet.mutation.set-drawing-apply",
|
|
11
|
-
type: M.MUTATION,
|
|
12
|
-
handler: (e, i) => {
|
|
13
|
-
const t = e.get(R), r = e.get(w), { 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
|
-
case 0:
|
|
16
|
-
t.addNotification(a), r.addNotification(a);
|
|
17
|
-
break;
|
|
18
|
-
case 1:
|
|
19
|
-
t.removeNotification(a), r.removeNotification(a);
|
|
20
|
-
break;
|
|
21
|
-
case 2:
|
|
22
|
-
t.updateNotification(a), r.updateNotification(a);
|
|
23
|
-
break;
|
|
24
|
-
case 3:
|
|
25
|
-
t.orderNotification(a), r.orderNotification(a);
|
|
26
|
-
break;
|
|
27
|
-
case 4:
|
|
28
|
-
t.groupUpdateNotification(a);
|
|
29
|
-
break;
|
|
30
|
-
case 5:
|
|
31
|
-
t.ungroupUpdateNotification(a);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
return !0;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
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
|
-
(o = e[s]) && (n = o(n) || n);
|
|
40
|
-
return n;
|
|
41
|
-
}, d = (e, i) => (t, r) => i(t, r, e);
|
|
42
|
-
const l = "SHEET_DRAWING_PLUGIN";
|
|
43
|
-
let f = class extends H {
|
|
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(h));
|
|
46
|
-
}
|
|
47
|
-
_initSnapshot() {
|
|
48
|
-
const e = (t, r) => {
|
|
49
|
-
const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
|
|
50
|
-
return n ? JSON.stringify(n) : "";
|
|
51
|
-
}, i = (t) => {
|
|
52
|
-
if (!t)
|
|
53
|
-
return {};
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(t);
|
|
56
|
-
} catch {
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
this.disposeWithMe(
|
|
61
|
-
this._resourceManagerService.registerPluginResource({
|
|
62
|
-
pluginName: l,
|
|
63
|
-
businesses: [p.UNIVER_SHEET],
|
|
64
|
-
toJson: (t, r) => e(t, r),
|
|
65
|
-
parseJson: (t) => i(t),
|
|
66
|
-
onUnLoad: (t) => {
|
|
67
|
-
this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
|
|
68
|
-
},
|
|
69
|
-
onLoad: (t, r) => {
|
|
70
|
-
this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
|
|
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 i;
|
|
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
|
-
if (!r || !n)
|
|
85
|
-
return { redos: [], undos: [] };
|
|
86
|
-
const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
|
|
87
|
-
if (o.length === 0)
|
|
88
|
-
return { redos: [], undos: [] };
|
|
89
|
-
const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
|
|
90
|
-
return {
|
|
91
|
-
redos: [
|
|
92
|
-
{
|
|
93
|
-
id: h.id,
|
|
94
|
-
params: {
|
|
95
|
-
op: U,
|
|
96
|
-
unitId: a,
|
|
97
|
-
subUnitId: g,
|
|
98
|
-
objects: _,
|
|
99
|
-
type: v.REMOVE
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
undos: [
|
|
104
|
-
{
|
|
105
|
-
id: h.id,
|
|
106
|
-
params: {
|
|
107
|
-
op: S,
|
|
108
|
-
unitId: a,
|
|
109
|
-
subUnitId: g,
|
|
110
|
-
objects: _,
|
|
111
|
-
type: v.INSERT
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
};
|
|
116
|
-
} else if (e.id === K.id) {
|
|
117
|
-
const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
|
|
118
|
-
if (!r || !n || !s)
|
|
119
|
-
return { redos: [], undos: [] };
|
|
120
|
-
const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
|
|
121
|
-
...N,
|
|
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: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
|
|
128
|
-
return {
|
|
129
|
-
redos: [
|
|
130
|
-
{
|
|
131
|
-
id: h.id,
|
|
132
|
-
params: {
|
|
133
|
-
op: _,
|
|
134
|
-
unitId: g,
|
|
135
|
-
subUnitId: S,
|
|
136
|
-
objects: I,
|
|
137
|
-
type: v.INSERT
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
undos: [
|
|
142
|
-
{
|
|
143
|
-
id: h.id,
|
|
144
|
-
params: {
|
|
145
|
-
op: U,
|
|
146
|
-
unitId: g,
|
|
147
|
-
subUnitId: S,
|
|
148
|
-
objects: I,
|
|
149
|
-
type: v.REMOVE
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return { redos: [], undos: [] };
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
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--)
|
|
175
|
-
(o = e[s]) && (n = o(n) || n);
|
|
176
|
-
return n;
|
|
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 {
|
|
179
|
-
constructor(e = b, i, t) {
|
|
180
|
-
super(), this._config = e, this._injector = i, this._configService = t;
|
|
181
|
-
const { ...r } = x(
|
|
182
|
-
{},
|
|
183
|
-
b,
|
|
184
|
-
this._config
|
|
185
|
-
);
|
|
186
|
-
this._configService.setConfig(y, r);
|
|
187
|
-
}
|
|
188
|
-
onStarting() {
|
|
189
|
-
[
|
|
190
|
-
[f],
|
|
191
|
-
[w, { useClass: q }]
|
|
192
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(f);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
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);
|
|
204
|
-
export {
|
|
205
|
-
v as DrawingApplyType,
|
|
206
|
-
w as ISheetDrawingService,
|
|
207
|
-
l as SHEET_DRAWING_PLUGIN,
|
|
208
|
-
h as SetDrawingApplyMutation,
|
|
209
|
-
Y as SheetDrawingAnchorType,
|
|
210
|
-
u as UniverSheetsDrawingPlugin
|
|
211
|
-
};
|
|
1
|
+
import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return 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}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const O=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.18.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};function P(e){"@babel/helpers - typeof";return P=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},P(e)}function F(e,t){if(P(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(P(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IMutation } from '@univerjs/core';
|
|
17
|
+
import type { IDrawingJson1Type } from '@univerjs/drawing';
|
|
3
18
|
export declare enum DrawingApplyType {
|
|
4
19
|
INSERT = 0,
|
|
5
20
|
REMOVE = 1,
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
2
17
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
3
18
|
import { SheetInterceptorService } from '@univerjs/sheets';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IUniverSheetsDrawingConfig } from './config/config';
|
|
2
17
|
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
18
|
export declare class UniverSheetsDrawingPlugin extends Plugin {
|
|
4
19
|
private readonly _config;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDrawingParam, IRotationSkewFlipTransform, Serializable } from '@univerjs/core';
|
|
17
|
+
import type { IImageData, IUnitDrawingService } from '@univerjs/drawing';
|
|
18
|
+
import type { ISheetOverGridPosition } from '@univerjs/sheets';
|
|
19
|
+
import { UnitDrawingService } from '@univerjs/drawing';
|
|
4
20
|
export declare enum SheetDrawingAnchorType {
|
|
5
21
|
/**
|
|
6
22
|
* Only the position of the drawing follows the cell changes. When rows or columns are inserted or deleted, the position of the drawing changes, but the size remains the same.
|
|
@@ -50,5 +66,5 @@ export declare class SheetDrawingService extends UnitDrawingService<ISheetDrawin
|
|
|
50
66
|
}
|
|
51
67
|
export interface ISheetDrawingService extends IUnitDrawingService<ISheetDrawing> {
|
|
52
68
|
}
|
|
53
|
-
export declare const ISheetDrawingService: import(
|
|
69
|
+
export declare const ISheetDrawingService: import("@wendellhu/redi").IdentifierDecorator<ISheetDrawingService>;
|
|
54
70
|
export {};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/drawing`),require(`@univerjs/sheets`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDrawing={},e.UniverCore,e.UniverDrawing,e.UniverSheets))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var a=class extends n.UnitDrawingService{};let o=(0,t.createIdentifier)(`sheets-drawing.sheet-drawing.service`),s=function(e){return 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={id:`sheet.mutation.set-drawing-apply`,type:t.CommandType.MUTATION,handler:(e,t)=>{let r=e.get(n.IDrawingManagerService),i=e.get(o),{op:a,unitId:c,subUnitId:l,type:u,objects:d}=t;switch(r.applyJson1(c,l,a),i.applyJson1(c,l,a),u){case s.INSERT:r.addNotification(d),i.addNotification(d);break;case s.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case s.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case s.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case s.GROUP:r.groupUpdateNotification(d);break;case s.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let d=`SHEET_DRAWING_PLUGIN`,f=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(c))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:d,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(o).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:c.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:s.REMOVE}}],undos:[{id:c.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:s.INSERT}}]}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),o=Object.values(a).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:(0,t.generateRandomId)(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:c.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:s.INSERT}}],undos:[{id:c.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:s.REMOVE}}]}}return{redos:[],undos:[]}}}))}};f=u([l(0,(0,t.Inject)(r.SheetInterceptorService)),l(1,(0,t.Inject)(t.IUniverInstanceService)),l(2,t.ICommandService),l(3,o),l(4,n.IDrawingManagerService),l(5,t.IResourceManagerService)],f);var p=`@univerjs/sheets-drawing`,m=`0.18.0`;let h=`sheets-drawing.config`;Symbol(h);let g={};function _(e){"@babel/helpers - typeof";return _=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let x=class extends t.Plugin{constructor(e=g,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},g,this._config);this._configService.setConfig(h,i)}onStarting(){[[f],[o,{useClass:a}]].forEach(e=>this._injector.add(e)),this._injector.get(f)}};b(x,`pluginName`,d),b(x,`packageName`,p),b(x,`version`,m),b(x,`type`,t.UniverInstanceType.UNIVER_SHEET),x=u([(0,t.DependentOn)(n.UniverDrawingPlugin),l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService)],x),e.DrawingApplyType=s,e.ISheetDrawingService=o,e.SHEET_DRAWING_PLUGIN=d,e.SetDrawingApplyMutation=c,e.SheetDrawingAnchorType=i,Object.defineProperty(e,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return x}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -43,22 +43,23 @@
|
|
|
43
43
|
"lib"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@univerjs/core": "0.
|
|
47
|
-
"@univerjs/sheets": "0.
|
|
48
|
-
"@univerjs/drawing": "0.
|
|
46
|
+
"@univerjs/core": "0.18.0",
|
|
47
|
+
"@univerjs/sheets": "0.18.0",
|
|
48
|
+
"@univerjs/drawing": "0.18.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"@univerjs-infra/shared": "0.17.0"
|
|
52
|
+
"vitest": "^4.1.0",
|
|
53
|
+
"@univerjs-infra/shared": "0.18.0"
|
|
55
54
|
},
|
|
56
55
|
"scripts": {
|
|
57
56
|
"test": "vitest run",
|
|
58
57
|
"test:watch": "vitest",
|
|
59
58
|
"coverage": "vitest run --coverage",
|
|
60
59
|
"typecheck": "tsc --noEmit",
|
|
61
|
-
"build": "univer-cli build"
|
|
60
|
+
"build:bundle": "univer-cli build",
|
|
61
|
+
"build:types": "tsc -p tsconfig.node.json",
|
|
62
|
+
"build": "pnpm run build:bundle && pnpm run build:types"
|
|
62
63
|
},
|
|
63
64
|
"module": "./lib/es/index.js"
|
|
64
65
|
}
|