@univerjs/sheets-drawing 0.2.11 → 0.2.13

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");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),this._drawingManagerService.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;
1
+ "use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),drawing=require("@univerjs/drawing"),PLUGIN_CONFIG_KEY="sheets-drawing.config",defaultPluginConfig={};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),this._drawingManagerService.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,__defNormalProp=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField=__name((obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a2;exports.UniverSheetsDrawingPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_a2,"UniverSheetsDrawingPlugin"),_a2);__publicField(exports.UniverSheetsDrawingPlugin,"pluginName",SHEET_DRAWING_PLUGIN);__publicField(exports.UniverSheetsDrawingPlugin,"type",core.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=__decorateClass([core.DependentOn(drawing.UniverDrawingPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=DrawingApplyType;exports.ISheetDrawingService=ISheetDrawingService;exports.SetDrawingApplyMutation=SetDrawingApplyMutation;exports.SheetDrawingAnchorType=SheetDrawingAnchorType;
package/lib/es/index.js CHANGED
@@ -1,9 +1,8 @@
1
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
2
  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, Disposable, UniverInstanceType, ICommandService, IResourceManagerService, Plugin, Inject, Injector } from "@univerjs/core";
6
- import { UnitDrawingService, IDrawingManagerService } from "@univerjs/drawing";
3
+ import { createIdentifier, CommandType, OnLifecycle, LifecycleStages, Disposable, UniverInstanceType, ICommandService, IResourceManagerService, DependentOn, Inject, Injector, Plugin, IConfigService } from "@univerjs/core";
4
+ import { UnitDrawingService, IDrawingManagerService, UniverDrawingPlugin } from "@univerjs/drawing";
5
+ const PLUGIN_CONFIG_KEY = "sheets-drawing.config", defaultPluginConfig = {};
7
6
  var SheetDrawingAnchorType = /* @__PURE__ */ ((SheetDrawingAnchorType2) => (SheetDrawingAnchorType2.Position = "0", SheetDrawingAnchorType2.Both = "1", SheetDrawingAnchorType2.None = "2", SheetDrawingAnchorType2))(SheetDrawingAnchorType || {});
8
7
  const _SheetDrawingService = class _SheetDrawingService extends UnitDrawingService {
9
8
  };
@@ -86,14 +85,16 @@ SheetsDrawingLoadController = __decorateClass$1([
86
85
  __decorateParam$1(2, IDrawingManagerService),
87
86
  __decorateParam$1(3, IResourceManagerService)
88
87
  ], SheetsDrawingLoadController);
89
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
88
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
90
89
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
91
90
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
92
91
  return kind && result && __defProp2(target, key, result), result;
93
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a2;
92
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a2;
94
93
  let UniverSheetsDrawingPlugin = (_a2 = class extends Plugin {
95
- constructor(_config, _injector) {
96
- super(), this._config = _config, this._injector = _injector;
94
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
95
+ super(), this._config = _config, this._injector = _injector, this._configService = _configService;
96
+ const { ...rest } = this._config;
97
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
97
98
  }
98
99
  onStarting() {
99
100
  [
@@ -101,9 +102,13 @@ let UniverSheetsDrawingPlugin = (_a2 = class extends Plugin {
101
102
  [ISheetDrawingService, { useClass: SheetDrawingService }]
102
103
  ].forEach((dependency) => this._injector.add(dependency));
103
104
  }
104
- }, __name(_a2, "UniverSheetsDrawingPlugin"), __publicField(_a2, "pluginName", SHEET_DRAWING_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_SHEET), _a2);
105
+ }, __name(_a2, "UniverSheetsDrawingPlugin"), _a2);
106
+ __publicField(UniverSheetsDrawingPlugin, "pluginName", SHEET_DRAWING_PLUGIN);
107
+ __publicField(UniverSheetsDrawingPlugin, "type", UniverInstanceType.UNIVER_SHEET);
105
108
  UniverSheetsDrawingPlugin = __decorateClass([
106
- __decorateParam(1, Inject(Injector))
109
+ DependentOn(UniverDrawingPlugin),
110
+ __decorateParam(1, Inject(Injector)),
111
+ __decorateParam(2, IConfigService)
107
112
  ], UniverSheetsDrawingPlugin);
108
113
  export {
109
114
  DrawingApplyType,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const PLUGIN_CONFIG_KEY = "sheets-drawing.config";
17
+ export declare const configSymbol: unique symbol;
18
+ export interface IUniverSheetsDrawingConfig {
19
+ }
20
+ export declare const defaultPluginConfig: IUniverSheetsDrawingConfig;
@@ -1,9 +1,11 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { IUniverSheetsDrawingConfig } from './controllers/config.schema';
2
3
  export declare class UniverSheetsDrawingPlugin extends Plugin {
3
4
  private readonly _config;
4
5
  readonly _injector: Injector;
6
+ private readonly _configService;
5
7
  static pluginName: string;
6
8
  static type: UniverInstanceType;
7
- constructor(_config: unknown, _injector: Injector);
9
+ constructor(_config: Partial<IUniverSheetsDrawingConfig> | undefined, _injector: Injector, _configService: IConfigService);
8
10
  onStarting(): void;
9
11
  }
@@ -29,6 +29,7 @@ export interface ISheetShape extends IDrawingParam, ISheetDrawingBase {
29
29
  export interface IFloatDomData extends IDrawingParam {
30
30
  componentKey: string;
31
31
  data?: Serializable;
32
+ allowTransform?: boolean;
32
33
  }
33
34
  export interface ISheetFloatDom extends IFloatDomData, ISheetDrawingBase {
34
35
  }
@@ -39,5 +40,5 @@ export declare class SheetDrawingService extends UnitDrawingService<ISheetDrawin
39
40
  }
40
41
  export interface ISheetDrawingService extends IUnitDrawingService<ISheetDrawing> {
41
42
  }
42
- export declare const ISheetDrawingService: import('@univerjs/core').IdentifierDecorator<ISheetDrawingService>;
43
+ export declare const ISheetDrawingService: import('@wendellhu/redi').IdentifierDecorator<ISheetDrawingService>;
43
44
  export {};
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")):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),this._drawingManagerService.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"})});
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 __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var _a,_b;const PLUGIN_CONFIG_KEY="sheets-drawing.config",defaultPluginConfig={};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),this._drawingManagerService.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,__defNormalProp=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__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"),__publicField=__name((obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsDrawingPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsDrawingLoadController],[ISheetDrawingService,{useClass:SheetDrawingService}]].forEach(dependency=>this._injector.add(dependency))}},__name(_b,"UniverSheetsDrawingPlugin"),_b),__publicField(exports2.UniverSheetsDrawingPlugin,"pluginName",SHEET_DRAWING_PLUGIN),__publicField(exports2.UniverSheetsDrawingPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsDrawingPlugin=__decorateClass([core.DependentOn(drawing.UniverDrawingPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],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.11",
3
+ "version": "0.2.13",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,17 +44,19 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@univerjs/core": "0.2.11",
48
- "@univerjs/drawing": "0.2.11"
47
+ "@univerjs/core": "0.2.13",
48
+ "@univerjs/drawing": "0.2.13"
49
+ },
50
+ "dependencies": {
51
+ "@univerjs/core": "0.2.13",
52
+ "@univerjs/drawing": "0.2.13",
53
+ "@univerjs/sheets": "0.2.13"
49
54
  },
50
55
  "devDependencies": {
51
- "typescript": "^5.5.4",
52
- "vite": "^5.4.2",
56
+ "typescript": "^5.6.2",
57
+ "vite": "^5.4.4",
53
58
  "vitest": "^2.0.5",
54
- "@univerjs/core": "0.2.11",
55
- "@univerjs/shared": "0.2.11",
56
- "@univerjs/sheets": "0.2.11",
57
- "@univerjs/drawing": "0.2.11"
59
+ "@univerjs-infra/shared": "0.2.13"
58
60
  },
59
61
  "univerSpace": {
60
62
  ".": {