@univerjs/docs-hyper-link 0.3.0 → 0.4.0-alpha.0

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"),AddHyperLinkMuatation={id:"docs.mutation.add-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},UpdateHyperLinkMuatation={id:"docs.mutation.update-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},DeleteHyperLinkMuatation={id:"docs.mutation.delete-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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 DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN";var _a;let DocHyperLinkResourceController=(_a=class extends core.Disposable{constructor(_resourceManagerService,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const customRangeMap=new Map,handleDoc=__name(model=>{var _a3,_b;return(_b=(_a3=model.getBody())==null?void 0:_a3.customRanges)==null||_b.forEach(customRange=>{customRange.rangeType===core.CustomRangeType.HYPERLINK&&customRangeMap.set(customRange.rangeId,customRange)}),customRangeMap},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc),resource.links.forEach(link=>{const customRange=customRangeMap.get(link.id);customRange&&(customRange.properties={...customRange.properties,url:link.payload})})},"onLoad"),onUnLoad:__name(unitID=>{},"onUnLoad"),toJson:__name(unitID=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),links=[];if(doc){const handleDoc=__name(model=>{var _a3,_b;(_b=(_a3=model.getBody())==null?void 0:_a3.customRanges)==null||_b.forEach(customRange=>{var _a4;customRange.rangeType===core.CustomRangeType.HYPERLINK&&links.push({id:customRange.rangeId,payload:((_a4=customRange.properties)==null?void 0:_a4.url)||""})})},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc)}return JSON.stringify({links})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_a,"DocHyperLinkResourceController"),_a);DocHyperLinkResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkResourceController),__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.IUniverInstanceService)],DocHyperLinkResourceController);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.UniverDocsHyperLinkPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_commandService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._commandService=_commandService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)}),[AddHyperLinkMuatation,DeleteHyperLinkMuatation,UpdateHyperLinkMuatation].forEach(mutation=>{this.disposeWithMe(this._commandService.registerCommand(mutation))})}},__name(_a2,"UniverDocsHyperLinkPlugin"),__publicField(_a2,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_a2,"type",core.UniverInstanceType.UNIVER_DOC),_a2);exports.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,core.ICommandService)],exports.UniverDocsHyperLinkPlugin);
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"),AddHyperLinkMuatation={id:"docs.mutation.add-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},UpdateHyperLinkMuatation={id:"docs.mutation.update-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},DeleteHyperLinkMuatation={id:"docs.mutation.delete-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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 DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN";var _a;let DocHyperLinkResourceController=(_a=class extends core.Disposable{constructor(_resourceManagerService,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const customRangeMap=new Map,handleDoc=__name(model=>{var _a3,_b;return(_b=(_a3=model.getBody())==null?void 0:_a3.customRanges)==null||_b.forEach(customRange=>{customRange.rangeType===core.CustomRangeType.HYPERLINK&&customRangeMap.set(customRange.rangeId,customRange)}),customRangeMap},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc),resource.links.forEach(link=>{const customRange=customRangeMap.get(link.id);customRange&&(customRange.properties={...customRange.properties,url:link.payload})})},"onLoad"),onUnLoad:__name(unitID=>{},"onUnLoad"),toJson:__name(unitID=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),links=[];if(doc){const handleDoc=__name(model=>{var _a3,_b;(_b=(_a3=model.getBody())==null?void 0:_a3.customRanges)==null||_b.forEach(customRange=>{var _a4;customRange.rangeType===core.CustomRangeType.HYPERLINK&&links.push({id:customRange.rangeId,payload:((_a4=customRange.properties)==null?void 0:_a4.url)||""})})},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc)}return JSON.stringify({links})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_a,"DocHyperLinkResourceController"),_a);DocHyperLinkResourceController=__decorateClass$1([__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.IUniverInstanceService)],DocHyperLinkResourceController);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.UniverDocsHyperLinkPlugin=(_a2=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_commandService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._commandService=_commandService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>this._injector.add(dep)),[AddHyperLinkMuatation,DeleteHyperLinkMuatation,UpdateHyperLinkMuatation].forEach(mutation=>{this.disposeWithMe(this._commandService.registerCommand(mutation))}),this._injector.get(DocHyperLinkResourceController)}},__name(_a2,"UniverDocsHyperLinkPlugin"),__publicField(_a2,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_a2,"type",core.UniverInstanceType.UNIVER_DOC),_a2);exports.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,core.ICommandService)],exports.UniverDocsHyperLinkPlugin);
package/lib/es/index.js CHANGED
@@ -2,7 +2,7 @@ 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 { CommandType, OnLifecycle, LifecycleStages, Inject, IResourceManagerService, Disposable, UniverInstanceType, IUniverInstanceService, CustomRangeType, Plugin, Injector, IConfigService, ICommandService } from "@univerjs/core";
5
+ import { CommandType, Inject, IResourceManagerService, Disposable, UniverInstanceType, IUniverInstanceService, CustomRangeType, Plugin, Injector, IConfigService, ICommandService } from "@univerjs/core";
6
6
  const AddHyperLinkMuatation = {
7
7
  id: "docs.mutation.add-hyper-link",
8
8
  type: CommandType.MUTATION,
@@ -83,7 +83,6 @@ let DocHyperLinkResourceController = (_a = class extends Disposable {
83
83
  }
84
84
  }, __name(_a, "DocHyperLinkResourceController"), _a);
85
85
  DocHyperLinkResourceController = __decorateClass$1([
86
- OnLifecycle(LifecycleStages.Starting, DocHyperLinkResourceController),
87
86
  __decorateParam$1(0, Inject(IResourceManagerService)),
88
87
  __decorateParam$1(1, IUniverInstanceService)
89
88
  ], DocHyperLinkResourceController);
@@ -99,13 +98,9 @@ let UniverDocsHyperLinkPlugin = (_a2 = class extends Plugin {
99
98
  this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
100
99
  }
101
100
  onStarting() {
102
- [
103
- [DocHyperLinkResourceController]
104
- ].forEach((dep) => {
105
- this._injector.add(dep);
106
- }), [AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation].forEach((mutation) => {
101
+ [[DocHyperLinkResourceController]].forEach((dep) => this._injector.add(dep)), [AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation].forEach((mutation) => {
107
102
  this.disposeWithMe(this._commandService.registerCommand(mutation));
108
- });
103
+ }), this._injector.get(DocHyperLinkResourceController);
109
104
  }
110
105
  }, __name(_a2, "UniverDocsHyperLinkPlugin"), __publicField(_a2, "pluginName", DOC_HYPER_LINK_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_DOC), _a2);
111
106
  UniverDocsHyperLinkPlugin = __decorateClass([
@@ -1,5 +1,5 @@
1
- import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
1
  import { IUniverDocsHyperLinkConfig } from './controllers/config.schema';
2
+ import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverDocsHyperLinkPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsHyperLink={},global.UniverCore))})(this,function(exports2,core){"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;const AddHyperLinkMuatation={id:"docs.mutation.add-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},UpdateHyperLinkMuatation={id:"docs.mutation.update-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},DeleteHyperLinkMuatation={id:"docs.mutation.delete-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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 DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN";let DocHyperLinkResourceController=(_a=class extends core.Disposable{constructor(_resourceManagerService,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const customRangeMap=new Map,handleDoc=__name(model=>{var _a2,_b2;return(_b2=(_a2=model.getBody())==null?void 0:_a2.customRanges)==null||_b2.forEach(customRange=>{customRange.rangeType===core.CustomRangeType.HYPERLINK&&customRangeMap.set(customRange.rangeId,customRange)}),customRangeMap},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc),resource.links.forEach(link=>{const customRange=customRangeMap.get(link.id);customRange&&(customRange.properties={...customRange.properties,url:link.payload})})},"onLoad"),onUnLoad:__name(unitID=>{},"onUnLoad"),toJson:__name(unitID=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),links=[];if(doc){const handleDoc=__name(model=>{var _a2,_b2;(_b2=(_a2=model.getBody())==null?void 0:_a2.customRanges)==null||_b2.forEach(customRange=>{var _a3;customRange.rangeType===core.CustomRangeType.HYPERLINK&&links.push({id:customRange.rangeId,payload:((_a3=customRange.properties)==null?void 0:_a3.url)||""})})},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc)}return JSON.stringify({links})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_a,"DocHyperLinkResourceController"),_a);DocHyperLinkResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkResourceController),__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.IUniverInstanceService)],DocHyperLinkResourceController);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.UniverDocsHyperLinkPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_commandService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._commandService=_commandService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)}),[AddHyperLinkMuatation,DeleteHyperLinkMuatation,UpdateHyperLinkMuatation].forEach(mutation=>{this.disposeWithMe(this._commandService.registerCommand(mutation))})}},__name(_b,"UniverDocsHyperLinkPlugin"),__publicField(_b,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_b,"type",core.UniverInstanceType.UNIVER_DOC),_b),exports2.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,core.ICommandService)],exports2.UniverDocsHyperLinkPlugin),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
1
+ (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsHyperLink={},global.UniverCore))})(this,function(exports2,core){"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;const AddHyperLinkMuatation={id:"docs.mutation.add-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},UpdateHyperLinkMuatation={id:"docs.mutation.update-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},DeleteHyperLinkMuatation={id:"docs.mutation.delete-hyper-link",type:core.CommandType.MUTATION,handler:__name(()=>!0,"handler")},PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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 DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN";let DocHyperLinkResourceController=(_a=class extends core.Disposable{constructor(_resourceManagerService,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const customRangeMap=new Map,handleDoc=__name(model=>{var _a2,_b2;return(_b2=(_a2=model.getBody())==null?void 0:_a2.customRanges)==null||_b2.forEach(customRange=>{customRange.rangeType===core.CustomRangeType.HYPERLINK&&customRangeMap.set(customRange.rangeId,customRange)}),customRangeMap},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc),resource.links.forEach(link=>{const customRange=customRangeMap.get(link.id);customRange&&(customRange.properties={...customRange.properties,url:link.payload})})},"onLoad"),onUnLoad:__name(unitID=>{},"onUnLoad"),toJson:__name(unitID=>{const doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),links=[];if(doc){const handleDoc=__name(model=>{var _a2,_b2;(_b2=(_a2=model.getBody())==null?void 0:_a2.customRanges)==null||_b2.forEach(customRange=>{var _a3;customRange.rangeType===core.CustomRangeType.HYPERLINK&&links.push({id:customRange.rangeId,payload:((_a3=customRange.properties)==null?void 0:_a3.url)||""})})},"handleDoc");doc.headerModelMap.forEach(headerModel=>{handleDoc(headerModel)}),doc.footerModelMap.forEach(footerModel=>{handleDoc(footerModel)}),handleDoc(doc)}return JSON.stringify({links})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_a,"DocHyperLinkResourceController"),_a);DocHyperLinkResourceController=__decorateClass$1([__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.IUniverInstanceService)],DocHyperLinkResourceController);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.UniverDocsHyperLinkPlugin=(_b=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_commandService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._commandService=_commandService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>this._injector.add(dep)),[AddHyperLinkMuatation,DeleteHyperLinkMuatation,UpdateHyperLinkMuatation].forEach(mutation=>{this.disposeWithMe(this._commandService.registerCommand(mutation))}),this._injector.get(DocHyperLinkResourceController)}},__name(_b,"UniverDocsHyperLinkPlugin"),__publicField(_b,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_b,"type",core.UniverInstanceType.UNIVER_DOC),_b),exports2.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,core.ICommandService)],exports2.UniverDocsHyperLinkPlugin),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-alpha.0",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,18 +44,18 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@univerjs/core": "0.3.0"
47
+ "@univerjs/core": "0.4.0-alpha.0"
48
48
  },
49
49
  "dependencies": {
50
50
  "@univerjs/icons": "^0.1.78",
51
- "@univerjs/core": "0.3.0"
51
+ "@univerjs/core": "0.4.0-alpha.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "rxjs": "^7.8.1",
55
- "typescript": "^5.6.2",
55
+ "typescript": "^5.6.3",
56
56
  "vite": "^5.4.8",
57
- "vitest": "^2.1.1",
58
- "@univerjs-infra/shared": "0.3.0"
57
+ "vitest": "^2.1.2",
58
+ "@univerjs-infra/shared": "0.4.0-alpha.0"
59
59
  },
60
60
  "univerSpace": {
61
61
  ".": {