@univerjs/docs-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 +16 -5
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +102 -95
- package/lib/types/controllers/doc-drawing.controller.d.ts +8 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
# @univerjs/docs-drawing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://img.shields.io/npm/l/@univerjs/docs-drawing)
|
|
3
|
+
## Package Overview
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
|
|
6
|
+
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
+
| `@univerjs/docs-drawing` | `UniverDocsDrawing` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Introduction
|
|
9
10
|
|
|
10
11
|
## Usage
|
|
11
12
|
|
|
12
13
|
### Installation
|
|
13
14
|
|
|
14
15
|
```shell
|
|
15
|
-
|
|
16
|
+
# Using npm
|
|
17
|
+
npm install @univerjs/docs-drawing
|
|
18
|
+
|
|
19
|
+
# Using pnpm
|
|
20
|
+
pnpm add @univerjs/docs-drawing
|
|
16
21
|
```
|
|
22
|
+
|
|
23
|
+
<!-- Links -->
|
|
24
|
+
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-drawing?style=flat-square
|
|
25
|
+
[npm-version-link]: https://npmjs.com/package/@univerjs/docs-drawing
|
|
26
|
+
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-drawing?style=flat-square
|
|
27
|
+
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-drawing?style=flat-square
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var p=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var S=(r,i,e)=>p(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),l=require("@wendellhu/redi"),U=require("@univerjs/drawing"),h=require("rxjs/operators");class f extends U.UnitDrawingService{}const D=l.createIdentifier("univer.doc.plugin.doc-drawing.service");var w=(r=>(r[r.INSERT=0]="INSERT",r[r.REMOVE=1]="REMOVE",r[r.UPDATE=2]="UPDATE",r[r.ARRANGE=3]="ARRANGE",r[r.GROUP=4]="GROUP",r[r.UNGROUP=5]="UNGROUP",r))(w||{});const N={id:"doc.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(r,i)=>{const e=r.get(U.IDrawingManagerService),t=r.get(D),n=r.get(a.IUniverInstanceService),{op:s,unitId:c,subUnitId:g,type:P,objects:o}=i;switch(e.applyJson1(c,g,s),t.applyJson1(c,g,s),P){case 0:e.addNotification(o),t.addNotification(o);break;case 1:e.removeNotification(o),t.removeNotification(o);break;case 2:e.updateNotification(o),t.updateNotification(o);break;case 3:e.orderNotification(o),t.orderNotification(o);break;case 4:e.groupUpdateNotification(o);break;case 5:e.ungroupUpdateNotification(o);break}return n.getUnit(c),!0}};var R=Object.defineProperty,M=Object.getOwnPropertyDescriptor,O=(r,i,e,t)=>{for(var n=t>1?void 0:t?M(i,e):i,s=r.length-1,c;s>=0;s--)(c=r[s])&&(n=(t?c(i,e,n):c(n))||n);return t&&n&&R(i,e,n),n},d=(r,i)=>(e,t)=>i(e,t,r);const I="DOC_DRAWING_PLUGIN";let v=class extends a.Disposable{constructor(r){super(),this._commandService=r,this.disposeWithMe(this._commandService.registerCommand(N))}};v=O([a.OnLifecycle(a.LifecycleStages.Starting,v),d(0,a.ICommandService)],v);let _=class extends a.Disposable{constructor(r,i,e,t,n){super(),this._docDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=e,this._univerInstanceService=t,this._lifecycleService=n,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const r=e=>{const t=this._docDrawingService.getDrawingDataForUnit(e);return t!=null&&t[e]?JSON.stringify(t==null?void 0:t[e]):""},i=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:I,businesses:[a.UniverInstanceType.UNIVER_DOC],toJson:e=>r(e),parseJson:e=>i(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,s;this._setDrawingDataForUnit(e,{data:(n=t.data)!=null?n:{},order:(s=t.order)!=null?s:[]})}}))}_setDrawingDataForUnit(r,i){const e=this._univerInstanceService.getUnit(r);e!=null&&(e.resetDrawing(i.data,i.order),this._initDataLoader())}_initDataLoader(){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const i=r.getUnitId(),e=i,t=r.getDrawings(),n=r.getDrawingsOrder();if(!t||!n)return!1;Object.keys(t).forEach(c=>{const g=t[c];t[c]={...g}});const s={[e]:{unitId:i,subUnitId:e,data:t,order:n}};return this._docDrawingService.registerDrawingData(i,s),this._drawingManagerService.registerDrawingData(i,s),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(h.filter(r=>r===a.LifecycleStages.Rendered),h.first()).subscribe(r=>{var e;const i=(e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();i&&(this._docDrawingService.initializeNotification(i),this._drawingManagerService.initializeNotification(i))})}};_=O([a.OnLifecycle(a.LifecycleStages.Starting,_),d(0,D),d(1,U.IDrawingManagerService),d(2,a.IResourceManagerService),d(3,a.IUniverInstanceService),d(4,l.Inject(a.LifecycleService))],_);var C=Object.defineProperty,E=Object.getOwnPropertyDescriptor,L=(r,i,e,t)=>{for(var n=t>1?void 0:t?E(i,e):i,s=r.length-1,c;s>=0;s--)(c=r[s])&&(n=(t?c(i,e,n):c(n))||n);return t&&n&&C(i,e,n),n},m=(r,i)=>(e,t)=>i(e,t,r),u;exports.UniverDocsDrawingPlugin=(u=class extends a.Plugin{constructor(i,e){super(),this._injector=e}onStarting(i){[[v],[_],[f],[D,{useClass:f}]].forEach(e=>i.add(e))}},S(u,"pluginName",I),S(u,"type",a.UniverInstanceType.UNIVER_DOC),u);exports.UniverDocsDrawingPlugin=L([m(1,l.Inject(l.Injector))],exports.UniverDocsDrawingPlugin);exports.DOCS_DRAWING_PLUGIN=I;exports.DocDrawingApplyType=w;exports.DocDrawingService=f;exports.IDocDrawingService=D;exports.SetDocDrawingApplyMutation=N;
|
package/lib/es/index.js
CHANGED
|
@@ -1,153 +1,160 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { createIdentifier as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
class m extends V {
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var M = (e, r, t) => r in e ? b(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var f = (e, r, t) => M(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { CommandType as p, IUniverInstanceService as D, OnLifecycle as I, LifecycleStages as l, LifecycleService as C, Disposable as N, ICommandService as E, UniverInstanceType as u, IResourceManagerService as L, Plugin as G } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as j, Inject as O, Injector as J } from "@wendellhu/redi";
|
|
6
|
+
import { UnitDrawingService as F, IDrawingManagerService as w } from "@univerjs/drawing";
|
|
7
|
+
import { filter as V, first as x } from "rxjs/operators";
|
|
8
|
+
class h extends F {
|
|
10
9
|
}
|
|
11
|
-
const S =
|
|
12
|
-
var
|
|
13
|
-
const
|
|
10
|
+
const S = j("univer.doc.plugin.doc-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 z = {
|
|
14
13
|
id: "doc.mutation.set-drawing-apply",
|
|
15
|
-
type:
|
|
16
|
-
handler: (
|
|
17
|
-
const
|
|
18
|
-
switch (
|
|
14
|
+
type: p.MUTATION,
|
|
15
|
+
handler: (e, r) => {
|
|
16
|
+
const t = e.get(w), i = e.get(S), n = e.get(D), { op: a, unitId: s, subUnitId: d, type: R, objects: o } = r;
|
|
17
|
+
switch (t.applyJson1(s, d, a), i.applyJson1(s, d, a), R) {
|
|
19
18
|
case 0:
|
|
20
|
-
|
|
19
|
+
t.addNotification(o), i.addNotification(o);
|
|
21
20
|
break;
|
|
22
21
|
case 1:
|
|
23
|
-
|
|
22
|
+
t.removeNotification(o), i.removeNotification(o);
|
|
24
23
|
break;
|
|
25
24
|
case 2:
|
|
26
|
-
|
|
25
|
+
t.updateNotification(o), i.updateNotification(o);
|
|
27
26
|
break;
|
|
28
27
|
case 3:
|
|
29
|
-
|
|
28
|
+
t.orderNotification(o), i.orderNotification(o);
|
|
30
29
|
break;
|
|
31
30
|
case 4:
|
|
32
|
-
|
|
31
|
+
t.groupUpdateNotification(o);
|
|
33
32
|
break;
|
|
34
33
|
case 5:
|
|
35
|
-
|
|
34
|
+
t.ungroupUpdateNotification(o);
|
|
36
35
|
break;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
return h.getSnapshot().drawings = e.getDrawingData(a, c), h.getSnapshot().drawingsOrder = e.getDrawingOrder(a, c), !0;
|
|
37
|
+
return n.getUnit(s), !0;
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
var
|
|
43
|
-
for (var n = i > 1 ? void 0 : i ? q(
|
|
44
|
-
(
|
|
45
|
-
return i && n &&
|
|
46
|
-
},
|
|
40
|
+
var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor, m = (e, r, t, i) => {
|
|
41
|
+
for (var n = i > 1 ? void 0 : i ? q(r, t) : r, a = e.length - 1, s; a >= 0; a--)
|
|
42
|
+
(s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
|
|
43
|
+
return i && n && W(r, t, n), n;
|
|
44
|
+
}, c = (e, r) => (t, i) => r(t, i, e);
|
|
47
45
|
const P = "DOC_DRAWING_PLUGIN";
|
|
48
|
-
let v = class extends
|
|
49
|
-
constructor(
|
|
50
|
-
super(), this._commandService =
|
|
46
|
+
let v = class extends N {
|
|
47
|
+
constructor(e) {
|
|
48
|
+
super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(z));
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
|
-
v =
|
|
54
|
-
l
|
|
55
|
-
|
|
51
|
+
v = m([
|
|
52
|
+
I(l.Starting, v),
|
|
53
|
+
c(0, E)
|
|
56
54
|
], v);
|
|
57
|
-
let _ = class extends
|
|
58
|
-
constructor(r, t,
|
|
59
|
-
super(), this._docDrawingService =
|
|
55
|
+
let _ = class extends N {
|
|
56
|
+
constructor(e, r, t, i, n) {
|
|
57
|
+
super(), this._docDrawingService = e, this._drawingManagerService = r, this._resourceManagerService = t, this._univerInstanceService = i, this._lifecycleService = n, this._init();
|
|
60
58
|
}
|
|
61
59
|
_init() {
|
|
62
|
-
this._initSnapshot(), this.
|
|
60
|
+
this._initSnapshot(), this._drawingInitializeListener();
|
|
63
61
|
}
|
|
64
62
|
_initSnapshot() {
|
|
65
|
-
const
|
|
66
|
-
const i = this._docDrawingService.getDrawingDataForUnit(
|
|
67
|
-
return i ? JSON.stringify(i) : "";
|
|
68
|
-
},
|
|
69
|
-
if (!
|
|
70
|
-
return {};
|
|
63
|
+
const e = (t) => {
|
|
64
|
+
const i = this._docDrawingService.getDrawingDataForUnit(t);
|
|
65
|
+
return i != null && i[t] ? JSON.stringify(i == null ? void 0 : i[t]) : "";
|
|
66
|
+
}, r = (t) => {
|
|
67
|
+
if (!t)
|
|
68
|
+
return { data: {}, order: [] };
|
|
71
69
|
try {
|
|
72
|
-
return JSON.parse(
|
|
70
|
+
return JSON.parse(t);
|
|
73
71
|
} catch {
|
|
74
|
-
return {};
|
|
72
|
+
return { data: {}, order: [] };
|
|
75
73
|
}
|
|
76
74
|
};
|
|
77
75
|
this.disposeWithMe(
|
|
78
76
|
this._resourceManagerService.registerPluginResource({
|
|
79
77
|
pluginName: P,
|
|
80
|
-
businesses: [
|
|
81
|
-
toJson: (
|
|
82
|
-
parseJson: (
|
|
83
|
-
onUnLoad: (
|
|
84
|
-
this.
|
|
78
|
+
businesses: [u.UNIVER_DOC],
|
|
79
|
+
toJson: (t) => e(t),
|
|
80
|
+
parseJson: (t) => r(t),
|
|
81
|
+
onUnLoad: (t) => {
|
|
82
|
+
this._setDrawingDataForUnit(t, { data: {}, order: [] });
|
|
85
83
|
},
|
|
86
|
-
onLoad: (
|
|
87
|
-
|
|
84
|
+
onLoad: (t, i) => {
|
|
85
|
+
var n, a;
|
|
86
|
+
this._setDrawingDataForUnit(t, { data: (n = i.data) != null ? n : {}, order: (a = i.order) != null ? a : [] });
|
|
88
87
|
}
|
|
89
88
|
})
|
|
90
89
|
);
|
|
91
90
|
}
|
|
92
|
-
_setDrawingDataForUnit(
|
|
93
|
-
const
|
|
94
|
-
|
|
91
|
+
_setDrawingDataForUnit(e, r) {
|
|
92
|
+
const t = this._univerInstanceService.getUnit(e);
|
|
93
|
+
t != null && (t.resetDrawing(r.data, r.order), this._initDataLoader());
|
|
95
94
|
}
|
|
96
95
|
_initDataLoader() {
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
96
|
+
const e = this._univerInstanceService.getCurrentUnitForType(u.UNIVER_DOC);
|
|
97
|
+
if (!e)
|
|
99
98
|
return !1;
|
|
100
|
-
const
|
|
99
|
+
const r = e.getUnitId(), t = r, i = e.getDrawings(), n = e.getDrawingsOrder();
|
|
101
100
|
if (!i || !n)
|
|
102
101
|
return !1;
|
|
103
|
-
Object.keys(i).forEach((
|
|
104
|
-
const
|
|
105
|
-
i[
|
|
102
|
+
Object.keys(i).forEach((s) => {
|
|
103
|
+
const d = i[s];
|
|
104
|
+
i[s] = { ...d };
|
|
106
105
|
});
|
|
107
|
-
const
|
|
108
|
-
[
|
|
109
|
-
unitId:
|
|
110
|
-
subUnitId:
|
|
106
|
+
const a = {
|
|
107
|
+
[t]: {
|
|
108
|
+
unitId: r,
|
|
109
|
+
subUnitId: t,
|
|
111
110
|
data: i,
|
|
112
111
|
order: n
|
|
113
112
|
}
|
|
114
113
|
};
|
|
115
|
-
return this._docDrawingService.registerDrawingData(
|
|
114
|
+
return this._docDrawingService.registerDrawingData(r, a), this._drawingManagerService.registerDrawingData(r, a), !0;
|
|
115
|
+
}
|
|
116
|
+
_drawingInitializeListener() {
|
|
117
|
+
this._lifecycleService.lifecycle$.pipe(V((e) => e === l.Rendered), x()).subscribe((e) => {
|
|
118
|
+
var t;
|
|
119
|
+
const r = (t = this._univerInstanceService.getCurrentUnitForType(u.UNIVER_DOC)) == null ? void 0 : t.getUnitId();
|
|
120
|
+
r && (this._docDrawingService.initializeNotification(r), this._drawingManagerService.initializeNotification(r));
|
|
121
|
+
});
|
|
116
122
|
}
|
|
117
123
|
};
|
|
118
|
-
_ =
|
|
119
|
-
l
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
_ = m([
|
|
125
|
+
I(l.Starting, _),
|
|
126
|
+
c(0, S),
|
|
127
|
+
c(1, w),
|
|
128
|
+
c(2, L),
|
|
129
|
+
c(3, D),
|
|
130
|
+
c(4, O(C))
|
|
125
131
|
], _);
|
|
126
|
-
var
|
|
127
|
-
for (var n = i > 1 ? void 0 : i ?
|
|
128
|
-
(
|
|
129
|
-
return i && n &&
|
|
130
|
-
},
|
|
131
|
-
let
|
|
132
|
-
constructor(
|
|
133
|
-
super(), this._injector =
|
|
132
|
+
var B = Object.defineProperty, H = Object.getOwnPropertyDescriptor, K = (e, r, t, i) => {
|
|
133
|
+
for (var n = i > 1 ? void 0 : i ? H(r, t) : r, a = e.length - 1, s; a >= 0; a--)
|
|
134
|
+
(s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
|
|
135
|
+
return i && n && B(r, t, n), n;
|
|
136
|
+
}, Q = (e, r) => (t, i) => r(t, i, e), g;
|
|
137
|
+
let U = (g = class extends G {
|
|
138
|
+
constructor(e, r) {
|
|
139
|
+
super(), this._injector = r;
|
|
134
140
|
}
|
|
135
|
-
onStarting(
|
|
141
|
+
onStarting(e) {
|
|
136
142
|
[
|
|
137
143
|
[v],
|
|
138
144
|
[_],
|
|
139
|
-
[
|
|
140
|
-
[S, { useClass:
|
|
141
|
-
].forEach((
|
|
145
|
+
[h],
|
|
146
|
+
[S, { useClass: h }]
|
|
147
|
+
].forEach((r) => e.add(r));
|
|
142
148
|
}
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
],
|
|
149
|
+
}, f(g, "pluginName", P), f(g, "type", u.UNIVER_DOC), g);
|
|
150
|
+
U = K([
|
|
151
|
+
Q(1, O(J))
|
|
152
|
+
], U);
|
|
147
153
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
P as DOCS_DRAWING_PLUGIN,
|
|
155
|
+
$ as DocDrawingApplyType,
|
|
156
|
+
h as DocDrawingService,
|
|
150
157
|
S as IDocDrawingService,
|
|
151
|
-
|
|
152
|
-
|
|
158
|
+
z as SetDocDrawingApplyMutation,
|
|
159
|
+
U as UniverDocsDrawingPlugin
|
|
153
160
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
-
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
1
|
+
import { IDocumentData, Disposable, ICommandService, IResourceManagerService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
|
|
3
2
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
4
3
|
import { IDocDrawingService } from '../services/doc-drawing.service';
|
|
5
4
|
|
|
6
5
|
export declare const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
|
6
|
+
export interface IDocDrawingModel {
|
|
7
|
+
drawings?: IDocumentData['drawings'];
|
|
8
|
+
drawingsOrder?: IDocumentData['drawingsOrder'];
|
|
9
|
+
}
|
|
7
10
|
export declare class DocDrawingLoadController extends Disposable {
|
|
8
11
|
private readonly _commandService;
|
|
9
12
|
constructor(_commandService: ICommandService);
|
|
@@ -13,10 +16,11 @@ export declare class DocDrawingController extends Disposable {
|
|
|
13
16
|
private readonly _drawingManagerService;
|
|
14
17
|
private _resourceManagerService;
|
|
15
18
|
private _univerInstanceService;
|
|
16
|
-
private
|
|
17
|
-
constructor(_docDrawingService: IDocDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService,
|
|
19
|
+
private _lifecycleService;
|
|
20
|
+
constructor(_docDrawingService: IDocDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _lifecycleService: LifecycleService);
|
|
18
21
|
private _init;
|
|
19
22
|
private _initSnapshot;
|
|
20
23
|
private _setDrawingDataForUnit;
|
|
21
24
|
private _initDataLoader;
|
|
25
|
+
private _drawingInitializeListener;
|
|
22
26
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export { UniverDocsDrawingPlugin } from './plugin';
|
|
17
17
|
export { type IDocDrawing, IDocDrawingService, DocDrawingService } from './services/doc-drawing.service';
|
|
18
|
+
export { DOCS_DRAWING_PLUGIN, type IDocDrawingModel } from './controllers/doc-drawing.controller';
|
|
18
19
|
export { SetDocDrawingApplyMutation, DocDrawingApplyType, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,n){typeof exports=="object"&&typeof module<"u"?n(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"],n):(s=typeof globalThis<"u"?globalThis:s||self,n(s.UniverDocsDrawing={},s.UniverCore,s["@wendellhu/redi"],s.UniverDrawing,s.rxjs.operators))})(this,function(s,n,u,S,w){"use strict";var E=Object.defineProperty;var L=(s,n,u)=>n in s?E(s,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[n]=u;var I=(s,n,u)=>L(s,typeof n!="symbol"?n+"":n,u);var D;class U extends S.UnitDrawingService{}const v=u.createIdentifier("univer.doc.plugin.doc-drawing.service");var N=(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))(N||{});const O={id:"doc.mutation.set-drawing-apply",type:n.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(S.IDrawingManagerService),t=i.get(v),a=i.get(n.IUniverInstanceService),{op:c,unitId:o,subUnitId:l,type:m,objects:d}=r;switch(e.applyJson1(o,l,c),t.applyJson1(o,l,c),m){case 0:e.addNotification(d),t.addNotification(d);break;case 1:e.removeNotification(d),t.removeNotification(d);break;case 2:e.updateNotification(d),t.updateNotification(d);break;case 3:e.orderNotification(d),t.orderNotification(d);break;case 4:e.groupUpdateNotification(d);break;case 5:e.ungroupUpdateNotification(d);break}return a.getUnit(o),!0}};var p=Object.defineProperty,R=Object.getOwnPropertyDescriptor,P=(i,r,e,t)=>{for(var a=t>1?void 0:t?R(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(t?o(r,e,a):o(a))||a);return t&&a&&p(r,e,a),a},g=(i,r)=>(e,t)=>r(e,t,i);const h="DOC_DRAWING_PLUGIN";let f=class extends n.Disposable{constructor(i){super(),this._commandService=i,this.disposeWithMe(this._commandService.registerCommand(O))}};f=P([n.OnLifecycle(n.LifecycleStages.Starting,f),g(0,n.ICommandService)],f);let _=class extends n.Disposable{constructor(i,r,e,t,a){super(),this._docDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=e,this._univerInstanceService=t,this._lifecycleService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const i=e=>{const t=this._docDrawingService.getDrawingDataForUnit(e);return t!=null&&t[e]?JSON.stringify(t==null?void 0:t[e]):""},r=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:h,businesses:[n.UniverInstanceType.UNIVER_DOC],toJson:e=>i(e),parseJson:e=>r(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var a,c;this._setDrawingDataForUnit(e,{data:(a=t.data)!=null?a:{},order:(c=t.order)!=null?c:[]})}}))}_setDrawingDataForUnit(i,r){const e=this._univerInstanceService.getUnit(i);e!=null&&(e.resetDrawing(r.data,r.order),this._initDataLoader())}_initDataLoader(){const i=this._univerInstanceService.getCurrentUnitForType(n.UniverInstanceType.UNIVER_DOC);if(!i)return!1;const r=i.getUnitId(),e=r,t=i.getDrawings(),a=i.getDrawingsOrder();if(!t||!a)return!1;Object.keys(t).forEach(o=>{const l=t[o];t[o]={...l}});const c={[e]:{unitId:r,subUnitId:e,data:t,order:a}};return this._docDrawingService.registerDrawingData(r,c),this._drawingManagerService.registerDrawingData(r,c),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(w.filter(i=>i===n.LifecycleStages.Rendered),w.first()).subscribe(i=>{var e;const r=(e=this._univerInstanceService.getCurrentUnitForType(n.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();r&&(this._docDrawingService.initializeNotification(r),this._drawingManagerService.initializeNotification(r))})}};_=P([n.OnLifecycle(n.LifecycleStages.Starting,_),g(0,v),g(1,S.IDrawingManagerService),g(2,n.IResourceManagerService),g(3,n.IUniverInstanceService),g(4,u.Inject(n.LifecycleService))],_);var M=Object.defineProperty,b=Object.getOwnPropertyDescriptor,j=(i,r,e,t)=>{for(var a=t>1?void 0:t?b(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(t?o(r,e,a):o(a))||a);return t&&a&&M(r,e,a),a},C=(i,r)=>(e,t)=>r(e,t,i);s.UniverDocsDrawingPlugin=(D=class extends n.Plugin{constructor(r,e){super(),this._injector=e}onStarting(r){[[f],[_],[U],[v,{useClass:U}]].forEach(e=>r.add(e))}},I(D,"pluginName",h),I(D,"type",n.UniverInstanceType.UNIVER_DOC),D),s.UniverDocsDrawingPlugin=j([C(1,u.Inject(u.Injector))],s.UniverDocsDrawingPlugin),s.DOCS_DRAWING_PLUGIN=h,s.DocDrawingApplyType=N,s.DocDrawingService=U,s.IDocDrawingService=v,s.SetDocDrawingApplyMutation=O,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-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,22 +45,20 @@
|
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@wendellhu/redi": "0.15.5",
|
|
48
|
-
"
|
|
49
|
-
"@univerjs/
|
|
50
|
-
"@univerjs/drawing": "0.2.
|
|
51
|
-
"@univerjs/engine-render": "0.2.1"
|
|
48
|
+
"rxjs": ">=7.0.0",
|
|
49
|
+
"@univerjs/core": "0.2.3",
|
|
50
|
+
"@univerjs/drawing": "0.2.3"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@wendellhu/redi": "0.15.5",
|
|
55
54
|
"typescript": "^5.5.3",
|
|
56
55
|
"vite": "^5.3.3",
|
|
57
56
|
"vitest": "^1.6.0",
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/engine-render": "0.2.1"
|
|
57
|
+
"@univerjs/docs": "0.2.3",
|
|
58
|
+
"@univerjs/core": "0.2.3",
|
|
59
|
+
"@univerjs/drawing": "0.2.3",
|
|
60
|
+
"@univerjs/shared": "0.2.3",
|
|
61
|
+
"@univerjs/engine-render": "0.2.3"
|
|
64
62
|
},
|
|
65
63
|
"univerSpace": {
|
|
66
64
|
".": {
|