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