@univerjs/docs-hyper-link 0.4.2 → 0.5.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([__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);
1
+ "use strict";var g=Object.defineProperty;var f=(t,e,r)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var l=(t,e,r)=>f(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),y={id:"docs.mutation.add-hyper-link",type:s.CommandType.MUTATION,handler:()=>!0},I={id:"docs.mutation.update-hyper-link",type:s.CommandType.MUTATION,handler:()=>!0},P={id:"docs.mutation.delete-hyper-link",type:s.CommandType.MUTATION,handler:()=>!0},m="docs-hyper-link.config",U={};var M=Object.defineProperty,O=Object.getOwnPropertyDescriptor,C=(t,e,r,i)=>{for(var n=i>1?void 0:i?O(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&M(e,r,n),n},h=(t,e)=>(r,i)=>e(r,i,t);const v="DOC_HYPER_LINK_PLUGIN";let d=class extends s.Disposable{constructor(t,e){super(),this._resourceManagerService=t,this._univerInstanceService=e,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:v,businesses:[s.UniverInstanceType.UNIVER_DOC],onLoad:(t,e)=>{const r=this._univerInstanceService.getUnit(t,s.UniverInstanceType.UNIVER_DOC);if(!r)return;const i=new Map,n=o=>{var c,a;return(a=(c=o.getBody())==null?void 0:c.customRanges)==null||a.forEach(p=>{p.rangeType===s.CustomRangeType.HYPERLINK&&i.set(p.rangeId,p)}),i};r.headerModelMap.forEach(o=>{n(o)}),r.footerModelMap.forEach(o=>{n(o)}),n(r),e.links.forEach(o=>{const c=i.get(o.id);c&&(c.properties={...c.properties,url:o.payload})})},onUnLoad:t=>{},toJson:t=>{const e=this._univerInstanceService.getUnit(t,s.UniverInstanceType.UNIVER_DOC),r=[];if(e){const i=n=>{var o,c;(c=(o=n.getBody())==null?void 0:o.customRanges)==null||c.forEach(a=>{var p;a.rangeType===s.CustomRangeType.HYPERLINK&&r.push({id:a.rangeId,payload:((p=a.properties)==null?void 0:p.url)||""})})};e.headerModelMap.forEach(n=>{i(n)}),e.footerModelMap.forEach(n=>{i(n)}),i(e)}return JSON.stringify({links:r})},parseJson(t){return JSON.parse(t)}})}};d=C([h(0,s.Inject(s.IResourceManagerService)),h(1,s.IUniverInstanceService)],d);var D=Object.defineProperty,N=Object.getOwnPropertyDescriptor,E=(t,e,r,i)=>{for(var n=i>1?void 0:i?N(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&D(e,r,n),n},_=(t,e)=>(r,i)=>e(r,i,t),u;exports.UniverDocsHyperLinkPlugin=(u=class extends s.Plugin{constructor(e=U,r,i,n){super(),this._config=e,this._injector=r,this._configService=i,this._commandService=n;const{...o}=this._config;this._configService.setConfig(m,o)}onStarting(){[[d]].forEach(r=>this._injector.add(r)),[y,P,I].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))}),this._injector.get(d)}},l(u,"pluginName",v),l(u,"type",s.UniverInstanceType.UNIVER_DOC),u);exports.UniverDocsHyperLinkPlugin=E([_(1,s.Inject(s.Injector)),_(2,s.IConfigService),_(3,s.ICommandService)],exports.UniverDocsHyperLinkPlugin);
package/lib/es/index.js CHANGED
@@ -1,113 +1,111 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, Inject, IResourceManagerService, Disposable, UniverInstanceType, IUniverInstanceService, CustomRangeType, Plugin, Injector, IConfigService, ICommandService } from "@univerjs/core";
6
- const AddHyperLinkMuatation = {
1
+ var P = Object.defineProperty;
2
+ var m = (r, e, n) => e in r ? P(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var _ = (r, e, n) => m(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { CommandType as l, Inject as I, IResourceManagerService as M, Disposable as O, UniverInstanceType as d, IUniverInstanceService as N, CustomRangeType as f, Plugin as E, Injector as C, IConfigService as D, ICommandService as U } from "@univerjs/core";
5
+ const S = {
7
6
  id: "docs.mutation.add-hyper-link",
8
- type: CommandType.MUTATION,
9
- handler: /* @__PURE__ */ __name(() => !0, "handler")
10
- }, UpdateHyperLinkMuatation = {
7
+ type: l.MUTATION,
8
+ handler: () => !0
9
+ }, L = {
11
10
  id: "docs.mutation.update-hyper-link",
12
- type: CommandType.MUTATION,
13
- handler: /* @__PURE__ */ __name(() => !0, "handler")
14
- }, DeleteHyperLinkMuatation = {
11
+ type: l.MUTATION,
12
+ handler: () => !0
13
+ }, R = {
15
14
  id: "docs.mutation.delete-hyper-link",
16
- type: CommandType.MUTATION,
17
- handler: /* @__PURE__ */ __name(() => !0, "handler")
18
- }, PLUGIN_CONFIG_KEY = "docs-hyper-link.config", defaultPluginConfig = {};
19
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
20
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
21
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
22
- return kind && result && __defProp$1(target, key, result), result;
23
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
24
- const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
25
- var _a;
26
- let DocHyperLinkResourceController = (_a = class extends Disposable {
27
- constructor(_resourceManagerService, _univerInstanceService) {
28
- super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._init();
15
+ type: l.MUTATION,
16
+ handler: () => !0
17
+ }, T = "docs-hyper-link.config", j = {};
18
+ var H = Object.defineProperty, b = Object.getOwnPropertyDescriptor, w = (r, e, n, o) => {
19
+ for (var t = o > 1 ? void 0 : o ? b(e, n) : e, i = r.length - 1, s; i >= 0; i--)
20
+ (s = r[i]) && (t = (o ? s(e, n, t) : s(t)) || t);
21
+ return o && t && H(e, n, t), t;
22
+ }, v = (r, e) => (n, o) => e(n, o, r);
23
+ const y = "DOC_HYPER_LINK_PLUGIN";
24
+ let u = class extends O {
25
+ constructor(r, e) {
26
+ super(), this._resourceManagerService = r, this._univerInstanceService = e, this._init();
29
27
  }
30
28
  _init() {
31
29
  this._resourceManagerService.registerPluginResource({
32
- pluginName: DOC_HYPER_LINK_PLUGIN,
33
- businesses: [UniverInstanceType.UNIVER_DOC],
34
- onLoad: /* @__PURE__ */ __name((unitID, resource) => {
35
- const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
36
- if (!doc)
30
+ pluginName: y,
31
+ businesses: [d.UNIVER_DOC],
32
+ onLoad: (r, e) => {
33
+ const n = this._univerInstanceService.getUnit(r, d.UNIVER_DOC);
34
+ if (!n)
37
35
  return;
38
- const customRangeMap = /* @__PURE__ */ new Map(), handleDoc = /* @__PURE__ */ __name((model) => {
39
- var _a3, _b;
40
- return (_b = (_a3 = model.getBody()) == null ? void 0 : _a3.customRanges) == null || _b.forEach((customRange) => {
41
- customRange.rangeType === CustomRangeType.HYPERLINK && customRangeMap.set(customRange.rangeId, customRange);
42
- }), customRangeMap;
43
- }, "handleDoc");
44
- doc.headerModelMap.forEach((headerModel) => {
45
- handleDoc(headerModel);
46
- }), doc.footerModelMap.forEach((footerModel) => {
47
- handleDoc(footerModel);
48
- }), handleDoc(doc), resource.links.forEach((link) => {
49
- const customRange = customRangeMap.get(link.id);
50
- customRange && (customRange.properties = {
51
- ...customRange.properties,
52
- url: link.payload
36
+ const o = /* @__PURE__ */ new Map(), t = (i) => {
37
+ var s, a;
38
+ return (a = (s = i.getBody()) == null ? void 0 : s.customRanges) == null || a.forEach((c) => {
39
+ c.rangeType === f.HYPERLINK && o.set(c.rangeId, c);
40
+ }), o;
41
+ };
42
+ n.headerModelMap.forEach((i) => {
43
+ t(i);
44
+ }), n.footerModelMap.forEach((i) => {
45
+ t(i);
46
+ }), t(n), e.links.forEach((i) => {
47
+ const s = o.get(i.id);
48
+ s && (s.properties = {
49
+ ...s.properties,
50
+ url: i.payload
53
51
  });
54
52
  });
55
- }, "onLoad"),
56
- onUnLoad: /* @__PURE__ */ __name((unitID) => {
57
- }, "onUnLoad"),
58
- toJson: /* @__PURE__ */ __name((unitID) => {
59
- const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC), links = [];
60
- if (doc) {
61
- const handleDoc = /* @__PURE__ */ __name((model) => {
62
- var _a3, _b;
63
- (_b = (_a3 = model.getBody()) == null ? void 0 : _a3.customRanges) == null || _b.forEach((customRange) => {
64
- var _a4;
65
- customRange.rangeType === CustomRangeType.HYPERLINK && links.push({
66
- id: customRange.rangeId,
67
- payload: ((_a4 = customRange.properties) == null ? void 0 : _a4.url) || ""
53
+ },
54
+ onUnLoad: (r) => {
55
+ },
56
+ toJson: (r) => {
57
+ const e = this._univerInstanceService.getUnit(r, d.UNIVER_DOC), n = [];
58
+ if (e) {
59
+ const o = (t) => {
60
+ var i, s;
61
+ (s = (i = t.getBody()) == null ? void 0 : i.customRanges) == null || s.forEach((a) => {
62
+ var c;
63
+ a.rangeType === f.HYPERLINK && n.push({
64
+ id: a.rangeId,
65
+ payload: ((c = a.properties) == null ? void 0 : c.url) || ""
68
66
  });
69
67
  });
70
- }, "handleDoc");
71
- doc.headerModelMap.forEach((headerModel) => {
72
- handleDoc(headerModel);
73
- }), doc.footerModelMap.forEach((footerModel) => {
74
- handleDoc(footerModel);
75
- }), handleDoc(doc);
68
+ };
69
+ e.headerModelMap.forEach((t) => {
70
+ o(t);
71
+ }), e.footerModelMap.forEach((t) => {
72
+ o(t);
73
+ }), o(e);
76
74
  }
77
- return JSON.stringify({ links });
78
- }, "toJson"),
79
- parseJson(bytes) {
80
- return JSON.parse(bytes);
75
+ return JSON.stringify({ links: n });
76
+ },
77
+ parseJson(r) {
78
+ return JSON.parse(r);
81
79
  }
82
80
  });
83
81
  }
84
- }, __name(_a, "DocHyperLinkResourceController"), _a);
85
- DocHyperLinkResourceController = __decorateClass$1([
86
- __decorateParam$1(0, Inject(IResourceManagerService)),
87
- __decorateParam$1(1, IUniverInstanceService)
88
- ], DocHyperLinkResourceController);
89
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
90
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
91
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
92
- return kind && result && __defProp2(target, key, result), result;
93
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a2;
94
- let UniverDocsHyperLinkPlugin = (_a2 = class extends Plugin {
95
- constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
96
- super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._commandService = _commandService;
97
- const { ...rest } = this._config;
98
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
82
+ };
83
+ u = w([
84
+ v(0, I(M)),
85
+ v(1, N)
86
+ ], u);
87
+ var K = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, A = (r, e, n, o) => {
88
+ for (var t = o > 1 ? void 0 : o ? Y(e, n) : e, i = r.length - 1, s; i >= 0; i--)
89
+ (s = r[i]) && (t = (o ? s(e, n, t) : s(t)) || t);
90
+ return o && t && K(e, n, t), t;
91
+ }, h = (r, e) => (n, o) => e(n, o, r), p;
92
+ let g = (p = class extends E {
93
+ constructor(r = j, e, n, o) {
94
+ super(), this._config = r, this._injector = e, this._configService = n, this._commandService = o;
95
+ const { ...t } = this._config;
96
+ this._configService.setConfig(T, t);
99
97
  }
100
98
  onStarting() {
101
- [[DocHyperLinkResourceController]].forEach((dep) => this._injector.add(dep)), [AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation].forEach((mutation) => {
102
- this.disposeWithMe(this._commandService.registerCommand(mutation));
103
- }), this._injector.get(DocHyperLinkResourceController);
99
+ [[u]].forEach((e) => this._injector.add(e)), [S, R, L].forEach((e) => {
100
+ this.disposeWithMe(this._commandService.registerCommand(e));
101
+ }), this._injector.get(u);
104
102
  }
105
- }, __name(_a2, "UniverDocsHyperLinkPlugin"), __publicField(_a2, "pluginName", DOC_HYPER_LINK_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_DOC), _a2);
106
- UniverDocsHyperLinkPlugin = __decorateClass([
107
- __decorateParam(1, Inject(Injector)),
108
- __decorateParam(2, IConfigService),
109
- __decorateParam(3, ICommandService)
110
- ], UniverDocsHyperLinkPlugin);
103
+ }, _(p, "pluginName", y), _(p, "type", d.UNIVER_DOC), p);
104
+ g = A([
105
+ h(1, I(C)),
106
+ h(2, D),
107
+ h(3, U)
108
+ ], g);
111
109
  export {
112
- UniverDocsHyperLinkPlugin
110
+ g as UniverDocsHyperLinkPlugin
113
111
  };
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([__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"})});
1
+ (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.UniverDocsHyperLink={},c.UniverCore))})(this,function(c,e){"use strict";var N=Object.defineProperty;var E=(c,e,p)=>e in c?N(c,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[e]=p;var _=(c,e,p)=>E(c,typeof e!="symbol"?e+"":e,p);var l;const p={id:"docs.mutation.add-hyper-link",type:e.CommandType.MUTATION,handler:()=>!0},y={id:"docs.mutation.update-hyper-link",type:e.CommandType.MUTATION,handler:()=>!0},I={id:"docs.mutation.delete-hyper-link",type:e.CommandType.MUTATION,handler:()=>!0},m="docs-hyper-link.config",P={};var U=Object.defineProperty,C=Object.getOwnPropertyDescriptor,D=(o,t,r,i)=>{for(var n=i>1?void 0:i?C(t,r):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,r,n):a(n))||n);return i&&n&&U(t,r,n),n},h=(o,t)=>(r,i)=>t(r,i,o);const g="DOC_HYPER_LINK_PLUGIN";let f=class extends e.Disposable{constructor(o,t){super(),this._resourceManagerService=o,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:g,businesses:[e.UniverInstanceType.UNIVER_DOC],onLoad:(o,t)=>{const r=this._univerInstanceService.getUnit(o,e.UniverInstanceType.UNIVER_DOC);if(!r)return;const i=new Map,n=s=>{var a,u;return(u=(a=s.getBody())==null?void 0:a.customRanges)==null||u.forEach(d=>{d.rangeType===e.CustomRangeType.HYPERLINK&&i.set(d.rangeId,d)}),i};r.headerModelMap.forEach(s=>{n(s)}),r.footerModelMap.forEach(s=>{n(s)}),n(r),t.links.forEach(s=>{const a=i.get(s.id);a&&(a.properties={...a.properties,url:s.payload})})},onUnLoad:o=>{},toJson:o=>{const t=this._univerInstanceService.getUnit(o,e.UniverInstanceType.UNIVER_DOC),r=[];if(t){const i=n=>{var s,a;(a=(s=n.getBody())==null?void 0:s.customRanges)==null||a.forEach(u=>{var d;u.rangeType===e.CustomRangeType.HYPERLINK&&r.push({id:u.rangeId,payload:((d=u.properties)==null?void 0:d.url)||""})})};t.headerModelMap.forEach(n=>{i(n)}),t.footerModelMap.forEach(n=>{i(n)}),i(t)}return JSON.stringify({links:r})},parseJson(o){return JSON.parse(o)}})}};f=D([h(0,e.Inject(e.IResourceManagerService)),h(1,e.IUniverInstanceService)],f);var M=Object.defineProperty,O=Object.getOwnPropertyDescriptor,T=(o,t,r,i)=>{for(var n=i>1?void 0:i?O(t,r):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,r,n):a(n))||n);return i&&n&&M(t,r,n),n},v=(o,t)=>(r,i)=>t(r,i,o);c.UniverDocsHyperLinkPlugin=(l=class extends e.Plugin{constructor(t=P,r,i,n){super(),this._config=t,this._injector=r,this._configService=i,this._commandService=n;const{...s}=this._config;this._configService.setConfig(m,s)}onStarting(){[[f]].forEach(r=>this._injector.add(r)),[p,I,y].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))}),this._injector.get(f)}},_(l,"pluginName",g),_(l,"type",e.UniverInstanceType.UNIVER_DOC),l),c.UniverDocsHyperLinkPlugin=T([v(1,e.Inject(e.Injector)),v(2,e.IConfigService),v(3,e.ICommandService)],c.UniverDocsHyperLinkPlugin),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link",
3
- "version": "0.4.2",
3
+ "version": "0.5.0-alpha.0",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -31,8 +31,7 @@
31
31
  },
32
32
  "./lib/*": "./lib/*"
33
33
  },
34
- "main": "./lib/cjs/index.js",
35
- "module": "./lib/es/index.js",
34
+ "main": "./lib/es/index.js",
36
35
  "types": "./lib/types/index.d.ts",
37
36
  "publishConfig": {
38
37
  "access": "public"
@@ -43,21 +42,19 @@
43
42
  "files": [
44
43
  "lib"
45
44
  ],
46
- "peerDependencies": {
47
- "@univerjs/core": "0.4.2"
48
- },
49
45
  "dependencies": {
50
- "@univerjs/icons": "^0.1.84",
51
- "@univerjs/core": "0.4.2"
46
+ "@univerjs/icons": "^0.2.5",
47
+ "@vitejs/plugin-react": "4.3.3",
48
+ "@univerjs/core": "0.5.0-alpha.0"
52
49
  },
53
50
  "devDependencies": {
54
51
  "rxjs": "^7.8.1",
55
52
  "typescript": "^5.6.3",
56
- "vite": "^5.4.8",
57
- "vitest": "^2.1.2",
58
- "@univerjs-infra/shared": "0.4.2"
53
+ "vite": "^5.4.10",
54
+ "vitest": "^2.1.4",
55
+ "@univerjs-infra/shared": "0.5.0-alpha.0"
59
56
  },
60
- "univerSpace": {
57
+ "space": {
61
58
  ".": {
62
59
  "import": "./lib/es/index.js",
63
60
  "require": "./lib/cjs/index.js",
@@ -75,6 +72,7 @@
75
72
  "test:watch": "vitest",
76
73
  "coverage": "vitest run --coverage",
77
74
  "lint:types": "tsc --noEmit",
78
- "build": "tsc && vite build"
79
- }
75
+ "build": "tsx build.ts"
76
+ },
77
+ "module": "./lib/es/index.js"
80
78
  }