@univerjs/sheets-drawing 0.2.4 → 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 -93
- package/lib/types/plugin.d.ts +2 -3
- package/lib/types/services/sheet-drawing.service.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -12
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,133 +1,137 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import { createIdentifier
|
|
6
|
-
import { UnitDrawingService
|
|
7
|
-
import { filter
|
|
8
|
-
var
|
|
9
|
-
class
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
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 = {
|
|
14
16
|
id: "sheet.mutation.set-drawing-apply",
|
|
15
|
-
type:
|
|
16
|
-
handler: (
|
|
17
|
-
const
|
|
18
|
-
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) {
|
|
19
21
|
case 0:
|
|
20
|
-
|
|
22
|
+
drawingManagerService.addNotification(objects), sheetDrawingService.addNotification(objects);
|
|
21
23
|
break;
|
|
22
24
|
case 1:
|
|
23
|
-
|
|
25
|
+
drawingManagerService.removeNotification(objects), sheetDrawingService.removeNotification(objects);
|
|
24
26
|
break;
|
|
25
27
|
case 2:
|
|
26
|
-
|
|
28
|
+
drawingManagerService.updateNotification(objects), sheetDrawingService.updateNotification(objects);
|
|
27
29
|
break;
|
|
28
30
|
case 3:
|
|
29
|
-
|
|
31
|
+
drawingManagerService.orderNotification(objects), sheetDrawingService.orderNotification(objects);
|
|
30
32
|
break;
|
|
31
33
|
case 4:
|
|
32
|
-
|
|
34
|
+
drawingManagerService.groupUpdateNotification(objects);
|
|
33
35
|
break;
|
|
34
36
|
case 5:
|
|
35
|
-
|
|
37
|
+
drawingManagerService.ungroupUpdateNotification(objects);
|
|
36
38
|
break;
|
|
37
39
|
}
|
|
38
40
|
return !0;
|
|
39
|
-
}
|
|
41
|
+
}, "handler")
|
|
40
42
|
};
|
|
41
|
-
var
|
|
42
|
-
for (var
|
|
43
|
-
(
|
|
44
|
-
return
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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));
|
|
50
53
|
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
],
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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();
|
|
59
63
|
}
|
|
60
64
|
_init() {
|
|
61
65
|
this._initSnapshot(), this._drawingInitializeListener();
|
|
62
66
|
}
|
|
63
67
|
_initSnapshot() {
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
},
|
|
68
|
-
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)
|
|
69
73
|
return {};
|
|
70
74
|
try {
|
|
71
|
-
return JSON.parse(
|
|
75
|
+
return JSON.parse(json);
|
|
72
76
|
} catch {
|
|
73
77
|
return {};
|
|
74
78
|
}
|
|
75
|
-
};
|
|
79
|
+
}, "parseJson");
|
|
76
80
|
this.disposeWithMe(
|
|
77
81
|
this._resourceManagerService.registerPluginResource({
|
|
78
|
-
pluginName:
|
|
79
|
-
businesses: [
|
|
80
|
-
toJson: (
|
|
81
|
-
parseJson: (
|
|
82
|
-
onUnLoad: (
|
|
83
|
-
this._sheetDrawingService.removeDrawingDataForUnit(
|
|
84
|
-
},
|
|
85
|
-
onLoad: (
|
|
86
|
-
this._sheetDrawingService.registerDrawingData(
|
|
87
|
-
}
|
|
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")
|
|
88
92
|
})
|
|
89
93
|
);
|
|
90
94
|
}
|
|
91
95
|
_drawingInitializeListener() {
|
|
92
|
-
this._lifecycleService.lifecycle$.pipe(
|
|
93
|
-
var
|
|
94
|
-
const
|
|
95
|
-
|
|
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);
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
],
|
|
107
|
-
var
|
|
108
|
-
for (var
|
|
109
|
-
(
|
|
110
|
-
return
|
|
111
|
-
},
|
|
112
|
-
let
|
|
113
|
-
constructor(
|
|
114
|
-
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;
|
|
115
119
|
}
|
|
116
|
-
onStarting(
|
|
120
|
+
onStarting() {
|
|
117
121
|
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
].forEach((
|
|
122
|
+
[SheetsDrawingLoadController],
|
|
123
|
+
[SheetsDrawingController],
|
|
124
|
+
[ISheetDrawingService, { useClass: SheetDrawingService }]
|
|
125
|
+
].forEach((dependency) => this._injector.add(dependency));
|
|
122
126
|
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
],
|
|
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);
|
|
127
131
|
export {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
DrawingApplyType,
|
|
133
|
+
ISheetDrawingService,
|
|
134
|
+
SetDrawingApplyMutation,
|
|
135
|
+
SheetDrawingAnchorType,
|
|
136
|
+
UniverSheetsDrawingPlugin
|
|
133
137
|
};
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
1
|
+
import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
2
|
|
|
4
3
|
export declare class UniverSheetsDrawingPlugin extends Plugin {
|
|
5
4
|
private readonly _config;
|
|
@@ -7,5 +6,5 @@ export declare class UniverSheetsDrawingPlugin extends Plugin {
|
|
|
7
6
|
static pluginName: string;
|
|
8
7
|
static type: UniverInstanceType;
|
|
9
8
|
constructor(_config: unknown, _injector: Injector);
|
|
10
|
-
onStarting(
|
|
9
|
+
onStarting(): void;
|
|
11
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDrawingParam, IImageData, IRotationSkewFlipTransform, IUnitDrawingService, UnitDrawingService } from '@univerjs/drawing';
|
|
2
|
+
import { Serializable } from '@univerjs/core';
|
|
2
3
|
|
|
3
4
|
interface ICellPosition {
|
|
4
5
|
column: number;
|
|
@@ -28,6 +29,7 @@ export interface ISheetShape extends IDrawingParam, ISheetDrawingBase {
|
|
|
28
29
|
}
|
|
29
30
|
export interface IFloatDomData extends IDrawingParam {
|
|
30
31
|
componentKey: string;
|
|
32
|
+
data?: Serializable;
|
|
31
33
|
}
|
|
32
34
|
export interface ISheetFloatDom extends IFloatDomData, ISheetDrawingBase {
|
|
33
35
|
}
|
|
@@ -38,5 +40,5 @@ export declare class SheetDrawingService extends UnitDrawingService<ISheetDrawin
|
|
|
38
40
|
}
|
|
39
41
|
export interface ISheetDrawingService extends IUnitDrawingService<ISheetDrawing> {
|
|
40
42
|
}
|
|
41
|
-
export declare const ISheetDrawingService: import('@
|
|
43
|
+
export declare const ISheetDrawingService: import('@univerjs/core').IdentifierDecorator<ISheetDrawingService>;
|
|
42
44
|
export {};
|
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>",
|
|
@@ -44,20 +44,18 @@
|
|
|
44
44
|
"lib"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@wendellhu/redi": "0.16.0",
|
|
48
47
|
"rxjs": ">=7.0.0",
|
|
49
|
-
"@univerjs/core": "0.2.
|
|
50
|
-
"@univerjs/drawing": "0.2.
|
|
48
|
+
"@univerjs/core": "0.2.6",
|
|
49
|
+
"@univerjs/drawing": "0.2.6"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/shared": "0.2.
|
|
59
|
-
"@univerjs/sheets": "0.2.
|
|
60
|
-
"@univerjs/drawing": "0.2.4"
|
|
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"
|
|
61
59
|
},
|
|
62
60
|
"univerSpace": {
|
|
63
61
|
".": {
|