@univerjs/sheets-drawing 0.2.5 → 0.2.6
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 +1 -1
- package/lib/es/index.js +97 -92
- package/lib/types/plugin.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),drawing=require("@univerjs/drawing"),operators=require("rxjs/operators");var SheetDrawingAnchorType=(SheetDrawingAnchorType2=>(SheetDrawingAnchorType2.Position="0",SheetDrawingAnchorType2.Both="1",SheetDrawingAnchorType2.None="2",SheetDrawingAnchorType2))(SheetDrawingAnchorType||{});const _SheetDrawingService=class _SheetDrawingService extends drawing.UnitDrawingService{};__name(_SheetDrawingService,"SheetDrawingService");let SheetDrawingService=_SheetDrawingService;const ISheetDrawingService=core.createIdentifier("sheets-drawing.sheet-drawing.service");var DrawingApplyType=(DrawingApplyType2=>(DrawingApplyType2[DrawingApplyType2.INSERT=0]="INSERT",DrawingApplyType2[DrawingApplyType2.REMOVE=1]="REMOVE",DrawingApplyType2[DrawingApplyType2.UPDATE=2]="UPDATE",DrawingApplyType2[DrawingApplyType2.ARRANGE=3]="ARRANGE",DrawingApplyType2[DrawingApplyType2.GROUP=4]="GROUP",DrawingApplyType2[DrawingApplyType2.UNGROUP=5]="UNGROUP",DrawingApplyType2))(DrawingApplyType||{});const SetDrawingApplyMutation={id:"sheet.mutation.set-drawing-apply",type:core.CommandType.MUTATION,handler:__name((accessor,params)=>{const drawingManagerService=accessor.get(drawing.IDrawingManagerService),sheetDrawingService=accessor.get(ISheetDrawingService),{op,unitId,subUnitId,type,objects}=params;switch(drawingManagerService.applyJson1(unitId,subUnitId,op),sheetDrawingService.applyJson1(unitId,subUnitId,op),type){case 0:drawingManagerService.addNotification(objects),sheetDrawingService.addNotification(objects);break;case 1:drawingManagerService.removeNotification(objects),sheetDrawingService.removeNotification(objects);break;case 2:drawingManagerService.updateNotification(objects),sheetDrawingService.updateNotification(objects);break;case 3:drawingManagerService.orderNotification(objects),sheetDrawingService.orderNotification(objects);break;case 4:drawingManagerService.groupUpdateNotification(objects);break;case 5:drawingManagerService.ungroupUpdateNotification(objects);break}return!0},"handler")};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const SHEET_DRAWING_PLUGIN="SHEET_DRAWING_PLUGIN";var _a;let SheetsDrawingLoadController=(_a=class extends core.Disposable{constructor(_commandService){super(),this._commandService=_commandService,this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService)],SheetsDrawingLoadController);var _a2;let SheetsDrawingController=(_a2=class extends core.Disposable{constructor(_sheetDrawingService,_drawingManagerService,_resourceManagerService,_lifecycleService,_univerInstanceService){super(),this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._lifecycleService=_lifecycleService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const toJson=__name(unitId=>{const map=this._sheetDrawingService.getDrawingDataForUnit(unitId);return map?JSON.stringify(map):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:SHEET_DRAWING_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_SHEET],toJson:__name(unitId=>toJson(unitId),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitId=>{this._sheetDrawingService.removeDrawingDataForUnit(unitId),this._drawingManagerService.removeDrawingDataForUnit(unitId)},"onUnLoad"),onLoad:__name((unitId,value)=>{this._sheetDrawingService.registerDrawingData(unitId,value)},"onLoad")}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(operators.filter(e=>e===core.LifecycleStages.Steady),operators.first()).subscribe(()=>{var _a4;const unitId=(_a4=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a4.getUnitId();unitId&&this._sheetDrawingService.initializeNotification(unitId)})}},__name(_a2,"SheetsDrawingController"),_a2);SheetsDrawingController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingController),__decorateParam$1(0,ISheetDrawingService),__decorateParam$1(1,drawing.IDrawingManagerService),__decorateParam$1(2,core.IResourceManagerService),__decorateParam$1(3,core.Inject(core.LifecycleService)),__decorateParam$1(4,core.IUniverInstanceService)],SheetsDrawingController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),_a3;exports.UniverSheetsDrawingPlugin=(_a3=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[SheetsDrawingController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_a3,"UniverSheetsDrawingPlugin"),__publicField(_a3,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_SHEET),_a3);exports.UniverSheetsDrawingPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=DrawingApplyType;exports.ISheetDrawingService=ISheetDrawingService;exports.SetDrawingApplyMutation=SetDrawingApplyMutation;exports.SheetDrawingAnchorType=SheetDrawingAnchorType;
|
package/lib/es/index.js
CHANGED
|
@@ -1,132 +1,137 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { createIdentifier, CommandType, OnLifecycle, LifecycleStages, Inject, LifecycleService, Disposable, ICommandService, UniverInstanceType, IResourceManagerService, IUniverInstanceService, Plugin, Injector } from "@univerjs/core";
|
|
6
|
+
import { UnitDrawingService, IDrawingManagerService } from "@univerjs/drawing";
|
|
7
|
+
import { filter, first } from "rxjs/operators";
|
|
8
|
+
var SheetDrawingAnchorType = /* @__PURE__ */ ((SheetDrawingAnchorType2) => (SheetDrawingAnchorType2.Position = "0", SheetDrawingAnchorType2.Both = "1", SheetDrawingAnchorType2.None = "2", SheetDrawingAnchorType2))(SheetDrawingAnchorType || {});
|
|
9
|
+
const _SheetDrawingService = class _SheetDrawingService extends UnitDrawingService {
|
|
10
|
+
};
|
|
11
|
+
__name(_SheetDrawingService, "SheetDrawingService");
|
|
12
|
+
let SheetDrawingService = _SheetDrawingService;
|
|
13
|
+
const ISheetDrawingService = createIdentifier("sheets-drawing.sheet-drawing.service");
|
|
14
|
+
var DrawingApplyType = /* @__PURE__ */ ((DrawingApplyType2) => (DrawingApplyType2[DrawingApplyType2.INSERT = 0] = "INSERT", DrawingApplyType2[DrawingApplyType2.REMOVE = 1] = "REMOVE", DrawingApplyType2[DrawingApplyType2.UPDATE = 2] = "UPDATE", DrawingApplyType2[DrawingApplyType2.ARRANGE = 3] = "ARRANGE", DrawingApplyType2[DrawingApplyType2.GROUP = 4] = "GROUP", DrawingApplyType2[DrawingApplyType2.UNGROUP = 5] = "UNGROUP", DrawingApplyType2))(DrawingApplyType || {});
|
|
15
|
+
const SetDrawingApplyMutation = {
|
|
13
16
|
id: "sheet.mutation.set-drawing-apply",
|
|
14
|
-
type:
|
|
15
|
-
handler: (
|
|
16
|
-
const
|
|
17
|
-
switch (
|
|
17
|
+
type: CommandType.MUTATION,
|
|
18
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
19
|
+
const drawingManagerService = accessor.get(IDrawingManagerService), sheetDrawingService = accessor.get(ISheetDrawingService), { op, unitId, subUnitId, type, objects } = params;
|
|
20
|
+
switch (drawingManagerService.applyJson1(unitId, subUnitId, op), sheetDrawingService.applyJson1(unitId, subUnitId, op), type) {
|
|
18
21
|
case 0:
|
|
19
|
-
|
|
22
|
+
drawingManagerService.addNotification(objects), sheetDrawingService.addNotification(objects);
|
|
20
23
|
break;
|
|
21
24
|
case 1:
|
|
22
|
-
|
|
25
|
+
drawingManagerService.removeNotification(objects), sheetDrawingService.removeNotification(objects);
|
|
23
26
|
break;
|
|
24
27
|
case 2:
|
|
25
|
-
|
|
28
|
+
drawingManagerService.updateNotification(objects), sheetDrawingService.updateNotification(objects);
|
|
26
29
|
break;
|
|
27
30
|
case 3:
|
|
28
|
-
|
|
31
|
+
drawingManagerService.orderNotification(objects), sheetDrawingService.orderNotification(objects);
|
|
29
32
|
break;
|
|
30
33
|
case 4:
|
|
31
|
-
|
|
34
|
+
drawingManagerService.groupUpdateNotification(objects);
|
|
32
35
|
break;
|
|
33
36
|
case 5:
|
|
34
|
-
|
|
37
|
+
drawingManagerService.ungroupUpdateNotification(objects);
|
|
35
38
|
break;
|
|
36
39
|
}
|
|
37
40
|
return !0;
|
|
38
|
-
}
|
|
41
|
+
}, "handler")
|
|
39
42
|
};
|
|
40
|
-
var
|
|
41
|
-
for (var
|
|
42
|
-
(
|
|
43
|
-
return
|
|
44
|
-
},
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
44
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
45
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
46
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
47
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
48
|
+
const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
|
|
49
|
+
var _a;
|
|
50
|
+
let SheetsDrawingLoadController = (_a = class extends Disposable {
|
|
51
|
+
constructor(_commandService) {
|
|
52
|
+
super(), this._commandService = _commandService, this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
|
|
49
53
|
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
}, __name(_a, "SheetsDrawingLoadController"), _a);
|
|
55
|
+
SheetsDrawingLoadController = __decorateClass$1([
|
|
56
|
+
OnLifecycle(LifecycleStages.Starting, SheetsDrawingLoadController),
|
|
57
|
+
__decorateParam$1(0, ICommandService)
|
|
58
|
+
], SheetsDrawingLoadController);
|
|
59
|
+
var _a2;
|
|
60
|
+
let SheetsDrawingController = (_a2 = class extends Disposable {
|
|
61
|
+
constructor(_sheetDrawingService, _drawingManagerService, _resourceManagerService, _lifecycleService, _univerInstanceService) {
|
|
62
|
+
super(), this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._lifecycleService = _lifecycleService, this._univerInstanceService = _univerInstanceService, this._init();
|
|
58
63
|
}
|
|
59
64
|
_init() {
|
|
60
65
|
this._initSnapshot(), this._drawingInitializeListener();
|
|
61
66
|
}
|
|
62
67
|
_initSnapshot() {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
},
|
|
67
|
-
if (!
|
|
68
|
+
const toJson = /* @__PURE__ */ __name((unitId) => {
|
|
69
|
+
const map = this._sheetDrawingService.getDrawingDataForUnit(unitId);
|
|
70
|
+
return map ? JSON.stringify(map) : "";
|
|
71
|
+
}, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
|
|
72
|
+
if (!json)
|
|
68
73
|
return {};
|
|
69
74
|
try {
|
|
70
|
-
return JSON.parse(
|
|
75
|
+
return JSON.parse(json);
|
|
71
76
|
} catch {
|
|
72
77
|
return {};
|
|
73
78
|
}
|
|
74
|
-
};
|
|
79
|
+
}, "parseJson");
|
|
75
80
|
this.disposeWithMe(
|
|
76
81
|
this._resourceManagerService.registerPluginResource({
|
|
77
|
-
pluginName:
|
|
78
|
-
businesses: [
|
|
79
|
-
toJson: (
|
|
80
|
-
parseJson: (
|
|
81
|
-
onUnLoad: (
|
|
82
|
-
this._sheetDrawingService.removeDrawingDataForUnit(
|
|
83
|
-
},
|
|
84
|
-
onLoad: (
|
|
85
|
-
this._sheetDrawingService.registerDrawingData(
|
|
86
|
-
}
|
|
82
|
+
pluginName: SHEET_DRAWING_PLUGIN,
|
|
83
|
+
businesses: [UniverInstanceType.UNIVER_SHEET],
|
|
84
|
+
toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
|
|
85
|
+
parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
|
|
86
|
+
onUnLoad: /* @__PURE__ */ __name((unitId) => {
|
|
87
|
+
this._sheetDrawingService.removeDrawingDataForUnit(unitId), this._drawingManagerService.removeDrawingDataForUnit(unitId);
|
|
88
|
+
}, "onUnLoad"),
|
|
89
|
+
onLoad: /* @__PURE__ */ __name((unitId, value) => {
|
|
90
|
+
this._sheetDrawingService.registerDrawingData(unitId, value);
|
|
91
|
+
}, "onLoad")
|
|
87
92
|
})
|
|
88
93
|
);
|
|
89
94
|
}
|
|
90
95
|
_drawingInitializeListener() {
|
|
91
|
-
this._lifecycleService.lifecycle$.pipe(
|
|
92
|
-
var
|
|
93
|
-
const
|
|
94
|
-
|
|
96
|
+
this._lifecycleService.lifecycle$.pipe(filter((e) => e === LifecycleStages.Steady), first()).subscribe(() => {
|
|
97
|
+
var _a4;
|
|
98
|
+
const unitId = (_a4 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a4.getUnitId();
|
|
99
|
+
unitId && this._sheetDrawingService.initializeNotification(unitId);
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
var
|
|
107
|
-
for (var
|
|
108
|
-
(
|
|
109
|
-
return
|
|
110
|
-
},
|
|
111
|
-
let
|
|
112
|
-
constructor(
|
|
113
|
-
super(), this._config =
|
|
102
|
+
}, __name(_a2, "SheetsDrawingController"), _a2);
|
|
103
|
+
SheetsDrawingController = __decorateClass$1([
|
|
104
|
+
OnLifecycle(LifecycleStages.Starting, SheetsDrawingController),
|
|
105
|
+
__decorateParam$1(0, ISheetDrawingService),
|
|
106
|
+
__decorateParam$1(1, IDrawingManagerService),
|
|
107
|
+
__decorateParam$1(2, IResourceManagerService),
|
|
108
|
+
__decorateParam$1(3, Inject(LifecycleService)),
|
|
109
|
+
__decorateParam$1(4, IUniverInstanceService)
|
|
110
|
+
], SheetsDrawingController);
|
|
111
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
112
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
113
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
114
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
115
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
|
|
116
|
+
let UniverSheetsDrawingPlugin = (_a3 = class extends Plugin {
|
|
117
|
+
constructor(_config, _injector) {
|
|
118
|
+
super(), this._config = _config, this._injector = _injector;
|
|
114
119
|
}
|
|
115
|
-
onStarting(
|
|
120
|
+
onStarting() {
|
|
116
121
|
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
].forEach((
|
|
122
|
+
[SheetsDrawingLoadController],
|
|
123
|
+
[SheetsDrawingController],
|
|
124
|
+
[ISheetDrawingService, { useClass: SheetDrawingService }]
|
|
125
|
+
].forEach((dependency) => this._injector.add(dependency));
|
|
121
126
|
}
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
],
|
|
127
|
+
}, __name(_a3, "UniverSheetsDrawingPlugin"), __publicField(_a3, "pluginName", SHEET_DRAWING_PLUGIN), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
|
|
128
|
+
UniverSheetsDrawingPlugin = __decorateClass([
|
|
129
|
+
__decorateParam(1, Inject(Injector))
|
|
130
|
+
], UniverSheetsDrawingPlugin);
|
|
126
131
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
DrawingApplyType,
|
|
133
|
+
ISheetDrawingService,
|
|
134
|
+
SetDrawingApplyMutation,
|
|
135
|
+
SheetDrawingAnchorType,
|
|
136
|
+
UniverSheetsDrawingPlugin
|
|
132
137
|
};
|
package/lib/types/plugin.d.ts
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","rxjs/operators"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDrawing={},global.UniverCore,global.UniverDrawing,global.rxjs.operators))})(this,function(exports2,core,drawing,operators){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;var SheetDrawingAnchorType=(SheetDrawingAnchorType2=>(SheetDrawingAnchorType2.Position="0",SheetDrawingAnchorType2.Both="1",SheetDrawingAnchorType2.None="2",SheetDrawingAnchorType2))(SheetDrawingAnchorType||{});const _SheetDrawingService=class _SheetDrawingService extends drawing.UnitDrawingService{};__name(_SheetDrawingService,"SheetDrawingService");let SheetDrawingService=_SheetDrawingService;const ISheetDrawingService=core.createIdentifier("sheets-drawing.sheet-drawing.service");var DrawingApplyType=(DrawingApplyType2=>(DrawingApplyType2[DrawingApplyType2.INSERT=0]="INSERT",DrawingApplyType2[DrawingApplyType2.REMOVE=1]="REMOVE",DrawingApplyType2[DrawingApplyType2.UPDATE=2]="UPDATE",DrawingApplyType2[DrawingApplyType2.ARRANGE=3]="ARRANGE",DrawingApplyType2[DrawingApplyType2.GROUP=4]="GROUP",DrawingApplyType2[DrawingApplyType2.UNGROUP=5]="UNGROUP",DrawingApplyType2))(DrawingApplyType||{});const SetDrawingApplyMutation={id:"sheet.mutation.set-drawing-apply",type:core.CommandType.MUTATION,handler:__name((accessor,params)=>{const drawingManagerService=accessor.get(drawing.IDrawingManagerService),sheetDrawingService=accessor.get(ISheetDrawingService),{op,unitId,subUnitId,type,objects}=params;switch(drawingManagerService.applyJson1(unitId,subUnitId,op),sheetDrawingService.applyJson1(unitId,subUnitId,op),type){case 0:drawingManagerService.addNotification(objects),sheetDrawingService.addNotification(objects);break;case 1:drawingManagerService.removeNotification(objects),sheetDrawingService.removeNotification(objects);break;case 2:drawingManagerService.updateNotification(objects),sheetDrawingService.updateNotification(objects);break;case 3:drawingManagerService.orderNotification(objects),sheetDrawingService.orderNotification(objects);break;case 4:drawingManagerService.groupUpdateNotification(objects);break;case 5:drawingManagerService.ungroupUpdateNotification(objects);break}return!0},"handler")};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const SHEET_DRAWING_PLUGIN="SHEET_DRAWING_PLUGIN";let SheetsDrawingLoadController=(_a=class extends core.Disposable{constructor(_commandService){super(),this._commandService=_commandService,this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService)],SheetsDrawingLoadController);let SheetsDrawingController=(_b=class extends core.Disposable{constructor(_sheetDrawingService,_drawingManagerService,_resourceManagerService,_lifecycleService,_univerInstanceService){super(),this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._lifecycleService=_lifecycleService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const toJson=__name(unitId=>{const map=this._sheetDrawingService.getDrawingDataForUnit(unitId);return map?JSON.stringify(map):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:SHEET_DRAWING_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_SHEET],toJson:__name(unitId=>toJson(unitId),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitId=>{this._sheetDrawingService.removeDrawingDataForUnit(unitId),this._drawingManagerService.removeDrawingDataForUnit(unitId)},"onUnLoad"),onLoad:__name((unitId,value)=>{this._sheetDrawingService.registerDrawingData(unitId,value)},"onLoad")}))}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(operators.filter(e=>e===core.LifecycleStages.Steady),operators.first()).subscribe(()=>{var _a2;const unitId=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getUnitId();unitId&&this._sheetDrawingService.initializeNotification(unitId)})}},__name(_b,"SheetsDrawingController"),_b);SheetsDrawingController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingController),__decorateParam$1(0,ISheetDrawingService),__decorateParam$1(1,drawing.IDrawingManagerService),__decorateParam$1(2,core.IResourceManagerService),__decorateParam$1(3,core.Inject(core.LifecycleService)),__decorateParam$1(4,core.IUniverInstanceService)],SheetsDrawingController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");exports2.UniverSheetsDrawingPlugin=(_c=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[SheetsDrawingController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_c,"UniverSheetsDrawingPlugin"),__publicField(_c,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_c,"type",core.UniverInstanceType.UNIVER_SHEET),_c),exports2.UniverSheetsDrawingPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports2.UniverSheetsDrawingPlugin),exports2.DrawingApplyType=DrawingApplyType,exports2.ISheetDrawingService=ISheetDrawingService,exports2.SetDrawingApplyMutation=SetDrawingApplyMutation,exports2.SheetDrawingAnchorType=SheetDrawingAnchorType,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"rxjs": ">=7.0.0",
|
|
48
|
-
"@univerjs/core": "0.2.
|
|
49
|
-
"@univerjs/drawing": "0.2.
|
|
48
|
+
"@univerjs/core": "0.2.6",
|
|
49
|
+
"@univerjs/drawing": "0.2.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"typescript": "^5.5.
|
|
53
|
-
"vite": "^5.3.
|
|
54
|
-
"vitest": "^2.0.
|
|
55
|
-
"@univerjs/core": "0.2.
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/sheets": "0.2.
|
|
52
|
+
"typescript": "^5.5.4",
|
|
53
|
+
"vite": "^5.3.5",
|
|
54
|
+
"vitest": "^2.0.4",
|
|
55
|
+
"@univerjs/core": "0.2.6",
|
|
56
|
+
"@univerjs/drawing": "0.2.6",
|
|
57
|
+
"@univerjs/shared": "0.2.6",
|
|
58
|
+
"@univerjs/sheets": "0.2.6"
|
|
59
59
|
},
|
|
60
60
|
"univerSpace": {
|
|
61
61
|
".": {
|