@univerjs/docs-hyper-link 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # @univerjs/docs-hyper-link
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@univerjs/docs-hyper-link)](https://npmjs.org/packages/@univerjs/docs-hyper-link )
4
- [![license](https://img.shields.io/npm/l/@univerjs/docs-hyper-link)](https://img.shields.io/npm/l/@univerjs/sheets- thread-comment)
3
+ ## Package Overview
4
+
5
+ | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
+ | --- | --- | --- | --- | --- | :---: | :---: |
7
+ | `@univerjs/docs-hyper-link` | `UniverDocsHyperLink` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
5
8
 
6
9
  ## Introduction
7
10
 
8
11
  `@univerjs/docs-hyper-link` provides the base link function of Univer Docs.
9
12
 
10
-
11
13
  ## Usage
12
14
 
13
- ### Install
15
+ ### Installation
14
16
 
15
17
  ```shell
16
18
  # Use npm
@@ -20,3 +22,8 @@ npm install @univerjs/docs-hyper-link
20
22
  pnpm add @univerjs/docs-hyper-link
21
23
  ```
22
24
 
25
+ <!-- Links -->
26
+ [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-hyper-link?style=flat-square
27
+ [npm-version-link]: https://npmjs.com/package/@univerjs/docs-hyper-link
28
+ [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-hyper-link?style=flat-square
29
+ [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-hyper-link?style=flat-square
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var U=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var c=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),m=require("rxjs"),u=require("@wendellhu/redi"),L="DOC_HYPER_LINK_PLUGIN";class p extends a.Disposable{constructor(){super();c(this,"_links",new Map);c(this,"_linkUpdate$",new m.Subject);c(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(e){let r=this._links.get(e);return r||(r=new Map,this._links.set(e,r)),r}addLink(e,r){return this._ensureMap(e).set(r.id,r),this._linkUpdate$.next({type:"add",link:r,unitId:e}),!0}updateLink(e,r,i){const s=this._ensureMap(e).get(r);if(!s)return!1;const g=s.payload;return s.payload=i,this._linkUpdate$.next({type:"update",link:s,oldPayload:g,unitId:e}),!0}deleteLink(e,r){const i=this._ensureMap(e),o=i.get(r);return o?(i.delete(r),this._linkUpdate$.next({type:"delete",link:o,unitId:e}),!1):!0}getLink(e,r){return this._ensureMap(e).get(r)}getUnit(e){const r=this._ensureMap(e);return Array.from(r.values())}deleteUnit(e){this._links.delete(e),this._linkUpdate$.next({unitId:e,type:"delete-unit"})}}var h=(n=>(n[n.URL=0]="URL",n))(h||{});const v={type:a.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(n,t){return t?n.get(p).addLink(t.unitId,t.link):!1}},f={type:a.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(n,t){return t?n.get(p).updateLink(t.unitId,t.linkId,t.payload):!1}},k={type:a.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(n,t){return t?n.get(p).deleteLink(t.unitId,t.linkId):!1}};var D=Object.defineProperty,P=Object.getOwnPropertyDescriptor,H=(n,t,e,r)=>{for(var i=r>1?void 0:r?P(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&D(t,e,i),i},O=(n,t)=>(e,r)=>t(e,r,n);let l=class extends a.Disposable{constructor(n){super(),this._commandService=n,this._initCommands()}_initCommands(){[v,f,k].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}};l=H([a.OnLifecycle(a.LifecycleStages.Starting,l),O(0,a.ICommandService)],l);var I=Object.defineProperty,S=Object.getOwnPropertyDescriptor,C=(n,t,e,r)=>{for(var i=r>1?void 0:r?S(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&I(t,e,i),i},_=(n,t)=>(e,r)=>t(e,r,n);let y=class extends a.Disposable{constructor(n,t,e){super(),this._resourceManagerService=n,this._docHyperLinkModel=t,this._univerInstanceService=e,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:L,businesses:[a.UniverInstanceType.UNIVER_DOC],onLoad:(n,t)=>{t.links.forEach(e=>{this._docHyperLinkModel.addLink(n,e)})},onUnLoad:n=>{this._docHyperLinkModel.deleteUnit(n)},toJson:n=>{var o;const t=this._docHyperLinkModel.getUnit(n),e=this._univerInstanceService.getUnit(n,a.UniverInstanceType.UNIVER_DOC),r=(o=e==null?void 0:e.getBody())==null?void 0:o.customRanges,i=new Set(r==null?void 0:r.filter(s=>s.rangeType===a.CustomRangeType.HYPERLINK).map(s=>s.rangeId));return JSON.stringify({links:t.filter(s=>i.has(s.id))})},parseJson(n){return JSON.parse(n)}})}};y=C([a.OnLifecycle(a.LifecycleStages.Starting,l),_(0,u.Inject(a.ResourceManagerService)),_(1,u.Inject(p)),_(2,a.IUniverInstanceService)],y);var N=Object.defineProperty,$=Object.getOwnPropertyDescriptor,b=(n,t,e,r)=>{for(var i=r>1?void 0:r?$(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&N(t,e,i),i},T=(n,t)=>(e,r)=>t(e,r,n),d;exports.UniverDocsHyperLinkPlugin=(d=class extends a.Plugin{constructor(t){super(),this._injector=t}onStarting(t){[[p],[l],[y]].forEach(r=>{t.add(r)})}},c(d,"pluginName",L),c(d,"type",a.UniverInstanceType.UNIVER_DOC),d);exports.UniverDocsHyperLinkPlugin=b([T(0,u.Inject(u.Injector))],exports.UniverDocsHyperLinkPlugin);exports.AddDocHyperLinkMutation=v;exports.DOC_HYPER_LINK_PLUGIN=L;exports.DeleteDocHyperLinkMutation=k;exports.DocHyperLinkModel=p;exports.DocHyperLinkType=h;exports.UpdateDocHyperLinkMutation=f;
1
+ "use strict";var M=Object.defineProperty;var U=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var c=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),m=require("rxjs"),_=require("@wendellhu/redi"),L="DOC_HYPER_LINK_PLUGIN";class p extends a.Disposable{constructor(){super();c(this,"_links",new Map);c(this,"_linkUpdate$",new m.Subject);c(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(e){let r=this._links.get(e);return r||(r=new Map,this._links.set(e,r)),r}addLink(e,r){return this._ensureMap(e).set(r.id,r),this._linkUpdate$.next({type:"add",link:r,unitId:e}),!0}updateLink(e,r,i){const s=this._ensureMap(e).get(r);if(!s)return!1;const g=s.payload;return s.payload=i,this._linkUpdate$.next({type:"update",link:s,oldPayload:g,unitId:e}),!0}deleteLink(e,r){const i=this._ensureMap(e),o=i.get(r);return o?(i.delete(r),this._linkUpdate$.next({type:"delete",link:o,unitId:e}),!1):!0}getLink(e,r){return this._ensureMap(e).get(r)}getUnit(e){const r=this._ensureMap(e);return Array.from(r.values())}deleteUnit(e){this._links.delete(e),this._linkUpdate$.next({unitId:e,type:"delete-unit"})}}var h=(n=>(n[n.URL=0]="URL",n))(h||{});const v={type:a.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(n,t){return t?n.get(p).addLink(t.unitId,t.link):!1}},f={type:a.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(n,t){return t?n.get(p).updateLink(t.unitId,t.linkId,t.payload):!1}},k={type:a.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(n,t){return t?n.get(p).deleteLink(t.unitId,t.linkId):!1}};var D=Object.defineProperty,P=Object.getOwnPropertyDescriptor,H=(n,t,e,r)=>{for(var i=r>1?void 0:r?P(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&D(t,e,i),i},O=(n,t)=>(e,r)=>t(e,r,n);let d=class extends a.Disposable{constructor(n){super(),this._commandService=n,this._initCommands()}_initCommands(){[v,f,k].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}};d=H([a.OnLifecycle(a.LifecycleStages.Starting,d),O(0,a.ICommandService)],d);var I=Object.defineProperty,S=Object.getOwnPropertyDescriptor,C=(n,t,e,r)=>{for(var i=r>1?void 0:r?S(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&I(t,e,i),i},y=(n,t)=>(e,r)=>t(e,r,n);let u=class extends a.Disposable{constructor(n,t,e){super(),this._resourceManagerService=n,this._docHyperLinkModel=t,this._univerInstanceService=e,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:L,businesses:[a.UniverInstanceType.UNIVER_DOC],onLoad:(n,t)=>{t.links.forEach(e=>{this._docHyperLinkModel.addLink(n,e)})},onUnLoad:n=>{this._docHyperLinkModel.deleteUnit(n)},toJson:n=>{var o;const t=this._docHyperLinkModel.getUnit(n),e=this._univerInstanceService.getUnit(n,a.UniverInstanceType.UNIVER_DOC),r=(o=e==null?void 0:e.getBody())==null?void 0:o.customRanges,i=new Set(r==null?void 0:r.filter(s=>s.rangeType===a.CustomRangeType.HYPERLINK).map(s=>s.rangeId));return JSON.stringify({links:t.filter(s=>i.has(s.id))})},parseJson(n){return JSON.parse(n)}})}};u=C([a.OnLifecycle(a.LifecycleStages.Starting,u),y(0,_.Inject(a.IResourceManagerService)),y(1,_.Inject(p)),y(2,a.IUniverInstanceService)],u);var N=Object.defineProperty,$=Object.getOwnPropertyDescriptor,b=(n,t,e,r)=>{for(var i=r>1?void 0:r?$(t,e):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=(r?s(t,e,i):s(i))||i);return r&&i&&N(t,e,i),i},T=(n,t)=>(e,r)=>t(e,r,n),l;exports.UniverDocsHyperLinkPlugin=(l=class extends a.Plugin{constructor(t){super(),this._injector=t}onStarting(t){[[p],[d],[u]].forEach(r=>{t.add(r)})}},c(l,"pluginName",L),c(l,"type",a.UniverInstanceType.UNIVER_DOC),l);exports.UniverDocsHyperLinkPlugin=b([T(0,_.Inject(_.Injector))],exports.UniverDocsHyperLinkPlugin);exports.AddDocHyperLinkMutation=v;exports.DOC_HYPER_LINK_PLUGIN=L;exports.DeleteDocHyperLinkMutation=k;exports.DocHyperLinkModel=p;exports.DocHyperLinkType=h;exports.UpdateDocHyperLinkMutation=f;
package/lib/es/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  var M = Object.defineProperty;
2
2
  var U = (t, n, e) => n in t ? M(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
3
  var a = (t, n, e) => U(t, typeof n != "symbol" ? n + "" : n, e);
4
- import { Disposable as y, CommandType as f, OnLifecycle as L, LifecycleStages as m, ICommandService as O, ResourceManagerService as P, IUniverInstanceService as H, UniverInstanceType as _, CustomRangeType as I, Plugin as D } from "@univerjs/core";
4
+ import { Disposable as y, CommandType as f, OnLifecycle as L, LifecycleStages as m, ICommandService as O, IResourceManagerService as P, UniverInstanceType as u, CustomRangeType as I, IUniverInstanceService as H, Plugin as D } from "@univerjs/core";
5
5
  import { Subject as S } from "rxjs";
6
- import { Inject as u, Injector as C } from "@wendellhu/redi";
6
+ import { Inject as h, Injector as C } from "@wendellhu/redi";
7
7
  const g = "DOC_HYPER_LINK_PLUGIN";
8
- class p extends y {
8
+ class c extends y {
9
9
  constructor() {
10
10
  super();
11
11
  a(this, "_links", /* @__PURE__ */ new Map());
@@ -65,19 +65,19 @@ const N = {
65
65
  type: f.MUTATION,
66
66
  id: "docs.mutation.add-hyper-link",
67
67
  handler(t, n) {
68
- return n ? t.get(p).addLink(n.unitId, n.link) : !1;
68
+ return n ? t.get(c).addLink(n.unitId, n.link) : !1;
69
69
  }
70
70
  }, R = {
71
71
  type: f.MUTATION,
72
72
  id: "docs.mutation.update-hyper-link",
73
73
  handler(t, n) {
74
- return n ? t.get(p).updateLink(n.unitId, n.linkId, n.payload) : !1;
74
+ return n ? t.get(c).updateLink(n.unitId, n.linkId, n.payload) : !1;
75
75
  }
76
76
  }, b = {
77
77
  type: f.MUTATION,
78
78
  id: "docs.mutation.delete-hyper-link",
79
79
  handler(t, n) {
80
- return n ? t.get(p).deleteLink(n.unitId, n.linkId) : !1;
80
+ return n ? t.get(c).deleteLink(n.unitId, n.linkId) : !1;
81
81
  }
82
82
  };
83
83
  var j = Object.defineProperty, w = Object.getOwnPropertyDescriptor, x = (t, n, e, r) => {
@@ -85,7 +85,7 @@ var j = Object.defineProperty, w = Object.getOwnPropertyDescriptor, x = (t, n, e
85
85
  (s = t[o]) && (i = (r ? s(n, e, i) : s(i)) || i);
86
86
  return r && i && j(n, e, i), i;
87
87
  }, E = (t, n) => (e, r) => n(e, r, t);
88
- let c = class extends y {
88
+ let l = class extends y {
89
89
  constructor(t) {
90
90
  super(), this._commandService = t, this._initCommands();
91
91
  }
@@ -99,23 +99,23 @@ let c = class extends y {
99
99
  });
100
100
  }
101
101
  };
102
- c = x([
103
- L(m.Starting, c),
102
+ l = x([
103
+ L(m.Starting, l),
104
104
  E(0, O)
105
- ], c);
105
+ ], l);
106
106
  var T = Object.defineProperty, A = Object.getOwnPropertyDescriptor, J = (t, n, e, r) => {
107
107
  for (var i = r > 1 ? void 0 : r ? A(n, e) : n, o = t.length - 1, s; o >= 0; o--)
108
108
  (s = t[o]) && (i = (r ? s(n, e, i) : s(i)) || i);
109
109
  return r && i && T(n, e, i), i;
110
- }, d = (t, n) => (e, r) => n(e, r, t);
111
- let h = class extends y {
110
+ }, _ = (t, n) => (e, r) => n(e, r, t);
111
+ let d = class extends y {
112
112
  constructor(t, n, e) {
113
113
  super(), this._resourceManagerService = t, this._docHyperLinkModel = n, this._univerInstanceService = e, this._init();
114
114
  }
115
115
  _init() {
116
116
  this._resourceManagerService.registerPluginResource({
117
117
  pluginName: g,
118
- businesses: [_.UNIVER_DOC],
118
+ businesses: [u.UNIVER_DOC],
119
119
  onLoad: (t, n) => {
120
120
  n.links.forEach((e) => {
121
121
  this._docHyperLinkModel.addLink(t, e);
@@ -126,7 +126,7 @@ let h = class extends y {
126
126
  },
127
127
  toJson: (t) => {
128
128
  var o;
129
- const n = this._docHyperLinkModel.getUnit(t), e = this._univerInstanceService.getUnit(t, _.UNIVER_DOC), r = (o = e == null ? void 0 : e.getBody()) == null ? void 0 : o.customRanges, i = new Set(r == null ? void 0 : r.filter((s) => s.rangeType === I.HYPERLINK).map((s) => s.rangeId));
129
+ const n = this._docHyperLinkModel.getUnit(t), e = this._univerInstanceService.getUnit(t, u.UNIVER_DOC), r = (o = e == null ? void 0 : e.getBody()) == null ? void 0 : o.customRanges, i = new Set(r == null ? void 0 : r.filter((s) => s.rangeType === I.HYPERLINK).map((s) => s.rangeId));
130
130
  return JSON.stringify({
131
131
  links: n.filter((s) => i.has(s.id))
132
132
  });
@@ -137,39 +137,39 @@ let h = class extends y {
137
137
  });
138
138
  }
139
139
  };
140
- h = J([
141
- L(m.Starting, c),
142
- d(0, u(P)),
143
- d(1, u(p)),
144
- d(2, H)
145
- ], h);
140
+ d = J([
141
+ L(m.Starting, d),
142
+ _(0, h(P)),
143
+ _(1, h(c)),
144
+ _(2, H)
145
+ ], d);
146
146
  var K = Object.defineProperty, V = Object.getOwnPropertyDescriptor, Y = (t, n, e, r) => {
147
147
  for (var i = r > 1 ? void 0 : r ? V(n, e) : n, o = t.length - 1, s; o >= 0; o--)
148
148
  (s = t[o]) && (i = (r ? s(n, e, i) : s(i)) || i);
149
149
  return r && i && K(n, e, i), i;
150
- }, G = (t, n) => (e, r) => n(e, r, t), l;
151
- let v = (l = class extends D {
150
+ }, G = (t, n) => (e, r) => n(e, r, t), p;
151
+ let v = (p = class extends D {
152
152
  constructor(t) {
153
153
  super(), this._injector = t;
154
154
  }
155
155
  onStarting(t) {
156
156
  [
157
- [p],
158
157
  [c],
159
- [h]
158
+ [l],
159
+ [d]
160
160
  ].forEach((e) => {
161
161
  t.add(e);
162
162
  });
163
163
  }
164
- }, a(l, "pluginName", g), a(l, "type", _.UNIVER_DOC), l);
164
+ }, a(p, "pluginName", g), a(p, "type", u.UNIVER_DOC), p);
165
165
  v = Y([
166
- G(0, u(C))
166
+ G(0, h(C))
167
167
  ], v);
168
168
  export {
169
169
  N as AddDocHyperLinkMutation,
170
170
  g as DOC_HYPER_LINK_PLUGIN,
171
171
  b as DeleteDocHyperLinkMutation,
172
- p as DocHyperLinkModel,
172
+ c as DocHyperLinkModel,
173
173
  $ as DocHyperLinkType,
174
174
  v as UniverDocsHyperLinkPlugin,
175
175
  R as UpdateDocHyperLinkMutation
@@ -1,10 +1,10 @@
1
- import { Disposable, IUniverInstanceService, ResourceManagerService } from '@univerjs/core';
1
+ import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
2
2
  import { DocHyperLinkModel } from '../models/hyper-link.model';
3
3
 
4
4
  export declare class DocHyperLinkResourceController extends Disposable {
5
5
  private readonly _resourceManagerService;
6
6
  private readonly _docHyperLinkModel;
7
7
  private readonly _univerInstanceService;
8
- constructor(_resourceManagerService: ResourceManagerService, _docHyperLinkModel: DocHyperLinkModel, _univerInstanceService: IUniverInstanceService);
8
+ constructor(_resourceManagerService: IResourceManagerService, _docHyperLinkModel: DocHyperLinkModel, _univerInstanceService: IUniverInstanceService);
9
9
  private _init;
10
10
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("rxjs"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@wendellhu/redi"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverDocsHyperLink={},o.UniverCore,o.rxjs,o["@wendellhu/redi"]))})(this,function(o,s,l,_){"use strict";var $=Object.defineProperty;var b=(o,s,l)=>s in o?$(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l;var c=(o,s,l)=>b(o,typeof s!="symbol"?s+"":s,l);var y;const h="DOC_HYPER_LINK_PLUGIN";class p extends s.Disposable{constructor(){super();c(this,"_links",new Map);c(this,"_linkUpdate$",new l.Subject);c(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(e){let t=this._links.get(e);return t||(t=new Map,this._links.set(e,t)),t}addLink(e,t){return this._ensureMap(e).set(t.id,t),this._linkUpdate$.next({type:"add",link:t,unitId:e}),!0}updateLink(e,t,r){const a=this._ensureMap(e).get(t);if(!a)return!1;const T=a.payload;return a.payload=r,this._linkUpdate$.next({type:"update",link:a,oldPayload:T,unitId:e}),!0}deleteLink(e,t){const r=this._ensureMap(e),d=r.get(t);return d?(r.delete(t),this._linkUpdate$.next({type:"delete",link:d,unitId:e}),!1):!0}getLink(e,t){return this._ensureMap(e).get(t)}getUnit(e){const t=this._ensureMap(e);return Array.from(t.values())}deleteUnit(e){this._links.delete(e),this._linkUpdate$.next({unitId:e,type:"delete-unit"})}}var L=(i=>(i[i.URL=0]="URL",i))(L||{});const k={type:s.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(i,n){return n?i.get(p).addLink(n.unitId,n.link):!1}},U={type:s.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(i,n){return n?i.get(p).updateLink(n.unitId,n.linkId,n.payload):!1}},m={type:s.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(i,n){return n?i.get(p).deleteLink(n.unitId,n.linkId):!1}};var M=Object.defineProperty,g=Object.getOwnPropertyDescriptor,D=(i,n,e,t)=>{for(var r=t>1?void 0:t?g(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&M(n,e,r),r},P=(i,n)=>(e,t)=>n(e,t,i);let u=class extends s.Disposable{constructor(i){super(),this._commandService=i,this._initCommands()}_initCommands(){[k,U,m].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};u=D([s.OnLifecycle(s.LifecycleStages.Starting,u),P(0,s.ICommandService)],u);var H=Object.defineProperty,O=Object.getOwnPropertyDescriptor,I=(i,n,e,t)=>{for(var r=t>1?void 0:t?O(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&H(n,e,r),r},f=(i,n)=>(e,t)=>n(e,t,i);let v=class extends s.Disposable{constructor(i,n,e){super(),this._resourceManagerService=i,this._docHyperLinkModel=n,this._univerInstanceService=e,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:h,businesses:[s.UniverInstanceType.UNIVER_DOC],onLoad:(i,n)=>{n.links.forEach(e=>{this._docHyperLinkModel.addLink(i,e)})},onUnLoad:i=>{this._docHyperLinkModel.deleteUnit(i)},toJson:i=>{var d;const n=this._docHyperLinkModel.getUnit(i),e=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_DOC),t=(d=e==null?void 0:e.getBody())==null?void 0:d.customRanges,r=new Set(t==null?void 0:t.filter(a=>a.rangeType===s.CustomRangeType.HYPERLINK).map(a=>a.rangeId));return JSON.stringify({links:n.filter(a=>r.has(a.id))})},parseJson(i){return JSON.parse(i)}})}};v=I([s.OnLifecycle(s.LifecycleStages.Starting,u),f(0,_.Inject(s.ResourceManagerService)),f(1,_.Inject(p)),f(2,s.IUniverInstanceService)],v);var C=Object.defineProperty,S=Object.getOwnPropertyDescriptor,j=(i,n,e,t)=>{for(var r=t>1?void 0:t?S(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&C(n,e,r),r},N=(i,n)=>(e,t)=>n(e,t,i);o.UniverDocsHyperLinkPlugin=(y=class extends s.Plugin{constructor(n){super(),this._injector=n}onStarting(n){[[p],[u],[v]].forEach(t=>{n.add(t)})}},c(y,"pluginName",h),c(y,"type",s.UniverInstanceType.UNIVER_DOC),y),o.UniverDocsHyperLinkPlugin=j([N(0,_.Inject(_.Injector))],o.UniverDocsHyperLinkPlugin),o.AddDocHyperLinkMutation=k,o.DOC_HYPER_LINK_PLUGIN=h,o.DeleteDocHyperLinkMutation=m,o.DocHyperLinkModel=p,o.DocHyperLinkType=L,o.UpdateDocHyperLinkMutation=U,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("rxjs"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@wendellhu/redi"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverDocsHyperLink={},o.UniverCore,o.rxjs,o["@wendellhu/redi"]))})(this,function(o,s,l,u){"use strict";var $=Object.defineProperty;var b=(o,s,l)=>s in o?$(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l;var c=(o,s,l)=>b(o,typeof s!="symbol"?s+"":s,l);var h;const f="DOC_HYPER_LINK_PLUGIN";class p extends s.Disposable{constructor(){super();c(this,"_links",new Map);c(this,"_linkUpdate$",new l.Subject);c(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(e){let t=this._links.get(e);return t||(t=new Map,this._links.set(e,t)),t}addLink(e,t){return this._ensureMap(e).set(t.id,t),this._linkUpdate$.next({type:"add",link:t,unitId:e}),!0}updateLink(e,t,r){const a=this._ensureMap(e).get(t);if(!a)return!1;const T=a.payload;return a.payload=r,this._linkUpdate$.next({type:"update",link:a,oldPayload:T,unitId:e}),!0}deleteLink(e,t){const r=this._ensureMap(e),d=r.get(t);return d?(r.delete(t),this._linkUpdate$.next({type:"delete",link:d,unitId:e}),!1):!0}getLink(e,t){return this._ensureMap(e).get(t)}getUnit(e){const t=this._ensureMap(e);return Array.from(t.values())}deleteUnit(e){this._links.delete(e),this._linkUpdate$.next({unitId:e,type:"delete-unit"})}}var L=(i=>(i[i.URL=0]="URL",i))(L||{});const k={type:s.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(i,n){return n?i.get(p).addLink(n.unitId,n.link):!1}},U={type:s.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(i,n){return n?i.get(p).updateLink(n.unitId,n.linkId,n.payload):!1}},m={type:s.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(i,n){return n?i.get(p).deleteLink(n.unitId,n.linkId):!1}};var M=Object.defineProperty,g=Object.getOwnPropertyDescriptor,D=(i,n,e,t)=>{for(var r=t>1?void 0:t?g(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&M(n,e,r),r},P=(i,n)=>(e,t)=>n(e,t,i);let _=class extends s.Disposable{constructor(i){super(),this._commandService=i,this._initCommands()}_initCommands(){[k,U,m].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};_=D([s.OnLifecycle(s.LifecycleStages.Starting,_),P(0,s.ICommandService)],_);var H=Object.defineProperty,O=Object.getOwnPropertyDescriptor,I=(i,n,e,t)=>{for(var r=t>1?void 0:t?O(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&H(n,e,r),r},v=(i,n)=>(e,t)=>n(e,t,i);let y=class extends s.Disposable{constructor(i,n,e){super(),this._resourceManagerService=i,this._docHyperLinkModel=n,this._univerInstanceService=e,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:f,businesses:[s.UniverInstanceType.UNIVER_DOC],onLoad:(i,n)=>{n.links.forEach(e=>{this._docHyperLinkModel.addLink(i,e)})},onUnLoad:i=>{this._docHyperLinkModel.deleteUnit(i)},toJson:i=>{var d;const n=this._docHyperLinkModel.getUnit(i),e=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_DOC),t=(d=e==null?void 0:e.getBody())==null?void 0:d.customRanges,r=new Set(t==null?void 0:t.filter(a=>a.rangeType===s.CustomRangeType.HYPERLINK).map(a=>a.rangeId));return JSON.stringify({links:n.filter(a=>r.has(a.id))})},parseJson(i){return JSON.parse(i)}})}};y=I([s.OnLifecycle(s.LifecycleStages.Starting,y),v(0,u.Inject(s.IResourceManagerService)),v(1,u.Inject(p)),v(2,s.IUniverInstanceService)],y);var C=Object.defineProperty,S=Object.getOwnPropertyDescriptor,j=(i,n,e,t)=>{for(var r=t>1?void 0:t?S(n,e):n,d=i.length-1,a;d>=0;d--)(a=i[d])&&(r=(t?a(n,e,r):a(r))||r);return t&&r&&C(n,e,r),r},N=(i,n)=>(e,t)=>n(e,t,i);o.UniverDocsHyperLinkPlugin=(h=class extends s.Plugin{constructor(n){super(),this._injector=n}onStarting(n){[[p],[_],[y]].forEach(t=>{n.add(t)})}},c(h,"pluginName",f),c(h,"type",s.UniverInstanceType.UNIVER_DOC),h),o.UniverDocsHyperLinkPlugin=j([N(0,u.Inject(u.Injector))],o.UniverDocsHyperLinkPlugin),o.AddDocHyperLinkMutation=k,o.DOC_HYPER_LINK_PLUGIN=f,o.DeleteDocHyperLinkMutation=m,o.DocHyperLinkModel=p,o.DocHyperLinkType=L,o.UpdateDocHyperLinkMutation=U,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -46,7 +46,7 @@
46
46
  "peerDependencies": {
47
47
  "@wendellhu/redi": "0.15.5",
48
48
  "rxjs": ">=7.0.0",
49
- "@univerjs/core": "0.2.1"
49
+ "@univerjs/core": "0.2.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@wendellhu/redi": "0.15.5",
@@ -54,9 +54,9 @@
54
54
  "typescript": "^5.5.3",
55
55
  "vite": "^5.3.3",
56
56
  "vitest": "^1.6.0",
57
- "@univerjs/core": "0.2.1",
58
- "@univerjs/design": "0.2.1",
59
- "@univerjs/shared": "0.2.1"
57
+ "@univerjs/core": "0.2.3",
58
+ "@univerjs/shared": "0.2.3",
59
+ "@univerjs/design": "0.2.3"
60
60
  },
61
61
  "univerSpace": {
62
62
  ".": {