@univerjs/sheets-hyper-link 0.24.0 → 0.25.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.
Files changed (108) hide show
  1. package/lib/cjs/facade.js +69 -69
  2. package/lib/cjs/index.js +13 -10
  3. package/lib/cjs/locale/ar-SA.js +6 -0
  4. package/lib/cjs/locale/ca-ES.js +6 -0
  5. package/lib/cjs/locale/de-DE.js +6 -0
  6. package/lib/cjs/locale/en-US.js +21 -0
  7. package/lib/cjs/locale/es-ES.js +6 -0
  8. package/lib/cjs/locale/fa-IR.js +6 -0
  9. package/lib/cjs/locale/fr-FR.js +6 -0
  10. package/lib/cjs/locale/id-ID.js +6 -0
  11. package/lib/cjs/locale/it-IT.js +6 -0
  12. package/lib/cjs/locale/ja-JP.js +6 -0
  13. package/lib/cjs/locale/ko-KR.js +6 -0
  14. package/lib/cjs/locale/pl-PL.js +6 -0
  15. package/lib/cjs/locale/pt-BR.js +6 -0
  16. package/lib/cjs/locale/ru-RU.js +6 -0
  17. package/lib/cjs/locale/sk-SK.js +6 -0
  18. package/lib/cjs/locale/vi-VN.js +6 -0
  19. package/lib/cjs/locale/zh-CN.js +6 -0
  20. package/lib/cjs/locale/zh-HK.js +6 -0
  21. package/lib/cjs/locale/zh-TW.js +6 -0
  22. package/lib/es/facade.js +69 -69
  23. package/lib/es/index.js +13 -10
  24. package/lib/es/locale/ar-SA.js +5 -0
  25. package/lib/es/locale/ca-ES.js +5 -0
  26. package/lib/es/locale/de-DE.js +5 -0
  27. package/lib/es/locale/en-US.js +20 -0
  28. package/lib/es/locale/es-ES.js +5 -0
  29. package/lib/es/locale/fa-IR.js +5 -0
  30. package/lib/es/locale/fr-FR.js +5 -0
  31. package/lib/es/locale/id-ID.js +5 -0
  32. package/lib/es/locale/it-IT.js +5 -0
  33. package/lib/es/locale/ja-JP.js +5 -0
  34. package/lib/es/locale/ko-KR.js +5 -0
  35. package/lib/es/locale/pl-PL.js +5 -0
  36. package/lib/es/locale/pt-BR.js +5 -0
  37. package/lib/es/locale/ru-RU.js +5 -0
  38. package/lib/es/locale/sk-SK.js +5 -0
  39. package/lib/es/locale/vi-VN.js +5 -0
  40. package/lib/es/locale/zh-CN.js +5 -0
  41. package/lib/es/locale/zh-HK.js +5 -0
  42. package/lib/es/locale/zh-TW.js +5 -0
  43. package/lib/facade.js +69 -69
  44. package/lib/index.js +13 -10
  45. package/lib/locale/ar-SA.js +5 -0
  46. package/lib/locale/ca-ES.js +5 -0
  47. package/lib/locale/de-DE.js +5 -0
  48. package/lib/locale/en-US.js +20 -0
  49. package/lib/locale/es-ES.js +5 -0
  50. package/lib/locale/fa-IR.js +5 -0
  51. package/lib/locale/fr-FR.js +5 -0
  52. package/lib/locale/id-ID.js +5 -0
  53. package/lib/locale/it-IT.js +5 -0
  54. package/lib/locale/ja-JP.js +5 -0
  55. package/lib/locale/ko-KR.js +5 -0
  56. package/lib/locale/pl-PL.js +5 -0
  57. package/lib/locale/pt-BR.js +5 -0
  58. package/lib/locale/ru-RU.js +5 -0
  59. package/lib/locale/sk-SK.js +5 -0
  60. package/lib/locale/vi-VN.js +5 -0
  61. package/lib/locale/zh-CN.js +5 -0
  62. package/lib/locale/zh-HK.js +5 -0
  63. package/lib/locale/zh-TW.js +5 -0
  64. package/lib/types/facade/f-range.d.ts +76 -46
  65. package/lib/types/facade/f-workbook.d.ts +40 -18
  66. package/lib/types/facade/f-worksheet.d.ts +3 -2
  67. package/lib/types/locale/ar-SA.d.ts +18 -0
  68. package/lib/types/locale/ca-ES.d.ts +18 -0
  69. package/lib/types/locale/de-DE.d.ts +18 -0
  70. package/lib/types/locale/en-US.d.ts +23 -0
  71. package/lib/types/locale/es-ES.d.ts +18 -0
  72. package/lib/types/locale/fa-IR.d.ts +18 -0
  73. package/lib/types/locale/fr-FR.d.ts +18 -0
  74. package/lib/types/locale/id-ID.d.ts +18 -0
  75. package/lib/types/locale/it-IT.d.ts +18 -0
  76. package/lib/types/locale/ja-JP.d.ts +18 -0
  77. package/lib/types/locale/ko-KR.d.ts +18 -0
  78. package/lib/types/locale/pl-PL.d.ts +18 -0
  79. package/lib/types/locale/pt-BR.d.ts +18 -0
  80. package/lib/types/locale/ru-RU.d.ts +18 -0
  81. package/lib/types/locale/sk-SK.d.ts +18 -0
  82. package/lib/types/locale/vi-VN.d.ts +18 -0
  83. package/lib/types/locale/zh-CN.d.ts +18 -0
  84. package/lib/types/locale/zh-HK.d.ts +18 -0
  85. package/lib/types/locale/zh-TW.d.ts +18 -0
  86. package/lib/types/services/parser.service.d.ts +2 -1
  87. package/lib/umd/facade.js +1 -1
  88. package/lib/umd/index.js +1 -1
  89. package/lib/umd/locale/ar-SA.js +1 -0
  90. package/lib/umd/locale/ca-ES.js +1 -0
  91. package/lib/umd/locale/de-DE.js +1 -0
  92. package/lib/umd/locale/en-US.js +1 -0
  93. package/lib/umd/locale/es-ES.js +1 -0
  94. package/lib/umd/locale/fa-IR.js +1 -0
  95. package/lib/umd/locale/fr-FR.js +1 -0
  96. package/lib/umd/locale/id-ID.js +1 -0
  97. package/lib/umd/locale/it-IT.js +1 -0
  98. package/lib/umd/locale/ja-JP.js +1 -0
  99. package/lib/umd/locale/ko-KR.js +1 -0
  100. package/lib/umd/locale/pl-PL.js +1 -0
  101. package/lib/umd/locale/pt-BR.js +1 -0
  102. package/lib/umd/locale/ru-RU.js +1 -0
  103. package/lib/umd/locale/sk-SK.js +1 -0
  104. package/lib/umd/locale/vi-VN.js +1 -0
  105. package/lib/umd/locale/zh-CN.js +1 -0
  106. package/lib/umd/locale/zh-HK.js +1 -0
  107. package/lib/umd/locale/zh-TW.js +1 -0
  108. package/package.json +12 -7
package/lib/es/index.js CHANGED
@@ -4,7 +4,7 @@ import { AFTER_CELL_EDIT, ClearSelectionAllCommand, ClearSelectionContentCommand
4
4
  import { Subject } from "rxjs";
5
5
  import { IDefinedNamesService, deserializeRangeWithSheet, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
6
6
 
7
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
8
8
  function _typeof(o) {
9
9
  "@babel/helpers - typeof";
10
10
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +15,7 @@ function _typeof(o) {
15
15
  }
16
16
 
17
17
  //#endregion
18
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
19
19
  function toPrimitive(t, r) {
20
20
  if ("object" != _typeof(t) || !t) return t;
21
21
  var e = t[Symbol.toPrimitive];
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
28
28
  }
29
29
 
30
30
  //#endregion
31
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
32
32
  function toPropertyKey(t) {
33
33
  var i = toPrimitive(t, "string");
34
34
  return "symbol" == _typeof(i) ? i : i + "";
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
39
39
  function _defineProperty(e, r, t) {
40
40
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
41
  value: t,
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
50
50
  function __decorateParam(paramIndex, decorator) {
51
51
  return function(target, key) {
52
52
  decorator(target, key, paramIndex);
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
54
54
  }
55
55
 
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -705,7 +705,7 @@ const UpdateRichHyperLinkMutation = {
705
705
  //#endregion
706
706
  //#region package.json
707
707
  var name = "@univerjs/sheets-hyper-link";
708
- var version = "0.24.0";
708
+ var version = "0.25.0";
709
709
 
710
710
  //#endregion
711
711
  //#region src/config/config.ts
@@ -1455,8 +1455,11 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1455
1455
  this._localeService = _localeService;
1456
1456
  this._definedNamesService = _definedNamesService;
1457
1457
  }
1458
- buildHyperLink(unitId, sheetId, range) {
1459
- return `#${"gid"}=${sheetId}${range ? `&${typeof range === "string" ? "rangeid" : "range"}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1458
+ buildHyperLink(defineNameIdOrRange, sheetId) {
1459
+ if (typeof defineNameIdOrRange === "string") return `#${"rangeid"}=${defineNameIdOrRange}`;
1460
+ let result = `#${"gid"}=${sheetId}`;
1461
+ if (defineNameIdOrRange) result += `&${"range"}=${serializeRange(defineNameIdOrRange)}`;
1462
+ return result;
1460
1463
  }
1461
1464
  parseHyperLink(urlStr) {
1462
1465
  if (urlStr.startsWith("#")) {
@@ -1488,7 +1491,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1488
1491
  const workbook = unitid ? this._univerInstanceService.getUnit(unitid, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1489
1492
  const invalidLink = {
1490
1493
  type: "invalid",
1491
- name: this._localeService.t("hyperLink.message.refError")
1494
+ name: this._localeService.t("sheets-hyper-link.message.refError")
1492
1495
  };
1493
1496
  if (!workbook) return invalidLink;
1494
1497
  const sheet = gid ? workbook.getSheetBySheetId(gid) : workbook.getActiveSheet();
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ar-SA.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "نطاق غير صالح" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ca-ES.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Interval no vàlid" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/de-DE.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Ungültiger Bereich" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,20 @@
1
+ //#region src/locale/en-US.ts
2
+ /**
3
+ * Copyright 2023-present DreamNum Co., Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ const locale = { "sheets-hyper-link": { message: { refError: "Invalid Range" } } };
18
+
19
+ //#endregion
20
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/es-ES.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Rango no válido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/fa-IR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "محدوده نامعتبر" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/fr-FR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Plage invalide" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/id-ID.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Rentang Tidak Valid" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/it-IT.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Intervallo non valido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ja-JP.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "無効な範囲です" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ko-KR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "잘못된 범위입니다" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/pl-PL.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Nieprawidłowy zakres" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/pt-BR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Intervalo Inválido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ru-RU.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Недопустимый диапазон" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/sk-SK.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Neplatný rozsah" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/vi-VN.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Tham chiếu lỗi" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/zh-CN.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "错误的引用" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/zh-HK.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "錯誤的引用" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/zh-TW.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "錯誤的引用" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
package/lib/facade.js CHANGED
@@ -1,43 +1,19 @@
1
- import { CanceledError, CustomRangeType, DataStreamTreeTokenType, ICommandService, Inject, generateRandomId } from "@univerjs/core";
1
+ import { IDefinedNamesService, operatorToken } from "@univerjs/engine-formula";
2
2
  import { AddHyperLinkCommand, CancelHyperLinkCommand, SheetsHyperLinkParserService, UpdateHyperLinkCommand } from "@univerjs/sheets-hyper-link";
3
3
  import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
4
+ import { CanceledError, CustomRangeType, DataStreamTreeTokenType, ICommandService, generateRandomId } from "@univerjs/core";
4
5
  import { FEventName, FUniver } from "@univerjs/core/facade";
5
6
 
6
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
7
- function __decorateParam(paramIndex, decorator) {
8
- return function(target, key) {
9
- decorator(target, key, paramIndex);
10
- };
11
- }
12
-
13
- //#endregion
14
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
15
- function __decorate(decorators, target, key, desc) {
16
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
18
- 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;
19
- return c > 3 && r && Object.defineProperty(target, key, r), r;
20
- }
21
-
22
- //#endregion
23
7
  //#region src/facade/f-workbook.ts
24
- let SheetHyperLinkBuilder = class SheetHyperLinkBuilder {
25
- constructor(_workbook, _parserService) {
26
- this._workbook = _workbook;
27
- this._parserService = _parserService;
28
- }
29
- getRangeUrl(range) {
30
- this._parserService.buildHyperLink(this._workbook.getId(), range.getSheetId(), range.getRange());
31
- return this;
32
- }
33
- };
34
- SheetHyperLinkBuilder = __decorate([__decorateParam(1, Inject(SheetsHyperLinkParserService))], SheetHyperLinkBuilder);
35
8
  var FWorkbookHyperlinkMixin = class extends FWorkbook {
36
- /**
37
- * Parse the hyperlink string to get the hyperlink info.
38
- * @param {string} hyperlink the hyperlink string
39
- * @returns {ISheetHyperLinkInfo} the hyperlink info
40
- */
9
+ getUrlOfDefineName(name) {
10
+ const definedNameService = this._injector.get(IDefinedNamesService);
11
+ const parserService = this._injector.get(SheetsHyperLinkParserService);
12
+ const definedName = definedNameService.getValueByName(this._workbook.getUnitId(), name);
13
+ if (!definedName) throw new Error(`Defined name "${name}" does not exist.`);
14
+ if (definedName.formulaOrRefString.startsWith(operatorToken.EQUALS)) throw new Error(`Defined name "${name}" is not a reference range, cannot be converted to hyperlink.`);
15
+ return parserService.buildHyperLink(definedName.id);
16
+ }
41
17
  parseSheetHyperlink(hyperlink) {
42
18
  return this._injector.get(SheetsHyperLinkParserService).parseHyperLink(hyperlink);
43
19
  }
@@ -63,7 +39,7 @@ FWorkbook.extend(FWorkbookHyperlinkMixin);
63
39
  */
64
40
  var FWorksheetHyperlinkMixin = class extends FWorksheet {
65
41
  getUrl() {
66
- return this._injector.get(SheetsHyperLinkParserService).buildHyperLink(this._workbook.getUnitId(), this._worksheet.getSheetId());
42
+ return this._injector.get(SheetsHyperLinkParserService).buildHyperLink(null, this._worksheet.getSheetId());
67
43
  }
68
44
  };
69
45
  FWorksheet.extend(FWorksheetHyperlinkMixin);
@@ -72,60 +48,84 @@ FWorksheet.extend(FWorksheetHyperlinkMixin);
72
48
  //#region src/facade/f-range.ts
73
49
  var FRangeSheetsHyperlinkMixin = class extends FRange {
74
50
  setHyperLink(url, label) {
75
- const params = {
51
+ return this._commandService.executeCommand(AddHyperLinkCommand.id, {
76
52
  unitId: this.getUnitId(),
77
53
  subUnitId: this._worksheet.getSheetId(),
78
54
  link: {
55
+ id: generateRandomId(),
79
56
  row: this._range.startRow,
80
57
  column: this._range.startColumn,
81
58
  payload: url,
82
- display: label,
83
- id: generateRandomId()
59
+ display: label
84
60
  }
85
- };
86
- return this._commandService.executeCommand(AddHyperLinkCommand.id, params);
61
+ });
87
62
  }
88
63
  getHyperLinks() {
89
- var _cellValue$p$body$cus, _cellValue$p$body;
90
- const cellValue = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn);
91
- if (!(cellValue === null || cellValue === void 0 ? void 0 : cellValue.p)) return [];
92
- return (_cellValue$p$body$cus = (_cellValue$p$body = cellValue.p.body) === null || _cellValue$p$body === void 0 || (_cellValue$p$body = _cellValue$p$body.customRanges) === null || _cellValue$p$body === void 0 ? void 0 : _cellValue$p$body.filter((range) => range.rangeType === CustomRangeType.HYPERLINK).map((range) => {
93
- var _range$properties$url, _range$properties, _cellValue$p$body$dat, _cellValue$p;
94
- return {
95
- id: `${range.rangeId}`,
96
- startIndex: range.startIndex,
97
- endIndex: range.endIndex,
98
- url: (_range$properties$url = (_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.url) !== null && _range$properties$url !== void 0 ? _range$properties$url : "",
99
- label: (_cellValue$p$body$dat = (_cellValue$p = cellValue.p) === null || _cellValue$p === void 0 || (_cellValue$p = _cellValue$p.body) === null || _cellValue$p === void 0 ? void 0 : _cellValue$p.dataStream.slice(range.startIndex, range.endIndex + 1).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "")) !== null && _cellValue$p$body$dat !== void 0 ? _cellValue$p$body$dat : ""
100
- };
101
- })) !== null && _cellValue$p$body$cus !== void 0 ? _cellValue$p$body$cus : [];
64
+ const hyperlinks = [];
65
+ this.forEach((row, column, cell) => {
66
+ var _cell$p$body$customRa, _cell$p$body;
67
+ if (!cell.p) return;
68
+ const ranges = (_cell$p$body$customRa = (_cell$p$body = cell.p.body) === null || _cell$p$body === void 0 || (_cell$p$body = _cell$p$body.customRanges) === null || _cell$p$body === void 0 ? void 0 : _cell$p$body.filter((range) => range.rangeType === CustomRangeType.HYPERLINK)) !== null && _cell$p$body$customRa !== void 0 ? _cell$p$body$customRa : [];
69
+ if (ranges.length > 0) {
70
+ var _cell$p, _properties$url, _dataStream$slice$rep;
71
+ const dataStream = (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 ? void 0 : _cell$p.dataStream;
72
+ const { rangeId, properties, startIndex, endIndex } = ranges[0];
73
+ const url = (_properties$url = properties === null || properties === void 0 ? void 0 : properties.url) !== null && _properties$url !== void 0 ? _properties$url : "";
74
+ const label = (_dataStream$slice$rep = dataStream === null || dataStream === void 0 ? void 0 : dataStream.slice(startIndex, endIndex + 1).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "")) !== null && _dataStream$slice$rep !== void 0 ? _dataStream$slice$rep : "";
75
+ hyperlinks.push({
76
+ id: `${rangeId}`,
77
+ row,
78
+ column,
79
+ url,
80
+ label
81
+ });
82
+ }
83
+ });
84
+ return hyperlinks;
102
85
  }
103
- updateHyperLink(id, url, label) {
104
- const params = {
86
+ updateHyperLink(url, label) {
87
+ const hyperlink = this.getHyperLinks().find((link) => link.row === this._range.startRow && link.column === this._range.startColumn);
88
+ if (!hyperlink) return Promise.reject(/* @__PURE__ */ new Error("No hyperlink found in the top left cell of the range"));
89
+ const { id, row, column } = hyperlink;
90
+ return this._commandService.executeCommand(UpdateHyperLinkCommand.id, {
105
91
  unitId: this.getUnitId(),
106
92
  subUnitId: this._worksheet.getSheetId(),
107
- row: this._range.startRow,
108
- column: this._range.startColumn,
109
93
  id,
94
+ row,
95
+ column,
110
96
  payload: {
111
97
  payload: url,
112
98
  display: label
113
99
  }
114
- };
115
- return this._commandService.executeCommand(UpdateHyperLinkCommand.id, params);
100
+ });
116
101
  }
117
- cancelHyperLink(id) {
118
- const params = {
119
- unitId: this.getUnitId(),
120
- subUnitId: this._worksheet.getSheetId(),
121
- row: this._range.startRow,
122
- column: this._range.startColumn,
123
- id
124
- };
125
- return this._commandService.syncExecuteCommand(CancelHyperLinkCommand.id, params);
102
+ cancelHyperLink(hyperlink) {
103
+ if (hyperlink) {
104
+ const { id, row, column } = hyperlink;
105
+ return this._commandService.syncExecuteCommand(CancelHyperLinkCommand.id, {
106
+ unitId: this.getUnitId(),
107
+ subUnitId: this._worksheet.getSheetId(),
108
+ id,
109
+ row,
110
+ column
111
+ });
112
+ } else {
113
+ const hyperlinks = this.getHyperLinks();
114
+ if (hyperlinks.length === 0) return true;
115
+ return hyperlinks.every((link) => {
116
+ const { id, row, column } = link;
117
+ return this._commandService.syncExecuteCommand(CancelHyperLinkCommand.id, {
118
+ unitId: this.getUnitId(),
119
+ subUnitId: this._worksheet.getSheetId(),
120
+ id,
121
+ row,
122
+ column
123
+ });
124
+ });
125
+ }
126
126
  }
127
127
  getUrl() {
128
- return this._injector.get(SheetsHyperLinkParserService).buildHyperLink(this.getUnitId(), this.getSheetId(), this.getRange());
128
+ return this._injector.get(SheetsHyperLinkParserService).buildHyperLink(this.getRange(), this.getSheetId());
129
129
  }
130
130
  };
131
131
  FRange.extend(FRangeSheetsHyperlinkMixin);
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { AFTER_CELL_EDIT, ClearSelectionAllCommand, ClearSelectionContentCommand
4
4
  import { Subject } from "rxjs";
5
5
  import { IDefinedNamesService, deserializeRangeWithSheet, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
6
6
 
7
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
8
8
  function _typeof(o) {
9
9
  "@babel/helpers - typeof";
10
10
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +15,7 @@ function _typeof(o) {
15
15
  }
16
16
 
17
17
  //#endregion
18
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
19
19
  function toPrimitive(t, r) {
20
20
  if ("object" != _typeof(t) || !t) return t;
21
21
  var e = t[Symbol.toPrimitive];
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
28
28
  }
29
29
 
30
30
  //#endregion
31
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
32
32
  function toPropertyKey(t) {
33
33
  var i = toPrimitive(t, "string");
34
34
  return "symbol" == _typeof(i) ? i : i + "";
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
39
39
  function _defineProperty(e, r, t) {
40
40
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
41
  value: t,
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
50
50
  function __decorateParam(paramIndex, decorator) {
51
51
  return function(target, key) {
52
52
  decorator(target, key, paramIndex);
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
54
54
  }
55
55
 
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -705,7 +705,7 @@ const UpdateRichHyperLinkMutation = {
705
705
  //#endregion
706
706
  //#region package.json
707
707
  var name = "@univerjs/sheets-hyper-link";
708
- var version = "0.24.0";
708
+ var version = "0.25.0";
709
709
 
710
710
  //#endregion
711
711
  //#region src/config/config.ts
@@ -1455,8 +1455,11 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1455
1455
  this._localeService = _localeService;
1456
1456
  this._definedNamesService = _definedNamesService;
1457
1457
  }
1458
- buildHyperLink(unitId, sheetId, range) {
1459
- return `#${"gid"}=${sheetId}${range ? `&${typeof range === "string" ? "rangeid" : "range"}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1458
+ buildHyperLink(defineNameIdOrRange, sheetId) {
1459
+ if (typeof defineNameIdOrRange === "string") return `#${"rangeid"}=${defineNameIdOrRange}`;
1460
+ let result = `#${"gid"}=${sheetId}`;
1461
+ if (defineNameIdOrRange) result += `&${"range"}=${serializeRange(defineNameIdOrRange)}`;
1462
+ return result;
1460
1463
  }
1461
1464
  parseHyperLink(urlStr) {
1462
1465
  if (urlStr.startsWith("#")) {
@@ -1488,7 +1491,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1488
1491
  const workbook = unitid ? this._univerInstanceService.getUnit(unitid, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1489
1492
  const invalidLink = {
1490
1493
  type: "invalid",
1491
- name: this._localeService.t("hyperLink.message.refError")
1494
+ name: this._localeService.t("sheets-hyper-link.message.refError")
1492
1495
  };
1493
1496
  if (!workbook) return invalidLink;
1494
1497
  const sheet = gid ? workbook.getSheetBySheetId(gid) : workbook.getActiveSheet();
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ar-SA.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "نطاق غير صالح" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ca-ES.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Interval no vàlid" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/de-DE.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Ungültiger Bereich" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,20 @@
1
+ //#region src/locale/en-US.ts
2
+ /**
3
+ * Copyright 2023-present DreamNum Co., Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ const locale = { "sheets-hyper-link": { message: { refError: "Invalid Range" } } };
18
+
19
+ //#endregion
20
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/es-ES.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Rango no válido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/fa-IR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "محدوده نامعتبر" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/fr-FR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Plage invalide" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/id-ID.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Rentang Tidak Valid" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/it-IT.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Intervallo non valido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ja-JP.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "無効な範囲です" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ko-KR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "잘못된 범위입니다" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/pl-PL.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Nieprawidłowy zakres" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/pt-BR.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Intervalo Inválido" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/ru-RU.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Недопустимый диапазон" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/sk-SK.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Neplatný rozsah" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/vi-VN.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "Tham chiếu lỗi" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/zh-CN.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "错误的引用" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };
@@ -0,0 +1,5 @@
1
+ //#region src/locale/zh-HK.ts
2
+ const locale = { "sheets-hyper-link": { message: { refError: "錯誤的引用" } } };
3
+
4
+ //#endregion
5
+ export { locale as default };