@univerjs/sheets-hyper-link-ui 0.25.0 → 1.0.0-alpha.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 +106 -239
- package/lib/es/index.js +109 -242
- package/lib/index.js +109 -242
- package/lib/types/controllers/components.controller.d.ts +24 -0
- package/lib/types/controllers/popup.controller.d.ts +1 -4
- package/lib/types/controllers/ui.controller.d.ts +3 -3
- package/lib/types/index.d.ts +4 -2
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/menu/menu.d.ts +3 -22
- package/lib/types/services/popup.service.d.ts +1 -5
- package/lib/types/services/side-panel.service.d.ts +2 -1
- package/lib/types/types/enums/edit-source.d.ts +1 -2
- package/lib/types/views/{CellLinkEdit/index.d.ts → CellLinkEdit.d.ts} +1 -1
- package/lib/types/views/{CellLinkPopup/index.d.ts → CellLinkPopup.d.ts} +3 -3
- package/lib/umd/index.js +1 -1
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
|
@@ -5,12 +5,12 @@ let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
|
5
5
|
let _univerjs_docs = require("@univerjs/docs");
|
|
6
6
|
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
7
7
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
8
|
-
let _univerjs_ui = require("@univerjs/ui");
|
|
9
8
|
let rxjs = require("rxjs");
|
|
10
9
|
let _univerjs_design = require("@univerjs/design");
|
|
11
10
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
12
11
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
13
12
|
let _univerjs_sheets_hyper_link = require("@univerjs/sheets-hyper-link");
|
|
13
|
+
let _univerjs_ui = require("@univerjs/ui");
|
|
14
14
|
let react = require("react");
|
|
15
15
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
16
|
let _univerjs_icons = require("@univerjs/icons");
|
|
@@ -63,7 +63,7 @@ const configSymbol = Symbol(SHEETS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY);
|
|
|
63
63
|
const defaultPluginConfig = {};
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region \0@oxc-project+runtime@0.
|
|
66
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
67
67
|
function __decorateParam(paramIndex, decorator) {
|
|
68
68
|
return function(target, key) {
|
|
69
69
|
decorator(target, key, paramIndex);
|
|
@@ -71,7 +71,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region \0@oxc-project+runtime@0.
|
|
74
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
75
75
|
function __decorate(decorators, target, key, desc) {
|
|
76
76
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
77
77
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -212,7 +212,7 @@ SheetsHyperLinkResolverService = __decorate([
|
|
|
212
212
|
], SheetsHyperLinkResolverService);
|
|
213
213
|
|
|
214
214
|
//#endregion
|
|
215
|
-
//#region \0@oxc-project+runtime@0.
|
|
215
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
216
216
|
function _typeof(o) {
|
|
217
217
|
"@babel/helpers - typeof";
|
|
218
218
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -223,7 +223,7 @@ function _typeof(o) {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
//#endregion
|
|
226
|
-
//#region \0@oxc-project+runtime@0.
|
|
226
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
227
227
|
function toPrimitive(t, r) {
|
|
228
228
|
if ("object" != _typeof(t) || !t) return t;
|
|
229
229
|
var e = t[Symbol.toPrimitive];
|
|
@@ -236,14 +236,14 @@ function toPrimitive(t, r) {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
//#endregion
|
|
239
|
-
//#region \0@oxc-project+runtime@0.
|
|
239
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
240
240
|
function toPropertyKey(t) {
|
|
241
241
|
var i = toPrimitive(t, "string");
|
|
242
242
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
|
-
//#region \0@oxc-project+runtime@0.
|
|
246
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
247
247
|
function _defineProperty(e, r, t) {
|
|
248
248
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
249
249
|
value: t,
|
|
@@ -313,7 +313,7 @@ function resolveRangePayload(rangeText, defaultSheetName) {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
//#endregion
|
|
316
|
-
//#region src/views/CellLinkEdit
|
|
316
|
+
//#region src/views/CellLinkEdit.tsx
|
|
317
317
|
const CellLinkEdit = () => {
|
|
318
318
|
var _definedNameService$g;
|
|
319
319
|
const [id, setId] = (0, react.useState)("");
|
|
@@ -333,13 +333,10 @@ const CellLinkEdit = () => {
|
|
|
333
333
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
334
334
|
const sidePanelService = (0, _univerjs_ui.useDependency)(SheetsHyperLinkSidePanelService);
|
|
335
335
|
const sidePanelOptions = (0, react.useMemo)(() => sidePanelService.getOptions(), [sidePanelService]);
|
|
336
|
-
const zenZoneService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IZenZoneService);
|
|
337
336
|
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
338
337
|
const markSelectionService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_ui.IMarkSelectionService);
|
|
339
338
|
const textSelectionService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
340
|
-
const contextService = (0, _univerjs_ui.useDependency)(_univerjs_core.IContextService);
|
|
341
339
|
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
342
|
-
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
343
340
|
const [selectorDialogVisible, setSelectorDialogVisible] = (0, react.useState)(false);
|
|
344
341
|
const sheetsSelectionService = (0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetsSelectionsService);
|
|
345
342
|
const selections = (0, react.useMemo)(() => sheetsSelectionService.getCurrentSelections(), []);
|
|
@@ -349,7 +346,11 @@ const CellLinkEdit = () => {
|
|
|
349
346
|
}, [sidePanelService, type]);
|
|
350
347
|
const [showError, setShowError] = (0, react.useState)(false);
|
|
351
348
|
const [isFocusRangeSelector, setIsFocusRangeSelector] = (0, react.useState)(false);
|
|
352
|
-
const
|
|
349
|
+
const isDisplaySyncedWithPayloadRef = (0, react.useRef)(false);
|
|
350
|
+
const getIsDisplaySyncedWithPayload = (0, _univerjs_ui.useEvent)(() => isDisplaySyncedWithPayloadRef.current);
|
|
351
|
+
const setDisplaySyncedWithPayload = (0, _univerjs_ui.useEvent)((synced) => {
|
|
352
|
+
isDisplaySyncedWithPayloadRef.current = synced;
|
|
353
|
+
});
|
|
353
354
|
const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
354
355
|
const subUnitId = (workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet().getSheetId()) || "";
|
|
355
356
|
const setDisplay = (0, react.useCallback)((value) => {
|
|
@@ -419,14 +420,14 @@ const CellLinkEdit = () => {
|
|
|
419
420
|
switch (linkInfo.type) {
|
|
420
421
|
case _univerjs_sheets_hyper_link.SheetHyperLinkType.URL:
|
|
421
422
|
setPayload(linkInfo.url);
|
|
422
|
-
if (linkInfo.url === link.display)
|
|
423
|
+
if (linkInfo.url === link.display) setDisplaySyncedWithPayload(true);
|
|
423
424
|
break;
|
|
424
425
|
case _univerjs_sheets_hyper_link.SheetHyperLinkType.RANGE: {
|
|
425
426
|
var _univerInstanceServic, _univerInstanceServic2;
|
|
426
427
|
const params = linkInfo.searchObj;
|
|
427
428
|
const payload = (0, _univerjs_engine_formula.serializeRangeWithSheet)(params.gid ? (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getUnit(editing.unitId)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(params.gid)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "" : "", (0, _univerjs_engine_formula.deserializeRangeWithSheet)(params.range).range);
|
|
428
429
|
setPayload(payload);
|
|
429
|
-
if (payload === link.display)
|
|
430
|
+
if (payload === link.display) setDisplaySyncedWithPayload(true);
|
|
430
431
|
break;
|
|
431
432
|
}
|
|
432
433
|
case _univerjs_sheets_hyper_link.SheetHyperLinkType.SHEET: {
|
|
@@ -487,7 +488,7 @@ const CellLinkEdit = () => {
|
|
|
487
488
|
setIsFocusRangeSelector(type === _univerjs_sheets_hyper_link.SheetHyperLinkType.RANGE);
|
|
488
489
|
}, [type]);
|
|
489
490
|
(0, react.useEffect)(() => {
|
|
490
|
-
const render =
|
|
491
|
+
const render = renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId());
|
|
491
492
|
const disposeCollection = new _univerjs_core.DisposableCollection();
|
|
492
493
|
if (render) {
|
|
493
494
|
const selectionRenderService = render.with(_univerjs_docs_ui.DocSelectionRenderService);
|
|
@@ -500,11 +501,7 @@ const CellLinkEdit = () => {
|
|
|
500
501
|
editorBridgeService.disableForceKeepVisible();
|
|
501
502
|
disposeCollection.dispose();
|
|
502
503
|
};
|
|
503
|
-
}, [
|
|
504
|
-
editing === null || editing === void 0 ? void 0 : editing.type,
|
|
505
|
-
editorBridgeService,
|
|
506
|
-
renderManagerService
|
|
507
|
-
]);
|
|
504
|
+
}, [editorBridgeService, renderManagerService]);
|
|
508
505
|
(0, react.useEffect)(() => {
|
|
509
506
|
if (isFocusRangeSelector) popupService.setIsKeepVisible(isFocusRangeSelector);
|
|
510
507
|
popupService.setIsKeepVisible(selectorDialogVisible);
|
|
@@ -516,14 +513,6 @@ const CellLinkEdit = () => {
|
|
|
516
513
|
selectorDialogVisible,
|
|
517
514
|
popupService
|
|
518
515
|
]);
|
|
519
|
-
(0, react.useEffect)(() => {
|
|
520
|
-
return () => {
|
|
521
|
-
if (zenZoneService.temporaryHidden) {
|
|
522
|
-
zenZoneService.show();
|
|
523
|
-
contextService.setContextValue(_univerjs_core.FOCUSING_SHEET, false);
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
}, [contextService, zenZoneService]);
|
|
527
516
|
(0, react.useEffect)(() => {
|
|
528
517
|
if (isFocusRangeSelector) {
|
|
529
518
|
editorBridgeService.enableForceKeepVisible();
|
|
@@ -578,9 +567,9 @@ const CellLinkEdit = () => {
|
|
|
578
567
|
return;
|
|
579
568
|
}
|
|
580
569
|
setPayload(newPayload);
|
|
581
|
-
if (newPayload && (
|
|
570
|
+
if (newPayload && (getIsDisplaySyncedWithPayload() || !display)) {
|
|
582
571
|
setDisplay(newPayload);
|
|
583
|
-
|
|
572
|
+
setDisplaySyncedWithPayload(true);
|
|
584
573
|
}
|
|
585
574
|
});
|
|
586
575
|
const handleSubmit = async () => {
|
|
@@ -589,7 +578,7 @@ const CellLinkEdit = () => {
|
|
|
589
578
|
return;
|
|
590
579
|
}
|
|
591
580
|
if (editing) if (id) {
|
|
592
|
-
const commandId = editing.type === "
|
|
581
|
+
const commandId = editing.type === "editing" ? _univerjs_sheets_hyper_link.UpdateRichHyperLinkCommand.id : _univerjs_sheets_hyper_link.UpdateHyperLinkCommand.id;
|
|
593
582
|
await commandService.executeCommand(commandId, {
|
|
594
583
|
id,
|
|
595
584
|
unitId: editing.unitId,
|
|
@@ -600,10 +589,10 @@ const CellLinkEdit = () => {
|
|
|
600
589
|
},
|
|
601
590
|
row: editing.row,
|
|
602
591
|
column: editing.col,
|
|
603
|
-
documentId:
|
|
592
|
+
documentId: editorBridgeService.getCurrentEditorId()
|
|
604
593
|
});
|
|
605
594
|
} else {
|
|
606
|
-
const commandId = editing.type === "
|
|
595
|
+
const commandId = editing.type === "editing" ? _univerjs_sheets_hyper_link.AddRichHyperLinkCommand.id : _univerjs_sheets_hyper_link.AddHyperLinkCommand.id;
|
|
607
596
|
await commandService.executeCommand(commandId, {
|
|
608
597
|
unitId: editing.unitId,
|
|
609
598
|
subUnitId: editing.subUnitId,
|
|
@@ -614,7 +603,7 @@ const CellLinkEdit = () => {
|
|
|
614
603
|
payload: formatUrl(type, payload),
|
|
615
604
|
display: showLabel ? display : ""
|
|
616
605
|
},
|
|
617
|
-
documentId:
|
|
606
|
+
documentId: editorBridgeService.getCurrentEditorId()
|
|
618
607
|
});
|
|
619
608
|
}
|
|
620
609
|
if ((editing === null || editing === void 0 ? void 0 : editing.type) === "viewing") {
|
|
@@ -643,7 +632,7 @@ const CellLinkEdit = () => {
|
|
|
643
632
|
value: display,
|
|
644
633
|
onChange: (v) => {
|
|
645
634
|
setDisplay(v);
|
|
646
|
-
|
|
635
|
+
setDisplaySyncedWithPayload(false);
|
|
647
636
|
},
|
|
648
637
|
placeholder: localeService.t("sheets-hyper-link-ui.form.labelPlaceholder"),
|
|
649
638
|
autoFocus: true,
|
|
@@ -670,9 +659,9 @@ const CellLinkEdit = () => {
|
|
|
670
659
|
value: payload,
|
|
671
660
|
onChange: (newLink) => {
|
|
672
661
|
setPayload(newLink);
|
|
673
|
-
if (newLink && (
|
|
662
|
+
if (newLink && (getIsDisplaySyncedWithPayload() || !display || display === newLink)) {
|
|
674
663
|
setDisplay(newLink);
|
|
675
|
-
|
|
664
|
+
setDisplaySyncedWithPayload(true);
|
|
676
665
|
}
|
|
677
666
|
},
|
|
678
667
|
placeholder: localeService.t("sheets-hyper-link-ui.form.linkPlaceholder"),
|
|
@@ -695,10 +684,6 @@ const CellLinkEdit = () => {
|
|
|
695
684
|
onRangeSelectorDialogVisibleChange: async (visible) => {
|
|
696
685
|
setSelectorDialogVisible(visible);
|
|
697
686
|
if (visible) {
|
|
698
|
-
if (editing.type === "zen_mode") {
|
|
699
|
-
zenZoneService.hide();
|
|
700
|
-
contextService.setContextValue(_univerjs_core.FOCUSING_SHEET, true);
|
|
701
|
-
}
|
|
702
687
|
if (editing.type !== "viewing") editorBridgeService.enableForceKeepVisible();
|
|
703
688
|
setHide(true);
|
|
704
689
|
} else {
|
|
@@ -708,33 +693,6 @@ const CellLinkEdit = () => {
|
|
|
708
693
|
startColumn: editing.col,
|
|
709
694
|
endColumn: editing.col
|
|
710
695
|
}, true);
|
|
711
|
-
if (editing.type === "zen_mode") {
|
|
712
|
-
var _renderManagerService, _docSelectionManagerS;
|
|
713
|
-
await commandService.executeCommand(_univerjs_sheets.SetSelectionsOperation.id, {
|
|
714
|
-
unitId: editing.unitId,
|
|
715
|
-
subUnitId: editing.subUnitId,
|
|
716
|
-
selections: [{ range: {
|
|
717
|
-
startRow: editing.row,
|
|
718
|
-
endRow: editing.row,
|
|
719
|
-
startColumn: editing.col,
|
|
720
|
-
endColumn: editing.col
|
|
721
|
-
} }]
|
|
722
|
-
});
|
|
723
|
-
zenZoneService.show();
|
|
724
|
-
contextService.setContextValue(_univerjs_core.FOCUSING_SHEET, false);
|
|
725
|
-
const docBackScrollRenderController = (_renderManagerService = renderManagerService.getRenderById(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs_ui.DocBackScrollRenderController);
|
|
726
|
-
const range = (_docSelectionManagerS = docSelectionManagerService.getTextRanges({
|
|
727
|
-
unitId: _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,
|
|
728
|
-
subUnitId: _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
729
|
-
})) === null || _docSelectionManagerS === void 0 ? void 0 : _docSelectionManagerS[0];
|
|
730
|
-
if (docBackScrollRenderController && range) {
|
|
731
|
-
docBackScrollRenderController.scrollToRange(range);
|
|
732
|
-
docSelectionManagerService.refreshSelection({
|
|
733
|
-
unitId: _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,
|
|
734
|
-
subUnitId: _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
696
|
editorBridgeService.disableForceKeepVisible();
|
|
739
697
|
setHide(false);
|
|
740
698
|
}
|
|
@@ -753,9 +711,9 @@ const CellLinkEdit = () => {
|
|
|
753
711
|
setPayload(newPayload);
|
|
754
712
|
const label = (_sheetsOption$find = sheetsOption.find((i) => i.value === newPayload)) === null || _sheetsOption$find === void 0 ? void 0 : _sheetsOption$find.label;
|
|
755
713
|
const oldLabel = (_sheetsOption$find2 = sheetsOption.find((i) => i.value === payload)) === null || _sheetsOption$find2 === void 0 ? void 0 : _sheetsOption$find2.label;
|
|
756
|
-
if (label && (
|
|
714
|
+
if (label && (getIsDisplaySyncedWithPayload() || !display || display === oldLabel)) {
|
|
757
715
|
setDisplay(label);
|
|
758
|
-
|
|
716
|
+
setDisplaySyncedWithPayload(true);
|
|
759
717
|
}
|
|
760
718
|
}
|
|
761
719
|
})
|
|
@@ -771,9 +729,9 @@ const CellLinkEdit = () => {
|
|
|
771
729
|
setPayload(newValue);
|
|
772
730
|
const label = (_definedNames$find = definedNames.find((i) => i.value === newValue)) === null || _definedNames$find === void 0 ? void 0 : _definedNames$find.label;
|
|
773
731
|
const oldLabel = (_definedNames$find2 = definedNames.find((i) => i.value === payload)) === null || _definedNames$find2 === void 0 ? void 0 : _definedNames$find2.label;
|
|
774
|
-
if (label && (
|
|
732
|
+
if (label && (getIsDisplaySyncedWithPayload() || !display || display === oldLabel)) {
|
|
775
733
|
setDisplay(label);
|
|
776
|
-
|
|
734
|
+
setDisplaySyncedWithPayload(true);
|
|
777
735
|
}
|
|
778
736
|
}
|
|
779
737
|
})
|
|
@@ -783,10 +741,11 @@ const CellLinkEdit = () => {
|
|
|
783
741
|
payload,
|
|
784
742
|
display,
|
|
785
743
|
showError,
|
|
786
|
-
|
|
744
|
+
getIsDisplaySyncedWithPayload,
|
|
745
|
+
setDisplaySyncedWithPayload,
|
|
787
746
|
setDisplay: (newLink) => {
|
|
788
747
|
setDisplay(newLink);
|
|
789
|
-
|
|
748
|
+
setDisplaySyncedWithPayload(true);
|
|
790
749
|
},
|
|
791
750
|
setPayload
|
|
792
751
|
}),
|
|
@@ -817,7 +776,7 @@ const CellLinkEdit = () => {
|
|
|
817
776
|
CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
|
|
818
777
|
|
|
819
778
|
//#endregion
|
|
820
|
-
//#region src/views/CellLinkPopup
|
|
779
|
+
//#region src/views/CellLinkPopup.tsx
|
|
821
780
|
const iconsMap = {
|
|
822
781
|
[_univerjs_sheets_hyper_link.SheetHyperLinkType.URL]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LinkIcon, {}),
|
|
823
782
|
[_univerjs_sheets_hyper_link.SheetHyperLinkType.SHEET]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.XlsxMultiIcon, { className: "univer-text-green-500" }),
|
|
@@ -834,7 +793,6 @@ const CellLinkPopupPure = (props) => {
|
|
|
834
793
|
const resolverService = (0, _univerjs_ui.useDependency)(SheetsHyperLinkResolverService);
|
|
835
794
|
const editorBridgeService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_ui.IEditorBridgeService);
|
|
836
795
|
const parserHyperLinkService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_hyper_link.SheetsHyperLinkParserService);
|
|
837
|
-
const zenZoneService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IZenZoneService);
|
|
838
796
|
const { customRange, row, col, unitId, subUnitId, editPermission, copyPermission, type } = props;
|
|
839
797
|
if (!(customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url)) return null;
|
|
840
798
|
const linkObj = parserHyperLinkService.parseHyperLink((_customRange$properti2 = customRange.properties.url) !== null && _customRange$properti2 !== void 0 ? _customRange$properti2 : "");
|
|
@@ -845,7 +803,6 @@ const CellLinkPopupPure = (props) => {
|
|
|
845
803
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
846
804
|
className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600", { "univer-text-red-500": isError }),
|
|
847
805
|
onClick: () => {
|
|
848
|
-
if (zenZoneService.visible) return;
|
|
849
806
|
if (isError) return;
|
|
850
807
|
resolverService.navigate(linkObj);
|
|
851
808
|
},
|
|
@@ -902,14 +859,14 @@ const CellLinkPopupPure = (props) => {
|
|
|
902
859
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
903
860
|
className: "univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
904
861
|
onClick: () => {
|
|
905
|
-
const commandId = type === "editing"
|
|
862
|
+
const commandId = type === "editing" ? _univerjs_sheets_hyper_link.CancelRichHyperLinkCommand.id : _univerjs_sheets_hyper_link.CancelHyperLinkCommand.id;
|
|
906
863
|
if (commandService.syncExecuteCommand(commandId, {
|
|
907
864
|
unitId,
|
|
908
865
|
subUnitId,
|
|
909
866
|
id: customRange.rangeId,
|
|
910
867
|
row,
|
|
911
868
|
column: col,
|
|
912
|
-
documentId:
|
|
869
|
+
documentId: editorBridgeService.getCurrentEditorId()
|
|
913
870
|
})) popupService.hideCurrentPopup(void 0, true);
|
|
914
871
|
},
|
|
915
872
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
@@ -965,15 +922,13 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
965
922
|
get currentEditing() {
|
|
966
923
|
return this._currentEditing$.getValue();
|
|
967
924
|
}
|
|
968
|
-
constructor(_sheetCanvasPopManagerService, _injector, _univerInstanceService, _editorBridgeService, _textSelectionManagerService
|
|
925
|
+
constructor(_sheetCanvasPopManagerService, _injector, _univerInstanceService, _editorBridgeService, _textSelectionManagerService) {
|
|
969
926
|
super();
|
|
970
927
|
this._sheetCanvasPopManagerService = _sheetCanvasPopManagerService;
|
|
971
928
|
this._injector = _injector;
|
|
972
929
|
this._univerInstanceService = _univerInstanceService;
|
|
973
930
|
this._editorBridgeService = _editorBridgeService;
|
|
974
931
|
this._textSelectionManagerService = _textSelectionManagerService;
|
|
975
|
-
this._docCanvasPopManagerService = _docCanvasPopManagerService;
|
|
976
|
-
this._zenZoneService = _zenZoneService;
|
|
977
932
|
_defineProperty(this, "_currentPopup", null);
|
|
978
933
|
_defineProperty(this, "_currentPopup$", new rxjs.Subject());
|
|
979
934
|
_defineProperty(this, "currentPopup$", this._currentPopup$.asObservable());
|
|
@@ -997,7 +952,6 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
997
952
|
showPopup(location) {
|
|
998
953
|
if (this._currentPopup && isEqualLink(location, this._currentPopup)) return;
|
|
999
954
|
this.hideCurrentPopup(void 0, true);
|
|
1000
|
-
if (location.type !== "zen_mode" && this._zenZoneService.visible) return;
|
|
1001
955
|
const currentEditing = this._currentEditing$.getValue();
|
|
1002
956
|
if (currentEditing && isEqualLink(location, currentEditing)) return;
|
|
1003
957
|
const { unitId, subUnitId, row, col, customRangeRect, customRange } = location;
|
|
@@ -1015,13 +969,6 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1015
969
|
if (location.type === "editing") {
|
|
1016
970
|
if (!customRange) return;
|
|
1017
971
|
disposable = customRangeRect && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(customRangeRect, popup);
|
|
1018
|
-
} else if (location.type === "zen_mode") {
|
|
1019
|
-
if (!customRange) return;
|
|
1020
|
-
disposable = this._docCanvasPopManagerService.attachPopupToRange({
|
|
1021
|
-
startOffset: customRange.startIndex,
|
|
1022
|
-
endOffset: customRange.endIndex + 1,
|
|
1023
|
-
collapsed: false
|
|
1024
|
-
}, popup, _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
|
|
1025
972
|
} else if (location.showAll) disposable = this._sheetCanvasPopManagerService.attachPopupToCell(location.row, location.col, popup, unitId, subUnitId);
|
|
1026
973
|
else {
|
|
1027
974
|
if (!customRange) return;
|
|
@@ -1108,19 +1055,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1108
1055
|
}
|
|
1109
1056
|
startAddEditing(link) {
|
|
1110
1057
|
const { unitId, subUnitId, type } = link;
|
|
1111
|
-
if (type === "
|
|
1112
|
-
var _document$getBody;
|
|
1113
|
-
const document = this._univerInstanceService.getUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1114
|
-
if (!document) return;
|
|
1115
|
-
const range = this._textSelectionManagerService.getActiveTextRange();
|
|
1116
|
-
if (!range) return;
|
|
1117
|
-
this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(range, this._editPopup, _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
|
|
1118
|
-
const label = (_document$getBody = document.getBody()) === null || _document$getBody === void 0 ? void 0 : _document$getBody.dataStream.slice(range.startOffset, range.endOffset);
|
|
1119
|
-
this._currentEditing$.next({
|
|
1120
|
-
...link,
|
|
1121
|
-
label
|
|
1122
|
-
});
|
|
1123
|
-
} else if (type === "editing") {
|
|
1058
|
+
if (type === "editing") {
|
|
1124
1059
|
var _range$label;
|
|
1125
1060
|
const range = this._getEditingRange();
|
|
1126
1061
|
if (!range) return;
|
|
@@ -1156,22 +1091,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1156
1091
|
const { unitId, subUnitId } = link;
|
|
1157
1092
|
let customRange;
|
|
1158
1093
|
let label;
|
|
1159
|
-
if (link.type === "
|
|
1160
|
-
var _document$getBody2, _document$getBody3;
|
|
1161
|
-
const document = this._univerInstanceService.getUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1162
|
-
customRange = document === null || document === void 0 || (_document$getBody2 = document.getBody()) === null || _document$getBody2 === void 0 || (_document$getBody2 = _document$getBody2.customRanges) === null || _document$getBody2 === void 0 ? void 0 : _document$getBody2.find((range) => range.rangeId === link.customRangeId);
|
|
1163
|
-
label = customRange ? document === null || document === void 0 || (_document$getBody3 = document.getBody()) === null || _document$getBody3 === void 0 ? void 0 : _document$getBody3.dataStream.slice(customRange.startIndex, customRange.endIndex + 1) : "";
|
|
1164
|
-
if (!customRange || !label) return;
|
|
1165
|
-
this._textSelectionManagerService.replaceTextRanges([{
|
|
1166
|
-
startOffset: customRange.startIndex,
|
|
1167
|
-
endOffset: customRange.endIndex + 1
|
|
1168
|
-
}]);
|
|
1169
|
-
this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange({
|
|
1170
|
-
startOffset: customRange.startIndex,
|
|
1171
|
-
endOffset: customRange.endIndex,
|
|
1172
|
-
collapsed: false
|
|
1173
|
-
}, this._editPopup, _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
|
|
1174
|
-
} else if (link.type === "editing") {
|
|
1094
|
+
if (link.type === "editing") {
|
|
1175
1095
|
var _customRangeInfo$rect;
|
|
1176
1096
|
const customRangeInfo = (0, _univerjs_sheets_ui.getEditingCustomRangePosition)(this._injector, link.unitId, link.subUnitId, link.row, link.col, link.customRangeId);
|
|
1177
1097
|
if (!customRangeInfo || !((_customRangeInfo$rect = customRangeInfo.rects) === null || _customRangeInfo$rect === void 0 ? void 0 : _customRangeInfo$rect.length)) return;
|
|
@@ -1222,14 +1142,12 @@ SheetsHyperLinkPopupService = __decorate([
|
|
|
1222
1142
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1223
1143
|
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
1224
1144
|
__decorateParam(3, _univerjs_sheets_ui.IEditorBridgeService),
|
|
1225
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
|
|
1226
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs_ui.DocCanvasPopManagerService)),
|
|
1227
|
-
__decorateParam(6, _univerjs_ui.IZenZoneService)
|
|
1145
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
|
|
1228
1146
|
], SheetsHyperLinkPopupService);
|
|
1229
1147
|
|
|
1230
1148
|
//#endregion
|
|
1231
1149
|
//#region src/utils/index.ts
|
|
1232
|
-
const disables = new Set([
|
|
1150
|
+
const disables = /* @__PURE__ */ new Set([
|
|
1233
1151
|
_univerjs_core.DataValidationType.CHECKBOX,
|
|
1234
1152
|
_univerjs_core.DataValidationType.LIST,
|
|
1235
1153
|
_univerjs_core.DataValidationType.LIST_MULTIPLE
|
|
@@ -1291,9 +1209,7 @@ const InsertHyperLinkOperation = {
|
|
|
1291
1209
|
type: _univerjs_core.CommandType.OPERATION,
|
|
1292
1210
|
id: "sheet.operation.insert-hyper-link",
|
|
1293
1211
|
handler(accessor) {
|
|
1294
|
-
|
|
1295
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1296
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
1212
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
|
|
1297
1213
|
const editorBridgeService = accessor.get(_univerjs_sheets_ui.IEditorBridgeService);
|
|
1298
1214
|
if (!target) return false;
|
|
1299
1215
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -1302,13 +1218,12 @@ const InsertHyperLinkOperation = {
|
|
|
1302
1218
|
const row = selection.range.startRow;
|
|
1303
1219
|
const col = selection.range.startColumn;
|
|
1304
1220
|
const visible = editorBridgeService.isVisible();
|
|
1305
|
-
const isZenEditor = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) === _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY;
|
|
1306
1221
|
return commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
|
|
1307
1222
|
unitId: target.unitId,
|
|
1308
1223
|
subUnitId: target.subUnitId,
|
|
1309
1224
|
row,
|
|
1310
1225
|
col,
|
|
1311
|
-
type:
|
|
1226
|
+
type: visible.visible ? "editing" : "viewing"
|
|
1312
1227
|
});
|
|
1313
1228
|
}
|
|
1314
1229
|
};
|
|
@@ -1534,7 +1449,7 @@ SheetsHyperLinkCopyPasteController = __decorate([
|
|
|
1534
1449
|
|
|
1535
1450
|
//#endregion
|
|
1536
1451
|
//#region src/menu/menu.ts
|
|
1537
|
-
const getEditingLinkDisable$ = (accessor, unitId = _univerjs_core.
|
|
1452
|
+
const getEditingLinkDisable$ = (accessor, unitId = _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) => {
|
|
1538
1453
|
var _accessor$get$getRend;
|
|
1539
1454
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1540
1455
|
const docSelctionService = (_accessor$get$getRend = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderById(unitId)) === null || _accessor$get$getRend === void 0 ? void 0 : _accessor$get$getRend.with(_univerjs_docs_ui.DocSelectionRenderService);
|
|
@@ -1581,51 +1496,28 @@ const getLinkDisable$ = (accessor) => {
|
|
|
1581
1496
|
}, true);
|
|
1582
1497
|
}));
|
|
1583
1498
|
};
|
|
1584
|
-
const linkMenu = {
|
|
1585
|
-
commandId: InsertHyperLinkOperation.id,
|
|
1586
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
1587
|
-
title: "sheets-hyper-link-ui.menu.add",
|
|
1588
|
-
icon: "LinkIcon"
|
|
1589
|
-
};
|
|
1590
|
-
const genZenEditorMenuId = (id) => `${id}-zen-editor`;
|
|
1591
1499
|
const insertLinkMenuFactory = (accessor) => {
|
|
1592
1500
|
return {
|
|
1593
|
-
|
|
1594
|
-
|
|
1501
|
+
commandId: InsertHyperLinkOperation.id,
|
|
1502
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
1503
|
+
title: "sheets-hyper-link-ui.menu.add",
|
|
1504
|
+
icon: "LinkIcon",
|
|
1505
|
+
id: InsertHyperLinkOperation.id,
|
|
1595
1506
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
1596
1507
|
disabled$: getLinkDisable$(accessor)
|
|
1597
1508
|
};
|
|
1598
1509
|
};
|
|
1599
|
-
const zenEditorInsertLinkMenuFactory = (accessor) => {
|
|
1600
|
-
return {
|
|
1601
|
-
...linkMenu,
|
|
1602
|
-
id: genZenEditorMenuId(linkMenu.commandId),
|
|
1603
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC, _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1604
|
-
disabled$: getEditingLinkDisable$(accessor)
|
|
1605
|
-
};
|
|
1606
|
-
};
|
|
1607
|
-
const linkToolbarMenu = {
|
|
1608
|
-
tooltip: "sheets-hyper-link-ui.form.addTitle",
|
|
1609
|
-
commandId: InsertHyperLinkToolbarOperation.id,
|
|
1610
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
1611
|
-
icon: "LinkIcon"
|
|
1612
|
-
};
|
|
1613
1510
|
const insertLinkMenuToolbarFactory = (accessor) => {
|
|
1614
1511
|
return {
|
|
1615
|
-
|
|
1616
|
-
|
|
1512
|
+
tooltip: "sheets-hyper-link-ui.form.addTitle",
|
|
1513
|
+
commandId: InsertHyperLinkToolbarOperation.id,
|
|
1514
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
1515
|
+
icon: "LinkIcon",
|
|
1516
|
+
id: InsertHyperLinkToolbarOperation.id,
|
|
1617
1517
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
1618
1518
|
disabled$: getLinkDisable$(accessor)
|
|
1619
1519
|
};
|
|
1620
1520
|
};
|
|
1621
|
-
const zenEditorInsertLinkMenuToolbarFactory = (accessor) => {
|
|
1622
|
-
return {
|
|
1623
|
-
...linkToolbarMenu,
|
|
1624
|
-
id: genZenEditorMenuId(linkToolbarMenu.commandId),
|
|
1625
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC, _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1626
|
-
disabled$: getEditingLinkDisable$(accessor)
|
|
1627
|
-
};
|
|
1628
|
-
};
|
|
1629
1521
|
const InsertLinkShortcut = {
|
|
1630
1522
|
id: InsertHyperLinkToolbarOperation.id,
|
|
1631
1523
|
binding: _univerjs_ui.KeyCode.K | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
@@ -1635,7 +1527,7 @@ const InsertLinkShortcut = {
|
|
|
1635
1527
|
//#endregion
|
|
1636
1528
|
//#region package.json
|
|
1637
1529
|
var name = "@univerjs/sheets-hyper-link-ui";
|
|
1638
|
-
var version = "0.
|
|
1530
|
+
var version = "1.0.0-alpha.0";
|
|
1639
1531
|
|
|
1640
1532
|
//#endregion
|
|
1641
1533
|
//#region src/controllers/auto-fill.controller.ts
|
|
@@ -1754,6 +1646,42 @@ let SheetsHyperLinkAutoFillController = class SheetsHyperLinkAutoFillController
|
|
|
1754
1646
|
};
|
|
1755
1647
|
SheetsHyperLinkAutoFillController = __decorate([__decorateParam(0, _univerjs_sheets.IAutoFillService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_hyper_link.HyperLinkModel))], SheetsHyperLinkAutoFillController);
|
|
1756
1648
|
|
|
1649
|
+
//#endregion
|
|
1650
|
+
//#region src/controllers/components.controller.ts
|
|
1651
|
+
/**
|
|
1652
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1653
|
+
*
|
|
1654
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1655
|
+
* you may not use this file except in compliance with the License.
|
|
1656
|
+
* You may obtain a copy of the License at
|
|
1657
|
+
*
|
|
1658
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1659
|
+
*
|
|
1660
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1661
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1662
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1663
|
+
* See the License for the specific language governing permissions and
|
|
1664
|
+
* limitations under the License.
|
|
1665
|
+
*/
|
|
1666
|
+
let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
|
|
1667
|
+
constructor(_componentManager, _iconManager) {
|
|
1668
|
+
super();
|
|
1669
|
+
this._componentManager = _componentManager;
|
|
1670
|
+
this._iconManager = _iconManager;
|
|
1671
|
+
this._registerComponents();
|
|
1672
|
+
this._registerIcons();
|
|
1673
|
+
}
|
|
1674
|
+
_registerComponents() {
|
|
1675
|
+
[[CellLinkPopup.componentKey, CellLinkPopup], [CellLinkEdit.componentKey, CellLinkEdit]].forEach(([key, comp]) => {
|
|
1676
|
+
this._componentManager.register(key, comp);
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
_registerIcons() {
|
|
1680
|
+
this.disposeWithMe(this._iconManager.register({ LinkIcon: _univerjs_icons.LinkIcon }));
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
1684
|
+
|
|
1757
1685
|
//#endregion
|
|
1758
1686
|
//#region src/controllers/hyper-link-permission.controller.ts
|
|
1759
1687
|
let SheetsHyperLinkPermissionController = class SheetsHyperLinkPermissionController extends _univerjs_core.Disposable {
|
|
@@ -1789,7 +1717,7 @@ SheetsHyperLinkPermissionController = __decorate([
|
|
|
1789
1717
|
//#endregion
|
|
1790
1718
|
//#region src/controllers/popup.controller.ts
|
|
1791
1719
|
let SheetsHyperLinkPopupController = class SheetsHyperLinkPopupController extends _univerjs_core.Disposable {
|
|
1792
|
-
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionCheckController, _commandService, _editorBridgeService, _textSelectionManagerService, _univerInstanceService
|
|
1720
|
+
constructor(_hoverManagerService, _sheetsHyperLinkPopupService, _renderManagerService, _permissionService, _sheetPermissionCheckController, _commandService, _editorBridgeService, _textSelectionManagerService, _univerInstanceService) {
|
|
1793
1721
|
super();
|
|
1794
1722
|
this._hoverManagerService = _hoverManagerService;
|
|
1795
1723
|
this._sheetsHyperLinkPopupService = _sheetsHyperLinkPopupService;
|
|
@@ -1800,12 +1728,10 @@ let SheetsHyperLinkPopupController = class SheetsHyperLinkPopupController extend
|
|
|
1800
1728
|
this._editorBridgeService = _editorBridgeService;
|
|
1801
1729
|
this._textSelectionManagerService = _textSelectionManagerService;
|
|
1802
1730
|
this._univerInstanceService = _univerInstanceService;
|
|
1803
|
-
this._zenZoneService = _zenZoneService;
|
|
1804
1731
|
this._initHoverListener();
|
|
1805
1732
|
this._initCommandListener();
|
|
1806
1733
|
this._initHoverEditingListener();
|
|
1807
1734
|
this._initTextSelectionListener();
|
|
1808
|
-
this._initZenEditor();
|
|
1809
1735
|
}
|
|
1810
1736
|
_getLinkPermission(location) {
|
|
1811
1737
|
const { unitId, subUnitId, row: currentRow, col: currentCol } = location;
|
|
@@ -1962,48 +1888,6 @@ let SheetsHyperLinkPopupController = class SheetsHyperLinkPopupController extend
|
|
|
1962
1888
|
subscribe === null || subscribe === void 0 || subscribe.unsubscribe();
|
|
1963
1889
|
});
|
|
1964
1890
|
}
|
|
1965
|
-
_initZenEditor() {
|
|
1966
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
|
|
1967
|
-
if (visible) {
|
|
1968
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup("viewing");
|
|
1969
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup("editing");
|
|
1970
|
-
this._sheetsHyperLinkPopupService.endEditing("editing");
|
|
1971
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup("viewing");
|
|
1972
|
-
} else {
|
|
1973
|
-
this._sheetsHyperLinkPopupService.hideCurrentPopup("zen_mode");
|
|
1974
|
-
this._sheetsHyperLinkPopupService.endEditing("zen_mode");
|
|
1975
|
-
}
|
|
1976
|
-
}));
|
|
1977
|
-
this.disposeWithMe(this._univerInstanceService.focused$.pipe((0, rxjs.switchMap)((id) => {
|
|
1978
|
-
const render = id === _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY ? this._renderManagerService.getRenderById(id) : null;
|
|
1979
|
-
if (render) return render.with(_univerjs_docs_ui.DocEventManagerService).hoverCustomRanges$.pipe((0, rxjs.debounceTime)(200));
|
|
1980
|
-
return new rxjs.Observable((sub) => {
|
|
1981
|
-
sub.next(null);
|
|
1982
|
-
});
|
|
1983
|
-
})).subscribe((value) => {
|
|
1984
|
-
const range = value === null || value === void 0 ? void 0 : value.find((range) => range.range.rangeType === _univerjs_core.CustomRangeType.HYPERLINK);
|
|
1985
|
-
const state = this._editorBridgeService.getEditCellState();
|
|
1986
|
-
if (range && state) {
|
|
1987
|
-
const { unitId, sheetId, row, column } = state;
|
|
1988
|
-
const { editPermission, viewPermission, copyPermission } = this._getLinkPermission({
|
|
1989
|
-
unitId,
|
|
1990
|
-
subUnitId: sheetId,
|
|
1991
|
-
row,
|
|
1992
|
-
col: column
|
|
1993
|
-
});
|
|
1994
|
-
if (viewPermission) this._sheetsHyperLinkPopupService.showPopup({
|
|
1995
|
-
type: "zen_mode",
|
|
1996
|
-
unitId,
|
|
1997
|
-
subUnitId: sheetId,
|
|
1998
|
-
row,
|
|
1999
|
-
col: column,
|
|
2000
|
-
customRange: range.range,
|
|
2001
|
-
editPermission,
|
|
2002
|
-
copyPermission
|
|
2003
|
-
});
|
|
2004
|
-
} else this._sheetsHyperLinkPopupService.hideCurrentPopup("zen_mode");
|
|
2005
|
-
}));
|
|
2006
|
-
}
|
|
2007
1891
|
_initTextSelectionListener() {
|
|
2008
1892
|
this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
2009
1893
|
if (selection && selection.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) this._sheetsHyperLinkPopupService.endEditing("editing");
|
|
@@ -2029,8 +1913,7 @@ SheetsHyperLinkPopupController = __decorate([
|
|
|
2029
1913
|
__decorateParam(5, _univerjs_core.ICommandService),
|
|
2030
1914
|
__decorateParam(6, _univerjs_sheets_ui.IEditorBridgeService),
|
|
2031
1915
|
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
2032
|
-
__decorateParam(8, _univerjs_core.IUniverInstanceService)
|
|
2033
|
-
__decorateParam(9, _univerjs_ui.IZenZoneService)
|
|
1916
|
+
__decorateParam(8, _univerjs_core.IUniverInstanceService)
|
|
2034
1917
|
], SheetsHyperLinkPopupController);
|
|
2035
1918
|
|
|
2036
1919
|
//#endregion
|
|
@@ -2057,25 +1940,15 @@ SheetsHyperLinkRenderController = __decorate([__decorateParam(1, (0, _univerjs_c
|
|
|
2057
1940
|
//#endregion
|
|
2058
1941
|
//#region src/menu/schema.ts
|
|
2059
1942
|
const menuSchema = {
|
|
2060
|
-
[_univerjs_ui.RibbonInsertGroup.MEDIA]: {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
},
|
|
2065
|
-
[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
|
|
2066
|
-
order: 1,
|
|
2067
|
-
menuItemFactory: zenEditorInsertLinkMenuToolbarFactory
|
|
2068
|
-
}
|
|
2069
|
-
},
|
|
1943
|
+
[_univerjs_ui.RibbonInsertGroup.MEDIA]: { [InsertHyperLinkToolbarOperation.id]: {
|
|
1944
|
+
order: 1,
|
|
1945
|
+
menuItemFactory: insertLinkMenuToolbarFactory
|
|
1946
|
+
} },
|
|
2070
1947
|
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: {
|
|
2071
1948
|
order: 1,
|
|
2072
1949
|
[InsertHyperLinkToolbarOperation.id]: {
|
|
2073
1950
|
order: 0,
|
|
2074
1951
|
menuItemFactory: insertLinkMenuFactory
|
|
2075
|
-
},
|
|
2076
|
-
[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]: {
|
|
2077
|
-
order: 0,
|
|
2078
|
-
menuItemFactory: zenEditorInsertLinkMenuFactory
|
|
2079
1952
|
}
|
|
2080
1953
|
} }
|
|
2081
1954
|
};
|
|
@@ -2098,27 +1971,18 @@ const menuSchema = {
|
|
|
2098
1971
|
* limitations under the License.
|
|
2099
1972
|
*/
|
|
2100
1973
|
let SheetsHyperLinkUIController = class SheetsHyperLinkUIController extends _univerjs_core.Disposable {
|
|
2101
|
-
constructor(_componentManager, _commandService, _menuManagerService, _injector, _shortcutService) {
|
|
1974
|
+
constructor(_componentManager, _iconManager, _commandService, _menuManagerService, _injector, _shortcutService) {
|
|
2102
1975
|
super();
|
|
2103
1976
|
this._componentManager = _componentManager;
|
|
1977
|
+
this._iconManager = _iconManager;
|
|
2104
1978
|
this._commandService = _commandService;
|
|
2105
1979
|
this._menuManagerService = _menuManagerService;
|
|
2106
1980
|
this._injector = _injector;
|
|
2107
1981
|
this._shortcutService = _shortcutService;
|
|
2108
|
-
this._initComponents();
|
|
2109
1982
|
this._initCommands();
|
|
2110
1983
|
this._initMenus();
|
|
2111
1984
|
this._initShortCut();
|
|
2112
1985
|
}
|
|
2113
|
-
_initComponents() {
|
|
2114
|
-
[
|
|
2115
|
-
[CellLinkPopup.componentKey, CellLinkPopup],
|
|
2116
|
-
[CellLinkEdit.componentKey, CellLinkEdit],
|
|
2117
|
-
["LinkIcon", _univerjs_icons.LinkIcon]
|
|
2118
|
-
].forEach(([key, comp]) => {
|
|
2119
|
-
this._componentManager.register(key, comp);
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
1986
|
_initCommands() {
|
|
2123
1987
|
[
|
|
2124
1988
|
OpenHyperLinkEditPanelOperation,
|
|
@@ -2138,10 +2002,11 @@ let SheetsHyperLinkUIController = class SheetsHyperLinkUIController extends _uni
|
|
|
2138
2002
|
};
|
|
2139
2003
|
SheetsHyperLinkUIController = __decorate([
|
|
2140
2004
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
2141
|
-
__decorateParam(1, _univerjs_core.
|
|
2142
|
-
__decorateParam(2,
|
|
2143
|
-
__decorateParam(3,
|
|
2144
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(
|
|
2005
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager)),
|
|
2006
|
+
__decorateParam(2, _univerjs_core.ICommandService),
|
|
2007
|
+
__decorateParam(3, _univerjs_ui.IMenuManagerService),
|
|
2008
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2009
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_ui.IShortcutService))
|
|
2145
2010
|
], SheetsHyperLinkUIController);
|
|
2146
2011
|
|
|
2147
2012
|
//#endregion
|
|
@@ -2191,6 +2056,8 @@ let UniverSheetsHyperLinkUIPlugin = class UniverSheetsHyperLinkUIPlugin extends
|
|
|
2191
2056
|
this._configService.setConfig(SHEETS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY, rest);
|
|
2192
2057
|
}
|
|
2193
2058
|
onStarting() {
|
|
2059
|
+
this._injector.add([ComponentsController]);
|
|
2060
|
+
this._injector.get(ComponentsController);
|
|
2194
2061
|
[
|
|
2195
2062
|
[SheetsHyperLinkResolverService],
|
|
2196
2063
|
[SheetsHyperLinkPopupService],
|