@univerjs/sheets-drawing 0.2.2 → 0.2.4-alpha.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/README.md CHANGED
@@ -1,16 +1,27 @@
1
1
  # @univerjs/sheets-drawing
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@univerjs/sheets-drawing)](https://npmjs.org/packages/@univerjs/sheets-drawing)
4
- [![license](https://img.shields.io/npm/l/@univerjs/sheets-drawing)](https://img.shields.io/npm/l/@univerjs/sheets-drawing)
3
+ ## Package Overview
5
4
 
6
- ## Introduction
5
+ | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
+ | --- | --- | --- | --- | --- | :---: | :---: |
7
+ | `@univerjs/sheets-drawing` | `UniverSheetsDrawing` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
7
8
 
8
- > This plugin adds drawing features to Univer.
9
+ ## Introduction
9
10
 
10
- ## Usage
11
+ This plugin adds drawing features to Univer.
11
12
 
12
13
  ### Installation
13
14
 
14
15
  ```shell
15
- npm i @univerjs/sheets-drawing
16
+ # Using npm
17
+ npm install @univerjs/sheets-drawing
18
+
19
+ # Using pnpm
20
+ pnpm add @univerjs/sheets-drawing
16
21
  ```
22
+
23
+ <!-- Links -->
24
+ [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-drawing?style=flat-square
25
+ [npm-version-link]: https://npmjs.com/package/@univerjs/sheets-drawing
26
+ [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-drawing?style=flat-square
27
+ [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-drawing?style=flat-square
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 d=(e,t,i)=>E(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),h=require("@wendellhu/redi"),l=require("@univerjs/drawing");var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class m extends l.UnitDrawingService{}const _=h.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(l.IDrawingManagerService),r=e.get(_),{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 p=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&&p(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.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(e=>{var t;if(e===a.LifecycleStages.Steady){const i=(t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId();if(!i)return;this._sheetDrawingService.initializeNotification(i)}}))}};u=N([a.OnLifecycle(a.LifecycleStages.Ready,u),v(0,_),v(1,l.IDrawingManagerService),v(2,a.IResourceManagerService),v(3,h.Inject(a.LifecycleService)),v(4,a.IUniverInstanceService)],u);var R=Object.defineProperty,b=Object.getOwnPropertyDescriptor,M=(e,t,i,r)=>{for(var n=r>1?void 0:r?b(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&&R(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],[_,{useClass:m}]].forEach(i=>t.add(i))}},d(g,"pluginName",w),d(g,"type",a.UniverInstanceType.UNIVER_SHEET),g);exports.UniverSheetsDrawingPlugin=M([L(1,h.Inject(h.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=I;exports.ISheetDrawingService=_;exports.SetDrawingApplyMutation=U;exports.SheetDrawingAnchorType=f;
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;
package/lib/es/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  var R = Object.defineProperty;
2
2
  var w = (e, i, t) => i in e ? R(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
3
  var u = (e, i, t) => w(e, typeof i != "symbol" ? i + "" : i, t);
4
- import { CommandType as D, OnLifecycle as l, LifecycleStages as d, LifecycleService as O, Disposable as N, ICommandService as b, UniverInstanceType as S, IResourceManagerService as p, IUniverInstanceService as M, Plugin as G } from "@univerjs/core";
5
- import { createIdentifier as L, Inject as I, Injector as C } from "@wendellhu/redi";
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";
6
5
  import { UnitDrawingService as J, IDrawingManagerService as U } from "@univerjs/drawing";
7
- var j = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(j || {});
8
- class x extends J {
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
9
  }
10
- const g = L("sheets-drawing.sheet-drawing.service");
11
- var H = /* @__PURE__ */ ((e) => (e[e.INSERT = 0] = "INSERT", e[e.REMOVE = 1] = "REMOVE", e[e.UPDATE = 2] = "UPDATE", e[e.ARRANGE = 3] = "ARRANGE", e[e.GROUP = 4] = "GROUP", e[e.UNGROUP = 5] = "UNGROUP", e))(H || {});
12
- const V = {
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 = {
13
13
  id: "sheet.mutation.set-drawing-apply",
14
- type: D.MUTATION,
14
+ type: O.MUTATION,
15
15
  handler: (e, i) => {
16
- const t = e.get(U), r = e.get(g), { op: n, unitId: s, subUnitId: a, type: P, objects: o } = i;
16
+ const t = e.get(U), r = e.get(d), { op: n, unitId: s, subUnitId: a, type: P, objects: o } = i;
17
17
  switch (t.applyJson1(s, a, n), r.applyJson1(s, a, n), P) {
18
18
  case 0:
19
19
  t.addNotification(o), r.addNotification(o);
@@ -37,22 +37,22 @@ const V = {
37
37
  return !0;
38
38
  }
39
39
  };
40
- var W = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, m = (e, i, t, r) => {
41
- for (var n = r > 1 ? void 0 : r ? $(i, t) : i, s = e.length - 1, a; s >= 0; s--)
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
42
  (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
43
43
  return r && n && W(i, t, n), n;
44
44
  }, c = (e, i) => (t, r) => i(t, r, e);
45
45
  const E = "SHEET_DRAWING_PLUGIN";
46
- let _ = class extends N {
46
+ let _ = class extends I {
47
47
  constructor(e) {
48
- super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(V));
48
+ super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(F));
49
49
  }
50
50
  };
51
51
  _ = m([
52
- l(d.Starting, _),
53
- c(0, b)
52
+ l(g.Starting, _),
53
+ c(0, p)
54
54
  ], _);
55
- let h = class extends N {
55
+ let S = class extends I {
56
56
  constructor(e, i, t, r, n) {
57
57
  super(), this._sheetDrawingService = e, this._drawingManagerService = i, this._resourceManagerService = t, this._lifecycleService = r, this._univerInstanceService = n, this._init();
58
58
  }
@@ -75,7 +75,7 @@ let h = class extends N {
75
75
  this.disposeWithMe(
76
76
  this._resourceManagerService.registerPluginResource({
77
77
  pluginName: E,
78
- businesses: [S.UNIVER_SHEET],
78
+ businesses: [h.UNIVER_SHEET],
79
79
  toJson: (t) => e(t),
80
80
  parseJson: (t) => i(t),
81
81
  onUnLoad: (t) => {
@@ -88,51 +88,45 @@ let h = class extends N {
88
88
  );
89
89
  }
90
90
  _drawingInitializeListener() {
91
- this.disposeWithMe(
92
- this._lifecycleService.lifecycle$.subscribe((e) => {
93
- var i;
94
- if (e === d.Steady) {
95
- const t = (i = this._univerInstanceService.getCurrentUnitForType(S.UNIVER_SHEET)) == null ? void 0 : i.getUnitId();
96
- if (!t)
97
- return;
98
- this._sheetDrawingService.initializeNotification(t);
99
- }
100
- })
101
- );
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);
95
+ });
102
96
  }
103
97
  };
104
- h = m([
105
- l(d.Ready, h),
106
- c(0, g),
98
+ S = m([
99
+ l(g.Starting, S),
100
+ c(0, d),
107
101
  c(1, U),
108
- c(2, p),
109
- c(3, I(O)),
110
- c(4, M)
111
- ], h);
112
- var F = Object.defineProperty, z = Object.getOwnPropertyDescriptor, B = (e, i, t, r) => {
113
- for (var n = r > 1 ? void 0 : r ? z(i, t) : i, s = e.length - 1, a; s >= 0; s--)
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--)
114
108
  (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
115
- return r && n && F(i, t, n), n;
116
- }, T = (e, i) => (t, r) => i(t, r, e), v;
117
- let f = (v = class extends G {
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 {
118
112
  constructor(e, i) {
119
113
  super(), this._config = e, this._injector = i;
120
114
  }
121
115
  onStarting(e) {
122
116
  [
123
117
  [_],
124
- [h],
125
- [g, { useClass: x }]
118
+ [S],
119
+ [d, { useClass: V }]
126
120
  ].forEach((i) => e.add(i));
127
121
  }
128
- }, u(v, "pluginName", E), u(v, "type", S.UNIVER_SHEET), v);
129
- f = B([
130
- T(1, I(C))
122
+ }, u(v, "pluginName", E), u(v, "type", h.UNIVER_SHEET), v);
123
+ f = q([
124
+ K(1, N(C))
131
125
  ], f);
132
126
  export {
133
- H as DrawingApplyType,
134
- g as ISheetDrawingService,
135
- V as SetDrawingApplyMutation,
136
- j as SheetDrawingAnchorType,
127
+ $ as DrawingApplyType,
128
+ d as ISheetDrawingService,
129
+ F as SetDrawingApplyMutation,
130
+ H as SheetDrawingAnchorType,
137
131
  f as UniverSheetsDrawingPlugin
138
132
  };
@@ -1,5 +1,4 @@
1
- import { Plugin, UniverInstanceType } from '@univerjs/core';
2
- import { Injector } from '@wendellhu/redi';
1
+ import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
2
 
4
3
  export declare class UniverSheetsDrawingPlugin extends Plugin {
5
4
  private readonly _config;
@@ -38,5 +38,5 @@ export declare class SheetDrawingService extends UnitDrawingService<ISheetDrawin
38
38
  }
39
39
  export interface ISheetDrawingService extends IUnitDrawingService<ISheetDrawing> {
40
40
  }
41
- export declare const ISheetDrawingService: import('@wendellhu/redi').IdentifierDecorator<ISheetDrawingService>;
41
+ export declare const ISheetDrawingService: import('@univerjs/core').IdentifierDecorator<ISheetDrawingService>;
42
42
  export {};
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.UniverSheetsDrawing={},s.UniverCore,s["@wendellhu/redi"],s.UniverDrawing))})(this,function(s,t,v,_){"use strict";var j=Object.defineProperty;var L=(s,t,v)=>t in s?j(s,t,{enumerable:!0,configurable:!0,writable:!0,value:v}):s[t]=v;var l=(s,t,v)=>L(s,typeof t!="symbol"?t+"":t,v);var f;var U=(i=>(i.Position="0",i.Both="1",i.None="2",i))(U||{});class P extends _.UnitDrawingService{}const S=v.createIdentifier("sheets-drawing.sheet-drawing.service");var I=(i=>(i[i.INSERT=0]="INSERT",i[i.REMOVE=1]="REMOVE",i[i.UPDATE=2]="UPDATE",i[i.ARRANGE=3]="ARRANGE",i[i.GROUP=4]="GROUP",i[i.UNGROUP=5]="UNGROUP",i))(I||{});const w={id:"sheet.mutation.set-drawing-apply",type:t.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(_.IDrawingManagerService),n=i.get(S),{op:a,unitId:c,subUnitId:o,type:M,objects:u}=r;switch(e.applyJson1(c,o,a),n.applyJson1(c,o,a),M){case 0:e.addNotification(u),n.addNotification(u);break;case 1:e.removeNotification(u),n.removeNotification(u);break;case 2:e.updateNotification(u),n.updateNotification(u);break;case 3:e.orderNotification(u),n.orderNotification(u);break;case 4:e.groupUpdateNotification(u);break;case 5:e.ungroupUpdateNotification(u);break}return!0}};var E=Object.defineProperty,m=Object.getOwnPropertyDescriptor,N=(i,r,e,n)=>{for(var a=n>1?void 0:n?m(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(n?o(r,e,a):o(a))||a);return n&&a&&E(r,e,a),a},h=(i,r)=>(e,n)=>r(e,n,i);const D="SHEET_DRAWING_PLUGIN";let d=class extends t.Disposable{constructor(i){super(),this._commandService=i,this.disposeWithMe(this._commandService.registerCommand(w))}};d=N([t.OnLifecycle(t.LifecycleStages.Starting,d),h(0,t.ICommandService)],d);let g=class extends t.Disposable{constructor(i,r,e,n,a){super(),this._sheetDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=e,this._lifecycleService=n,this._univerInstanceService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const i=e=>{const n=this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):""},r=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:D,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>r(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,n)=>{this._sheetDrawingService.registerDrawingData(e,n)}}))}_drawingInitializeListener(){this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(i=>{var r;if(i===t.LifecycleStages.Steady){const e=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();if(!e)return;this._sheetDrawingService.initializeNotification(e)}}))}};g=N([t.OnLifecycle(t.LifecycleStages.Ready,g),h(0,S),h(1,_.IDrawingManagerService),h(2,t.IResourceManagerService),h(3,v.Inject(t.LifecycleService)),h(4,t.IUniverInstanceService)],g);var p=Object.defineProperty,O=Object.getOwnPropertyDescriptor,R=(i,r,e,n)=>{for(var a=n>1?void 0:n?O(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(n?o(r,e,a):o(a))||a);return n&&a&&p(r,e,a),a},b=(i,r)=>(e,n)=>r(e,n,i);s.UniverSheetsDrawingPlugin=(f=class extends t.Plugin{constructor(r,e){super(),this._config=r,this._injector=e}onStarting(r){[[d],[g],[S,{useClass:P}]].forEach(e=>r.add(e))}},l(f,"pluginName",D),l(f,"type",t.UniverInstanceType.UNIVER_SHEET),f),s.UniverSheetsDrawingPlugin=R([b(1,v.Inject(v.Injector))],s.UniverSheetsDrawingPlugin),s.DrawingApplyType=I,s.ISheetDrawingService=S,s.SetDrawingApplyMutation=w,s.SheetDrawingAnchorType=U,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.2.2",
3
+ "version": "0.2.4-alpha.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,19 +44,18 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@wendellhu/redi": "0.15.5",
48
- "@univerjs/core": "0.2.2",
49
- "@univerjs/drawing": "0.2.2"
47
+ "rxjs": ">=7.0.0",
48
+ "@univerjs/core": "0.2.4-alpha.0",
49
+ "@univerjs/drawing": "0.2.4-alpha.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@wendellhu/redi": "0.15.5",
53
52
  "typescript": "^5.5.3",
54
- "vite": "^5.3.3",
55
- "vitest": "^1.6.0",
56
- "@univerjs/shared": "0.2.2",
57
- "@univerjs/core": "0.2.2",
58
- "@univerjs/drawing": "0.2.2",
59
- "@univerjs/sheets": "0.2.2"
53
+ "vite": "^5.3.4",
54
+ "vitest": "^2.0.3",
55
+ "@univerjs/core": "0.2.4-alpha.0",
56
+ "@univerjs/shared": "0.2.4-alpha.0",
57
+ "@univerjs/drawing": "0.2.4-alpha.0",
58
+ "@univerjs/sheets": "0.2.4-alpha.0"
60
59
  },
61
60
  "univerSpace": {
62
61
  ".": {