@univerjs/sheets-drawing 0.4.2 → 0.5.0-beta.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 CHANGED
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),drawing=require("@univerjs/drawing"),PLUGIN_CONFIG_KEY="sheets-drawing.config",defaultPluginConfig={};var SheetDrawingAnchorType=(SheetDrawingAnchorType2=>(SheetDrawingAnchorType2.Position="0",SheetDrawingAnchorType2.Both="1",SheetDrawingAnchorType2.None="2",SheetDrawingAnchorType2))(SheetDrawingAnchorType||{});const _SheetDrawingService=class _SheetDrawingService extends drawing.UnitDrawingService{};__name(_SheetDrawingService,"SheetDrawingService");let SheetDrawingService=_SheetDrawingService;const ISheetDrawingService=core.createIdentifier("sheets-drawing.sheet-drawing.service");var DrawingApplyType=(DrawingApplyType2=>(DrawingApplyType2[DrawingApplyType2.INSERT=0]="INSERT",DrawingApplyType2[DrawingApplyType2.REMOVE=1]="REMOVE",DrawingApplyType2[DrawingApplyType2.UPDATE=2]="UPDATE",DrawingApplyType2[DrawingApplyType2.ARRANGE=3]="ARRANGE",DrawingApplyType2[DrawingApplyType2.GROUP=4]="GROUP",DrawingApplyType2[DrawingApplyType2.UNGROUP=5]="UNGROUP",DrawingApplyType2))(DrawingApplyType||{});const SetDrawingApplyMutation={id:"sheet.mutation.set-drawing-apply",type:core.CommandType.MUTATION,handler:__name((accessor,params)=>{const drawingManagerService=accessor.get(drawing.IDrawingManagerService),sheetDrawingService=accessor.get(ISheetDrawingService),{op,unitId,subUnitId,type,objects}=params;switch(drawingManagerService.applyJson1(unitId,subUnitId,op),sheetDrawingService.applyJson1(unitId,subUnitId,op),type){case 0:drawingManagerService.addNotification(objects),sheetDrawingService.addNotification(objects);break;case 1:drawingManagerService.removeNotification(objects),sheetDrawingService.removeNotification(objects);break;case 2:drawingManagerService.updateNotification(objects),sheetDrawingService.updateNotification(objects);break;case 3:drawingManagerService.orderNotification(objects),sheetDrawingService.orderNotification(objects);break;case 4:drawingManagerService.groupUpdateNotification(objects);break;case 5:drawingManagerService.ungroupUpdateNotification(objects);break}return!0},"handler")};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const SHEET_DRAWING_PLUGIN="SHEET_DRAWING_PLUGIN";var _a;let SheetsDrawingLoadController=(_a=class extends core.Disposable{constructor(_commandService,_sheetDrawingService,_drawingManagerService,_resourceManagerService){super(),this._commandService=_commandService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}_initSnapshot(){const toJson=__name((unitId,model)=>{const map=model||this._sheetDrawingService.getDrawingDataForUnit(unitId);return map?JSON.stringify(map):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:SHEET_DRAWING_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_SHEET],toJson:__name((unitId,model)=>toJson(unitId,model),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitId=>{this._sheetDrawingService.removeDrawingDataForUnit(unitId),this._drawingManagerService.removeDrawingDataForUnit(unitId)},"onUnLoad"),onLoad:__name((unitId,value)=>{this._sheetDrawingService.registerDrawingData(unitId,value),this._drawingManagerService.registerDrawingData(unitId,value)},"onLoad")}))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([__decorateParam$1(0,core.ICommandService),__decorateParam$1(1,ISheetDrawingService),__decorateParam$1(2,drawing.IDrawingManagerService),__decorateParam$1(3,core.IResourceManagerService)],SheetsDrawingLoadController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField=__name((obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a2;exports.UniverSheetsDrawingPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency)),this._injector.get(SheetsDrawingLoadController)}},__name(_a2,"UniverSheetsDrawingPlugin"),_a2);__publicField(exports.UniverSheetsDrawingPlugin,"pluginName",SHEET_DRAWING_PLUGIN);__publicField(exports.UniverSheetsDrawingPlugin,"type",core.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=__decorateClass([core.DependentOn(drawing.UniverDrawingPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=DrawingApplyType;exports.ISheetDrawingService=ISheetDrawingService;exports.SHEET_DRAWING_PLUGIN=SHEET_DRAWING_PLUGIN;exports.SetDrawingApplyMutation=SetDrawingApplyMutation;exports.SheetDrawingAnchorType=SheetDrawingAnchorType;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),u=require("@univerjs/drawing"),D="sheets-drawing.config",w={};var d=(e=>(e.Position="0",e.Both="1",e.None="2",e))(d||{});class I extends u.UnitDrawingService{}const _=a.createIdentifier("sheets-drawing.sheet-drawing.service");var f=(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))(f||{});const N={id:"sheet.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(e,i)=>{const r=e.get(u.IDrawingManagerService),t=e.get(_),{op:n,unitId:s,subUnitId:o,type:l,objects:c}=i;switch(r.applyJson1(s,o,n),t.applyJson1(s,o,n),l){case 0:r.addNotification(c),t.addNotification(c);break;case 1:r.removeNotification(c),t.removeNotification(c);break;case 2:r.updateNotification(c),t.updateNotification(c);break;case 3:r.orderNotification(c),t.orderNotification(c);break;case 4:r.groupUpdateNotification(c);break;case 5:r.ungroupUpdateNotification(c);break}return!0}};var m=Object.defineProperty,E=Object.getOwnPropertyDescriptor,p=(e,i,r,t)=>{for(var n=t>1?void 0:t?E(i,r):i,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(t?o(i,r,n):o(n))||n);return t&&n&&m(i,r,n),n},g=(e,i)=>(r,t)=>i(r,t,e);const h="SHEET_DRAWING_PLUGIN";let v=class extends a.Disposable{constructor(e,i,r,t){super(),this._commandService=e,this._sheetDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=t,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(N))}_initSnapshot(){const e=(r,t)=>{const n=t||this._sheetDrawingService.getDrawingDataForUnit(r);return n?JSON.stringify(n):""},i=r=>{if(!r)return{};try{return JSON.parse(r)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:h,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:(r,t)=>e(r,t),parseJson:r=>i(r),onUnLoad:r=>{this._sheetDrawingService.removeDrawingDataForUnit(r),this._drawingManagerService.removeDrawingDataForUnit(r)},onLoad:(r,t)=>{this._sheetDrawingService.registerDrawingData(r,t),this._drawingManagerService.registerDrawingData(r,t)}}))}};v=p([g(0,a.ICommandService),g(1,_),g(2,u.IDrawingManagerService),g(3,a.IResourceManagerService)],v);var P=Object.defineProperty,O=Object.getOwnPropertyDescriptor,b=(e,i,r)=>i in e?P(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,R=(e,i,r,t)=>{for(var n=t>1?void 0:t?O(i,r):i,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(t?o(i,r,n):o(n))||n);return t&&n&&P(i,r,n),n},S=(e,i)=>(r,t)=>i(r,t,e),U=(e,i,r)=>b(e,typeof i!="symbol"?i+"":i,r);exports.UniverSheetsDrawingPlugin=class extends a.Plugin{constructor(i=w,r,t){super(),this._config=i,this._injector=r,this._configService=t;const{...n}=this._config;this._configService.setConfig(D,n)}onStarting(){[[v],[_,{useClass:I}]].forEach(i=>this._injector.add(i)),this._injector.get(v)}};U(exports.UniverSheetsDrawingPlugin,"pluginName",h);U(exports.UniverSheetsDrawingPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=R([a.DependentOn(u.UniverDrawingPlugin),S(1,a.Inject(a.Injector)),S(2,a.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=f;exports.ISheetDrawingService=_;exports.SHEET_DRAWING_PLUGIN=h;exports.SetDrawingApplyMutation=N;exports.SheetDrawingAnchorType=d;
package/lib/es/index.js CHANGED
@@ -1,119 +1,114 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
3
- import { createIdentifier, CommandType, Disposable, UniverInstanceType, ICommandService, IResourceManagerService, DependentOn, Inject, Injector, Plugin, IConfigService } from "@univerjs/core";
4
- import { UnitDrawingService, IDrawingManagerService, UniverDrawingPlugin } from "@univerjs/drawing";
5
- const PLUGIN_CONFIG_KEY = "sheets-drawing.config", defaultPluginConfig = {};
6
- var SheetDrawingAnchorType = /* @__PURE__ */ ((SheetDrawingAnchorType2) => (SheetDrawingAnchorType2.Position = "0", SheetDrawingAnchorType2.Both = "1", SheetDrawingAnchorType2.None = "2", SheetDrawingAnchorType2))(SheetDrawingAnchorType || {});
7
- const _SheetDrawingService = class _SheetDrawingService extends UnitDrawingService {
8
- };
9
- __name(_SheetDrawingService, "SheetDrawingService");
10
- let SheetDrawingService = _SheetDrawingService;
11
- const ISheetDrawingService = createIdentifier("sheets-drawing.sheet-drawing.service");
12
- var DrawingApplyType = /* @__PURE__ */ ((DrawingApplyType2) => (DrawingApplyType2[DrawingApplyType2.INSERT = 0] = "INSERT", DrawingApplyType2[DrawingApplyType2.REMOVE = 1] = "REMOVE", DrawingApplyType2[DrawingApplyType2.UPDATE = 2] = "UPDATE", DrawingApplyType2[DrawingApplyType2.ARRANGE = 3] = "ARRANGE", DrawingApplyType2[DrawingApplyType2.GROUP = 4] = "GROUP", DrawingApplyType2[DrawingApplyType2.UNGROUP = 5] = "UNGROUP", DrawingApplyType2))(DrawingApplyType || {});
13
- const SetDrawingApplyMutation = {
1
+ import { createIdentifier as P, CommandType as U, Disposable as l, UniverInstanceType as h, ICommandService as E, IResourceManagerService as D, DependentOn as I, Inject as w, Injector as O, Plugin as R, IConfigService as b } from "@univerjs/core";
2
+ import { UnitDrawingService as p, IDrawingManagerService as f, UniverDrawingPlugin as M } from "@univerjs/drawing";
3
+ const G = "sheets-drawing.config", C = {};
4
+ var J = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(J || {});
5
+ class j extends p {
6
+ }
7
+ const v = P("sheets-drawing.sheet-drawing.service");
8
+ var L = /* @__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))(L || {});
9
+ const F = {
14
10
  id: "sheet.mutation.set-drawing-apply",
15
- type: CommandType.MUTATION,
16
- handler: /* @__PURE__ */ __name((accessor, params) => {
17
- const drawingManagerService = accessor.get(IDrawingManagerService), sheetDrawingService = accessor.get(ISheetDrawingService), { op, unitId, subUnitId, type, objects } = params;
18
- switch (drawingManagerService.applyJson1(unitId, subUnitId, op), sheetDrawingService.applyJson1(unitId, subUnitId, op), type) {
11
+ type: U.MUTATION,
12
+ handler: (e, i) => {
13
+ const r = e.get(f), t = e.get(v), { op: n, unitId: a, subUnitId: s, type: m, objects: o } = i;
14
+ switch (r.applyJson1(a, s, n), t.applyJson1(a, s, n), m) {
19
15
  case 0:
20
- drawingManagerService.addNotification(objects), sheetDrawingService.addNotification(objects);
16
+ r.addNotification(o), t.addNotification(o);
21
17
  break;
22
18
  case 1:
23
- drawingManagerService.removeNotification(objects), sheetDrawingService.removeNotification(objects);
19
+ r.removeNotification(o), t.removeNotification(o);
24
20
  break;
25
21
  case 2:
26
- drawingManagerService.updateNotification(objects), sheetDrawingService.updateNotification(objects);
22
+ r.updateNotification(o), t.updateNotification(o);
27
23
  break;
28
24
  case 3:
29
- drawingManagerService.orderNotification(objects), sheetDrawingService.orderNotification(objects);
25
+ r.orderNotification(o), t.orderNotification(o);
30
26
  break;
31
27
  case 4:
32
- drawingManagerService.groupUpdateNotification(objects);
28
+ r.groupUpdateNotification(o);
33
29
  break;
34
30
  case 5:
35
- drawingManagerService.ungroupUpdateNotification(objects);
31
+ r.ungroupUpdateNotification(o);
36
32
  break;
37
33
  }
38
34
  return !0;
39
- }, "handler")
35
+ }
40
36
  };
41
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
42
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
43
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
44
- return kind && result && __defProp$1(target, key, result), result;
45
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
46
- const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
47
- var _a;
48
- let SheetsDrawingLoadController = (_a = class extends Disposable {
49
- constructor(_commandService, _sheetDrawingService, _drawingManagerService, _resourceManagerService) {
50
- super(), this._commandService = _commandService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._initSnapshot(), this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
37
+ var x = Object.defineProperty, H = Object.getOwnPropertyDescriptor, V = (e, i, r, t) => {
38
+ for (var n = t > 1 ? void 0 : t ? H(i, r) : i, a = e.length - 1, s; a >= 0; a--)
39
+ (s = e[a]) && (n = (t ? s(i, r, n) : s(n)) || n);
40
+ return t && n && x(i, r, n), n;
41
+ }, c = (e, i) => (r, t) => i(r, t, e);
42
+ const d = "SHEET_DRAWING_PLUGIN";
43
+ let g = class extends l {
44
+ constructor(e, i, r, t) {
45
+ super(), this._commandService = e, this._sheetDrawingService = i, this._drawingManagerService = r, this._resourceManagerService = t, this._initSnapshot(), this.disposeWithMe(this._commandService.registerCommand(F));
51
46
  }
52
47
  _initSnapshot() {
53
- const toJson = /* @__PURE__ */ __name((unitId, model) => {
54
- const map = model || this._sheetDrawingService.getDrawingDataForUnit(unitId);
55
- return map ? JSON.stringify(map) : "";
56
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
57
- if (!json)
48
+ const e = (r, t) => {
49
+ const n = t || this._sheetDrawingService.getDrawingDataForUnit(r);
50
+ return n ? JSON.stringify(n) : "";
51
+ }, i = (r) => {
52
+ if (!r)
58
53
  return {};
59
54
  try {
60
- return JSON.parse(json);
55
+ return JSON.parse(r);
61
56
  } catch {
62
57
  return {};
63
58
  }
64
- }, "parseJson");
59
+ };
65
60
  this.disposeWithMe(
66
61
  this._resourceManagerService.registerPluginResource({
67
- pluginName: SHEET_DRAWING_PLUGIN,
68
- businesses: [UniverInstanceType.UNIVER_SHEET],
69
- toJson: /* @__PURE__ */ __name((unitId, model) => toJson(unitId, model), "toJson"),
70
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
71
- onUnLoad: /* @__PURE__ */ __name((unitId) => {
72
- this._sheetDrawingService.removeDrawingDataForUnit(unitId), this._drawingManagerService.removeDrawingDataForUnit(unitId);
73
- }, "onUnLoad"),
74
- onLoad: /* @__PURE__ */ __name((unitId, value) => {
75
- this._sheetDrawingService.registerDrawingData(unitId, value), this._drawingManagerService.registerDrawingData(unitId, value);
76
- }, "onLoad")
62
+ pluginName: d,
63
+ businesses: [h.UNIVER_SHEET],
64
+ toJson: (r, t) => e(r, t),
65
+ parseJson: (r) => i(r),
66
+ onUnLoad: (r) => {
67
+ this._sheetDrawingService.removeDrawingDataForUnit(r), this._drawingManagerService.removeDrawingDataForUnit(r);
68
+ },
69
+ onLoad: (r, t) => {
70
+ this._sheetDrawingService.registerDrawingData(r, t), this._drawingManagerService.registerDrawingData(r, t);
71
+ }
77
72
  })
78
73
  );
79
74
  }
80
- }, __name(_a, "SheetsDrawingLoadController"), _a);
81
- SheetsDrawingLoadController = __decorateClass$1([
82
- __decorateParam$1(0, ICommandService),
83
- __decorateParam$1(1, ISheetDrawingService),
84
- __decorateParam$1(2, IDrawingManagerService),
85
- __decorateParam$1(3, IResourceManagerService)
86
- ], SheetsDrawingLoadController);
87
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
88
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
89
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
90
- return kind && result && __defProp2(target, key, result), result;
91
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a2;
92
- let UniverSheetsDrawingPlugin = (_a2 = class extends Plugin {
93
- constructor(_config = defaultPluginConfig, _injector, _configService) {
94
- super(), this._config = _config, this._injector = _injector, this._configService = _configService;
95
- const { ...rest } = this._config;
96
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
75
+ };
76
+ g = V([
77
+ c(0, E),
78
+ c(1, v),
79
+ c(2, f),
80
+ c(3, D)
81
+ ], g);
82
+ var S = Object.defineProperty, W = Object.getOwnPropertyDescriptor, $ = (e, i, r) => i in e ? S(e, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[i] = r, B = (e, i, r, t) => {
83
+ for (var n = t > 1 ? void 0 : t ? W(i, r) : i, a = e.length - 1, s; a >= 0; a--)
84
+ (s = e[a]) && (n = (t ? s(i, r, n) : s(n)) || n);
85
+ return t && n && S(i, r, n), n;
86
+ }, u = (e, i) => (r, t) => i(r, t, e), N = (e, i, r) => $(e, typeof i != "symbol" ? i + "" : i, r);
87
+ let _ = class extends R {
88
+ constructor(e = C, i, r) {
89
+ super(), this._config = e, this._injector = i, this._configService = r;
90
+ const { ...t } = this._config;
91
+ this._configService.setConfig(G, t);
97
92
  }
98
93
  onStarting() {
99
94
  [
100
- [SheetsDrawingLoadController],
101
- [ISheetDrawingService, { useClass: SheetDrawingService }]
102
- ].forEach((dependency) => this._injector.add(dependency)), this._injector.get(SheetsDrawingLoadController);
95
+ [g],
96
+ [v, { useClass: j }]
97
+ ].forEach((e) => this._injector.add(e)), this._injector.get(g);
103
98
  }
104
- }, __name(_a2, "UniverSheetsDrawingPlugin"), _a2);
105
- __publicField(UniverSheetsDrawingPlugin, "pluginName", SHEET_DRAWING_PLUGIN);
106
- __publicField(UniverSheetsDrawingPlugin, "type", UniverInstanceType.UNIVER_SHEET);
107
- UniverSheetsDrawingPlugin = __decorateClass([
108
- DependentOn(UniverDrawingPlugin),
109
- __decorateParam(1, Inject(Injector)),
110
- __decorateParam(2, IConfigService)
111
- ], UniverSheetsDrawingPlugin);
99
+ };
100
+ N(_, "pluginName", d);
101
+ N(_, "type", h.UNIVER_SHEET);
102
+ _ = B([
103
+ I(M),
104
+ u(1, w(O)),
105
+ u(2, b)
106
+ ], _);
112
107
  export {
113
- DrawingApplyType,
114
- ISheetDrawingService,
115
- SHEET_DRAWING_PLUGIN,
116
- SetDrawingApplyMutation,
117
- SheetDrawingAnchorType,
118
- UniverSheetsDrawingPlugin
108
+ L as DrawingApplyType,
109
+ v as ISheetDrawingService,
110
+ d as SHEET_DRAWING_PLUGIN,
111
+ F as SetDrawingApplyMutation,
112
+ J as SheetDrawingAnchorType,
113
+ _ as UniverSheetsDrawingPlugin
119
114
  };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDrawing={},global.UniverCore,global.UniverDrawing))})(this,function(exports2,core,drawing){"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var _a,_b;const PLUGIN_CONFIG_KEY="sheets-drawing.config",defaultPluginConfig={};var SheetDrawingAnchorType=(SheetDrawingAnchorType2=>(SheetDrawingAnchorType2.Position="0",SheetDrawingAnchorType2.Both="1",SheetDrawingAnchorType2.None="2",SheetDrawingAnchorType2))(SheetDrawingAnchorType||{});const _SheetDrawingService=class _SheetDrawingService extends drawing.UnitDrawingService{};__name(_SheetDrawingService,"SheetDrawingService");let SheetDrawingService=_SheetDrawingService;const ISheetDrawingService=core.createIdentifier("sheets-drawing.sheet-drawing.service");var DrawingApplyType=(DrawingApplyType2=>(DrawingApplyType2[DrawingApplyType2.INSERT=0]="INSERT",DrawingApplyType2[DrawingApplyType2.REMOVE=1]="REMOVE",DrawingApplyType2[DrawingApplyType2.UPDATE=2]="UPDATE",DrawingApplyType2[DrawingApplyType2.ARRANGE=3]="ARRANGE",DrawingApplyType2[DrawingApplyType2.GROUP=4]="GROUP",DrawingApplyType2[DrawingApplyType2.UNGROUP=5]="UNGROUP",DrawingApplyType2))(DrawingApplyType||{});const SetDrawingApplyMutation={id:"sheet.mutation.set-drawing-apply",type:core.CommandType.MUTATION,handler:__name((accessor,params)=>{const drawingManagerService=accessor.get(drawing.IDrawingManagerService),sheetDrawingService=accessor.get(ISheetDrawingService),{op,unitId,subUnitId,type,objects}=params;switch(drawingManagerService.applyJson1(unitId,subUnitId,op),sheetDrawingService.applyJson1(unitId,subUnitId,op),type){case 0:drawingManagerService.addNotification(objects),sheetDrawingService.addNotification(objects);break;case 1:drawingManagerService.removeNotification(objects),sheetDrawingService.removeNotification(objects);break;case 2:drawingManagerService.updateNotification(objects),sheetDrawingService.updateNotification(objects);break;case 3:drawingManagerService.orderNotification(objects),sheetDrawingService.orderNotification(objects);break;case 4:drawingManagerService.groupUpdateNotification(objects);break;case 5:drawingManagerService.ungroupUpdateNotification(objects);break}return!0},"handler")};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const SHEET_DRAWING_PLUGIN="SHEET_DRAWING_PLUGIN";let SheetsDrawingLoadController=(_a=class extends core.Disposable{constructor(_commandService,_sheetDrawingService,_drawingManagerService,_resourceManagerService){super(),this._commandService=_commandService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}_initSnapshot(){const toJson=__name((unitId,model)=>{const map=model||this._sheetDrawingService.getDrawingDataForUnit(unitId);return map?JSON.stringify(map):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:SHEET_DRAWING_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_SHEET],toJson:__name((unitId,model)=>toJson(unitId,model),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitId=>{this._sheetDrawingService.removeDrawingDataForUnit(unitId),this._drawingManagerService.removeDrawingDataForUnit(unitId)},"onUnLoad"),onLoad:__name((unitId,value)=>{this._sheetDrawingService.registerDrawingData(unitId,value),this._drawingManagerService.registerDrawingData(unitId,value)},"onLoad")}))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([__decorateParam$1(0,core.ICommandService),__decorateParam$1(1,ISheetDrawingService),__decorateParam$1(2,drawing.IDrawingManagerService),__decorateParam$1(3,core.IResourceManagerService)],SheetsDrawingLoadController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField=__name((obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsDrawingPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency)),this._injector.get(SheetsDrawingLoadController)}},__name(_b,"UniverSheetsDrawingPlugin"),_b),__publicField(exports2.UniverSheetsDrawingPlugin,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(exports2.UniverSheetsDrawingPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsDrawingPlugin=__decorateClass([core.DependentOn(drawing.UniverDrawingPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverSheetsDrawingPlugin),exports2.DrawingApplyType=DrawingApplyType,exports2.ISheetDrawingService=ISheetDrawingService,exports2.SHEET_DRAWING_PLUGIN=SHEET_DRAWING_PLUGIN,exports2.SetDrawingApplyMutation=SetDrawingApplyMutation,exports2.SheetDrawingAnchorType=SheetDrawingAnchorType,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing))})(this,function(a,s,u){"use strict";const w="sheets-drawing.config",l={};var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class m extends u.UnitDrawingService{}const v=s.createIdentifier("sheets-drawing.sheet-drawing.service");var d=(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))(d||{});const U={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,r)=>{const i=e.get(u.IDrawingManagerService),n=e.get(v),{op:t,unitId:o,subUnitId:c,type:M,objects:g}=r;switch(i.applyJson1(o,c,t),n.applyJson1(o,c,t),M){case 0:i.addNotification(g),n.addNotification(g);break;case 1:i.removeNotification(g),n.removeNotification(g);break;case 2:i.updateNotification(g),n.updateNotification(g);break;case 3:i.orderNotification(g),n.orderNotification(g);break;case 4:i.groupUpdateNotification(g);break;case 5:i.ungroupUpdateNotification(g);break}return!0}};var I=Object.defineProperty,E=Object.getOwnPropertyDescriptor,O=(e,r,i,n)=>{for(var t=n>1?void 0:n?E(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&I(r,i,t),t},h=(e,r)=>(i,n)=>r(i,n,e);const _="SHEET_DRAWING_PLUGIN";let S=class extends s.Disposable{constructor(e,r,i,n){super(),this._commandService=e,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=n,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(U))}_initSnapshot(){const e=(i,n)=>{const t=n||this._sheetDrawingService.getDrawingDataForUnit(i);return t?JSON.stringify(t):""},r=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(i,n)=>e(i,n),parseJson:i=>r(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,n)=>{this._sheetDrawingService.registerDrawingData(i,n),this._drawingManagerService.registerDrawingData(i,n)}}))}};S=O([h(0,s.ICommandService),h(1,v),h(2,u.IDrawingManagerService),h(3,s.IResourceManagerService)],S);var D=Object.defineProperty,R=Object.getOwnPropertyDescriptor,b=(e,r,i)=>r in e?D(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i,p=(e,r,i,n)=>{for(var t=n>1?void 0:n?R(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&D(r,i,t),t},N=(e,r)=>(i,n)=>r(i,n,e),P=(e,r,i)=>b(e,typeof r!="symbol"?r+"":r,i);a.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=l,i,n){super(),this._config=r,this._injector=i,this._configService=n;const{...t}=this._config;this._configService.setConfig(w,t)}onStarting(){[[S],[v,{useClass:m}]].forEach(r=>this._injector.add(r)),this._injector.get(S)}},P(a.UniverSheetsDrawingPlugin,"pluginName",_),P(a.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=p([s.DependentOn(u.UniverDrawingPlugin),N(1,s.Inject(s.Injector)),N(2,s.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=d,a.ISheetDrawingService=v,a.SHEET_DRAWING_PLUGIN=_,a.SetDrawingApplyMutation=U,a.SheetDrawingAnchorType=f,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.4.2",
3
+ "version": "0.5.0-beta.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -31,8 +31,7 @@
31
31
  },
32
32
  "./lib/*": "./lib/*"
33
33
  },
34
- "main": "./lib/cjs/index.js",
35
- "module": "./lib/es/index.js",
34
+ "main": "./lib/es/index.js",
36
35
  "types": "./lib/types/index.d.ts",
37
36
  "publishConfig": {
38
37
  "access": "public"
@@ -43,21 +42,17 @@
43
42
  "files": [
44
43
  "lib"
45
44
  ],
46
- "peerDependencies": {
47
- "@univerjs/core": "0.4.2",
48
- "@univerjs/drawing": "0.4.2"
49
- },
50
45
  "dependencies": {
51
- "@univerjs/core": "0.4.2",
52
- "@univerjs/drawing": "0.4.2"
46
+ "@univerjs/core": "0.5.0-beta.0",
47
+ "@univerjs/drawing": "0.5.0-beta.0"
53
48
  },
54
49
  "devDependencies": {
55
50
  "typescript": "^5.6.3",
56
- "vite": "^5.4.8",
57
- "vitest": "^2.1.2",
58
- "@univerjs-infra/shared": "0.4.2"
51
+ "vite": "^5.4.11",
52
+ "vitest": "^2.1.5",
53
+ "@univerjs-infra/shared": "0.5.0-beta.0"
59
54
  },
60
- "univerSpace": {
55
+ "space": {
61
56
  ".": {
62
57
  "import": "./lib/es/index.js",
63
58
  "require": "./lib/cjs/index.js",
@@ -75,6 +70,7 @@
75
70
  "test:watch": "vitest",
76
71
  "coverage": "vitest run --coverage",
77
72
  "lint:types": "tsc --noEmit",
78
- "build": "tsc && vite build"
79
- }
73
+ "build": "univer-cli build"
74
+ },
75
+ "module": "./lib/es/index.js"
80
76
  }