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