@univerjs/sheets-hyper-link 0.21.1 → 0.22.0-insiders.20260513-0b53885

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,29 +1,42 @@
1
1
  # @univerjs/sheets-hyper-link
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@univerjs/sheets-hyper-link?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-hyper-link)
4
+ [![license](https://img.shields.io/npm/l/@univerjs/sheets-hyper-link?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-hyper-link)
5
+ [![downloads](https://img.shields.io/npm/dm/@univerjs/sheets-hyper-link?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-hyper-link)
6
+
7
+ `@univerjs/sheets-hyper-link` adds the core hyperlink model, commands, and sheet-specific services for Univer Sheets.
8
+
3
9
  ## Package Overview
4
10
 
5
- | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
- | --- | --- | --- | --- | --- | :---: | :---: |
7
- | `@univerjs/sheets-hyper-link` | `UniverSheetsHyperLink` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
11
+ | Package | UMD global | CSS | Locales | Facade entry |
12
+ | --- | --- | :---: | :---: | :---: |
13
+ | `@univerjs/sheets-hyper-link` | `UniverSheetsHyperLink` | No | No | Yes |
8
14
 
9
- ## Introduction
15
+ ## Installation
10
16
 
11
- A internal package for `@univerjs/sheets-hyper-link-ui`, for using hyper-link feature please refer to `@univerjs/sheets-hyper-link-ui`.
17
+ ```sh
18
+ pnpm add @univerjs/sheets-hyper-link
19
+ # or
20
+ npm install @univerjs/sheets-hyper-link
21
+ ```
22
+
23
+ Keep all `@univerjs/*` packages on the same version.
12
24
 
13
25
  ## Usage
14
26
 
15
- ### Installation
27
+ ```ts
28
+ import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';
16
29
 
17
- ```shell
18
- # Using npm
19
- npm install @univerjs/sheets-hyper-link
20
-
21
- # Using pnpm
22
- pnpm add @univerjs/sheets-hyper-link
30
+ univer.registerPlugin(UniverSheetsHyperLinkPlugin);
23
31
  ```
24
32
 
25
- <!-- Links -->
26
- [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-hyper-link?style=flat-square
27
- [npm-version-link]: https://npmjs.com/package/@univerjs/sheets-hyper-link
28
- [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-hyper-link?style=flat-square
29
- [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-hyper-link?style=flat-square
33
+ ## Integration Notes
34
+
35
+ Use this package with `@univerjs/sheets-hyper-link-ui` when users need hyperlink editing UI.
36
+
37
+ ## Resources
38
+
39
+ - [Documentation](https://docs.univer.ai)
40
+ - [NPM package](https://npmjs.com/package/@univerjs/sheets-hyper-link)
41
+ - [GitHub repository](https://github.com/dream-num/univer)
42
+
package/lib/cjs/facade.js CHANGED
@@ -4,7 +4,7 @@ let _univerjs_sheets_hyper_link = require("@univerjs/sheets-hyper-link");
4
4
  let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
5
5
  let _univerjs_core_facade = require("@univerjs/core/facade");
6
6
 
7
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
7
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
8
8
  function __decorateParam(paramIndex, decorator) {
9
9
  return function(target, key) {
10
10
  decorator(target, key, paramIndex);
@@ -12,7 +12,7 @@ function __decorateParam(paramIndex, decorator) {
12
12
  }
13
13
 
14
14
  //#endregion
15
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
15
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
16
16
  function __decorate(decorators, target, key, desc) {
17
17
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18
18
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/cjs/index.js CHANGED
@@ -5,7 +5,7 @@ let _univerjs_sheets = require("@univerjs/sheets");
5
5
  let rxjs = require("rxjs");
6
6
  let _univerjs_engine_formula = require("@univerjs/engine-formula");
7
7
 
8
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
8
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
9
9
  function _typeof(o) {
10
10
  "@babel/helpers - typeof";
11
11
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -16,7 +16,7 @@ function _typeof(o) {
16
16
  }
17
17
 
18
18
  //#endregion
19
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
19
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
20
20
  function toPrimitive(t, r) {
21
21
  if ("object" != _typeof(t) || !t) return t;
22
22
  var e = t[Symbol.toPrimitive];
@@ -29,14 +29,14 @@ function toPrimitive(t, r) {
29
29
  }
30
30
 
31
31
  //#endregion
32
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
32
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
33
33
  function toPropertyKey(t) {
34
34
  var i = toPrimitive(t, "string");
35
35
  return "symbol" == _typeof(i) ? i : i + "";
36
36
  }
37
37
 
38
38
  //#endregion
39
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
39
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
40
40
  function _defineProperty(e, r, t) {
41
41
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
42
  value: t,
@@ -47,7 +47,7 @@ function _defineProperty(e, r, t) {
47
47
  }
48
48
 
49
49
  //#endregion
50
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
50
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
51
51
  function __decorateParam(paramIndex, decorator) {
52
52
  return function(target, key) {
53
53
  decorator(target, key, paramIndex);
@@ -55,7 +55,7 @@ function __decorateParam(paramIndex, decorator) {
55
55
  }
56
56
 
57
57
  //#endregion
58
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
58
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
59
59
  function __decorate(decorators, target, key, desc) {
60
60
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
61
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -600,7 +600,7 @@ const UpdateHyperLinkCommand = {
600
600
  }
601
601
  });
602
602
  }
603
- if ((0, _univerjs_core.sequenceExecute)(redos, commandService)) {
603
+ if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
604
604
  if (await interceptorService.onValidateCell(workbook, worksheet, row, column) === false) {
605
605
  (0, _univerjs_core.sequenceExecute)(undos, commandService);
606
606
  return false;
@@ -706,7 +706,7 @@ const UpdateRichHyperLinkMutation = {
706
706
  //#endregion
707
707
  //#region package.json
708
708
  var name = "@univerjs/sheets-hyper-link";
709
- var version = "0.21.1";
709
+ var version = "0.22.0-insiders.20260513-0b53885";
710
710
 
711
711
  //#endregion
712
712
  //#region src/config/config.ts
@@ -1457,7 +1457,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1457
1457
  this._definedNamesService = _definedNamesService;
1458
1458
  }
1459
1459
  buildHyperLink(unitId, sheetId, range) {
1460
- return `#${SheetHyperLinkType.SHEET}=${sheetId}${range ? `&${typeof range === "string" ? SheetHyperLinkType.DEFINE_NAME : SheetHyperLinkType.RANGE}=${typeof range === "string" ? range : (0, _univerjs_engine_formula.serializeRange)(range)}` : ""}`;
1460
+ return `#${"gid"}=${sheetId}${range ? `&${typeof range === "string" ? "rangeid" : "range"}=${typeof range === "string" ? range : (0, _univerjs_engine_formula.serializeRange)(range)}` : ""}`;
1461
1461
  }
1462
1462
  parseHyperLink(urlStr) {
1463
1463
  if (urlStr.startsWith("#")) {
@@ -1477,7 +1477,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1477
1477
  searchObj
1478
1478
  };
1479
1479
  } else return {
1480
- type: SheetHyperLinkType.URL,
1480
+ type: "url",
1481
1481
  name: urlStr,
1482
1482
  url: urlStr,
1483
1483
  searchObj: null
@@ -1488,7 +1488,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1488
1488
  const { gid, range, rangeid, unitid } = params;
1489
1489
  const workbook = unitid ? this._univerInstanceService.getUnit(unitid, _univerjs_core.UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1490
1490
  const invalidLink = {
1491
- type: SheetHyperLinkType.INVALID,
1491
+ type: "invalid",
1492
1492
  name: this._localeService.t("hyperLink.message.refError")
1493
1493
  };
1494
1494
  if (!workbook) return invalidLink;
@@ -1498,7 +1498,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1498
1498
  if (!sheet) return invalidLink;
1499
1499
  const rangeObj = (0, _univerjs_engine_formula.deserializeRangeWithSheet)(range).range;
1500
1500
  if ((0, _univerjs_core.isValidRange)(rangeObj, sheet) && range !== "err") return {
1501
- type: SheetHyperLinkType.RANGE,
1501
+ type: "range",
1502
1502
  name: (0, _univerjs_engine_formula.serializeRangeWithSheet)(sheetName, rangeObj)
1503
1503
  };
1504
1504
  return invalidLink;
@@ -1506,7 +1506,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1506
1506
  if (rangeid) {
1507
1507
  const range = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
1508
1508
  if (range) return {
1509
- type: SheetHyperLinkType.DEFINE_NAME,
1509
+ type: "rangeid",
1510
1510
  name: range.formulaOrRefString
1511
1511
  };
1512
1512
  return invalidLink;
@@ -1514,7 +1514,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1514
1514
  if (gid) {
1515
1515
  const worksheet = workbook.getSheetBySheetId(gid);
1516
1516
  if (worksheet) return {
1517
- type: SheetHyperLinkType.SHEET,
1517
+ type: "gid",
1518
1518
  name: worksheet.getName()
1519
1519
  };
1520
1520
  return invalidLink;
package/lib/es/facade.js CHANGED
@@ -3,7 +3,7 @@ import { AddHyperLinkCommand, CancelHyperLinkCommand, SheetsHyperLinkParserServi
3
3
  import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
4
4
  import { FEventName, FUniver } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
6
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
7
7
  function __decorateParam(paramIndex, decorator) {
8
8
  return function(target, key) {
9
9
  decorator(target, key, paramIndex);
@@ -11,7 +11,7 @@ function __decorateParam(paramIndex, decorator) {
11
11
  }
12
12
 
13
13
  //#endregion
14
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
14
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
15
15
  function __decorate(decorators, target, key, desc) {
16
16
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
17
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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.124.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/decorateParam.js
49
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/decorate.js
57
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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);
@@ -599,7 +599,7 @@ const UpdateHyperLinkCommand = {
599
599
  }
600
600
  });
601
601
  }
602
- if (sequenceExecute(redos, commandService)) {
602
+ if (sequenceExecute(redos, commandService).result) {
603
603
  if (await interceptorService.onValidateCell(workbook, worksheet, row, column) === false) {
604
604
  sequenceExecute(undos, commandService);
605
605
  return false;
@@ -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.21.1";
708
+ var version = "0.22.0-insiders.20260513-0b53885";
709
709
 
710
710
  //#endregion
711
711
  //#region src/config/config.ts
@@ -1456,7 +1456,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1456
1456
  this._definedNamesService = _definedNamesService;
1457
1457
  }
1458
1458
  buildHyperLink(unitId, sheetId, range) {
1459
- return `#${SheetHyperLinkType.SHEET}=${sheetId}${range ? `&${typeof range === "string" ? SheetHyperLinkType.DEFINE_NAME : SheetHyperLinkType.RANGE}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1459
+ return `#${"gid"}=${sheetId}${range ? `&${typeof range === "string" ? "rangeid" : "range"}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1460
1460
  }
1461
1461
  parseHyperLink(urlStr) {
1462
1462
  if (urlStr.startsWith("#")) {
@@ -1476,7 +1476,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1476
1476
  searchObj
1477
1477
  };
1478
1478
  } else return {
1479
- type: SheetHyperLinkType.URL,
1479
+ type: "url",
1480
1480
  name: urlStr,
1481
1481
  url: urlStr,
1482
1482
  searchObj: null
@@ -1487,7 +1487,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1487
1487
  const { gid, range, rangeid, unitid } = params;
1488
1488
  const workbook = unitid ? this._univerInstanceService.getUnit(unitid, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1489
1489
  const invalidLink = {
1490
- type: SheetHyperLinkType.INVALID,
1490
+ type: "invalid",
1491
1491
  name: this._localeService.t("hyperLink.message.refError")
1492
1492
  };
1493
1493
  if (!workbook) return invalidLink;
@@ -1497,7 +1497,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1497
1497
  if (!sheet) return invalidLink;
1498
1498
  const rangeObj = deserializeRangeWithSheet(range).range;
1499
1499
  if (isValidRange(rangeObj, sheet) && range !== "err") return {
1500
- type: SheetHyperLinkType.RANGE,
1500
+ type: "range",
1501
1501
  name: serializeRangeWithSheet(sheetName, rangeObj)
1502
1502
  };
1503
1503
  return invalidLink;
@@ -1505,7 +1505,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1505
1505
  if (rangeid) {
1506
1506
  const range = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
1507
1507
  if (range) return {
1508
- type: SheetHyperLinkType.DEFINE_NAME,
1508
+ type: "rangeid",
1509
1509
  name: range.formulaOrRefString
1510
1510
  };
1511
1511
  return invalidLink;
@@ -1513,7 +1513,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1513
1513
  if (gid) {
1514
1514
  const worksheet = workbook.getSheetBySheetId(gid);
1515
1515
  if (worksheet) return {
1516
- type: SheetHyperLinkType.SHEET,
1516
+ type: "gid",
1517
1517
  name: worksheet.getName()
1518
1518
  };
1519
1519
  return invalidLink;
package/lib/facade.js CHANGED
@@ -3,7 +3,7 @@ import { AddHyperLinkCommand, CancelHyperLinkCommand, SheetsHyperLinkParserServi
3
3
  import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
4
4
  import { FEventName, FUniver } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
6
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
7
7
  function __decorateParam(paramIndex, decorator) {
8
8
  return function(target, key) {
9
9
  decorator(target, key, paramIndex);
@@ -11,7 +11,7 @@ function __decorateParam(paramIndex, decorator) {
11
11
  }
12
12
 
13
13
  //#endregion
14
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
14
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
15
15
  function __decorate(decorators, target, key, desc) {
16
16
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
17
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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.124.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/decorateParam.js
49
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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.124.0/helpers/decorate.js
57
+ //#region \0@oxc-project+runtime@0.129.0/helpers/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);
@@ -599,7 +599,7 @@ const UpdateHyperLinkCommand = {
599
599
  }
600
600
  });
601
601
  }
602
- if (sequenceExecute(redos, commandService)) {
602
+ if (sequenceExecute(redos, commandService).result) {
603
603
  if (await interceptorService.onValidateCell(workbook, worksheet, row, column) === false) {
604
604
  sequenceExecute(undos, commandService);
605
605
  return false;
@@ -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.21.1";
708
+ var version = "0.22.0-insiders.20260513-0b53885";
709
709
 
710
710
  //#endregion
711
711
  //#region src/config/config.ts
@@ -1456,7 +1456,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1456
1456
  this._definedNamesService = _definedNamesService;
1457
1457
  }
1458
1458
  buildHyperLink(unitId, sheetId, range) {
1459
- return `#${SheetHyperLinkType.SHEET}=${sheetId}${range ? `&${typeof range === "string" ? SheetHyperLinkType.DEFINE_NAME : SheetHyperLinkType.RANGE}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1459
+ return `#${"gid"}=${sheetId}${range ? `&${typeof range === "string" ? "rangeid" : "range"}=${typeof range === "string" ? range : serializeRange(range)}` : ""}`;
1460
1460
  }
1461
1461
  parseHyperLink(urlStr) {
1462
1462
  if (urlStr.startsWith("#")) {
@@ -1476,7 +1476,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1476
1476
  searchObj
1477
1477
  };
1478
1478
  } else return {
1479
- type: SheetHyperLinkType.URL,
1479
+ type: "url",
1480
1480
  name: urlStr,
1481
1481
  url: urlStr,
1482
1482
  searchObj: null
@@ -1487,7 +1487,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1487
1487
  const { gid, range, rangeid, unitid } = params;
1488
1488
  const workbook = unitid ? this._univerInstanceService.getUnit(unitid, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1489
1489
  const invalidLink = {
1490
- type: SheetHyperLinkType.INVALID,
1490
+ type: "invalid",
1491
1491
  name: this._localeService.t("hyperLink.message.refError")
1492
1492
  };
1493
1493
  if (!workbook) return invalidLink;
@@ -1497,7 +1497,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1497
1497
  if (!sheet) return invalidLink;
1498
1498
  const rangeObj = deserializeRangeWithSheet(range).range;
1499
1499
  if (isValidRange(rangeObj, sheet) && range !== "err") return {
1500
- type: SheetHyperLinkType.RANGE,
1500
+ type: "range",
1501
1501
  name: serializeRangeWithSheet(sheetName, rangeObj)
1502
1502
  };
1503
1503
  return invalidLink;
@@ -1505,7 +1505,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1505
1505
  if (rangeid) {
1506
1506
  const range = this._definedNamesService.getValueById(workbook.getUnitId(), rangeid);
1507
1507
  if (range) return {
1508
- type: SheetHyperLinkType.DEFINE_NAME,
1508
+ type: "rangeid",
1509
1509
  name: range.formulaOrRefString
1510
1510
  };
1511
1511
  return invalidLink;
@@ -1513,7 +1513,7 @@ let SheetsHyperLinkParserService = class SheetsHyperLinkParserService {
1513
1513
  if (gid) {
1514
1514
  const worksheet = workbook.getSheetBySheetId(gid);
1515
1515
  if (worksheet) return {
1516
- type: SheetHyperLinkType.SHEET,
1516
+ type: "gid",
1517
1517
  name: worksheet.getName()
1518
1518
  };
1519
1519
  return invalidLink;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/docs`),require(`@univerjs/sheets`),require(`rxjs`),require(`@univerjs/engine-formula`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLink={},e.UniverCore,e.UniverDocs,e.UniverSheets,e.rxjs,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends t.Disposable{constructor(e){super(),this._univerInstanceService=e,l(this,`_linkUpdate$`,new i.Subject),l(this,`linkUpdate$`,this._linkUpdate$.asObservable()),l(this,`_linkMap`,new Map),l(this,`_linkPositionMap`,new Map),this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let i=r.get(n);i||(i=new t.ObjectMatrix,r.set(n,i));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let o=a.get(n);return o||(o=new Map,a.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t);return r.setValue(n.row,n.column,n),i.set(n.id,{row:n.row,column:n.column,link:n}),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:n,type:`add`}),!0}updateHyperLink(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return c?(Object.assign(c,r),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:{display:c.display,payload:c.payload},id:n,type:`update`,silent:i}),!0):!0}updateHyperLinkRef(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return!c||c.id!==n?c=s.link:a.realDeleteValue(s.row,s.column),Object.assign(c,r),o.set(n,{...r,link:c}),a.setValue(r.row,r.column,c),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:r,id:n,type:`updateRef`,silent:i}),!0}removeHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(!a)return!1;i.delete(n);let o=r.getValue(a.row,a.column);return o&&o.id===n&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:a.link,type:`remove`}),!0}getHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,t,n,r){let{matrix:i}=this._ensureMap(e,t);return i.getValue(n,r)}getHyperLinkByLocationSync(e,n,r,i){var a,o,s,c;let{matrix:l}=this._ensureMap(e,n),u=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),d=u==null||(a=u.getSheetBySheetId(n))==null?void 0:a.getCellRaw(r,i),f=((o=(s=d==null?void 0:d.v)==null?d==null||(c=d.p)==null||(c=c.body)==null?void 0:c.dataStream.slice(0,-2):s)==null?``:o).toString(),p=l.getValue(r,i);if(p)return{...p,display:f}}getSubUnit(e,t){let{matrix:n}=this._ensureMap(e,t),r=[];return n.forValue((e,t,n)=>{n&&r.push(n)}),r}getUnit(e){let t=this._linkMap.get(e);return t?Array.from(t.keys()).map(t=>({unitId:e,subUnitId:t,links:this.getSubUnit(e,t)})):[]}deleteUnit(e){let t=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:`unload`,unitId:e,unitLinks:t})}getAll(){return Array.from(this._linkMap.keys()).map(e=>this.getUnit(e))}};f=d([u(0,t.IUniverInstanceService)],f);let p={type:t.CommandType.MUTATION,id:`sheets.mutation.add-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,link:a}=t;return n.addHyperLink(r,i,a)}},m={type:t.CommandType.MUTATION,id:`sheets.mutation.remove-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a}=t;return n.removeHyperLink(r,i,a)}},h={type:t.CommandType.COMMAND,id:`sheets.command.add-hyper-link`,async handler(e,n){if(!n)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(t.IUniverInstanceService),s=e.get(f),c=e.get(r.SheetInterceptorService),l=(0,r.getSheetCommandTarget)(o,n);if(!l)return!1;let{unitId:u,subUnitId:d,workbook:h,worksheet:g}=l,{link:_}=n,{payload:v,display:y,row:b,column:x,id:S}=_,C=g.getCell(b,x),w=g.getBlankCellDocumentModel(C,b,x),T=w.documentModel.getSnapshot(),E=t.Tools.deepClone(T.body);if(!E)return!1;let D;if(D=y?t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:E.dataStream.length-2,collapsed:E.dataStream.length-2==0},body:{dataStream:`${y}`,customRanges:[{startIndex:0,endIndex:y.length-1,rangeType:t.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:v}}]},doc:w.documentModel}):t.BuildTextUtils.customRange.add({body:E,ranges:[{startOffset:0,endOffset:E.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:v,refId:S}}),!D)return!1;let O=t.TextX.apply(E,D.serialize()),k={p:{...T,body:O},t:t.CellValueType.STRING},A=c.onWriteCell(h,g,b,x,k),j={unitId:u,subUnitId:d,cellValue:{[_.row]:{[_.column]:A}}},M={id:r.SetRangeValuesMutation.id,params:j},N=(0,r.SetRangeValuesUndoMutationFactory)(e,j),P={id:r.SetRangeValuesMutation.id,params:N},F=[M],I=[P],L=s.getHyperLinkByLocation(u,d,b,x);return L&&(F.push({id:m.id,params:{unitId:u,subUnitId:d,id:L.id}}),I.push({id:p.id,params:{unitId:u,subUnitId:d,link:L}})),await(0,t.sequenceExecute)(F,i)?await c.onValidateCell(h,g,b,x)===!1?((0,t.sequenceExecute)(I,i),!1):(a.pushUndoRedo({redoMutations:F,undoMutations:I,unitID:u}),!0):!1}},g={id:`sheets.command.add-rich-hyper-link`,type:t.CommandType.COMMAND,handler:async(e,r)=>{if(!r)return!1;let{documentId:i,link:a}=r,o=e.get(t.ICommandService),s=(0,t.generateRandomId)(),{payload:c}=a,l=(0,n.addCustomRangeBySelectionFactory)(e,{unitId:i,rangeId:s,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c,refId:s}});return l?o.syncExecuteCommand(l.id,l.params):!1}},_={type:t.CommandType.COMMAND,id:`sheets.command.cancel-hyper-link`,handler(e,n){var i;if(!n)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),c=e.get(f),l=(0,r.getSheetCommandTarget)(s,n);if(!l)return!1;let{row:u,column:d,id:h}=n,{unitId:g,subUnitId:_,worksheet:v}=l,y=v.getCell(u,d);if(!y)return!1;let b=v.getCellDocumentModelWithFormula(y,u,d);if(!(b!=null&&b.documentModel))return!1;let x=t.Tools.deepClone(b.documentModel.getSnapshot()),S=(i=x.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>`${e.rangeId}`===h);if(!S)return!1;let C=t.BuildTextUtils.customRange.delete({documentDataModel:b.documentModel,rangeId:S.rangeId});if(!C)return!1;let w=t.TextX.apply(x.body,C.serialize()),T=[],E=[],D={unitId:g,subUnitId:_,cellValue:{[u]:{[d]:{p:{...x,body:w},t:t.CellValueType.STRING}}}};T.push({id:r.SetRangeValuesMutation.id,params:D});let O=(0,r.SetRangeValuesUndoMutationFactory)(e,D);E.push({id:r.SetRangeValuesMutation.id,params:O});let k=c.getHyperLinkByLocation(g,_,u,d);return k&&(T.push({id:m.id,params:{unitId:g,subUnitId:_,id:k.id}}),E.push({id:p.id,params:{unitId:g,subUnitId:_,link:{...k}}})),(0,t.sequenceExecute)(T,a).result?(o.pushUndoRedo({redoMutations:T,undoMutations:E,unitID:g}),!0):!1}},v={type:t.CommandType.COMMAND,id:`sheets.command.cancel-rich-hyper-link`,handler(e,r){var i;if(!r)return!1;let{id:a,documentId:o}=r,s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getUnit(o,t.UniverInstanceType.UNIVER_DOC),l=c==null||(i=c.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===a),u=null;l&&l.endIndex===c.getBody().dataStream.length-3&&(u={dataStream:` `});let d=(0,n.deleteCustomRangeFactory)(e,{unitId:o,rangeId:a,insert:u});return d?s.syncExecuteCommand(d.id,d.params):!1}},y={type:t.CommandType.COMMAND,id:`sheets.command.update-hyper-link`,async handler(e,i){var a,o;if(!i)return!1;let s=e.get(t.ICommandService),c=e.get(t.IUndoRedoService),l=e.get(t.IUniverInstanceService),u=e.get(f),d=e.get(r.SheetInterceptorService),h=(0,r.getSheetCommandTarget)(l,{unitId:i.unitId,subUnitId:i.subUnitId});if(!h)return!1;let{payload:g,row:_,column:v,id:y}=i,{workbook:b,worksheet:x,unitId:S,subUnitId:C}=h,{payload:w,display:T=``}=g,E=x.getCell(_,v);if(!E)return!1;let D=x.getCellDocumentModelWithFormula(E,_,v);if(!(D!=null&&D.documentModel))return!1;let O=D.documentModel.getSnapshot(),k=(a=O.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>`${e.rangeId}`===y);if(!k)return!1;let A=(0,t.generateRandomId)(),j=(o=(0,t.getBodySlice)(D.documentModel.getBody(),k.startIndex,k.endIndex+1).textRuns)==null?void 0:o[0];j&&(j.ed=T.length+1);let M=(0,n.replaceSelectionFactory)(e,{unitId:S,body:{dataStream:`${T}`,customRanges:[{rangeId:A,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:T.length-1,properties:{url:w}}],textRuns:j?[j]:void 0},selection:{startOffset:k.startIndex,endOffset:k.endIndex+1,collapsed:!1},doc:D.documentModel});if(!M)return!1;let N=t.TextX.apply(t.Tools.deepClone(O.body),M.textX.serialize()),P={p:{...O,body:N},t:t.CellValueType.STRING},F=d.onWriteCell(b,x,_,v,P),I={id:r.SetRangeValuesMutation.id,params:{unitId:S,subUnitId:C,cellValue:{[_]:{[v]:F}}}},L=(0,r.SetRangeValuesUndoMutationFactory)(e,I.params),R={id:r.SetRangeValuesMutation.id,params:L},z=[I],B=[R],V=u.getHyperLinkByLocation(S,C,_,v);return V&&(z.push({id:m.id,params:{unitId:S,subUnitId:C,id:V.id}}),B.push({id:p.id,params:{unitId:S,subUnitId:C,link:V}})),(0,t.sequenceExecute)(z,s)?await d.onValidateCell(b,x,_,v)===!1?((0,t.sequenceExecute)(B,s),!1):(c.pushUndoRedo({redoMutations:z,undoMutations:B,unitID:S}),!0):!1}},b={type:t.CommandType.COMMAND,id:`sheets.command.update-rich-hyper-link`,handler:(e,r)=>{var i,a,o;if(!r)return!1;let{documentId:s,payload:c,id:l}=r,u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=u.getUnit(s,t.UniverInstanceType.UNIVER_DOC);if(!f)return!1;let p=(i=f.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===l);if(!p)return!1;let m=(a=r.payload.display)==null?``:a,h=(0,t.generateRandomId)(),g=(o=(0,t.getBodySlice)(f.getBody(),p.startIndex,p.endIndex+1).textRuns)==null?void 0:o[0];g&&(g.ed=m.length+1);let _=(0,n.replaceSelectionFactory)(e,{unitId:s,body:{dataStream:`${m}`,customRanges:[{rangeId:h,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:m.length-1,properties:{url:c.payload}}],textRuns:g?[g]:void 0},selection:{startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},doc:f});return _?d.syncExecuteCommand(_.id,_.params):!1}},x={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,payload:a,id:o}=t;return n.updateHyperLink(r,i,o,a,!1)}},S={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link-ref`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a,row:o,column:s,silent:c}=t;return n.updateHyperLinkRef(r,i,a,{row:o,column:s},c)}},C={type:t.CommandType.MUTATION,id:`sheets.mutation.update-rich-hyper-link`,handler(e,n){var i;if(!n)return!1;let{unitId:a,subUnitId:o,row:s,col:c,id:l,url:u}=n,d=(0,r.getSheetCommandTarget)(e.get(t.IUniverInstanceService),{unitId:a,subUnitId:o});if(!d)return!1;let{worksheet:f}=d,p=f.getCellRaw(s,c),m=p==null||(i=p.p)==null||(i=i.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeType===t.CustomRangeType.HYPERLINK&&e.rangeId===l);return m&&(m.properties.url=u),!0}};var w=`@univerjs/sheets-hyper-link`,T=`0.21.1`;let E=`sheets-hyper-link.config`;Symbol(E);let D={},O=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._commandService=r,l(this,`_disposableMap`,new Map),l(this,`_watchDisposableMap`,new Map),l(this,`_rangeDisableMap`,new Map),l(this,`_rangeWatcherMap`,new Map),l(this,`_handlePositionChange`,(e,t,n,r,i)=>{let a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:m.id,params:{unitId:e,subUnitId:t,id:n.id}}],undos:[{id:p.id,params:{unitId:e,subUnitId:t,link:n}}]}}),this._initData(),this._initRefRange()}_registerPosition(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(i,this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,t,n,s,!1)},e,t))}_watchPosition(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handlePositionChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){let t=this._disposableMap.get(e);t==null||t.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){let t=this._watchDisposableMap.get(e);t==null||t.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,i,o=!1){if(i.startsWith(`#`)){var s,c,l;let u=new URLSearchParams(i.slice(1)),d={gid:(s=u.get(`gid`))==null?``:s,range:(c=u.get(`range`))==null?``:c,rangeid:(l=u.get(`rangeid`))==null?``:l};if(d.range&&d.gid){let s=d.gid,c=(0,a.deserializeRangeWithSheet)(d.range).range;(0,t.isValidRange)(c)&&d.range!==`err`&&(this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(c,t=>{let o=(0,r.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests)(c,t,{selectionManagerService:this._selectionManagerService});return o&&(0,a.serializeRange)(o)===(0,a.serializeRange)(c)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:`#gid=${s}&range=${o?(0,a.serializeRange)(o):`err`}`}}}],undos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:i}}}]}},e,s)),o||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,s,c,(t,r)=>{this._hyperLinkModel.updateHyperLink(e,s,n,{payload:`#gid=${s}&range=${r?(0,a.serializeRange)(r):`err`}`},!0)},!0)))}}}_unregisterRange(e){let t=this._rangeDisableMap.get(e);t==null||t.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){let t=this._rangeWatcherMap.get(e);t==null||t.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,links:r}=e;r.forEach(e=>{this._registerPosition(t,n,e),this._watchPosition(t,n,e),this._registerRange(t,e.id,e.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case`add`:this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break;case`remove`:this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break;case`updateRef`:{let{unitId:t,subUnitId:n,id:r,silent:i}=e,a=this._hyperLinkModel.getHyperLink(t,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(t,n,a),i||(this._unwatchPosition(r),this._watchPosition(t,n,a));break}case`unload`:{let{unitLinks:t}=e;t.forEach(e=>{let{links:t}=e;t.forEach(e=>{this._unregisterPosition(e.id),this._unwatchPosition(e.id),this._unregisterRange(e.id),this._unwatchRange(e.id)})});break}case`update`:e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};O=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.ICommandService)],O);let k=class extends t.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return{redos:[],undos:[]};let a=i.getUnitId(),o=r.subUnitId||((n=i.getActiveSheet())==null?void 0:n.getSheetId());if(!o)return{redos:[],undos:[]};let s=this._hyperLinkModel.getSubUnit(a,o);return{redos:s.map(e=>({id:m.id,params:{unitId:a,subUnitId:o,id:e.id}})),undos:s.map(e=>({id:p.id,params:{unitId:a,subUnitId:o,link:e}}))}}return{redos:[],undos:[]}}}))}};k=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],k);let A=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._refRangeService=n,l(this,`_refRangeMap`,new Map),this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(e,n){let r=this._refRangeMap.get(e);r||(r=new Map,this._refRangeMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_isLegalRangeUrl(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!r)return null;if(n&&n.startsWith(`#`)){var i,o,s;let e=new URLSearchParams(n.slice(1)),c={gid:(i=e.get(`gid`))==null?``:i,range:(o=e.get(`range`))==null?``:o,rangeid:(s=e.get(`rangeid`))==null?``:s};if(c.range&&c.gid){let e=c.gid,n=r.getSheetBySheetId(e);if(!n)return null;let i=(0,a.deserializeRangeWithSheet)(c.range).range;if((0,t.isValidRange)(i,n)&&c.range!==`err`)return{range:i,worksheet:n}}}return null}_registerRange(e,n,i,o,s){var c;let l=this._enusreMap(e,n);if(!((c=s.body)==null||(c=c.customRanges)==null)&&c.some(n=>{var r;return n.rangeType===t.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(e,(r=n.properties)==null?void 0:r.url)})){var u;let c=new t.DisposableCollection,d=!1;(u=s.body)==null||(u=u.customRanges)==null||u.forEach(s=>{if(s.rangeType===t.CustomRangeType.HYPERLINK){var l;let u=(l=s.properties)==null?void 0:l.url,f=this._isLegalRangeUrl(e,u);if(f){let{range:l,worksheet:p}=f;d=!0,c.add(this._refRangeService.registerRefRange(l,c=>{let d=(0,r.handleDefaultRangeChangeWithEffectRefCommands)(l,c);return d&&t.Rectangle.equals(d,l)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:`#gid=${n}&range=${d?(0,a.serializeRange)(d):`err`}`}}],undos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:u}}],redos:[]}},p.getUnitId(),p.getSheetId()))}}}),d&&l.setValue(i,o,c)}}_initWorkbookLoad(){let e=e=>{let t=e.getUnitId();e.getSheets().forEach(e=>{let n=e.getSheetId(),r=this._enusreMap(t,n);e.getCellMatrix().forValue((e,i,a)=>{let o=r.getValue(e,i);o&&o.dispose(),a&&a.p&&this._registerRange(t,n,e,i,a.p)})})};this._univerInstanceService.getAllUnitsForType(t.UniverInstanceType.UNIVER_SHEET).forEach(t=>{e(t)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(n=>{let{unit:r}=n;r.type===t.UniverInstanceType.UNIVER_SHEET&&e(r)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{if(e.type===t.UniverInstanceType.UNIVER_SHEET){let t=e,n=t.getUnitId();t.getSheets().forEach(e=>{let t=e.getSheetId();this._enusreMap(n,t).forValue((e,t,n)=>{n&&n.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===r.SetRangeValuesMutation.id){let{unitId:n,subUnitId:r,cellValue:i}=e.params,a=this._enusreMap(n,r);i&&new t.ObjectMatrix(i).forValue((e,t,i)=>{let o=a.getValue(e,t);o&&o.dispose(),i&&i.p&&this._registerRange(n,r,e,t,i.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.id){let{unitId:t,subUnitId:n,row:i,col:a}=e.params,o=(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:t,subUnitId:n}),s=this._enusreMap(t,n).getValue(i,a);if(s&&s.dispose(),o){let{worksheet:e}=o,r=e.getCellRaw(i,a);r&&r.p&&this._registerRange(t,n,i,a,r.p)}}}))}};A=d([u(0,t.ICommandService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.RefRangeService))],A);let j=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._univerInstanceService=r,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.SetRangeValuesCommand.id){let n=e.params,{unitId:r,subUnitId:i}=n,a=[],o=[];return n.cellValue&&new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{let n=this._hyperLinkModel.getHyperLinkByLocation(r,i,e,t);n&&(a.push({id:m.id,params:{unitId:r,subUnitId:i,id:n.id}}),o.push({id:p.id,params:{unitId:r,subUnitId:i,link:n}}))}),{undos:o,redos:a}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.ClearSelectionContentCommand.id||e.id===r.ClearSelectionAllCommand.id||e.id===r.ClearSelectionFormatCommand.id){let n=[],i=[],a=this._selectionManagerService.getCurrentLastSelection(),o=(0,r.getSheetCommandTarget)(this._univerInstanceService,e.params);if(a&&o){let{unitId:e,subUnitId:r}=o;t.Range.foreach(a.range,(t,a)=>{let o=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,a);o&&(n.push({id:m.id,params:{unitId:e,subUnitId:r,id:o.id}}),i.push({id:p.id,params:{unitId:e,subUnitId:r,link:o}}))})}return{redos:n,undos:i}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.AFTER_CELL_EDIT,{handler:(e,n,r)=>{if(!e||e.p)return r(e);if(typeof e.v==`string`&&t.Tools.isLegalUrl(e.v)&&e.v[e.v.length-1]!==` `){let{unitId:i,subUnitId:a,row:o,col:s}=n,c=t.Tools.normalizeUrl(e.v),l=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),u=l==null?void 0:l.getSheetBySheetId(a);if(!u)return r(e);let d=u.getBlankCellDocumentModel(e,o,s);if(!d.documentModel)return r(e);let f=t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:e.v.length,collapsed:!1},body:{dataStream:`${e.v}`,customRanges:[{startIndex:0,endIndex:e.v.length-1,rangeId:(0,t.generateRandomId)(),rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c}}]},doc:d.documentModel});if(!f)return r(e);let p=d.documentModel.getBody();return t.TextX.apply(p,f.serialize()),r({...e,p:{id:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return r(e)}}))}};j=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.IUniverInstanceService)],j);let M=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._registerCommands()}_registerCommands(){[h,y,_,b,v,g,p,x,m,S,C].forEach(e=>{this._commandService.registerCommand(e)})}};M=d([u(0,t.ICommandService)],M);let N=function(e){return e.SHEET=`gid`,e.RANGE=`range`,e.DEFINE_NAME=`rangeid`,e.INVALID=`invalid`,e.URL=`url`,e}({}),P=class{constructor(e,t,n){this._univerInstanceService=e,this._localeService=t,this._definedNamesService=n}buildHyperLink(e,t,n){return`#${N.SHEET}=${t}${n?`&${typeof n==`string`?N.DEFINE_NAME:N.RANGE}=${typeof n==`string`?n:(0,a.serializeRange)(n)}`:``}`}parseHyperLink(e){if(e.startsWith(`#`)){var t,n,r,i;let a=new URLSearchParams(e.slice(1)),o={gid:(t=a.get(`gid`))==null?``:t,range:(n=a.get(`range`))==null?``:n,rangeid:(r=a.get(`rangeid`))==null?``:r,unitid:(i=a.get(`unitid`))==null?``:i},s=this._getURLName(o);return{type:s.type,name:s.name,url:e,searchObj:o}}else return{type:N.URL,name:e,url:e,searchObj:null}}_getURLName(e){var n;let{gid:r,range:i,rangeid:o,unitid:s}=e,c=s?this._univerInstanceService.getUnit(s,t.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),l={type:N.INVALID,name:this._localeService.t(`hyperLink.message.refError`)};if(!c)return l;let u=r?c.getSheetBySheetId(r):c.getActiveSheet(),d=(n=u==null?void 0:u.getName())==null?``:n;if(i){if(!u)return l;let e=(0,a.deserializeRangeWithSheet)(i).range;return(0,t.isValidRange)(e,u)&&i!==`err`?{type:N.RANGE,name:(0,a.serializeRangeWithSheet)(d,e)}:l}if(o){let e=this._definedNamesService.getValueById(c.getUnitId(),o);return e?{type:N.DEFINE_NAME,name:e.formulaOrRefString}:l}if(r){let e=c.getSheetBySheetId(r);return e?{type:N.SHEET,name:e.getName()}:l}return l}};P=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(t.LocaleService)),u(2,a.IDefinedNamesService)],P);let F=class extends t.Plugin{constructor(e=D,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,i)}onStarting(){(0,t.registerDependencies)(this._injector,[[f],[P],[M],[O],[j],[k],[A]]),(0,t.touchDependencies)(this._injector,[[O],[M],[j],[k],[A]])}};l(F,`pluginName`,`SHEET_HYPER_LINK_PLUGIN`),l(F,`packageName`,w),l(F,`version`,T),l(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=d([(0,t.DependentOn)(r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,t.IConfigService)],F),e.AddHyperLinkCommand=h,e.AddHyperLinkMutation=p,e.AddRichHyperLinkCommand=g,e.CancelHyperLinkCommand=_,e.CancelRichHyperLinkCommand=v,e.ERROR_RANGE=`err`,Object.defineProperty(e,`HyperLinkModel`,{enumerable:!0,get:function(){return f}}),e.RemoveHyperLinkMutation=m,e.SheetHyperLinkType=N,Object.defineProperty(e,`SheetsHyperLinkParserService`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,`UniverSheetsHyperLinkPlugin`,{enumerable:!0,get:function(){return F}}),e.UpdateHyperLinkCommand=y,e.UpdateHyperLinkMutation=x,e.UpdateHyperLinkRefMutation=S,e.UpdateRichHyperLinkCommand=b});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/docs`),require(`@univerjs/sheets`),require(`rxjs`),require(`@univerjs/engine-formula`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLink={},e.UniverCore,e.UniverDocs,e.UniverSheets,e.rxjs,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends t.Disposable{constructor(e){super(),this._univerInstanceService=e,l(this,`_linkUpdate$`,new i.Subject),l(this,`linkUpdate$`,this._linkUpdate$.asObservable()),l(this,`_linkMap`,new Map),l(this,`_linkPositionMap`,new Map),this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let i=r.get(n);i||(i=new t.ObjectMatrix,r.set(n,i));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let o=a.get(n);return o||(o=new Map,a.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t);return r.setValue(n.row,n.column,n),i.set(n.id,{row:n.row,column:n.column,link:n}),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:n,type:`add`}),!0}updateHyperLink(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return c?(Object.assign(c,r),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:{display:c.display,payload:c.payload},id:n,type:`update`,silent:i}),!0):!0}updateHyperLinkRef(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return!c||c.id!==n?c=s.link:a.realDeleteValue(s.row,s.column),Object.assign(c,r),o.set(n,{...r,link:c}),a.setValue(r.row,r.column,c),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:r,id:n,type:`updateRef`,silent:i}),!0}removeHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(!a)return!1;i.delete(n);let o=r.getValue(a.row,a.column);return o&&o.id===n&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:a.link,type:`remove`}),!0}getHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,t,n,r){let{matrix:i}=this._ensureMap(e,t);return i.getValue(n,r)}getHyperLinkByLocationSync(e,n,r,i){var a,o,s,c;let{matrix:l}=this._ensureMap(e,n),u=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),d=u==null||(a=u.getSheetBySheetId(n))==null?void 0:a.getCellRaw(r,i),f=((o=(s=d==null?void 0:d.v)==null?d==null||(c=d.p)==null||(c=c.body)==null?void 0:c.dataStream.slice(0,-2):s)==null?``:o).toString(),p=l.getValue(r,i);if(p)return{...p,display:f}}getSubUnit(e,t){let{matrix:n}=this._ensureMap(e,t),r=[];return n.forValue((e,t,n)=>{n&&r.push(n)}),r}getUnit(e){let t=this._linkMap.get(e);return t?Array.from(t.keys()).map(t=>({unitId:e,subUnitId:t,links:this.getSubUnit(e,t)})):[]}deleteUnit(e){let t=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:`unload`,unitId:e,unitLinks:t})}getAll(){return Array.from(this._linkMap.keys()).map(e=>this.getUnit(e))}};f=d([u(0,t.IUniverInstanceService)],f);let p={type:t.CommandType.MUTATION,id:`sheets.mutation.add-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,link:a}=t;return n.addHyperLink(r,i,a)}},m={type:t.CommandType.MUTATION,id:`sheets.mutation.remove-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a}=t;return n.removeHyperLink(r,i,a)}},h={type:t.CommandType.COMMAND,id:`sheets.command.add-hyper-link`,async handler(e,n){if(!n)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(t.IUniverInstanceService),s=e.get(f),c=e.get(r.SheetInterceptorService),l=(0,r.getSheetCommandTarget)(o,n);if(!l)return!1;let{unitId:u,subUnitId:d,workbook:h,worksheet:g}=l,{link:_}=n,{payload:v,display:y,row:b,column:x,id:S}=_,C=g.getCell(b,x),w=g.getBlankCellDocumentModel(C,b,x),T=w.documentModel.getSnapshot(),E=t.Tools.deepClone(T.body);if(!E)return!1;let D;if(D=y?t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:E.dataStream.length-2,collapsed:E.dataStream.length-2==0},body:{dataStream:`${y}`,customRanges:[{startIndex:0,endIndex:y.length-1,rangeType:t.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:v}}]},doc:w.documentModel}):t.BuildTextUtils.customRange.add({body:E,ranges:[{startOffset:0,endOffset:E.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:v,refId:S}}),!D)return!1;let O=t.TextX.apply(E,D.serialize()),k={p:{...T,body:O},t:t.CellValueType.STRING},A=c.onWriteCell(h,g,b,x,k),j={unitId:u,subUnitId:d,cellValue:{[_.row]:{[_.column]:A}}},M={id:r.SetRangeValuesMutation.id,params:j},N=(0,r.SetRangeValuesUndoMutationFactory)(e,j),P={id:r.SetRangeValuesMutation.id,params:N},F=[M],I=[P],L=s.getHyperLinkByLocation(u,d,b,x);return L&&(F.push({id:m.id,params:{unitId:u,subUnitId:d,id:L.id}}),I.push({id:p.id,params:{unitId:u,subUnitId:d,link:L}})),await(0,t.sequenceExecute)(F,i)?await c.onValidateCell(h,g,b,x)===!1?((0,t.sequenceExecute)(I,i),!1):(a.pushUndoRedo({redoMutations:F,undoMutations:I,unitID:u}),!0):!1}},g={id:`sheets.command.add-rich-hyper-link`,type:t.CommandType.COMMAND,handler:async(e,r)=>{if(!r)return!1;let{documentId:i,link:a}=r,o=e.get(t.ICommandService),s=(0,t.generateRandomId)(),{payload:c}=a,l=(0,n.addCustomRangeBySelectionFactory)(e,{unitId:i,rangeId:s,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c,refId:s}});return l?o.syncExecuteCommand(l.id,l.params):!1}},_={type:t.CommandType.COMMAND,id:`sheets.command.cancel-hyper-link`,handler(e,n){var i;if(!n)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),c=e.get(f),l=(0,r.getSheetCommandTarget)(s,n);if(!l)return!1;let{row:u,column:d,id:h}=n,{unitId:g,subUnitId:_,worksheet:v}=l,y=v.getCell(u,d);if(!y)return!1;let b=v.getCellDocumentModelWithFormula(y,u,d);if(!(b!=null&&b.documentModel))return!1;let x=t.Tools.deepClone(b.documentModel.getSnapshot()),S=(i=x.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>`${e.rangeId}`===h);if(!S)return!1;let C=t.BuildTextUtils.customRange.delete({documentDataModel:b.documentModel,rangeId:S.rangeId});if(!C)return!1;let w=t.TextX.apply(x.body,C.serialize()),T=[],E=[],D={unitId:g,subUnitId:_,cellValue:{[u]:{[d]:{p:{...x,body:w},t:t.CellValueType.STRING}}}};T.push({id:r.SetRangeValuesMutation.id,params:D});let O=(0,r.SetRangeValuesUndoMutationFactory)(e,D);E.push({id:r.SetRangeValuesMutation.id,params:O});let k=c.getHyperLinkByLocation(g,_,u,d);return k&&(T.push({id:m.id,params:{unitId:g,subUnitId:_,id:k.id}}),E.push({id:p.id,params:{unitId:g,subUnitId:_,link:{...k}}})),(0,t.sequenceExecute)(T,a).result?(o.pushUndoRedo({redoMutations:T,undoMutations:E,unitID:g}),!0):!1}},v={type:t.CommandType.COMMAND,id:`sheets.command.cancel-rich-hyper-link`,handler(e,r){var i;if(!r)return!1;let{id:a,documentId:o}=r,s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getUnit(o,t.UniverInstanceType.UNIVER_DOC),l=c==null||(i=c.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===a),u=null;l&&l.endIndex===c.getBody().dataStream.length-3&&(u={dataStream:` `});let d=(0,n.deleteCustomRangeFactory)(e,{unitId:o,rangeId:a,insert:u});return d?s.syncExecuteCommand(d.id,d.params):!1}},y={type:t.CommandType.COMMAND,id:`sheets.command.update-hyper-link`,async handler(e,i){var a,o;if(!i)return!1;let s=e.get(t.ICommandService),c=e.get(t.IUndoRedoService),l=e.get(t.IUniverInstanceService),u=e.get(f),d=e.get(r.SheetInterceptorService),h=(0,r.getSheetCommandTarget)(l,{unitId:i.unitId,subUnitId:i.subUnitId});if(!h)return!1;let{payload:g,row:_,column:v,id:y}=i,{workbook:b,worksheet:x,unitId:S,subUnitId:C}=h,{payload:w,display:T=``}=g,E=x.getCell(_,v);if(!E)return!1;let D=x.getCellDocumentModelWithFormula(E,_,v);if(!(D!=null&&D.documentModel))return!1;let O=D.documentModel.getSnapshot(),k=(a=O.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>`${e.rangeId}`===y);if(!k)return!1;let A=(0,t.generateRandomId)(),j=(o=(0,t.getBodySlice)(D.documentModel.getBody(),k.startIndex,k.endIndex+1).textRuns)==null?void 0:o[0];j&&(j.ed=T.length+1);let M=(0,n.replaceSelectionFactory)(e,{unitId:S,body:{dataStream:`${T}`,customRanges:[{rangeId:A,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:T.length-1,properties:{url:w}}],textRuns:j?[j]:void 0},selection:{startOffset:k.startIndex,endOffset:k.endIndex+1,collapsed:!1},doc:D.documentModel});if(!M)return!1;let N=t.TextX.apply(t.Tools.deepClone(O.body),M.textX.serialize()),P={p:{...O,body:N},t:t.CellValueType.STRING},F=d.onWriteCell(b,x,_,v,P),I={id:r.SetRangeValuesMutation.id,params:{unitId:S,subUnitId:C,cellValue:{[_]:{[v]:F}}}},L=(0,r.SetRangeValuesUndoMutationFactory)(e,I.params),R={id:r.SetRangeValuesMutation.id,params:L},z=[I],B=[R],V=u.getHyperLinkByLocation(S,C,_,v);return V&&(z.push({id:m.id,params:{unitId:S,subUnitId:C,id:V.id}}),B.push({id:p.id,params:{unitId:S,subUnitId:C,link:V}})),(0,t.sequenceExecute)(z,s).result?await d.onValidateCell(b,x,_,v)===!1?((0,t.sequenceExecute)(B,s),!1):(c.pushUndoRedo({redoMutations:z,undoMutations:B,unitID:S}),!0):!1}},b={type:t.CommandType.COMMAND,id:`sheets.command.update-rich-hyper-link`,handler:(e,r)=>{var i,a,o;if(!r)return!1;let{documentId:s,payload:c,id:l}=r,u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=u.getUnit(s,t.UniverInstanceType.UNIVER_DOC);if(!f)return!1;let p=(i=f.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===l);if(!p)return!1;let m=(a=r.payload.display)==null?``:a,h=(0,t.generateRandomId)(),g=(o=(0,t.getBodySlice)(f.getBody(),p.startIndex,p.endIndex+1).textRuns)==null?void 0:o[0];g&&(g.ed=m.length+1);let _=(0,n.replaceSelectionFactory)(e,{unitId:s,body:{dataStream:`${m}`,customRanges:[{rangeId:h,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:m.length-1,properties:{url:c.payload}}],textRuns:g?[g]:void 0},selection:{startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},doc:f});return _?d.syncExecuteCommand(_.id,_.params):!1}},x={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,payload:a,id:o}=t;return n.updateHyperLink(r,i,o,a,!1)}},S={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link-ref`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a,row:o,column:s,silent:c}=t;return n.updateHyperLinkRef(r,i,a,{row:o,column:s},c)}},C={type:t.CommandType.MUTATION,id:`sheets.mutation.update-rich-hyper-link`,handler(e,n){var i;if(!n)return!1;let{unitId:a,subUnitId:o,row:s,col:c,id:l,url:u}=n,d=(0,r.getSheetCommandTarget)(e.get(t.IUniverInstanceService),{unitId:a,subUnitId:o});if(!d)return!1;let{worksheet:f}=d,p=f.getCellRaw(s,c),m=p==null||(i=p.p)==null||(i=i.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeType===t.CustomRangeType.HYPERLINK&&e.rangeId===l);return m&&(m.properties.url=u),!0}};var w=`@univerjs/sheets-hyper-link`,T=`0.22.0-insiders.20260513-0b53885`;let E=`sheets-hyper-link.config`;Symbol(E);let D={},O=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._commandService=r,l(this,`_disposableMap`,new Map),l(this,`_watchDisposableMap`,new Map),l(this,`_rangeDisableMap`,new Map),l(this,`_rangeWatcherMap`,new Map),l(this,`_handlePositionChange`,(e,t,n,r,i)=>{let a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:m.id,params:{unitId:e,subUnitId:t,id:n.id}}],undos:[{id:p.id,params:{unitId:e,subUnitId:t,link:n}}]}}),this._initData(),this._initRefRange()}_registerPosition(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(i,this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,t,n,s,!1)},e,t))}_watchPosition(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handlePositionChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){let t=this._disposableMap.get(e);t==null||t.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){let t=this._watchDisposableMap.get(e);t==null||t.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,i,o=!1){if(i.startsWith(`#`)){var s,c,l;let u=new URLSearchParams(i.slice(1)),d={gid:(s=u.get(`gid`))==null?``:s,range:(c=u.get(`range`))==null?``:c,rangeid:(l=u.get(`rangeid`))==null?``:l};if(d.range&&d.gid){let s=d.gid,c=(0,a.deserializeRangeWithSheet)(d.range).range;(0,t.isValidRange)(c)&&d.range!==`err`&&(this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(c,t=>{let o=(0,r.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests)(c,t,{selectionManagerService:this._selectionManagerService});return o&&(0,a.serializeRange)(o)===(0,a.serializeRange)(c)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:`#gid=${s}&range=${o?(0,a.serializeRange)(o):`err`}`}}}],undos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:i}}}]}},e,s)),o||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,s,c,(t,r)=>{this._hyperLinkModel.updateHyperLink(e,s,n,{payload:`#gid=${s}&range=${r?(0,a.serializeRange)(r):`err`}`},!0)},!0)))}}}_unregisterRange(e){let t=this._rangeDisableMap.get(e);t==null||t.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){let t=this._rangeWatcherMap.get(e);t==null||t.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,links:r}=e;r.forEach(e=>{this._registerPosition(t,n,e),this._watchPosition(t,n,e),this._registerRange(t,e.id,e.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case`add`:this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break;case`remove`:this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break;case`updateRef`:{let{unitId:t,subUnitId:n,id:r,silent:i}=e,a=this._hyperLinkModel.getHyperLink(t,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(t,n,a),i||(this._unwatchPosition(r),this._watchPosition(t,n,a));break}case`unload`:{let{unitLinks:t}=e;t.forEach(e=>{let{links:t}=e;t.forEach(e=>{this._unregisterPosition(e.id),this._unwatchPosition(e.id),this._unregisterRange(e.id),this._unwatchRange(e.id)})});break}case`update`:e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};O=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.ICommandService)],O);let k=class extends t.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return{redos:[],undos:[]};let a=i.getUnitId(),o=r.subUnitId||((n=i.getActiveSheet())==null?void 0:n.getSheetId());if(!o)return{redos:[],undos:[]};let s=this._hyperLinkModel.getSubUnit(a,o);return{redos:s.map(e=>({id:m.id,params:{unitId:a,subUnitId:o,id:e.id}})),undos:s.map(e=>({id:p.id,params:{unitId:a,subUnitId:o,link:e}}))}}return{redos:[],undos:[]}}}))}};k=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],k);let A=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._refRangeService=n,l(this,`_refRangeMap`,new Map),this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(e,n){let r=this._refRangeMap.get(e);r||(r=new Map,this._refRangeMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_isLegalRangeUrl(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!r)return null;if(n&&n.startsWith(`#`)){var i,o,s;let e=new URLSearchParams(n.slice(1)),c={gid:(i=e.get(`gid`))==null?``:i,range:(o=e.get(`range`))==null?``:o,rangeid:(s=e.get(`rangeid`))==null?``:s};if(c.range&&c.gid){let e=c.gid,n=r.getSheetBySheetId(e);if(!n)return null;let i=(0,a.deserializeRangeWithSheet)(c.range).range;if((0,t.isValidRange)(i,n)&&c.range!==`err`)return{range:i,worksheet:n}}}return null}_registerRange(e,n,i,o,s){var c;let l=this._enusreMap(e,n);if(!((c=s.body)==null||(c=c.customRanges)==null)&&c.some(n=>{var r;return n.rangeType===t.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(e,(r=n.properties)==null?void 0:r.url)})){var u;let c=new t.DisposableCollection,d=!1;(u=s.body)==null||(u=u.customRanges)==null||u.forEach(s=>{if(s.rangeType===t.CustomRangeType.HYPERLINK){var l;let u=(l=s.properties)==null?void 0:l.url,f=this._isLegalRangeUrl(e,u);if(f){let{range:l,worksheet:p}=f;d=!0,c.add(this._refRangeService.registerRefRange(l,c=>{let d=(0,r.handleDefaultRangeChangeWithEffectRefCommands)(l,c);return d&&t.Rectangle.equals(d,l)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:`#gid=${n}&range=${d?(0,a.serializeRange)(d):`err`}`}}],undos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:u}}],redos:[]}},p.getUnitId(),p.getSheetId()))}}}),d&&l.setValue(i,o,c)}}_initWorkbookLoad(){let e=e=>{let t=e.getUnitId();e.getSheets().forEach(e=>{let n=e.getSheetId(),r=this._enusreMap(t,n);e.getCellMatrix().forValue((e,i,a)=>{let o=r.getValue(e,i);o&&o.dispose(),a&&a.p&&this._registerRange(t,n,e,i,a.p)})})};this._univerInstanceService.getAllUnitsForType(t.UniverInstanceType.UNIVER_SHEET).forEach(t=>{e(t)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(n=>{let{unit:r}=n;r.type===t.UniverInstanceType.UNIVER_SHEET&&e(r)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{if(e.type===t.UniverInstanceType.UNIVER_SHEET){let t=e,n=t.getUnitId();t.getSheets().forEach(e=>{let t=e.getSheetId();this._enusreMap(n,t).forValue((e,t,n)=>{n&&n.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===r.SetRangeValuesMutation.id){let{unitId:n,subUnitId:r,cellValue:i}=e.params,a=this._enusreMap(n,r);i&&new t.ObjectMatrix(i).forValue((e,t,i)=>{let o=a.getValue(e,t);o&&o.dispose(),i&&i.p&&this._registerRange(n,r,e,t,i.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.id){let{unitId:t,subUnitId:n,row:i,col:a}=e.params,o=(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:t,subUnitId:n}),s=this._enusreMap(t,n).getValue(i,a);if(s&&s.dispose(),o){let{worksheet:e}=o,r=e.getCellRaw(i,a);r&&r.p&&this._registerRange(t,n,i,a,r.p)}}}))}};A=d([u(0,t.ICommandService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.RefRangeService))],A);let j=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._univerInstanceService=r,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.SetRangeValuesCommand.id){let n=e.params,{unitId:r,subUnitId:i}=n,a=[],o=[];return n.cellValue&&new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{let n=this._hyperLinkModel.getHyperLinkByLocation(r,i,e,t);n&&(a.push({id:m.id,params:{unitId:r,subUnitId:i,id:n.id}}),o.push({id:p.id,params:{unitId:r,subUnitId:i,link:n}}))}),{undos:o,redos:a}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.ClearSelectionContentCommand.id||e.id===r.ClearSelectionAllCommand.id||e.id===r.ClearSelectionFormatCommand.id){let n=[],i=[],a=this._selectionManagerService.getCurrentLastSelection(),o=(0,r.getSheetCommandTarget)(this._univerInstanceService,e.params);if(a&&o){let{unitId:e,subUnitId:r}=o;t.Range.foreach(a.range,(t,a)=>{let o=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,a);o&&(n.push({id:m.id,params:{unitId:e,subUnitId:r,id:o.id}}),i.push({id:p.id,params:{unitId:e,subUnitId:r,link:o}}))})}return{redos:n,undos:i}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.AFTER_CELL_EDIT,{handler:(e,n,r)=>{if(!e||e.p)return r(e);if(typeof e.v==`string`&&t.Tools.isLegalUrl(e.v)&&e.v[e.v.length-1]!==` `){let{unitId:i,subUnitId:a,row:o,col:s}=n,c=t.Tools.normalizeUrl(e.v),l=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),u=l==null?void 0:l.getSheetBySheetId(a);if(!u)return r(e);let d=u.getBlankCellDocumentModel(e,o,s);if(!d.documentModel)return r(e);let f=t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:e.v.length,collapsed:!1},body:{dataStream:`${e.v}`,customRanges:[{startIndex:0,endIndex:e.v.length-1,rangeId:(0,t.generateRandomId)(),rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c}}]},doc:d.documentModel});if(!f)return r(e);let p=d.documentModel.getBody();return t.TextX.apply(p,f.serialize()),r({...e,p:{id:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return r(e)}}))}};j=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.IUniverInstanceService)],j);let M=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._registerCommands()}_registerCommands(){[h,y,_,b,v,g,p,x,m,S,C].forEach(e=>{this._commandService.registerCommand(e)})}};M=d([u(0,t.ICommandService)],M);let N=function(e){return e.SHEET=`gid`,e.RANGE=`range`,e.DEFINE_NAME=`rangeid`,e.INVALID=`invalid`,e.URL=`url`,e}({}),P=class{constructor(e,t,n){this._univerInstanceService=e,this._localeService=t,this._definedNamesService=n}buildHyperLink(e,t,n){return`#gid=${t}${n?`&${typeof n==`string`?`rangeid`:`range`}=${typeof n==`string`?n:(0,a.serializeRange)(n)}`:``}`}parseHyperLink(e){if(e.startsWith(`#`)){var t,n,r,i;let a=new URLSearchParams(e.slice(1)),o={gid:(t=a.get(`gid`))==null?``:t,range:(n=a.get(`range`))==null?``:n,rangeid:(r=a.get(`rangeid`))==null?``:r,unitid:(i=a.get(`unitid`))==null?``:i},s=this._getURLName(o);return{type:s.type,name:s.name,url:e,searchObj:o}}else return{type:`url`,name:e,url:e,searchObj:null}}_getURLName(e){var n;let{gid:r,range:i,rangeid:o,unitid:s}=e,c=s?this._univerInstanceService.getUnit(s,t.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),l={type:`invalid`,name:this._localeService.t(`hyperLink.message.refError`)};if(!c)return l;let u=r?c.getSheetBySheetId(r):c.getActiveSheet(),d=(n=u==null?void 0:u.getName())==null?``:n;if(i){if(!u)return l;let e=(0,a.deserializeRangeWithSheet)(i).range;return(0,t.isValidRange)(e,u)&&i!==`err`?{type:`range`,name:(0,a.serializeRangeWithSheet)(d,e)}:l}if(o){let e=this._definedNamesService.getValueById(c.getUnitId(),o);return e?{type:`rangeid`,name:e.formulaOrRefString}:l}if(r){let e=c.getSheetBySheetId(r);return e?{type:`gid`,name:e.getName()}:l}return l}};P=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(t.LocaleService)),u(2,a.IDefinedNamesService)],P);let F=class extends t.Plugin{constructor(e=D,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,i)}onStarting(){(0,t.registerDependencies)(this._injector,[[f],[P],[M],[O],[j],[k],[A]]),(0,t.touchDependencies)(this._injector,[[O],[M],[j],[k],[A]])}};l(F,`pluginName`,`SHEET_HYPER_LINK_PLUGIN`),l(F,`packageName`,w),l(F,`version`,T),l(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=d([(0,t.DependentOn)(r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,t.IConfigService)],F),e.AddHyperLinkCommand=h,e.AddHyperLinkMutation=p,e.AddRichHyperLinkCommand=g,e.CancelHyperLinkCommand=_,e.CancelRichHyperLinkCommand=v,e.ERROR_RANGE=`err`,Object.defineProperty(e,`HyperLinkModel`,{enumerable:!0,get:function(){return f}}),e.RemoveHyperLinkMutation=m,e.SheetHyperLinkType=N,Object.defineProperty(e,`SheetsHyperLinkParserService`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,`UniverSheetsHyperLinkPlugin`,{enumerable:!0,get:function(){return F}}),e.UpdateHyperLinkCommand=y,e.UpdateHyperLinkMutation=x,e.UpdateHyperLinkRefMutation=S,e.UpdateRichHyperLinkCommand=b});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-hyper-link",
3
- "version": "0.21.1",
3
+ "version": "0.22.0-insiders.20260513-0b53885",
4
4
  "private": false,
5
- "description": "",
6
- "author": "DreamNum <developer@univer.ai>",
5
+ "description": "Hyperlink model and commands for Univer Sheets.",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -17,7 +17,13 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
- "keywords": [],
20
+ "keywords": [
21
+ "univer",
22
+ "sheets",
23
+ "hyperlink",
24
+ "link",
25
+ "plugin"
26
+ ],
21
27
  "exports": {
22
28
  ".": {
23
29
  "import": "./lib/es/index.js",
@@ -56,16 +62,16 @@
56
62
  "rxjs": ">=7.0.0"
57
63
  },
58
64
  "dependencies": {
59
- "@univerjs/core": "0.21.1",
60
- "@univerjs/docs": "0.21.1",
61
- "@univerjs/engine-formula": "0.21.1",
62
- "@univerjs/sheets": "0.21.1"
65
+ "@univerjs/core": "0.22.0-insiders.20260513-0b53885",
66
+ "@univerjs/docs": "0.22.0-insiders.20260513-0b53885",
67
+ "@univerjs/engine-formula": "0.22.0-insiders.20260513-0b53885",
68
+ "@univerjs/sheets": "0.22.0-insiders.20260513-0b53885"
63
69
  },
64
70
  "devDependencies": {
65
71
  "rxjs": "^7.8.2",
66
- "typescript": "^6.0.2",
67
- "vitest": "^4.1.4",
68
- "@univerjs-infra/shared": "0.21.1"
72
+ "typescript": "^6.0.3",
73
+ "vitest": "^4.1.5",
74
+ "@univerjs-infra/shared": "0.22.0"
69
75
  },
70
76
  "scripts": {
71
77
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS