@univerjs/docs-hyper-link 0.20.1 → 0.21.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,227 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`);var t=`@univerjs/docs-hyper-link`,n=`0.20.1`;const r={id:`docs.mutation.add-hyper-link`,type:e.CommandType.MUTATION,handler:()=>!0},i={id:`docs.mutation.update-hyper-link`,type:e.CommandType.MUTATION,handler:()=>!0},a={id:`docs.mutation.delete-hyper-link`,type:e.CommandType.MUTATION,handler:()=>!0},o=`docs-hyper-link.config`;Symbol(o);const s={};function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const u=`DOC_HYPER_LINK_PLUGIN`;let d=class extends e.Disposable{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[e.UniverInstanceType.UNIVER_DOC],onLoad:(t,n)=>{let r=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(!r)return;let i=new Map,a=t=>{var n;return(n=t.getBody())==null||(n=n.customRanges)==null||n.forEach(t=>{t.rangeType===e.CustomRangeType.HYPERLINK&&i.set(t.rangeId,t)}),i};r.headerModelMap.forEach(e=>{a(e)}),r.footerModelMap.forEach(e=>{a(e)}),a(r),n.links.forEach(e=>{let t=i.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:t=>{let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC),r=[];if(n){let t=t=>{var n;(n=t.getBody())==null||(n=n.customRanges)==null||n.forEach(t=>{if(t.rangeType===e.CustomRangeType.HYPERLINK){var n;r.push({id:t.rangeId,payload:((n=t.properties)==null?void 0:n.url)||``})}})};n.headerModelMap.forEach(e=>{t(e)}),n.footerModelMap.forEach(e=>{t(e)}),t(n)}return JSON.stringify({links:r})},parseJson(e){return JSON.parse(e)}})}};d=l([c(0,(0,e.Inject)(e.IResourceManagerService)),c(1,e.IUniverInstanceService)],d);function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let g=class extends e.Plugin{constructor(t=s,n,r,i){super(),this._config=t,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,e.merge)({},s,this._config);this._configService.setConfig(o,a)}onStarting(){[[d]].forEach(e=>this._injector.add(e)),[r,a,i].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(d)}};h(g,`pluginName`,u),h(g,`packageName`,t),h(g,`version`,n),h(g,`type`,e.UniverInstanceType.UNIVER_DOC),g=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.IConfigService),c(3,e.ICommandService)],g),Object.defineProperty(exports,`UniverDocsHyperLinkPlugin`,{enumerable:!0,get:function(){return g}});
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _univerjs_core = require("@univerjs/core");
3
+
4
+ //#region package.json
5
+ var name = "@univerjs/docs-hyper-link";
6
+ var version = "0.21.0";
7
+
8
+ //#endregion
9
+ //#region src/commands/mutations/hyper-link.mutation.ts
10
+ const AddHyperLinkMuatation = {
11
+ id: "docs.mutation.add-hyper-link",
12
+ type: _univerjs_core.CommandType.MUTATION,
13
+ handler: () => {
14
+ return true;
15
+ }
16
+ };
17
+ const UpdateHyperLinkMuatation = {
18
+ id: "docs.mutation.update-hyper-link",
19
+ type: _univerjs_core.CommandType.MUTATION,
20
+ handler: () => {
21
+ return true;
22
+ }
23
+ };
24
+ const DeleteHyperLinkMuatation = {
25
+ id: "docs.mutation.delete-hyper-link",
26
+ type: _univerjs_core.CommandType.MUTATION,
27
+ handler: () => {
28
+ return true;
29
+ }
30
+ };
31
+
32
+ //#endregion
33
+ //#region src/config/config.ts
34
+ /**
35
+ * Copyright 2023-present DreamNum Co., Ltd.
36
+ *
37
+ * Licensed under the Apache License, Version 2.0 (the "License");
38
+ * you may not use this file except in compliance with the License.
39
+ * You may obtain a copy of the License at
40
+ *
41
+ * http://www.apache.org/licenses/LICENSE-2.0
42
+ *
43
+ * Unless required by applicable law or agreed to in writing, software
44
+ * distributed under the License is distributed on an "AS IS" BASIS,
45
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46
+ * See the License for the specific language governing permissions and
47
+ * limitations under the License.
48
+ */
49
+ const DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY = "docs-hyper-link.config";
50
+ const configSymbol = Symbol(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY);
51
+ const defaultPluginConfig = {};
52
+
53
+ //#endregion
54
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
55
+ function __decorateParam(paramIndex, decorator) {
56
+ return function(target, key) {
57
+ decorator(target, key, paramIndex);
58
+ };
59
+ }
60
+
61
+ //#endregion
62
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
63
+ function __decorate(decorators, target, key, desc) {
64
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
65
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
66
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
68
+ }
69
+
70
+ //#endregion
71
+ //#region src/controllers/resource.controller.ts
72
+ const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
73
+ let DocHyperLinkResourceController = class DocHyperLinkResourceController extends _univerjs_core.Disposable {
74
+ constructor(_resourceManagerService, _univerInstanceService) {
75
+ super();
76
+ this._resourceManagerService = _resourceManagerService;
77
+ this._univerInstanceService = _univerInstanceService;
78
+ this._init();
79
+ }
80
+ _init() {
81
+ this._resourceManagerService.registerPluginResource({
82
+ pluginName: DOC_HYPER_LINK_PLUGIN,
83
+ businesses: [_univerjs_core.UniverInstanceType.UNIVER_DOC],
84
+ onLoad: (unitID, resource) => {
85
+ const doc = this._univerInstanceService.getUnit(unitID, _univerjs_core.UniverInstanceType.UNIVER_DOC);
86
+ if (!doc) return;
87
+ const customRangeMap = /* @__PURE__ */ new Map();
88
+ const handleDoc = (model) => {
89
+ var _model$getBody;
90
+ (_model$getBody = model.getBody()) === null || _model$getBody === void 0 || (_model$getBody = _model$getBody.customRanges) === null || _model$getBody === void 0 || _model$getBody.forEach((customRange) => {
91
+ if (customRange.rangeType === _univerjs_core.CustomRangeType.HYPERLINK) customRangeMap.set(customRange.rangeId, customRange);
92
+ });
93
+ return customRangeMap;
94
+ };
95
+ doc.headerModelMap.forEach((headerModel) => {
96
+ handleDoc(headerModel);
97
+ });
98
+ doc.footerModelMap.forEach((footerModel) => {
99
+ handleDoc(footerModel);
100
+ });
101
+ handleDoc(doc);
102
+ resource.links.forEach((link) => {
103
+ const customRange = customRangeMap.get(link.id);
104
+ if (customRange) customRange.properties = {
105
+ ...customRange.properties,
106
+ url: link.payload
107
+ };
108
+ });
109
+ },
110
+ onUnLoad: (unitID) => {},
111
+ toJson: (unitID) => {
112
+ const doc = this._univerInstanceService.getUnit(unitID, _univerjs_core.UniverInstanceType.UNIVER_DOC);
113
+ const links = [];
114
+ if (doc) {
115
+ const handleDoc = (model) => {
116
+ var _model$getBody2;
117
+ (_model$getBody2 = model.getBody()) === null || _model$getBody2 === void 0 || (_model$getBody2 = _model$getBody2.customRanges) === null || _model$getBody2 === void 0 || _model$getBody2.forEach((customRange) => {
118
+ if (customRange.rangeType === _univerjs_core.CustomRangeType.HYPERLINK) {
119
+ var _customRange$properti;
120
+ links.push({
121
+ id: customRange.rangeId,
122
+ payload: ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) || ""
123
+ });
124
+ }
125
+ });
126
+ };
127
+ doc.headerModelMap.forEach((headerModel) => {
128
+ handleDoc(headerModel);
129
+ });
130
+ doc.footerModelMap.forEach((footerModel) => {
131
+ handleDoc(footerModel);
132
+ });
133
+ handleDoc(doc);
134
+ }
135
+ return JSON.stringify({ links });
136
+ },
137
+ parseJson(bytes) {
138
+ return JSON.parse(bytes);
139
+ }
140
+ });
141
+ }
142
+ };
143
+ DocHyperLinkResourceController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.IResourceManagerService)), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DocHyperLinkResourceController);
144
+
145
+ //#endregion
146
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
147
+ function _typeof(o) {
148
+ "@babel/helpers - typeof";
149
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
150
+ return typeof o;
151
+ } : function(o) {
152
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
153
+ }, _typeof(o);
154
+ }
155
+
156
+ //#endregion
157
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
158
+ function toPrimitive(t, r) {
159
+ if ("object" != _typeof(t) || !t) return t;
160
+ var e = t[Symbol.toPrimitive];
161
+ if (void 0 !== e) {
162
+ var i = e.call(t, r || "default");
163
+ if ("object" != _typeof(i)) return i;
164
+ throw new TypeError("@@toPrimitive must return a primitive value.");
165
+ }
166
+ return ("string" === r ? String : Number)(t);
167
+ }
168
+
169
+ //#endregion
170
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
171
+ function toPropertyKey(t) {
172
+ var i = toPrimitive(t, "string");
173
+ return "symbol" == _typeof(i) ? i : i + "";
174
+ }
175
+
176
+ //#endregion
177
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
178
+ function _defineProperty(e, r, t) {
179
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
180
+ value: t,
181
+ enumerable: !0,
182
+ configurable: !0,
183
+ writable: !0
184
+ }) : e[r] = t, e;
185
+ }
186
+
187
+ //#endregion
188
+ //#region src/plugin.ts
189
+ let UniverDocsHyperLinkPlugin = class UniverDocsHyperLinkPlugin extends _univerjs_core.Plugin {
190
+ constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
191
+ super();
192
+ this._config = _config;
193
+ this._injector = _injector;
194
+ this._configService = _configService;
195
+ this._commandService = _commandService;
196
+ const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
197
+ this._configService.setConfig(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY, rest);
198
+ }
199
+ onStarting() {
200
+ [[DocHyperLinkResourceController]].forEach((dep) => this._injector.add(dep));
201
+ [
202
+ AddHyperLinkMuatation,
203
+ DeleteHyperLinkMuatation,
204
+ UpdateHyperLinkMuatation
205
+ ].forEach((mutation) => {
206
+ this.disposeWithMe(this._commandService.registerCommand(mutation));
207
+ });
208
+ this._injector.get(DocHyperLinkResourceController);
209
+ }
210
+ };
211
+ _defineProperty(UniverDocsHyperLinkPlugin, "pluginName", DOC_HYPER_LINK_PLUGIN);
212
+ _defineProperty(UniverDocsHyperLinkPlugin, "packageName", name);
213
+ _defineProperty(UniverDocsHyperLinkPlugin, "version", version);
214
+ _defineProperty(UniverDocsHyperLinkPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
215
+ UniverDocsHyperLinkPlugin = __decorate([
216
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
217
+ __decorateParam(2, _univerjs_core.IConfigService),
218
+ __decorateParam(3, _univerjs_core.ICommandService)
219
+ ], UniverDocsHyperLinkPlugin);
220
+
221
+ //#endregion
222
+ Object.defineProperty(exports, 'UniverDocsHyperLinkPlugin', {
223
+ enumerable: true,
224
+ get: function () {
225
+ return UniverDocsHyperLinkPlugin;
226
+ }
227
+ });
package/lib/es/index.js CHANGED
@@ -1 +1,221 @@
1
- import{CommandType as e,CustomRangeType as t,Disposable as n,ICommandService as r,IConfigService as i,IResourceManagerService as a,IUniverInstanceService as o,Inject as s,Injector as c,Plugin as l,UniverInstanceType as u,merge as d}from"@univerjs/core";var f=`@univerjs/docs-hyper-link`,p=`0.20.1`;const m={id:`docs.mutation.add-hyper-link`,type:e.MUTATION,handler:()=>!0},h={id:`docs.mutation.update-hyper-link`,type:e.MUTATION,handler:()=>!0},g={id:`docs.mutation.delete-hyper-link`,type:e.MUTATION,handler:()=>!0},_=`docs-hyper-link.config`;Symbol(_);const v={};function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const x=`DOC_HYPER_LINK_PLUGIN`;let S=class extends n{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:x,businesses:[u.UNIVER_DOC],onLoad:(e,n)=>{let r=this._univerInstanceService.getUnit(e,u.UNIVER_DOC);if(!r)return;let i=new Map,a=e=>{var n;return(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{e.rangeType===t.HYPERLINK&&i.set(e.rangeId,e)}),i};r.headerModelMap.forEach(e=>{a(e)}),r.footerModelMap.forEach(e=>{a(e)}),a(r),n.links.forEach(e=>{let t=i.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let n=this._univerInstanceService.getUnit(e,u.UNIVER_DOC),r=[];if(n){let e=e=>{var n;(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{if(e.rangeType===t.HYPERLINK){var n;r.push({id:e.rangeId,payload:((n=e.properties)==null?void 0:n.url)||``})}})};n.headerModelMap.forEach(t=>{e(t)}),n.footerModelMap.forEach(t=>{e(t)}),e(n)}return JSON.stringify({links:r})},parseJson(e){return JSON.parse(e)}})}};S=b([y(0,s(a)),y(1,o)],S);function C(e){"@babel/helpers - typeof";return C=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends l{constructor(e=v,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._commandService=r;let{...i}=d({},v,this._config);this._configService.setConfig(_,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e)),[m,g,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(S)}};E(D,`pluginName`,x),E(D,`packageName`,f),E(D,`version`,p),E(D,`type`,u.UNIVER_DOC),D=b([y(1,s(c)),y(2,i),y(3,r)],D);export{D as UniverDocsHyperLinkPlugin};
1
+ import { CommandType, CustomRangeType, Disposable, ICommandService, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, UniverInstanceType, merge } from "@univerjs/core";
2
+
3
+ //#region package.json
4
+ var name = "@univerjs/docs-hyper-link";
5
+ var version = "0.21.0";
6
+
7
+ //#endregion
8
+ //#region src/commands/mutations/hyper-link.mutation.ts
9
+ const AddHyperLinkMuatation = {
10
+ id: "docs.mutation.add-hyper-link",
11
+ type: CommandType.MUTATION,
12
+ handler: () => {
13
+ return true;
14
+ }
15
+ };
16
+ const UpdateHyperLinkMuatation = {
17
+ id: "docs.mutation.update-hyper-link",
18
+ type: CommandType.MUTATION,
19
+ handler: () => {
20
+ return true;
21
+ }
22
+ };
23
+ const DeleteHyperLinkMuatation = {
24
+ id: "docs.mutation.delete-hyper-link",
25
+ type: CommandType.MUTATION,
26
+ handler: () => {
27
+ return true;
28
+ }
29
+ };
30
+
31
+ //#endregion
32
+ //#region src/config/config.ts
33
+ /**
34
+ * Copyright 2023-present DreamNum Co., Ltd.
35
+ *
36
+ * Licensed under the Apache License, Version 2.0 (the "License");
37
+ * you may not use this file except in compliance with the License.
38
+ * You may obtain a copy of the License at
39
+ *
40
+ * http://www.apache.org/licenses/LICENSE-2.0
41
+ *
42
+ * Unless required by applicable law or agreed to in writing, software
43
+ * distributed under the License is distributed on an "AS IS" BASIS,
44
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45
+ * See the License for the specific language governing permissions and
46
+ * limitations under the License.
47
+ */
48
+ const DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY = "docs-hyper-link.config";
49
+ const configSymbol = Symbol(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY);
50
+ const defaultPluginConfig = {};
51
+
52
+ //#endregion
53
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
54
+ function __decorateParam(paramIndex, decorator) {
55
+ return function(target, key) {
56
+ decorator(target, key, paramIndex);
57
+ };
58
+ }
59
+
60
+ //#endregion
61
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
62
+ function __decorate(decorators, target, key, desc) {
63
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
64
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
65
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
66
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
67
+ }
68
+
69
+ //#endregion
70
+ //#region src/controllers/resource.controller.ts
71
+ const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
72
+ let DocHyperLinkResourceController = class DocHyperLinkResourceController extends Disposable {
73
+ constructor(_resourceManagerService, _univerInstanceService) {
74
+ super();
75
+ this._resourceManagerService = _resourceManagerService;
76
+ this._univerInstanceService = _univerInstanceService;
77
+ this._init();
78
+ }
79
+ _init() {
80
+ this._resourceManagerService.registerPluginResource({
81
+ pluginName: DOC_HYPER_LINK_PLUGIN,
82
+ businesses: [UniverInstanceType.UNIVER_DOC],
83
+ onLoad: (unitID, resource) => {
84
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
85
+ if (!doc) return;
86
+ const customRangeMap = /* @__PURE__ */ new Map();
87
+ const handleDoc = (model) => {
88
+ var _model$getBody;
89
+ (_model$getBody = model.getBody()) === null || _model$getBody === void 0 || (_model$getBody = _model$getBody.customRanges) === null || _model$getBody === void 0 || _model$getBody.forEach((customRange) => {
90
+ if (customRange.rangeType === CustomRangeType.HYPERLINK) customRangeMap.set(customRange.rangeId, customRange);
91
+ });
92
+ return customRangeMap;
93
+ };
94
+ doc.headerModelMap.forEach((headerModel) => {
95
+ handleDoc(headerModel);
96
+ });
97
+ doc.footerModelMap.forEach((footerModel) => {
98
+ handleDoc(footerModel);
99
+ });
100
+ handleDoc(doc);
101
+ resource.links.forEach((link) => {
102
+ const customRange = customRangeMap.get(link.id);
103
+ if (customRange) customRange.properties = {
104
+ ...customRange.properties,
105
+ url: link.payload
106
+ };
107
+ });
108
+ },
109
+ onUnLoad: (unitID) => {},
110
+ toJson: (unitID) => {
111
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
112
+ const links = [];
113
+ if (doc) {
114
+ const handleDoc = (model) => {
115
+ var _model$getBody2;
116
+ (_model$getBody2 = model.getBody()) === null || _model$getBody2 === void 0 || (_model$getBody2 = _model$getBody2.customRanges) === null || _model$getBody2 === void 0 || _model$getBody2.forEach((customRange) => {
117
+ if (customRange.rangeType === CustomRangeType.HYPERLINK) {
118
+ var _customRange$properti;
119
+ links.push({
120
+ id: customRange.rangeId,
121
+ payload: ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) || ""
122
+ });
123
+ }
124
+ });
125
+ };
126
+ doc.headerModelMap.forEach((headerModel) => {
127
+ handleDoc(headerModel);
128
+ });
129
+ doc.footerModelMap.forEach((footerModel) => {
130
+ handleDoc(footerModel);
131
+ });
132
+ handleDoc(doc);
133
+ }
134
+ return JSON.stringify({ links });
135
+ },
136
+ parseJson(bytes) {
137
+ return JSON.parse(bytes);
138
+ }
139
+ });
140
+ }
141
+ };
142
+ DocHyperLinkResourceController = __decorate([__decorateParam(0, Inject(IResourceManagerService)), __decorateParam(1, IUniverInstanceService)], DocHyperLinkResourceController);
143
+
144
+ //#endregion
145
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
146
+ function _typeof(o) {
147
+ "@babel/helpers - typeof";
148
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
149
+ return typeof o;
150
+ } : function(o) {
151
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
152
+ }, _typeof(o);
153
+ }
154
+
155
+ //#endregion
156
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
157
+ function toPrimitive(t, r) {
158
+ if ("object" != _typeof(t) || !t) return t;
159
+ var e = t[Symbol.toPrimitive];
160
+ if (void 0 !== e) {
161
+ var i = e.call(t, r || "default");
162
+ if ("object" != _typeof(i)) return i;
163
+ throw new TypeError("@@toPrimitive must return a primitive value.");
164
+ }
165
+ return ("string" === r ? String : Number)(t);
166
+ }
167
+
168
+ //#endregion
169
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
170
+ function toPropertyKey(t) {
171
+ var i = toPrimitive(t, "string");
172
+ return "symbol" == _typeof(i) ? i : i + "";
173
+ }
174
+
175
+ //#endregion
176
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
177
+ function _defineProperty(e, r, t) {
178
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
179
+ value: t,
180
+ enumerable: !0,
181
+ configurable: !0,
182
+ writable: !0
183
+ }) : e[r] = t, e;
184
+ }
185
+
186
+ //#endregion
187
+ //#region src/plugin.ts
188
+ let UniverDocsHyperLinkPlugin = class UniverDocsHyperLinkPlugin extends Plugin {
189
+ constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
190
+ super();
191
+ this._config = _config;
192
+ this._injector = _injector;
193
+ this._configService = _configService;
194
+ this._commandService = _commandService;
195
+ const { ...rest } = merge({}, defaultPluginConfig, this._config);
196
+ this._configService.setConfig(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY, rest);
197
+ }
198
+ onStarting() {
199
+ [[DocHyperLinkResourceController]].forEach((dep) => this._injector.add(dep));
200
+ [
201
+ AddHyperLinkMuatation,
202
+ DeleteHyperLinkMuatation,
203
+ UpdateHyperLinkMuatation
204
+ ].forEach((mutation) => {
205
+ this.disposeWithMe(this._commandService.registerCommand(mutation));
206
+ });
207
+ this._injector.get(DocHyperLinkResourceController);
208
+ }
209
+ };
210
+ _defineProperty(UniverDocsHyperLinkPlugin, "pluginName", DOC_HYPER_LINK_PLUGIN);
211
+ _defineProperty(UniverDocsHyperLinkPlugin, "packageName", name);
212
+ _defineProperty(UniverDocsHyperLinkPlugin, "version", version);
213
+ _defineProperty(UniverDocsHyperLinkPlugin, "type", UniverInstanceType.UNIVER_DOC);
214
+ UniverDocsHyperLinkPlugin = __decorate([
215
+ __decorateParam(1, Inject(Injector)),
216
+ __decorateParam(2, IConfigService),
217
+ __decorateParam(3, ICommandService)
218
+ ], UniverDocsHyperLinkPlugin);
219
+
220
+ //#endregion
221
+ export { UniverDocsHyperLinkPlugin };
package/lib/index.js CHANGED
@@ -1 +1,221 @@
1
- import{CommandType as e,CustomRangeType as t,Disposable as n,ICommandService as r,IConfigService as i,IResourceManagerService as a,IUniverInstanceService as o,Inject as s,Injector as c,Plugin as l,UniverInstanceType as u,merge as d}from"@univerjs/core";var f=`@univerjs/docs-hyper-link`,p=`0.20.1`;const m={id:`docs.mutation.add-hyper-link`,type:e.MUTATION,handler:()=>!0},h={id:`docs.mutation.update-hyper-link`,type:e.MUTATION,handler:()=>!0},g={id:`docs.mutation.delete-hyper-link`,type:e.MUTATION,handler:()=>!0},_=`docs-hyper-link.config`;Symbol(_);const v={};function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const x=`DOC_HYPER_LINK_PLUGIN`;let S=class extends n{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:x,businesses:[u.UNIVER_DOC],onLoad:(e,n)=>{let r=this._univerInstanceService.getUnit(e,u.UNIVER_DOC);if(!r)return;let i=new Map,a=e=>{var n;return(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{e.rangeType===t.HYPERLINK&&i.set(e.rangeId,e)}),i};r.headerModelMap.forEach(e=>{a(e)}),r.footerModelMap.forEach(e=>{a(e)}),a(r),n.links.forEach(e=>{let t=i.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let n=this._univerInstanceService.getUnit(e,u.UNIVER_DOC),r=[];if(n){let e=e=>{var n;(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{if(e.rangeType===t.HYPERLINK){var n;r.push({id:e.rangeId,payload:((n=e.properties)==null?void 0:n.url)||``})}})};n.headerModelMap.forEach(t=>{e(t)}),n.footerModelMap.forEach(t=>{e(t)}),e(n)}return JSON.stringify({links:r})},parseJson(e){return JSON.parse(e)}})}};S=b([y(0,s(a)),y(1,o)],S);function C(e){"@babel/helpers - typeof";return C=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends l{constructor(e=v,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._commandService=r;let{...i}=d({},v,this._config);this._configService.setConfig(_,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e)),[m,g,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(S)}};E(D,`pluginName`,x),E(D,`packageName`,f),E(D,`version`,p),E(D,`type`,u.UNIVER_DOC),D=b([y(1,s(c)),y(2,i),y(3,r)],D);export{D as UniverDocsHyperLinkPlugin};
1
+ import { CommandType, CustomRangeType, Disposable, ICommandService, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, UniverInstanceType, merge } from "@univerjs/core";
2
+
3
+ //#region package.json
4
+ var name = "@univerjs/docs-hyper-link";
5
+ var version = "0.21.0";
6
+
7
+ //#endregion
8
+ //#region src/commands/mutations/hyper-link.mutation.ts
9
+ const AddHyperLinkMuatation = {
10
+ id: "docs.mutation.add-hyper-link",
11
+ type: CommandType.MUTATION,
12
+ handler: () => {
13
+ return true;
14
+ }
15
+ };
16
+ const UpdateHyperLinkMuatation = {
17
+ id: "docs.mutation.update-hyper-link",
18
+ type: CommandType.MUTATION,
19
+ handler: () => {
20
+ return true;
21
+ }
22
+ };
23
+ const DeleteHyperLinkMuatation = {
24
+ id: "docs.mutation.delete-hyper-link",
25
+ type: CommandType.MUTATION,
26
+ handler: () => {
27
+ return true;
28
+ }
29
+ };
30
+
31
+ //#endregion
32
+ //#region src/config/config.ts
33
+ /**
34
+ * Copyright 2023-present DreamNum Co., Ltd.
35
+ *
36
+ * Licensed under the Apache License, Version 2.0 (the "License");
37
+ * you may not use this file except in compliance with the License.
38
+ * You may obtain a copy of the License at
39
+ *
40
+ * http://www.apache.org/licenses/LICENSE-2.0
41
+ *
42
+ * Unless required by applicable law or agreed to in writing, software
43
+ * distributed under the License is distributed on an "AS IS" BASIS,
44
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45
+ * See the License for the specific language governing permissions and
46
+ * limitations under the License.
47
+ */
48
+ const DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY = "docs-hyper-link.config";
49
+ const configSymbol = Symbol(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY);
50
+ const defaultPluginConfig = {};
51
+
52
+ //#endregion
53
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
54
+ function __decorateParam(paramIndex, decorator) {
55
+ return function(target, key) {
56
+ decorator(target, key, paramIndex);
57
+ };
58
+ }
59
+
60
+ //#endregion
61
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
62
+ function __decorate(decorators, target, key, desc) {
63
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
64
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
65
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
66
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
67
+ }
68
+
69
+ //#endregion
70
+ //#region src/controllers/resource.controller.ts
71
+ const DOC_HYPER_LINK_PLUGIN = "DOC_HYPER_LINK_PLUGIN";
72
+ let DocHyperLinkResourceController = class DocHyperLinkResourceController extends Disposable {
73
+ constructor(_resourceManagerService, _univerInstanceService) {
74
+ super();
75
+ this._resourceManagerService = _resourceManagerService;
76
+ this._univerInstanceService = _univerInstanceService;
77
+ this._init();
78
+ }
79
+ _init() {
80
+ this._resourceManagerService.registerPluginResource({
81
+ pluginName: DOC_HYPER_LINK_PLUGIN,
82
+ businesses: [UniverInstanceType.UNIVER_DOC],
83
+ onLoad: (unitID, resource) => {
84
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
85
+ if (!doc) return;
86
+ const customRangeMap = /* @__PURE__ */ new Map();
87
+ const handleDoc = (model) => {
88
+ var _model$getBody;
89
+ (_model$getBody = model.getBody()) === null || _model$getBody === void 0 || (_model$getBody = _model$getBody.customRanges) === null || _model$getBody === void 0 || _model$getBody.forEach((customRange) => {
90
+ if (customRange.rangeType === CustomRangeType.HYPERLINK) customRangeMap.set(customRange.rangeId, customRange);
91
+ });
92
+ return customRangeMap;
93
+ };
94
+ doc.headerModelMap.forEach((headerModel) => {
95
+ handleDoc(headerModel);
96
+ });
97
+ doc.footerModelMap.forEach((footerModel) => {
98
+ handleDoc(footerModel);
99
+ });
100
+ handleDoc(doc);
101
+ resource.links.forEach((link) => {
102
+ const customRange = customRangeMap.get(link.id);
103
+ if (customRange) customRange.properties = {
104
+ ...customRange.properties,
105
+ url: link.payload
106
+ };
107
+ });
108
+ },
109
+ onUnLoad: (unitID) => {},
110
+ toJson: (unitID) => {
111
+ const doc = this._univerInstanceService.getUnit(unitID, UniverInstanceType.UNIVER_DOC);
112
+ const links = [];
113
+ if (doc) {
114
+ const handleDoc = (model) => {
115
+ var _model$getBody2;
116
+ (_model$getBody2 = model.getBody()) === null || _model$getBody2 === void 0 || (_model$getBody2 = _model$getBody2.customRanges) === null || _model$getBody2 === void 0 || _model$getBody2.forEach((customRange) => {
117
+ if (customRange.rangeType === CustomRangeType.HYPERLINK) {
118
+ var _customRange$properti;
119
+ links.push({
120
+ id: customRange.rangeId,
121
+ payload: ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) || ""
122
+ });
123
+ }
124
+ });
125
+ };
126
+ doc.headerModelMap.forEach((headerModel) => {
127
+ handleDoc(headerModel);
128
+ });
129
+ doc.footerModelMap.forEach((footerModel) => {
130
+ handleDoc(footerModel);
131
+ });
132
+ handleDoc(doc);
133
+ }
134
+ return JSON.stringify({ links });
135
+ },
136
+ parseJson(bytes) {
137
+ return JSON.parse(bytes);
138
+ }
139
+ });
140
+ }
141
+ };
142
+ DocHyperLinkResourceController = __decorate([__decorateParam(0, Inject(IResourceManagerService)), __decorateParam(1, IUniverInstanceService)], DocHyperLinkResourceController);
143
+
144
+ //#endregion
145
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
146
+ function _typeof(o) {
147
+ "@babel/helpers - typeof";
148
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
149
+ return typeof o;
150
+ } : function(o) {
151
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
152
+ }, _typeof(o);
153
+ }
154
+
155
+ //#endregion
156
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
157
+ function toPrimitive(t, r) {
158
+ if ("object" != _typeof(t) || !t) return t;
159
+ var e = t[Symbol.toPrimitive];
160
+ if (void 0 !== e) {
161
+ var i = e.call(t, r || "default");
162
+ if ("object" != _typeof(i)) return i;
163
+ throw new TypeError("@@toPrimitive must return a primitive value.");
164
+ }
165
+ return ("string" === r ? String : Number)(t);
166
+ }
167
+
168
+ //#endregion
169
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
170
+ function toPropertyKey(t) {
171
+ var i = toPrimitive(t, "string");
172
+ return "symbol" == _typeof(i) ? i : i + "";
173
+ }
174
+
175
+ //#endregion
176
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
177
+ function _defineProperty(e, r, t) {
178
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
179
+ value: t,
180
+ enumerable: !0,
181
+ configurable: !0,
182
+ writable: !0
183
+ }) : e[r] = t, e;
184
+ }
185
+
186
+ //#endregion
187
+ //#region src/plugin.ts
188
+ let UniverDocsHyperLinkPlugin = class UniverDocsHyperLinkPlugin extends Plugin {
189
+ constructor(_config = defaultPluginConfig, _injector, _configService, _commandService) {
190
+ super();
191
+ this._config = _config;
192
+ this._injector = _injector;
193
+ this._configService = _configService;
194
+ this._commandService = _commandService;
195
+ const { ...rest } = merge({}, defaultPluginConfig, this._config);
196
+ this._configService.setConfig(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY, rest);
197
+ }
198
+ onStarting() {
199
+ [[DocHyperLinkResourceController]].forEach((dep) => this._injector.add(dep));
200
+ [
201
+ AddHyperLinkMuatation,
202
+ DeleteHyperLinkMuatation,
203
+ UpdateHyperLinkMuatation
204
+ ].forEach((mutation) => {
205
+ this.disposeWithMe(this._commandService.registerCommand(mutation));
206
+ });
207
+ this._injector.get(DocHyperLinkResourceController);
208
+ }
209
+ };
210
+ _defineProperty(UniverDocsHyperLinkPlugin, "pluginName", DOC_HYPER_LINK_PLUGIN);
211
+ _defineProperty(UniverDocsHyperLinkPlugin, "packageName", name);
212
+ _defineProperty(UniverDocsHyperLinkPlugin, "version", version);
213
+ _defineProperty(UniverDocsHyperLinkPlugin, "type", UniverInstanceType.UNIVER_DOC);
214
+ UniverDocsHyperLinkPlugin = __decorate([
215
+ __decorateParam(1, Inject(Injector)),
216
+ __decorateParam(2, IConfigService),
217
+ __decorateParam(3, ICommandService)
218
+ ], UniverDocsHyperLinkPlugin);
219
+
220
+ //#endregion
221
+ export { UniverDocsHyperLinkPlugin };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLink={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=`@univerjs/docs-hyper-link`,r=`0.20.1`;let i={id:`docs.mutation.add-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},a={id:`docs.mutation.update-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},o={id:`docs.mutation.delete-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},s=`docs-hyper-link.config`;Symbol(s);let c={};function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let d=`DOC_HYPER_LINK_PLUGIN`,f=class extends t.Disposable{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:d,businesses:[t.UniverInstanceType.UNIVER_DOC],onLoad:(e,n)=>{let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!r)return;let i=new Map,a=e=>{var n;return(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{e.rangeType===t.CustomRangeType.HYPERLINK&&i.set(e.rangeId,e)}),i};r.headerModelMap.forEach(e=>{a(e)}),r.footerModelMap.forEach(e=>{a(e)}),a(r),n.links.forEach(e=>{let t=i.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC),r=[];if(n){let e=e=>{var n;(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{if(e.rangeType===t.CustomRangeType.HYPERLINK){var n;r.push({id:e.rangeId,payload:((n=e.properties)==null?void 0:n.url)||``})}})};n.headerModelMap.forEach(t=>{e(t)}),n.footerModelMap.forEach(t=>{e(t)}),e(n)}return JSON.stringify({links:r})},parseJson(e){return JSON.parse(e)}})}};f=u([l(0,(0,t.Inject)(t.IResourceManagerService)),l(1,t.IUniverInstanceService)],f);function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let _=class extends t.Plugin{constructor(e=c,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},c,this._config);this._configService.setConfig(s,a)}onStarting(){[[f]].forEach(e=>this._injector.add(e)),[i,o,a].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(f)}};g(_,`pluginName`,d),g(_,`packageName`,n),g(_,`version`,r),g(_,`type`,t.UniverInstanceType.UNIVER_DOC),_=u([l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService),l(3,t.ICommandService)],_),Object.defineProperty(e,`UniverDocsHyperLinkPlugin`,{enumerable:!0,get:function(){return _}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLink={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=`@univerjs/docs-hyper-link`,r=`0.21.0`;let i={id:`docs.mutation.add-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},a={id:`docs.mutation.update-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},o={id:`docs.mutation.delete-hyper-link`,type:t.CommandType.MUTATION,handler:()=>!0},s=`docs-hyper-link.config`;Symbol(s);let c={};function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let d=`DOC_HYPER_LINK_PLUGIN`,f=class extends t.Disposable{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:d,businesses:[t.UniverInstanceType.UNIVER_DOC],onLoad:(e,n)=>{let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!r)return;let i=new Map,a=e=>{var n;return(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{e.rangeType===t.CustomRangeType.HYPERLINK&&i.set(e.rangeId,e)}),i};r.headerModelMap.forEach(e=>{a(e)}),r.footerModelMap.forEach(e=>{a(e)}),a(r),n.links.forEach(e=>{let t=i.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC),r=[];if(n){let e=e=>{var n;(n=e.getBody())==null||(n=n.customRanges)==null||n.forEach(e=>{if(e.rangeType===t.CustomRangeType.HYPERLINK){var n;r.push({id:e.rangeId,payload:((n=e.properties)==null?void 0:n.url)||``})}})};n.headerModelMap.forEach(t=>{e(t)}),n.footerModelMap.forEach(t=>{e(t)}),e(n)}return JSON.stringify({links:r})},parseJson(e){return JSON.parse(e)}})}};f=u([l(0,(0,t.Inject)(t.IResourceManagerService)),l(1,t.IUniverInstanceService)],f);function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let _=class extends t.Plugin{constructor(e=c,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},c,this._config);this._configService.setConfig(s,a)}onStarting(){[[f]].forEach(e=>this._injector.add(e)),[i,o,a].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(f)}};g(_,`pluginName`,d),g(_,`packageName`,n),g(_,`version`,r),g(_,`type`,t.UniverInstanceType.UNIVER_DOC),_=u([l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService),l(3,t.ICommandService)],_),Object.defineProperty(e,`UniverDocsHyperLinkPlugin`,{enumerable:!0,get:function(){return _}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -43,12 +43,12 @@
43
43
  "lib"
44
44
  ],
45
45
  "dependencies": {
46
- "@univerjs/core": "0.20.1"
46
+ "@univerjs/core": "0.21.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "typescript": "^6.0.2",
50
- "vitest": "^4.1.1",
51
- "@univerjs-infra/shared": "0.20.1"
50
+ "vitest": "^4.1.4",
51
+ "@univerjs-infra/shared": "0.21.0"
52
52
  },
53
53
  "scripts": {
54
54
  "test": "vitest run",