@univerjs/docs-drawing 1.0.0-alpha.1 → 1.0.0-alpha.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/lib/cjs/index.js +43 -1
- package/lib/es/index.js +43 -3
- package/lib/index.js +43 -3
- package/lib/types/index.d.ts +2 -0
- package/lib/types/services/doc-drawing-adapter.service.d.ts +54 -0
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -136,7 +136,7 @@ DocDrawingController = __decorate([
|
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region package.json
|
|
138
138
|
var name = "@univerjs/docs-drawing";
|
|
139
|
-
var version = "1.0.0-alpha.
|
|
139
|
+
var version = "1.0.0-alpha.3";
|
|
140
140
|
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/config/config.ts
|
|
@@ -201,6 +201,44 @@ function _defineProperty(e, r, t) {
|
|
|
201
201
|
}) : e[r] = t, e;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/services/doc-drawing-adapter.service.ts
|
|
206
|
+
const IDocDrawingAdapterService = (0, _univerjs_core.createIdentifier)("doc.drawing-adapter.service");
|
|
207
|
+
var DocDrawingAdapterService = class {
|
|
208
|
+
constructor() {
|
|
209
|
+
_defineProperty(this, "_adapters", []);
|
|
210
|
+
}
|
|
211
|
+
registerAdapter(adapter) {
|
|
212
|
+
this._adapters.push(adapter);
|
|
213
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
214
|
+
const index = this._adapters.indexOf(adapter);
|
|
215
|
+
if (index >= 0) this._adapters.splice(index, 1);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
getRemoveDrawingMutationInfos(params) {
|
|
219
|
+
const mutationInfos = {
|
|
220
|
+
redoMutations: [],
|
|
221
|
+
undoMutations: []
|
|
222
|
+
};
|
|
223
|
+
for (const adapter of this._adapters) {
|
|
224
|
+
var _adapter$getRemoveDra;
|
|
225
|
+
const nextMutationInfos = (_adapter$getRemoveDra = adapter.getRemoveDrawingMutationInfos) === null || _adapter$getRemoveDra === void 0 ? void 0 : _adapter$getRemoveDra.call(adapter, params);
|
|
226
|
+
if (!nextMutationInfos) continue;
|
|
227
|
+
mutationInfos.redoMutations.push(...nextMutationInfos.redoMutations);
|
|
228
|
+
mutationInfos.undoMutations.push(...nextMutationInfos.undoMutations);
|
|
229
|
+
}
|
|
230
|
+
return mutationInfos;
|
|
231
|
+
}
|
|
232
|
+
getEditDrawingCommandInfo(params) {
|
|
233
|
+
for (const adapter of this._adapters) {
|
|
234
|
+
var _adapter$getEditDrawi;
|
|
235
|
+
const commandInfo = (_adapter$getEditDrawi = adapter.getEditDrawingCommandInfo) === null || _adapter$getEditDrawi === void 0 ? void 0 : _adapter$getEditDrawi.call(adapter, params);
|
|
236
|
+
if (commandInfo) return commandInfo;
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
204
242
|
//#endregion
|
|
205
243
|
//#region src/plugin.ts
|
|
206
244
|
let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends _univerjs_core.Plugin {
|
|
@@ -215,6 +253,8 @@ let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends _univerjs_co
|
|
|
215
253
|
onStarting() {
|
|
216
254
|
[
|
|
217
255
|
[DocDrawingController],
|
|
256
|
+
[DocDrawingAdapterService],
|
|
257
|
+
[IDocDrawingAdapterService, { useClass: DocDrawingAdapterService }],
|
|
218
258
|
[DocDrawingService],
|
|
219
259
|
[IDocDrawingService, { useClass: DocDrawingService }]
|
|
220
260
|
].forEach((dependency) => this._injector.add(dependency));
|
|
@@ -229,6 +269,7 @@ UniverDocsDrawingPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inje
|
|
|
229
269
|
|
|
230
270
|
//#endregion
|
|
231
271
|
exports.DOCS_DRAWING_PLUGIN = DOCS_DRAWING_PLUGIN;
|
|
272
|
+
exports.DocDrawingAdapterService = DocDrawingAdapterService;
|
|
232
273
|
Object.defineProperty(exports, 'DocDrawingController', {
|
|
233
274
|
enumerable: true,
|
|
234
275
|
get: function () {
|
|
@@ -236,6 +277,7 @@ Object.defineProperty(exports, 'DocDrawingController', {
|
|
|
236
277
|
}
|
|
237
278
|
});
|
|
238
279
|
exports.DocDrawingService = DocDrawingService;
|
|
280
|
+
exports.IDocDrawingAdapterService = IDocDrawingAdapterService;
|
|
239
281
|
exports.IDocDrawingService = IDocDrawingService;
|
|
240
282
|
Object.defineProperty(exports, 'UniverDocsDrawingPlugin', {
|
|
241
283
|
enumerable: true,
|
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { IDrawingManagerService, UnitDrawingService } from "@univerjs/drawing";
|
|
3
3
|
|
|
4
4
|
//#region src/services/doc-drawing.service.ts
|
|
@@ -135,7 +135,7 @@ DocDrawingController = __decorate([
|
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
137
|
var name = "@univerjs/docs-drawing";
|
|
138
|
-
var version = "1.0.0-alpha.
|
|
138
|
+
var version = "1.0.0-alpha.3";
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/config/config.ts
|
|
@@ -200,6 +200,44 @@ function _defineProperty(e, r, t) {
|
|
|
200
200
|
}) : e[r] = t, e;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/services/doc-drawing-adapter.service.ts
|
|
205
|
+
const IDocDrawingAdapterService = createIdentifier("doc.drawing-adapter.service");
|
|
206
|
+
var DocDrawingAdapterService = class {
|
|
207
|
+
constructor() {
|
|
208
|
+
_defineProperty(this, "_adapters", []);
|
|
209
|
+
}
|
|
210
|
+
registerAdapter(adapter) {
|
|
211
|
+
this._adapters.push(adapter);
|
|
212
|
+
return toDisposable(() => {
|
|
213
|
+
const index = this._adapters.indexOf(adapter);
|
|
214
|
+
if (index >= 0) this._adapters.splice(index, 1);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
getRemoveDrawingMutationInfos(params) {
|
|
218
|
+
const mutationInfos = {
|
|
219
|
+
redoMutations: [],
|
|
220
|
+
undoMutations: []
|
|
221
|
+
};
|
|
222
|
+
for (const adapter of this._adapters) {
|
|
223
|
+
var _adapter$getRemoveDra;
|
|
224
|
+
const nextMutationInfos = (_adapter$getRemoveDra = adapter.getRemoveDrawingMutationInfos) === null || _adapter$getRemoveDra === void 0 ? void 0 : _adapter$getRemoveDra.call(adapter, params);
|
|
225
|
+
if (!nextMutationInfos) continue;
|
|
226
|
+
mutationInfos.redoMutations.push(...nextMutationInfos.redoMutations);
|
|
227
|
+
mutationInfos.undoMutations.push(...nextMutationInfos.undoMutations);
|
|
228
|
+
}
|
|
229
|
+
return mutationInfos;
|
|
230
|
+
}
|
|
231
|
+
getEditDrawingCommandInfo(params) {
|
|
232
|
+
for (const adapter of this._adapters) {
|
|
233
|
+
var _adapter$getEditDrawi;
|
|
234
|
+
const commandInfo = (_adapter$getEditDrawi = adapter.getEditDrawingCommandInfo) === null || _adapter$getEditDrawi === void 0 ? void 0 : _adapter$getEditDrawi.call(adapter, params);
|
|
235
|
+
if (commandInfo) return commandInfo;
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
203
241
|
//#endregion
|
|
204
242
|
//#region src/plugin.ts
|
|
205
243
|
let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends Plugin {
|
|
@@ -214,6 +252,8 @@ let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends Plugin {
|
|
|
214
252
|
onStarting() {
|
|
215
253
|
[
|
|
216
254
|
[DocDrawingController],
|
|
255
|
+
[DocDrawingAdapterService],
|
|
256
|
+
[IDocDrawingAdapterService, { useClass: DocDrawingAdapterService }],
|
|
217
257
|
[DocDrawingService],
|
|
218
258
|
[IDocDrawingService, { useClass: DocDrawingService }]
|
|
219
259
|
].forEach((dependency) => this._injector.add(dependency));
|
|
@@ -227,4 +267,4 @@ _defineProperty(UniverDocsDrawingPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
|
227
267
|
UniverDocsDrawingPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverDocsDrawingPlugin);
|
|
228
268
|
|
|
229
269
|
//#endregion
|
|
230
|
-
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
|
270
|
+
export { DOCS_DRAWING_PLUGIN, DocDrawingAdapterService, DocDrawingController, DocDrawingService, IDocDrawingAdapterService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { IDrawingManagerService, UnitDrawingService } from "@univerjs/drawing";
|
|
3
3
|
|
|
4
4
|
//#region src/services/doc-drawing.service.ts
|
|
@@ -135,7 +135,7 @@ DocDrawingController = __decorate([
|
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
137
|
var name = "@univerjs/docs-drawing";
|
|
138
|
-
var version = "1.0.0-alpha.
|
|
138
|
+
var version = "1.0.0-alpha.3";
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/config/config.ts
|
|
@@ -200,6 +200,44 @@ function _defineProperty(e, r, t) {
|
|
|
200
200
|
}) : e[r] = t, e;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/services/doc-drawing-adapter.service.ts
|
|
205
|
+
const IDocDrawingAdapterService = createIdentifier("doc.drawing-adapter.service");
|
|
206
|
+
var DocDrawingAdapterService = class {
|
|
207
|
+
constructor() {
|
|
208
|
+
_defineProperty(this, "_adapters", []);
|
|
209
|
+
}
|
|
210
|
+
registerAdapter(adapter) {
|
|
211
|
+
this._adapters.push(adapter);
|
|
212
|
+
return toDisposable(() => {
|
|
213
|
+
const index = this._adapters.indexOf(adapter);
|
|
214
|
+
if (index >= 0) this._adapters.splice(index, 1);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
getRemoveDrawingMutationInfos(params) {
|
|
218
|
+
const mutationInfos = {
|
|
219
|
+
redoMutations: [],
|
|
220
|
+
undoMutations: []
|
|
221
|
+
};
|
|
222
|
+
for (const adapter of this._adapters) {
|
|
223
|
+
var _adapter$getRemoveDra;
|
|
224
|
+
const nextMutationInfos = (_adapter$getRemoveDra = adapter.getRemoveDrawingMutationInfos) === null || _adapter$getRemoveDra === void 0 ? void 0 : _adapter$getRemoveDra.call(adapter, params);
|
|
225
|
+
if (!nextMutationInfos) continue;
|
|
226
|
+
mutationInfos.redoMutations.push(...nextMutationInfos.redoMutations);
|
|
227
|
+
mutationInfos.undoMutations.push(...nextMutationInfos.undoMutations);
|
|
228
|
+
}
|
|
229
|
+
return mutationInfos;
|
|
230
|
+
}
|
|
231
|
+
getEditDrawingCommandInfo(params) {
|
|
232
|
+
for (const adapter of this._adapters) {
|
|
233
|
+
var _adapter$getEditDrawi;
|
|
234
|
+
const commandInfo = (_adapter$getEditDrawi = adapter.getEditDrawingCommandInfo) === null || _adapter$getEditDrawi === void 0 ? void 0 : _adapter$getEditDrawi.call(adapter, params);
|
|
235
|
+
if (commandInfo) return commandInfo;
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
203
241
|
//#endregion
|
|
204
242
|
//#region src/plugin.ts
|
|
205
243
|
let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends Plugin {
|
|
@@ -214,6 +252,8 @@ let UniverDocsDrawingPlugin = class UniverDocsDrawingPlugin extends Plugin {
|
|
|
214
252
|
onStarting() {
|
|
215
253
|
[
|
|
216
254
|
[DocDrawingController],
|
|
255
|
+
[DocDrawingAdapterService],
|
|
256
|
+
[IDocDrawingAdapterService, { useClass: DocDrawingAdapterService }],
|
|
217
257
|
[DocDrawingService],
|
|
218
258
|
[IDocDrawingService, { useClass: DocDrawingService }]
|
|
219
259
|
].forEach((dependency) => this._injector.add(dependency));
|
|
@@ -227,4 +267,4 @@ _defineProperty(UniverDocsDrawingPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
|
227
267
|
UniverDocsDrawingPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverDocsDrawingPlugin);
|
|
228
268
|
|
|
229
269
|
//#endregion
|
|
230
|
-
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
|
270
|
+
export { DOCS_DRAWING_PLUGIN, DocDrawingAdapterService, DocDrawingController, DocDrawingService, IDocDrawingAdapterService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export { DOCS_DRAWING_PLUGIN, getDocDrawingRenderOrder } from './controllers/doc
|
|
|
18
18
|
export type { IDocDrawingModel } from './controllers/doc-drawing.controller';
|
|
19
19
|
export { DocDrawingController } from './controllers/doc-drawing.controller';
|
|
20
20
|
export { UniverDocsDrawingPlugin } from './plugin';
|
|
21
|
+
export { DocDrawingAdapterService, IDocDrawingAdapterService } from './services/doc-drawing-adapter.service';
|
|
22
|
+
export type { IDocDrawingAdapter, IDocDrawingMutationInfos, IDocDrawingRemoveMutationInfoParams, } from './services/doc-drawing-adapter.service';
|
|
21
23
|
export { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';
|
|
22
24
|
export type { IDocDrawing, IDocImage } from './services/doc-drawing.service';
|
|
23
25
|
export { type IDocFloatDom } from './services/doc-drawing.service';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type { IDisposable, IMutationInfo } from '@univerjs/core';
|
|
17
|
+
import type { IDocDrawing } from './doc-drawing.service';
|
|
18
|
+
export interface IDocDrawingRemoveMutationInfoParams {
|
|
19
|
+
unitId: string;
|
|
20
|
+
subUnitId: string;
|
|
21
|
+
drawing: IDocDrawing;
|
|
22
|
+
removeDrawings: readonly IDocDrawing[];
|
|
23
|
+
}
|
|
24
|
+
export interface IDocDrawingEditCommandInfoParams {
|
|
25
|
+
unitId: string;
|
|
26
|
+
subUnitId: string;
|
|
27
|
+
drawing: IDocDrawing;
|
|
28
|
+
}
|
|
29
|
+
export interface IDocDrawingMutationInfos {
|
|
30
|
+
redoMutations: IMutationInfo[];
|
|
31
|
+
undoMutations: IMutationInfo[];
|
|
32
|
+
}
|
|
33
|
+
export interface IDocDrawingEditCommandInfo {
|
|
34
|
+
label?: string;
|
|
35
|
+
commandId: string;
|
|
36
|
+
commandParams?: unknown;
|
|
37
|
+
disable?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface IDocDrawingAdapter {
|
|
40
|
+
getRemoveDrawingMutationInfos?: (params: IDocDrawingRemoveMutationInfoParams) => IDocDrawingMutationInfos | null | undefined;
|
|
41
|
+
getEditDrawingCommandInfo?: (params: IDocDrawingEditCommandInfoParams) => IDocDrawingEditCommandInfo | null | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface IDocDrawingAdapterService {
|
|
44
|
+
registerAdapter(adapter: IDocDrawingAdapter): IDisposable;
|
|
45
|
+
getRemoveDrawingMutationInfos(params: IDocDrawingRemoveMutationInfoParams): IDocDrawingMutationInfos;
|
|
46
|
+
getEditDrawingCommandInfo(params: IDocDrawingEditCommandInfoParams): IDocDrawingEditCommandInfo | null;
|
|
47
|
+
}
|
|
48
|
+
export declare const IDocDrawingAdapterService: import("@wendellhu/redi").IdentifierDecorator<IDocDrawingAdapterService>;
|
|
49
|
+
export declare class DocDrawingAdapterService implements IDocDrawingAdapterService {
|
|
50
|
+
private readonly _adapters;
|
|
51
|
+
registerAdapter(adapter: IDocDrawingAdapter): IDisposable;
|
|
52
|
+
getRemoveDrawingMutationInfos(params: IDocDrawingRemoveMutationInfoParams): IDocDrawingMutationInfos;
|
|
53
|
+
getEditDrawingCommandInfo(params: IDocDrawingEditCommandInfoParams): IDocDrawingEditCommandInfo | null;
|
|
54
|
+
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=`DOC_DRAWING_PLUGIN`;function c(e,t={}){return e.map((e,t)=>({drawingId:e,index:t})).sort((e,n)=>{let r=l(t[e.drawingId]);return r===l(t[n.drawingId])?e.index-n.index:r?-1:1}).map(({drawingId:e})=>e)}function l(e){return(e==null?void 0:e.layoutType)===t.PositionedObjectLayoutType.WRAP_NONE&&e.behindDoc===t.BooleanNumber.TRUE}let u=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder;return JSON.stringify({data:e==null?{}:e,order:t==null?[]:t})}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}},s={[r]:{...o[r],order:c(a,i)}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,s),!0}};u=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],u);var d=`@univerjs/docs-drawing`,f=`1.0.0-alpha.
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=`DOC_DRAWING_PLUGIN`;function c(e,t={}){return e.map((e,t)=>({drawingId:e,index:t})).sort((e,n)=>{let r=l(t[e.drawingId]);return r===l(t[n.drawingId])?e.index-n.index:r?-1:1}).map(({drawingId:e})=>e)}function l(e){return(e==null?void 0:e.layoutType)===t.PositionedObjectLayoutType.WRAP_NONE&&e.behindDoc===t.BooleanNumber.TRUE}let u=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder;return JSON.stringify({data:e==null?{}:e,order:t==null?[]:t})}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}},s={[r]:{...o[r],order:c(a,i)}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,s),!0}};u=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],u);var d=`@univerjs/docs-drawing`,f=`1.0.0-alpha.3`;let p={};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let v=(0,t.createIdentifier)(`doc.drawing-adapter.service`);var y=class{constructor(){_(this,`_adapters`,[])}registerAdapter(e){return this._adapters.push(e),(0,t.toDisposable)(()=>{let t=this._adapters.indexOf(e);t>=0&&this._adapters.splice(t,1)})}getRemoveDrawingMutationInfos(e){let t={redoMutations:[],undoMutations:[]};for(let r of this._adapters){var n;let i=(n=r.getRemoveDrawingMutationInfos)==null?void 0:n.call(r,e);i&&(t.redoMutations.push(...i.redoMutations),t.undoMutations.push(...i.undoMutations))}return t}getEditDrawingCommandInfo(e){for(let n of this._adapters){var t;let r=(t=n.getEditDrawingCommandInfo)==null?void 0:t.call(n,e);if(r)return r}return null}};let b=class extends t.Plugin{constructor(e=p,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},p,this._config);this._configService.setConfig(`docs-drawing.config`,i)}onStarting(){[[u],[y],[v,{useClass:y}],[r],[i,{useClass:r}]].forEach(e=>this._injector.add(e)),(0,t.touchDependencies)(this._injector,[[u]])}};_(b,`pluginName`,s),_(b,`packageName`,d),_(b,`version`,f),_(b,`type`,t.UniverInstanceType.UNIVER_DOC),b=o([a(1,(0,t.Inject)(t.Injector)),a(2,t.IConfigService)],b),e.DOCS_DRAWING_PLUGIN=s,e.DocDrawingAdapterService=y,Object.defineProperty(e,"DocDrawingController",{enumerable:!0,get:function(){return u}}),e.DocDrawingService=r,e.IDocDrawingAdapterService=v,e.IDocDrawingService=i,Object.defineProperty(e,"UniverDocsDrawingPlugin",{enumerable:!0,get:function(){return b}}),e.getDocDrawingRenderOrder=c});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-drawing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Drawing model integration for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"lib"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@univerjs/core": "1.0.0-alpha.
|
|
53
|
-
"@univerjs/drawing": "1.0.0-alpha.
|
|
52
|
+
"@univerjs/core": "1.0.0-alpha.3",
|
|
53
|
+
"@univerjs/drawing": "1.0.0-alpha.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
|
-
"vitest": "^4.1.
|
|
58
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
57
|
+
"vitest": "^4.1.10",
|
|
58
|
+
"@univerjs-infra/shared": "1.0.0-alpha.3"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "vitest run",
|