@univerjs/sheets-drawing 0.2.6 → 0.2.8

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 CHANGED
@@ -1 +1 @@
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;
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");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,_sheetDrawingService,_drawingManagerService,_resourceManagerService){super(),this._commandService=_commandService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}_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")}))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService),__decorateParam$1(1,ISheetDrawingService),__decorateParam$1(2,drawing.IDrawingManagerService),__decorateParam$1(3,core.IResourceManagerService)],SheetsDrawingLoadController);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"),_a2;exports.UniverSheetsDrawingPlugin=(_a2=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_a2,"UniverSheetsDrawingPlugin"),__publicField(_a2,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_a2,"type",core.UniverInstanceType.UNIVER_SHEET),_a2);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
@@ -2,9 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
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";
5
+ import { createIdentifier, CommandType, OnLifecycle, LifecycleStages, Disposable, UniverInstanceType, ICommandService, IResourceManagerService, Plugin, Inject, Injector } from "@univerjs/core";
6
6
  import { UnitDrawingService, IDrawingManagerService } from "@univerjs/drawing";
7
- import { filter, first } from "rxjs/operators";
8
7
  var SheetDrawingAnchorType = /* @__PURE__ */ ((SheetDrawingAnchorType2) => (SheetDrawingAnchorType2.Position = "0", SheetDrawingAnchorType2.Both = "1", SheetDrawingAnchorType2.None = "2", SheetDrawingAnchorType2))(SheetDrawingAnchorType || {});
9
8
  const _SheetDrawingService = class _SheetDrawingService extends UnitDrawingService {
10
9
  };
@@ -48,21 +47,8 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
48
47
  const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
49
48
  var _a;
50
49
  let SheetsDrawingLoadController = (_a = class extends Disposable {
51
- constructor(_commandService) {
52
- super(), this._commandService = _commandService, this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
53
- }
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();
63
- }
64
- _init() {
65
- this._initSnapshot(), this._drawingInitializeListener();
50
+ constructor(_commandService, _sheetDrawingService, _drawingManagerService, _resourceManagerService) {
51
+ super(), this._commandService = _commandService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._initSnapshot(), this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
66
52
  }
67
53
  _initSnapshot() {
68
54
  const toJson = /* @__PURE__ */ __name((unitId) => {
@@ -92,39 +78,30 @@ let SheetsDrawingController = (_a2 = class extends Disposable {
92
78
  })
93
79
  );
94
80
  }
95
- _drawingInitializeListener() {
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);
100
- });
101
- }
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);
81
+ }, __name(_a, "SheetsDrawingLoadController"), _a);
82
+ SheetsDrawingLoadController = __decorateClass$1([
83
+ OnLifecycle(LifecycleStages.Starting, SheetsDrawingLoadController),
84
+ __decorateParam$1(0, ICommandService),
85
+ __decorateParam$1(1, ISheetDrawingService),
86
+ __decorateParam$1(2, IDrawingManagerService),
87
+ __decorateParam$1(3, IResourceManagerService)
88
+ ], SheetsDrawingLoadController);
111
89
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
112
90
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
113
91
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
114
92
  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 {
93
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a2;
94
+ let UniverSheetsDrawingPlugin = (_a2 = class extends Plugin {
117
95
  constructor(_config, _injector) {
118
96
  super(), this._config = _config, this._injector = _injector;
119
97
  }
120
98
  onStarting() {
121
99
  [
122
100
  [SheetsDrawingLoadController],
123
- [SheetsDrawingController],
124
101
  [ISheetDrawingService, { useClass: SheetDrawingService }]
125
102
  ].forEach((dependency) => this._injector.add(dependency));
126
103
  }
127
- }, __name(_a3, "UniverSheetsDrawingPlugin"), __publicField(_a3, "pluginName", SHEET_DRAWING_PLUGIN), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
104
+ }, __name(_a2, "UniverSheetsDrawingPlugin"), __publicField(_a2, "pluginName", SHEET_DRAWING_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_SHEET), _a2);
128
105
  UniverSheetsDrawingPlugin = __decorateClass([
129
106
  __decorateParam(1, Inject(Injector))
130
107
  ], UniverSheetsDrawingPlugin);
@@ -1,6 +1,5 @@
1
1
  import { IMutation } from '@univerjs/core';
2
2
  import { IDrawingJson1Type } from '@univerjs/drawing';
3
-
4
3
  export declare enum DrawingApplyType {
5
4
  INSERT = 0,
6
5
  REMOVE = 1,
@@ -1,20 +1,12 @@
1
- import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
1
+ import { Disposable, ICommandService, IResourceManagerService } from '@univerjs/core';
2
2
  import { IDrawingManagerService } from '@univerjs/drawing';
3
3
  import { ISheetDrawingService } from '../services/sheet-drawing.service';
4
-
5
4
  export declare const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
6
5
  export declare class SheetsDrawingLoadController extends Disposable {
7
6
  private readonly _commandService;
8
- constructor(_commandService: ICommandService);
9
- }
10
- export declare class SheetsDrawingController extends Disposable {
11
7
  private readonly _sheetDrawingService;
12
8
  private readonly _drawingManagerService;
13
9
  private _resourceManagerService;
14
- private _lifecycleService;
15
- private _univerInstanceService;
16
- constructor(_sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService, _lifecycleService: LifecycleService, _univerInstanceService: IUniverInstanceService);
17
- private _init;
10
+ constructor(_commandService: ICommandService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService);
18
11
  private _initSnapshot;
19
- private _drawingInitializeListener;
20
12
  }
@@ -1,5 +1,4 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
-
3
2
  export declare class UniverSheetsDrawingPlugin extends Plugin {
4
3
  private readonly _config;
5
4
  readonly _injector: Injector;
@@ -1,6 +1,5 @@
1
1
  import { IDrawingParam, IImageData, IRotationSkewFlipTransform, IUnitDrawingService, UnitDrawingService } from '@univerjs/drawing';
2
2
  import { Serializable } from '@univerjs/core';
3
-
4
3
  interface ICellPosition {
5
4
  column: number;
6
5
  columnOffset: number;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
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"})});
1
+ (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDrawing={},global.UniverCore,global.UniverDrawing))})(this,function(exports2,core,drawing){"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;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,_sheetDrawingService,_drawingManagerService,_resourceManagerService){super(),this._commandService=_commandService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._resourceManagerService=_resourceManagerService,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation))}_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")}))}},__name(_a,"SheetsDrawingLoadController"),_a);SheetsDrawingLoadController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,SheetsDrawingLoadController),__decorateParam$1(0,core.ICommandService),__decorateParam$1(1,ISheetDrawingService),__decorateParam$1(2,drawing.IDrawingManagerService),__decorateParam$1(3,core.IResourceManagerService)],SheetsDrawingLoadController);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=(_b=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_b,"UniverSheetsDrawingPlugin"),__publicField(_b,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(_b,"type",core.UniverInstanceType.UNIVER_SHEET),_b),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.6",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,18 +44,17 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
- "rxjs": ">=7.0.0",
48
- "@univerjs/core": "0.2.6",
49
- "@univerjs/drawing": "0.2.6"
47
+ "@univerjs/drawing": "0.2.8",
48
+ "@univerjs/core": "0.2.8"
50
49
  },
51
50
  "devDependencies": {
52
51
  "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"
52
+ "vite": "^5.4.0",
53
+ "vitest": "^2.0.5",
54
+ "@univerjs/core": "0.2.8",
55
+ "@univerjs/drawing": "0.2.8",
56
+ "@univerjs/sheets": "0.2.8",
57
+ "@univerjs/shared": "0.2.8"
59
58
  },
60
59
  "univerSpace": {
61
60
  ".": {