@univerjs/sheets-drawing 0.2.5 → 0.2.6

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 P=Object.defineProperty;var E=(e,t,i)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var _=(e,t,i)=>E(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),d=require("@univerjs/drawing"),l=require("rxjs/operators");var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class p extends d.UnitDrawingService{}const h=a.createIdentifier("sheets-drawing.sheet-drawing.service");var I=(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))(I||{});const U={id:"sheet.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(e,t)=>{const i=e.get(d.IDrawingManagerService),r=e.get(h),{op:n,unitId:s,subUnitId:c,type:D,objects:o}=t;switch(i.applyJson1(s,c,n),r.applyJson1(s,c,n),D){case 0:i.addNotification(o),r.addNotification(o);break;case 1:i.removeNotification(o),r.removeNotification(o);break;case 2:i.updateNotification(o),r.updateNotification(o);break;case 3:i.orderNotification(o),r.orderNotification(o);break;case 4:i.groupUpdateNotification(o);break;case 5:i.ungroupUpdateNotification(o);break}return!0}};var m=Object.defineProperty,O=Object.getOwnPropertyDescriptor,N=(e,t,i,r)=>{for(var n=r>1?void 0:r?O(t,i):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(n=(r?c(t,i,n):c(n))||n);return r&&n&&m(t,i,n),n},v=(e,t)=>(i,r)=>t(i,r,e);const w="SHEET_DRAWING_PLUGIN";let S=class extends a.Disposable{constructor(e){super(),this._commandService=e,this.disposeWithMe(this._commandService.registerCommand(U))}};S=N([a.OnLifecycle(a.LifecycleStages.Starting,S),v(0,a.ICommandService)],S);let u=class extends a.Disposable{constructor(e,t,i,r,n){super(),this._sheetDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=i,this._lifecycleService=r,this._univerInstanceService=n,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const e=i=>{const r=this._sheetDrawingService.getDrawingDataForUnit(i);return r?JSON.stringify(r):""},t=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:i=>e(i),parseJson:i=>t(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,r)=>{this._sheetDrawingService.registerDrawingData(i,r)}}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(l.filter(e=>e===a.LifecycleStages.Steady),l.first()).subscribe(()=>{var t;const e=(t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId();e&&this._sheetDrawingService.initializeNotification(e)})}};u=N([a.OnLifecycle(a.LifecycleStages.Starting,u),v(0,h),v(1,d.IDrawingManagerService),v(2,a.IResourceManagerService),v(3,a.Inject(a.LifecycleService)),v(4,a.IUniverInstanceService)],u);var b=Object.defineProperty,R=Object.getOwnPropertyDescriptor,M=(e,t,i,r)=>{for(var n=r>1?void 0:r?R(t,i):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(n=(r?c(t,i,n):c(n))||n);return r&&n&&b(t,i,n),n},L=(e,t)=>(i,r)=>t(i,r,e),g;exports.UniverSheetsDrawingPlugin=(g=class extends a.Plugin{constructor(t,i){super(),this._config=t,this._injector=i}onStarting(t){[[S],[u],[h,{useClass:p}]].forEach(i=>t.add(i))}},_(g,"pluginName",w),_(g,"type",a.UniverInstanceType.UNIVER_SHEET),g);exports.UniverSheetsDrawingPlugin=M([L(1,a.Inject(a.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=I;exports.ISheetDrawingService=h;exports.SetDrawingApplyMutation=U;exports.SheetDrawingAnchorType=f;
1
+ "use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),drawing=require("@univerjs/drawing"),operators=require("rxjs/operators");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){super(),this._commandService=_commandService,this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService)],SheetsDrawingLoadController);var _a2;let SheetsDrawingController=(_a2=class extends core.Disposable{constructor(_sheetDrawingService,_drawingManagerService,_resourceManagerService,_lifecycleService,_univerInstanceService){super(),this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._lifecycleService=_lifecycleService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const toJson=__name(unitId=>{const map=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=>toJson(unitId),"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)},"onLoad")}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(operators.filter(e=>e===core.LifecycleStages.Steady),operators.first()).subscribe(()=>{var _a4;const unitId=(_a4=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a4.getUnitId();unitId&&this._sheetDrawingService.initializeNotification(unitId)})}},__name(_a2,"SheetsDrawingController"),_a2);SheetsDrawingController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingController),__decorateParam$1(0,ISheetDrawingService),__decorateParam$1(1,drawing.IDrawingManagerService),__decorateParam$1(2,core.IResourceManagerService),__decorateParam$1(3,core.Inject(core.LifecycleService)),__decorateParam$1(4,core.IUniverInstanceService)],SheetsDrawingController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__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"),_a3;exports.UniverSheetsDrawingPlugin=(_a3=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[SheetsDrawingController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_a3,"UniverSheetsDrawingPlugin"),__publicField(_a3,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_SHEET),_a3);exports.UniverSheetsDrawingPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=DrawingApplyType;exports.ISheetDrawingService=ISheetDrawingService;exports.SetDrawingApplyMutation=SetDrawingApplyMutation;exports.SheetDrawingAnchorType=SheetDrawingAnchorType;
package/lib/es/index.js CHANGED
@@ -1,132 +1,137 @@
1
- var R = Object.defineProperty;
2
- var w = (e, i, t) => i in e ? R(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
- var u = (e, i, t) => w(e, typeof i != "symbol" ? i + "" : i, t);
4
- import { createIdentifier as D, CommandType as O, OnLifecycle as l, LifecycleStages as g, Inject as N, LifecycleService as b, Disposable as I, ICommandService as p, UniverInstanceType as h, IResourceManagerService as M, IUniverInstanceService as G, Plugin as L, Injector as C } from "@univerjs/core";
5
- import { UnitDrawingService as J, IDrawingManagerService as U } from "@univerjs/drawing";
6
- import { filter as j, first as x } from "rxjs/operators";
7
- var H = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(H || {});
8
- class V extends J {
9
- }
10
- const d = D("sheets-drawing.sheet-drawing.service");
11
- var $ = /* @__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))($ || {});
12
- const F = {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { createIdentifier, CommandType, OnLifecycle, LifecycleStages, Inject, LifecycleService, Disposable, ICommandService, UniverInstanceType, IResourceManagerService, IUniverInstanceService, Plugin, Injector } from "@univerjs/core";
6
+ import { UnitDrawingService, IDrawingManagerService } from "@univerjs/drawing";
7
+ import { filter, first } from "rxjs/operators";
8
+ var SheetDrawingAnchorType = /* @__PURE__ */ ((SheetDrawingAnchorType2) => (SheetDrawingAnchorType2.Position = "0", SheetDrawingAnchorType2.Both = "1", SheetDrawingAnchorType2.None = "2", SheetDrawingAnchorType2))(SheetDrawingAnchorType || {});
9
+ const _SheetDrawingService = class _SheetDrawingService extends UnitDrawingService {
10
+ };
11
+ __name(_SheetDrawingService, "SheetDrawingService");
12
+ let SheetDrawingService = _SheetDrawingService;
13
+ const ISheetDrawingService = createIdentifier("sheets-drawing.sheet-drawing.service");
14
+ 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 || {});
15
+ const SetDrawingApplyMutation = {
13
16
  id: "sheet.mutation.set-drawing-apply",
14
- type: O.MUTATION,
15
- handler: (e, i) => {
16
- const t = e.get(U), r = e.get(d), { op: n, unitId: s, subUnitId: a, type: P, objects: o } = i;
17
- switch (t.applyJson1(s, a, n), r.applyJson1(s, a, n), P) {
17
+ type: CommandType.MUTATION,
18
+ handler: /* @__PURE__ */ __name((accessor, params) => {
19
+ const drawingManagerService = accessor.get(IDrawingManagerService), sheetDrawingService = accessor.get(ISheetDrawingService), { op, unitId, subUnitId, type, objects } = params;
20
+ switch (drawingManagerService.applyJson1(unitId, subUnitId, op), sheetDrawingService.applyJson1(unitId, subUnitId, op), type) {
18
21
  case 0:
19
- t.addNotification(o), r.addNotification(o);
22
+ drawingManagerService.addNotification(objects), sheetDrawingService.addNotification(objects);
20
23
  break;
21
24
  case 1:
22
- t.removeNotification(o), r.removeNotification(o);
25
+ drawingManagerService.removeNotification(objects), sheetDrawingService.removeNotification(objects);
23
26
  break;
24
27
  case 2:
25
- t.updateNotification(o), r.updateNotification(o);
28
+ drawingManagerService.updateNotification(objects), sheetDrawingService.updateNotification(objects);
26
29
  break;
27
30
  case 3:
28
- t.orderNotification(o), r.orderNotification(o);
31
+ drawingManagerService.orderNotification(objects), sheetDrawingService.orderNotification(objects);
29
32
  break;
30
33
  case 4:
31
- t.groupUpdateNotification(o);
34
+ drawingManagerService.groupUpdateNotification(objects);
32
35
  break;
33
36
  case 5:
34
- t.ungroupUpdateNotification(o);
37
+ drawingManagerService.ungroupUpdateNotification(objects);
35
38
  break;
36
39
  }
37
40
  return !0;
38
- }
41
+ }, "handler")
39
42
  };
40
- var W = Object.defineProperty, z = Object.getOwnPropertyDescriptor, m = (e, i, t, r) => {
41
- for (var n = r > 1 ? void 0 : r ? z(i, t) : i, s = e.length - 1, a; s >= 0; s--)
42
- (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
43
- return r && n && W(i, t, n), n;
44
- }, c = (e, i) => (t, r) => i(t, r, e);
45
- const E = "SHEET_DRAWING_PLUGIN";
46
- let _ = class extends I {
47
- constructor(e) {
48
- super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(F));
43
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
44
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
45
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
46
+ return kind && result && __defProp$1(target, key, result), result;
47
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
48
+ const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
49
+ var _a;
50
+ let SheetsDrawingLoadController = (_a = class extends Disposable {
51
+ constructor(_commandService) {
52
+ super(), this._commandService = _commandService, this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
49
53
  }
50
- };
51
- _ = m([
52
- l(g.Starting, _),
53
- c(0, p)
54
- ], _);
55
- let S = class extends I {
56
- constructor(e, i, t, r, n) {
57
- super(), this._sheetDrawingService = e, this._drawingManagerService = i, this._resourceManagerService = t, this._lifecycleService = r, this._univerInstanceService = n, this._init();
54
+ }, __name(_a, "SheetsDrawingLoadController"), _a);
55
+ SheetsDrawingLoadController = __decorateClass$1([
56
+ OnLifecycle(LifecycleStages.Starting, SheetsDrawingLoadController),
57
+ __decorateParam$1(0, ICommandService)
58
+ ], SheetsDrawingLoadController);
59
+ var _a2;
60
+ let SheetsDrawingController = (_a2 = class extends Disposable {
61
+ constructor(_sheetDrawingService, _drawingManagerService, _resourceManagerService, _lifecycleService, _univerInstanceService) {
62
+ super(), this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._lifecycleService = _lifecycleService, this._univerInstanceService = _univerInstanceService, this._init();
58
63
  }
59
64
  _init() {
60
65
  this._initSnapshot(), this._drawingInitializeListener();
61
66
  }
62
67
  _initSnapshot() {
63
- const e = (t) => {
64
- const r = this._sheetDrawingService.getDrawingDataForUnit(t);
65
- return r ? JSON.stringify(r) : "";
66
- }, i = (t) => {
67
- if (!t)
68
+ const toJson = /* @__PURE__ */ __name((unitId) => {
69
+ const map = this._sheetDrawingService.getDrawingDataForUnit(unitId);
70
+ return map ? JSON.stringify(map) : "";
71
+ }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
72
+ if (!json)
68
73
  return {};
69
74
  try {
70
- return JSON.parse(t);
75
+ return JSON.parse(json);
71
76
  } catch {
72
77
  return {};
73
78
  }
74
- };
79
+ }, "parseJson");
75
80
  this.disposeWithMe(
76
81
  this._resourceManagerService.registerPluginResource({
77
- pluginName: E,
78
- businesses: [h.UNIVER_SHEET],
79
- toJson: (t) => e(t),
80
- parseJson: (t) => i(t),
81
- onUnLoad: (t) => {
82
- this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
83
- },
84
- onLoad: (t, r) => {
85
- this._sheetDrawingService.registerDrawingData(t, r);
86
- }
82
+ pluginName: SHEET_DRAWING_PLUGIN,
83
+ businesses: [UniverInstanceType.UNIVER_SHEET],
84
+ toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
85
+ parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
86
+ onUnLoad: /* @__PURE__ */ __name((unitId) => {
87
+ this._sheetDrawingService.removeDrawingDataForUnit(unitId), this._drawingManagerService.removeDrawingDataForUnit(unitId);
88
+ }, "onUnLoad"),
89
+ onLoad: /* @__PURE__ */ __name((unitId, value) => {
90
+ this._sheetDrawingService.registerDrawingData(unitId, value);
91
+ }, "onLoad")
87
92
  })
88
93
  );
89
94
  }
90
95
  _drawingInitializeListener() {
91
- this._lifecycleService.lifecycle$.pipe(j((e) => e === g.Steady), x()).subscribe(() => {
92
- var i;
93
- const e = (i = this._univerInstanceService.getCurrentUnitForType(h.UNIVER_SHEET)) == null ? void 0 : i.getUnitId();
94
- e && this._sheetDrawingService.initializeNotification(e);
96
+ this._lifecycleService.lifecycle$.pipe(filter((e) => e === LifecycleStages.Steady), first()).subscribe(() => {
97
+ var _a4;
98
+ const unitId = (_a4 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a4.getUnitId();
99
+ unitId && this._sheetDrawingService.initializeNotification(unitId);
95
100
  });
96
101
  }
97
- };
98
- S = m([
99
- l(g.Starting, S),
100
- c(0, d),
101
- c(1, U),
102
- c(2, M),
103
- c(3, N(b)),
104
- c(4, G)
105
- ], S);
106
- var B = Object.defineProperty, T = Object.getOwnPropertyDescriptor, q = (e, i, t, r) => {
107
- for (var n = r > 1 ? void 0 : r ? T(i, t) : i, s = e.length - 1, a; s >= 0; s--)
108
- (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
109
- return r && n && B(i, t, n), n;
110
- }, K = (e, i) => (t, r) => i(t, r, e), v;
111
- let f = (v = class extends L {
112
- constructor(e, i) {
113
- super(), this._config = e, this._injector = i;
102
+ }, __name(_a2, "SheetsDrawingController"), _a2);
103
+ SheetsDrawingController = __decorateClass$1([
104
+ OnLifecycle(LifecycleStages.Starting, SheetsDrawingController),
105
+ __decorateParam$1(0, ISheetDrawingService),
106
+ __decorateParam$1(1, IDrawingManagerService),
107
+ __decorateParam$1(2, IResourceManagerService),
108
+ __decorateParam$1(3, Inject(LifecycleService)),
109
+ __decorateParam$1(4, IUniverInstanceService)
110
+ ], SheetsDrawingController);
111
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
112
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
113
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
114
+ return kind && result && __defProp2(target, key, result), result;
115
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
116
+ let UniverSheetsDrawingPlugin = (_a3 = class extends Plugin {
117
+ constructor(_config, _injector) {
118
+ super(), this._config = _config, this._injector = _injector;
114
119
  }
115
- onStarting(e) {
120
+ onStarting() {
116
121
  [
117
- [_],
118
- [S],
119
- [d, { useClass: V }]
120
- ].forEach((i) => e.add(i));
122
+ [SheetsDrawingLoadController],
123
+ [SheetsDrawingController],
124
+ [ISheetDrawingService, { useClass: SheetDrawingService }]
125
+ ].forEach((dependency) => this._injector.add(dependency));
121
126
  }
122
- }, u(v, "pluginName", E), u(v, "type", h.UNIVER_SHEET), v);
123
- f = q([
124
- K(1, N(C))
125
- ], f);
127
+ }, __name(_a3, "UniverSheetsDrawingPlugin"), __publicField(_a3, "pluginName", SHEET_DRAWING_PLUGIN), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
128
+ UniverSheetsDrawingPlugin = __decorateClass([
129
+ __decorateParam(1, Inject(Injector))
130
+ ], UniverSheetsDrawingPlugin);
126
131
  export {
127
- $ as DrawingApplyType,
128
- d as ISheetDrawingService,
129
- F as SetDrawingApplyMutation,
130
- H as SheetDrawingAnchorType,
131
- f as UniverSheetsDrawingPlugin
132
+ DrawingApplyType,
133
+ ISheetDrawingService,
134
+ SetDrawingApplyMutation,
135
+ SheetDrawingAnchorType,
136
+ UniverSheetsDrawingPlugin
132
137
  };
@@ -6,5 +6,5 @@ export declare class UniverSheetsDrawingPlugin extends Plugin {
6
6
  static pluginName: string;
7
7
  static type: UniverInstanceType;
8
8
  constructor(_config: unknown, _injector: Injector);
9
- onStarting(_injector: Injector): void;
9
+ onStarting(): void;
10
10
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","rxjs/operators"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.UniverSheetsDrawing={},s.UniverCore,s.UniverDrawing,s.rxjs.operators))})(this,function(s,t,u,l){"use strict";var M=Object.defineProperty;var L=(s,t,u)=>t in s?M(s,t,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[t]=u;var _=(s,t,u)=>L(s,typeof t!="symbol"?t+"":t,u);var d;var U=(e=>(e.Position="0",e.Both="1",e.None="2",e))(U||{});class P extends u.UnitDrawingService{}const g=t.createIdentifier("sheets-drawing.sheet-drawing.service");var I=(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))(I||{});const N={id:"sheet.mutation.set-drawing-apply",type:t.CommandType.MUTATION,handler:(e,n)=>{const i=e.get(u.IDrawingManagerService),r=e.get(g),{op:a,unitId:c,subUnitId:o,type:j,objects:v}=n;switch(i.applyJson1(c,o,a),r.applyJson1(c,o,a),j){case 0:i.addNotification(v),r.addNotification(v);break;case 1:i.removeNotification(v),r.removeNotification(v);break;case 2:i.updateNotification(v),r.updateNotification(v);break;case 3:i.orderNotification(v),r.orderNotification(v);break;case 4:i.groupUpdateNotification(v);break;case 5:i.ungroupUpdateNotification(v);break}return!0}};var p=Object.defineProperty,E=Object.getOwnPropertyDescriptor,D=(e,n,i,r)=>{for(var a=r>1?void 0:r?E(n,i):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(a=(r?o(n,i,a):o(a))||a);return r&&a&&p(n,i,a),a},S=(e,n)=>(i,r)=>n(i,r,e);const w="SHEET_DRAWING_PLUGIN";let h=class extends t.Disposable{constructor(e){super(),this._commandService=e,this.disposeWithMe(this._commandService.registerCommand(N))}};h=D([t.OnLifecycle(t.LifecycleStages.Starting,h),S(0,t.ICommandService)],h);let f=class extends t.Disposable{constructor(e,n,i,r,a){super(),this._sheetDrawingService=e,this._drawingManagerService=n,this._resourceManagerService=i,this._lifecycleService=r,this._univerInstanceService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const e=i=>{const r=this._sheetDrawingService.getDrawingDataForUnit(i);return r?JSON.stringify(r):""},n=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:i=>e(i),parseJson:i=>n(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,r)=>{this._sheetDrawingService.registerDrawingData(i,r)}}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(l.filter(e=>e===t.LifecycleStages.Steady),l.first()).subscribe(()=>{var n;const e=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getUnitId();e&&this._sheetDrawingService.initializeNotification(e)})}};f=D([t.OnLifecycle(t.LifecycleStages.Starting,f),S(0,g),S(1,u.IDrawingManagerService),S(2,t.IResourceManagerService),S(3,t.Inject(t.LifecycleService)),S(4,t.IUniverInstanceService)],f);var m=Object.defineProperty,O=Object.getOwnPropertyDescriptor,R=(e,n,i,r)=>{for(var a=r>1?void 0:r?O(n,i):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(a=(r?o(n,i,a):o(a))||a);return r&&a&&m(n,i,a),a},b=(e,n)=>(i,r)=>n(i,r,e);s.UniverSheetsDrawingPlugin=(d=class extends t.Plugin{constructor(n,i){super(),this._config=n,this._injector=i}onStarting(n){[[h],[f],[g,{useClass:P}]].forEach(i=>n.add(i))}},_(d,"pluginName",w),_(d,"type",t.UniverInstanceType.UNIVER_SHEET),d),s.UniverSheetsDrawingPlugin=R([b(1,t.Inject(t.Injector))],s.UniverSheetsDrawingPlugin),s.DrawingApplyType=I,s.ISheetDrawingService=g,s.SetDrawingApplyMutation=N,s.SheetDrawingAnchorType=U,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","rxjs/operators"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDrawing={},global.UniverCore,global.UniverDrawing,global.rxjs.operators))})(this,function(exports2,core,drawing,operators){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;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){super(),this._commandService=_commandService,this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService)],SheetsDrawingLoadController);let SheetsDrawingController=(_b=class extends core.Disposable{constructor(_sheetDrawingService,_drawingManagerService,_resourceManagerService,_lifecycleService,_univerInstanceService){super(),this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._lifecycleService=_lifecycleService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const toJson=__name(unitId=>{const map=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=>toJson(unitId),"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)},"onLoad")}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(operators.filter(e=>e===core.LifecycleStages.Steady),operators.first()).subscribe(()=>{var _a2;const unitId=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getUnitId();unitId&&this._sheetDrawingService.initializeNotification(unitId)})}},__name(_b,"SheetsDrawingController"),_b);SheetsDrawingController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingController),__decorateParam$1(0,ISheetDrawingService),__decorateParam$1(1,drawing.IDrawingManagerService),__decorateParam$1(2,core.IResourceManagerService),__decorateParam$1(3,core.Inject(core.LifecycleService)),__decorateParam$1(4,core.IUniverInstanceService)],SheetsDrawingController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__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");exports2.UniverSheetsDrawingPlugin=(_c=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[SheetsDrawingController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_c,"UniverSheetsDrawingPlugin"),__publicField(_c,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_c,"type",core.UniverInstanceType.UNIVER_SHEET),_c),exports2.UniverSheetsDrawingPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports2.UniverSheetsDrawingPlugin),exports2.DrawingApplyType=DrawingApplyType,exports2.ISheetDrawingService=ISheetDrawingService,exports2.SetDrawingApplyMutation=SetDrawingApplyMutation,exports2.SheetDrawingAnchorType=SheetDrawingAnchorType,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -45,17 +45,17 @@
45
45
  ],
46
46
  "peerDependencies": {
47
47
  "rxjs": ">=7.0.0",
48
- "@univerjs/core": "0.2.5",
49
- "@univerjs/drawing": "0.2.5"
48
+ "@univerjs/core": "0.2.6",
49
+ "@univerjs/drawing": "0.2.6"
50
50
  },
51
51
  "devDependencies": {
52
- "typescript": "^5.5.3",
53
- "vite": "^5.3.4",
54
- "vitest": "^2.0.3",
55
- "@univerjs/core": "0.2.5",
56
- "@univerjs/shared": "0.2.5",
57
- "@univerjs/drawing": "0.2.5",
58
- "@univerjs/sheets": "0.2.5"
52
+ "typescript": "^5.5.4",
53
+ "vite": "^5.3.5",
54
+ "vitest": "^2.0.4",
55
+ "@univerjs/core": "0.2.6",
56
+ "@univerjs/drawing": "0.2.6",
57
+ "@univerjs/shared": "0.2.6",
58
+ "@univerjs/sheets": "0.2.6"
59
59
  },
60
60
  "univerSpace": {
61
61
  ".": {