@univerjs/sheets-hyper-link 0.17.0 → 0.18.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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -180
- package/lib/es/index.js +1 -1282
- package/lib/facade.js +1 -180
- package/lib/index.js +1 -1282
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +17 -2
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +16 -1
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +17 -2
- package/lib/types/commands/mutations/add-hyper-link.mutation.d.ts +17 -2
- package/lib/types/commands/mutations/remove-hyper-link.mutation.d.ts +16 -1
- package/lib/types/commands/mutations/update-hyper-link.mutation.d.ts +17 -2
- package/lib/types/controllers/ref-range.controller.d.ts +15 -0
- package/lib/types/controllers/remove-sheet.controller.d.ts +15 -0
- package/lib/types/controllers/rich-text-ref-range.controller.d.ts +15 -0
- package/lib/types/controllers/set-range.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-hyper-link-resource.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-hyper-link.controller.d.ts +15 -0
- package/lib/types/facade/f-event.d.ts +18 -3
- package/lib/types/facade/f-range.d.ts +15 -0
- package/lib/types/facade/f-univer.d.ts +16 -1
- package/lib/types/facade/f-workbook.d.ts +20 -3
- package/lib/types/facade/f-worksheet.d.ts +15 -0
- package/lib/types/models/hyper-link.model.d.ts +18 -3
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/parser.service.d.ts +17 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -9
package/lib/facade.js
CHANGED
|
@@ -1,180 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SheetsHyperLinkParserService as a, AddHyperLinkCommand as u, UpdateHyperLinkCommand as g, CancelHyperLinkCommand as S } from "@univerjs/sheets-hyper-link";
|
|
3
|
-
import { FWorkbook as v, FWorksheet as w, FRange as _ } from "@univerjs/sheets/facade";
|
|
4
|
-
import { FEventName as x, FUniver as y } from "@univerjs/core/facade";
|
|
5
|
-
var I = Object.getOwnPropertyDescriptor, E = (s, e, i, r) => {
|
|
6
|
-
for (var n = r > 1 ? void 0 : r ? I(e, i) : e, t = s.length - 1, o; t >= 0; t--)
|
|
7
|
-
(o = s[t]) && (n = o(n) || n);
|
|
8
|
-
return n;
|
|
9
|
-
}, H = (s, e) => (i, r) => e(i, r, s);
|
|
10
|
-
let m = class {
|
|
11
|
-
constructor(s, e) {
|
|
12
|
-
this._workbook = s, this._parserService = e;
|
|
13
|
-
}
|
|
14
|
-
getRangeUrl(s) {
|
|
15
|
-
return this._parserService.buildHyperLink(this._workbook.getId(), s.getSheetId(), s.getRange()), this;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
m = E([
|
|
19
|
-
H(1, L(a))
|
|
20
|
-
], m);
|
|
21
|
-
class U extends v {
|
|
22
|
-
createSheetHyperlink(e, i) {
|
|
23
|
-
return this._injector.get(a).buildHyperLink(this.getId(), e, i);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Parse the hyperlink string to get the hyperlink info.
|
|
27
|
-
* @param {string} hyperlink the hyperlink string
|
|
28
|
-
* @returns {ISheetHyperLinkInfo} the hyperlink info
|
|
29
|
-
*/
|
|
30
|
-
parseSheetHyperlink(e) {
|
|
31
|
-
return this._injector.get(a).parseHyperLink(e);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
v.extend(U);
|
|
35
|
-
class R extends w {
|
|
36
|
-
getUrl() {
|
|
37
|
-
return this._injector.get(a).buildHyperLink(this._workbook.getUnitId(), this._worksheet.getSheetId());
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
w.extend(R);
|
|
41
|
-
class T extends _ {
|
|
42
|
-
// #region hyperlink
|
|
43
|
-
setHyperLink(e, i) {
|
|
44
|
-
const r = {
|
|
45
|
-
unitId: this.getUnitId(),
|
|
46
|
-
subUnitId: this._worksheet.getSheetId(),
|
|
47
|
-
link: {
|
|
48
|
-
row: this._range.startRow,
|
|
49
|
-
column: this._range.startColumn,
|
|
50
|
-
payload: e,
|
|
51
|
-
display: i,
|
|
52
|
-
id: f()
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return this._commandService.executeCommand(u.id, r);
|
|
56
|
-
}
|
|
57
|
-
getHyperLinks() {
|
|
58
|
-
var i, r, n;
|
|
59
|
-
const e = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn);
|
|
60
|
-
return e != null && e.p ? (n = (r = (i = e.p.body) == null ? void 0 : i.customRanges) == null ? void 0 : r.filter((t) => t.rangeType === C.HYPERLINK).map((t) => {
|
|
61
|
-
var o, h, c, l, k;
|
|
62
|
-
return {
|
|
63
|
-
id: `${t.rangeId}`,
|
|
64
|
-
startIndex: t.startIndex,
|
|
65
|
-
endIndex: t.endIndex,
|
|
66
|
-
url: (h = (o = t.properties) == null ? void 0 : o.url) != null ? h : "",
|
|
67
|
-
label: (k = (l = (c = e.p) == null ? void 0 : c.body) == null ? void 0 : l.dataStream.slice(t.startIndex, t.endIndex + 1).replaceAll(p.CUSTOM_RANGE_START, "").replaceAll(p.CUSTOM_RANGE_END, "")) != null ? k : ""
|
|
68
|
-
};
|
|
69
|
-
})) != null ? n : [] : [];
|
|
70
|
-
}
|
|
71
|
-
updateHyperLink(e, i, r) {
|
|
72
|
-
const n = {
|
|
73
|
-
unitId: this.getUnitId(),
|
|
74
|
-
subUnitId: this._worksheet.getSheetId(),
|
|
75
|
-
row: this._range.startRow,
|
|
76
|
-
column: this._range.startColumn,
|
|
77
|
-
id: e,
|
|
78
|
-
payload: {
|
|
79
|
-
payload: i,
|
|
80
|
-
display: r
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
return this._commandService.executeCommand(g.id, n);
|
|
84
|
-
}
|
|
85
|
-
cancelHyperLink(e) {
|
|
86
|
-
const i = {
|
|
87
|
-
unitId: this.getUnitId(),
|
|
88
|
-
subUnitId: this._worksheet.getSheetId(),
|
|
89
|
-
row: this._range.startRow,
|
|
90
|
-
column: this._range.startColumn,
|
|
91
|
-
id: e
|
|
92
|
-
};
|
|
93
|
-
return this._commandService.syncExecuteCommand(S.id, i);
|
|
94
|
-
}
|
|
95
|
-
getUrl() {
|
|
96
|
-
return this._injector.get(a).buildHyperLink(this.getUnitId(), this.getSheetId(), this.getRange());
|
|
97
|
-
}
|
|
98
|
-
// #endregion
|
|
99
|
-
}
|
|
100
|
-
_.extend(T);
|
|
101
|
-
class B {
|
|
102
|
-
get BeforeSheetLinkAdd() {
|
|
103
|
-
return "BeforeSheetLinkAdd";
|
|
104
|
-
}
|
|
105
|
-
get BeforeSheetLinkCancel() {
|
|
106
|
-
return "BeforeSheetLinkCancel";
|
|
107
|
-
}
|
|
108
|
-
get BeforeSheetLinkUpdate() {
|
|
109
|
-
return "BeforeSheetLinkUpdate";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
x.extend(B);
|
|
113
|
-
class A extends y {
|
|
114
|
-
/**
|
|
115
|
-
* @ignore
|
|
116
|
-
*/
|
|
117
|
-
_initialize(e) {
|
|
118
|
-
const i = e.get(b);
|
|
119
|
-
this.disposeWithMe(
|
|
120
|
-
this.registerEventHandler(
|
|
121
|
-
this.Event.BeforeSheetLinkAdd,
|
|
122
|
-
() => i.beforeCommandExecuted((r) => {
|
|
123
|
-
if (r.id !== u.id) return;
|
|
124
|
-
const n = this.getCommandSheetTarget(r);
|
|
125
|
-
if (!n) return;
|
|
126
|
-
const t = r.params, o = {
|
|
127
|
-
workbook: n.workbook,
|
|
128
|
-
worksheet: n.worksheet,
|
|
129
|
-
row: t.link.row,
|
|
130
|
-
col: t.link.column,
|
|
131
|
-
link: t.link
|
|
132
|
-
};
|
|
133
|
-
if (this.fireEvent(this.Event.BeforeSheetLinkAdd, o), o.cancel)
|
|
134
|
-
throw new d();
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
), this.disposeWithMe(
|
|
138
|
-
this.registerEventHandler(
|
|
139
|
-
this.Event.BeforeSheetLinkUpdate,
|
|
140
|
-
() => i.beforeCommandExecuted((r) => {
|
|
141
|
-
if (r.id !== g.id) return;
|
|
142
|
-
const n = this.getCommandSheetTarget(r);
|
|
143
|
-
if (!n) return;
|
|
144
|
-
const t = r.params, o = {
|
|
145
|
-
workbook: n.workbook,
|
|
146
|
-
worksheet: n.worksheet,
|
|
147
|
-
row: t.row,
|
|
148
|
-
column: t.column,
|
|
149
|
-
id: t.id,
|
|
150
|
-
payload: t.payload
|
|
151
|
-
};
|
|
152
|
-
if (this.fireEvent(this.Event.BeforeSheetLinkUpdate, o), o.cancel)
|
|
153
|
-
throw new d();
|
|
154
|
-
})
|
|
155
|
-
)
|
|
156
|
-
), this.disposeWithMe(
|
|
157
|
-
this.registerEventHandler(
|
|
158
|
-
this.Event.BeforeSheetLinkCancel,
|
|
159
|
-
() => i.beforeCommandExecuted((r) => {
|
|
160
|
-
if (r.id !== S.id) return;
|
|
161
|
-
const n = this.getCommandSheetTarget(r);
|
|
162
|
-
if (!n) return;
|
|
163
|
-
const t = r.params, o = {
|
|
164
|
-
workbook: n.workbook,
|
|
165
|
-
worksheet: n.worksheet,
|
|
166
|
-
row: t.row,
|
|
167
|
-
column: t.column,
|
|
168
|
-
id: t.id
|
|
169
|
-
};
|
|
170
|
-
if (this.fireEvent(this.Event.BeforeSheetLinkCancel, o), o.cancel)
|
|
171
|
-
throw new d();
|
|
172
|
-
})
|
|
173
|
-
)
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
y.extend(A);
|
|
178
|
-
export {
|
|
179
|
-
U as FWorkbookHyperLinkMixin
|
|
180
|
-
};
|
|
1
|
+
import{CanceledError as e,CustomRangeType as t,DataStreamTreeTokenType as n,ICommandService as r,Inject as i,generateRandomId as a}from"@univerjs/core";import{AddHyperLinkCommand as o,CancelHyperLinkCommand as s,SheetsHyperLinkParserService as c,UpdateHyperLinkCommand as l}from"@univerjs/sheets-hyper-link";import{FRange as u,FWorkbook as d,FWorksheet as f}from"@univerjs/sheets/facade";import{FEventName as p,FUniver as m}from"@univerjs/core/facade";function h(e,t){return function(n,r){t(n,r,e)}}function g(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 _=class{constructor(e,t){this._workbook=e,this._parserService=t}getRangeUrl(e){return this._parserService.buildHyperLink(this._workbook.getId(),e.getSheetId(),e.getRange()),this}};_=g([h(1,i(c))],_);var v=class extends d{createSheetHyperlink(e,t){return this._injector.get(c).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(c).parseHyperLink(e)}};d.extend(v);var y=class extends f{getUrl(){return this._injector.get(c).buildHyperLink(this._workbook.getUnitId(),this._worksheet.getSheetId())}};f.extend(y);var b=class extends u{setHyperLink(e,t){let n={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:a()}};return this._commandService.executeCommand(o.id,n)}getHyperLinks(){var e,r;let i=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return i!=null&&i.p?(e=(r=i.p.body)==null||(r=r.customRanges)==null?void 0:r.filter(e=>e.rangeType===t.HYPERLINK).map(e=>{var t,r,a,o;return{id:`${e.rangeId}`,startIndex:e.startIndex,endIndex:e.endIndex,url:(t=(r=e.properties)==null?void 0:r.url)==null?``:t,label:(a=(o=i.p)==null||(o=o.body)==null?void 0:o.dataStream.slice(e.startIndex,e.endIndex+1).replaceAll(n.CUSTOM_RANGE_START,``).replaceAll(n.CUSTOM_RANGE_END,``))==null?``:a}}))==null?[]:e:[]}updateHyperLink(e,t,n){let r={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:n}};return this._commandService.executeCommand(l.id,r)}cancelHyperLink(e){let t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(s.id,t)}getUrl(){return this._injector.get(c).buildHyperLink(this.getUnitId(),this.getSheetId(),this.getRange())}};u.extend(b);var x=class{get BeforeSheetLinkAdd(){return`BeforeSheetLinkAdd`}get BeforeSheetLinkCancel(){return`BeforeSheetLinkCancel`}get BeforeSheetLinkUpdate(){return`BeforeSheetLinkUpdate`}};p.extend(x);var S=class extends m{_initialize(t){let n=t.get(r);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkAdd,()=>n.beforeCommandExecuted(t=>{if(t.id!==o.id)return;let n=this.getCommandSheetTarget(t);if(!n)return;let r=t.params,i={workbook:n.workbook,worksheet:n.worksheet,row:r.link.row,col:r.link.column,link:r.link};if(this.fireEvent(this.Event.BeforeSheetLinkAdd,i),i.cancel)throw new e}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkUpdate,()=>n.beforeCommandExecuted(t=>{if(t.id!==l.id)return;let n=this.getCommandSheetTarget(t);if(!n)return;let r=t.params,i={workbook:n.workbook,worksheet:n.worksheet,row:r.row,column:r.column,id:r.id,payload:r.payload};if(this.fireEvent(this.Event.BeforeSheetLinkUpdate,i),i.cancel)throw new e}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkCancel,()=>n.beforeCommandExecuted(t=>{if(t.id!==s.id)return;let n=this.getCommandSheetTarget(t);if(!n)return;let r=t.params,i={workbook:n.workbook,worksheet:n.worksheet,row:r.row,column:r.column,id:r.id};if(this.fireEvent(this.Event.BeforeSheetLinkCancel,i),i.cancel)throw new e})))}};m.extend(S);export{v as FWorkbookHyperLinkMixin};
|