@univerjs/docs-drawing 0.1.13-nightly.202406041140
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 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/index.js +153 -0
- package/lib/types/commands/mutations/set-drawing-apply.mutation.d.ts +15 -0
- package/lib/types/controllers/doc-drawing.controller.d.ts +22 -0
- package/lib/types/index.d.ts +18 -0
- package/lib/types/plugin.d.ts +10 -0
- package/lib/types/services/doc-drawing.service.d.ts +19 -0
- package/lib/umd/index.js +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @univerjs/docs-drawing
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/packages/@univerjs/docs-drawing)
|
|
4
|
+
[](https://img.shields.io/npm/l/@univerjs/docs-drawing)
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
> TODO: Introduction
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm i @univerjs/docs-drawing
|
|
16
|
+
```
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var R=Object.defineProperty;var O=(r,t,e)=>t in r?R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>(O(r,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),w=require("@wendellhu/redi"),P=require("@univerjs/engine-render"),b=require("@univerjs/docs-ui"),h=require("@univerjs/drawing");class U extends h.UnitDrawingService{}const S=w.createIdentifier("univer.doc.plugin.doc-drawing.service");var I=(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))(I||{});const N={id:"doc.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(r,t)=>{const e=r.get(h.IDrawingManagerService),n=r.get(S),i=r.get(a.IUniverInstanceService),{op:o,unitId:s,subUnitId:g,type:_,objects:c}=t;switch(e.applyJson1(s,g,o),n.applyJson1(s,g,o),_){case 0:e.addNotification(c),n.addNotification(c);break;case 1:e.removeNotification(c),n.removeNotification(c);break;case 2:e.updateNotification(c),n.updateNotification(c);break;case 3:e.orderNotification(c),n.orderNotification(c);break;case 4:e.groupUpdateNotification(c);break;case 5:e.ungroupUpdateNotification(c);break}const f=i.getUnit(s);return f.getSnapshot().drawings=e.getDrawingData(s,g),f.getSnapshot().drawingsOrder=e.getDrawingOrder(s,g),!0}};var m=(r,t,e,n)=>{for(var i=t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},d=(r,t)=>(e,n)=>t(e,n,r);const M="DOC_DRAWING_PLUGIN";let D=class extends a.Disposable{constructor(r){super(),this._commandService=r,this.disposeWithMe(this._commandService.registerCommand(N))}};D=m([a.OnLifecycle(a.LifecycleStages.Starting,D),d(0,a.ICommandService)],D);let v=class extends a.Disposable{constructor(r,t,e,n,i){super(),this._docDrawingService=r,this._drawingManagerService=t,this._resourceManagerService=e,this._univerInstanceService=n,this._textSelectionRenderManager=i,this._init()}_init(){this._initSnapshot(),this._initDataLoader()}_initSnapshot(){const r=e=>{const n=this._docDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:M,businesses:[a.UniverInstanceType.UNIVER_DOC],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._docDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e),this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,n)=>{this._docDrawingService.registerDrawingData(e,n),this._drawingManagerService.registerDrawingData(e,n),this._setDrawingDataForUnit(e,n[e])}}))}_setDrawingDataForUnit(r,t){const e=this._univerInstanceService.getUnit(r);e!=null&&e.resetDrawing(t.data,t.order)}_initDataLoader(){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const t=r.getUnitId(),e=t,n=r.getDrawings(),i=r.getDrawingsOrder();if(!n||!i)return!1;Object.keys(n).forEach(s=>{const g=n[s],_=g.docTransform,c=b.docDrawingPositionToTransform(_);n[s]={...g,transform:c}});const o={[e]:{unitId:t,subUnitId:e,data:n,order:i}};return this._docDrawingService.registerDrawingData(t,o),this._drawingManagerService.registerDrawingData(t,o),!0}};v=m([a.OnLifecycle(a.LifecycleStages.Rendered,v),d(0,S),d(1,h.IDrawingManagerService),d(2,a.IResourceManagerService),d(3,a.IUniverInstanceService),d(4,P.ITextSelectionRenderManager)],v);var E=(r,t,e,n)=>{for(var i=t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},C=(r,t)=>(e,n)=>t(e,n,r),u;exports.UniverDocsDrawingPlugin=(u=class extends a.Plugin{constructor(t,e){super(),this._injector=e}onStarting(t){[[D],[v],[U],[S,{useClass:U}]].forEach(e=>t.add(e))}},l(u,"pluginName",M),l(u,"type",a.UniverInstanceType.UNIVER_DOC),u);exports.UniverDocsDrawingPlugin=E([C(1,w.Inject(w.Injector))],exports.UniverDocsDrawingPlugin);exports.DocDrawingApplyType=I;exports.DocDrawingService=U;exports.IDocDrawingService=S;exports.SetDocDrawingApplyMutation=N;
|
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var C = (e, t, r) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var D = (e, t, r) => (C(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
import { CommandType as P, IUniverInstanceService as l, OnLifecycle as w, LifecycleStages as N, Disposable as I, ICommandService as b, UniverInstanceType as S, IResourceManagerService as k, Plugin as p } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as G, Inject as L, Injector as J } from "@wendellhu/redi";
|
|
6
|
+
import { ITextSelectionRenderManager as x } from "@univerjs/engine-render";
|
|
7
|
+
import { docDrawingPositionToTransform as F } from "@univerjs/docs-ui";
|
|
8
|
+
import { UnitDrawingService as V, IDrawingManagerService as M } from "@univerjs/drawing";
|
|
9
|
+
class m extends V {
|
|
10
|
+
}
|
|
11
|
+
const h = G("univer.doc.plugin.doc-drawing.service");
|
|
12
|
+
var j = /* @__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))(j || {});
|
|
13
|
+
const W = {
|
|
14
|
+
id: "doc.mutation.set-drawing-apply",
|
|
15
|
+
type: P.MUTATION,
|
|
16
|
+
handler: (e, t) => {
|
|
17
|
+
const r = e.get(M), i = e.get(h), a = e.get(l), { op: s, unitId: n, subUnitId: c, type: _, objects: o } = t;
|
|
18
|
+
switch (r.applyJson1(n, c, s), i.applyJson1(n, c, s), _) {
|
|
19
|
+
case 0:
|
|
20
|
+
r.addNotification(o), i.addNotification(o);
|
|
21
|
+
break;
|
|
22
|
+
case 1:
|
|
23
|
+
r.removeNotification(o), i.removeNotification(o);
|
|
24
|
+
break;
|
|
25
|
+
case 2:
|
|
26
|
+
r.updateNotification(o), i.updateNotification(o);
|
|
27
|
+
break;
|
|
28
|
+
case 3:
|
|
29
|
+
r.orderNotification(o), i.orderNotification(o);
|
|
30
|
+
break;
|
|
31
|
+
case 4:
|
|
32
|
+
r.groupUpdateNotification(o);
|
|
33
|
+
break;
|
|
34
|
+
case 5:
|
|
35
|
+
r.ungroupUpdateNotification(o);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
const f = a.getUnit(n);
|
|
39
|
+
return f.getSnapshot().drawings = r.getDrawingData(n, c), f.getSnapshot().drawingsOrder = r.getDrawingOrder(n, c), !0;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var R = (e, t, r, i) => {
|
|
43
|
+
for (var a = t, s = e.length - 1, n; s >= 0; s--)
|
|
44
|
+
(n = e[s]) && (a = n(a) || a);
|
|
45
|
+
return a;
|
|
46
|
+
}, d = (e, t) => (r, i) => t(r, i, e);
|
|
47
|
+
const O = "DOC_DRAWING_PLUGIN";
|
|
48
|
+
let u = class extends I {
|
|
49
|
+
constructor(e) {
|
|
50
|
+
super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(W));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
u = R([
|
|
54
|
+
w(N.Starting, u),
|
|
55
|
+
d(0, b)
|
|
56
|
+
], u);
|
|
57
|
+
let v = class extends I {
|
|
58
|
+
constructor(e, t, r, i, a) {
|
|
59
|
+
super(), this._docDrawingService = e, this._drawingManagerService = t, this._resourceManagerService = r, this._univerInstanceService = i, this._textSelectionRenderManager = a, this._init();
|
|
60
|
+
}
|
|
61
|
+
_init() {
|
|
62
|
+
this._initSnapshot(), this._initDataLoader();
|
|
63
|
+
}
|
|
64
|
+
_initSnapshot() {
|
|
65
|
+
const e = (r) => {
|
|
66
|
+
const i = this._docDrawingService.getDrawingDataForUnit(r);
|
|
67
|
+
return i ? JSON.stringify(i) : "";
|
|
68
|
+
}, t = (r) => {
|
|
69
|
+
if (!r)
|
|
70
|
+
return {};
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(r);
|
|
73
|
+
} catch {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.disposeWithMe(
|
|
78
|
+
this._resourceManagerService.registerPluginResource({
|
|
79
|
+
pluginName: O,
|
|
80
|
+
businesses: [S.UNIVER_DOC],
|
|
81
|
+
toJson: (r) => e(r),
|
|
82
|
+
parseJson: (r) => t(r),
|
|
83
|
+
onUnLoad: (r) => {
|
|
84
|
+
this._docDrawingService.removeDrawingDataForUnit(r), this._drawingManagerService.removeDrawingDataForUnit(r), this._setDrawingDataForUnit(r, { data: {}, order: [] });
|
|
85
|
+
},
|
|
86
|
+
onLoad: (r, i) => {
|
|
87
|
+
this._docDrawingService.registerDrawingData(r, i), this._drawingManagerService.registerDrawingData(r, i), this._setDrawingDataForUnit(r, i[r]);
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
_setDrawingDataForUnit(e, t) {
|
|
93
|
+
const r = this._univerInstanceService.getUnit(e);
|
|
94
|
+
r != null && r.resetDrawing(t.data, t.order);
|
|
95
|
+
}
|
|
96
|
+
_initDataLoader() {
|
|
97
|
+
const e = this._univerInstanceService.getCurrentUnitForType(S.UNIVER_DOC);
|
|
98
|
+
if (!e)
|
|
99
|
+
return !1;
|
|
100
|
+
const t = e.getUnitId(), r = t, i = e.getDrawings(), a = e.getDrawingsOrder();
|
|
101
|
+
if (!i || !a)
|
|
102
|
+
return !1;
|
|
103
|
+
Object.keys(i).forEach((n) => {
|
|
104
|
+
const c = i[n], _ = c.docTransform, o = F(_);
|
|
105
|
+
i[n] = { ...c, transform: o };
|
|
106
|
+
});
|
|
107
|
+
const s = {
|
|
108
|
+
[r]: {
|
|
109
|
+
unitId: t,
|
|
110
|
+
subUnitId: r,
|
|
111
|
+
data: i,
|
|
112
|
+
order: a
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return this._docDrawingService.registerDrawingData(t, s), this._drawingManagerService.registerDrawingData(t, s), !0;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
v = R([
|
|
119
|
+
w(N.Rendered, v),
|
|
120
|
+
d(0, h),
|
|
121
|
+
d(1, M),
|
|
122
|
+
d(2, k),
|
|
123
|
+
d(3, l),
|
|
124
|
+
d(4, x)
|
|
125
|
+
], v);
|
|
126
|
+
var T = (e, t, r, i) => {
|
|
127
|
+
for (var a = t, s = e.length - 1, n; s >= 0; s--)
|
|
128
|
+
(n = e[s]) && (a = n(a) || a);
|
|
129
|
+
return a;
|
|
130
|
+
}, $ = (e, t) => (r, i) => t(r, i, e), g;
|
|
131
|
+
let U = (g = class extends p {
|
|
132
|
+
constructor(e, t) {
|
|
133
|
+
super(), this._injector = t;
|
|
134
|
+
}
|
|
135
|
+
onStarting(e) {
|
|
136
|
+
[
|
|
137
|
+
[u],
|
|
138
|
+
[v],
|
|
139
|
+
[m],
|
|
140
|
+
[h, { useClass: m }]
|
|
141
|
+
].forEach((t) => e.add(t));
|
|
142
|
+
}
|
|
143
|
+
}, D(g, "pluginName", O), D(g, "type", S.UNIVER_DOC), g);
|
|
144
|
+
U = T([
|
|
145
|
+
$(1, L(J))
|
|
146
|
+
], U);
|
|
147
|
+
export {
|
|
148
|
+
j as DocDrawingApplyType,
|
|
149
|
+
m as DocDrawingService,
|
|
150
|
+
h as IDocDrawingService,
|
|
151
|
+
W as SetDocDrawingApplyMutation,
|
|
152
|
+
U as UniverDocsDrawingPlugin
|
|
153
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IMutation } from '@univerjs/core';
|
|
2
|
+
import { IDrawingJson1Type } from '@univerjs/drawing';
|
|
3
|
+
|
|
4
|
+
export declare enum DocDrawingApplyType {
|
|
5
|
+
INSERT = 0,
|
|
6
|
+
REMOVE = 1,
|
|
7
|
+
UPDATE = 2,
|
|
8
|
+
ARRANGE = 3,
|
|
9
|
+
GROUP = 4,
|
|
10
|
+
UNGROUP = 5
|
|
11
|
+
}
|
|
12
|
+
export interface ISetDrawingApplyMutationParams extends IDrawingJson1Type {
|
|
13
|
+
type: DocDrawingApplyType;
|
|
14
|
+
}
|
|
15
|
+
export declare const SetDocDrawingApplyMutation: IMutation<ISetDrawingApplyMutationParams>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
3
|
+
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
4
|
+
import { IDocDrawingService } from '../services/doc-drawing.service';
|
|
5
|
+
|
|
6
|
+
export declare const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
|
7
|
+
export declare class DocDrawingLoadController extends Disposable {
|
|
8
|
+
private readonly _commandService;
|
|
9
|
+
constructor(_commandService: ICommandService);
|
|
10
|
+
}
|
|
11
|
+
export declare class DocDrawingController extends Disposable {
|
|
12
|
+
private readonly _docDrawingService;
|
|
13
|
+
private readonly _drawingManagerService;
|
|
14
|
+
private _resourceManagerService;
|
|
15
|
+
private _univerInstanceService;
|
|
16
|
+
private readonly _textSelectionRenderManager;
|
|
17
|
+
constructor(_docDrawingService: IDocDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _textSelectionRenderManager: ITextSelectionRenderManager);
|
|
18
|
+
private _init;
|
|
19
|
+
private _initSnapshot;
|
|
20
|
+
private _setDrawingDataForUnit;
|
|
21
|
+
private _initDataLoader;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export { UniverDocsDrawingPlugin } from './plugin';
|
|
17
|
+
export { DocDrawingApplyType, SetDocDrawingApplyMutation, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
|
|
18
|
+
export { type IDocDrawing, IDocDrawingService, DocDrawingService } from './services/doc-drawing.service';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
+
import { Injector } from '@wendellhu/redi';
|
|
3
|
+
|
|
4
|
+
export declare class UniverDocsDrawingPlugin extends Plugin {
|
|
5
|
+
_injector: Injector;
|
|
6
|
+
static pluginName: string;
|
|
7
|
+
static type: UniverInstanceType;
|
|
8
|
+
constructor(_config: undefined, _injector: Injector);
|
|
9
|
+
onStarting(_injector: Injector): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IDocDrawingBase } from '@univerjs/core';
|
|
2
|
+
import { IImageData, IUnitDrawingService, UnitDrawingService } from '@univerjs/drawing';
|
|
3
|
+
|
|
4
|
+
export interface IDocImage extends IImageData, IDocDrawingBase {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* test type
|
|
8
|
+
*/
|
|
9
|
+
export interface IDocShape extends IDocDrawingBase {
|
|
10
|
+
}
|
|
11
|
+
export type IDocDrawing = IDocImage | IDocShape;
|
|
12
|
+
type OptionalField<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
13
|
+
export type IDocUpdateDrawing = OptionalField<IDocDrawing, 'drawingType' | 'layoutType' | 'docTransform' | 'description' | 'title'>;
|
|
14
|
+
export declare class DocDrawingService extends UnitDrawingService<IDocDrawing> {
|
|
15
|
+
}
|
|
16
|
+
export interface IDocDrawingService extends IUnitDrawingService<IDocDrawing> {
|
|
17
|
+
}
|
|
18
|
+
export declare const IDocDrawingService: import('@wendellhu/redi').IdentifierDecorator<IDocDrawingService>;
|
|
19
|
+
export {};
|
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/engine-render"),require("@univerjs/docs-ui"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/engine-render","@univerjs/docs-ui","@univerjs/drawing"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.UniverDocsDrawing={},a.UniverCore,a["@wendellhu/redi"],a.UniverEngineRender,a.UniverDocsUi,a.UniverDrawing))})(this,function(a,i,g,O,P,h){"use strict";var j=Object.defineProperty;var p=(a,i,g)=>i in a?j(a,i,{enumerable:!0,configurable:!0,writable:!0,value:g}):a[i]=g;var l=(a,i,g)=>(p(a,typeof i!="symbol"?i+"":i,g),g);var U;class w extends h.UnitDrawingService{}const D=g.createIdentifier("univer.doc.plugin.doc-drawing.service");var I=(n=>(n[n.INSERT=0]="INSERT",n[n.REMOVE=1]="REMOVE",n[n.UPDATE=2]="UPDATE",n[n.ARRANGE=3]="ARRANGE",n[n.GROUP=4]="GROUP",n[n.UNGROUP=5]="UNGROUP",n))(I||{});const m={id:"doc.mutation.set-drawing-apply",type:i.CommandType.MUTATION,handler:(n,t)=>{const e=n.get(h.IDrawingManagerService),r=n.get(D),s=n.get(i.IUniverInstanceService),{op:c,unitId:o,subUnitId:u,type:_,objects:d}=t;switch(e.applyJson1(o,u,c),r.applyJson1(o,u,c),_){case 0:e.addNotification(d),r.addNotification(d);break;case 1:e.removeNotification(d),r.removeNotification(d);break;case 2:e.updateNotification(d),r.updateNotification(d);break;case 3:e.orderNotification(d),r.orderNotification(d);break;case 4:e.groupUpdateNotification(d);break;case 5:e.ungroupUpdateNotification(d);break}const R=s.getUnit(o);return R.getSnapshot().drawings=e.getDrawingData(o,u),R.getSnapshot().drawingsOrder=e.getDrawingOrder(o,u),!0}};var N=(n,t,e,r)=>{for(var s=t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(s=o(s)||s);return s},v=(n,t)=>(e,r)=>t(e,r,n);const M="DOC_DRAWING_PLUGIN";let S=class extends i.Disposable{constructor(n){super(),this._commandService=n,this.disposeWithMe(this._commandService.registerCommand(m))}};S=N([i.OnLifecycle(i.LifecycleStages.Starting,S),v(0,i.ICommandService)],S);let f=class extends i.Disposable{constructor(n,t,e,r,s){super(),this._docDrawingService=n,this._drawingManagerService=t,this._resourceManagerService=e,this._univerInstanceService=r,this._textSelectionRenderManager=s,this._init()}_init(){this._initSnapshot(),this._initDataLoader()}_initSnapshot(){const n=e=>{const r=this._docDrawingService.getDrawingDataForUnit(e);return r?JSON.stringify(r):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:M,businesses:[i.UniverInstanceType.UNIVER_DOC],toJson:e=>n(e),parseJson:e=>t(e),onUnLoad:e=>{this._docDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e),this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,r)=>{this._docDrawingService.registerDrawingData(e,r),this._drawingManagerService.registerDrawingData(e,r),this._setDrawingDataForUnit(e,r[e])}}))}_setDrawingDataForUnit(n,t){const e=this._univerInstanceService.getUnit(n);e!=null&&e.resetDrawing(t.data,t.order)}_initDataLoader(){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(!n)return!1;const t=n.getUnitId(),e=t,r=n.getDrawings(),s=n.getDrawingsOrder();if(!r||!s)return!1;Object.keys(r).forEach(o=>{const u=r[o],_=u.docTransform,d=P.docDrawingPositionToTransform(_);r[o]={...u,transform:d}});const c={[e]:{unitId:t,subUnitId:e,data:r,order:s}};return this._docDrawingService.registerDrawingData(t,c),this._drawingManagerService.registerDrawingData(t,c),!0}};f=N([i.OnLifecycle(i.LifecycleStages.Rendered,f),v(0,D),v(1,h.IDrawingManagerService),v(2,i.IResourceManagerService),v(3,i.IUniverInstanceService),v(4,O.ITextSelectionRenderManager)],f);var E=(n,t,e,r)=>{for(var s=t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(s=o(s)||s);return s},C=(n,t)=>(e,r)=>t(e,r,n);a.UniverDocsDrawingPlugin=(U=class extends i.Plugin{constructor(t,e){super(),this._injector=e}onStarting(t){[[S],[f],[w],[D,{useClass:w}]].forEach(e=>t.add(e))}},l(U,"pluginName",M),l(U,"type",i.UniverInstanceType.UNIVER_DOC),U),a.UniverDocsDrawingPlugin=E([C(1,g.Inject(g.Injector))],a.UniverDocsDrawingPlugin),a.DocDrawingApplyType=I,a.DocDrawingService=w,a.IDocDrawingService=D,a.SetDocDrawingApplyMutation=m,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univerjs/docs-drawing",
|
|
3
|
+
"version": "0.1.13-nightly.202406041140",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": "DreamNum <developer@univer.ai>",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/univer"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://univer.ai",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/dream-num/univer"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/dream-num/univer/issues"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./lib/es/index.js",
|
|
24
|
+
"require": "./lib/cjs/index.js",
|
|
25
|
+
"types": "./lib/types/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./*": {
|
|
28
|
+
"import": "./lib/es/*",
|
|
29
|
+
"require": "./lib/cjs/*",
|
|
30
|
+
"types": "./lib/types/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./lib/*": "./lib/*"
|
|
33
|
+
},
|
|
34
|
+
"main": "./lib/cjs/index.js",
|
|
35
|
+
"module": "./lib/es/index.js",
|
|
36
|
+
"types": "./lib/types/index.d.ts",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"directories": {
|
|
41
|
+
"lib": "lib"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"lib"
|
|
45
|
+
],
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@wendellhu/redi": "0.15.2",
|
|
48
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
49
|
+
"@univerjs/docs-ui": "0.1.13-nightly.202406041140",
|
|
50
|
+
"@univerjs/drawing": "0.1.13-nightly.202406041140",
|
|
51
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@wendellhu/redi": "^0.15.2",
|
|
56
|
+
"typescript": "^5.4.5",
|
|
57
|
+
"vite": "^5.2.12",
|
|
58
|
+
"vitest": "^1.6.0",
|
|
59
|
+
"@univerjs/docs": "0.1.13-nightly.202406041140",
|
|
60
|
+
"@univerjs/drawing": "0.1.13-nightly.202406041140",
|
|
61
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
62
|
+
"@univerjs/docs-ui": "0.1.13-nightly.202406041140",
|
|
63
|
+
"@univerjs/shared": "0.1.13",
|
|
64
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest",
|
|
69
|
+
"coverage": "vitest run --coverage",
|
|
70
|
+
"lint:types": "tsc --noEmit",
|
|
71
|
+
"build": "tsc && vite build"
|
|
72
|
+
}
|
|
73
|
+
}
|