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