@univerjs/docs-hyper-link-ui 1.0.0-beta.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/cjs/index.js +42 -24
  2. package/lib/cjs/locale/ar-SA.js +0 -2
  3. package/lib/cjs/locale/ca-ES.js +0 -2
  4. package/lib/cjs/locale/de-DE.js +0 -2
  5. package/lib/cjs/locale/en-US.js +0 -2
  6. package/lib/cjs/locale/es-ES.js +0 -2
  7. package/lib/cjs/locale/fa-IR.js +0 -2
  8. package/lib/cjs/locale/fr-FR.js +0 -2
  9. package/lib/cjs/locale/id-ID.js +0 -2
  10. package/lib/cjs/locale/it-IT.js +0 -2
  11. package/lib/cjs/locale/ja-JP.js +0 -2
  12. package/lib/cjs/locale/ko-KR.js +0 -2
  13. package/lib/cjs/locale/pl-PL.js +0 -2
  14. package/lib/cjs/locale/pt-BR.js +0 -2
  15. package/lib/cjs/locale/ru-RU.js +0 -2
  16. package/lib/cjs/locale/sk-SK.js +0 -2
  17. package/lib/cjs/locale/vi-VN.js +0 -2
  18. package/lib/cjs/locale/zh-CN.js +0 -2
  19. package/lib/cjs/locale/zh-HK.js +0 -2
  20. package/lib/cjs/locale/zh-TW.js +0 -2
  21. package/lib/es/index.js +42 -24
  22. package/lib/es/locale/ar-SA.js +0 -2
  23. package/lib/es/locale/ca-ES.js +0 -2
  24. package/lib/es/locale/de-DE.js +0 -2
  25. package/lib/es/locale/en-US.js +0 -2
  26. package/lib/es/locale/es-ES.js +0 -2
  27. package/lib/es/locale/fa-IR.js +0 -2
  28. package/lib/es/locale/fr-FR.js +0 -2
  29. package/lib/es/locale/id-ID.js +0 -2
  30. package/lib/es/locale/it-IT.js +0 -2
  31. package/lib/es/locale/ja-JP.js +0 -2
  32. package/lib/es/locale/ko-KR.js +0 -2
  33. package/lib/es/locale/pl-PL.js +0 -2
  34. package/lib/es/locale/pt-BR.js +0 -2
  35. package/lib/es/locale/ru-RU.js +0 -2
  36. package/lib/es/locale/sk-SK.js +0 -2
  37. package/lib/es/locale/vi-VN.js +0 -2
  38. package/lib/es/locale/zh-CN.js +0 -2
  39. package/lib/es/locale/zh-HK.js +0 -2
  40. package/lib/es/locale/zh-TW.js +0 -2
  41. package/lib/index.css +4 -4
  42. package/lib/index.js +42 -24
  43. package/lib/locale/ar-SA.js +0 -2
  44. package/lib/locale/ca-ES.js +0 -2
  45. package/lib/locale/de-DE.js +0 -2
  46. package/lib/locale/en-US.js +0 -2
  47. package/lib/locale/es-ES.js +0 -2
  48. package/lib/locale/fa-IR.js +0 -2
  49. package/lib/locale/fr-FR.js +0 -2
  50. package/lib/locale/id-ID.js +0 -2
  51. package/lib/locale/it-IT.js +0 -2
  52. package/lib/locale/ja-JP.js +0 -2
  53. package/lib/locale/ko-KR.js +0 -2
  54. package/lib/locale/pl-PL.js +0 -2
  55. package/lib/locale/pt-BR.js +0 -2
  56. package/lib/locale/ru-RU.js +0 -2
  57. package/lib/locale/sk-SK.js +0 -2
  58. package/lib/locale/vi-VN.js +0 -2
  59. package/lib/locale/zh-CN.js +0 -2
  60. package/lib/locale/zh-HK.js +0 -2
  61. package/lib/locale/zh-TW.js +0 -2
  62. package/lib/types/controllers/render-controllers/hyper-link-event.render-controller.d.ts +1 -0
  63. package/lib/types/locale/en-US.d.ts +0 -2
  64. package/lib/types/services/hyper-link-popup.service.d.ts +3 -0
  65. package/lib/umd/index.js +1 -1
  66. package/lib/umd/locale/ar-SA.js +1 -1
  67. package/lib/umd/locale/ca-ES.js +1 -1
  68. package/lib/umd/locale/de-DE.js +1 -1
  69. package/lib/umd/locale/en-US.js +1 -1
  70. package/lib/umd/locale/es-ES.js +1 -1
  71. package/lib/umd/locale/fa-IR.js +1 -1
  72. package/lib/umd/locale/fr-FR.js +1 -1
  73. package/lib/umd/locale/id-ID.js +1 -1
  74. package/lib/umd/locale/it-IT.js +1 -1
  75. package/lib/umd/locale/ja-JP.js +1 -1
  76. package/lib/umd/locale/ko-KR.js +1 -1
  77. package/lib/umd/locale/pl-PL.js +1 -1
  78. package/lib/umd/locale/pt-BR.js +1 -1
  79. package/lib/umd/locale/ru-RU.js +1 -1
  80. package/lib/umd/locale/sk-SK.js +1 -1
  81. package/lib/umd/locale/vi-VN.js +1 -1
  82. package/lib/umd/locale/zh-CN.js +1 -1
  83. package/lib/umd/locale/zh-HK.js +1 -1
  84. package/lib/umd/locale/zh-TW.js +1 -1
  85. package/package.json +10 -10
package/lib/cjs/index.js CHANGED
@@ -171,7 +171,7 @@ const DocHyperLinkEdit = () => {
171
171
  };
172
172
  if (!doc) return;
173
173
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
174
- className: (0, _univerjs_design.clsx)("univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
174
+ className: (0, _univerjs_design.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", _univerjs_design.borderClassName),
175
175
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
176
176
  label: localeService.t("docs-hyper-link-ui.edit.label"),
177
177
  error: showError && isBlankInput(label) ? localeService.t("docs-hyper-link-ui.edit.labelError") : "",
@@ -247,7 +247,7 @@ const DocLinkPopup = () => {
247
247
  if (!link) return null;
248
248
  const url = (_link$properties = link.properties) === null || _link$properties === void 0 ? void 0 : _link$properties.url;
249
249
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
250
- className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
250
+ className: (0, _univerjs_design.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", _univerjs_design.borderClassName),
251
251
  onClick: () => {
252
252
  hyperLinkService.hideInfoPopup();
253
253
  },
@@ -255,7 +255,7 @@ const DocLinkPopup = () => {
255
255
  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",
256
256
  onClick: () => window.open(url, void 0, "noopener noreferrer"),
257
257
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
258
- 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-white",
258
+ 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",
259
259
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LinkIcon, {})
260
260
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
261
261
  showIfEllipsis: true,
@@ -388,7 +388,10 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
388
388
  _defineProperty(this, "showingLink$", this._showingLink$.asObservable());
389
389
  _defineProperty(this, "_editPopup", null);
390
390
  _defineProperty(this, "_infoPopup", null);
391
+ _defineProperty(this, "_infoPopupSuppressed", false);
392
+ _defineProperty(this, "_infoPopupSuppressionTimer", null);
391
393
  this.disposeWithMe(() => {
394
+ if (this._infoPopupSuppressionTimer !== null) clearTimeout(this._infoPopupSuppressionTimer);
392
395
  this._editingLink$.complete();
393
396
  this._showingLink$.complete();
394
397
  });
@@ -424,7 +427,8 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
424
427
  if (activeRange) {
425
428
  this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(activeRange, {
426
429
  componentKey: DocHyperLinkEdit.componentKey,
427
- direction: "bottom"
430
+ direction: "bottom",
431
+ offset: [0, 10]
428
432
  }, unitId);
429
433
  return this._editPopup;
430
434
  }
@@ -437,6 +441,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
437
441
  }
438
442
  showInfoPopup(info) {
439
443
  var _this$showing, _this$showing2, _this$showing3, _this$showing4, _this$showing5, _this$showing6;
444
+ if (this._infoPopupSuppressed) return;
440
445
  const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
441
446
  if (((_this$showing = this.showing) === null || _this$showing === void 0 ? void 0 : _this$showing.linkId) === linkId && ((_this$showing2 = this.showing) === null || _this$showing2 === void 0 ? void 0 : _this$showing2.unitId) === unitId && ((_this$showing3 = this.showing) === null || _this$showing3 === void 0 ? void 0 : _this$showing3.segmentId) === segmentId && ((_this$showing4 = this.showing) === null || _this$showing4 === void 0 ? void 0 : _this$showing4.segmentPage) === segmentPage && ((_this$showing5 = this.showing) === null || _this$showing5 === void 0 ? void 0 : _this$showing5.startIndex) === startIndex && ((_this$showing6 = this.showing) === null || _this$showing6 === void 0 ? void 0 : _this$showing6.endIndex) === endIndex) return;
442
447
  if (this._infoPopup) this._infoPopup.dispose();
@@ -459,6 +464,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
459
464
  componentKey: DocLinkPopup.componentKey,
460
465
  direction: "top-center",
461
466
  multipleDirection: "top",
467
+ offset: [0, 10],
462
468
  onClickOutside: () => {
463
469
  this.hideInfoPopup();
464
470
  }
@@ -470,6 +476,15 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
470
476
  this._showingLink$.next(null);
471
477
  (_this$_infoPopup = this._infoPopup) === null || _this$_infoPopup === void 0 || _this$_infoPopup.dispose();
472
478
  }
479
+ hideInfoPopupOnPointerDown() {
480
+ this._infoPopupSuppressed = true;
481
+ if (this._infoPopupSuppressionTimer !== null) clearTimeout(this._infoPopupSuppressionTimer);
482
+ this.hideInfoPopup();
483
+ this._infoPopupSuppressionTimer = setTimeout(() => {
484
+ this._infoPopupSuppressed = false;
485
+ this._infoPopupSuppressionTimer = null;
486
+ }, 0);
487
+ }
473
488
  };
474
489
  DocHyperLinkPopupService = __decorate([
475
490
  __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_docs_ui.DocCanvasPopManagerService)),
@@ -589,7 +604,7 @@ const menuSchema = {
589
604
  //#endregion
590
605
  //#region package.json
591
606
  var name = "@univerjs/docs-hyper-link-ui";
592
- var version = "1.0.0-beta.0";
607
+ var version = "1.0.0-beta.2";
593
608
 
594
609
  //#endregion
595
610
  //#region src/config/config.ts
@@ -649,25 +664,21 @@ let DocHyperLinkSelectionController = class DocHyperLinkSelectionController exte
649
664
  const { unitId, ranges, segmentId } = commandInfo.params;
650
665
  const doc = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
651
666
  const primary = ranges[0];
652
- if (primary && doc) {
667
+ if ((primary === null || primary === void 0 ? void 0 : primary.collapsed) && doc) {
653
668
  var _doc$getSelfOrHeaderF;
654
- const { startOffset, endOffset, collapsed, segmentPage } = primary;
655
- const customRanges = (_doc$getSelfOrHeaderF = doc.getSelfOrHeaderFooterModel(segmentId)) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.getBody()) === null || _doc$getSelfOrHeaderF === void 0 ? void 0 : _doc$getSelfOrHeaderF.customRanges;
656
- if (collapsed) {
657
- const index = (customRanges === null || customRanges === void 0 ? void 0 : customRanges.findIndex((value) => value.startIndex < startOffset && value.endIndex > endOffset - 1)) ?? -1;
658
- if (index > -1) {
659
- const customRange = customRanges[index];
660
- this._docHyperLinkService.showInfoPopup({
661
- unitId,
662
- linkId: customRange.rangeId,
663
- segmentId,
664
- segmentPage,
665
- startIndex: customRange.startIndex,
666
- endIndex: customRange.endIndex
667
- });
668
- return;
669
- }
670
- } else if (customRanges === null || customRanges === void 0 ? void 0 : customRanges.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1)) return;
669
+ const { startOffset, endOffset, segmentPage } = primary;
670
+ const customRange = (_doc$getSelfOrHeaderF = doc.getSelfOrHeaderFooterModel(segmentId)) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.getBody()) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.customRanges) === null || _doc$getSelfOrHeaderF === void 0 ? void 0 : _doc$getSelfOrHeaderF.find((value) => value.rangeType === _univerjs_core.CustomRangeType.HYPERLINK && value.startIndex < startOffset && value.endIndex > endOffset - 1);
671
+ if (customRange) {
672
+ this._docHyperLinkService.showInfoPopup({
673
+ unitId,
674
+ linkId: customRange.rangeId,
675
+ segmentId,
676
+ segmentPage,
677
+ startIndex: customRange.startIndex,
678
+ endIndex: customRange.endIndex
679
+ });
680
+ return;
681
+ }
671
682
  }
672
683
  this._docHyperLinkService.hideInfoPopup();
673
684
  this._docHyperLinkService.hideEditPopup();
@@ -696,12 +707,18 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
696
707
  this._docSkeletonManagerService = _docSkeletonManagerService;
697
708
  this._docSelectionManagerService = _docSelectionManagerService;
698
709
  if (this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
710
+ this._initPointerDown();
699
711
  this._initHover();
700
712
  this._initClick();
701
713
  }
702
714
  _hideInfoPopup() {
703
715
  if (this._hyperLinkPopupService.showing) this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id);
704
716
  }
717
+ _initPointerDown() {
718
+ this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe((ranges) => {
719
+ if (!ranges.some((range) => range.range.rangeType === _univerjs_core.CustomRangeType.HYPERLINK)) this._hyperLinkPopupService.hideInfoPopupOnPointerDown();
720
+ }));
721
+ }
705
722
  _initHover() {
706
723
  this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe((ranges) => {
707
724
  var _activeRanges$;
@@ -727,7 +744,8 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
727
744
  _initClick() {
728
745
  this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe((range) => {
729
746
  const link = range.range;
730
- if (link) this._commandService.executeCommand(ClickDocHyperLinkOperation.id, {
747
+ if (link.rangeType !== _univerjs_core.CustomRangeType.HYPERLINK || !range.ctrlKey && !range.metaKey) return;
748
+ this._commandService.executeCommand(ClickDocHyperLinkOperation.id, {
731
749
  unitId: this._context.unitId,
732
750
  linkId: link.rangeId,
733
751
  segmentId: range.segmentId
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "تأكيد",
6
6
  cancel: "إلغاء",
7
- title: "ارتباط",
8
7
  address: "ارتباط",
9
- placeholder: "يُرجى إدخال عنوان URL للارتباط",
10
8
  addressError: "عنوان URL غير قانوني!",
11
9
  label: "تسمية",
12
10
  labelError: "يُرجى إدخال تسمية الارتباط"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Confirma",
6
6
  cancel: "Cancel·la",
7
- title: "Enllaç",
8
7
  address: "Enllaç",
9
- placeholder: "Si us plau, introdueix una URL",
10
8
  addressError: "La URL no és vàlida!",
11
9
  label: "Etiqueta",
12
10
  labelError: "Si us plau, introdueix l'etiqueta de l'enllaç"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Bestätigen",
6
6
  cancel: "Abbrechen",
7
- title: "Link",
8
7
  address: "Link",
9
- placeholder: "Bitte eine Link-URL eingeben",
10
8
  addressError: "URL ist ungültig!",
11
9
  label: "Bezeichnung",
12
10
  labelError: "Bitte die Bezeichnung des Links eingeben"
@@ -19,9 +19,7 @@ const locale = { "docs-hyper-link-ui": {
19
19
  edit: {
20
20
  confirm: "Confirm",
21
21
  cancel: "Cancel",
22
- title: "Link",
23
22
  address: "Link",
24
- placeholder: "Please input a link url",
25
23
  addressError: "Url is illegal!",
26
24
  label: "Label",
27
25
  labelError: "Please input label of link"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Confirmar",
6
6
  cancel: "Cancelar",
7
- title: "Enlace",
8
7
  address: "Enlace",
9
- placeholder: "Por favor, introduce una URL",
10
8
  addressError: "¡La URL no es válida!",
11
9
  label: "Etiqueta",
12
10
  labelError: "Por favor, introduce la etiqueta del enlace"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "تایید",
6
6
  cancel: "انصراف",
7
- title: "لینک",
8
7
  address: "لینک",
9
- placeholder: "لطفا یک آدرس لینک وارد کنید",
10
8
  addressError: "آدرس غیرمجاز است!",
11
9
  label: "برچسب",
12
10
  labelError: "لطفا برچسب لینک را وارد کنید"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Confirmer",
6
6
  cancel: "Annuler",
7
- title: "Lien",
8
7
  address: "Lien",
9
- placeholder: "Veuillez entrer un lien",
10
8
  addressError: "L'url est illégal!",
11
9
  label: "Libellé",
12
10
  labelError: "Veuillez entrer le label du lien"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Konfirmasi",
6
6
  cancel: "Batal",
7
- title: "Tautan",
8
7
  address: "Tautan",
9
- placeholder: "Silakan masukkan URL tautan",
10
8
  addressError: "URL tidak valid!",
11
9
  label: "Label",
12
10
  labelError: "Silakan masukkan label tautan"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Conferma",
6
6
  cancel: "Annulla",
7
- title: "Collegamento",
8
7
  address: "Collegamento",
9
- placeholder: "Inserisci un URL di collegamento",
10
8
  addressError: "URL non valido!",
11
9
  label: "Etichetta",
12
10
  labelError: "Inserisci l'etichetta del collegamento"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "OK",
6
6
  cancel: "キャンセル",
7
- title: "リンク",
8
7
  address: "アドレス",
9
- placeholder: "リンクのURLを入力してください",
10
8
  addressError: "URLが正しくありません!",
11
9
  label: "表示文字列",
12
10
  labelError: "リンクの表示文字列を入力してください"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "확인",
6
6
  cancel: "취소",
7
- title: "링크",
8
7
  address: "링크",
9
- placeholder: "링크 URL을 입력해주세요",
10
8
  addressError: "URL이 올바르지 않습니다!",
11
9
  label: "라벨",
12
10
  labelError: "링크 라벨을 입력해주세요"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Potwierdź",
6
6
  cancel: "Anuluj",
7
- title: "Łącze",
8
7
  address: "Łącze",
9
- placeholder: "Wprowadź adres URL",
10
8
  addressError: "Adres URL jest nieprawidłowy!",
11
9
  label: "Etykieta",
12
10
  labelError: "Wprowadź etykietę łącza"
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Confirmar",
6
6
  cancel: "Cancelar",
7
- title: "Link",
8
7
  address: "Link",
9
- placeholder: "Insira uma URL de link",
10
8
  addressError: "URL inválida!",
11
9
  label: "Rótulo",
12
10
  labelError: "Insira o rótulo do link"
@@ -4,11 +4,9 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Подтвердить",
6
6
  cancel: "Отменить",
7
- title: "Ссылка",
8
7
  address: "Ссылка",
9
8
  label: "Текст",
10
9
  labelError: "Введите текст ссылки",
11
- placeholder: "Пожалуйста, введите ссылку",
12
10
  addressError: "Пожалуйста, введите корректную ссылку"
13
11
  },
14
12
  info: {
@@ -4,9 +4,7 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Potvrdiť",
6
6
  cancel: "Zrušiť",
7
- title: "Odkaz",
8
7
  address: "Odkaz",
9
- placeholder: "Zadajte URL odkazu",
10
8
  addressError: "URL je neplatná!",
11
9
  label: "Popisok",
12
10
  labelError: "Zadajte popis odkazu"
@@ -4,11 +4,9 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "Xác nhận",
6
6
  cancel: "Hủy",
7
- title: "Liên kết",
8
7
  address: "Liên kết",
9
8
  label: "Nhãn",
10
9
  labelError: "Vui lòng nhập nhãn liên kết",
11
- placeholder: "Vui lòng nhập liên kết hợp lệ",
12
10
  addressError: "Vui lòng nhập liên kết hợp lệ"
13
11
  },
14
12
  info: {
@@ -4,11 +4,9 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "确认",
6
6
  cancel: "取消",
7
- title: "链接",
8
7
  address: "链接",
9
8
  label: "文本",
10
9
  labelError: "请输入链接文本",
11
- placeholder: "请输入合法的链接",
12
10
  addressError: "请输入合法的链接"
13
11
  },
14
12
  info: {
@@ -4,11 +4,9 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "確認",
6
6
  cancel: "取消",
7
- title: "連結",
8
7
  address: "連結",
9
8
  label: "文字",
10
9
  labelError: "請輸入連結文字",
11
- placeholder: "請輸入合法的連結",
12
10
  addressError: "請輸入合法的連結"
13
11
  },
14
12
  info: {
@@ -4,11 +4,9 @@ const locale = { "docs-hyper-link-ui": {
4
4
  edit: {
5
5
  confirm: "確認",
6
6
  cancel: "取消",
7
- title: "連結",
8
7
  address: "連結",
9
8
  label: "文字",
10
9
  labelError: "請輸入連結文字",
11
- placeholder: "請輸入合法的連結",
12
10
  addressError: "請輸入合法的連結"
13
11
  },
14
12
  info: {
package/lib/es/index.js CHANGED
@@ -170,7 +170,7 @@ const DocHyperLinkEdit = () => {
170
170
  };
171
171
  if (!doc) return;
172
172
  return /* @__PURE__ */ jsxs("div", {
173
- className: clsx("univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900", borderClassName),
173
+ className: 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", borderClassName),
174
174
  children: [/* @__PURE__ */ jsxs("div", { children: [editing ? /* @__PURE__ */ jsx(FormLayout, {
175
175
  label: localeService.t("docs-hyper-link-ui.edit.label"),
176
176
  error: showError && isBlankInput(label) ? localeService.t("docs-hyper-link-ui.edit.labelError") : "",
@@ -246,7 +246,7 @@ const DocLinkPopup = () => {
246
246
  if (!link) return null;
247
247
  const url = (_link$properties = link.properties) === null || _link$properties === void 0 ? void 0 : _link$properties.url;
248
248
  return /* @__PURE__ */ jsxs("div", {
249
- className: clsx("univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900", borderClassName),
249
+ className: 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", borderClassName),
250
250
  onClick: () => {
251
251
  hyperLinkService.hideInfoPopup();
252
252
  },
@@ -254,7 +254,7 @@ const DocLinkPopup = () => {
254
254
  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",
255
255
  onClick: () => window.open(url, void 0, "noopener noreferrer"),
256
256
  children: [/* @__PURE__ */ jsx("div", {
257
- 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-white",
257
+ 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",
258
258
  children: /* @__PURE__ */ jsx(LinkIcon, {})
259
259
  }), /* @__PURE__ */ jsx(Tooltip, {
260
260
  showIfEllipsis: true,
@@ -387,7 +387,10 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
387
387
  _defineProperty(this, "showingLink$", this._showingLink$.asObservable());
388
388
  _defineProperty(this, "_editPopup", null);
389
389
  _defineProperty(this, "_infoPopup", null);
390
+ _defineProperty(this, "_infoPopupSuppressed", false);
391
+ _defineProperty(this, "_infoPopupSuppressionTimer", null);
390
392
  this.disposeWithMe(() => {
393
+ if (this._infoPopupSuppressionTimer !== null) clearTimeout(this._infoPopupSuppressionTimer);
391
394
  this._editingLink$.complete();
392
395
  this._showingLink$.complete();
393
396
  });
@@ -423,7 +426,8 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
423
426
  if (activeRange) {
424
427
  this._editPopup = this._docCanvasPopupManagerService.attachPopupToRange(activeRange, {
425
428
  componentKey: DocHyperLinkEdit.componentKey,
426
- direction: "bottom"
429
+ direction: "bottom",
430
+ offset: [0, 10]
427
431
  }, unitId);
428
432
  return this._editPopup;
429
433
  }
@@ -436,6 +440,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
436
440
  }
437
441
  showInfoPopup(info) {
438
442
  var _this$showing, _this$showing2, _this$showing3, _this$showing4, _this$showing5, _this$showing6;
443
+ if (this._infoPopupSuppressed) return;
439
444
  const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
440
445
  if (((_this$showing = this.showing) === null || _this$showing === void 0 ? void 0 : _this$showing.linkId) === linkId && ((_this$showing2 = this.showing) === null || _this$showing2 === void 0 ? void 0 : _this$showing2.unitId) === unitId && ((_this$showing3 = this.showing) === null || _this$showing3 === void 0 ? void 0 : _this$showing3.segmentId) === segmentId && ((_this$showing4 = this.showing) === null || _this$showing4 === void 0 ? void 0 : _this$showing4.segmentPage) === segmentPage && ((_this$showing5 = this.showing) === null || _this$showing5 === void 0 ? void 0 : _this$showing5.startIndex) === startIndex && ((_this$showing6 = this.showing) === null || _this$showing6 === void 0 ? void 0 : _this$showing6.endIndex) === endIndex) return;
441
446
  if (this._infoPopup) this._infoPopup.dispose();
@@ -458,6 +463,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
458
463
  componentKey: DocLinkPopup.componentKey,
459
464
  direction: "top-center",
460
465
  multipleDirection: "top",
466
+ offset: [0, 10],
461
467
  onClickOutside: () => {
462
468
  this.hideInfoPopup();
463
469
  }
@@ -469,6 +475,15 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
469
475
  this._showingLink$.next(null);
470
476
  (_this$_infoPopup = this._infoPopup) === null || _this$_infoPopup === void 0 || _this$_infoPopup.dispose();
471
477
  }
478
+ hideInfoPopupOnPointerDown() {
479
+ this._infoPopupSuppressed = true;
480
+ if (this._infoPopupSuppressionTimer !== null) clearTimeout(this._infoPopupSuppressionTimer);
481
+ this.hideInfoPopup();
482
+ this._infoPopupSuppressionTimer = setTimeout(() => {
483
+ this._infoPopupSuppressed = false;
484
+ this._infoPopupSuppressionTimer = null;
485
+ }, 0);
486
+ }
472
487
  };
473
488
  DocHyperLinkPopupService = __decorate([
474
489
  __decorateParam(0, Inject(DocCanvasPopManagerService)),
@@ -588,7 +603,7 @@ const menuSchema = {
588
603
  //#endregion
589
604
  //#region package.json
590
605
  var name = "@univerjs/docs-hyper-link-ui";
591
- var version = "1.0.0-beta.0";
606
+ var version = "1.0.0-beta.2";
592
607
 
593
608
  //#endregion
594
609
  //#region src/config/config.ts
@@ -648,25 +663,21 @@ let DocHyperLinkSelectionController = class DocHyperLinkSelectionController exte
648
663
  const { unitId, ranges, segmentId } = commandInfo.params;
649
664
  const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
650
665
  const primary = ranges[0];
651
- if (primary && doc) {
666
+ if ((primary === null || primary === void 0 ? void 0 : primary.collapsed) && doc) {
652
667
  var _doc$getSelfOrHeaderF;
653
- const { startOffset, endOffset, collapsed, segmentPage } = primary;
654
- const customRanges = (_doc$getSelfOrHeaderF = doc.getSelfOrHeaderFooterModel(segmentId)) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.getBody()) === null || _doc$getSelfOrHeaderF === void 0 ? void 0 : _doc$getSelfOrHeaderF.customRanges;
655
- if (collapsed) {
656
- const index = (customRanges === null || customRanges === void 0 ? void 0 : customRanges.findIndex((value) => value.startIndex < startOffset && value.endIndex > endOffset - 1)) ?? -1;
657
- if (index > -1) {
658
- const customRange = customRanges[index];
659
- this._docHyperLinkService.showInfoPopup({
660
- unitId,
661
- linkId: customRange.rangeId,
662
- segmentId,
663
- segmentPage,
664
- startIndex: customRange.startIndex,
665
- endIndex: customRange.endIndex
666
- });
667
- return;
668
- }
669
- } else if (customRanges === null || customRanges === void 0 ? void 0 : customRanges.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1)) return;
668
+ const { startOffset, endOffset, segmentPage } = primary;
669
+ const customRange = (_doc$getSelfOrHeaderF = doc.getSelfOrHeaderFooterModel(segmentId)) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.getBody()) === null || _doc$getSelfOrHeaderF === void 0 || (_doc$getSelfOrHeaderF = _doc$getSelfOrHeaderF.customRanges) === null || _doc$getSelfOrHeaderF === void 0 ? void 0 : _doc$getSelfOrHeaderF.find((value) => value.rangeType === CustomRangeType.HYPERLINK && value.startIndex < startOffset && value.endIndex > endOffset - 1);
670
+ if (customRange) {
671
+ this._docHyperLinkService.showInfoPopup({
672
+ unitId,
673
+ linkId: customRange.rangeId,
674
+ segmentId,
675
+ segmentPage,
676
+ startIndex: customRange.startIndex,
677
+ endIndex: customRange.endIndex
678
+ });
679
+ return;
680
+ }
670
681
  }
671
682
  this._docHyperLinkService.hideInfoPopup();
672
683
  this._docHyperLinkService.hideEditPopup();
@@ -695,12 +706,18 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
695
706
  this._docSkeletonManagerService = _docSkeletonManagerService;
696
707
  this._docSelectionManagerService = _docSelectionManagerService;
697
708
  if (this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
709
+ this._initPointerDown();
698
710
  this._initHover();
699
711
  this._initClick();
700
712
  }
701
713
  _hideInfoPopup() {
702
714
  if (this._hyperLinkPopupService.showing) this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id);
703
715
  }
716
+ _initPointerDown() {
717
+ this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe((ranges) => {
718
+ if (!ranges.some((range) => range.range.rangeType === CustomRangeType.HYPERLINK)) this._hyperLinkPopupService.hideInfoPopupOnPointerDown();
719
+ }));
720
+ }
704
721
  _initHover() {
705
722
  this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe((ranges) => {
706
723
  var _activeRanges$;
@@ -726,7 +743,8 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
726
743
  _initClick() {
727
744
  this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe((range) => {
728
745
  const link = range.range;
729
- if (link) this._commandService.executeCommand(ClickDocHyperLinkOperation.id, {
746
+ if (link.rangeType !== CustomRangeType.HYPERLINK || !range.ctrlKey && !range.metaKey) return;
747
+ this._commandService.executeCommand(ClickDocHyperLinkOperation.id, {
730
748
  unitId: this._context.unitId,
731
749
  linkId: link.rangeId,
732
750
  segmentId: range.segmentId
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "تأكيد",
5
5
  cancel: "إلغاء",
6
- title: "ارتباط",
7
6
  address: "ارتباط",
8
- placeholder: "يُرجى إدخال عنوان URL للارتباط",
9
7
  addressError: "عنوان URL غير قانوني!",
10
8
  label: "تسمية",
11
9
  labelError: "يُرجى إدخال تسمية الارتباط"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Confirma",
5
5
  cancel: "Cancel·la",
6
- title: "Enllaç",
7
6
  address: "Enllaç",
8
- placeholder: "Si us plau, introdueix una URL",
9
7
  addressError: "La URL no és vàlida!",
10
8
  label: "Etiqueta",
11
9
  labelError: "Si us plau, introdueix l'etiqueta de l'enllaç"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Bestätigen",
5
5
  cancel: "Abbrechen",
6
- title: "Link",
7
6
  address: "Link",
8
- placeholder: "Bitte eine Link-URL eingeben",
9
7
  addressError: "URL ist ungültig!",
10
8
  label: "Bezeichnung",
11
9
  labelError: "Bitte die Bezeichnung des Links eingeben"
@@ -18,9 +18,7 @@ const locale = { "docs-hyper-link-ui": {
18
18
  edit: {
19
19
  confirm: "Confirm",
20
20
  cancel: "Cancel",
21
- title: "Link",
22
21
  address: "Link",
23
- placeholder: "Please input a link url",
24
22
  addressError: "Url is illegal!",
25
23
  label: "Label",
26
24
  labelError: "Please input label of link"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Confirmar",
5
5
  cancel: "Cancelar",
6
- title: "Enlace",
7
6
  address: "Enlace",
8
- placeholder: "Por favor, introduce una URL",
9
7
  addressError: "¡La URL no es válida!",
10
8
  label: "Etiqueta",
11
9
  labelError: "Por favor, introduce la etiqueta del enlace"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "تایید",
5
5
  cancel: "انصراف",
6
- title: "لینک",
7
6
  address: "لینک",
8
- placeholder: "لطفا یک آدرس لینک وارد کنید",
9
7
  addressError: "آدرس غیرمجاز است!",
10
8
  label: "برچسب",
11
9
  labelError: "لطفا برچسب لینک را وارد کنید"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Confirmer",
5
5
  cancel: "Annuler",
6
- title: "Lien",
7
6
  address: "Lien",
8
- placeholder: "Veuillez entrer un lien",
9
7
  addressError: "L'url est illégal!",
10
8
  label: "Libellé",
11
9
  labelError: "Veuillez entrer le label du lien"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Konfirmasi",
5
5
  cancel: "Batal",
6
- title: "Tautan",
7
6
  address: "Tautan",
8
- placeholder: "Silakan masukkan URL tautan",
9
7
  addressError: "URL tidak valid!",
10
8
  label: "Label",
11
9
  labelError: "Silakan masukkan label tautan"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "Conferma",
5
5
  cancel: "Annulla",
6
- title: "Collegamento",
7
6
  address: "Collegamento",
8
- placeholder: "Inserisci un URL di collegamento",
9
7
  addressError: "URL non valido!",
10
8
  label: "Etichetta",
11
9
  labelError: "Inserisci l'etichetta del collegamento"
@@ -3,9 +3,7 @@ const locale = { "docs-hyper-link-ui": {
3
3
  edit: {
4
4
  confirm: "OK",
5
5
  cancel: "キャンセル",
6
- title: "リンク",
7
6
  address: "アドレス",
8
- placeholder: "リンクのURLを入力してください",
9
7
  addressError: "URLが正しくありません!",
10
8
  label: "表示文字列",
11
9
  labelError: "リンクの表示文字列を入力してください"