@univerjs/docs-hyper-link 0.2.10 → 0.2.12

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
@@ -2,20 +2,28 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- `@univerjs/docs-hyper-link` provides the base link function of Univer Docs.
5
+ `@univerjs/docs-hyper-link` provides the link function of Univer Docs.
6
6
 
7
7
  ## Usage
8
8
 
9
9
  ### Installation
10
10
 
11
11
  ```shell
12
- # Use npm
12
+ # Using npm
13
13
  npm install @univerjs/docs-hyper-link
14
14
 
15
- # Use pnpm
15
+ # Using pnpm
16
16
  pnpm add @univerjs/docs-hyper-link
17
17
  ```
18
18
 
19
+ ### Register the plugin
20
+
21
+ ```typescript
22
+ import { UniverDocsHyperLinkUIPlugin} from '@univerjs/docs-hyper-link';
23
+
24
+ univer.registerPlugin(UniverDocsHyperLinkUIPlugin);
25
+ ```
26
+
19
27
  <!-- Links -->
20
28
  [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-hyper-link?style=flat-square
21
29
  [npm-version-link]: https://npmjs.com/package/@univerjs/docs-hyper-link
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"),rxjs=require("rxjs"),DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN",_DocHyperLinkModel=class _DocHyperLinkModel extends core.Disposable{constructor(){super();__publicField(this,"_links",new Map);__publicField(this,"_linkUpdate$",new rxjs.Subject);__publicField(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(unitId){let map=this._links.get(unitId);return map||(map=new Map,this._links.set(unitId,map)),map}addLink(unitId,link){const map=this._ensureMap(unitId);return link.payload=core.Tools.normalizeUrl(link.payload),map.set(link.id,link),this._linkUpdate$.next({type:"add",link,unitId}),!0}updateLink(unitId,id,payload){const link=this._ensureMap(unitId).get(id);if(!link)return!1;const oldPayload=link.payload;return link.payload=payload,this._linkUpdate$.next({type:"update",link,oldPayload,unitId}),!0}deleteLink(unitId,id){const map=this._ensureMap(unitId),link=map.get(id);return link?(map.delete(id),this._linkUpdate$.next({type:"delete",link,unitId}),!1):!0}getLink(unitId,linkId){return this._ensureMap(unitId).get(linkId)}getUnit(unitId){const map=this._ensureMap(unitId);return Array.from(map.values())}deleteUnit(unitId){this._links.delete(unitId),this._linkUpdate$.next({unitId,type:"delete-unit"})}};__name(_DocHyperLinkModel,"DocHyperLinkModel");let DocHyperLinkModel=_DocHyperLinkModel;var DocHyperLinkType=(DocHyperLinkType2=>(DocHyperLinkType2[DocHyperLinkType2.URL=0]="URL",DocHyperLinkType2))(DocHyperLinkType||{});const AddDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).addLink(params.unitId,params.link):!1}},UpdateDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).updateLink(params.unitId,params.linkId,params.payload):!1}},DeleteDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).deleteLink(params.unitId,params.linkId):!1}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(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$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a;let DocHyperLinkController=(_a=class extends core.Disposable{constructor(_commandService){super(),this._commandService=_commandService,this._initCommands()}_initCommands(){[AddDocHyperLinkMutation,UpdateDocHyperLinkMutation,DeleteDocHyperLinkMutation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}},__name(_a,"DocHyperLinkController"),_a);DocHyperLinkController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkController),__decorateParam$2(0,core.ICommandService)],DocHyperLinkController);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"),_a2;let DocHyperLinkResourceController=(_a2=class extends core.Disposable{constructor(_resourceManagerService,_docHyperLinkModel,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._docHyperLinkModel=_docHyperLinkModel,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{resource.links.forEach(link=>{this._docHyperLinkModel.addLink(unitID,link)})},"onLoad"),onUnLoad:__name(unitID=>{this._docHyperLinkModel.deleteUnit(unitID)},"onUnLoad"),toJson:__name(unitID=>{var _a4;const links=this._docHyperLinkModel.getUnit(unitID),doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),customRanges=(_a4=doc==null?void 0:doc.getBody())==null?void 0:_a4.customRanges,set=new Set(customRanges==null?void 0:customRanges.filter(i=>i.rangeType===core.CustomRangeType.HYPERLINK).map(i=>i.rangeId));return JSON.stringify({links:links.filter(link=>set.has(link.id))})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_a2,"DocHyperLinkResourceController"),_a2);DocHyperLinkResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkResourceController),__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.Inject(DocHyperLinkModel)),__decorateParam$1(2,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"),_a3;exports.UniverDocsHyperLinkPlugin=(_a3=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[DocHyperLinkModel],[DocHyperLinkController],[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)})}},__name(_a3,"UniverDocsHyperLinkPlugin"),__publicField(_a3,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_DOC),_a3);exports.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports.UniverDocsHyperLinkPlugin);exports.AddDocHyperLinkMutation=AddDocHyperLinkMutation;exports.DOC_HYPER_LINK_PLUGIN=DOC_HYPER_LINK_PLUGIN;exports.DeleteDocHyperLinkMutation=DeleteDocHyperLinkMutation;exports.DocHyperLinkModel=DocHyperLinkModel;exports.DocHyperLinkType=DocHyperLinkType;exports.UpdateDocHyperLinkMutation=UpdateDocHyperLinkMutation;
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");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);const PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)})}},__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)],exports.UniverDocsHyperLinkPlugin);
package/lib/es/index.js CHANGED
@@ -2,177 +2,102 @@ 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 { Disposable, Tools, CommandType, OnLifecycle, LifecycleStages, ICommandService, Inject, IResourceManagerService, UniverInstanceType, CustomRangeType, IUniverInstanceService, Plugin, Injector } from "@univerjs/core";
6
- import { Subject } from "rxjs";
7
- const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN", _DocHyperLinkModel = class _DocHyperLinkModel extends Disposable {
8
- constructor() {
9
- super();
10
- __publicField(this, "_links", /* @__PURE__ */ new Map());
11
- __publicField(this, "_linkUpdate$", new Subject());
12
- __publicField(this, "linkUpdate$", this._linkUpdate$.asObservable());
13
- this.disposeWithMe(() => {
14
- this._linkUpdate$.complete();
15
- });
16
- }
17
- _ensureMap(unitId) {
18
- let map = this._links.get(unitId);
19
- return map || (map = /* @__PURE__ */ new Map(), this._links.set(unitId, map)), map;
20
- }
21
- addLink(unitId, link) {
22
- const map = this._ensureMap(unitId);
23
- return link.payload = Tools.normalizeUrl(link.payload), map.set(link.id, link), this._linkUpdate$.next({
24
- type: "add",
25
- link,
26
- unitId
27
- }), !0;
28
- }
29
- updateLink(unitId, id, payload) {
30
- const link = this._ensureMap(unitId).get(id);
31
- if (!link)
32
- return !1;
33
- const oldPayload = link.payload;
34
- return link.payload = payload, this._linkUpdate$.next({
35
- type: "update",
36
- link,
37
- oldPayload,
38
- unitId
39
- }), !0;
40
- }
41
- deleteLink(unitId, id) {
42
- const map = this._ensureMap(unitId), link = map.get(id);
43
- return link ? (map.delete(id), this._linkUpdate$.next({
44
- type: "delete",
45
- link,
46
- unitId
47
- }), !1) : !0;
48
- }
49
- getLink(unitId, linkId) {
50
- return this._ensureMap(unitId).get(linkId);
51
- }
52
- getUnit(unitId) {
53
- const map = this._ensureMap(unitId);
54
- return Array.from(map.values());
55
- }
56
- deleteUnit(unitId) {
57
- this._links.delete(unitId), this._linkUpdate$.next({
58
- unitId,
59
- type: "delete-unit"
60
- });
61
- }
62
- };
63
- __name(_DocHyperLinkModel, "DocHyperLinkModel");
64
- let DocHyperLinkModel = _DocHyperLinkModel;
65
- var DocHyperLinkType = /* @__PURE__ */ ((DocHyperLinkType2) => (DocHyperLinkType2[DocHyperLinkType2.URL = 0] = "URL", DocHyperLinkType2))(DocHyperLinkType || {});
66
- const AddDocHyperLinkMutation = {
67
- type: CommandType.MUTATION,
68
- id: "docs.mutation.add-hyper-link",
69
- handler(accessor, params) {
70
- return params ? accessor.get(DocHyperLinkModel).addLink(params.unitId, params.link) : !1;
71
- }
72
- }, UpdateDocHyperLinkMutation = {
73
- type: CommandType.MUTATION,
74
- id: "docs.mutation.update-hyper-link",
75
- handler(accessor, params) {
76
- return params ? accessor.get(DocHyperLinkModel).updateLink(params.unitId, params.linkId, params.payload) : !1;
77
- }
78
- }, DeleteDocHyperLinkMutation = {
79
- type: CommandType.MUTATION,
80
- id: "docs.mutation.delete-hyper-link",
81
- handler(accessor, params) {
82
- return params ? accessor.get(DocHyperLinkModel).deleteLink(params.unitId, params.linkId) : !1;
83
- }
84
- };
85
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
86
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
87
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
88
- return kind && result && __defProp$2(target, key, result), result;
89
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
90
- let DocHyperLinkController = (_a = class extends Disposable {
91
- constructor(_commandService) {
92
- super(), this._commandService = _commandService, this._initCommands();
93
- }
94
- _initCommands() {
95
- [
96
- AddDocHyperLinkMutation,
97
- UpdateDocHyperLinkMutation,
98
- DeleteDocHyperLinkMutation
99
- ].forEach((command) => {
100
- this.disposeWithMe(this._commandService.registerCommand(command));
101
- });
102
- }
103
- }, __name(_a, "DocHyperLinkController"), _a);
104
- DocHyperLinkController = __decorateClass$2([
105
- OnLifecycle(LifecycleStages.Starting, DocHyperLinkController),
106
- __decorateParam$2(0, ICommandService)
107
- ], DocHyperLinkController);
5
+ import { OnLifecycle, LifecycleStages, Inject, IResourceManagerService, Disposable, UniverInstanceType, IUniverInstanceService, CustomRangeType, Plugin, Injector, IConfigService } from "@univerjs/core";
108
6
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
109
7
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
110
8
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
111
9
  return kind && result && __defProp$1(target, key, result), result;
112
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
113
- let DocHyperLinkResourceController = (_a2 = class extends Disposable {
114
- constructor(_resourceManagerService, _docHyperLinkModel, _univerInstanceService) {
115
- super(), this._resourceManagerService = _resourceManagerService, this._docHyperLinkModel = _docHyperLinkModel, this._univerInstanceService = _univerInstanceService, this._init();
10
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
11
+ const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
12
+ var _a;
13
+ let DocHyperLinkResourceController = (_a = class extends Disposable {
14
+ constructor(_resourceManagerService, _univerInstanceService) {
15
+ super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._init();
116
16
  }
117
17
  _init() {
118
18
  this._resourceManagerService.registerPluginResource({
119
19
  pluginName: DOC_HYPER_LINK_PLUGIN,
120
20
  businesses: [UniverInstanceType.UNIVER_DOC],
121
21
  onLoad: /* @__PURE__ */ __name((unitID, resource) => {
122
- resource.links.forEach((link) => {
123
- this._docHyperLinkModel.addLink(unitID, link);
22
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
23
+ if (!doc)
24
+ return;
25
+ const customRangeMap = /* @__PURE__ */ new Map(), handleDoc = /* @__PURE__ */ __name((model) => {
26
+ var _a3, _b;
27
+ return (_b = (_a3 = model.getBody()) == null ? void 0 : _a3.customRanges) == null || _b.forEach((customRange) => {
28
+ customRange.rangeType === CustomRangeType.HYPERLINK && customRangeMap.set(customRange.rangeId, customRange);
29
+ }), customRangeMap;
30
+ }, "handleDoc");
31
+ doc.headerModelMap.forEach((headerModel) => {
32
+ handleDoc(headerModel);
33
+ }), doc.footerModelMap.forEach((footerModel) => {
34
+ handleDoc(footerModel);
35
+ }), handleDoc(doc), resource.links.forEach((link) => {
36
+ const customRange = customRangeMap.get(link.id);
37
+ customRange && (customRange.properties = {
38
+ ...customRange.properties,
39
+ url: link.payload
40
+ });
124
41
  });
125
42
  }, "onLoad"),
126
43
  onUnLoad: /* @__PURE__ */ __name((unitID) => {
127
- this._docHyperLinkModel.deleteUnit(unitID);
128
44
  }, "onUnLoad"),
129
45
  toJson: /* @__PURE__ */ __name((unitID) => {
130
- var _a4;
131
- const links = this._docHyperLinkModel.getUnit(unitID), doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC), customRanges = (_a4 = doc == null ? void 0 : doc.getBody()) == null ? void 0 : _a4.customRanges, set = new Set(customRanges == null ? void 0 : customRanges.filter((i) => i.rangeType === CustomRangeType.HYPERLINK).map((i) => i.rangeId));
132
- return JSON.stringify({
133
- links: links.filter((link) => set.has(link.id))
134
- });
46
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC), links = [];
47
+ if (doc) {
48
+ const handleDoc = /* @__PURE__ */ __name((model) => {
49
+ var _a3, _b;
50
+ (_b = (_a3 = model.getBody()) == null ? void 0 : _a3.customRanges) == null || _b.forEach((customRange) => {
51
+ var _a4;
52
+ customRange.rangeType === CustomRangeType.HYPERLINK && links.push({
53
+ id: customRange.rangeId,
54
+ payload: ((_a4 = customRange.properties) == null ? void 0 : _a4.url) || ""
55
+ });
56
+ });
57
+ }, "handleDoc");
58
+ doc.headerModelMap.forEach((headerModel) => {
59
+ handleDoc(headerModel);
60
+ }), doc.footerModelMap.forEach((footerModel) => {
61
+ handleDoc(footerModel);
62
+ }), handleDoc(doc);
63
+ }
64
+ return JSON.stringify({ links });
135
65
  }, "toJson"),
136
66
  parseJson(bytes) {
137
67
  return JSON.parse(bytes);
138
68
  }
139
69
  });
140
70
  }
141
- }, __name(_a2, "DocHyperLinkResourceController"), _a2);
71
+ }, __name(_a, "DocHyperLinkResourceController"), _a);
142
72
  DocHyperLinkResourceController = __decorateClass$1([
143
73
  OnLifecycle(LifecycleStages.Starting, DocHyperLinkResourceController),
144
74
  __decorateParam$1(0, Inject(IResourceManagerService)),
145
- __decorateParam$1(1, Inject(DocHyperLinkModel)),
146
- __decorateParam$1(2, IUniverInstanceService)
75
+ __decorateParam$1(1, IUniverInstanceService)
147
76
  ], DocHyperLinkResourceController);
77
+ const PLUGIN_CONFIG_KEY = "docs-hyper-link.config", defaultPluginConfig = {};
148
78
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
149
79
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
150
80
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
151
81
  return kind && result && __defProp2(target, key, result), result;
152
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
153
- let UniverDocsHyperLinkPlugin = (_a3 = class extends Plugin {
154
- constructor(_config, _injector) {
155
- super(), this._config = _config, this._injector = _injector;
82
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a2;
83
+ let UniverDocsHyperLinkPlugin = (_a2 = class extends Plugin {
84
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
85
+ super(), this._config = _config, this._injector = _injector, this._configService = _configService;
86
+ const { ...rest } = this._config;
87
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
156
88
  }
157
89
  onStarting() {
158
90
  [
159
- [DocHyperLinkModel],
160
- [DocHyperLinkController],
161
91
  [DocHyperLinkResourceController]
162
92
  ].forEach((dep) => {
163
93
  this._injector.add(dep);
164
94
  });
165
95
  }
166
- }, __name(_a3, "UniverDocsHyperLinkPlugin"), __publicField(_a3, "pluginName", DOC_HYPER_LINK_PLUGIN), __publicField(_a3, "type", UniverInstanceType.UNIVER_DOC), _a3);
96
+ }, __name(_a2, "UniverDocsHyperLinkPlugin"), __publicField(_a2, "pluginName", DOC_HYPER_LINK_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_DOC), _a2);
167
97
  UniverDocsHyperLinkPlugin = __decorateClass([
168
- __decorateParam(1, Inject(Injector))
98
+ __decorateParam(1, Inject(Injector)),
99
+ __decorateParam(2, IConfigService)
169
100
  ], UniverDocsHyperLinkPlugin);
170
101
  export {
171
- AddDocHyperLinkMutation,
172
- DOC_HYPER_LINK_PLUGIN,
173
- DeleteDocHyperLinkMutation,
174
- DocHyperLinkModel,
175
- DocHyperLinkType,
176
- UniverDocsHyperLinkPlugin,
177
- UpdateDocHyperLinkMutation
102
+ UniverDocsHyperLinkPlugin
178
103
  };
@@ -13,6 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare enum DocHyperLinkType {
17
- URL = 0
16
+ export declare const PLUGIN_CONFIG_KEY = "docs-hyper-link.config";
17
+ export declare const configSymbol: unique symbol;
18
+ export interface IUniverDocsHyperLinkConfig {
18
19
  }
20
+ export declare const defaultPluginConfig: IUniverDocsHyperLinkConfig;
@@ -1,9 +1,8 @@
1
1
  import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
2
- import { DocHyperLinkModel } from '../models/hyper-link.model';
2
+ export declare const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
3
3
  export declare class DocHyperLinkResourceController extends Disposable {
4
4
  private readonly _resourceManagerService;
5
- private readonly _docHyperLinkModel;
6
5
  private readonly _univerInstanceService;
7
- constructor(_resourceManagerService: IResourceManagerService, _docHyperLinkModel: DocHyperLinkModel, _univerInstanceService: IUniverInstanceService);
6
+ constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
8
7
  private _init;
9
8
  }
@@ -13,11 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { DOC_HYPER_LINK_PLUGIN } from './types/const';
17
- export { DocHyperLinkModel } from './models/hyper-link.model';
18
- export type { IDocHyperLink } from './types/interfaces/i-doc-hyper-link';
19
- export { DocHyperLinkType } from './types/enums/doc-hyper-link-type';
20
16
  export { UniverDocsHyperLinkPlugin } from './plugin';
21
- export { AddDocHyperLinkMutation, type IAddDocHyperLinkMutationParams } from './commands/mutations/add-link.mutation';
22
- export { UpdateDocHyperLinkMutation, type IUpdateDocHyperLinkMutationParams } from './commands/mutations/update-link.mutation';
23
- export { DeleteDocHyperLinkMutation, type IDeleteDocHyperLinkMutationParams } from './commands/mutations/delete-link.mutation';
@@ -1,9 +1,11 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { IUniverDocsHyperLinkConfig } from './controllers/config.schema';
2
3
  export declare class UniverDocsHyperLinkPlugin extends Plugin {
3
- private _config;
4
+ private readonly _config;
4
5
  protected _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<IUniverDocsHyperLinkConfig>, _injector: Injector, _configService: IConfigService);
8
10
  onStarting(): void;
9
11
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsHyperLink={},global.UniverCore,global.rxjs))})(this,function(exports2,core,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const DOC_HYPER_LINK_PLUGIN="DOC_HYPER_LINK_PLUGIN",_DocHyperLinkModel=class _DocHyperLinkModel extends core.Disposable{constructor(){super();__publicField(this,"_links",new Map);__publicField(this,"_linkUpdate$",new rxjs.Subject);__publicField(this,"linkUpdate$",this._linkUpdate$.asObservable());this.disposeWithMe(()=>{this._linkUpdate$.complete()})}_ensureMap(unitId){let map=this._links.get(unitId);return map||(map=new Map,this._links.set(unitId,map)),map}addLink(unitId,link){const map=this._ensureMap(unitId);return link.payload=core.Tools.normalizeUrl(link.payload),map.set(link.id,link),this._linkUpdate$.next({type:"add",link,unitId}),!0}updateLink(unitId,id,payload){const link=this._ensureMap(unitId).get(id);if(!link)return!1;const oldPayload=link.payload;return link.payload=payload,this._linkUpdate$.next({type:"update",link,oldPayload,unitId}),!0}deleteLink(unitId,id){const map=this._ensureMap(unitId),link=map.get(id);return link?(map.delete(id),this._linkUpdate$.next({type:"delete",link,unitId}),!1):!0}getLink(unitId,linkId){return this._ensureMap(unitId).get(linkId)}getUnit(unitId){const map=this._ensureMap(unitId);return Array.from(map.values())}deleteUnit(unitId){this._links.delete(unitId),this._linkUpdate$.next({unitId,type:"delete-unit"})}};__name(_DocHyperLinkModel,"DocHyperLinkModel");let DocHyperLinkModel=_DocHyperLinkModel;var DocHyperLinkType=(DocHyperLinkType2=>(DocHyperLinkType2[DocHyperLinkType2.URL=0]="URL",DocHyperLinkType2))(DocHyperLinkType||{});const AddDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.add-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).addLink(params.unitId,params.link):!1}},UpdateDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.update-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).updateLink(params.unitId,params.linkId,params.payload):!1}},DeleteDocHyperLinkMutation={type:core.CommandType.MUTATION,id:"docs.mutation.delete-hyper-link",handler(accessor,params){return params?accessor.get(DocHyperLinkModel).deleteLink(params.unitId,params.linkId):!1}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(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$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let DocHyperLinkController=(_a=class extends core.Disposable{constructor(_commandService){super(),this._commandService=_commandService,this._initCommands()}_initCommands(){[AddDocHyperLinkMutation,UpdateDocHyperLinkMutation,DeleteDocHyperLinkMutation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}},__name(_a,"DocHyperLinkController"),_a);DocHyperLinkController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkController),__decorateParam$2(0,core.ICommandService)],DocHyperLinkController);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");let DocHyperLinkResourceController=(_b=class extends core.Disposable{constructor(_resourceManagerService,_docHyperLinkModel,_univerInstanceService){super(),this._resourceManagerService=_resourceManagerService,this._docHyperLinkModel=_docHyperLinkModel,this._univerInstanceService=_univerInstanceService,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:DOC_HYPER_LINK_PLUGIN,businesses:[core.UniverInstanceType.UNIVER_DOC],onLoad:__name((unitID,resource)=>{resource.links.forEach(link=>{this._docHyperLinkModel.addLink(unitID,link)})},"onLoad"),onUnLoad:__name(unitID=>{this._docHyperLinkModel.deleteUnit(unitID)},"onUnLoad"),toJson:__name(unitID=>{var _a2;const links=this._docHyperLinkModel.getUnit(unitID),doc=this._univerInstanceService.getUnit(unitID,core.UniverInstanceType.UNIVER_DOC),customRanges=(_a2=doc==null?void 0:doc.getBody())==null?void 0:_a2.customRanges,set=new Set(customRanges==null?void 0:customRanges.filter(i=>i.rangeType===core.CustomRangeType.HYPERLINK).map(i=>i.rangeId));return JSON.stringify({links:links.filter(link=>set.has(link.id))})},"toJson"),parseJson(bytes){return JSON.parse(bytes)}})}},__name(_b,"DocHyperLinkResourceController"),_b);DocHyperLinkResourceController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkResourceController),__decorateParam$1(0,core.Inject(core.IResourceManagerService)),__decorateParam$1(1,core.Inject(DocHyperLinkModel)),__decorateParam$1(2,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=(_c=class extends core.Plugin{constructor(_config,_injector){super(),this._config=_config,this._injector=_injector}onStarting(){[[DocHyperLinkModel],[DocHyperLinkController],[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)})}},__name(_c,"UniverDocsHyperLinkPlugin"),__publicField(_c,"pluginName",DOC_HYPER_LINK_PLUGIN),__publicField(_c,"type",core.UniverInstanceType.UNIVER_DOC),_c),exports2.UniverDocsHyperLinkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector))],exports2.UniverDocsHyperLinkPlugin),exports2.AddDocHyperLinkMutation=AddDocHyperLinkMutation,exports2.DOC_HYPER_LINK_PLUGIN=DOC_HYPER_LINK_PLUGIN,exports2.DeleteDocHyperLinkMutation=DeleteDocHyperLinkMutation,exports2.DocHyperLinkModel=DocHyperLinkModel,exports2.DocHyperLinkType=DocHyperLinkType,exports2.UpdateDocHyperLinkMutation=UpdateDocHyperLinkMutation,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;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);const PLUGIN_CONFIG_KEY="docs-hyper-link.config",defaultPluginConfig={};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){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkResourceController]].forEach(dep=>{this._injector.add(dep)})}},__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)],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.2.10",
3
+ "version": "0.2.12",
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
- "rxjs": ">=7.0.0",
48
- "@univerjs/core": "0.2.10"
47
+ "@univerjs/core": "0.2.12"
48
+ },
49
+ "dependencies": {
50
+ "@univerjs/icons": "^0.1.74"
49
51
  },
50
52
  "devDependencies": {
51
53
  "rxjs": "^7.8.1",
52
54
  "typescript": "^5.5.4",
53
55
  "vite": "^5.4.2",
54
56
  "vitest": "^2.0.5",
55
- "@univerjs/core": "0.2.10",
56
- "@univerjs/design": "0.2.10",
57
- "@univerjs/docs": "0.2.10",
58
- "@univerjs/shared": "0.2.10"
57
+ "@univerjs/core": "0.2.12",
58
+ "@univerjs/docs": "0.2.12"
59
59
  },
60
60
  "univerSpace": {
61
61
  ".": {
@@ -1,7 +0,0 @@
1
- import { IMutation } from '@univerjs/core';
2
- import { IDocHyperLink } from '../../types/interfaces/i-doc-hyper-link';
3
- export interface IAddDocHyperLinkMutationParams {
4
- unitId: string;
5
- link: IDocHyperLink;
6
- }
7
- export declare const AddDocHyperLinkMutation: IMutation<IAddDocHyperLinkMutationParams>;
@@ -1,6 +0,0 @@
1
- import { ICommand } from '@univerjs/core';
2
- export interface IDeleteDocHyperLinkMutationParams {
3
- unitId: string;
4
- linkId: string;
5
- }
6
- export declare const DeleteDocHyperLinkMutation: ICommand<IDeleteDocHyperLinkMutationParams>;
@@ -1,7 +0,0 @@
1
- import { ICommand } from '@univerjs/core';
2
- export interface IUpdateDocHyperLinkMutationParams {
3
- unitId: string;
4
- linkId: string;
5
- payload: string;
6
- }
7
- export declare const UpdateDocHyperLinkMutation: ICommand<IUpdateDocHyperLinkMutationParams>;
@@ -1,6 +0,0 @@
1
- import { Disposable, ICommandService } from '@univerjs/core';
2
- export declare class DocHyperLinkController extends Disposable {
3
- private readonly _commandService;
4
- constructor(_commandService: ICommandService);
5
- private _initCommands;
6
- }
@@ -1,32 +0,0 @@
1
- import { Disposable } from '@univerjs/core';
2
- import { IDocHyperLink } from '../types/interfaces/i-doc-hyper-link';
3
- export type DocLinkUpdate = {
4
- type: 'add';
5
- link: IDocHyperLink;
6
- unitId: string;
7
- } | {
8
- type: 'update';
9
- oldPayload: string;
10
- link: IDocHyperLink;
11
- unitId: string;
12
- } | {
13
- type: 'delete';
14
- link: IDocHyperLink;
15
- unitId: string;
16
- } | {
17
- type: 'delete-unit';
18
- unitId: string;
19
- };
20
- export declare class DocHyperLinkModel extends Disposable {
21
- private readonly _links;
22
- private readonly _linkUpdate$;
23
- readonly linkUpdate$: import('rxjs').Observable<DocLinkUpdate>;
24
- constructor();
25
- private _ensureMap;
26
- addLink(unitId: string, link: IDocHyperLink): boolean;
27
- updateLink(unitId: string, id: string, payload: string): boolean;
28
- deleteLink(unitId: string, id: string): boolean;
29
- getLink(unitId: string, linkId: string): IDocHyperLink | undefined;
30
- getUnit(unitId: string): IDocHyperLink[];
31
- deleteUnit(unitId: string): void;
32
- }
@@ -1,16 +0,0 @@
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 DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
@@ -1,19 +0,0 @@
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 interface IDocHyperLink {
17
- payload: string;
18
- id: string;
19
- }