@univerjs/sheets-hyper-link-ui 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +69 -115
- package/lib/types/controllers/menu.d.ts +5 -6
- package/lib/umd/index.js +2 -2
- package/package.json +14 -14
package/lib/es/index.js
CHANGED
|
@@ -2,18 +2,18 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Tools, Inject, LocaleService, UniverInstanceType, isValidRange, IUniverInstanceService, ICommandService, IConfigService, RANGE_TYPE, Rectangle, Injector, Disposable, Range, ObjectMatrix, CommandType, IUndoRedoService, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, getBodySlice, useDependency, IContextService, ThemeService, ColorKit, DisposableCollection, FOCUSING_SHEET,
|
|
5
|
+
import { Tools, Inject, LocaleService, UniverInstanceType, isValidRange, IUniverInstanceService, ICommandService, IConfigService, RANGE_TYPE, Rectangle, Injector, Disposable, Range, ObjectMatrix, CommandType, IUndoRedoService, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, getBodySlice, useDependency, IContextService, ThemeService, ColorKit, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DisposableCollection, FOCUSING_SHEET, sequenceExecute, useObservable as useObservable$1, DataValidationType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, IPermissionService, InterceptorEffectEnum, DependentOn, Plugin } from "@univerjs/core";
|
|
6
6
|
import { SheetHyperLinkType, ERROR_RANGE, HyperLinkModel, RemoveHyperLinkMutation, AddHyperLinkMutation, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
7
7
|
import { ScrollToRangeOperation, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, IEditorBridgeService, SheetSkeletonManagerService, IMarkSelectionService, SheetCanvasPopManagerService, getEditingCustomRangePosition, getCustomRangePosition, whenSheetEditorFocused, getCurrentRangeDisable$, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange, SheetPermissionInterceptorBaseController, HoverManagerService, HoverRenderController } from "@univerjs/sheets-ui";
|
|
8
8
|
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
9
9
|
import { deserializeRangeWithSheet, serializeRangeWithSheet, serializeRange, IDefinedNamesService, serializeRangeToRefString } from "@univerjs/engine-formula";
|
|
10
|
-
import { SetSelectionsOperation, SetWorksheetActiveOperation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookCopyPermission, WorksheetCopyPermission, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, SheetInterceptorService, RemoveSheetCommand, INTERCEPTOR_POINT, RefRangeService,
|
|
10
|
+
import { SetSelectionsOperation, SetWorksheetActiveOperation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookCopyPermission, WorksheetCopyPermission, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, SheetInterceptorService, RemoveSheetCommand, INTERCEPTOR_POINT, RefRangeService, SetRangeValuesCommand } from "@univerjs/sheets";
|
|
11
11
|
import { IMessageService, useObservable, IZenZoneService, useEvent, KeyCode, MenuItemType, MenuPosition, MenuGroup, MetaKeys, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IShortcutService, IMenuManagerService } from "@univerjs/ui";
|
|
12
|
-
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
13
|
-
import { Subject, BehaviorSubject, map, mergeMap, Observable, debounceTime } from "rxjs";
|
|
14
12
|
import { addCustomRangeBySelectionFactory, replaceSelectionFactory, DocSelectionRenderService, DocBackScrollRenderController, deleteCustomRangeFactory, DocCanvasPopManagerService, IEditorService, IRangeSelectorService, DocEventManagerService, UniverDocsUIPlugin } from "@univerjs/docs-ui";
|
|
15
|
-
import require$$0, { useState, useMemo, useRef, useEffect, forwardRef, createElement } from "react";
|
|
16
13
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
14
|
+
import { Subject, BehaviorSubject, of, map, filter, switchMap, distinctUntilChanged, debounceTime, Observable } from "rxjs";
|
|
15
|
+
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
16
|
+
import require$$0, { useState, useMemo, useRef, useEffect, forwardRef, createElement } from "react";
|
|
17
17
|
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
18
18
|
function isLegalLink(link) {
|
|
19
19
|
return Tools.isLegalUrl(link);
|
|
@@ -253,15 +253,15 @@ let SheetsHyperLinkCopyPasteController = (_a2 = class extends Disposable {
|
|
|
253
253
|
this._plainTextFilter.clear();
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
|
-
registerPlainTextFilter(
|
|
257
|
-
this._plainTextFilter.add(
|
|
256
|
+
registerPlainTextFilter(filter2) {
|
|
257
|
+
this._plainTextFilter.add(filter2);
|
|
258
258
|
}
|
|
259
|
-
removePlainTextFilter(
|
|
260
|
-
this._plainTextFilter.delete(
|
|
259
|
+
removePlainTextFilter(filter2) {
|
|
260
|
+
this._plainTextFilter.delete(filter2);
|
|
261
261
|
}
|
|
262
262
|
/* If return false the process of paste text will be stop */
|
|
263
263
|
_filterPlainText(text) {
|
|
264
|
-
return Array.from(this._plainTextFilter).every((
|
|
264
|
+
return Array.from(this._plainTextFilter).every((filter2) => filter2(text));
|
|
265
265
|
}
|
|
266
266
|
_initCopyPaste() {
|
|
267
267
|
this._sheetClipboardService.addClipboardHook({
|
|
@@ -510,10 +510,7 @@ const AddHyperLinkCommand = {
|
|
|
510
510
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
511
511
|
if (!params)
|
|
512
512
|
return !1;
|
|
513
|
-
const { documentId, link } = params, commandService = accessor.get(ICommandService),
|
|
514
|
-
if (!textSelectionService.getActiveTextRange())
|
|
515
|
-
return !1;
|
|
516
|
-
const replaceSelection = addCustomRangeBySelectionFactory(accessor, {
|
|
513
|
+
const { documentId, link } = params, commandService = accessor.get(ICommandService), newId = generateRandomId(), { payload } = link, replaceSelection = addCustomRangeBySelectionFactory(accessor, {
|
|
517
514
|
unitId: documentId,
|
|
518
515
|
rangeId: newId,
|
|
519
516
|
rangeType: CustomRangeType.HYPERLINK,
|
|
@@ -695,7 +692,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
695
692
|
useEffect(() => {
|
|
696
693
|
isFocusRangeSelectorSet(!1);
|
|
697
694
|
}, [subUnitId]), useEffect(() => {
|
|
698
|
-
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
695
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
699
696
|
if ((editing == null ? void 0 : editing.row) !== void 0 && editing.col !== void 0) {
|
|
700
697
|
const { label, customRange, row, col } = editing;
|
|
701
698
|
let link;
|
|
@@ -720,11 +717,11 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
720
717
|
column: col
|
|
721
718
|
};
|
|
722
719
|
} else {
|
|
723
|
-
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC),
|
|
720
|
+
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), currentSelection = textSelectionService.getActiveTextRange(), body = doc == null ? void 0 : doc.getBody(), selection = currentSelection && body ? BuildTextUtils.selection.getInsertSelection(currentSelection, body) : null, customRange2 = selection && ((_l = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_k = body == null ? void 0 : body.customRanges) != null ? _k : [])) == null ? void 0 : _l[0]);
|
|
724
721
|
setShowLabel(!1), link = {
|
|
725
722
|
id: "",
|
|
726
723
|
display: label != null ? label : "",
|
|
727
|
-
payload: (
|
|
724
|
+
payload: (_n = (_m = customRange2 == null ? void 0 : customRange2.properties) == null ? void 0 : _m.url) != null ? _n : "",
|
|
728
725
|
row,
|
|
729
726
|
column: col
|
|
730
727
|
};
|
|
@@ -744,7 +741,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
744
741
|
break;
|
|
745
742
|
}
|
|
746
743
|
case SheetHyperLinkType.RANGE: {
|
|
747
|
-
const params = linkInfo.searchObj, sheetName = params.gid && (
|
|
744
|
+
const params = linkInfo.searchObj, sheetName = params.gid && (_q = (_p = (_o = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _o.getSheetBySheetId(params.gid)) == null ? void 0 : _p.getName()) != null ? _q : "", payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
|
|
748
745
|
setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
|
|
749
746
|
break;
|
|
750
747
|
}
|
|
@@ -791,10 +788,10 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
791
788
|
return () => {
|
|
792
789
|
id2 && markSelectionService.removeShape(id2);
|
|
793
790
|
};
|
|
794
|
-
}, [editing, markSelectionService, themeService, univerInstanceService])
|
|
795
|
-
|
|
796
|
-
useEffect(() => {
|
|
797
|
-
const render2 = renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()), disposeCollection = new DisposableCollection();
|
|
791
|
+
}, [editing, markSelectionService, themeService, univerInstanceService]), useEffect(() => {
|
|
792
|
+
type === SheetHyperLinkType.RANGE && !showLabel && !isFocusRangeSelector && isFocusRangeSelectorSet(!0);
|
|
793
|
+
}, [type, isFocusRangeSelector, showLabel, editorBridgeService]), useEffect(() => {
|
|
794
|
+
const render2 = (editing == null ? void 0 : editing.type) === HyperLinkEditSourceType.ZEN_EDITOR ? renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY) : renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()), disposeCollection = new DisposableCollection();
|
|
798
795
|
if (render2) {
|
|
799
796
|
const selectionRenderService = render2.with(DocSelectionRenderService);
|
|
800
797
|
selectionRenderService.setReserveRangesStatus(!0), disposeCollection.add(() => {
|
|
@@ -804,9 +801,9 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
804
801
|
return () => {
|
|
805
802
|
editorBridgeService.disableForceKeepVisible(), disposeCollection.dispose();
|
|
806
803
|
};
|
|
807
|
-
}, [editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(
|
|
804
|
+
}, [editing == null ? void 0 : editing.type, editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(isFocusRangeSelector), () => {
|
|
808
805
|
popupService.setIsKeepVisible(!1);
|
|
809
|
-
}), [
|
|
806
|
+
}), [isFocusRangeSelector, popupService]), useEffect(() => () => {
|
|
810
807
|
zenZoneService.temporaryHidden && (zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1));
|
|
811
808
|
}, [contextService, zenZoneService]);
|
|
812
809
|
const linkTypeOptions = [
|
|
@@ -930,7 +927,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
930
927
|
)
|
|
931
928
|
}
|
|
932
929
|
) : null,
|
|
933
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("hyperLink.form.type"),
|
|
930
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("hyperLink.form.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
934
931
|
Select,
|
|
935
932
|
{
|
|
936
933
|
options: linkTypeOptions,
|
|
@@ -952,7 +949,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
952
949
|
setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
|
|
953
950
|
}, "onChange"),
|
|
954
951
|
placeholder: localeService.t("hyperLink.form.linkPlaceholder"),
|
|
955
|
-
autoFocus: !
|
|
952
|
+
autoFocus: !0,
|
|
956
953
|
onKeyDown: /* @__PURE__ */ __name((e) => {
|
|
957
954
|
e.keyCode === KeyCode.ENTER && handleSubmit();
|
|
958
955
|
}, "onKeyDown")
|
|
@@ -967,7 +964,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
967
964
|
subUnitId,
|
|
968
965
|
isOnlyOneRange: !0,
|
|
969
966
|
isSupportAcrossSheet: !0,
|
|
970
|
-
initValue:
|
|
967
|
+
initValue: payload,
|
|
971
968
|
onChange: handleRangeChange,
|
|
972
969
|
isFocus: isFocusRangeSelector,
|
|
973
970
|
onBlur: /* @__PURE__ */ __name(() => {
|
|
@@ -986,9 +983,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
986
983
|
selections: [{ range: { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col } }]
|
|
987
984
|
}), zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1);
|
|
988
985
|
const docBackScrollRenderController = (_a16 = renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a16.with(DocBackScrollRenderController), range = (_b = docSelectionManagerService.getTextRanges({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY })) == null ? void 0 : _b[0];
|
|
989
|
-
docBackScrollRenderController && range &&
|
|
990
|
-
docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY });
|
|
991
|
-
}, 100);
|
|
986
|
+
docBackScrollRenderController && range && (docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY }));
|
|
992
987
|
}
|
|
993
988
|
editorBridgeService.disableForceKeepVisible(), setHide(!1);
|
|
994
989
|
}
|
|
@@ -1466,7 +1461,7 @@ let SheetsHyperLinkPopupService = (_a3 = class extends Disposable {
|
|
|
1466
1461
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1467
1462
|
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1468
1463
|
};
|
|
1469
|
-
const links = BuildTextUtils.customRange.
|
|
1464
|
+
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (_c = (_b = body.customRanges) == null ? void 0 : _b.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) != null ? _c : []);
|
|
1470
1465
|
let start = textRange.startOffset, end = textRange.endOffset;
|
|
1471
1466
|
return links.forEach((link) => {
|
|
1472
1467
|
start = Math.min(start, link.startIndex), end = Math.max(end, link.endIndex + 1);
|
|
@@ -1631,16 +1626,17 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1631
1626
|
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1632
1627
|
return getShouldDisableCellLink(worksheet, row, col);
|
|
1633
1628
|
}, "getShouldDisableCurrentCellLink"), shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
1634
|
-
var _a15;
|
|
1629
|
+
var _a15, _b;
|
|
1635
1630
|
const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getDocRanges();
|
|
1636
1631
|
if (!textRanges.length || textRanges.length > 1)
|
|
1637
1632
|
return !0;
|
|
1638
1633
|
const activeRange = textRanges[0], doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
1639
1634
|
if (!doc || !activeRange || activeRange.collapsed)
|
|
1640
1635
|
return !0;
|
|
1641
|
-
const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody()
|
|
1642
|
-
if (!
|
|
1636
|
+
const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody();
|
|
1637
|
+
if (!body)
|
|
1643
1638
|
return !0;
|
|
1639
|
+
const paragraphs = (_a15 = body == null ? void 0 : body.paragraphs) != null ? _a15 : [];
|
|
1644
1640
|
for (let i = 0, len = paragraphs.length; i < len; i++) {
|
|
1645
1641
|
const p2 = paragraphs[i];
|
|
1646
1642
|
if (activeRange.startOffset <= p2.startIndex && activeRange.endOffset > p2.startIndex)
|
|
@@ -1648,7 +1644,7 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1648
1644
|
if (p2.startIndex > activeRange.endOffset)
|
|
1649
1645
|
break;
|
|
1650
1646
|
}
|
|
1651
|
-
return !BuildTextUtils.customRange.
|
|
1647
|
+
return !BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(activeRange, (_b = body.customRanges) != null ? _b : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
|
|
1652
1648
|
}, "shouldDisableAddLink"), OpenHyperLinkEditPanelOperation = {
|
|
1653
1649
|
type: CommandType.OPERATION,
|
|
1654
1650
|
id: "sheet.operation.open-hyper-link-edit-panel",
|
|
@@ -1693,13 +1689,23 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1693
1689
|
const commandService = accessor.get(ICommandService);
|
|
1694
1690
|
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkPopupOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
1695
1691
|
}
|
|
1696
|
-
},
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1692
|
+
}, getEditingLinkDisable$ = /* @__PURE__ */ __name((accessor, unitId = DOCS_ZEN_EDITOR_UNIT_ID_KEY) => {
|
|
1693
|
+
var _a15;
|
|
1694
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), docSelctionService = (_a15 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a15.with(DocSelectionRenderService);
|
|
1695
|
+
return docSelctionService ? docSelctionService.textSelectionInner$.pipe(map(() => {
|
|
1696
|
+
const state = accessor.get(IEditorBridgeService).getEditCellState();
|
|
1697
|
+
if (!state)
|
|
1698
|
+
return !0;
|
|
1699
|
+
const target = getSheetCommandTarget(univerInstanceService, { unitId: state.unitId, subUnitId: state.sheetId });
|
|
1700
|
+
return !(target != null && target.worksheet) || getShouldDisableCellLink(target.worksheet, state.row, state.column) ? !0 : shouldDisableAddLink(accessor);
|
|
1701
|
+
})) : of(!0);
|
|
1702
|
+
}, "getEditingLinkDisable$"), getLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
1703
|
+
const disableRange$ = getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }, !0), univerInstanceService = accessor.get(IUniverInstanceService), sheetSelectionService = accessor.get(SheetsSelectionsService), editorBridgeService = accessor.has(IEditorBridgeService) ? accessor.get(IEditorBridgeService) : null, disableCell$ = univerInstanceService.focused$.pipe(
|
|
1704
|
+
filter((focused) => !!focused),
|
|
1705
|
+
map((focused) => univerInstanceService.getUnit(focused, UniverInstanceType.UNIVER_SHEET)),
|
|
1706
|
+
filter((unit) => !!unit),
|
|
1707
|
+
switchMap((unit) => unit.activeSheet$),
|
|
1708
|
+
switchMap((sheet) => sheetSelectionService.selectionMoveEnd$.pipe(map((selections) => sheet && { selections, sheet }))),
|
|
1703
1709
|
map((sheetWithSelection) => {
|
|
1704
1710
|
if (!sheetWithSelection)
|
|
1705
1711
|
return !0;
|
|
@@ -1707,25 +1713,20 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1707
1713
|
if (!selections.length)
|
|
1708
1714
|
return !0;
|
|
1709
1715
|
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1710
|
-
|
|
1711
|
-
})
|
|
1712
|
-
);
|
|
1713
|
-
return disableRange$.pipe(mergeMap((disableRange) => disableCell$.pipe(map((disableCell) => disableRange || disableCell))));
|
|
1714
|
-
}, "getLinkDisable$"), getZenLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
1715
|
-
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1716
|
-
return univerInstanceService.focused$.pipe(
|
|
1717
|
-
mergeMap((focused) => !focused || focused !== DOCS_ZEN_EDITOR_UNIT_ID_KEY ? new Observable((sub) => sub.next(null)) : accessor.get(DocSelectionManagerService).textSelection$),
|
|
1718
|
-
map((selection) => {
|
|
1719
|
-
if (!selection || selection.unitId !== DOCS_ZEN_EDITOR_UNIT_ID_KEY)
|
|
1720
|
-
return !0;
|
|
1721
|
-
const state = accessor.get(IEditorBridgeService).getEditCellState();
|
|
1722
|
-
if (!state)
|
|
1716
|
+
if (getShouldDisableCellLink(sheet, row, col))
|
|
1723
1717
|
return !0;
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1718
|
+
}),
|
|
1719
|
+
switchMap((disableCell) => disableCell ? of(!0) : (editorBridgeService ? editorBridgeService.visible$ : of(null)).pipe(map((visible) => visible != null && visible.visible ? DOCS_NORMAL_EDITOR_UNIT_ID_KEY : void 0)).pipe(
|
|
1720
|
+
switchMap(
|
|
1721
|
+
(editing) => editing ? getEditingLinkDisable$(accessor, editing) : of(!1)
|
|
1722
|
+
)
|
|
1723
|
+
))
|
|
1727
1724
|
);
|
|
1728
|
-
|
|
1725
|
+
return disableRange$.pipe(
|
|
1726
|
+
distinctUntilChanged(),
|
|
1727
|
+
switchMap((disableRange) => disableCell$.pipe(map((disableCell) => disableRange || disableCell)))
|
|
1728
|
+
);
|
|
1729
|
+
}, "getLinkDisable$"), linkMenu = {
|
|
1729
1730
|
commandId: InsertHyperLinkOperation.id,
|
|
1730
1731
|
type: MenuItemType.BUTTON,
|
|
1731
1732
|
positions: [MenuPosition.CONTEXT_MENU],
|
|
@@ -1741,7 +1742,7 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1741
1742
|
...linkMenu,
|
|
1742
1743
|
id: genZenEditorMenuId(linkMenu.commandId),
|
|
1743
1744
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1744
|
-
disabled$:
|
|
1745
|
+
disabled$: getEditingLinkDisable$(accessor)
|
|
1745
1746
|
}), "zenEditorInsertLinkMenuFactory"), linkToolbarMenu = {
|
|
1746
1747
|
tooltip: "hyperLink.form.addTitle",
|
|
1747
1748
|
positions: MenuPosition.TOOLBAR_START,
|
|
@@ -1758,7 +1759,7 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1758
1759
|
...linkToolbarMenu,
|
|
1759
1760
|
id: genZenEditorMenuId(linkToolbarMenu.commandId),
|
|
1760
1761
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
|
|
1761
|
-
disabled$:
|
|
1762
|
+
disabled$: getEditingLinkDisable$(accessor)
|
|
1762
1763
|
}), "zenEditorInsertLinkMenuToolbarFactory"), InsertLinkShortcut = {
|
|
1763
1764
|
id: InsertHyperLinkToolbarOperation.id,
|
|
1764
1765
|
binding: KeyCode.K | MetaKeys.CTRL_COMMAND,
|
|
@@ -1961,7 +1962,7 @@ let SheetsHyperLinkPopupController = (_a6 = class extends Disposable {
|
|
|
1961
1962
|
_initHoverEditingListener() {
|
|
1962
1963
|
let subscribe = null;
|
|
1963
1964
|
this.disposeWithMe(
|
|
1964
|
-
this._editorBridgeService.currentEditCellState$.pipe(
|
|
1965
|
+
this._editorBridgeService.currentEditCellState$.pipe(switchMap((state) => this._editorBridgeService.visible$.pipe(map((visible) => ({ visible, state }))))).subscribe(({ visible, state }) => {
|
|
1965
1966
|
if (!state || state.editorUnitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY)
|
|
1966
1967
|
return;
|
|
1967
1968
|
if (!visible.visible) {
|
|
@@ -2008,11 +2009,11 @@ let SheetsHyperLinkPopupController = (_a6 = class extends Disposable {
|
|
|
2008
2009
|
_initZenEditor() {
|
|
2009
2010
|
this.disposeWithMe(
|
|
2010
2011
|
this._zenZoneService.visible$.subscribe((visible) => {
|
|
2011
|
-
visible
|
|
2012
|
+
visible ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.ZEN_EDITOR));
|
|
2012
2013
|
})
|
|
2013
2014
|
), this.disposeWithMe(
|
|
2014
2015
|
this._univerInstanceService.focused$.pipe(
|
|
2015
|
-
|
|
2016
|
+
switchMap((id) => {
|
|
2016
2017
|
const render2 = id === DOCS_ZEN_EDITOR_UNIT_ID_KEY ? this._renderManagerService.getRenderById(id) : null;
|
|
2017
2018
|
return render2 ? render2.with(DocEventManagerService).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((sub) => {
|
|
2018
2019
|
sub.next(null);
|
|
@@ -2204,56 +2205,7 @@ let SheetsHyperLinkRichTextRefRangeController = (_a10 = class extends Disposable
|
|
|
2204
2205
|
}
|
|
2205
2206
|
_registerRange(unitId, subUnitId, row, col, p2) {
|
|
2206
2207
|
var _a15, _b, _c, _d;
|
|
2207
|
-
const map2 = this._enusreMap(unitId, subUnitId)
|
|
2208
|
-
var _a16, _b2;
|
|
2209
|
-
const dataCopy = Tools.deepClone(data);
|
|
2210
|
-
(_b2 = (_a16 = dataCopy.body) == null ? void 0 : _a16.customRanges) == null || _b2.forEach((customRange) => {
|
|
2211
|
-
var _a17;
|
|
2212
|
-
if (customRange.rangeType === CustomRangeType.HYPERLINK) {
|
|
2213
|
-
const payload = (_a17 = customRange.properties) == null ? void 0 : _a17.url, range = this._isLegalRangeUrl(unitId, payload);
|
|
2214
|
-
if (range) {
|
|
2215
|
-
const resultRange = handleDefaultRangeChangeWithEffectRefCommands(range, commandInfo), newPayload = `#gid=${subUnitId}&range=${resultRange ? serializeRange(resultRange) : ERROR_RANGE}`;
|
|
2216
|
-
customRange.properties.url = newPayload;
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
});
|
|
2220
|
-
const position = handleDefaultRangeChangeWithEffectRefCommands({ startRow: row, endRow: row, startColumn: col, endColumn: col }, commandInfo);
|
|
2221
|
-
return position ? {
|
|
2222
|
-
redos: [{
|
|
2223
|
-
id: SetRangeValuesMutation.id,
|
|
2224
|
-
params: {
|
|
2225
|
-
unitId,
|
|
2226
|
-
subUnitId,
|
|
2227
|
-
cellValue: {
|
|
2228
|
-
[position.startRow]: {
|
|
2229
|
-
[position.startColumn]: {
|
|
2230
|
-
p: dataCopy
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
}],
|
|
2236
|
-
undos: [
|
|
2237
|
-
{
|
|
2238
|
-
id: SetRangeValuesMutation.id,
|
|
2239
|
-
params: {
|
|
2240
|
-
unitId,
|
|
2241
|
-
subUnitId,
|
|
2242
|
-
cellValue: {
|
|
2243
|
-
[row]: {
|
|
2244
|
-
[col]: {
|
|
2245
|
-
p: data
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
]
|
|
2252
|
-
} : {
|
|
2253
|
-
redos: [],
|
|
2254
|
-
undos: []
|
|
2255
|
-
};
|
|
2256
|
-
}, "handleRangeChange");
|
|
2208
|
+
const map2 = this._enusreMap(unitId, subUnitId);
|
|
2257
2209
|
if ((_b = (_a15 = p2.body) == null ? void 0 : _a15.customRanges) != null && _b.some((customRange) => {
|
|
2258
2210
|
var _a16;
|
|
2259
2211
|
return customRange.rangeType === CustomRangeType.HYPERLINK && this._isLegalRangeUrl(unitId, (_a16 = customRange.properties) == null ? void 0 : _a16.url);
|
|
@@ -2263,7 +2215,9 @@ let SheetsHyperLinkRichTextRefRangeController = (_a10 = class extends Disposable
|
|
|
2263
2215
|
var _a16;
|
|
2264
2216
|
if (customRange.rangeType === CustomRangeType.HYPERLINK) {
|
|
2265
2217
|
const payload = (_a16 = customRange.properties) == null ? void 0 : _a16.url, range = this._isLegalRangeUrl(unitId, payload);
|
|
2266
|
-
range && disposableCollection.add(this._refRangeService.
|
|
2218
|
+
range && disposableCollection.add(this._refRangeService.watchRange(unitId, subUnitId, range, (before, after) => {
|
|
2219
|
+
customRange.properties.url = `#gid=${subUnitId}&range=${after ? serializeRange(after) : ERROR_RANGE}`;
|
|
2220
|
+
}));
|
|
2267
2221
|
}
|
|
2268
2222
|
}), map2.setValue(row, col, disposableCollection);
|
|
2269
2223
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { MenuGroup, MenuItemType, MenuPosition, IMenuItem, IShortcutItem } from '@univerjs/ui';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
1
|
import { IAccessor } from '@univerjs/core';
|
|
2
|
+
import { IMenuItem, IShortcutItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
|
|
4
3
|
export declare const genZenEditorMenuId: (id: string) => string;
|
|
5
4
|
export declare const insertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
6
5
|
export declare const zenEditorInsertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
7
6
|
export declare const insertLinkMenuToolbarFactory: (accessor: IAccessor) => {
|
|
8
7
|
id: string;
|
|
9
|
-
hidden$: Observable<boolean>;
|
|
10
|
-
disabled$: Observable<boolean>;
|
|
8
|
+
hidden$: import('rxjs').Observable<boolean>;
|
|
9
|
+
disabled$: import('rxjs').Observable<boolean>;
|
|
11
10
|
tooltip: string;
|
|
12
11
|
positions: MenuPosition;
|
|
13
12
|
group: MenuGroup;
|
|
@@ -17,8 +16,8 @@ export declare const insertLinkMenuToolbarFactory: (accessor: IAccessor) => {
|
|
|
17
16
|
};
|
|
18
17
|
export declare const zenEditorInsertLinkMenuToolbarFactory: (accessor: IAccessor) => {
|
|
19
18
|
id: string;
|
|
20
|
-
hidden$: Observable<boolean>;
|
|
21
|
-
disabled$: Observable<boolean>;
|
|
19
|
+
hidden$: import('rxjs').Observable<boolean>;
|
|
20
|
+
disabled$: import('rxjs').Observable<boolean>;
|
|
22
21
|
tooltip: string;
|
|
23
22
|
positions: MenuPosition;
|
|
24
23
|
group: MenuGroup;
|