@univerjs/docs-hyper-link-ui 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +59 -6
- package/lib/es/index.js +59 -6
- package/lib/index.js +59 -6
- package/lib/types/services/hyper-link-popup.service.d.ts +4 -0
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -252,6 +252,21 @@ DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
|
252
252
|
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/views/DocLinkPopup.tsx
|
|
255
|
+
/**
|
|
256
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
257
|
+
*
|
|
258
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
259
|
+
* you may not use this file except in compliance with the License.
|
|
260
|
+
* You may obtain a copy of the License at
|
|
261
|
+
*
|
|
262
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
265
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
266
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
267
|
+
* See the License for the specific language governing permissions and
|
|
268
|
+
* limitations under the License.
|
|
269
|
+
*/
|
|
255
270
|
const DocLinkPopup = () => {
|
|
256
271
|
var _doc$getSelfOrHeaderF, _body$customRanges, _link$properties, _link$properties2, _link$properties3;
|
|
257
272
|
const hyperLinkService = (0, _univerjs_ui.useDependency)(DocHyperLinkPopupService);
|
|
@@ -273,9 +288,10 @@ const DocLinkPopup = () => {
|
|
|
273
288
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
274
289
|
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),
|
|
275
290
|
onPointerEnter: () => {
|
|
276
|
-
hyperLinkService.
|
|
291
|
+
hyperLinkService.setInfoPopupHovered(true);
|
|
277
292
|
},
|
|
278
293
|
onPointerLeave: () => {
|
|
294
|
+
hyperLinkService.setInfoPopupHovered(false);
|
|
279
295
|
hyperLinkService.scheduleHideInfoPopup();
|
|
280
296
|
},
|
|
281
297
|
onClick: () => {
|
|
@@ -412,6 +428,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
412
428
|
//#endregion
|
|
413
429
|
//#region src/services/hyper-link-popup.service.ts
|
|
414
430
|
const INFO_POPUP_HIDE_DELAY = 150;
|
|
431
|
+
const INFO_POPUP_REPLACEMENT_DELAY = 200;
|
|
415
432
|
function isSameLinkInfo(current, next) {
|
|
416
433
|
return (current === null || current === void 0 ? void 0 : current.linkId) === next.linkId && current.unitId === next.unitId && (current.segmentId ?? "") === (next.segmentId ?? "") && current.segmentPage === next.segmentPage && current.startIndex === next.startIndex && current.endIndex === next.endIndex;
|
|
417
434
|
}
|
|
@@ -434,7 +451,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
434
451
|
_defineProperty(this, "_editPopupUnitId", null);
|
|
435
452
|
_defineProperty(this, "_infoPopup", null);
|
|
436
453
|
_defineProperty(this, "_infoPopupPinned", false);
|
|
454
|
+
_defineProperty(this, "_infoPopupHovered", false);
|
|
437
455
|
_defineProperty(this, "_infoPopupHideTimer", null);
|
|
456
|
+
_defineProperty(this, "_infoPopupReplacement", null);
|
|
438
457
|
_defineProperty(this, "_infoPopupSuppressed", false);
|
|
439
458
|
_defineProperty(this, "_infoPopupSuppressionTimer", null);
|
|
440
459
|
this.disposeWithMe(() => {
|
|
@@ -450,7 +469,8 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
450
469
|
if (showing) this._showingLink$.next({ ...showing });
|
|
451
470
|
}));
|
|
452
471
|
this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => {
|
|
453
|
-
var _this$showing;
|
|
472
|
+
var _this$_infoPopupRepla, _this$showing;
|
|
473
|
+
if (((_this$_infoPopupRepla = this._infoPopupReplacement) === null || _this$_infoPopupRepla === void 0 ? void 0 : _this$_infoPopupRepla.info.unitId) === unitId) this._cancelScheduledInfoPopupReplacement();
|
|
454
474
|
if (this._editPopupUnitId === unitId) this.hideEditPopup();
|
|
455
475
|
if (((_this$showing = this.showing) === null || _this$showing === void 0 ? void 0 : _this$showing.unitId) === unitId) this.hideInfoPopup();
|
|
456
476
|
}));
|
|
@@ -471,6 +491,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
471
491
|
}
|
|
472
492
|
showEditPopup(unitId, linkInfo) {
|
|
473
493
|
var _getEditorRuntimeConf;
|
|
494
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
474
495
|
const doc = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
475
496
|
if (doc && ((_getEditorRuntimeConf = (0, _univerjs_docs_ui.getEditorRuntimeConfig)(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
|
|
476
497
|
if (!this.canEditLink(unitId, linkInfo)) return null;
|
|
@@ -517,6 +538,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
517
538
|
var _getEditorRuntimeConf2;
|
|
518
539
|
const doc = this._univerInstanceService.getUnit(info.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
519
540
|
if (!(doc instanceof _univerjs_core.DocumentDataModel) || ((_getEditorRuntimeConf2 = (0, _univerjs_docs_ui.getEditorRuntimeConfig)(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
|
|
541
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
520
542
|
this.cancelScheduledHideInfoPopup();
|
|
521
543
|
if (this._infoPopupSuppressed) return;
|
|
522
544
|
const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
|
|
@@ -529,6 +551,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
529
551
|
this._infoPopup = null;
|
|
530
552
|
}
|
|
531
553
|
this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
|
|
554
|
+
this._infoPopupHovered = false;
|
|
532
555
|
this._showingLink$.next({
|
|
533
556
|
unitId,
|
|
534
557
|
linkId,
|
|
@@ -579,20 +602,50 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
|
|
|
579
602
|
}, unitId);
|
|
580
603
|
}
|
|
581
604
|
showInfoPopupFromHover(info) {
|
|
605
|
+
var _this$_infoPopupRepla2;
|
|
582
606
|
this.cancelScheduledHideInfoPopup();
|
|
583
|
-
if (this._infoPopupPinned || this._infoPopupSuppressed) return;
|
|
584
|
-
if (!this.showing
|
|
607
|
+
if (this._infoPopupPinned || this._infoPopupHovered || this._infoPopupSuppressed) return;
|
|
608
|
+
if (!this.showing || isSameLinkInfo(this.showing, info)) {
|
|
609
|
+
this.showInfoPopup(info);
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
if (isSameLinkInfo(((_this$_infoPopupRepla2 = this._infoPopupReplacement) === null || _this$_infoPopupRepla2 === void 0 ? void 0 : _this$_infoPopupRepla2.info) ?? null, info)) return;
|
|
613
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
614
|
+
const pendingInfo = { ...info };
|
|
615
|
+
this._infoPopupReplacement = {
|
|
616
|
+
info: pendingInfo,
|
|
617
|
+
timer: setTimeout(() => {
|
|
618
|
+
this._infoPopupReplacement = null;
|
|
619
|
+
this.showInfoPopup(pendingInfo);
|
|
620
|
+
}, INFO_POPUP_REPLACEMENT_DELAY)
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
setInfoPopupHovered(hovered) {
|
|
624
|
+
this._infoPopupHovered = hovered && this.showing !== null;
|
|
625
|
+
if (this._infoPopupHovered) {
|
|
626
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
627
|
+
this.cancelScheduledHideInfoPopup();
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
_cancelScheduledInfoPopupReplacement() {
|
|
631
|
+
if (this._infoPopupReplacement) {
|
|
632
|
+
clearTimeout(this._infoPopupReplacement.timer);
|
|
633
|
+
this._infoPopupReplacement = null;
|
|
634
|
+
}
|
|
585
635
|
}
|
|
586
636
|
hideInfoPopup() {
|
|
637
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
587
638
|
this.cancelScheduledHideInfoPopup();
|
|
588
639
|
this._infoPopupPinned = false;
|
|
640
|
+
this._infoPopupHovered = false;
|
|
589
641
|
this._showingLink$.next(null);
|
|
590
642
|
const popup = this._infoPopup;
|
|
591
643
|
this._infoPopup = null;
|
|
592
644
|
popup === null || popup === void 0 || popup.dispose();
|
|
593
645
|
}
|
|
594
646
|
scheduleHideInfoPopup() {
|
|
595
|
-
|
|
647
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
648
|
+
if (this._infoPopupPinned || this._infoPopupHovered || !this.showing) return;
|
|
596
649
|
this.cancelScheduledHideInfoPopup();
|
|
597
650
|
this._infoPopupHideTimer = setTimeout(() => {
|
|
598
651
|
this._infoPopupHideTimer = null;
|
|
@@ -790,7 +843,7 @@ const menuSchema = {
|
|
|
790
843
|
//#endregion
|
|
791
844
|
//#region package.json
|
|
792
845
|
var name = "@univerjs/docs-hyper-link-ui";
|
|
793
|
-
var version = "1.
|
|
846
|
+
var version = "1.3.0";
|
|
794
847
|
|
|
795
848
|
//#endregion
|
|
796
849
|
//#region src/config/config.ts
|
package/lib/es/index.js
CHANGED
|
@@ -251,6 +251,21 @@ DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
|
251
251
|
|
|
252
252
|
//#endregion
|
|
253
253
|
//#region src/views/DocLinkPopup.tsx
|
|
254
|
+
/**
|
|
255
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
256
|
+
*
|
|
257
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
258
|
+
* you may not use this file except in compliance with the License.
|
|
259
|
+
* You may obtain a copy of the License at
|
|
260
|
+
*
|
|
261
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
262
|
+
*
|
|
263
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
264
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
265
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
266
|
+
* See the License for the specific language governing permissions and
|
|
267
|
+
* limitations under the License.
|
|
268
|
+
*/
|
|
254
269
|
const DocLinkPopup = () => {
|
|
255
270
|
var _doc$getSelfOrHeaderF, _body$customRanges, _link$properties, _link$properties2, _link$properties3;
|
|
256
271
|
const hyperLinkService = useDependency(DocHyperLinkPopupService);
|
|
@@ -272,9 +287,10 @@ const DocLinkPopup = () => {
|
|
|
272
287
|
return /* @__PURE__ */ jsxs("div", {
|
|
273
288
|
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),
|
|
274
289
|
onPointerEnter: () => {
|
|
275
|
-
hyperLinkService.
|
|
290
|
+
hyperLinkService.setInfoPopupHovered(true);
|
|
276
291
|
},
|
|
277
292
|
onPointerLeave: () => {
|
|
293
|
+
hyperLinkService.setInfoPopupHovered(false);
|
|
278
294
|
hyperLinkService.scheduleHideInfoPopup();
|
|
279
295
|
},
|
|
280
296
|
onClick: () => {
|
|
@@ -411,6 +427,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
411
427
|
//#endregion
|
|
412
428
|
//#region src/services/hyper-link-popup.service.ts
|
|
413
429
|
const INFO_POPUP_HIDE_DELAY = 150;
|
|
430
|
+
const INFO_POPUP_REPLACEMENT_DELAY = 200;
|
|
414
431
|
function isSameLinkInfo(current, next) {
|
|
415
432
|
return (current === null || current === void 0 ? void 0 : current.linkId) === next.linkId && current.unitId === next.unitId && (current.segmentId ?? "") === (next.segmentId ?? "") && current.segmentPage === next.segmentPage && current.startIndex === next.startIndex && current.endIndex === next.endIndex;
|
|
416
433
|
}
|
|
@@ -433,7 +450,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
433
450
|
_defineProperty(this, "_editPopupUnitId", null);
|
|
434
451
|
_defineProperty(this, "_infoPopup", null);
|
|
435
452
|
_defineProperty(this, "_infoPopupPinned", false);
|
|
453
|
+
_defineProperty(this, "_infoPopupHovered", false);
|
|
436
454
|
_defineProperty(this, "_infoPopupHideTimer", null);
|
|
455
|
+
_defineProperty(this, "_infoPopupReplacement", null);
|
|
437
456
|
_defineProperty(this, "_infoPopupSuppressed", false);
|
|
438
457
|
_defineProperty(this, "_infoPopupSuppressionTimer", null);
|
|
439
458
|
this.disposeWithMe(() => {
|
|
@@ -449,7 +468,8 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
449
468
|
if (showing) this._showingLink$.next({ ...showing });
|
|
450
469
|
}));
|
|
451
470
|
this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => {
|
|
452
|
-
var _this$showing;
|
|
471
|
+
var _this$_infoPopupRepla, _this$showing;
|
|
472
|
+
if (((_this$_infoPopupRepla = this._infoPopupReplacement) === null || _this$_infoPopupRepla === void 0 ? void 0 : _this$_infoPopupRepla.info.unitId) === unitId) this._cancelScheduledInfoPopupReplacement();
|
|
453
473
|
if (this._editPopupUnitId === unitId) this.hideEditPopup();
|
|
454
474
|
if (((_this$showing = this.showing) === null || _this$showing === void 0 ? void 0 : _this$showing.unitId) === unitId) this.hideInfoPopup();
|
|
455
475
|
}));
|
|
@@ -470,6 +490,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
470
490
|
}
|
|
471
491
|
showEditPopup(unitId, linkInfo) {
|
|
472
492
|
var _getEditorRuntimeConf;
|
|
493
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
473
494
|
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
474
495
|
if (doc && ((_getEditorRuntimeConf = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
|
|
475
496
|
if (!this.canEditLink(unitId, linkInfo)) return null;
|
|
@@ -516,6 +537,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
516
537
|
var _getEditorRuntimeConf2;
|
|
517
538
|
const doc = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_DOC);
|
|
518
539
|
if (!(doc instanceof DocumentDataModel) || ((_getEditorRuntimeConf2 = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
|
|
540
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
519
541
|
this.cancelScheduledHideInfoPopup();
|
|
520
542
|
if (this._infoPopupSuppressed) return;
|
|
521
543
|
const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
|
|
@@ -528,6 +550,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
528
550
|
this._infoPopup = null;
|
|
529
551
|
}
|
|
530
552
|
this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
|
|
553
|
+
this._infoPopupHovered = false;
|
|
531
554
|
this._showingLink$.next({
|
|
532
555
|
unitId,
|
|
533
556
|
linkId,
|
|
@@ -578,20 +601,50 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
578
601
|
}, unitId);
|
|
579
602
|
}
|
|
580
603
|
showInfoPopupFromHover(info) {
|
|
604
|
+
var _this$_infoPopupRepla2;
|
|
581
605
|
this.cancelScheduledHideInfoPopup();
|
|
582
|
-
if (this._infoPopupPinned || this._infoPopupSuppressed) return;
|
|
583
|
-
if (!this.showing
|
|
606
|
+
if (this._infoPopupPinned || this._infoPopupHovered || this._infoPopupSuppressed) return;
|
|
607
|
+
if (!this.showing || isSameLinkInfo(this.showing, info)) {
|
|
608
|
+
this.showInfoPopup(info);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (isSameLinkInfo(((_this$_infoPopupRepla2 = this._infoPopupReplacement) === null || _this$_infoPopupRepla2 === void 0 ? void 0 : _this$_infoPopupRepla2.info) ?? null, info)) return;
|
|
612
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
613
|
+
const pendingInfo = { ...info };
|
|
614
|
+
this._infoPopupReplacement = {
|
|
615
|
+
info: pendingInfo,
|
|
616
|
+
timer: setTimeout(() => {
|
|
617
|
+
this._infoPopupReplacement = null;
|
|
618
|
+
this.showInfoPopup(pendingInfo);
|
|
619
|
+
}, INFO_POPUP_REPLACEMENT_DELAY)
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
setInfoPopupHovered(hovered) {
|
|
623
|
+
this._infoPopupHovered = hovered && this.showing !== null;
|
|
624
|
+
if (this._infoPopupHovered) {
|
|
625
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
626
|
+
this.cancelScheduledHideInfoPopup();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
_cancelScheduledInfoPopupReplacement() {
|
|
630
|
+
if (this._infoPopupReplacement) {
|
|
631
|
+
clearTimeout(this._infoPopupReplacement.timer);
|
|
632
|
+
this._infoPopupReplacement = null;
|
|
633
|
+
}
|
|
584
634
|
}
|
|
585
635
|
hideInfoPopup() {
|
|
636
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
586
637
|
this.cancelScheduledHideInfoPopup();
|
|
587
638
|
this._infoPopupPinned = false;
|
|
639
|
+
this._infoPopupHovered = false;
|
|
588
640
|
this._showingLink$.next(null);
|
|
589
641
|
const popup = this._infoPopup;
|
|
590
642
|
this._infoPopup = null;
|
|
591
643
|
popup === null || popup === void 0 || popup.dispose();
|
|
592
644
|
}
|
|
593
645
|
scheduleHideInfoPopup() {
|
|
594
|
-
|
|
646
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
647
|
+
if (this._infoPopupPinned || this._infoPopupHovered || !this.showing) return;
|
|
595
648
|
this.cancelScheduledHideInfoPopup();
|
|
596
649
|
this._infoPopupHideTimer = setTimeout(() => {
|
|
597
650
|
this._infoPopupHideTimer = null;
|
|
@@ -789,7 +842,7 @@ const menuSchema = {
|
|
|
789
842
|
//#endregion
|
|
790
843
|
//#region package.json
|
|
791
844
|
var name = "@univerjs/docs-hyper-link-ui";
|
|
792
|
-
var version = "1.
|
|
845
|
+
var version = "1.3.0";
|
|
793
846
|
|
|
794
847
|
//#endregion
|
|
795
848
|
//#region src/config/config.ts
|
package/lib/index.js
CHANGED
|
@@ -251,6 +251,21 @@ DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
|
251
251
|
|
|
252
252
|
//#endregion
|
|
253
253
|
//#region src/views/DocLinkPopup.tsx
|
|
254
|
+
/**
|
|
255
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
256
|
+
*
|
|
257
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
258
|
+
* you may not use this file except in compliance with the License.
|
|
259
|
+
* You may obtain a copy of the License at
|
|
260
|
+
*
|
|
261
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
262
|
+
*
|
|
263
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
264
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
265
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
266
|
+
* See the License for the specific language governing permissions and
|
|
267
|
+
* limitations under the License.
|
|
268
|
+
*/
|
|
254
269
|
const DocLinkPopup = () => {
|
|
255
270
|
var _doc$getSelfOrHeaderF, _body$customRanges, _link$properties, _link$properties2, _link$properties3;
|
|
256
271
|
const hyperLinkService = useDependency(DocHyperLinkPopupService);
|
|
@@ -272,9 +287,10 @@ const DocLinkPopup = () => {
|
|
|
272
287
|
return /* @__PURE__ */ jsxs("div", {
|
|
273
288
|
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),
|
|
274
289
|
onPointerEnter: () => {
|
|
275
|
-
hyperLinkService.
|
|
290
|
+
hyperLinkService.setInfoPopupHovered(true);
|
|
276
291
|
},
|
|
277
292
|
onPointerLeave: () => {
|
|
293
|
+
hyperLinkService.setInfoPopupHovered(false);
|
|
278
294
|
hyperLinkService.scheduleHideInfoPopup();
|
|
279
295
|
},
|
|
280
296
|
onClick: () => {
|
|
@@ -411,6 +427,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
411
427
|
//#endregion
|
|
412
428
|
//#region src/services/hyper-link-popup.service.ts
|
|
413
429
|
const INFO_POPUP_HIDE_DELAY = 150;
|
|
430
|
+
const INFO_POPUP_REPLACEMENT_DELAY = 200;
|
|
414
431
|
function isSameLinkInfo(current, next) {
|
|
415
432
|
return (current === null || current === void 0 ? void 0 : current.linkId) === next.linkId && current.unitId === next.unitId && (current.segmentId ?? "") === (next.segmentId ?? "") && current.segmentPage === next.segmentPage && current.startIndex === next.startIndex && current.endIndex === next.endIndex;
|
|
416
433
|
}
|
|
@@ -433,7 +450,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
433
450
|
_defineProperty(this, "_editPopupUnitId", null);
|
|
434
451
|
_defineProperty(this, "_infoPopup", null);
|
|
435
452
|
_defineProperty(this, "_infoPopupPinned", false);
|
|
453
|
+
_defineProperty(this, "_infoPopupHovered", false);
|
|
436
454
|
_defineProperty(this, "_infoPopupHideTimer", null);
|
|
455
|
+
_defineProperty(this, "_infoPopupReplacement", null);
|
|
437
456
|
_defineProperty(this, "_infoPopupSuppressed", false);
|
|
438
457
|
_defineProperty(this, "_infoPopupSuppressionTimer", null);
|
|
439
458
|
this.disposeWithMe(() => {
|
|
@@ -449,7 +468,8 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
449
468
|
if (showing) this._showingLink$.next({ ...showing });
|
|
450
469
|
}));
|
|
451
470
|
this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => {
|
|
452
|
-
var _this$showing;
|
|
471
|
+
var _this$_infoPopupRepla, _this$showing;
|
|
472
|
+
if (((_this$_infoPopupRepla = this._infoPopupReplacement) === null || _this$_infoPopupRepla === void 0 ? void 0 : _this$_infoPopupRepla.info.unitId) === unitId) this._cancelScheduledInfoPopupReplacement();
|
|
453
473
|
if (this._editPopupUnitId === unitId) this.hideEditPopup();
|
|
454
474
|
if (((_this$showing = this.showing) === null || _this$showing === void 0 ? void 0 : _this$showing.unitId) === unitId) this.hideInfoPopup();
|
|
455
475
|
}));
|
|
@@ -470,6 +490,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
470
490
|
}
|
|
471
491
|
showEditPopup(unitId, linkInfo) {
|
|
472
492
|
var _getEditorRuntimeConf;
|
|
493
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
473
494
|
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
474
495
|
if (doc && ((_getEditorRuntimeConf = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
|
|
475
496
|
if (!this.canEditLink(unitId, linkInfo)) return null;
|
|
@@ -516,6 +537,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
516
537
|
var _getEditorRuntimeConf2;
|
|
517
538
|
const doc = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_DOC);
|
|
518
539
|
if (!(doc instanceof DocumentDataModel) || ((_getEditorRuntimeConf2 = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
|
|
540
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
519
541
|
this.cancelScheduledHideInfoPopup();
|
|
520
542
|
if (this._infoPopupSuppressed) return;
|
|
521
543
|
const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
|
|
@@ -528,6 +550,7 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
528
550
|
this._infoPopup = null;
|
|
529
551
|
}
|
|
530
552
|
this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
|
|
553
|
+
this._infoPopupHovered = false;
|
|
531
554
|
this._showingLink$.next({
|
|
532
555
|
unitId,
|
|
533
556
|
linkId,
|
|
@@ -578,20 +601,50 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
|
|
|
578
601
|
}, unitId);
|
|
579
602
|
}
|
|
580
603
|
showInfoPopupFromHover(info) {
|
|
604
|
+
var _this$_infoPopupRepla2;
|
|
581
605
|
this.cancelScheduledHideInfoPopup();
|
|
582
|
-
if (this._infoPopupPinned || this._infoPopupSuppressed) return;
|
|
583
|
-
if (!this.showing
|
|
606
|
+
if (this._infoPopupPinned || this._infoPopupHovered || this._infoPopupSuppressed) return;
|
|
607
|
+
if (!this.showing || isSameLinkInfo(this.showing, info)) {
|
|
608
|
+
this.showInfoPopup(info);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (isSameLinkInfo(((_this$_infoPopupRepla2 = this._infoPopupReplacement) === null || _this$_infoPopupRepla2 === void 0 ? void 0 : _this$_infoPopupRepla2.info) ?? null, info)) return;
|
|
612
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
613
|
+
const pendingInfo = { ...info };
|
|
614
|
+
this._infoPopupReplacement = {
|
|
615
|
+
info: pendingInfo,
|
|
616
|
+
timer: setTimeout(() => {
|
|
617
|
+
this._infoPopupReplacement = null;
|
|
618
|
+
this.showInfoPopup(pendingInfo);
|
|
619
|
+
}, INFO_POPUP_REPLACEMENT_DELAY)
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
setInfoPopupHovered(hovered) {
|
|
623
|
+
this._infoPopupHovered = hovered && this.showing !== null;
|
|
624
|
+
if (this._infoPopupHovered) {
|
|
625
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
626
|
+
this.cancelScheduledHideInfoPopup();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
_cancelScheduledInfoPopupReplacement() {
|
|
630
|
+
if (this._infoPopupReplacement) {
|
|
631
|
+
clearTimeout(this._infoPopupReplacement.timer);
|
|
632
|
+
this._infoPopupReplacement = null;
|
|
633
|
+
}
|
|
584
634
|
}
|
|
585
635
|
hideInfoPopup() {
|
|
636
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
586
637
|
this.cancelScheduledHideInfoPopup();
|
|
587
638
|
this._infoPopupPinned = false;
|
|
639
|
+
this._infoPopupHovered = false;
|
|
588
640
|
this._showingLink$.next(null);
|
|
589
641
|
const popup = this._infoPopup;
|
|
590
642
|
this._infoPopup = null;
|
|
591
643
|
popup === null || popup === void 0 || popup.dispose();
|
|
592
644
|
}
|
|
593
645
|
scheduleHideInfoPopup() {
|
|
594
|
-
|
|
646
|
+
this._cancelScheduledInfoPopupReplacement();
|
|
647
|
+
if (this._infoPopupPinned || this._infoPopupHovered || !this.showing) return;
|
|
595
648
|
this.cancelScheduledHideInfoPopup();
|
|
596
649
|
this._infoPopupHideTimer = setTimeout(() => {
|
|
597
650
|
this._infoPopupHideTimer = null;
|
|
@@ -789,7 +842,7 @@ const menuSchema = {
|
|
|
789
842
|
//#endregion
|
|
790
843
|
//#region package.json
|
|
791
844
|
var name = "@univerjs/docs-hyper-link-ui";
|
|
792
|
-
var version = "1.
|
|
845
|
+
var version = "1.3.0";
|
|
793
846
|
|
|
794
847
|
//#endregion
|
|
795
848
|
//#region src/config/config.ts
|
|
@@ -44,7 +44,9 @@ export declare class DocHyperLinkPopupService extends Disposable {
|
|
|
44
44
|
private _editPopupUnitId;
|
|
45
45
|
private _infoPopup;
|
|
46
46
|
private _infoPopupPinned;
|
|
47
|
+
private _infoPopupHovered;
|
|
47
48
|
private _infoPopupHideTimer;
|
|
49
|
+
private _infoPopupReplacement;
|
|
48
50
|
private _infoPopupSuppressed;
|
|
49
51
|
private _infoPopupSuppressionTimer;
|
|
50
52
|
constructor(_docCanvasPopupManagerService: DocCanvasPopManagerService, _textSelectionManagerService: DocSelectionManagerService, _univerInstanceService: IUniverInstanceService, _permissionService: IPermissionService, _renderManagerService: IRenderManagerService, _dialogService: IDialogService, _localeService: LocaleService, _commandService: ICommandService);
|
|
@@ -60,6 +62,8 @@ export declare class DocHyperLinkPopupService extends Disposable {
|
|
|
60
62
|
protected _openEditSurface(activeRange: ITextRangeParam, unitId: string): IDisposable;
|
|
61
63
|
protected _openInfoSurface(info: ILinkInfo, componentKey?: string): IDisposable;
|
|
62
64
|
showInfoPopupFromHover(info: ILinkInfo): void;
|
|
65
|
+
setInfoPopupHovered(hovered: boolean): void;
|
|
66
|
+
private _cancelScheduledInfoPopupReplacement;
|
|
63
67
|
hideInfoPopup(): void;
|
|
64
68
|
scheduleHideInfoPopup(): void;
|
|
65
69
|
cancelScheduledHideInfoPopup(): void;
|
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)(L),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)(L),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.cancelScheduledHideInfoPopup()},onPointerLeave:()=>{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 oe(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 L=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,`_infoPopupHideTimer`,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;this._editPopupUnitId===e&&this.hideEditPopup(),((t=this.showing)==null?void 0:t.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;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.cancelScheduledHideInfoPopup(),this._infoPopupSuppressed))return;let{linkId:o,unitId:s,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}=e;if(oe(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._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){this.cancelScheduledHideInfoPopup(),!(this._infoPopupPinned||this._infoPopupSuppressed)&&(this.showing||this.showInfoPopup(e))}hideInfoPopup(){this.cancelScheduledHideInfoPopup(),this._infoPopupPinned=!1,this._showingLink$.next(null);let e=this._infoPopup;this._infoPopup=null,e==null||e.dispose()}scheduleHideInfoPopup(){!this._infoPopupPinned&&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)])}};L=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)],L);let R=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(R(e)&&!i)return!1;let o=e.get(L),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(L);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(R(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.1.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)(L))],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)(L),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)(L)),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)(L))],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 L{_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],[L,{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)(L)),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],[L],[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=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.3.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 $}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-hyper-link-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Hyperlink editing UI for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "1.
|
|
62
|
-
"@univerjs/design": "1.
|
|
63
|
-
"@univerjs/docs": "1.
|
|
64
|
-
"@univerjs/docs-hyper-link": "1.
|
|
65
|
-
"@univerjs/docs-ui": "1.
|
|
66
|
-
"@univerjs/engine-render": "1.
|
|
61
|
+
"@univerjs/core": "1.3.0",
|
|
62
|
+
"@univerjs/design": "1.3.0",
|
|
63
|
+
"@univerjs/docs": "1.3.0",
|
|
64
|
+
"@univerjs/docs-hyper-link": "1.3.0",
|
|
65
|
+
"@univerjs/docs-ui": "1.3.0",
|
|
66
|
+
"@univerjs/engine-render": "1.3.0",
|
|
67
67
|
"@univerjs/icons": "1.46.0",
|
|
68
|
-
"@univerjs/protocol": "1.
|
|
69
|
-
"@univerjs/ui": "1.
|
|
68
|
+
"@univerjs/protocol": "1.3.0",
|
|
69
|
+
"@univerjs/ui": "1.3.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@univerjs-infra/shared": "1.
|
|
72
|
+
"@univerjs-infra/shared": "1.3.0",
|
|
73
73
|
"postcss": "^8.5.29",
|
|
74
74
|
"react": "18.3.1",
|
|
75
|
-
"rxjs": "
|
|
75
|
+
"rxjs": "7.8.2",
|
|
76
76
|
"tailwindcss": "3.4.18",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"vitest": "^5.0.4"
|