@univerjs/docs-hyper-link-ui 1.4.0 → 1.5.1

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
@@ -8,9 +8,9 @@
8
8
 
9
9
  ## Package Overview
10
10
 
11
- | Package | UMD global | CSS | Locales | Facade entry |
12
- | --- | --- | :---: | :---: | :---: |
13
- | `@univerjs/docs-hyper-link-ui` | `UniverDocsHyperLinkUi` | Yes | Yes | No |
11
+ | Package | UMD global | CSS | Locales | Facade entry | Worker entry |
12
+ | --- | --- | :---: | :---: | :---: | :---: |
13
+ | `@univerjs/docs-hyper-link-ui` | `UniverDocsHyperLinkUi` | Yes | Yes | No | No |
14
14
 
15
15
  ## Installation
16
16
 
@@ -20,10 +20,10 @@ pnpm add @univerjs/docs-hyper-link-ui
20
20
  npm install @univerjs/docs-hyper-link-ui
21
21
  ```
22
22
 
23
- Keep all `@univerjs/*` packages on the same version.
24
-
25
23
  ## Usage
26
24
 
25
+ Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
26
+
27
27
  ```ts
28
28
  import '@univerjs/docs-hyper-link-ui/lib/index.css';
29
29
  import EnUS from '@univerjs/docs-hyper-link-ui/locale/en-US';
package/lib/cjs/index.js CHANGED
@@ -360,7 +360,7 @@ const DocLinkPopup = () => {
360
360
  };
361
361
  DocLinkPopup.componentKey = "univer.doc.link-info-popup";
362
362
 
363
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
363
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
364
364
  function _typeof(o) {
365
365
  "@babel/helpers - typeof";
366
366
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -370,25 +370,25 @@ function _typeof(o) {
370
370
  }, _typeof(o);
371
371
  }
372
372
 
373
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
374
- function toPrimitive(t, r) {
373
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
374
+ function toPrimitive(t, e) {
375
375
  if ("object" != _typeof(t) || !t) return t;
376
- var e = t[Symbol.toPrimitive];
377
- if (void 0 !== e) {
378
- var i = e.call(t, r || "default");
376
+ var r;
377
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
378
+ var i = r.call(t, e || "default");
379
379
  if ("object" != _typeof(i)) return i;
380
380
  throw new TypeError("@@toPrimitive must return a primitive value.");
381
381
  }
382
- return ("string" === r ? String : Number)(t);
382
+ return ("string" === e ? String : Number)(t);
383
383
  }
384
384
 
385
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
385
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
386
386
  function toPropertyKey(t) {
387
387
  var i = toPrimitive(t, "string");
388
388
  return "symbol" == _typeof(i) ? i : i + "";
389
389
  }
390
390
 
391
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
391
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
392
392
  function _defineProperty(e, r, t) {
393
393
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
394
394
  value: t,
@@ -398,14 +398,14 @@ function _defineProperty(e, r, t) {
398
398
  }) : e[r] = t, e;
399
399
  }
400
400
 
401
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
401
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
402
402
  function __decorateParam(paramIndex, decorator) {
403
403
  return function(target, key) {
404
404
  decorator(target, key, paramIndex);
405
405
  };
406
406
  }
407
407
 
408
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
408
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
409
409
  function __decorate(decorators, target, key, desc) {
410
410
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
411
411
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -826,7 +826,7 @@ const menuSchema = {
826
826
 
827
827
  // package.json
828
828
  var name = "@univerjs/docs-hyper-link-ui";
829
- var version = "1.4.0";
829
+ var version = "1.5.1";
830
830
 
831
831
  // src/config/config.ts
832
832
  const DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config";
@@ -910,6 +910,21 @@ DocHyperLinkSelectionController = __decorate([
910
910
  ], DocHyperLinkSelectionController);
911
911
 
912
912
  // src/views/MobileDocHyperLinkEdit.tsx
913
+ /**
914
+ * Copyright 2023-present DreamNum Co., Ltd.
915
+ *
916
+ * Licensed under the Apache License, Version 2.0 (the "License");
917
+ * you may not use this file except in compliance with the License.
918
+ * You may obtain a copy of the License at
919
+ *
920
+ * http://www.apache.org/licenses/LICENSE-2.0
921
+ *
922
+ * Unless required by applicable law or agreed to in writing, software
923
+ * distributed under the License is distributed on an "AS IS" BASIS,
924
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
925
+ * See the License for the specific language governing permissions and
926
+ * limitations under the License.
927
+ */
913
928
  function MobileDocHyperLinkEdit() {
914
929
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
915
930
  const { doc, editing, handleCancel, handleConfirm, isLegal, label, link, setLabel, setLink, showError } = useDocHyperLinkEdit();
@@ -925,7 +940,8 @@ function MobileDocHyperLinkEdit() {
925
940
  autoFocus: true,
926
941
  onKeyDown: (event) => {
927
942
  if (event.keyCode === _univerjs_ui.KeyCode.ENTER) handleConfirm();
928
- }
943
+ },
944
+ size: "small"
929
945
  })
930
946
  }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
931
947
  label: localeService.t("docs-hyper-link-ui.edit.address"),
@@ -936,19 +952,22 @@ function MobileDocHyperLinkEdit() {
936
952
  autoFocus: !editing,
937
953
  onKeyDown: (event) => {
938
954
  if (event.keyCode === _univerjs_ui.KeyCode.ENTER) handleConfirm();
939
- }
955
+ },
956
+ size: "small"
940
957
  })
941
958
  })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
942
959
  className: "univer-mt-5 univer-flex univer-gap-3",
943
960
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
944
- className: "univer-h-12 univer-flex-1",
961
+ className: "univer-flex-1",
945
962
  onClick: handleCancel,
963
+ size: "middle",
946
964
  children: localeService.t("docs-hyper-link-ui.edit.cancel")
947
965
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
948
966
  variant: "primary",
949
- className: "univer-h-12 univer-flex-1",
967
+ className: "univer-flex-1",
950
968
  disabled: isBlankInput(link),
951
969
  onClick: handleConfirm,
970
+ size: "middle",
952
971
  children: localeService.t("docs-hyper-link-ui.edit.confirm")
953
972
  })]
954
973
  })]
package/lib/es/index.js CHANGED
@@ -359,7 +359,7 @@ const DocLinkPopup = () => {
359
359
  };
360
360
  DocLinkPopup.componentKey = "univer.doc.link-info-popup";
361
361
 
362
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
362
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
363
363
  function _typeof(o) {
364
364
  "@babel/helpers - typeof";
365
365
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -369,25 +369,25 @@ function _typeof(o) {
369
369
  }, _typeof(o);
370
370
  }
371
371
 
372
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
373
- function toPrimitive(t, r) {
372
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
373
+ function toPrimitive(t, e) {
374
374
  if ("object" != _typeof(t) || !t) return t;
375
- var e = t[Symbol.toPrimitive];
376
- if (void 0 !== e) {
377
- var i = e.call(t, r || "default");
375
+ var r;
376
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
377
+ var i = r.call(t, e || "default");
378
378
  if ("object" != _typeof(i)) return i;
379
379
  throw new TypeError("@@toPrimitive must return a primitive value.");
380
380
  }
381
- return ("string" === r ? String : Number)(t);
381
+ return ("string" === e ? String : Number)(t);
382
382
  }
383
383
 
384
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
384
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
385
385
  function toPropertyKey(t) {
386
386
  var i = toPrimitive(t, "string");
387
387
  return "symbol" == _typeof(i) ? i : i + "";
388
388
  }
389
389
 
390
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
390
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
391
391
  function _defineProperty(e, r, t) {
392
392
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
393
393
  value: t,
@@ -397,14 +397,14 @@ function _defineProperty(e, r, t) {
397
397
  }) : e[r] = t, e;
398
398
  }
399
399
 
400
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
400
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
401
401
  function __decorateParam(paramIndex, decorator) {
402
402
  return function(target, key) {
403
403
  decorator(target, key, paramIndex);
404
404
  };
405
405
  }
406
406
 
407
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
407
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
408
408
  function __decorate(decorators, target, key, desc) {
409
409
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
410
410
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -825,7 +825,7 @@ const menuSchema = {
825
825
 
826
826
  // package.json
827
827
  var name = "@univerjs/docs-hyper-link-ui";
828
- var version = "1.4.0";
828
+ var version = "1.5.1";
829
829
 
830
830
  // src/config/config.ts
831
831
  const DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config";
@@ -909,6 +909,21 @@ DocHyperLinkSelectionController = __decorate([
909
909
  ], DocHyperLinkSelectionController);
910
910
 
911
911
  // src/views/MobileDocHyperLinkEdit.tsx
912
+ /**
913
+ * Copyright 2023-present DreamNum Co., Ltd.
914
+ *
915
+ * Licensed under the Apache License, Version 2.0 (the "License");
916
+ * you may not use this file except in compliance with the License.
917
+ * You may obtain a copy of the License at
918
+ *
919
+ * http://www.apache.org/licenses/LICENSE-2.0
920
+ *
921
+ * Unless required by applicable law or agreed to in writing, software
922
+ * distributed under the License is distributed on an "AS IS" BASIS,
923
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
924
+ * See the License for the specific language governing permissions and
925
+ * limitations under the License.
926
+ */
912
927
  function MobileDocHyperLinkEdit() {
913
928
  const localeService = useDependency(LocaleService);
914
929
  const { doc, editing, handleCancel, handleConfirm, isLegal, label, link, setLabel, setLink, showError } = useDocHyperLinkEdit();
@@ -924,7 +939,8 @@ function MobileDocHyperLinkEdit() {
924
939
  autoFocus: true,
925
940
  onKeyDown: (event) => {
926
941
  if (event.keyCode === KeyCode.ENTER) handleConfirm();
927
- }
942
+ },
943
+ size: "small"
928
944
  })
929
945
  }) : null, /* @__PURE__ */ jsx(FormLayout, {
930
946
  label: localeService.t("docs-hyper-link-ui.edit.address"),
@@ -935,19 +951,22 @@ function MobileDocHyperLinkEdit() {
935
951
  autoFocus: !editing,
936
952
  onKeyDown: (event) => {
937
953
  if (event.keyCode === KeyCode.ENTER) handleConfirm();
938
- }
954
+ },
955
+ size: "small"
939
956
  })
940
957
  })] }), /* @__PURE__ */ jsxs("div", {
941
958
  className: "univer-mt-5 univer-flex univer-gap-3",
942
959
  children: [/* @__PURE__ */ jsx(Button, {
943
- className: "univer-h-12 univer-flex-1",
960
+ className: "univer-flex-1",
944
961
  onClick: handleCancel,
962
+ size: "middle",
945
963
  children: localeService.t("docs-hyper-link-ui.edit.cancel")
946
964
  }), /* @__PURE__ */ jsx(Button, {
947
965
  variant: "primary",
948
- className: "univer-h-12 univer-flex-1",
966
+ className: "univer-flex-1",
949
967
  disabled: isBlankInput(link),
950
968
  onClick: handleConfirm,
969
+ size: "middle",
951
970
  children: localeService.t("docs-hyper-link-ui.edit.confirm")
952
971
  })]
953
972
  })]
package/lib/index.css CHANGED
@@ -32,10 +32,6 @@
32
32
  height: 1.5rem;
33
33
  }
34
34
 
35
- .univer-h-12 {
36
- height: 3rem;
37
- }
38
-
39
35
  .univer-h-6 {
40
36
  height: 1.5rem;
41
37
  }
package/lib/index.js CHANGED
@@ -359,7 +359,7 @@ const DocLinkPopup = () => {
359
359
  };
360
360
  DocLinkPopup.componentKey = "univer.doc.link-info-popup";
361
361
 
362
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
362
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
363
363
  function _typeof(o) {
364
364
  "@babel/helpers - typeof";
365
365
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -369,25 +369,25 @@ function _typeof(o) {
369
369
  }, _typeof(o);
370
370
  }
371
371
 
372
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
373
- function toPrimitive(t, r) {
372
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
373
+ function toPrimitive(t, e) {
374
374
  if ("object" != _typeof(t) || !t) return t;
375
- var e = t[Symbol.toPrimitive];
376
- if (void 0 !== e) {
377
- var i = e.call(t, r || "default");
375
+ var r;
376
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
377
+ var i = r.call(t, e || "default");
378
378
  if ("object" != _typeof(i)) return i;
379
379
  throw new TypeError("@@toPrimitive must return a primitive value.");
380
380
  }
381
- return ("string" === r ? String : Number)(t);
381
+ return ("string" === e ? String : Number)(t);
382
382
  }
383
383
 
384
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
384
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
385
385
  function toPropertyKey(t) {
386
386
  var i = toPrimitive(t, "string");
387
387
  return "symbol" == _typeof(i) ? i : i + "";
388
388
  }
389
389
 
390
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
390
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
391
391
  function _defineProperty(e, r, t) {
392
392
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
393
393
  value: t,
@@ -397,14 +397,14 @@ function _defineProperty(e, r, t) {
397
397
  }) : e[r] = t, e;
398
398
  }
399
399
 
400
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
400
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
401
401
  function __decorateParam(paramIndex, decorator) {
402
402
  return function(target, key) {
403
403
  decorator(target, key, paramIndex);
404
404
  };
405
405
  }
406
406
 
407
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
407
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
408
408
  function __decorate(decorators, target, key, desc) {
409
409
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
410
410
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -825,7 +825,7 @@ const menuSchema = {
825
825
 
826
826
  // package.json
827
827
  var name = "@univerjs/docs-hyper-link-ui";
828
- var version = "1.4.0";
828
+ var version = "1.5.1";
829
829
 
830
830
  // src/config/config.ts
831
831
  const DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config";
@@ -909,6 +909,21 @@ DocHyperLinkSelectionController = __decorate([
909
909
  ], DocHyperLinkSelectionController);
910
910
 
911
911
  // src/views/MobileDocHyperLinkEdit.tsx
912
+ /**
913
+ * Copyright 2023-present DreamNum Co., Ltd.
914
+ *
915
+ * Licensed under the Apache License, Version 2.0 (the "License");
916
+ * you may not use this file except in compliance with the License.
917
+ * You may obtain a copy of the License at
918
+ *
919
+ * http://www.apache.org/licenses/LICENSE-2.0
920
+ *
921
+ * Unless required by applicable law or agreed to in writing, software
922
+ * distributed under the License is distributed on an "AS IS" BASIS,
923
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
924
+ * See the License for the specific language governing permissions and
925
+ * limitations under the License.
926
+ */
912
927
  function MobileDocHyperLinkEdit() {
913
928
  const localeService = useDependency(LocaleService);
914
929
  const { doc, editing, handleCancel, handleConfirm, isLegal, label, link, setLabel, setLink, showError } = useDocHyperLinkEdit();
@@ -924,7 +939,8 @@ function MobileDocHyperLinkEdit() {
924
939
  autoFocus: true,
925
940
  onKeyDown: (event) => {
926
941
  if (event.keyCode === KeyCode.ENTER) handleConfirm();
927
- }
942
+ },
943
+ size: "small"
928
944
  })
929
945
  }) : null, /* @__PURE__ */ jsx(FormLayout, {
930
946
  label: localeService.t("docs-hyper-link-ui.edit.address"),
@@ -935,19 +951,22 @@ function MobileDocHyperLinkEdit() {
935
951
  autoFocus: !editing,
936
952
  onKeyDown: (event) => {
937
953
  if (event.keyCode === KeyCode.ENTER) handleConfirm();
938
- }
954
+ },
955
+ size: "small"
939
956
  })
940
957
  })] }), /* @__PURE__ */ jsxs("div", {
941
958
  className: "univer-mt-5 univer-flex univer-gap-3",
942
959
  children: [/* @__PURE__ */ jsx(Button, {
943
- className: "univer-h-12 univer-flex-1",
960
+ className: "univer-flex-1",
944
961
  onClick: handleCancel,
962
+ size: "middle",
945
963
  children: localeService.t("docs-hyper-link-ui.edit.cancel")
946
964
  }), /* @__PURE__ */ jsx(Button, {
947
965
  variant: "primary",
948
- className: "univer-h-12 univer-flex-1",
966
+ className: "univer-flex-1",
949
967
  disabled: isBlankInput(link),
950
968
  onClick: handleConfirm,
969
+ size: "middle",
951
970
  children: localeService.t("docs-hyper-link-ui.edit.confirm")
952
971
  })]
953
972
  })]
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs-hyper-link"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/protocol")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/engine-render`,`rxjs`,`@univerjs/docs-hyper-link`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/protocol`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLinkUi={},e.UniverDocsUi,e.UniverUi,e.UniverCore,e.UniverDocs,e.UniverEngineRender,e.rxjs,e.UniverDocsHyperLink,e.UniverDesign,e.React,e.React,e.UniverProtocol))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let f={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Delete,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:a,segmentId:o}=t,s=e.get(r.ICommandService),c=(0,i.deleteCustomRangeFactory)(e,{unitId:n,rangeId:a,segmentId:o});return c?await s.syncExecuteCommand(c.id,c.params):!1}},p={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Add,async handler(e,t){if(!t)return!1;let{payload:n,unitId:a,selections:o}=t,s=e.get(r.ICommandService),c=(0,r.generateRandomId)(),l=(0,i.addCustomRangeBySelectionFactory)(e,{rangeId:c,rangeType:r.CustomRangeType.HYPERLINK,properties:{url:n},unitId:a,selections:o});return l?s.syncExecuteCommand(l.id,l.params):!1}},m={id:s.DocHyperLinkCommandId.Update,type:r.CommandType.COMMAND,handler(e,t){var n,a,o,s,c;if(!t)return!1;let{unitId:l,payload:u,segmentId:d,linkId:f}=t,p=e.get(r.ICommandService),m=e.get(r.IUniverInstanceService),h=e.get(i.DocSelectionManagerService).getActiveTextRange(),g=m.getUnit(l,r.UniverInstanceType.UNIVER_DOC);if(!h||!g)return!1;let _=(n=g.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody();if(!_)return!1;let v=(a=_.customRanges)==null?void 0:a.find(e=>e.rangeId===f&&e.rangeType===r.CustomRangeType.HYPERLINK),y=(o=(0,r.getBodySlice)(_,h.startOffset,h.endOffset).textRuns)==null?void 0:o[0];y&&(y.ed=t.label.length+1);let b=(0,i.replaceSelectionFactory)(e,{unitId:l,body:{dataStream:`${t.label}`,customRanges:[{rangeId:f,rangeType:r.CustomRangeType.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:u,...v!=null&&(s=v.properties)!=null&&s.textStyleMode?{textStyleMode:v.properties.textStyleMode}:null,...v!=null&&(c=v.properties)!=null&&c.textColorMode?{textColorMode:v.properties.textColorMode}:null}}],textRuns:y?[y]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:d}});return b?p.syncExecuteCommand(b.id,b.params):!1}};function h(e){return e.trim().length===0}function g(e){return/^[a-zA-Z]+:\/\//.test(e)}function _(e){return/^[\w.-]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function v(e){return g(e)?e:_(e)?`mailto://${e}`:`https://${e}`}function y(){let e=(0,n.useDependency)(R),t=(0,n.useObservable)(e.editingLink$,e.editing),a=(0,n.useDependency)(r.ICommandService),o=(0,n.useDependency)(r.IUniverInstanceService),s=(0,n.useDependency)(i.DocSelectionManagerService),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[g,_]=(0,l.useState)(!1),y=r.Tools.isLegalUrl(c),b=t?o.getUnit(t.unitId,r.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC);return(0,l.useEffect)(()=>{var e,n;let i=s.getActiveTextRange();if(!i)return;if(t){var a,o;let e=b==null||(a=b.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:a.getBody(),n=e==null||(o=e.customRanges)==null?void 0:o.find(e=>t.linkId===e.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex);if(b&&n){var c;u(((c=n.properties)==null?void 0:c.url)??``),f(r.BuildTextUtils.transform.getPlainText((0,r.getBodySlice)(e,n.startIndex,n.endIndex+1).dataStream))}return}let l=b==null||(e=b.getSelfOrHeaderFooterModel(i.segmentId))==null?void 0:e.getBody(),d=l?i:null,p=d&&((n=r.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(d,(l==null?void 0:l.customRanges)??[]))==null?void 0:n[0]);if(b&&p){var m;u(((m=p.properties)==null?void 0:m.url)??``)}},[b,s,t]),{doc:b,editing:t,handleCancel:()=>e.hideEditPopup(),handleConfirm:()=>{if(_(!0),!y||!b)return;let n=v(c);if(t){if(h(d))return;a.executeCommand(m.id,{unitId:b.getUnitId(),payload:n,linkId:t.linkId,label:d,segmentId:t.segmentId}).catch(()=>void 0)}else a.executeCommand(p.id,{unitId:b.getUnitId(),payload:n}).catch(()=>void 0);e.hideEditPopup()},isLegal:y,label:d,link:c,setLabel:f,setLink:u,showError:g}}let b=()=>{let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-gray-0 univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{children:[i?/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),/* @__PURE__ */ (0,u.jsx)(c.Button,{variant:`primary`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};b.componentKey=`docs-hyper-link-edit`;function x({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return T(d.current)},[n,r]),S(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function S(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...C(e,n,i),...r},(w(e,n).children||[]).map((r,a)=>S(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function C(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function w(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function T(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:E(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(D(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function E(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function D(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}x.displayName=`UniverIcon`;let O={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},k=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`copy-icon`,ref:t,icon:O}))});k.displayName=`CopyIcon`;let A={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.30999 8.71386C6.39955 7.80343 6.37922 6.34731 7.26629 5.45772L10.313 2.41112C11.2111 1.51303 12.6799 1.51258 13.5691 2.45476C14.4811 3.36679 14.4798 4.84384 13.6128 5.71094L10.9677 8.35604`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.0456 7.66774L2.4005 10.3128C1.50242 11.2109 1.50197 12.6798 2.44413 13.5691C3.35615 14.4811 4.8332 14.4798 5.70033 13.6127L8.747 10.566C9.65743 9.65558 9.67776 8.19945 8.7905 7.30999`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}}]},j=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`link-icon`,ref:t,icon:A}))});j.displayName=`LinkIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},te=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:ee}))});te.displayName=`UnlinkIcon`;let ne={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},re=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`write-icon`,ref:t,icon:ne}))});re.displayName=`WriteIcon`;let M=()=>{var e,t,a,o,s;let l=(0,n.useDependency)(R),p=(0,n.useDependency)(r.ICommandService),m=(0,n.useDependency)(n.IMessageService),h=(0,n.useDependency)(r.LocaleService),g=(0,n.useObservable)(l.showingLink$,l.showing),_=(0,n.useDependency)(r.IUniverInstanceService),v=(0,n.useDependency)(r.IPermissionService);if(!g)return null;let{unitId:y,linkId:b,segmentId:x,startIndex:S,endIndex:C}=g,w=_.getUnit(y,r.UniverInstanceType.UNIVER_DOC),T=w instanceof r.DocumentDataModel?(e=w.getSelfOrHeaderFooterModel(x))==null?void 0:e.getBody():void 0,E=T==null||(t=T.customRanges)==null?void 0:t.find(e=>e.rangeId===b&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===S&&e.endIndex===C);if(!E)return null;let D=((a=E.properties)==null?void 0:a.url)??`#${((o=E.properties)==null?void 0:o.bookmarkId)??((s=E.properties)==null?void 0:s.headingId)??``}`,O=l.canEditLink(y,g),A=(0,i.getDocumentPermissionValue)(v,y,y,d.UnitAction.Copy);return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-3 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),onPointerEnter:()=>{l.setInfoPopupHovered(!0)},onPointerLeave:()=>{l.setInfoPopupHovered(!1),l.scheduleHideInfoPopup()},onClick:()=>{l.hideInfoPopup()},children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>p.executeCommand(B.id,{unitId:y,linkId:b,segmentId:x}),children:[/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-gray-0`,children:/* @__PURE__ */ (0,u.jsx)(j,{})}),/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{showIfEllipsis:!0,title:D,children:/* @__PURE__ */ (0,u.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{type:`button`,variant:`text`,size:`small`,"aria-label":h.t(`docs-hyper-link-ui.info.copy`),className:`univer-ml-2 !univer-flex univer-size-6 !univer-rounded !univer-border-0 !univer-bg-transparent !univer-p-0 !univer-text-base !univer-font-normal hover:!univer-bg-transparent active:!univer-bg-transparent disabled:!univer-pointer-events-auto disabled:!univer-opacity-40`,disabled:!A,onClick:()=>{navigator.clipboard.writeText(D),m.show({content:h.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.copy`),children:/* @__PURE__ */ (0,u.jsx)(k,{})})}),O&&/* @__PURE__ */ (0,u.jsxs)(u.Fragment,{children:[/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(z.id,{link:g})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.edit`),children:/* @__PURE__ */ (0,u.jsx)(re,{})})}),/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(f.id,{unitId:y,linkId:E.rangeId,segmentId:x})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.cancel`),children:/* @__PURE__ */ (0,u.jsx)(te,{})})})]})]})]})};M.componentKey=`univer.doc.link-info-popup`;function N(e){"@babel/helpers - typeof";return N=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},N(e)}function ie(e,t){if(N(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(N(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ae(e){var t=ie(e,`string`);return N(t)==`symbol`?t:t+``}function P(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e,t){return function(n,r){t(n,r,e)}}function I(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}function L(e,t){return(e==null?void 0:e.linkId)===t.linkId&&e.unitId===t.unitId&&(e.segmentId??``)===(t.segmentId??``)&&e.segmentPage===t.segmentPage&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}let R=class extends r.Disposable{constructor(e,t,n,r,i,a,s,c){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._permissionService=r,this._renderManagerService=i,this._dialogService=a,this._localeService=s,this._commandService=c,P(this,`_editingLink$`,new o.BehaviorSubject(null)),P(this,`_showingLink$`,new o.BehaviorSubject(null)),P(this,`editingLink$`,this._editingLink$.asObservable()),P(this,`showingLink$`,this._showingLink$.asObservable()),P(this,`_editPopup`,null),P(this,`_editPopupUnitId`,null),P(this,`_infoPopup`,null),P(this,`_infoPopupPinned`,!1),P(this,`_infoPopupHovered`,!1),P(this,`_infoPopupHideTimer`,null),P(this,`_infoPopupReplacement`,null),P(this,`_infoPopupSuppressed`,!1),P(this,`_infoPopupSuppressionTimer`,null),this.disposeWithMe(()=>{this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this._editingLink$.complete(),this._showingLink$.complete()}),this.disposeWithMe(this._permissionService.permissionPointUpdate$.subscribe(()=>{let e=this.editing;e&&!this.canEditLink(e.unitId,e)&&this.hideEditPopup();let t=this.showing;t&&this._showingLink$.next({...t})})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{var t,n;((t=this._infoPopupReplacement)==null?void 0:t.info.unitId)===e&&this._cancelScheduledInfoPopupReplacement(),this._editPopupUnitId===e&&this.hideEditPopup(),((n=this.showing)==null?void 0:n.unitId)===e&&this.hideInfoPopup()}))}dispose(){this.hideEditPopup(),this.hideInfoPopup(),super.dispose()}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}get infoPopupPinned(){return this._infoPopupPinned}showEditPopup(e,n){var i;this._cancelScheduledInfoPopupReplacement();let a=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(a&&(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||!this.canEditLink(e,n))return null;this._editPopup&&(this._editPopup.dispose(),this._editPopup=null,this._editPopupUnitId=null),this._editingLink$.next(n);let o=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),s=o==null?void 0:o[o.length-1];if(n){let{segmentId:e,segmentPage:t,startIndex:r,endIndex:i}=n;s={collapsed:!1,startOffset:r,endOffset:i+1,segmentId:e,segmentPage:t},this._textSelectionManagerService.replaceDocRanges([{startOffset:r,endOffset:i+1}])}return s?(this._editPopup=this._openEditSurface(s,e),this._editPopupUnitId=e,this._editPopup):null}hideEditPopup(){this._editingLink$.next(null);let e=this._editPopup;this._editPopup=null,e==null||e.dispose(),this._editPopupUnitId=null}showInfoPopup(e,n){var i;let a=this._univerInstanceService.getUnit(e.unitId,r.UniverInstanceType.UNIVER_DOC);if(!(a instanceof r.DocumentDataModel)||(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||(this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressed))return;let{linkId:o,unitId:s,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}=e;if(L(this.showing,e))n!=null&&n.pinned&&(this._infoPopupPinned=!0);else return this._infoPopup&&=(this._infoPopup.dispose(),null),this._infoPopupPinned=(n==null?void 0:n.pinned)??!1,this._infoPopupHovered=!1,this._showingLink$.next({unitId:s,linkId:o,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}),this._infoPopup=this._openInfoSurface(e),this._infoPopup}_openEditSurface(e,t){return this._docCanvasPopupManagerService.attachPopupToRange(e,{componentKey:b.componentKey,direction:`bottom`,offset:[0,10]},t)}_openInfoSurface(e,t=M.componentKey){let{unitId:n,linkId:r,segmentId:i,segmentPage:a,startIndex:o,endIndex:s}=e;return this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:o,endOffset:s+1,segmentId:i,segmentPage:a},{componentKey:t,extraProps:{onEdit:()=>{this.hideInfoPopup(),this.showEditPopup(n,e)},onDelete:async()=>{await this._commandService.executeCommand(f.id,{unitId:n,linkId:r,segmentId:i})&&this.hideInfoPopup()}},direction:`top-center`,multipleDirection:`top`,offset:[0,10],onClickOutside:()=>{this.hideInfoPopup()}},n)}showInfoPopupFromHover(e){var t;if(this.cancelScheduledHideInfoPopup(),this._infoPopupPinned||this._infoPopupHovered||this._infoPopupSuppressed)return;if(!this.showing||L(this.showing,e)){this.showInfoPopup(e);return}if(L(((t=this._infoPopupReplacement)==null?void 0:t.info)??null,e))return;this._cancelScheduledInfoPopupReplacement();let n={...e};this._infoPopupReplacement={info:n,timer:setTimeout(()=>{this._infoPopupReplacement=null,this.showInfoPopup(n)},200)}}setInfoPopupHovered(e){this._infoPopupHovered=e&&this.showing!==null,this._infoPopupHovered&&(this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup())}_cancelScheduledInfoPopupReplacement(){this._infoPopupReplacement&&=(clearTimeout(this._infoPopupReplacement.timer),null)}hideInfoPopup(){this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup(),this._infoPopupPinned=!1,this._infoPopupHovered=!1,this._showingLink$.next(null);let e=this._infoPopup;this._infoPopup=null,e==null||e.dispose()}scheduleHideInfoPopup(){this._cancelScheduledInfoPopupReplacement(),this._infoPopupPinned||this._infoPopupHovered||!this.showing||(this.cancelScheduledHideInfoPopup(),this._infoPopupHideTimer=setTimeout(()=>{this._infoPopupHideTimer=null,this._infoPopupPinned||this.hideInfoPopup()},150))}cancelScheduledHideInfoPopup(){this._infoPopupHideTimer!==null&&(clearTimeout(this._infoPopupHideTimer),this._infoPopupHideTimer=null)}hideInfoPopupOnPointerDown(){this._infoPopupSuppressed=!0,this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this.hideInfoPopup(),this._infoPopupSuppressionTimer=setTimeout(()=>{this._infoPopupSuppressed=!1,this._infoPopupSuppressionTimer=null},0)}canEditLink(e,t){let n=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(!(n instanceof r.DocumentDataModel))return!1;if(!t)return(0,i.canEditDocumentTargets)(this._permissionService,e,[]);let a=t.segmentId??``;return(0,i.canEditDocumentTargets)(this._permissionService,e,[...(0,i.getDocumentEntityParentPermissionObjectIds)(n,a,`custom-range`,t.linkId),(0,i.getDocumentEntityPermissionObjectId)(a,`custom-range`,t.linkId)])}};R=I([F(0,(0,r.Inject)(t.DocCanvasPopManagerService)),F(1,(0,r.Inject)(i.DocSelectionManagerService)),F(2,r.IUniverInstanceService),F(3,r.IPermissionService),F(4,a.IRenderManagerService),F(5,n.IDialogService),F(6,(0,r.Inject)(r.LocaleService)),F(7,r.ICommandService)],R);let oe=e=>{let t=e.get(i.DocSelectionManagerService),n=e.get(r.IUniverInstanceService),a=t.getTextRanges();if(!(a!=null&&a.length))return!0;let o=a[0];return!(n.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC)&&o&&!o.collapsed)},z={type:r.CommandType.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){var n;let i=t==null?void 0:t.link,a=e.get(r.IUniverInstanceService);if(oe(e)&&!i)return!1;let o=e.get(R),s=(i==null?void 0:i.unitId)||((n=a.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId());return s?(o.showEditPopup(s,i??null),!0):!1}},se={type:r.CommandType.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(R);return t?(t.fromHover?n.showInfoPopupFromHover(t):n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},B={type:r.CommandType.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,n){var o,s;if(!n)return!1;let{unitId:c,linkId:l,segmentId:u}=n,d=e.get(r.IUniverInstanceService).getUnit(c,r.UniverInstanceType.UNIVER_DOC),f=d==null||(o=d.getSelfOrHeaderFooterModel(u))==null?void 0:o.getBody(),p=f==null||(s=f.customRanges)==null||(s=s.find(e=>e.rangeId===l&&e.rangeType===r.CustomRangeType.HYPERLINK))==null?void 0:s.properties;if(p!=null&&p.bookmarkId||p!=null&&p.headingId){var m;let n=ce(d==null?void 0:d.getBody(),p.bookmarkId,p.headingId);if(n==null)return!1;let r={startOffset:n,endOffset:n,collapsed:!0},o=e.get(i.DocSelectionManagerService),s=()=>o.replaceDocRanges([r],{unitId:c,subUnitId:c},!1,{[i.DOC_SELECTION_OPTION_PRESERVE_CARET]:!0}),l=e.get(a.IRenderManagerService).getRenderUnitById(c),u=l==null||(m=l.getInjector)==null?void 0:m.call(l),f=u!=null&&u.has(t.DocBackScrollRenderController)?l==null?void 0:l.with(t.DocBackScrollRenderController):null;return f?f.scrollToRange(r,s):s(),!0}return!(p!=null&&p.url)||!(0,r.isSafeUrl)(p.url)?!1:(window.open(p.url,`_blank`,`noopener noreferrer`),!0)}};function ce(e,t,n){if(e){if(t){var i;let n=(i=e.customRanges)==null?void 0:i.find(e=>{var n;return e.rangeType===r.CustomRangeType.BOOKMARK&&(e.rangeId===t||((n=e.properties)==null?void 0:n.bookmarkId)===t)});if(n)return n.startIndex}if(n){var a;let t=((a=e.paragraphs)==null?void 0:a.findIndex(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.headingId)===n}))??-1;if(t>=0)return t===0?0:e.paragraphs[t-1].startIndex+1}}}function V(e){return{id:z.id,type:n.MenuItemType.BUTTON,icon:`LinkIcon`,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_DOC),disabled$:new o.Observable(function(t){let n=e.get(i.DocSelectionManagerService).textSelection$.pipe((0,o.debounceTime)(16)).subscribe(()=>{t.next(oe(e))});return()=>{n.unsubscribe()}})}}let le={id:z.id,binding:n.MetaKeys.CTRL_COMMAND|n.KeyCode.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:t.whenDocAndEditorFocused},ue={[n.RibbonInsertGroup.MEDIA]:{[z.id]:{order:1,gridLayout:{row:1,column:5},menuItemFactory:V}},[t.FLOAT_TOOLBAR_MENU_POSITION]:{[z.id]:{order:20,menuItemFactory:V}},[n.ContextMenuPosition.MAIN_AREA]:{[n.ContextMenuGroup.DATA]:{[z.id]:{order:0,menuItemFactory:V}}},[n.ContextMenuPosition.PARAGRAPH]:{[n.ContextMenuGroup.LAYOUT]:{[t.INSERT_BELLOW_MENU_ID]:{[z.id]:{order:6,menuItemFactory:V}}},[t.EMPTY_PARAGRAPH_MENU_ID]:{[n.ContextMenuGroup.LAYOUT]:{[z.id]:{order:6,menuItemFactory:V}}}}};var de=`@univerjs/docs-hyper-link-ui`,fe=`1.4.0`;let pe=`docs-hyper-link-ui.config`,H={},U=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,P(this,`_selection`,null),this._initSelectionChange(),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t;((t=this._selection)==null?void 0:t.unitId)===e.getUnitId()&&(this._selection=null)}))}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.RichTextEditingMutation.id){var t;e.params.unitId===((t=this._docHyperLinkService.showing)==null?void 0:t.unitId)&&this._docHyperLinkService.hideInfoPopup()}else if(e.id===i.SetTextSelectionsOperation.id){var n;let t=e.params,{unitId:i,ranges:o,segmentId:s}=t,c=this._univerInstanceService.getUnit(i,r.UniverInstanceType.UNIVER_DOC),l=o[0],u=JSON.stringify([i,s??``,l==null?void 0:l.startOffset,l==null?void 0:l.endOffset,l==null?void 0:l.segmentPage]),d=u===((n=this._selection)==null?void 0:n.key);this._selection={unitId:i,key:u};let f=this._docHyperLinkService.editing;if((f==null?void 0:f.unitId)===i&&(f.segmentId??``)===(s??``)&&(l==null?void 0:l.startOffset)===f.startIndex&&l.endOffset===f.endIndex+1)return;if(t.isEditing){this._docHyperLinkService.hideInfoPopup();return}if(d)return;if(l!=null&&l.collapsed&&c){var a;let{startOffset:e,endOffset:t,segmentPage:n}=l,o=(a=c.getSelfOrHeaderFooterModel(s))==null||(a=a.getBody())==null?void 0:a.customRanges,u=this._docHyperLinkService.showing,d=((u==null?void 0:u.unitId)===i&&(u.segmentId??``)===s&&u.segmentPage===n&&u.endIndex===t-1?o==null?void 0:o.find(n=>n.rangeId===u.linkId&&n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex===t-1):void 0)??(o==null?void 0:o.find(n=>n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex>t-1));if(d){this._docHyperLinkService.showInfoPopup({unitId:i,linkId:d.rangeId,segmentId:s,segmentPage:n,startIndex:d.startIndex,endIndex:d.endIndex});return}}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};U=I([F(0,r.ICommandService),F(1,r.IUniverInstanceService),F(2,(0,r.Inject)(R))],U);function W(){let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full univer-bg-gray-0 univer-py-2 dark:!univer-bg-gray-900`,children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{children:[i?/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!i,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-gap-3`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{className:`univer-h-12 univer-flex-1`,onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),/* @__PURE__ */ (0,u.jsx)(c.Button,{variant:`primary`,className:`univer-h-12 univer-flex-1`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})}W.componentKey=`univer.doc.mobile-hyper-link-edit`;function G(){var e,t,a;let o=(0,n.useDependency)(r.ICommandService),s=(0,n.useDependency)(R),l=(0,n.useDependency)(r.LocaleService),p=(0,n.useDependency)(n.IMessageService),m=(0,n.useDependency)(r.IPermissionService),h=(0,n.useDependency)(r.IUniverInstanceService),g=(0,n.useObservable)(s.showingLink$,s.showing);if(!g)return null;let{unitId:_,linkId:v,segmentId:y,startIndex:b,endIndex:x}=g,S=h.getUnit(_,r.UniverInstanceType.UNIVER_DOC),C=S instanceof r.DocumentDataModel?(e=S.getSelfOrHeaderFooterModel(y))==null?void 0:e.getBody():void 0,w=C==null||(t=C.customRanges)==null?void 0:t.find(e=>e.rangeId===v&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===b&&e.endIndex===x);if(!w)return null;let T=(a=w.properties)==null?void 0:a.url,E=s.canEditLink(_,g),D=(0,i.getDocumentPermissionValue)(m,_,_,d.UnitAction.Copy);return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2 univer-py-2`,children:[/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:/* @__PURE__ */ (0,u.jsx)(`span`,{className:`univer-truncate univer-text-primary-600`,children:T}),"aria-label":T,variant:`subtle`,onClick:()=>window.open(T,void 0,`noopener noreferrer`)}),D&&/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.copy`),"aria-label":l.t(`docs-hyper-link-ui.info.copy`),variant:`subtle`,onClick:()=>navigator.clipboard.writeText(T).then(()=>{p.show({content:l.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})}).catch(()=>void 0)}),E&&/* @__PURE__ */ (0,u.jsxs)(u.Fragment,{children:[/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.edit`),"aria-label":l.t(`docs-hyper-link-ui.info.edit`),variant:`subtle`,onClick:()=>{o.executeCommand(z.id,{link:g}).catch(()=>void 0)}}),/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.cancel`),"aria-label":l.t(`docs-hyper-link-ui.info.cancel`),variant:`subtle`,onClick:()=>{o.executeCommand(f.id,{unitId:_,linkId:w.rangeId,segmentId:y}).catch(()=>void 0)}})]})]})}G.componentKey=`univer.doc.mobile-link-info-popup`;let K=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[W.componentKey,W],[G.componentKey,G]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};K=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],K);let q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,i,a,o){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=i,this._docSkeletonManagerService=a,this._mobileElementMenuService=o,this._context.unitId!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initPointerDown(),this._initClick())}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{let t=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK);if(!t){this._hyperLinkPopupService.hideInfoPopupOnPointerDown();return}let n={unitId:this._context.unitId,linkId:t.range.rangeId,segmentId:t.segmentId,segmentPage:t.segmentPageIndex,startIndex:t.range.startIndex,endIndex:t.range.endIndex},i=t.rects[0];i&&this._hyperLinkPopupService.canEditLink(n.unitId,n)&&this._mobileElementMenuService.capture({unitId:n.unitId,rect:i,onEdit:()=>this._hyperLinkPopupService.showEditPopup(n.unitId,n),onDelete:()=>this._commandService.executeCommand(f.id,n)})}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t.rangeType===r.CustomRangeType.HYPERLINK&&(!e.ctrlKey&&!e.metaKey?this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0}):this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId}))}))}};q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(R)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(t.DocMobileElementMenuService))],q);let J=class extends r.Disposable{constructor(e,t,n){super(),this._docInterceptorService=t,this._hyperLinkService=n,this._init()}_init(){this._docInterceptorService.intercept(i.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}};J=I([F(1,(0,r.Inject)(i.DocInterceptorService)),F(2,(0,r.Inject)(R))],J);let Y=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortcut()}_initCommands(){[p,m,f,z,se,B].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[le].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.appendRootMenu({[t.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(ue)}};Y=I([F(0,r.ICommandService),F(1,n.IMenuManagerService),F(2,n.IShortcutService)],Y);var me=class extends R{_openEditSurface(e,t){return this._dialogService.open({id:`doc-mobile-hyper-link-editor`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:W.componentKey},maskClosable:!1,onClose:()=>this.hideEditPopup()})}_openInfoSurface(e){return this.canEditLink(e.unitId,e)?super._openInfoSurface(e,t.MOBILE_DOC_ELEMENT_MENU):this._dialogService.open({id:`doc-mobile-hyper-link-viewer`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:G.componentKey},onClose:()=>this.hideInfoPopup()})}};let he=`DOC_HYPER_LINK_UI_PLUGIN`,X=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[K],[R,{useClass:me}],[Y],[U]].forEach(e=>this._injector.add(e)),this._injector.get(K),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){[[J],[q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P(X,`pluginName`,he),P(X,`packageName`,de),P(X,`version`,fe),P(X,`type`,r.UniverInstanceType.UNIVER_DOC),X=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsMobileUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],X);let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[b.componentKey,b],[M.componentKey,M]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};Z=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,n,i,a,o,s){var c;super(),this._context=e,this._docEventManagerService=n,this._commandService=i,this._hyperLinkPopupService=a,this._docSkeletonManagerService=o,this._docSelectionManagerService=s,this._context.unitId===r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||(c=(0,t.getEditorRuntimeConfig)(this._context.unit))!=null&&c.customHyperLinkUI||(this._initPointerDown(),this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.infoPopupPinned||this._hyperLinkPopupService.showing&&this._hyperLinkPopupService.scheduleHideInfoPopup()}_normalizeSegmentId(e){var t;return e?(t=this._context.unit.getBody())!=null&&(t=t.tables)!=null&&t.some(t=>t.tableId===e)?``:e:``}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK)||this._hyperLinkPopupService.hideInfoPopupOnPointerDown()}))}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),a=i==null||(t=i[0])==null?void 0:t.segmentId;if(this._normalizeSegmentId(n==null?void 0:n.segmentId)!==this._normalizeSegmentId(a))this._hideInfoPopup();else if(n){let e={unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,startIndex:n.range.startIndex,endIndex:n.range.endIndex};this._commandService.executeCommand(se.id,{...e,fromHover:!0})}else this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t.rangeType===r.CustomRangeType.HYPERLINK&&(!e.ctrlKey&&!e.metaKey?this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0}):this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId}))}))}};Q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(R)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(i.DocSelectionManagerService))],Q);let $=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[Z],[R],[Y],[U]].forEach(e=>{this._injector.add(e)}),this._injector.get(Z),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){this._initRenderModule()}_initRenderModule(){[[J],[Q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P($,`pluginName`,he),P($,`packageName`,de),P($,`version`,fe),P($,`type`,r.UniverInstanceType.UNIVER_DOC),$=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],$),e.DocsHyperLinkUIMenuSchema=ue,Object.defineProperty(e,"UniverDocsHyperLinkMobileUIPlugin",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UniverDocsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs-hyper-link"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/protocol")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/engine-render`,`rxjs`,`@univerjs/docs-hyper-link`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/protocol`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLinkUi={},e.UniverDocsUi,e.UniverUi,e.UniverCore,e.UniverDocs,e.UniverEngineRender,e.rxjs,e.UniverDocsHyperLink,e.UniverDesign,e.React,e.React,e.UniverProtocol))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let f={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Delete,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:a,segmentId:o}=t,s=e.get(r.ICommandService),c=(0,i.deleteCustomRangeFactory)(e,{unitId:n,rangeId:a,segmentId:o});return c?await s.syncExecuteCommand(c.id,c.params):!1}},p={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Add,async handler(e,t){if(!t)return!1;let{payload:n,unitId:a,selections:o}=t,s=e.get(r.ICommandService),c=(0,r.generateRandomId)(),l=(0,i.addCustomRangeBySelectionFactory)(e,{rangeId:c,rangeType:r.CustomRangeType.HYPERLINK,properties:{url:n},unitId:a,selections:o});return l?s.syncExecuteCommand(l.id,l.params):!1}},m={id:s.DocHyperLinkCommandId.Update,type:r.CommandType.COMMAND,handler(e,t){var n,a,o,s,c;if(!t)return!1;let{unitId:l,payload:u,segmentId:d,linkId:f}=t,p=e.get(r.ICommandService),m=e.get(r.IUniverInstanceService),h=e.get(i.DocSelectionManagerService).getActiveTextRange(),g=m.getUnit(l,r.UniverInstanceType.UNIVER_DOC);if(!h||!g)return!1;let _=(n=g.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody();if(!_)return!1;let v=(a=_.customRanges)==null?void 0:a.find(e=>e.rangeId===f&&e.rangeType===r.CustomRangeType.HYPERLINK),y=(o=(0,r.getBodySlice)(_,h.startOffset,h.endOffset).textRuns)==null?void 0:o[0];y&&(y.ed=t.label.length+1);let b=(0,i.replaceSelectionFactory)(e,{unitId:l,body:{dataStream:`${t.label}`,customRanges:[{rangeId:f,rangeType:r.CustomRangeType.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:u,...v!=null&&(s=v.properties)!=null&&s.textStyleMode?{textStyleMode:v.properties.textStyleMode}:null,...v!=null&&(c=v.properties)!=null&&c.textColorMode?{textColorMode:v.properties.textColorMode}:null}}],textRuns:y?[y]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:d}});return b?p.syncExecuteCommand(b.id,b.params):!1}};function h(e){return e.trim().length===0}function g(e){return/^[a-zA-Z]+:\/\//.test(e)}function _(e){return/^[\w.-]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function v(e){return g(e)?e:_(e)?`mailto://${e}`:`https://${e}`}function y(){let e=(0,n.useDependency)(R),t=(0,n.useObservable)(e.editingLink$,e.editing),a=(0,n.useDependency)(r.ICommandService),o=(0,n.useDependency)(r.IUniverInstanceService),s=(0,n.useDependency)(i.DocSelectionManagerService),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[g,_]=(0,l.useState)(!1),y=r.Tools.isLegalUrl(c),b=t?o.getUnit(t.unitId,r.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC);return(0,l.useEffect)(()=>{var e,n;let i=s.getActiveTextRange();if(!i)return;if(t){var a,o;let e=b==null||(a=b.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:a.getBody(),n=e==null||(o=e.customRanges)==null?void 0:o.find(e=>t.linkId===e.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex);if(b&&n){var c;u(((c=n.properties)==null?void 0:c.url)??``),f(r.BuildTextUtils.transform.getPlainText((0,r.getBodySlice)(e,n.startIndex,n.endIndex+1).dataStream))}return}let l=b==null||(e=b.getSelfOrHeaderFooterModel(i.segmentId))==null?void 0:e.getBody(),d=l?i:null,p=d&&((n=r.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(d,(l==null?void 0:l.customRanges)??[]))==null?void 0:n[0]);if(b&&p){var m;u(((m=p.properties)==null?void 0:m.url)??``)}},[b,s,t]),{doc:b,editing:t,handleCancel:()=>e.hideEditPopup(),handleConfirm:()=>{if(_(!0),!y||!b)return;let n=v(c);if(t){if(h(d))return;a.executeCommand(m.id,{unitId:b.getUnitId(),payload:n,linkId:t.linkId,label:d,segmentId:t.segmentId}).catch(()=>void 0)}else a.executeCommand(p.id,{unitId:b.getUnitId(),payload:n}).catch(()=>void 0);e.hideEditPopup()},isLegal:y,label:d,link:c,setLabel:f,setLink:u,showError:g}}let b=()=>{let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-gray-0 univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{children:[i?/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),/* @__PURE__ */ (0,u.jsx)(c.Button,{variant:`primary`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};b.componentKey=`docs-hyper-link-edit`;function x({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return T(d.current)},[n,r]),S(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function S(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...C(e,n,i),...r},(w(e,n).children||[]).map((r,a)=>S(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function C(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function w(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function T(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:E(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(D(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function E(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function D(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}x.displayName=`UniverIcon`;let O={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},k=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`copy-icon`,ref:t,icon:O}))});k.displayName=`CopyIcon`;let A={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.30999 8.71386C6.39955 7.80343 6.37922 6.34731 7.26629 5.45772L10.313 2.41112C11.2111 1.51303 12.6799 1.51258 13.5691 2.45476C14.4811 3.36679 14.4798 4.84384 13.6128 5.71094L10.9677 8.35604`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.0456 7.66774L2.4005 10.3128C1.50242 11.2109 1.50197 12.6798 2.44413 13.5691C3.35615 14.4811 4.8332 14.4798 5.70033 13.6127L8.747 10.566C9.65743 9.65558 9.67776 8.19945 8.7905 7.30999`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}}]},j=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`link-icon`,ref:t,icon:A}))});j.displayName=`LinkIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},te=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:ee}))});te.displayName=`UnlinkIcon`;let ne={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},re=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`write-icon`,ref:t,icon:ne}))});re.displayName=`WriteIcon`;let M=()=>{var e,t,a,o,s;let l=(0,n.useDependency)(R),p=(0,n.useDependency)(r.ICommandService),m=(0,n.useDependency)(n.IMessageService),h=(0,n.useDependency)(r.LocaleService),g=(0,n.useObservable)(l.showingLink$,l.showing),_=(0,n.useDependency)(r.IUniverInstanceService),v=(0,n.useDependency)(r.IPermissionService);if(!g)return null;let{unitId:y,linkId:b,segmentId:x,startIndex:S,endIndex:C}=g,w=_.getUnit(y,r.UniverInstanceType.UNIVER_DOC),T=w instanceof r.DocumentDataModel?(e=w.getSelfOrHeaderFooterModel(x))==null?void 0:e.getBody():void 0,E=T==null||(t=T.customRanges)==null?void 0:t.find(e=>e.rangeId===b&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===S&&e.endIndex===C);if(!E)return null;let D=((a=E.properties)==null?void 0:a.url)??`#${((o=E.properties)==null?void 0:o.bookmarkId)??((s=E.properties)==null?void 0:s.headingId)??``}`,O=l.canEditLink(y,g),A=(0,i.getDocumentPermissionValue)(v,y,y,d.UnitAction.Copy);return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-3 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),onPointerEnter:()=>{l.setInfoPopupHovered(!0)},onPointerLeave:()=>{l.setInfoPopupHovered(!1),l.scheduleHideInfoPopup()},onClick:()=>{l.hideInfoPopup()},children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>p.executeCommand(B.id,{unitId:y,linkId:b,segmentId:x}),children:[/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-gray-0`,children:/* @__PURE__ */ (0,u.jsx)(j,{})}),/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{showIfEllipsis:!0,title:D,children:/* @__PURE__ */ (0,u.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{type:`button`,variant:`text`,size:`small`,"aria-label":h.t(`docs-hyper-link-ui.info.copy`),className:`univer-ml-2 !univer-flex univer-size-6 !univer-rounded !univer-border-0 !univer-bg-transparent !univer-p-0 !univer-text-base !univer-font-normal hover:!univer-bg-transparent active:!univer-bg-transparent disabled:!univer-pointer-events-auto disabled:!univer-opacity-40`,disabled:!A,onClick:()=>{navigator.clipboard.writeText(D),m.show({content:h.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.copy`),children:/* @__PURE__ */ (0,u.jsx)(k,{})})}),O&&/* @__PURE__ */ (0,u.jsxs)(u.Fragment,{children:[/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(z.id,{link:g})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.edit`),children:/* @__PURE__ */ (0,u.jsx)(re,{})})}),/* @__PURE__ */ (0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(f.id,{unitId:y,linkId:E.rangeId,segmentId:x})},children:/* @__PURE__ */ (0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.cancel`),children:/* @__PURE__ */ (0,u.jsx)(te,{})})})]})]})]})};M.componentKey=`univer.doc.link-info-popup`;function N(e){"@babel/helpers - typeof";return N=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},N(e)}function ie(e,t){if(N(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(N(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ae(e){var t=ie(e,`string`);return N(t)==`symbol`?t:t+``}function P(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e,t){return function(n,r){t(n,r,e)}}function I(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}function L(e,t){return(e==null?void 0:e.linkId)===t.linkId&&e.unitId===t.unitId&&(e.segmentId??``)===(t.segmentId??``)&&e.segmentPage===t.segmentPage&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}let R=class extends r.Disposable{constructor(e,t,n,r,i,a,s,c){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._permissionService=r,this._renderManagerService=i,this._dialogService=a,this._localeService=s,this._commandService=c,P(this,`_editingLink$`,new o.BehaviorSubject(null)),P(this,`_showingLink$`,new o.BehaviorSubject(null)),P(this,`editingLink$`,this._editingLink$.asObservable()),P(this,`showingLink$`,this._showingLink$.asObservable()),P(this,`_editPopup`,null),P(this,`_editPopupUnitId`,null),P(this,`_infoPopup`,null),P(this,`_infoPopupPinned`,!1),P(this,`_infoPopupHovered`,!1),P(this,`_infoPopupHideTimer`,null),P(this,`_infoPopupReplacement`,null),P(this,`_infoPopupSuppressed`,!1),P(this,`_infoPopupSuppressionTimer`,null),this.disposeWithMe(()=>{this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this._editingLink$.complete(),this._showingLink$.complete()}),this.disposeWithMe(this._permissionService.permissionPointUpdate$.subscribe(()=>{let e=this.editing;e&&!this.canEditLink(e.unitId,e)&&this.hideEditPopup();let t=this.showing;t&&this._showingLink$.next({...t})})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{var t,n;((t=this._infoPopupReplacement)==null?void 0:t.info.unitId)===e&&this._cancelScheduledInfoPopupReplacement(),this._editPopupUnitId===e&&this.hideEditPopup(),((n=this.showing)==null?void 0:n.unitId)===e&&this.hideInfoPopup()}))}dispose(){this.hideEditPopup(),this.hideInfoPopup(),super.dispose()}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}get infoPopupPinned(){return this._infoPopupPinned}showEditPopup(e,n){var i;this._cancelScheduledInfoPopupReplacement();let a=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(a&&(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||!this.canEditLink(e,n))return null;this._editPopup&&(this._editPopup.dispose(),this._editPopup=null,this._editPopupUnitId=null),this._editingLink$.next(n);let o=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),s=o==null?void 0:o[o.length-1];if(n){let{segmentId:e,segmentPage:t,startIndex:r,endIndex:i}=n;s={collapsed:!1,startOffset:r,endOffset:i+1,segmentId:e,segmentPage:t},this._textSelectionManagerService.replaceDocRanges([{startOffset:r,endOffset:i+1}])}return s?(this._editPopup=this._openEditSurface(s,e),this._editPopupUnitId=e,this._editPopup):null}hideEditPopup(){this._editingLink$.next(null);let e=this._editPopup;this._editPopup=null,e==null||e.dispose(),this._editPopupUnitId=null}showInfoPopup(e,n){var i;let a=this._univerInstanceService.getUnit(e.unitId,r.UniverInstanceType.UNIVER_DOC);if(!(a instanceof r.DocumentDataModel)||(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||(this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressed))return;let{linkId:o,unitId:s,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}=e;if(L(this.showing,e))n!=null&&n.pinned&&(this._infoPopupPinned=!0);else return this._infoPopup&&=(this._infoPopup.dispose(),null),this._infoPopupPinned=(n==null?void 0:n.pinned)??!1,this._infoPopupHovered=!1,this._showingLink$.next({unitId:s,linkId:o,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}),this._infoPopup=this._openInfoSurface(e),this._infoPopup}_openEditSurface(e,t){return this._docCanvasPopupManagerService.attachPopupToRange(e,{componentKey:b.componentKey,direction:`bottom`,offset:[0,10]},t)}_openInfoSurface(e,t=M.componentKey){let{unitId:n,linkId:r,segmentId:i,segmentPage:a,startIndex:o,endIndex:s}=e;return this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:o,endOffset:s+1,segmentId:i,segmentPage:a},{componentKey:t,extraProps:{onEdit:()=>{this.hideInfoPopup(),this.showEditPopup(n,e)},onDelete:async()=>{await this._commandService.executeCommand(f.id,{unitId:n,linkId:r,segmentId:i})&&this.hideInfoPopup()}},direction:`top-center`,multipleDirection:`top`,offset:[0,10],onClickOutside:()=>{this.hideInfoPopup()}},n)}showInfoPopupFromHover(e){var t;if(this.cancelScheduledHideInfoPopup(),this._infoPopupPinned||this._infoPopupHovered||this._infoPopupSuppressed)return;if(!this.showing||L(this.showing,e)){this.showInfoPopup(e);return}if(L(((t=this._infoPopupReplacement)==null?void 0:t.info)??null,e))return;this._cancelScheduledInfoPopupReplacement();let n={...e};this._infoPopupReplacement={info:n,timer:setTimeout(()=>{this._infoPopupReplacement=null,this.showInfoPopup(n)},200)}}setInfoPopupHovered(e){this._infoPopupHovered=e&&this.showing!==null,this._infoPopupHovered&&(this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup())}_cancelScheduledInfoPopupReplacement(){this._infoPopupReplacement&&=(clearTimeout(this._infoPopupReplacement.timer),null)}hideInfoPopup(){this._cancelScheduledInfoPopupReplacement(),this.cancelScheduledHideInfoPopup(),this._infoPopupPinned=!1,this._infoPopupHovered=!1,this._showingLink$.next(null);let e=this._infoPopup;this._infoPopup=null,e==null||e.dispose()}scheduleHideInfoPopup(){this._cancelScheduledInfoPopupReplacement(),this._infoPopupPinned||this._infoPopupHovered||!this.showing||(this.cancelScheduledHideInfoPopup(),this._infoPopupHideTimer=setTimeout(()=>{this._infoPopupHideTimer=null,this._infoPopupPinned||this.hideInfoPopup()},150))}cancelScheduledHideInfoPopup(){this._infoPopupHideTimer!==null&&(clearTimeout(this._infoPopupHideTimer),this._infoPopupHideTimer=null)}hideInfoPopupOnPointerDown(){this._infoPopupSuppressed=!0,this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this.hideInfoPopup(),this._infoPopupSuppressionTimer=setTimeout(()=>{this._infoPopupSuppressed=!1,this._infoPopupSuppressionTimer=null},0)}canEditLink(e,t){let n=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(!(n instanceof r.DocumentDataModel))return!1;if(!t)return(0,i.canEditDocumentTargets)(this._permissionService,e,[]);let a=t.segmentId??``;return(0,i.canEditDocumentTargets)(this._permissionService,e,[...(0,i.getDocumentEntityParentPermissionObjectIds)(n,a,`custom-range`,t.linkId),(0,i.getDocumentEntityPermissionObjectId)(a,`custom-range`,t.linkId)])}};R=I([F(0,(0,r.Inject)(t.DocCanvasPopManagerService)),F(1,(0,r.Inject)(i.DocSelectionManagerService)),F(2,r.IUniverInstanceService),F(3,r.IPermissionService),F(4,a.IRenderManagerService),F(5,n.IDialogService),F(6,(0,r.Inject)(r.LocaleService)),F(7,r.ICommandService)],R);let oe=e=>{let t=e.get(i.DocSelectionManagerService),n=e.get(r.IUniverInstanceService),a=t.getTextRanges();if(!(a!=null&&a.length))return!0;let o=a[0];return!(n.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC)&&o&&!o.collapsed)},z={type:r.CommandType.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){var n;let i=t==null?void 0:t.link,a=e.get(r.IUniverInstanceService);if(oe(e)&&!i)return!1;let o=e.get(R),s=(i==null?void 0:i.unitId)||((n=a.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId());return s?(o.showEditPopup(s,i??null),!0):!1}},se={type:r.CommandType.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(R);return t?(t.fromHover?n.showInfoPopupFromHover(t):n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},B={type:r.CommandType.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,n){var o,s;if(!n)return!1;let{unitId:c,linkId:l,segmentId:u}=n,d=e.get(r.IUniverInstanceService).getUnit(c,r.UniverInstanceType.UNIVER_DOC),f=d==null||(o=d.getSelfOrHeaderFooterModel(u))==null?void 0:o.getBody(),p=f==null||(s=f.customRanges)==null||(s=s.find(e=>e.rangeId===l&&e.rangeType===r.CustomRangeType.HYPERLINK))==null?void 0:s.properties;if(p!=null&&p.bookmarkId||p!=null&&p.headingId){var m;let n=ce(d==null?void 0:d.getBody(),p.bookmarkId,p.headingId);if(n==null)return!1;let r={startOffset:n,endOffset:n,collapsed:!0},o=e.get(i.DocSelectionManagerService),s=()=>o.replaceDocRanges([r],{unitId:c,subUnitId:c},!1,{[i.DOC_SELECTION_OPTION_PRESERVE_CARET]:!0}),l=e.get(a.IRenderManagerService).getRenderUnitById(c),u=l==null||(m=l.getInjector)==null?void 0:m.call(l),f=u!=null&&u.has(t.DocBackScrollRenderController)?l==null?void 0:l.with(t.DocBackScrollRenderController):null;return f?f.scrollToRange(r,s):s(),!0}return!(p!=null&&p.url)||!(0,r.isSafeUrl)(p.url)?!1:(window.open(p.url,`_blank`,`noopener noreferrer`),!0)}};function ce(e,t,n){if(e){if(t){var i;let n=(i=e.customRanges)==null?void 0:i.find(e=>{var n;return e.rangeType===r.CustomRangeType.BOOKMARK&&(e.rangeId===t||((n=e.properties)==null?void 0:n.bookmarkId)===t)});if(n)return n.startIndex}if(n){var a;let t=((a=e.paragraphs)==null?void 0:a.findIndex(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.headingId)===n}))??-1;if(t>=0)return t===0?0:e.paragraphs[t-1].startIndex+1}}}function V(e){return{id:z.id,type:n.MenuItemType.BUTTON,icon:`LinkIcon`,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_DOC),disabled$:new o.Observable(function(t){let n=e.get(i.DocSelectionManagerService).textSelection$.pipe((0,o.debounceTime)(16)).subscribe(()=>{t.next(oe(e))});return()=>{n.unsubscribe()}})}}let le={id:z.id,binding:n.MetaKeys.CTRL_COMMAND|n.KeyCode.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:t.whenDocAndEditorFocused},ue={[n.RibbonInsertGroup.MEDIA]:{[z.id]:{order:1,gridLayout:{row:1,column:5},menuItemFactory:V}},[t.FLOAT_TOOLBAR_MENU_POSITION]:{[z.id]:{order:20,menuItemFactory:V}},[n.ContextMenuPosition.MAIN_AREA]:{[n.ContextMenuGroup.DATA]:{[z.id]:{order:0,menuItemFactory:V}}},[n.ContextMenuPosition.PARAGRAPH]:{[n.ContextMenuGroup.LAYOUT]:{[t.INSERT_BELLOW_MENU_ID]:{[z.id]:{order:6,menuItemFactory:V}}},[t.EMPTY_PARAGRAPH_MENU_ID]:{[n.ContextMenuGroup.LAYOUT]:{[z.id]:{order:6,menuItemFactory:V}}}}};var de=`@univerjs/docs-hyper-link-ui`,fe=`1.5.1`;let pe=`docs-hyper-link-ui.config`,H={},U=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,P(this,`_selection`,null),this._initSelectionChange(),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t;((t=this._selection)==null?void 0:t.unitId)===e.getUnitId()&&(this._selection=null)}))}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.RichTextEditingMutation.id){var t;e.params.unitId===((t=this._docHyperLinkService.showing)==null?void 0:t.unitId)&&this._docHyperLinkService.hideInfoPopup()}else if(e.id===i.SetTextSelectionsOperation.id){var n;let t=e.params,{unitId:i,ranges:o,segmentId:s}=t,c=this._univerInstanceService.getUnit(i,r.UniverInstanceType.UNIVER_DOC),l=o[0],u=JSON.stringify([i,s??``,l==null?void 0:l.startOffset,l==null?void 0:l.endOffset,l==null?void 0:l.segmentPage]),d=u===((n=this._selection)==null?void 0:n.key);this._selection={unitId:i,key:u};let f=this._docHyperLinkService.editing;if((f==null?void 0:f.unitId)===i&&(f.segmentId??``)===(s??``)&&(l==null?void 0:l.startOffset)===f.startIndex&&l.endOffset===f.endIndex+1)return;if(t.isEditing){this._docHyperLinkService.hideInfoPopup();return}if(d)return;if(l!=null&&l.collapsed&&c){var a;let{startOffset:e,endOffset:t,segmentPage:n}=l,o=(a=c.getSelfOrHeaderFooterModel(s))==null||(a=a.getBody())==null?void 0:a.customRanges,u=this._docHyperLinkService.showing,d=((u==null?void 0:u.unitId)===i&&(u.segmentId??``)===s&&u.segmentPage===n&&u.endIndex===t-1?o==null?void 0:o.find(n=>n.rangeId===u.linkId&&n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex===t-1):void 0)??(o==null?void 0:o.find(n=>n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex>t-1));if(d){this._docHyperLinkService.showInfoPopup({unitId:i,linkId:d.rangeId,segmentId:s,segmentPage:n,startIndex:d.startIndex,endIndex:d.endIndex});return}}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};U=I([F(0,r.ICommandService),F(1,r.IUniverInstanceService),F(2,(0,r.Inject)(R))],U);function W(){let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full univer-bg-gray-0 univer-py-2 dark:!univer-bg-gray-900`,children:[/* @__PURE__ */ (0,u.jsxs)(`div`,{children:[i?/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()},size:`small`})}):null,/* @__PURE__ */ (0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:/* @__PURE__ */ (0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!i,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()},size:`small`})})]}),/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-gap-3`,children:[/* @__PURE__ */ (0,u.jsx)(c.Button,{className:`univer-flex-1`,onClick:a,size:`middle`,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),/* @__PURE__ */ (0,u.jsx)(c.Button,{variant:`primary`,className:`univer-flex-1`,disabled:h(d),onClick:o,size:`middle`,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})}W.componentKey=`univer.doc.mobile-hyper-link-edit`;function G(){var e,t,a;let o=(0,n.useDependency)(r.ICommandService),s=(0,n.useDependency)(R),l=(0,n.useDependency)(r.LocaleService),p=(0,n.useDependency)(n.IMessageService),m=(0,n.useDependency)(r.IPermissionService),h=(0,n.useDependency)(r.IUniverInstanceService),g=(0,n.useObservable)(s.showingLink$,s.showing);if(!g)return null;let{unitId:_,linkId:v,segmentId:y,startIndex:b,endIndex:x}=g,S=h.getUnit(_,r.UniverInstanceType.UNIVER_DOC),C=S instanceof r.DocumentDataModel?(e=S.getSelfOrHeaderFooterModel(y))==null?void 0:e.getBody():void 0,w=C==null||(t=C.customRanges)==null?void 0:t.find(e=>e.rangeId===v&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===b&&e.endIndex===x);if(!w)return null;let T=(a=w.properties)==null?void 0:a.url,E=s.canEditLink(_,g),D=(0,i.getDocumentPermissionValue)(m,_,_,d.UnitAction.Copy);return/* @__PURE__ */ (0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2 univer-py-2`,children:[/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:/* @__PURE__ */ (0,u.jsx)(`span`,{className:`univer-truncate univer-text-primary-600`,children:T}),"aria-label":T,variant:`subtle`,onClick:()=>window.open(T,void 0,`noopener noreferrer`)}),D&&/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.copy`),"aria-label":l.t(`docs-hyper-link-ui.info.copy`),variant:`subtle`,onClick:()=>navigator.clipboard.writeText(T).then(()=>{p.show({content:l.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})}).catch(()=>void 0)}),E&&/* @__PURE__ */ (0,u.jsxs)(u.Fragment,{children:[/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.edit`),"aria-label":l.t(`docs-hyper-link-ui.info.edit`),variant:`subtle`,onClick:()=>{o.executeCommand(z.id,{link:g}).catch(()=>void 0)}}),/* @__PURE__ */ (0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.cancel`),"aria-label":l.t(`docs-hyper-link-ui.info.cancel`),variant:`subtle`,onClick:()=>{o.executeCommand(f.id,{unitId:_,linkId:w.rangeId,segmentId:y}).catch(()=>void 0)}})]})]})}G.componentKey=`univer.doc.mobile-link-info-popup`;let K=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[W.componentKey,W],[G.componentKey,G]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};K=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],K);let q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,i,a,o){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=i,this._docSkeletonManagerService=a,this._mobileElementMenuService=o,this._context.unitId!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initPointerDown(),this._initClick())}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{let t=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK);if(!t){this._hyperLinkPopupService.hideInfoPopupOnPointerDown();return}let n={unitId:this._context.unitId,linkId:t.range.rangeId,segmentId:t.segmentId,segmentPage:t.segmentPageIndex,startIndex:t.range.startIndex,endIndex:t.range.endIndex},i=t.rects[0];i&&this._hyperLinkPopupService.canEditLink(n.unitId,n)&&this._mobileElementMenuService.capture({unitId:n.unitId,rect:i,onEdit:()=>this._hyperLinkPopupService.showEditPopup(n.unitId,n),onDelete:()=>this._commandService.executeCommand(f.id,n)})}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t.rangeType===r.CustomRangeType.HYPERLINK&&(!e.ctrlKey&&!e.metaKey?this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0}):this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId}))}))}};q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(R)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(t.DocMobileElementMenuService))],q);let J=class extends r.Disposable{constructor(e,t,n){super(),this._docInterceptorService=t,this._hyperLinkService=n,this._init()}_init(){this._docInterceptorService.intercept(i.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}};J=I([F(1,(0,r.Inject)(i.DocInterceptorService)),F(2,(0,r.Inject)(R))],J);let Y=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortcut()}_initCommands(){[p,m,f,z,se,B].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[le].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.appendRootMenu({[t.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(ue)}};Y=I([F(0,r.ICommandService),F(1,n.IMenuManagerService),F(2,n.IShortcutService)],Y);var me=class extends R{_openEditSurface(e,t){return this._dialogService.open({id:`doc-mobile-hyper-link-editor`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:W.componentKey},maskClosable:!1,onClose:()=>this.hideEditPopup()})}_openInfoSurface(e){return this.canEditLink(e.unitId,e)?super._openInfoSurface(e,t.MOBILE_DOC_ELEMENT_MENU):this._dialogService.open({id:`doc-mobile-hyper-link-viewer`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:G.componentKey},onClose:()=>this.hideInfoPopup()})}};let he=`DOC_HYPER_LINK_UI_PLUGIN`,X=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[K],[R,{useClass:me}],[Y],[U]].forEach(e=>this._injector.add(e)),this._injector.get(K),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){[[J],[q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P(X,`pluginName`,he),P(X,`packageName`,de),P(X,`version`,fe),P(X,`type`,r.UniverInstanceType.UNIVER_DOC),X=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsMobileUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],X);let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[b.componentKey,b],[M.componentKey,M]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};Z=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,n,i,a,o,s){var c;super(),this._context=e,this._docEventManagerService=n,this._commandService=i,this._hyperLinkPopupService=a,this._docSkeletonManagerService=o,this._docSelectionManagerService=s,this._context.unitId===r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||(c=(0,t.getEditorRuntimeConfig)(this._context.unit))!=null&&c.customHyperLinkUI||(this._initPointerDown(),this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.infoPopupPinned||this._hyperLinkPopupService.showing&&this._hyperLinkPopupService.scheduleHideInfoPopup()}_normalizeSegmentId(e){var t;return e?(t=this._context.unit.getBody())!=null&&(t=t.tables)!=null&&t.some(t=>t.tableId===e)?``:e:``}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK)||this._hyperLinkPopupService.hideInfoPopupOnPointerDown()}))}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),a=i==null||(t=i[0])==null?void 0:t.segmentId;if(this._normalizeSegmentId(n==null?void 0:n.segmentId)!==this._normalizeSegmentId(a))this._hideInfoPopup();else if(n){let e={unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,startIndex:n.range.startIndex,endIndex:n.range.endIndex};this._commandService.executeCommand(se.id,{...e,fromHover:!0})}else this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t.rangeType===r.CustomRangeType.HYPERLINK&&(!e.ctrlKey&&!e.metaKey?this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0}):this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId}))}))}};Q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(R)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(i.DocSelectionManagerService))],Q);let $=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[Z],[R],[Y],[U]].forEach(e=>{this._injector.add(e)}),this._injector.get(Z),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){this._initRenderModule()}_initRenderModule(){[[J],[Q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P($,`pluginName`,he),P($,`packageName`,de),P($,`version`,fe),P($,`type`,r.UniverInstanceType.UNIVER_DOC),$=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],$),e.DocsHyperLinkUIMenuSchema=ue,Object.defineProperty(e,"UniverDocsHyperLinkMobileUIPlugin",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UniverDocsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link-ui",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "private": false,
5
5
  "description": "Hyperlink editing UI for Univer Docs.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,24 +58,24 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "1.4.0",
62
- "@univerjs/design": "1.4.0",
63
- "@univerjs/docs": "1.4.0",
64
- "@univerjs/docs-hyper-link": "1.4.0",
65
- "@univerjs/docs-ui": "1.4.0",
66
- "@univerjs/engine-render": "1.4.0",
61
+ "@univerjs/core": "1.5.1",
62
+ "@univerjs/design": "1.5.1",
63
+ "@univerjs/docs": "1.5.1",
64
+ "@univerjs/docs-hyper-link": "1.5.1",
65
+ "@univerjs/docs-ui": "1.5.1",
66
+ "@univerjs/engine-render": "1.5.1",
67
67
  "@univerjs/icons": "1.47.0",
68
- "@univerjs/protocol": "1.4.0",
69
- "@univerjs/ui": "1.4.0"
68
+ "@univerjs/protocol": "1.5.1",
69
+ "@univerjs/ui": "1.5.1"
70
70
  },
71
71
  "devDependencies": {
72
- "@univerjs-infra/shared": "1.4.0",
72
+ "@univerjs-infra/shared": "1.5.1",
73
73
  "postcss": "^8.5.32",
74
74
  "react": "18.3.1",
75
75
  "rxjs": "7.8.2",
76
76
  "tailwindcss": "3.4.18",
77
- "tsrs": "0.20.1-ts7.1.0-beta",
78
- "vitest": "^5.0.5"
77
+ "tsrs": "0.23.0-ts7.1.0-beta",
78
+ "vitest": "^5.1.0"
79
79
  },
80
80
  "scripts": {
81
81
  "test": "vitest run",