@univerjs/sheets-hyper-link-ui 1.0.0-alpha.8 → 1.0.0-beta.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 +26 -30
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +27 -31
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/index.js +27 -31
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
|
@@ -315,7 +315,6 @@ function resolveRangePayload(rangeText, defaultSheetName) {
|
|
|
315
315
|
//#endregion
|
|
316
316
|
//#region src/views/CellLinkEdit.tsx
|
|
317
317
|
const CellLinkEdit = () => {
|
|
318
|
-
var _definedNameService$g;
|
|
319
318
|
const [id, setId] = (0, react.useState)("");
|
|
320
319
|
const [hide, setHide] = (0, react.useState)(false);
|
|
321
320
|
const [display, _setDisplay] = (0, react.useState)("");
|
|
@@ -363,16 +362,16 @@ const CellLinkEdit = () => {
|
|
|
363
362
|
if (typeof label === "number") label = `${label}`;
|
|
364
363
|
let link;
|
|
365
364
|
if (customRange) {
|
|
366
|
-
var _customRange$
|
|
365
|
+
var _customRange$properti;
|
|
367
366
|
link = {
|
|
368
|
-
id: (
|
|
369
|
-
display:
|
|
370
|
-
payload: (
|
|
367
|
+
id: (customRange === null || customRange === void 0 ? void 0 : customRange.rangeId) ?? "",
|
|
368
|
+
display: label ?? "",
|
|
369
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) ?? "",
|
|
371
370
|
row,
|
|
372
371
|
column: col
|
|
373
372
|
};
|
|
374
373
|
} else if (editing.type === "viewing") {
|
|
375
|
-
var _cell$p, _cell$p2, _range$
|
|
374
|
+
var _cell$p, _cell$p2, _range$properties2;
|
|
376
375
|
const workbook = univerInstanceService.getUnit(editing.unitId);
|
|
377
376
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(editing.subUnitId);
|
|
378
377
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(editing.row, editing.col);
|
|
@@ -385,22 +384,22 @@ const CellLinkEdit = () => {
|
|
|
385
384
|
link = {
|
|
386
385
|
id: "",
|
|
387
386
|
display: "",
|
|
388
|
-
payload: (
|
|
387
|
+
payload: (range === null || range === void 0 || (_range$properties2 = range.properties) === null || _range$properties2 === void 0 ? void 0 : _range$properties2.url) ?? "",
|
|
389
388
|
row,
|
|
390
389
|
column: col
|
|
391
390
|
};
|
|
392
391
|
} else {
|
|
393
|
-
var _BuildTextUtils$custo,
|
|
392
|
+
var _BuildTextUtils$custo, _customRange$properti2;
|
|
394
393
|
const doc = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
395
394
|
const currentSelection = textSelectionService.getActiveTextRange();
|
|
396
395
|
const body = doc === null || doc === void 0 ? void 0 : doc.getBody();
|
|
397
396
|
const selection = currentSelection && body ? currentSelection : null;
|
|
398
|
-
const customRange = selection && ((_BuildTextUtils$custo = _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (
|
|
397
|
+
const customRange = selection && ((_BuildTextUtils$custo = _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (body === null || body === void 0 ? void 0 : body.customRanges) ?? [])) === null || _BuildTextUtils$custo === void 0 ? void 0 : _BuildTextUtils$custo[0]);
|
|
399
398
|
setShowLabel(false);
|
|
400
399
|
link = {
|
|
401
400
|
id: "",
|
|
402
|
-
display:
|
|
403
|
-
payload: (
|
|
401
|
+
display: label ?? "",
|
|
402
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti2 = customRange.properties) === null || _customRange$properti2 === void 0 ? void 0 : _customRange$properti2.url) ?? "",
|
|
404
403
|
row,
|
|
405
404
|
column: col
|
|
406
405
|
};
|
|
@@ -423,9 +422,9 @@ const CellLinkEdit = () => {
|
|
|
423
422
|
if (linkInfo.url === link.display) setDisplaySyncedWithPayload(true);
|
|
424
423
|
break;
|
|
425
424
|
case _univerjs_sheets_hyper_link.SheetHyperLinkType.RANGE: {
|
|
426
|
-
var _univerInstanceServic
|
|
425
|
+
var _univerInstanceServic;
|
|
427
426
|
const params = linkInfo.searchObj;
|
|
428
|
-
const payload = (0, _univerjs_engine_formula.serializeRangeWithSheet)(params.gid ? (_univerInstanceServic =
|
|
427
|
+
const payload = (0, _univerjs_engine_formula.serializeRangeWithSheet)(params.gid ? ((_univerInstanceServic = univerInstanceService.getUnit(editing.unitId)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(params.gid)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "" : "", (0, _univerjs_engine_formula.deserializeRangeWithSheet)(params.range).range);
|
|
429
428
|
setPayload(payload);
|
|
430
429
|
if (payload === link.display) setDisplaySyncedWithPayload(true);
|
|
431
430
|
break;
|
|
@@ -460,7 +459,7 @@ const CellLinkEdit = () => {
|
|
|
460
459
|
const mergeInfo = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(editing.row, editing.col);
|
|
461
460
|
const color = new _univerjs_core.ColorKit(themeService.getColorFromTheme("primary.600")).toRgb();
|
|
462
461
|
id = markSelectionService.addShape({
|
|
463
|
-
range: mergeInfo
|
|
462
|
+
range: mergeInfo ?? {
|
|
464
463
|
startColumn: editing.col,
|
|
465
464
|
endColumn: editing.col,
|
|
466
465
|
startRow: editing.row,
|
|
@@ -559,7 +558,7 @@ const CellLinkEdit = () => {
|
|
|
559
558
|
label: sheet.getName(),
|
|
560
559
|
value: sheet.getSheetId()
|
|
561
560
|
})).filter((opt) => hiddens.indexOf(opt.value) === -1);
|
|
562
|
-
const definedNames = Object.values(
|
|
561
|
+
const definedNames = Object.values(definedNameService.getDefinedNameMap(workbook.getUnitId()) ?? {}).map((value) => ({
|
|
563
562
|
label: value.name,
|
|
564
563
|
value: value.id
|
|
565
564
|
}));
|
|
@@ -785,7 +784,7 @@ const iconsMap = {
|
|
|
785
784
|
[_univerjs_sheets_hyper_link.SheetHyperLinkType.INVALID]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AllBorderIcon, {})
|
|
786
785
|
};
|
|
787
786
|
const CellLinkPopupPure = (props) => {
|
|
788
|
-
var _customRange$properti
|
|
787
|
+
var _customRange$properti;
|
|
789
788
|
const popupService = (0, _univerjs_ui.useDependency)(SheetsHyperLinkPopupService);
|
|
790
789
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
791
790
|
const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
|
|
@@ -795,7 +794,7 @@ const CellLinkPopupPure = (props) => {
|
|
|
795
794
|
const parserHyperLinkService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_hyper_link.SheetsHyperLinkParserService);
|
|
796
795
|
const { customRange, row, col, unitId, subUnitId, editPermission, copyPermission, type } = props;
|
|
797
796
|
if (!(customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url)) return null;
|
|
798
|
-
const linkObj = parserHyperLinkService.parseHyperLink(
|
|
797
|
+
const linkObj = parserHyperLinkService.parseHyperLink(customRange.properties.url ?? "");
|
|
799
798
|
const isError = linkObj.type === _univerjs_sheets_hyper_link.SheetHyperLinkType.INVALID;
|
|
800
799
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
801
800
|
className: (0, _univerjs_design.clsx)("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-gap-2 univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-2 univer-shadow-md dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
|
|
@@ -1007,7 +1006,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1007
1006
|
const visible = this._editorBridgeService.isVisible().visible;
|
|
1008
1007
|
const state = this._editorBridgeService.getEditCellState();
|
|
1009
1008
|
if (visible && state) {
|
|
1010
|
-
var _state$documentLayout, _body$customRanges
|
|
1009
|
+
var _state$documentLayout, _body$customRanges;
|
|
1011
1010
|
const textRange = this._textSelectionManagerService.getActiveTextRange();
|
|
1012
1011
|
const body = (_state$documentLayout = state.documentLayoutObject.documentModel) === null || _state$documentLayout === void 0 ? void 0 : _state$documentLayout.getBody();
|
|
1013
1012
|
if (!body) return null;
|
|
@@ -1017,7 +1016,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1017
1016
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1018
1017
|
label: _univerjs_core.BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1019
1018
|
};
|
|
1020
|
-
const links = _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (
|
|
1019
|
+
const links = _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.filter((i) => i.rangeType === _univerjs_core.CustomRangeType.HYPERLINK)) ?? []);
|
|
1021
1020
|
let start = textRange.startOffset;
|
|
1022
1021
|
let end = textRange.endOffset;
|
|
1023
1022
|
links.forEach((link) => {
|
|
@@ -1049,7 +1048,6 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1049
1048
|
startAddEditing(link) {
|
|
1050
1049
|
const { unitId, subUnitId, type } = link;
|
|
1051
1050
|
if (type === "editing") {
|
|
1052
|
-
var _range$label;
|
|
1053
1051
|
const range = this._getEditingRange();
|
|
1054
1052
|
if (!range) return;
|
|
1055
1053
|
this._textSelectionManagerService.replaceDocRanges([{ ...range }], {
|
|
@@ -1063,17 +1061,17 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends _uni
|
|
|
1063
1061
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(rects.pop(), this._editPopup, unitId, subUnitId);
|
|
1064
1062
|
this._currentEditing$.next({
|
|
1065
1063
|
...link,
|
|
1066
|
-
label: (
|
|
1064
|
+
label: (range === null || range === void 0 ? void 0 : range.label) ?? ""
|
|
1067
1065
|
});
|
|
1068
1066
|
} else {
|
|
1069
|
-
var _cell$p$body
|
|
1067
|
+
var _cell$p$body;
|
|
1070
1068
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(link.row, link.col, this._editPopup, unitId, subUnitId);
|
|
1071
1069
|
const workbook = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
1072
1070
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
1073
1071
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(link.row, link.col);
|
|
1074
1072
|
this._currentEditing$.next({
|
|
1075
1073
|
...link,
|
|
1076
|
-
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? _univerjs_core.BuildTextUtils.transform.getPlainText((
|
|
1074
|
+
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? _univerjs_core.BuildTextUtils.transform.getPlainText(((_cell$p$body = cell.p.body) === null || _cell$p$body === void 0 ? void 0 : _cell$p$body.dataStream) ?? "") : ((cell === null || cell === void 0 ? void 0 : cell.v) ?? "").toString()
|
|
1077
1075
|
});
|
|
1078
1076
|
}
|
|
1079
1077
|
}
|
|
@@ -1346,9 +1344,8 @@ let SheetsHyperLinkCopyPasteController = class SheetsHyperLinkCopyPasteControlle
|
|
|
1346
1344
|
const { rows, cols } = discreteRange;
|
|
1347
1345
|
rows.forEach((row, rowIndex) => {
|
|
1348
1346
|
cols.forEach((col, colIndex) => {
|
|
1349
|
-
var _link$id;
|
|
1350
1347
|
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1351
|
-
matrix.setValue(rowIndex, colIndex, (
|
|
1348
|
+
matrix.setValue(rowIndex, colIndex, (link === null || link === void 0 ? void 0 : link.id) ?? "");
|
|
1352
1349
|
});
|
|
1353
1350
|
});
|
|
1354
1351
|
}
|
|
@@ -1461,10 +1458,9 @@ const getEditingLinkDisable$ = (accessor, unitId = _univerjs_core.DOCS_NORMAL_ED
|
|
|
1461
1458
|
}));
|
|
1462
1459
|
};
|
|
1463
1460
|
const getLinkDisable$ = (accessor) => {
|
|
1464
|
-
var _editorBridgeService$;
|
|
1465
1461
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1466
1462
|
const editorBridgeService = accessor.has(_univerjs_sheets_ui.IEditorBridgeService) ? accessor.get(_univerjs_sheets_ui.IEditorBridgeService) : null;
|
|
1467
|
-
return ((
|
|
1463
|
+
return ((editorBridgeService === null || editorBridgeService === void 0 ? void 0 : editorBridgeService.currentEditCellState$.pipe((0, rxjs.map)((state) => {
|
|
1468
1464
|
if (!state) return 1;
|
|
1469
1465
|
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, {
|
|
1470
1466
|
unitId: state.unitId,
|
|
@@ -1477,7 +1473,7 @@ const getLinkDisable$ = (accessor) => {
|
|
|
1477
1473
|
return (0, rxjs.combineLatest)([editorBridgeService ? editorBridgeService.visible$ : (0, rxjs.of)(null), univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC)]).pipe((0, rxjs.switchMap)(([editing, focusingDoc]) => {
|
|
1478
1474
|
return (editing === null || editing === void 0 ? void 0 : editing.visible) ? (focusingDoc === null || focusingDoc === void 0 ? void 0 : focusingDoc.getUnitId()) === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? (0, rxjs.of)(true) : getEditingLinkDisable$(accessor, _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) : (0, rxjs.of)(disableCell !== 0);
|
|
1479
1475
|
}));
|
|
1480
|
-
})))
|
|
1476
|
+
}))) ?? (0, rxjs.of)(true)).pipe((0, rxjs.switchMap)((disableCell) => {
|
|
1481
1477
|
if (disableCell) return (0, rxjs.of)(true);
|
|
1482
1478
|
else return (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
|
|
1483
1479
|
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
@@ -1543,7 +1539,7 @@ const menuSchema = {
|
|
|
1543
1539
|
//#endregion
|
|
1544
1540
|
//#region package.json
|
|
1545
1541
|
var name = "@univerjs/sheets-hyper-link-ui";
|
|
1546
|
-
var version = "1.0.0-
|
|
1542
|
+
var version = "1.0.0-beta.0";
|
|
1547
1543
|
|
|
1548
1544
|
//#endregion
|
|
1549
1545
|
//#region src/controllers/auto-fill.controller.ts
|
|
@@ -2081,7 +2077,7 @@ _defineProperty(UniverSheetsHyperLinkUIPlugin, "packageName", name);
|
|
|
2081
2077
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "version", version);
|
|
2082
2078
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2083
2079
|
UniverSheetsHyperLinkUIPlugin = __decorate([
|
|
2084
|
-
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin,
|
|
2080
|
+
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_sheets_hyper_link.UniverSheetsHyperLinkPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
|
|
2085
2081
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2086
2082
|
__decorateParam(2, _univerjs_core.IConfigService)
|
|
2087
2083
|
], UniverSheetsHyperLinkUIPlugin);
|
package/lib/cjs/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Button, FormLayout, Input, MessageType, Select, Tooltip, borderClassNam
|
|
|
9
9
|
import { IDefinedNamesService, UniverFormulaEnginePlugin, deserializeRangeWithSheet, serializeRange, serializeRangeToRefString, serializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
10
10
|
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
11
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,
|
|
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, SheetsMultiIcon, UnlinkIcon, WriteIcon } from "@univerjs/icons";
|
|
@@ -314,7 +314,6 @@ function resolveRangePayload(rangeText, defaultSheetName) {
|
|
|
314
314
|
//#endregion
|
|
315
315
|
//#region src/views/CellLinkEdit.tsx
|
|
316
316
|
const CellLinkEdit = () => {
|
|
317
|
-
var _definedNameService$g;
|
|
318
317
|
const [id, setId] = useState("");
|
|
319
318
|
const [hide, setHide] = useState(false);
|
|
320
319
|
const [display, _setDisplay] = useState("");
|
|
@@ -362,16 +361,16 @@ const CellLinkEdit = () => {
|
|
|
362
361
|
if (typeof label === "number") label = `${label}`;
|
|
363
362
|
let link;
|
|
364
363
|
if (customRange) {
|
|
365
|
-
var _customRange$
|
|
364
|
+
var _customRange$properti;
|
|
366
365
|
link = {
|
|
367
|
-
id: (
|
|
368
|
-
display:
|
|
369
|
-
payload: (
|
|
366
|
+
id: (customRange === null || customRange === void 0 ? void 0 : customRange.rangeId) ?? "",
|
|
367
|
+
display: label ?? "",
|
|
368
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) ?? "",
|
|
370
369
|
row,
|
|
371
370
|
column: col
|
|
372
371
|
};
|
|
373
372
|
} else if (editing.type === "viewing") {
|
|
374
|
-
var _cell$p, _cell$p2, _range$
|
|
373
|
+
var _cell$p, _cell$p2, _range$properties2;
|
|
375
374
|
const workbook = univerInstanceService.getUnit(editing.unitId);
|
|
376
375
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(editing.subUnitId);
|
|
377
376
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(editing.row, editing.col);
|
|
@@ -384,22 +383,22 @@ const CellLinkEdit = () => {
|
|
|
384
383
|
link = {
|
|
385
384
|
id: "",
|
|
386
385
|
display: "",
|
|
387
|
-
payload: (
|
|
386
|
+
payload: (range === null || range === void 0 || (_range$properties2 = range.properties) === null || _range$properties2 === void 0 ? void 0 : _range$properties2.url) ?? "",
|
|
388
387
|
row,
|
|
389
388
|
column: col
|
|
390
389
|
};
|
|
391
390
|
} else {
|
|
392
|
-
var _BuildTextUtils$custo,
|
|
391
|
+
var _BuildTextUtils$custo, _customRange$properti2;
|
|
393
392
|
const doc = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
394
393
|
const currentSelection = textSelectionService.getActiveTextRange();
|
|
395
394
|
const body = doc === null || doc === void 0 ? void 0 : doc.getBody();
|
|
396
395
|
const selection = currentSelection && body ? currentSelection : null;
|
|
397
|
-
const customRange = selection && ((_BuildTextUtils$custo = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (
|
|
396
|
+
const customRange = selection && ((_BuildTextUtils$custo = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (body === null || body === void 0 ? void 0 : body.customRanges) ?? [])) === null || _BuildTextUtils$custo === void 0 ? void 0 : _BuildTextUtils$custo[0]);
|
|
398
397
|
setShowLabel(false);
|
|
399
398
|
link = {
|
|
400
399
|
id: "",
|
|
401
|
-
display:
|
|
402
|
-
payload: (
|
|
400
|
+
display: label ?? "",
|
|
401
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti2 = customRange.properties) === null || _customRange$properti2 === void 0 ? void 0 : _customRange$properti2.url) ?? "",
|
|
403
402
|
row,
|
|
404
403
|
column: col
|
|
405
404
|
};
|
|
@@ -422,9 +421,9 @@ const CellLinkEdit = () => {
|
|
|
422
421
|
if (linkInfo.url === link.display) setDisplaySyncedWithPayload(true);
|
|
423
422
|
break;
|
|
424
423
|
case SheetHyperLinkType.RANGE: {
|
|
425
|
-
var _univerInstanceServic
|
|
424
|
+
var _univerInstanceServic;
|
|
426
425
|
const params = linkInfo.searchObj;
|
|
427
|
-
const payload = serializeRangeWithSheet(params.gid ? (_univerInstanceServic =
|
|
426
|
+
const payload = serializeRangeWithSheet(params.gid ? ((_univerInstanceServic = univerInstanceService.getUnit(editing.unitId)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(params.gid)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "" : "", deserializeRangeWithSheet(params.range).range);
|
|
428
427
|
setPayload(payload);
|
|
429
428
|
if (payload === link.display) setDisplaySyncedWithPayload(true);
|
|
430
429
|
break;
|
|
@@ -459,7 +458,7 @@ const CellLinkEdit = () => {
|
|
|
459
458
|
const mergeInfo = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(editing.row, editing.col);
|
|
460
459
|
const color = new ColorKit(themeService.getColorFromTheme("primary.600")).toRgb();
|
|
461
460
|
id = markSelectionService.addShape({
|
|
462
|
-
range: mergeInfo
|
|
461
|
+
range: mergeInfo ?? {
|
|
463
462
|
startColumn: editing.col,
|
|
464
463
|
endColumn: editing.col,
|
|
465
464
|
startRow: editing.row,
|
|
@@ -558,7 +557,7 @@ const CellLinkEdit = () => {
|
|
|
558
557
|
label: sheet.getName(),
|
|
559
558
|
value: sheet.getSheetId()
|
|
560
559
|
})).filter((opt) => hiddens.indexOf(opt.value) === -1);
|
|
561
|
-
const definedNames = Object.values(
|
|
560
|
+
const definedNames = Object.values(definedNameService.getDefinedNameMap(workbook.getUnitId()) ?? {}).map((value) => ({
|
|
562
561
|
label: value.name,
|
|
563
562
|
value: value.id
|
|
564
563
|
}));
|
|
@@ -784,7 +783,7 @@ const iconsMap = {
|
|
|
784
783
|
[SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsx(AllBorderIcon, {})
|
|
785
784
|
};
|
|
786
785
|
const CellLinkPopupPure = (props) => {
|
|
787
|
-
var _customRange$properti
|
|
786
|
+
var _customRange$properti;
|
|
788
787
|
const popupService = useDependency(SheetsHyperLinkPopupService);
|
|
789
788
|
const commandService = useDependency(ICommandService);
|
|
790
789
|
const messageService = useDependency(IMessageService);
|
|
@@ -794,7 +793,7 @@ const CellLinkPopupPure = (props) => {
|
|
|
794
793
|
const parserHyperLinkService = useDependency(SheetsHyperLinkParserService);
|
|
795
794
|
const { customRange, row, col, unitId, subUnitId, editPermission, copyPermission, type } = props;
|
|
796
795
|
if (!(customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url)) return null;
|
|
797
|
-
const linkObj = parserHyperLinkService.parseHyperLink(
|
|
796
|
+
const linkObj = parserHyperLinkService.parseHyperLink(customRange.properties.url ?? "");
|
|
798
797
|
const isError = linkObj.type === SheetHyperLinkType.INVALID;
|
|
799
798
|
return /* @__PURE__ */ jsxs("div", {
|
|
800
799
|
className: clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-gap-2 univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-2 univer-shadow-md dark:!univer-bg-gray-900", borderClassName),
|
|
@@ -1006,7 +1005,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1006
1005
|
const visible = this._editorBridgeService.isVisible().visible;
|
|
1007
1006
|
const state = this._editorBridgeService.getEditCellState();
|
|
1008
1007
|
if (visible && state) {
|
|
1009
|
-
var _state$documentLayout, _body$customRanges
|
|
1008
|
+
var _state$documentLayout, _body$customRanges;
|
|
1010
1009
|
const textRange = this._textSelectionManagerService.getActiveTextRange();
|
|
1011
1010
|
const body = (_state$documentLayout = state.documentLayoutObject.documentModel) === null || _state$documentLayout === void 0 ? void 0 : _state$documentLayout.getBody();
|
|
1012
1011
|
if (!body) return null;
|
|
@@ -1016,7 +1015,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1016
1015
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1017
1016
|
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1018
1017
|
};
|
|
1019
|
-
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (
|
|
1018
|
+
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) ?? []);
|
|
1020
1019
|
let start = textRange.startOffset;
|
|
1021
1020
|
let end = textRange.endOffset;
|
|
1022
1021
|
links.forEach((link) => {
|
|
@@ -1048,7 +1047,6 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1048
1047
|
startAddEditing(link) {
|
|
1049
1048
|
const { unitId, subUnitId, type } = link;
|
|
1050
1049
|
if (type === "editing") {
|
|
1051
|
-
var _range$label;
|
|
1052
1050
|
const range = this._getEditingRange();
|
|
1053
1051
|
if (!range) return;
|
|
1054
1052
|
this._textSelectionManagerService.replaceDocRanges([{ ...range }], {
|
|
@@ -1062,17 +1060,17 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1062
1060
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(rects.pop(), this._editPopup, unitId, subUnitId);
|
|
1063
1061
|
this._currentEditing$.next({
|
|
1064
1062
|
...link,
|
|
1065
|
-
label: (
|
|
1063
|
+
label: (range === null || range === void 0 ? void 0 : range.label) ?? ""
|
|
1066
1064
|
});
|
|
1067
1065
|
} else {
|
|
1068
|
-
var _cell$p$body
|
|
1066
|
+
var _cell$p$body;
|
|
1069
1067
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(link.row, link.col, this._editPopup, unitId, subUnitId);
|
|
1070
1068
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1071
1069
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
1072
1070
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(link.row, link.col);
|
|
1073
1071
|
this._currentEditing$.next({
|
|
1074
1072
|
...link,
|
|
1075
|
-
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? BuildTextUtils.transform.getPlainText((
|
|
1073
|
+
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? BuildTextUtils.transform.getPlainText(((_cell$p$body = cell.p.body) === null || _cell$p$body === void 0 ? void 0 : _cell$p$body.dataStream) ?? "") : ((cell === null || cell === void 0 ? void 0 : cell.v) ?? "").toString()
|
|
1076
1074
|
});
|
|
1077
1075
|
}
|
|
1078
1076
|
}
|
|
@@ -1345,9 +1343,8 @@ let SheetsHyperLinkCopyPasteController = class SheetsHyperLinkCopyPasteControlle
|
|
|
1345
1343
|
const { rows, cols } = discreteRange;
|
|
1346
1344
|
rows.forEach((row, rowIndex) => {
|
|
1347
1345
|
cols.forEach((col, colIndex) => {
|
|
1348
|
-
var _link$id;
|
|
1349
1346
|
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1350
|
-
matrix.setValue(rowIndex, colIndex, (
|
|
1347
|
+
matrix.setValue(rowIndex, colIndex, (link === null || link === void 0 ? void 0 : link.id) ?? "");
|
|
1351
1348
|
});
|
|
1352
1349
|
});
|
|
1353
1350
|
}
|
|
@@ -1460,10 +1457,9 @@ const getEditingLinkDisable$ = (accessor, unitId = DOCS_NORMAL_EDITOR_UNIT_ID_KE
|
|
|
1460
1457
|
}));
|
|
1461
1458
|
};
|
|
1462
1459
|
const getLinkDisable$ = (accessor) => {
|
|
1463
|
-
var _editorBridgeService$;
|
|
1464
1460
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1465
1461
|
const editorBridgeService = accessor.has(IEditorBridgeService) ? accessor.get(IEditorBridgeService) : null;
|
|
1466
|
-
return ((
|
|
1462
|
+
return ((editorBridgeService === null || editorBridgeService === void 0 ? void 0 : editorBridgeService.currentEditCellState$.pipe(map((state) => {
|
|
1467
1463
|
if (!state) return 1;
|
|
1468
1464
|
const target = getSheetCommandTarget(univerInstanceService, {
|
|
1469
1465
|
unitId: state.unitId,
|
|
@@ -1476,7 +1472,7 @@ const getLinkDisable$ = (accessor) => {
|
|
|
1476
1472
|
return combineLatest([editorBridgeService ? editorBridgeService.visible$ : of(null), univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC)]).pipe(switchMap(([editing, focusingDoc]) => {
|
|
1477
1473
|
return (editing === null || editing === void 0 ? void 0 : editing.visible) ? (focusingDoc === null || focusingDoc === void 0 ? void 0 : focusingDoc.getUnitId()) === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? of(true) : getEditingLinkDisable$(accessor, DOCS_NORMAL_EDITOR_UNIT_ID_KEY) : of(disableCell !== 0);
|
|
1478
1474
|
}));
|
|
1479
|
-
})))
|
|
1475
|
+
}))) ?? of(true)).pipe(switchMap((disableCell) => {
|
|
1480
1476
|
if (disableCell) return of(true);
|
|
1481
1477
|
else return getCurrentRangeDisable$(accessor, {
|
|
1482
1478
|
workbookTypes: [WorkbookEditablePermission],
|
|
@@ -1542,7 +1538,7 @@ const menuSchema = {
|
|
|
1542
1538
|
//#endregion
|
|
1543
1539
|
//#region package.json
|
|
1544
1540
|
var name = "@univerjs/sheets-hyper-link-ui";
|
|
1545
|
-
var version = "1.0.0-
|
|
1541
|
+
var version = "1.0.0-beta.0";
|
|
1546
1542
|
|
|
1547
1543
|
//#endregion
|
|
1548
1544
|
//#region src/controllers/auto-fill.controller.ts
|
|
@@ -2080,7 +2076,7 @@ _defineProperty(UniverSheetsHyperLinkUIPlugin, "packageName", name);
|
|
|
2080
2076
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "version", version);
|
|
2081
2077
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
2082
2078
|
UniverSheetsHyperLinkUIPlugin = __decorate([
|
|
2083
|
-
DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin,
|
|
2079
|
+
DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverDocsUIPlugin, UniverSheetsHyperLinkPlugin, UniverSheetsUIPlugin),
|
|
2084
2080
|
__decorateParam(1, Inject(Injector)),
|
|
2085
2081
|
__decorateParam(2, IConfigService)
|
|
2086
2082
|
], UniverSheetsHyperLinkUIPlugin);
|
package/lib/es/locale/zh-HK.js
CHANGED
package/lib/es/locale/zh-TW.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Button, FormLayout, Input, MessageType, Select, Tooltip, borderClassNam
|
|
|
9
9
|
import { IDefinedNamesService, UniverFormulaEnginePlugin, deserializeRangeWithSheet, serializeRange, serializeRangeToRefString, serializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
10
10
|
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
11
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,
|
|
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, SheetsMultiIcon, UnlinkIcon, WriteIcon } from "@univerjs/icons";
|
|
@@ -314,7 +314,6 @@ function resolveRangePayload(rangeText, defaultSheetName) {
|
|
|
314
314
|
//#endregion
|
|
315
315
|
//#region src/views/CellLinkEdit.tsx
|
|
316
316
|
const CellLinkEdit = () => {
|
|
317
|
-
var _definedNameService$g;
|
|
318
317
|
const [id, setId] = useState("");
|
|
319
318
|
const [hide, setHide] = useState(false);
|
|
320
319
|
const [display, _setDisplay] = useState("");
|
|
@@ -362,16 +361,16 @@ const CellLinkEdit = () => {
|
|
|
362
361
|
if (typeof label === "number") label = `${label}`;
|
|
363
362
|
let link;
|
|
364
363
|
if (customRange) {
|
|
365
|
-
var _customRange$
|
|
364
|
+
var _customRange$properti;
|
|
366
365
|
link = {
|
|
367
|
-
id: (
|
|
368
|
-
display:
|
|
369
|
-
payload: (
|
|
366
|
+
id: (customRange === null || customRange === void 0 ? void 0 : customRange.rangeId) ?? "",
|
|
367
|
+
display: label ?? "",
|
|
368
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url) ?? "",
|
|
370
369
|
row,
|
|
371
370
|
column: col
|
|
372
371
|
};
|
|
373
372
|
} else if (editing.type === "viewing") {
|
|
374
|
-
var _cell$p, _cell$p2, _range$
|
|
373
|
+
var _cell$p, _cell$p2, _range$properties2;
|
|
375
374
|
const workbook = univerInstanceService.getUnit(editing.unitId);
|
|
376
375
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(editing.subUnitId);
|
|
377
376
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(editing.row, editing.col);
|
|
@@ -384,22 +383,22 @@ const CellLinkEdit = () => {
|
|
|
384
383
|
link = {
|
|
385
384
|
id: "",
|
|
386
385
|
display: "",
|
|
387
|
-
payload: (
|
|
386
|
+
payload: (range === null || range === void 0 || (_range$properties2 = range.properties) === null || _range$properties2 === void 0 ? void 0 : _range$properties2.url) ?? "",
|
|
388
387
|
row,
|
|
389
388
|
column: col
|
|
390
389
|
};
|
|
391
390
|
} else {
|
|
392
|
-
var _BuildTextUtils$custo,
|
|
391
|
+
var _BuildTextUtils$custo, _customRange$properti2;
|
|
393
392
|
const doc = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
394
393
|
const currentSelection = textSelectionService.getActiveTextRange();
|
|
395
394
|
const body = doc === null || doc === void 0 ? void 0 : doc.getBody();
|
|
396
395
|
const selection = currentSelection && body ? currentSelection : null;
|
|
397
|
-
const customRange = selection && ((_BuildTextUtils$custo = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (
|
|
396
|
+
const customRange = selection && ((_BuildTextUtils$custo = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (body === null || body === void 0 ? void 0 : body.customRanges) ?? [])) === null || _BuildTextUtils$custo === void 0 ? void 0 : _BuildTextUtils$custo[0]);
|
|
398
397
|
setShowLabel(false);
|
|
399
398
|
link = {
|
|
400
399
|
id: "",
|
|
401
|
-
display:
|
|
402
|
-
payload: (
|
|
400
|
+
display: label ?? "",
|
|
401
|
+
payload: (customRange === null || customRange === void 0 || (_customRange$properti2 = customRange.properties) === null || _customRange$properti2 === void 0 ? void 0 : _customRange$properti2.url) ?? "",
|
|
403
402
|
row,
|
|
404
403
|
column: col
|
|
405
404
|
};
|
|
@@ -422,9 +421,9 @@ const CellLinkEdit = () => {
|
|
|
422
421
|
if (linkInfo.url === link.display) setDisplaySyncedWithPayload(true);
|
|
423
422
|
break;
|
|
424
423
|
case SheetHyperLinkType.RANGE: {
|
|
425
|
-
var _univerInstanceServic
|
|
424
|
+
var _univerInstanceServic;
|
|
426
425
|
const params = linkInfo.searchObj;
|
|
427
|
-
const payload = serializeRangeWithSheet(params.gid ? (_univerInstanceServic =
|
|
426
|
+
const payload = serializeRangeWithSheet(params.gid ? ((_univerInstanceServic = univerInstanceService.getUnit(editing.unitId)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(params.gid)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "" : "", deserializeRangeWithSheet(params.range).range);
|
|
428
427
|
setPayload(payload);
|
|
429
428
|
if (payload === link.display) setDisplaySyncedWithPayload(true);
|
|
430
429
|
break;
|
|
@@ -459,7 +458,7 @@ const CellLinkEdit = () => {
|
|
|
459
458
|
const mergeInfo = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(editing.row, editing.col);
|
|
460
459
|
const color = new ColorKit(themeService.getColorFromTheme("primary.600")).toRgb();
|
|
461
460
|
id = markSelectionService.addShape({
|
|
462
|
-
range: mergeInfo
|
|
461
|
+
range: mergeInfo ?? {
|
|
463
462
|
startColumn: editing.col,
|
|
464
463
|
endColumn: editing.col,
|
|
465
464
|
startRow: editing.row,
|
|
@@ -558,7 +557,7 @@ const CellLinkEdit = () => {
|
|
|
558
557
|
label: sheet.getName(),
|
|
559
558
|
value: sheet.getSheetId()
|
|
560
559
|
})).filter((opt) => hiddens.indexOf(opt.value) === -1);
|
|
561
|
-
const definedNames = Object.values(
|
|
560
|
+
const definedNames = Object.values(definedNameService.getDefinedNameMap(workbook.getUnitId()) ?? {}).map((value) => ({
|
|
562
561
|
label: value.name,
|
|
563
562
|
value: value.id
|
|
564
563
|
}));
|
|
@@ -784,7 +783,7 @@ const iconsMap = {
|
|
|
784
783
|
[SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsx(AllBorderIcon, {})
|
|
785
784
|
};
|
|
786
785
|
const CellLinkPopupPure = (props) => {
|
|
787
|
-
var _customRange$properti
|
|
786
|
+
var _customRange$properti;
|
|
788
787
|
const popupService = useDependency(SheetsHyperLinkPopupService);
|
|
789
788
|
const commandService = useDependency(ICommandService);
|
|
790
789
|
const messageService = useDependency(IMessageService);
|
|
@@ -794,7 +793,7 @@ const CellLinkPopupPure = (props) => {
|
|
|
794
793
|
const parserHyperLinkService = useDependency(SheetsHyperLinkParserService);
|
|
795
794
|
const { customRange, row, col, unitId, subUnitId, editPermission, copyPermission, type } = props;
|
|
796
795
|
if (!(customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.url)) return null;
|
|
797
|
-
const linkObj = parserHyperLinkService.parseHyperLink(
|
|
796
|
+
const linkObj = parserHyperLinkService.parseHyperLink(customRange.properties.url ?? "");
|
|
798
797
|
const isError = linkObj.type === SheetHyperLinkType.INVALID;
|
|
799
798
|
return /* @__PURE__ */ jsxs("div", {
|
|
800
799
|
className: clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-gap-2 univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-2 univer-shadow-md dark:!univer-bg-gray-900", borderClassName),
|
|
@@ -1006,7 +1005,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1006
1005
|
const visible = this._editorBridgeService.isVisible().visible;
|
|
1007
1006
|
const state = this._editorBridgeService.getEditCellState();
|
|
1008
1007
|
if (visible && state) {
|
|
1009
|
-
var _state$documentLayout, _body$customRanges
|
|
1008
|
+
var _state$documentLayout, _body$customRanges;
|
|
1010
1009
|
const textRange = this._textSelectionManagerService.getActiveTextRange();
|
|
1011
1010
|
const body = (_state$documentLayout = state.documentLayoutObject.documentModel) === null || _state$documentLayout === void 0 ? void 0 : _state$documentLayout.getBody();
|
|
1012
1011
|
if (!body) return null;
|
|
@@ -1016,7 +1015,7 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1016
1015
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1017
1016
|
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1018
1017
|
};
|
|
1019
|
-
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (
|
|
1018
|
+
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) ?? []);
|
|
1020
1019
|
let start = textRange.startOffset;
|
|
1021
1020
|
let end = textRange.endOffset;
|
|
1022
1021
|
links.forEach((link) => {
|
|
@@ -1048,7 +1047,6 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1048
1047
|
startAddEditing(link) {
|
|
1049
1048
|
const { unitId, subUnitId, type } = link;
|
|
1050
1049
|
if (type === "editing") {
|
|
1051
|
-
var _range$label;
|
|
1052
1050
|
const range = this._getEditingRange();
|
|
1053
1051
|
if (!range) return;
|
|
1054
1052
|
this._textSelectionManagerService.replaceDocRanges([{ ...range }], {
|
|
@@ -1062,17 +1060,17 @@ let SheetsHyperLinkPopupService = class SheetsHyperLinkPopupService extends Disp
|
|
|
1062
1060
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(rects.pop(), this._editPopup, unitId, subUnitId);
|
|
1063
1061
|
this._currentEditing$.next({
|
|
1064
1062
|
...link,
|
|
1065
|
-
label: (
|
|
1063
|
+
label: (range === null || range === void 0 ? void 0 : range.label) ?? ""
|
|
1066
1064
|
});
|
|
1067
1065
|
} else {
|
|
1068
|
-
var _cell$p$body
|
|
1066
|
+
var _cell$p$body;
|
|
1069
1067
|
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(link.row, link.col, this._editPopup, unitId, subUnitId);
|
|
1070
1068
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1071
1069
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
1072
1070
|
const cell = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellRaw(link.row, link.col);
|
|
1073
1071
|
this._currentEditing$.next({
|
|
1074
1072
|
...link,
|
|
1075
|
-
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? BuildTextUtils.transform.getPlainText((
|
|
1073
|
+
label: (cell === null || cell === void 0 ? void 0 : cell.p) ? BuildTextUtils.transform.getPlainText(((_cell$p$body = cell.p.body) === null || _cell$p$body === void 0 ? void 0 : _cell$p$body.dataStream) ?? "") : ((cell === null || cell === void 0 ? void 0 : cell.v) ?? "").toString()
|
|
1076
1074
|
});
|
|
1077
1075
|
}
|
|
1078
1076
|
}
|
|
@@ -1345,9 +1343,8 @@ let SheetsHyperLinkCopyPasteController = class SheetsHyperLinkCopyPasteControlle
|
|
|
1345
1343
|
const { rows, cols } = discreteRange;
|
|
1346
1344
|
rows.forEach((row, rowIndex) => {
|
|
1347
1345
|
cols.forEach((col, colIndex) => {
|
|
1348
|
-
var _link$id;
|
|
1349
1346
|
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, col);
|
|
1350
|
-
matrix.setValue(rowIndex, colIndex, (
|
|
1347
|
+
matrix.setValue(rowIndex, colIndex, (link === null || link === void 0 ? void 0 : link.id) ?? "");
|
|
1351
1348
|
});
|
|
1352
1349
|
});
|
|
1353
1350
|
}
|
|
@@ -1460,10 +1457,9 @@ const getEditingLinkDisable$ = (accessor, unitId = DOCS_NORMAL_EDITOR_UNIT_ID_KE
|
|
|
1460
1457
|
}));
|
|
1461
1458
|
};
|
|
1462
1459
|
const getLinkDisable$ = (accessor) => {
|
|
1463
|
-
var _editorBridgeService$;
|
|
1464
1460
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1465
1461
|
const editorBridgeService = accessor.has(IEditorBridgeService) ? accessor.get(IEditorBridgeService) : null;
|
|
1466
|
-
return ((
|
|
1462
|
+
return ((editorBridgeService === null || editorBridgeService === void 0 ? void 0 : editorBridgeService.currentEditCellState$.pipe(map((state) => {
|
|
1467
1463
|
if (!state) return 1;
|
|
1468
1464
|
const target = getSheetCommandTarget(univerInstanceService, {
|
|
1469
1465
|
unitId: state.unitId,
|
|
@@ -1476,7 +1472,7 @@ const getLinkDisable$ = (accessor) => {
|
|
|
1476
1472
|
return combineLatest([editorBridgeService ? editorBridgeService.visible$ : of(null), univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC)]).pipe(switchMap(([editing, focusingDoc]) => {
|
|
1477
1473
|
return (editing === null || editing === void 0 ? void 0 : editing.visible) ? (focusingDoc === null || focusingDoc === void 0 ? void 0 : focusingDoc.getUnitId()) === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? of(true) : getEditingLinkDisable$(accessor, DOCS_NORMAL_EDITOR_UNIT_ID_KEY) : of(disableCell !== 0);
|
|
1478
1474
|
}));
|
|
1479
|
-
})))
|
|
1475
|
+
}))) ?? of(true)).pipe(switchMap((disableCell) => {
|
|
1480
1476
|
if (disableCell) return of(true);
|
|
1481
1477
|
else return getCurrentRangeDisable$(accessor, {
|
|
1482
1478
|
workbookTypes: [WorkbookEditablePermission],
|
|
@@ -1542,7 +1538,7 @@ const menuSchema = {
|
|
|
1542
1538
|
//#endregion
|
|
1543
1539
|
//#region package.json
|
|
1544
1540
|
var name = "@univerjs/sheets-hyper-link-ui";
|
|
1545
|
-
var version = "1.0.0-
|
|
1541
|
+
var version = "1.0.0-beta.0";
|
|
1546
1542
|
|
|
1547
1543
|
//#endregion
|
|
1548
1544
|
//#region src/controllers/auto-fill.controller.ts
|
|
@@ -2080,7 +2076,7 @@ _defineProperty(UniverSheetsHyperLinkUIPlugin, "packageName", name);
|
|
|
2080
2076
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "version", version);
|
|
2081
2077
|
_defineProperty(UniverSheetsHyperLinkUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
2082
2078
|
UniverSheetsHyperLinkUIPlugin = __decorate([
|
|
2083
|
-
DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin,
|
|
2079
|
+
DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverDocsUIPlugin, UniverSheetsHyperLinkPlugin, UniverSheetsUIPlugin),
|
|
2084
2080
|
__decorateParam(1, Inject(Injector)),
|
|
2085
2081
|
__decorateParam(2, IConfigService)
|
|
2086
2082
|
], UniverSheetsHyperLinkUIPlugin);
|
package/lib/locale/zh-HK.js
CHANGED
package/lib/locale/zh-TW.js
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-hyper-link"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/sheets-data-validation")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/engine-render`,`rxjs`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`@univerjs/sheets-hyper-link`,`@univerjs/ui`,`react`,`react/jsx-runtime`,`@univerjs/sheets-data-validation`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLinkUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsUi,e.UniverDocs,e.UniverDocsUi,e.UniverEngineRender,e.rxjs,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.UniverSheetsHyperLink,e.UniverUi,e.React,e.React,e.UniverSheetsDataValidation))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function g(e){return t.Tools.isLegalUrl(e)}function _(e){return/^[a-zA-Z]+:\/\//.test(e)}function v(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function y(e){if(g(e)){let t=_(e)?e:v(e)?`mailto://${e}`:`http://${e}`,n;try{n=new URL(t)}catch{return e}return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:t}return e}let b=`sheets-hyper-link-ui.config`,x={};function S(e,t){return function(n,r){t(n,r,e)}}function C(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function w(e,n){let r=n.getMergeData(),i=n.getMaxColumns()-1,a=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),a<e.endRow&&(e.endRow=a),e.rangeType===t.RANGE_TYPE.COLUMN||t.RANGE_TYPE.ROW)return e;let o=[];return r.forEach(n=>{t.Rectangle.intersects(e,n)&&o.push(n)}),t.Rectangle.realUnion(e,...o)}let T=class{constructor(e,t,n,r,i,a){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=i,this._configService=a}navigate(e){switch(e.type){case d.SheetHyperLinkType.URL:this.navigateToOtherWebsite(e.url);break;default:this._navigateToUniver(e.searchObj)}}_navigateToUniver(e){let{gid:n,range:r,rangeid:i}=e,a=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=a.getUnitId();if(i){let e=this._definedNamesService.getValueById(o,i);if(!e)return;let{formulaOrRefString:t}=e,n=this._definedNamesService.getWorksheetByRef(o,t);if(!n){this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.refError`),type:c.MessageType.Error});return}if(n.isSheetHidden()){this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.hiddenSheet`),type:c.MessageType.Error});return}this.navigateToDefineName(o,i)}if(n){if(r){let e=(0,l.deserializeRangeWithSheet)(r);(0,t.isValidRange)(e.range)&&r!==d.ERROR_RANGE&&this.navigateToRange(o,n,e.range);return}this.navigateToSheetById(o,n)}}async navigateToRange(e,t,i,a){let o=await this.navigateToSheetById(e,t);if(o){let s=w(i,o);await this._commandService.executeCommand(n.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:s,primary:null}]}),await this._commandService.executeCommand(r.ScrollToRangeOperation.id,{range:s,forceTop:a})}}async navigateToSheetById(e,r){let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;let a=i.getActiveSheet();if(!a)return!1;if(a.getSheetId()===r)return a;let o=i.getSheetBySheetId(r);return o?i.getHiddenWorksheets().indexOf(r)>-1?(this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.hiddenSheet`),type:c.MessageType.Error}),!1):await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r})?o:!1:(this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.noSheet`),type:c.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){var n;if(!(0,t.isSafeUrl)(e))return;let r=this._configService.getConfig(b);if(r!=null&&(n=r.urlHandler)!=null&&n.navigateToOtherWebsite)return r.urlHandler.navigateToOtherWebsite(e);window.open(e,`_blank`,`noopener noreferrer`)}};T=C([S(0,t.IUniverInstanceService),S(1,t.ICommandService),S(2,l.IDefinedNamesService),S(3,f.IMessageService),S(4,(0,t.Inject)(t.LocaleService)),S(5,t.IConfigService)],T);function E(e){"@babel/helpers - typeof";return E=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function k(e,t,n){return(t=O(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee=class extends t.Disposable{constructor(...e){super(...e),k(this,`_customHyperLinks`,new Map)}isBuiltInLinkType(e){return e!==d.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(t=>t.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){let{_customHyperLinks:t}=this;t.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}};function te(e){return e.trim().length===0}function ne(e,n){let[r]=e.split(`,`).map(l.deserializeRangeWithSheet);return!r||!(0,t.isValidRange)(r.range)?``:(r.sheetName||(r.sheetName=n),(0,l.serializeRangeToRefString)(r))}let A=()=>{var e;let[s,h]=(0,p.useState)(``),[_,v]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),[S,C]=(0,p.useState)(!0),[w,E]=(0,p.useState)(d.SheetHyperLinkType.URL),[D,O]=(0,p.useState)(``),k=(0,f.useDependency)(t.LocaleService),A=(0,f.useDependency)(l.IDefinedNamesService),j=(0,f.useDependency)(r.IEditorBridgeService),M=(0,f.useDependency)(t.IUniverInstanceService),N=(0,f.useDependency)(V),P=(0,f.useObservable)(N.currentEditing$),re=(0,f.useDependency)(d.SheetsHyperLinkParserService),ie=(0,f.useDependency)(T),F=(0,f.useDependency)(t.ICommandService),I=(0,f.useDependency)(ee),ae=(0,p.useMemo)(()=>I.getOptions(),[I]),oe=(0,f.useDependency)(o.IRenderManagerService),L=(0,f.useDependency)(r.IMarkSelectionService),se=(0,f.useDependency)(i.DocSelectionManagerService),ce=(0,f.useDependency)(t.ThemeService),[le,ue]=(0,p.useState)(!1),de=(0,f.useDependency)(n.SheetsSelectionsService),fe=(0,p.useMemo)(()=>de.getCurrentSelections(),[]),pe=(0,p.useMemo)(()=>{if(!I.isBuiltInLinkType(w))return I.getCustomHyperLink(w)},[I,w]),[R,z]=(0,p.useState)(!1),[B,me]=(0,p.useState)(!1),H=(0,p.useRef)(!1),U=(0,f.useEvent)(()=>H.current),W=(0,f.useEvent)(e=>{H.current=e}),G=M.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),q=(G==null?void 0:G.getActiveSheet().getSheetId())||``,J=(0,p.useCallback)(e=>{x(e.replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_START,``).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_END,``))},[x]);(0,p.useEffect)(()=>{if((P==null?void 0:P.row)!==void 0&&P.col!==void 0){let{customRange:y,row:b,col:x}=P,{label:S}=P;typeof S==`number`&&(S=`${S}`);let w;if(y){var e,n,r,i;w={id:(e=y==null?void 0:y.rangeId)==null?``:e,display:(n=S)==null?``:n,payload:(r=y==null||(i=y.properties)==null?void 0:i.url)==null?``:r,row:b,column:x}}else if(P.type===`viewing`){var a,o,s,c;let e=M.getUnit(P.unitId),n=e==null?void 0:e.getSheetBySheetId(P.subUnitId),r=n==null?void 0:n.getCellRaw(P.row,P.col),i=r==null||(a=r.p)==null||(a=a.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK&&((n=e.properties)==null?void 0:n.url)}),l=r==null?void 0:r.v;r&&(!t.BuildTextUtils.transform.isEmptyDocument((o=r.p)==null||(o=o.body)==null?void 0:o.dataStream)||t.Tools.isDefine(l))&&C(!1),w={id:``,display:``,payload:(s=i==null||(c=i.properties)==null?void 0:c.url)==null?``:s,row:b,column:x}}else{var u,f,p,m,g;let e=M.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),n=se.getActiveTextRange(),r=e==null?void 0:e.getBody(),i=n&&r?n:null,a=i&&((u=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(f=r==null?void 0:r.customRanges)==null?[]:f))==null?void 0:u[0]);C(!1),w={id:``,display:(p=S)==null?``:p,payload:(m=a==null||(g=a.properties)==null?void 0:g.url)==null?``:m,row:b,column:x}}h(w.id);let T=I.findCustomHyperLink(w);if(T){let e=T.convert(w);E(e.type),O(e.payload),J(e.display);return}J(w.display);let D=re.parseHyperLink(w.payload);switch(E(D.type===d.SheetHyperLinkType.INVALID?d.SheetHyperLinkType.RANGE:D.type),D.type){case d.SheetHyperLinkType.URL:O(D.url),D.url===w.display&&W(!0);break;case d.SheetHyperLinkType.RANGE:{var _,v;let e=D.searchObj,t=(0,l.serializeRangeWithSheet)(e.gid?(_=(v=M.getUnit(P.unitId))==null||(v=v.getSheetBySheetId(e.gid))==null?void 0:v.getName())==null?``:_:``,(0,l.deserializeRangeWithSheet)(e.range).range);O(t),t===w.display&&W(!0);break}case d.SheetHyperLinkType.SHEET:{let e=D.searchObj;O(e.gid);break}case d.SheetHyperLinkType.DEFINE_NAME:{let e=D.searchObj;O(e.rangeid);break}default:O(``);break}}},[P,ie,I,se,M]),(0,p.useEffect)(()=>{let e=null;if(P&&!P.customRangeId&&P.type===`viewing`&&t.Tools.isDefine(P.row)&&t.Tools.isDefine(P.col)){let n=M.getUnit(P.unitId,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getSheetBySheetId(P.subUnitId),i=r==null?void 0:r.getMergedCell(P.row,P.col),a=new t.ColorKit(ce.getColorFromTheme(`primary.600`)).toRgb();e=L.addShape({range:i==null?{startColumn:P.col,endColumn:P.col,startRow:P.row,endRow:P.row}:i,style:{fill:`rgb(${a.r}, ${a.g}, ${a.b}, 0.12)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1)}return()=>{e&&L.removeShape(e)}},[P,L,ce,M]),(0,p.useEffect)(()=>{me(w===d.SheetHyperLinkType.RANGE)},[w]),(0,p.useEffect)(()=>{let e=oe.getRenderUnitById(j.getCurrentEditorId()),n=new t.DisposableCollection;if(e){let t=e.with(a.DocSelectionRenderService);t.setReserveRangesStatus(!0),n.add(()=>{t.setReserveRangesStatus(!1)})}return()=>{j.disableForceKeepVisible(),n.dispose()}},[j,oe]),(0,p.useEffect)(()=>(B&&N.setIsKeepVisible(B),N.setIsKeepVisible(le),()=>{N.setIsKeepVisible(!1)}),[B,le,N]),(0,p.useEffect)(()=>{if(B)return j.enableForceKeepVisible(),()=>{j.disableForceKeepVisible()}},[B,j]);let he=[{label:k.t(`sheets-hyper-link-ui.form.link`),value:d.SheetHyperLinkType.URL},{label:k.t(`sheets-hyper-link-ui.form.range`),value:d.SheetHyperLinkType.RANGE},{label:k.t(`sheets-hyper-link-ui.form.worksheet`),value:d.SheetHyperLinkType.SHEET},{label:k.t(`sheets-hyper-link-ui.form.definedName`),value:d.SheetHyperLinkType.DEFINE_NAME},...ae],Y=(0,f.useEvent)(e=>{var t;let n=ne(e,(G==null||(t=G.getActiveSheet())==null?void 0:t.getName())||``);if(!n){O(``);return}O(n),(U()||!b)&&(J(n),W(!0))});if(!G)return;let ge=G.getHiddenWorksheets(),X=G.getSheets().map(e=>({label:e.getName(),value:e.getSheetId()})).filter(e=>ge.indexOf(e.value)===-1),_e=Object.values((e=A.getDefinedNameMap(G.getUnitId()))==null?{}:e).map(e=>({label:e.name,value:e.id})),ve=(e,t)=>{if(e===d.SheetHyperLinkType.URL)return y(t);if(e===d.SheetHyperLinkType.RANGE){let e=(0,l.deserializeRangeWithSheet)(t),n=G.getSheetBySheetName(e.sheetName);if(n)return`#gid=${n.getSheetId()}&range=${(0,l.serializeRange)(e.range)}`}return`#${e}=${t}`},Z=async()=>{if(S&&te(b)||!D||w===d.SheetHyperLinkType.URL&&!g(D)){z(!0);return}if(P)if(s){let e=P.type===`editing`?d.UpdateRichHyperLinkCommand.id:d.UpdateHyperLinkCommand.id;await F.executeCommand(e,{id:s,unitId:P.unitId,subUnitId:P.subUnitId,payload:{display:S?b:``,payload:ve(w,D)},row:P.row,column:P.col,documentId:j.getCurrentEditorId()})}else{let e=P.type===`editing`?d.AddRichHyperLinkCommand.id:d.AddHyperLinkCommand.id;await F.executeCommand(e,{unitId:P.unitId,subUnitId:P.subUnitId,link:{id:(0,t.generateRandomId)(),row:P.row,column:P.col,payload:ve(w,D),display:S?b:``},documentId:j.getCurrentEditorId()})}(P==null?void 0:P.type)===`viewing`&&(await F.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:P.unitId,subUnitId:P.subUnitId}),await F.executeCommand(r.ScrollToRangeOperation.id,{range:{startRow:Math.max(P.row-1,0),endRow:P.row+1,startColumn:Math.max(P.col-1,0),endColumn:P.col+1}})),F.executeCommand(K.id)};return P?(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900`,c.borderClassName),children:[S?(0,m.jsx)(c.FormLayout,{label:k.t(`sheets-hyper-link-ui.form.label`),error:R&&te(b)?k.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(c.Input,{value:b,onChange:e=>{J(e),W(!1)},placeholder:k.t(`sheets-hyper-link-ui.form.labelPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===f.KeyCode.ENTER&&Z()}})}):null,(0,m.jsx)(c.FormLayout,{label:k.t(`sheets-hyper-link-ui.form.type`),children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:he,value:w,onChange:e=>{E(e),O(``)}})}),w===d.SheetHyperLinkType.URL&&(0,m.jsx)(c.FormLayout,{error:R?D?g(D)?``:k.t(`sheets-hyper-link-ui.form.linkError`):k.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(c.Input,{value:D,onChange:e=>{O(e),e&&(U()||!b||b===e)&&(J(e),W(!0))},placeholder:k.t(`sheets-hyper-link-ui.form.linkPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===f.KeyCode.ENTER&&Z()}})}),w===d.SheetHyperLinkType.RANGE&&(0,m.jsx)(c.FormLayout,{error:R&&!D?k.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(u.RangeSelector,{unitId:G.getUnitId(),subUnitId:q,maxRangeCount:1,supportAcrossSheet:!0,initialValue:D,resetRange:fe,onChange:(e,t)=>Y(t),onRangeSelectorDialogVisibleChange:async e=>{ue(e),e?(P.type!==`viewing`&&j.enableForceKeepVisible(),v(!0)):(await ie.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),j.disableForceKeepVisible(),v(!1))},onFocusChange:e=>me(e)})}),w===d.SheetHyperLinkType.SHEET&&(0,m.jsx)(c.FormLayout,{error:R&&!D?k.t(`sheets-hyper-link-ui.form.selectError`):``,children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:X,value:D,onChange:e=>{var t,n;O(e);let r=(t=X.find(t=>t.value===e))==null?void 0:t.label,i=(n=X.find(e=>e.value===D))==null?void 0:n.label;r&&(U()||!b||b===i)&&(J(r),W(!0))}})}),w===d.SheetHyperLinkType.DEFINE_NAME&&(0,m.jsx)(c.FormLayout,{error:R&&!D?k.t(`sheets-hyper-link-ui.form.selectError`):``,children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:_e,value:D,onChange:e=>{var t,n;O(e);let r=(t=_e.find(t=>t.value===e))==null?void 0:t.label,i=(n=_e.find(e=>e.value===D))==null?void 0:n.label;r&&(U()||!b||b===i)&&(J(r),W(!0))}})}),(pe==null?void 0:pe.Form)&&(0,m.jsx)(pe.Form,{linkId:s,payload:D,display:b,showError:R,getIsDisplaySyncedWithPayload:U,setDisplaySyncedWithPayload:W,setDisplay:e=>{J(e),W(!0)},setPayload:O}),(0,m.jsxs)(`div`,{className:`univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,m.jsx)(c.Button,{onClick:()=>{P&&ie.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),F.executeCommand(K.id)},children:k.t(`sheets-hyper-link-ui.form.cancel`)}),(0,m.jsx)(c.Button,{variant:`primary`,onClick:async()=>{Z()},children:k.t(`sheets-hyper-link-ui.form.ok`)})]})]}):null};A.componentKey=`univer.sheet.cell-link-edit`;function j({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,p.useRef)(`_${re()}`);return M(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function M(e,t,n,r,i){return(0,p.createElement)(e.tag,{key:t,...N(e,n,i),...r},(P(e,n).children||[]).map((r,a)=>M(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function N(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function P(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function re(){return Math.random().toString(36).substring(2,8)}j.displayName=`UniverIcon`;let ie={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},F=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`all-border-icon`,ref:t,icon:ie}))});F.displayName=`AllBorderIcon`;let I={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ae=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`copy-icon`,ref:t,icon:I}))});ae.displayName=`CopyIcon`;let oe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z`}}]},L=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`link-icon`,ref:t,icon:oe}))});L.displayName=`LinkIcon`;let se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},ce=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:se}))});ce.displayName=`UnlinkIcon`;let le={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},ue=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`write-icon`,ref:t,icon:le}))});ue.displayName=`WriteIcon`;let de={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`#35BD4B`,d:`M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z`}},{tag:`path`,attrs:{fill:`#32A846`,d:`M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z`}},{tag:`path`,attrs:{fill:`white`,d:`M4.7 7.05H11.1V12.05H4.7V7.05ZM5.5 7.85V9.2H7.35V7.85H5.5ZM8.15 7.85V9.2H10.3V7.85H8.15ZM5.5 10V11.25H7.35V10H5.5ZM8.15 10V11.25H10.3V10H8.15Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},fe=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`sheets-multi-icon`,ref:t,icon:de}))});fe.displayName=`SheetsMultiIcon`;let pe={[d.SheetHyperLinkType.URL]:(0,m.jsx)(L,{}),[d.SheetHyperLinkType.SHEET]:(0,m.jsx)(fe,{className:`univer-text-green-500`}),[d.SheetHyperLinkType.RANGE]:(0,m.jsx)(F,{}),[d.SheetHyperLinkType.DEFINE_NAME]:(0,m.jsx)(F,{}),[d.SheetHyperLinkType.INVALID]:(0,m.jsx)(F,{})},R=e=>{var n,i;let a=(0,f.useDependency)(V),o=(0,f.useDependency)(t.ICommandService),s=(0,f.useDependency)(f.IMessageService),l=(0,f.useDependency)(t.LocaleService),u=(0,f.useDependency)(T),p=(0,f.useDependency)(r.IEditorBridgeService),h=(0,f.useDependency)(d.SheetsHyperLinkParserService),{customRange:g,row:_,col:v,unitId:y,subUnitId:b,editPermission:x,copyPermission:S,type:C}=e;if(!(g!=null&&(n=g.properties)!=null&&n.url))return null;let w=h.parseHyperLink((i=g.properties.url)==null?``:i),E=w.type===d.SheetHyperLinkType.INVALID;return(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-gap-2 univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-2 univer-shadow-md dark:!univer-bg-gray-900`,c.borderClassName),onClick:()=>a.hideCurrentPopup(),children:[(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-gap-1 univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600`,{"univer-text-red-500":E}),onClick:()=>{E||u.navigate(w)},children:[(0,m.jsx)(`div`,{className:`univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:pe[w.type]}),(0,m.jsx)(c.Tooltip,{showIfEllipsis:!0,title:w.name,asChild:!0,children:(0,m.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:w.name})})]}),(0,m.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center univer-gap-2`,children:[S&&(0,m.jsx)(`div`,{className:(0,c.clsx)(`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`,{"univer-text-red-500":E}),onClick:()=>{if(!E){if(w.type!==d.SheetHyperLinkType.URL){let e=new URL(window.location.href);e.hash=w.url.slice(1),navigator.clipboard.writeText(e.href)}else navigator.clipboard.writeText(w.url);s.show({content:l.t(`sheets-hyper-link-ui.message.coped`),type:c.MessageType.Info})}},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:l.t(`sheets-hyper-link-ui.popup.copy`),children:(0,m.jsx)(ae,{className:`dark:!univer-text-white`})})}),x&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{"data-u-comp":`cell-link-popup-edit`,className:`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`,onClick:()=>{o.executeCommand(G.id,{unitId:y,subUnitId:b,row:_,col:v,customRangeId:g.rangeId,type:C})},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:l.t(`sheets-hyper-link-ui.popup.edit`),children:(0,m.jsx)(ue,{className:`dark:!univer-text-white`})})}),(0,m.jsx)(`div`,{"data-u-comp":`cell-link-popup-remove`,className:`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`,onClick:()=>{let e=C===`editing`?d.CancelRichHyperLinkCommand.id:d.CancelHyperLinkCommand.id;o.syncExecuteCommand(e,{unitId:y,subUnitId:b,id:g.rangeId,row:_,column:v,documentId:p.getCurrentEditorId()})&&a.hideCurrentPopup(void 0,!0)},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:l.t(`sheets-hyper-link-ui.popup.cancel`),children:(0,m.jsx)(ce,{className:`dark:!univer-text-white`})})})]})]})]})},z=()=>{let e=(0,f.useDependency)(V),n=(0,f.useObservable)(e.currentPopup$,e.currentPopup),r=(0,f.useDependency)(t.IUniverInstanceService);if(!n)return null;if(n.showAll){var i;let e=r.getUnit(n.unitId,t.UniverInstanceType.UNIVER_SHEET),a=e==null?void 0:e.getSheetBySheetId(n.subUnitId),o=a==null?void 0:a.getCell(n.row,n.col),s=o==null||(i=o.p)==null||(i=i.body)==null?void 0:i.customRanges;return s!=null&&s.length?(0,m.jsx)(`div`,{children:s.map(e=>(0,m.jsx)(R,{...n,customRange:e},e.rangeId))}):null}return(0,m.jsx)(R,{...n})};z.componentKey=`univer.sheet.cell-link-popup`;let B=(e,t)=>{var n,r;return e.unitId===t.unitId&&e.subUnitId===t.subUnitId&&e.row===t.row&&e.col===t.col&&((n=e.customRange)==null?void 0:n.rangeId)===((r=t.customRange)==null?void 0:r.rangeId)&&e.type===t.type},V=class extends t.Disposable{get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}constructor(e,t,n,r,i){super(),this._sheetCanvasPopManagerService=e,this._injector=t,this._univerInstanceService=n,this._editorBridgeService=r,this._textSelectionManagerService=i,k(this,`_currentPopup`,null),k(this,`_currentPopup$`,new s.Subject),k(this,`currentPopup$`,this._currentPopup$.asObservable()),k(this,`_currentEditingPopup`,null),k(this,`_currentEditing$`,new s.BehaviorSubject(null)),k(this,`currentEditing$`,this._currentEditing$.asObservable()),k(this,`_isKeepVisible`,!1),this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&B(e,this._currentPopup))return;this.hideCurrentPopup(void 0,!0);let t=this._currentEditing$.getValue();if(t&&B(e,t))return;let{unitId:n,subUnitId:r,row:i,col:a,customRangeRect:o,customRange:s}=e,c,l={componentKey:z.componentKey,direction:`bottom`,onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===`editing`){if(!s)return;c=o&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(o,l)}else if(e.showAll)c=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,l,n,r);else{if(!s)return;c=o&&this._sheetCanvasPopManagerService.attachPopupByPosition(o,l,e)}if(c){if(this._currentPopup){var u;(u=this._currentPopup.disposable)==null||u.dispose()}this._currentPopup={unitId:n,subUnitId:r,disposable:c,row:i,col:a,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:s,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup)}}hideCurrentPopup(e,t){if(this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||t)){var n;(n=this._currentPopup)==null||(n=n.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null)}}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){let e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){var r,i,a;let e=this._textSelectionManagerService.getActiveTextRange(),o=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!o)return null;if(!e||e.collapsed)return{startOffset:0,endOffset:o.dataStream.length-2,collapsed:o.dataStream.length-2==0,label:t.BuildTextUtils.transform.getPlainText(o.dataStream)};let s=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(e,(i=(a=o.customRanges)==null?void 0:a.filter(e=>e.rangeType===t.CustomRangeType.HYPERLINK))==null?[]:i),c=e.startOffset,l=e.endOffset;return s.forEach(e=>{c=Math.min(c,e.startIndex),l=Math.max(l,e.endIndex+1)}),{startOffset:c,endOffset:l,collapsed:c===l,label:t.BuildTextUtils.transform.getPlainText(o.dataStream.slice(c,l))}}return null}get _editPopup(){return{componentKey:A.componentKey,direction:`vertical`,onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:`hide`}}startAddEditing(e){let{unitId:n,subUnitId:r,type:i}=e;if(i===`editing`){var s;let i=this._getEditingRange();if(!i)return;this._textSelectionManagerService.replaceDocRanges([{...i}],{unitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});let c=this._injector.get(o.IRenderManagerService).getRenderUnitById(t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!c)return;let l=(0,a.calcDocRangePositions)(i,c);if(!(l!=null&&l.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(s=i==null?void 0:i.label)==null?``:s})}else{var c,l,u;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);let i=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET),a=i==null?void 0:i.getSheetBySheetId(r),o=a==null?void 0:a.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:o!=null&&o.p?t.BuildTextUtils.transform.getPlainText((c=(l=o.p.body)==null?void 0:l.dataStream)==null?``:c):((u=o==null?void 0:o.v)==null?``:u).toString()})}}startEditing(e){var n;(n=this._currentEditingPopup)==null||n.dispose(),this.hideCurrentPopup(void 0,!0);let{unitId:i,subUnitId:a}=e,o,s;if(e.type===`editing`){var c;let t=(0,r.getEditingCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!t||!((c=t.rects)!=null&&c.length))return;o=t.customRange,s=t.label,this._textSelectionManagerService.replaceDocRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(t.rects.pop(),this._editPopup,i,a)}else{var l;let n=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),c=n==null?void 0:n.getSheetBySheetId(a),u=c==null?void 0:c.getCellRaw(e.row,e.col),d=n==null?void 0:n.getStyles().getStyleByCell(u),f=d==null?void 0:d.tr,p=(0,r.getCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!p||!((l=p.rects)!=null&&l.length))return;o=p.customRange,s=p.label,f?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,a):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(p.rects.pop(),this._editPopup,{unitId:i,subUnitId:a,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:o,label:s})}endEditing(e){if(this.getIsKeepVisible())return;let t=this._currentEditing$.getValue();if(t&&(!e||e===t.type)){var n;(n=this._currentEditingPopup)==null||n.dispose(),this._currentEditing$.next(null)}}};V=C([S(0,(0,t.Inject)(r.SheetCanvasPopManagerService)),S(1,(0,t.Inject)(t.Injector)),S(2,t.IUniverInstanceService),S(3,r.IEditorBridgeService),S(4,(0,t.Inject)(i.DocSelectionManagerService))],V);let me=new Set([t.DataValidationType.CHECKBOX,t.DataValidationType.LIST,t.DataValidationType.LIST_MULTIPLE]),H=(e,t,n,r)=>{var i,a;let o=t.getCell(n,r);if(o!=null&&o.f||o!=null&&o.si||o!=null&&(i=o.p)!=null&&(i=i.body)!=null&&(i=i.customBlocks)!=null&&i.length)return 1;let s=e.has(h.SheetDataValidationModel)?e.get(h.SheetDataValidationModel):null,c=s==null?void 0:s.getRuleByLocation(t.getUnitId(),t.getSheetId(),n,r);return c&&me.has(c.type)?!0:o!=null&&(a=o.p)!=null&&(a=a.drawingsOrder)!=null&&a.length?2:0},U=e=>{let r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!r)return!0;let i=r.getActiveSheet(),a=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!a.length)return!0;let o=a[0].range.startRow,s=a[0].range.startColumn;return H(e,i,o,s)===1},W=e=>{var n;let r=e.get(i.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=r.getTextRanges();if(!(o!=null&&o.length))return!0;let s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);return!!(!s||o.every(e=>e.collapsed)||!((n=s.getSelfOrHeaderFooterModel(o[0].segmentId))!=null&&n.getBody()))},G={type:t.CommandType.OPERATION,id:`sheet.operation.open-hyper-link-edit-panel`,handler(e,t){if(!t)return!1;let n=e.get(V);return t.customRangeId?n.startEditing(t):n.startAddEditing(t),!0}},K={type:t.CommandType.OPERATION,id:`sheet.operation.close-hyper-link-popup`,handler(e){return e.get(V).endEditing(),!0}},q={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link`,handler(e){let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService)),a=e.get(r.IEditorBridgeService);if(!i)return!1;let o=e.get(t.ICommandService),s=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!s)return!1;let c=s.range.startRow,l=s.range.startColumn,u=a.isVisible();return o.executeCommand(G.id,{unitId:i.unitId,subUnitId:i.subUnitId,row:c,col:l,type:u.visible?`editing`:`viewing`})}},J={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link-toolbar`,handler(e){if(U(e))return!1;let n=e.get(t.ICommandService);return e.get(V).currentEditing?n.executeCommand(K.id):n.executeCommand(q.id)}},he=`SHEET_HYPER_LINK_UI_PLUGIN`,Y=class extends t.Disposable{registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(t=>t(e))}constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._hyperLinkModel=t,this._injector=n,this._resolverService=r,k(this,`_plainTextFilter`,new Set),k(this,`_copyInfo`,void 0),this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:he,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,i)=>{let{copyType:a=r.COPY_TYPE.COPY,pasteType:o}=i,{range:s}=e||{},{range:c,unitId:l,subUnitId:u}=t;return this._generateMutations(c,{copyType:a,pasteType:o,copyRange:s,unitId:l,subUnitId:u})},onPastePlainText:(e,n)=>{let i=this._filterPlainText(n);if(g(n)&&i){let{range:n,unitId:i,subUnitId:a}=e,{ranges:[o],mapFunc:s}=(0,r.virtualizeDiscreteRanges)([n]),c=[],l=[];return t.Range.foreach(o,(e,t)=>{let{row:n,col:r}=s(e,t),o=this._hyperLinkModel.getHyperLinkByLocation(i,a,n,r);o&&c.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:i,subUnitId:a,id:o.id}}),o&&l.push({id:d.AddHyperLinkMutation.id,params:{unitId:i,subUnitId:a,link:o}})}),{redos:c,undos:l}}return{undos:[],redos:[]}},priority:99})}_collect(e,r,i){let a=new t.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:r,matrix:a};let o=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!o)return;let{rows:s,cols:c}=o;s.forEach((t,n)=>{c.forEach((i,o)=>{var s;let c=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,i);a.setValue(n,o,(s=c==null?void 0:c.id)==null?``:s)})})}_generateMutations(e,n){if(!this._copyInfo||!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange||[r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};let{unitId:i,subUnitId:a}=this._copyInfo,o=[],s=[],{ranges:[c,l],mapFunc:u}=(0,r.virtualizeDiscreteRanges)([n.copyRange,e]);return(0,r.getRepeatRange)(c,l,!0).forEach(({startRange:e})=>{var r;(r=this._copyInfo)==null||r.matrix.forValue((r,c,l)=>{let f=t.Rectangle.getPositionRange({startRow:r,endRow:r,startColumn:c,endColumn:c},e),p=this._hyperLinkModel.getHyperLink(i,a,l),{row:m,col:h}=u(f.startRow,f.startColumn),g=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,m,h),_=(0,t.generateRandomId)();g&&o.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:g.id}}),p&&(o.push({id:d.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...p,id:_,row:m,column:h}}}),s.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:_}})),g&&s.push({id:d.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:g}})})}),{redos:o,undos:s}}};Y=C([S(0,r.ISheetClipboardService),S(1,(0,t.Inject)(d.HyperLinkModel)),S(2,(0,t.Inject)(t.Injector)),S(3,(0,t.Inject)(T))],Y);let ge=(e,i=t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)=>{var c;let l=e.get(t.IUniverInstanceService),u=(c=e.get(o.IRenderManagerService).getRenderUnitById(i))==null?void 0:c.with(a.DocSelectionRenderService);return u?u.textSelectionInner$.pipe((0,s.map)(()=>{let t=e.get(r.IEditorBridgeService).getEditCellState();if(!t)return!0;let i=(0,n.getSheetCommandTarget)(l,{unitId:t.unitId,subUnitId:t.sheetId});return!(i!=null&&i.worksheet)||H(e,i.worksheet,t.row,t.column)===1||W(e)})):(0,s.of)(!0)},X=e=>{var i;let a=e.get(t.IUniverInstanceService),o=e.has(r.IEditorBridgeService)?e.get(r.IEditorBridgeService):null;return((i=o==null?void 0:o.currentEditCellState$.pipe((0,s.map)(t=>{if(!t)return 1;let r=(0,n.getSheetCommandTarget)(a,{unitId:t.unitId,subUnitId:t.sheetId});return r?H(e,r.worksheet,t.row,t.column):1}),(0,s.switchMap)(n=>n===1?(0,s.of)(!0):(0,s.combineLatest)([o?o.visible$:(0,s.of)(null),a.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC)]).pipe((0,s.switchMap)(([r,i])=>r!=null&&r.visible?(i==null?void 0:i.getUnitId())===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?(0,s.of)(!0):ge(e,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):(0,s.of)(n!==0))))))==null?(0,s.of)(!0):i).pipe((0,s.switchMap)(t=>t?(0,s.of)(!0):(0,r.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},!0)))},_e=e=>({commandId:q.id,type:f.MenuItemType.BUTTON,title:`sheets-hyper-link-ui.menu.add`,icon:`LinkIcon`,id:q.id,hidden$:(0,f.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:X(e)}),ve=e=>({tooltip:`sheets-hyper-link-ui.form.addTitle`,commandId:J.id,type:f.MenuItemType.BUTTON,icon:`LinkIcon`,id:J.id,hidden$:(0,f.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:X(e)}),Z={id:J.id,binding:f.KeyCode.K|f.MetaKeys.CTRL_COMMAND,preconditions:r.whenSheetEditorFocused},ye={[f.RibbonInsertGroup.MEDIA]:{[J.id]:{order:1,gridLayout:{row:1,column:2,rowSpan:2,showLabel:!0},menuItemFactory:ve}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:1,[J.id]:{order:0,menuItemFactory:_e}}}};var be=`@univerjs/sheets-hyper-link-ui`,xe=`1.0.0-alpha.8`;let Se=class extends t.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,i)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,l=(0,r.virtualizeDiscreteRanges)([a,o]),[u,f]=l.ranges,{mapFunc:p}=l,m={row:u.startRow,col:u.startColumn},h=n.AutoFillTools.getAutoFillRepeatRange(u,f),g=[],_=[];return h.forEach(e=>{let r=e.repeatStartCell,a=e.relativeRange,o={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},l={startRow:r.row,startColumn:r.col,endColumn:r.col,endRow:r.row};t.Range.foreach(a,(e,r)=>{let a=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},o),{row:u,col:f}=p(a.startRow,a.startColumn),m=this._hyperLinkModel.getHyperLinkByLocation(s,c,u,f),h=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},l),{row:v,col:y}=p(h.startRow,h.startColumn),b=(0,t.generateRandomId)(),x=this._hyperLinkModel.getHyperLinkByLocation(s,c,v,y);x&&g.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:x.id}}),(n.AUTO_FILL_APPLY_TYPE.COPY===i||n.AUTO_FILL_APPLY_TYPE.SERIES===i)&&m&&(g.push({id:d.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{...m,id:b,row:v,column:y}}}),_.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:b}})),x&&_.push({id:d.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:x}})})}),{undos:_,redos:g}},a={id:he,onFillData:(t,r,a)=>a===n.AUTO_FILL_APPLY_TYPE.COPY||a===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===n.AUTO_FILL_APPLY_TYPE.SERIES?i(t,a):e()};this.disposeWithMe(this._autoFillService.addHook(a))}};Se=C([S(0,n.IAutoFillService),S(1,(0,t.Inject)(d.HyperLinkModel))],Se);let Ce=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[z.componentKey,z],[A.componentKey,A]].forEach(([e,t])=>{this._componentManager.register(e,t)})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:L}))}};Ce=C([S(0,(0,t.Inject)(f.ComponentManager)),S(1,(0,t.Inject)(f.IconManager))],Ce);let we=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Z.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-hyper-link-ui.permission.hyperLinkErr`)))}))}};we=C([S(0,(0,t.Inject)(t.LocaleService)),S(1,t.ICommandService),S(2,(0,t.Inject)(n.SheetPermissionCheckController))],we);let Te=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=s,this._univerInstanceService=c,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener()}_getLinkPermission(e){let{unitId:r,subUnitId:i,row:a,col:o}=e,s=this._univerInstanceService.getUnit(r,t.UniverInstanceType.UNIVER_SHEET),c=s==null?void 0:s.getSheetBySheetId(i);if(!c)return{viewPermission:!1,editPermission:!1,copyPermission:!1};let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookViewPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),d=c.getCellRaw(a,o);d!=null&&d.f&&d.f.startsWith(`=HYPERLINK(`)&&(u=!1);let f=this._permissionService.composePermission([new n.WorkbookCopyPermission(r).id,new n.WorksheetCopyPermission(r,i).id]).every(e=>e.value);return{viewPermission:l,editPermission:u,copyPermission:f}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe((0,s.debounceTime)(200)).subscribe(e=>{var n,i,a;if(!e||((n=e.customRange)==null?void 0:n.rangeType)!==t.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let{unitId:o,subUnitId:s,row:c,col:l}=e,u=this._renderManagerService.getRenderUnitById(o);if(!u)return;let d=this._univerInstanceService.getUnit(o,t.UniverInstanceType.UNIVER_SHEET),f=d==null?void 0:d.getSheetBySheetId(s);if(!f)return;if(!u.with(r.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(`viewing`);return}let p=u==null||(i=u.with(r.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:i.skeleton,m=l,h=c,g=h,_=m;p&&p.overflowCache.forValue((e,n,r)=>{t.Rectangle.contains(r,{startColumn:m,endColumn:m,startRow:h,endRow:h})&&(g=e,_=n)});let{viewPermission:v,editPermission:y,copyPermission:b}=this._getLinkPermission(e);if(!v){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let x=f.getCellStyleOnly(g,_),S=d.getStyles().getStyleByCell(x),C=S==null||(a=S.tr)==null?void 0:a.a;if(!C&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:g,col:_,editPermission:y,copyPermission:b,customRange:e.customRange,customRangeRect:e.rect,type:`viewing`,unitId:o,subUnitId:s,showAll:!!C})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe((0,s.switchMap)(e=>this._editorBridgeService.visible$.pipe((0,s.map)(t=>({visible:t,state:e}))))).subscribe(({visible:n,state:i})=>{if(!i||i.editorUnitId!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(`editing`),this._sheetsHyperLinkPopupService.endEditing(`editing`);return}let{editorUnitId:o,unitId:c,sheetId:l,row:u,column:d}=i,f=this._renderManagerService.getRenderUnitById(o);if(!f)return;let{editPermission:p,viewPermission:m,copyPermission:h}=this._getLinkPermission({unitId:c,subUnitId:l,row:u,col:d}),g=f.with(a.DocEventManagerService);m&&(e==null||e.unsubscribe(),e=g.hoverCustomRanges$.pipe((0,s.debounceTime)(200)).subscribe(e=>{var n;let i=e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK);if(!i){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let a=i.rects[i.rects.length-1];if(!((n=this._renderManagerService.getRenderUnitById(c))!=null&&(n=n.with(r.SheetSkeletonManagerService).getSkeletonParam(l))!=null&&n.skeleton)||!a)return;let o=f.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:c,subUnitId:l,row:u,col:d,customRange:i.range,customRangeRect:{left:a.left+o.left,top:a.top+o.top,bottom:a.bottom+o.top,right:a.right+o.left},editPermission:p,copyPermission:h,type:`editing`})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(`editing`)}))}_initCommandListener(){let e=[n.ClearSelectionContentCommand.id,n.ClearSelectionAllCommand.id,n.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Te=C([S(0,(0,t.Inject)(r.HoverManagerService)),S(1,(0,t.Inject)(V)),S(2,(0,t.Inject)(o.IRenderManagerService)),S(3,(0,t.Inject)(t.IPermissionService)),S(4,(0,t.Inject)(n.SheetPermissionCheckController)),S(5,t.ICommandService),S(6,r.IEditorBridgeService),S(7,(0,t.Inject)(i.DocSelectionManagerService)),S(8,t.IUniverInstanceService)],Te);let Ee=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._hyperLinkModel=t,this._initSkeletonChange()}_initSkeletonChange(){let e=()=>{var e;(e=this._context.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe((0,s.debounceTime)(16)).subscribe(()=>{e()}))}};Ee=C([S(1,(0,t.Inject)(d.HyperLinkModel))],Ee);let De=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortCut()}_initCommands(){[G,K,q,J].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(ye)}_initShortCut(){this._shortcutService.registerShortcut(Z)}};De=C([S(0,t.ICommandService),S(1,f.IMenuManagerService),S(2,(0,t.Inject)(f.IShortcutService))],De);let Q=class extends t.Disposable{constructor(e,t){super(),this._parserService=e,this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){let e=location.hash;if(e){let t=this._parserService.parseHyperLink(e);this._resolverService.navigate(t)}}};Q=C([S(0,(0,t.Inject)(d.SheetsHyperLinkParserService)),S(1,(0,t.Inject)(T))],Q);let $=class extends t.Plugin{constructor(e=x,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},x,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(b,a)}onStarting(){this._injector.add([Ce]),this._injector.get(Ce),[[T],[V],[ee],[Te],[De],[Se],[Y],[we],[Q]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(o.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[Ee]),this._injector.get(Se),this._injector.get(Y),this._injector.get(De)}onRendered(){this._injector.get(we),this._injector.get(Q),this._injector.get(Te)}};k($,`pluginName`,he),k($,`packageName`,be),k($,`version`,xe),k($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=C([(0,t.DependentOn)(i.UniverDocsPlugin,l.UniverFormulaEnginePlugin,o.UniverRenderEnginePlugin,n.UniverSheetsPlugin,f.UniverUIPlugin,a.UniverDocsUIPlugin,d.UniverSheetsHyperLinkPlugin,r.UniverSheetsUIPlugin),S(1,(0,t.Inject)(t.Injector)),S(2,t.IConfigService)],$),e.CloseHyperLinkPopupOperation=K,e.InsertHyperLinkOperation=q,e.InsertLinkShortcut=Z,e.OpenHyperLinkEditPanelOperation=G,Object.defineProperty(e,"SheetsHyperLinkCopyPasteController",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"SheetsHyperLinkPopupService",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SheetsHyperLinkResolverService",{enumerable:!0,get:function(){return T}}),e.SheetsHyperLinkSidePanelService=ee,e.SheetsHyperLinkUIMenuSchema=ye,Object.defineProperty(e,"UniverSheetsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-hyper-link"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/sheets-data-validation")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/engine-render`,`rxjs`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`@univerjs/sheets-hyper-link`,`@univerjs/ui`,`react`,`react/jsx-runtime`,`@univerjs/sheets-data-validation`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLinkUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsUi,e.UniverDocs,e.UniverDocsUi,e.UniverEngineRender,e.rxjs,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.UniverSheetsHyperLink,e.UniverUi,e.React,e.React,e.UniverSheetsDataValidation))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function g(e){return t.Tools.isLegalUrl(e)}function _(e){return/^[a-zA-Z]+:\/\//.test(e)}function v(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function y(e){if(g(e)){let t=_(e)?e:v(e)?`mailto://${e}`:`http://${e}`,n;try{n=new URL(t)}catch{return e}return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:t}return e}let b=`sheets-hyper-link-ui.config`,x={};function S(e,t){return function(n,r){t(n,r,e)}}function C(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function w(e,n){let r=n.getMergeData(),i=n.getMaxColumns()-1,a=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),a<e.endRow&&(e.endRow=a),e.rangeType===t.RANGE_TYPE.COLUMN||t.RANGE_TYPE.ROW)return e;let o=[];return r.forEach(n=>{t.Rectangle.intersects(e,n)&&o.push(n)}),t.Rectangle.realUnion(e,...o)}let T=class{constructor(e,t,n,r,i,a){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=i,this._configService=a}navigate(e){switch(e.type){case d.SheetHyperLinkType.URL:this.navigateToOtherWebsite(e.url);break;default:this._navigateToUniver(e.searchObj)}}_navigateToUniver(e){let{gid:n,range:r,rangeid:i}=e,a=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=a.getUnitId();if(i){let e=this._definedNamesService.getValueById(o,i);if(!e)return;let{formulaOrRefString:t}=e,n=this._definedNamesService.getWorksheetByRef(o,t);if(!n){this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.refError`),type:c.MessageType.Error});return}if(n.isSheetHidden()){this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.hiddenSheet`),type:c.MessageType.Error});return}this.navigateToDefineName(o,i)}if(n){if(r){let e=(0,l.deserializeRangeWithSheet)(r);(0,t.isValidRange)(e.range)&&r!==d.ERROR_RANGE&&this.navigateToRange(o,n,e.range);return}this.navigateToSheetById(o,n)}}async navigateToRange(e,t,i,a){let o=await this.navigateToSheetById(e,t);if(o){let s=w(i,o);await this._commandService.executeCommand(n.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:s,primary:null}]}),await this._commandService.executeCommand(r.ScrollToRangeOperation.id,{range:s,forceTop:a})}}async navigateToSheetById(e,r){let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;let a=i.getActiveSheet();if(!a)return!1;if(a.getSheetId()===r)return a;let o=i.getSheetBySheetId(r);return o?i.getHiddenWorksheets().indexOf(r)>-1?(this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.hiddenSheet`),type:c.MessageType.Error}),!1):await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r})?o:!1:(this._messageService.show({content:this._localeService.t(`sheets-hyper-link-ui.message.noSheet`),type:c.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){var n;if(!(0,t.isSafeUrl)(e))return;let r=this._configService.getConfig(b);if(r!=null&&(n=r.urlHandler)!=null&&n.navigateToOtherWebsite)return r.urlHandler.navigateToOtherWebsite(e);window.open(e,`_blank`,`noopener noreferrer`)}};T=C([S(0,t.IUniverInstanceService),S(1,t.ICommandService),S(2,l.IDefinedNamesService),S(3,f.IMessageService),S(4,(0,t.Inject)(t.LocaleService)),S(5,t.IConfigService)],T);function E(e){"@babel/helpers - typeof";return E=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function k(e,t,n){return(t=O(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee=class extends t.Disposable{constructor(...e){super(...e),k(this,`_customHyperLinks`,new Map)}isBuiltInLinkType(e){return e!==d.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(t=>t.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){let{_customHyperLinks:t}=this;t.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}};function te(e){return e.trim().length===0}function ne(e,n){let[r]=e.split(`,`).map(l.deserializeRangeWithSheet);return!r||!(0,t.isValidRange)(r.range)?``:(r.sheetName||=n,(0,l.serializeRangeToRefString)(r))}let A=()=>{let[e,s]=(0,p.useState)(``),[h,_]=(0,p.useState)(!1),[v,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(!0),[C,w]=(0,p.useState)(d.SheetHyperLinkType.URL),[E,D]=(0,p.useState)(``),O=(0,f.useDependency)(t.LocaleService),k=(0,f.useDependency)(l.IDefinedNamesService),A=(0,f.useDependency)(r.IEditorBridgeService),j=(0,f.useDependency)(t.IUniverInstanceService),M=(0,f.useDependency)(U),N=(0,f.useObservable)(M.currentEditing$),re=(0,f.useDependency)(d.SheetsHyperLinkParserService),P=(0,f.useDependency)(T),F=(0,f.useDependency)(t.ICommandService),I=(0,f.useDependency)(ee),ie=(0,p.useMemo)(()=>I.getOptions(),[I]),ae=(0,f.useDependency)(o.IRenderManagerService),oe=(0,f.useDependency)(r.IMarkSelectionService),L=(0,f.useDependency)(i.DocSelectionManagerService),se=(0,f.useDependency)(t.ThemeService),[R,ce]=(0,p.useState)(!1),le=(0,f.useDependency)(n.SheetsSelectionsService),ue=(0,p.useMemo)(()=>le.getCurrentSelections(),[]),z=(0,p.useMemo)(()=>{if(!I.isBuiltInLinkType(C))return I.getCustomHyperLink(C)},[I,C]),[B,de]=(0,p.useState)(!1),[V,H]=(0,p.useState)(!1),fe=(0,p.useRef)(!1),W=(0,f.useEvent)(()=>fe.current),G=(0,f.useEvent)(e=>{fe.current=e}),K=j.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),q=(K==null?void 0:K.getActiveSheet().getSheetId())||``,Y=(0,p.useCallback)(e=>{b(e.replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_START,``).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_END,``))},[b]);(0,p.useEffect)(()=>{if((N==null?void 0:N.row)!==void 0&&N.col!==void 0){let{customRange:u,row:f,col:p}=N,{label:m}=N;typeof m==`number`&&(m=`${m}`);let h;if(u){var e;h={id:(u==null?void 0:u.rangeId)??``,display:m??``,payload:(u==null||(e=u.properties)==null?void 0:e.url)??``,row:f,column:p}}else if(N.type===`viewing`){var n,r,i;let e=j.getUnit(N.unitId),a=e==null?void 0:e.getSheetBySheetId(N.subUnitId),o=a==null?void 0:a.getCellRaw(N.row,N.col),s=o==null||(n=o.p)==null||(n=n.body)==null||(n=n.customRanges)==null?void 0:n.find(e=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK&&((n=e.properties)==null?void 0:n.url)}),c=o==null?void 0:o.v;o&&(!t.BuildTextUtils.transform.isEmptyDocument((r=o.p)==null||(r=r.body)==null?void 0:r.dataStream)||t.Tools.isDefine(c))&&S(!1),h={id:``,display:``,payload:(s==null||(i=s.properties)==null?void 0:i.url)??``,row:f,column:p}}else{var a,o;let e=j.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),n=L.getActiveTextRange(),r=e==null?void 0:e.getBody(),i=n&&r?n:null,s=i&&((a=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(r==null?void 0:r.customRanges)??[]))==null?void 0:a[0]);S(!1),h={id:``,display:m??``,payload:(s==null||(o=s.properties)==null?void 0:o.url)??``,row:f,column:p}}s(h.id);let g=I.findCustomHyperLink(h);if(g){let e=g.convert(h);w(e.type),D(e.payload),Y(e.display);return}Y(h.display);let _=re.parseHyperLink(h.payload);switch(w(_.type===d.SheetHyperLinkType.INVALID?d.SheetHyperLinkType.RANGE:_.type),_.type){case d.SheetHyperLinkType.URL:D(_.url),_.url===h.display&&G(!0);break;case d.SheetHyperLinkType.RANGE:{var c;let e=_.searchObj,t=(0,l.serializeRangeWithSheet)(e.gid?((c=j.getUnit(N.unitId))==null||(c=c.getSheetBySheetId(e.gid))==null?void 0:c.getName())??``:``,(0,l.deserializeRangeWithSheet)(e.range).range);D(t),t===h.display&&G(!0);break}case d.SheetHyperLinkType.SHEET:{let e=_.searchObj;D(e.gid);break}case d.SheetHyperLinkType.DEFINE_NAME:{let e=_.searchObj;D(e.rangeid);break}default:D(``);break}}},[N,P,I,L,j]),(0,p.useEffect)(()=>{let e=null;if(N&&!N.customRangeId&&N.type===`viewing`&&t.Tools.isDefine(N.row)&&t.Tools.isDefine(N.col)){let n=j.getUnit(N.unitId,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getSheetBySheetId(N.subUnitId),i=r==null?void 0:r.getMergedCell(N.row,N.col),a=new t.ColorKit(se.getColorFromTheme(`primary.600`)).toRgb();e=oe.addShape({range:i??{startColumn:N.col,endColumn:N.col,startRow:N.row,endRow:N.row},style:{fill:`rgb(${a.r}, ${a.g}, ${a.b}, 0.12)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1)}return()=>{e&&oe.removeShape(e)}},[N,oe,se,j]),(0,p.useEffect)(()=>{H(C===d.SheetHyperLinkType.RANGE)},[C]),(0,p.useEffect)(()=>{let e=ae.getRenderUnitById(A.getCurrentEditorId()),n=new t.DisposableCollection;if(e){let t=e.with(a.DocSelectionRenderService);t.setReserveRangesStatus(!0),n.add(()=>{t.setReserveRangesStatus(!1)})}return()=>{A.disableForceKeepVisible(),n.dispose()}},[A,ae]),(0,p.useEffect)(()=>(V&&M.setIsKeepVisible(V),M.setIsKeepVisible(R),()=>{M.setIsKeepVisible(!1)}),[V,R,M]),(0,p.useEffect)(()=>{if(V)return A.enableForceKeepVisible(),()=>{A.disableForceKeepVisible()}},[V,A]);let X=[{label:O.t(`sheets-hyper-link-ui.form.link`),value:d.SheetHyperLinkType.URL},{label:O.t(`sheets-hyper-link-ui.form.range`),value:d.SheetHyperLinkType.RANGE},{label:O.t(`sheets-hyper-link-ui.form.worksheet`),value:d.SheetHyperLinkType.SHEET},{label:O.t(`sheets-hyper-link-ui.form.definedName`),value:d.SheetHyperLinkType.DEFINE_NAME},...ie],pe=(0,f.useEvent)(e=>{var t;let n=ne(e,(K==null||(t=K.getActiveSheet())==null?void 0:t.getName())||``);if(!n){D(``);return}D(n),(W()||!v)&&(Y(n),G(!0))});if(!K)return;let Z=K.getHiddenWorksheets(),me=K.getSheets().map(e=>({label:e.getName(),value:e.getSheetId()})).filter(e=>Z.indexOf(e.value)===-1),Q=Object.values(k.getDefinedNameMap(K.getUnitId())??{}).map(e=>({label:e.name,value:e.id})),he=(e,t)=>{if(e===d.SheetHyperLinkType.URL)return y(t);if(e===d.SheetHyperLinkType.RANGE){let e=(0,l.deserializeRangeWithSheet)(t),n=K.getSheetBySheetName(e.sheetName);if(n)return`#gid=${n.getSheetId()}&range=${(0,l.serializeRange)(e.range)}`}return`#${e}=${t}`},ge=async()=>{if(x&&te(v)||!E||C===d.SheetHyperLinkType.URL&&!g(E)){de(!0);return}if(N)if(e){let t=N.type===`editing`?d.UpdateRichHyperLinkCommand.id:d.UpdateHyperLinkCommand.id;await F.executeCommand(t,{id:e,unitId:N.unitId,subUnitId:N.subUnitId,payload:{display:x?v:``,payload:he(C,E)},row:N.row,column:N.col,documentId:A.getCurrentEditorId()})}else{let e=N.type===`editing`?d.AddRichHyperLinkCommand.id:d.AddHyperLinkCommand.id;await F.executeCommand(e,{unitId:N.unitId,subUnitId:N.subUnitId,link:{id:(0,t.generateRandomId)(),row:N.row,column:N.col,payload:he(C,E),display:x?v:``},documentId:A.getCurrentEditorId()})}(N==null?void 0:N.type)===`viewing`&&(await F.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:N.unitId,subUnitId:N.subUnitId}),await F.executeCommand(r.ScrollToRangeOperation.id,{range:{startRow:Math.max(N.row-1,0),endRow:N.row+1,startColumn:Math.max(N.col-1,0),endColumn:N.col+1}})),F.executeCommand(J.id)};return N?(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900`,c.borderClassName),children:[x?(0,m.jsx)(c.FormLayout,{label:O.t(`sheets-hyper-link-ui.form.label`),error:B&&te(v)?O.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(c.Input,{value:v,onChange:e=>{Y(e),G(!1)},placeholder:O.t(`sheets-hyper-link-ui.form.labelPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===f.KeyCode.ENTER&&ge()}})}):null,(0,m.jsx)(c.FormLayout,{label:O.t(`sheets-hyper-link-ui.form.type`),children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:X,value:C,onChange:e=>{w(e),D(``)}})}),C===d.SheetHyperLinkType.URL&&(0,m.jsx)(c.FormLayout,{error:B?E?g(E)?``:O.t(`sheets-hyper-link-ui.form.linkError`):O.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(c.Input,{value:E,onChange:e=>{D(e),e&&(W()||!v||v===e)&&(Y(e),G(!0))},placeholder:O.t(`sheets-hyper-link-ui.form.linkPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===f.KeyCode.ENTER&&ge()}})}),C===d.SheetHyperLinkType.RANGE&&(0,m.jsx)(c.FormLayout,{error:B&&!E?O.t(`sheets-hyper-link-ui.form.inputError`):``,children:(0,m.jsx)(u.RangeSelector,{unitId:K.getUnitId(),subUnitId:q,maxRangeCount:1,supportAcrossSheet:!0,initialValue:E,resetRange:ue,onChange:(e,t)=>pe(t),onRangeSelectorDialogVisibleChange:async e=>{ce(e),e?(N.type!==`viewing`&&A.enableForceKeepVisible(),_(!0)):(await P.navigateToRange(N.unitId,N.subUnitId,{startRow:N.row,endRow:N.row,startColumn:N.col,endColumn:N.col},!0),A.disableForceKeepVisible(),_(!1))},onFocusChange:e=>H(e)})}),C===d.SheetHyperLinkType.SHEET&&(0,m.jsx)(c.FormLayout,{error:B&&!E?O.t(`sheets-hyper-link-ui.form.selectError`):``,children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:me,value:E,onChange:e=>{var t,n;D(e);let r=(t=me.find(t=>t.value===e))==null?void 0:t.label,i=(n=me.find(e=>e.value===E))==null?void 0:n.label;r&&(W()||!v||v===i)&&(Y(r),G(!0))}})}),C===d.SheetHyperLinkType.DEFINE_NAME&&(0,m.jsx)(c.FormLayout,{error:B&&!E?O.t(`sheets-hyper-link-ui.form.selectError`):``,children:(0,m.jsx)(c.Select,{className:`univer-w-full`,options:Q,value:E,onChange:e=>{var t,n;D(e);let r=(t=Q.find(t=>t.value===e))==null?void 0:t.label,i=(n=Q.find(e=>e.value===E))==null?void 0:n.label;r&&(W()||!v||v===i)&&(Y(r),G(!0))}})}),(z==null?void 0:z.Form)&&(0,m.jsx)(z.Form,{linkId:e,payload:E,display:v,showError:B,getIsDisplaySyncedWithPayload:W,setDisplaySyncedWithPayload:G,setDisplay:e=>{Y(e),G(!0)},setPayload:D}),(0,m.jsxs)(`div`,{className:`univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,m.jsx)(c.Button,{onClick:()=>{N&&P.navigateToRange(N.unitId,N.subUnitId,{startRow:N.row,endRow:N.row,startColumn:N.col,endColumn:N.col},!0),F.executeCommand(J.id)},children:O.t(`sheets-hyper-link-ui.form.cancel`)}),(0,m.jsx)(c.Button,{variant:`primary`,onClick:async()=>{ge()},children:O.t(`sheets-hyper-link-ui.form.ok`)})]})]}):null};A.componentKey=`univer.sheet.cell-link-edit`;function j({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,p.useRef)(`_${P()}`);return M(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function M(e,t,n,r,i){return(0,p.createElement)(e.tag,{key:t,...N(e,n,i),...r},(re(e,n).children||[]).map((r,a)=>M(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function N(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function re(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function P(){return Math.random().toString(36).substring(2,8)}j.displayName=`UniverIcon`;let F={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},I=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`all-border-icon`,ref:t,icon:F}))});I.displayName=`AllBorderIcon`;let ie={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ae=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`copy-icon`,ref:t,icon:ie}))});ae.displayName=`CopyIcon`;let oe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z`}}]},L=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`link-icon`,ref:t,icon:oe}))});L.displayName=`LinkIcon`;let se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},R=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:se}))});R.displayName=`UnlinkIcon`;let ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},le=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`write-icon`,ref:t,icon:ce}))});le.displayName=`WriteIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`#35BD4B`,d:`M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z`}},{tag:`path`,attrs:{fill:`#32A846`,d:`M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z`}},{tag:`path`,attrs:{fill:`white`,d:`M4.7 7.05H11.1V12.05H4.7V7.05ZM5.5 7.85V9.2H7.35V7.85H5.5ZM8.15 7.85V9.2H10.3V7.85H8.15ZM5.5 10V11.25H7.35V10H5.5ZM8.15 10V11.25H10.3V10H8.15Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},z=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`sheets-multi-icon`,ref:t,icon:ue}))});z.displayName=`SheetsMultiIcon`;let B={[d.SheetHyperLinkType.URL]:(0,m.jsx)(L,{}),[d.SheetHyperLinkType.SHEET]:(0,m.jsx)(z,{className:`univer-text-green-500`}),[d.SheetHyperLinkType.RANGE]:(0,m.jsx)(I,{}),[d.SheetHyperLinkType.DEFINE_NAME]:(0,m.jsx)(I,{}),[d.SheetHyperLinkType.INVALID]:(0,m.jsx)(I,{})},de=e=>{var n;let i=(0,f.useDependency)(U),a=(0,f.useDependency)(t.ICommandService),o=(0,f.useDependency)(f.IMessageService),s=(0,f.useDependency)(t.LocaleService),l=(0,f.useDependency)(T),u=(0,f.useDependency)(r.IEditorBridgeService),p=(0,f.useDependency)(d.SheetsHyperLinkParserService),{customRange:h,row:g,col:_,unitId:v,subUnitId:y,editPermission:b,copyPermission:x,type:S}=e;if(!(h!=null&&(n=h.properties)!=null&&n.url))return null;let C=p.parseHyperLink(h.properties.url??``),w=C.type===d.SheetHyperLinkType.INVALID;return(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-gap-2 univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-2 univer-shadow-md dark:!univer-bg-gray-900`,c.borderClassName),onClick:()=>i.hideCurrentPopup(),children:[(0,m.jsxs)(`div`,{className:(0,c.clsx)(`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-gap-1 univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600`,{"univer-text-red-500":w}),onClick:()=>{w||l.navigate(C)},children:[(0,m.jsx)(`div`,{className:`univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:B[C.type]}),(0,m.jsx)(c.Tooltip,{showIfEllipsis:!0,title:C.name,asChild:!0,children:(0,m.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:C.name})})]}),(0,m.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center univer-gap-2`,children:[x&&(0,m.jsx)(`div`,{className:(0,c.clsx)(`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`,{"univer-text-red-500":w}),onClick:()=>{if(!w){if(C.type!==d.SheetHyperLinkType.URL){let e=new URL(window.location.href);e.hash=C.url.slice(1),navigator.clipboard.writeText(e.href)}else navigator.clipboard.writeText(C.url);o.show({content:s.t(`sheets-hyper-link-ui.message.coped`),type:c.MessageType.Info})}},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:s.t(`sheets-hyper-link-ui.popup.copy`),children:(0,m.jsx)(ae,{className:`dark:!univer-text-white`})})}),b&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{"data-u-comp":`cell-link-popup-edit`,className:`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`,onClick:()=>{a.executeCommand(q.id,{unitId:v,subUnitId:y,row:g,col:_,customRangeId:h.rangeId,type:S})},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:s.t(`sheets-hyper-link-ui.popup.edit`),children:(0,m.jsx)(le,{className:`dark:!univer-text-white`})})}),(0,m.jsx)(`div`,{"data-u-comp":`cell-link-popup-remove`,className:`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`,onClick:()=>{let e=S===`editing`?d.CancelRichHyperLinkCommand.id:d.CancelHyperLinkCommand.id;a.syncExecuteCommand(e,{unitId:v,subUnitId:y,id:h.rangeId,row:g,column:_,documentId:u.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:(0,m.jsx)(c.Tooltip,{placement:`bottom`,title:s.t(`sheets-hyper-link-ui.popup.cancel`),children:(0,m.jsx)(R,{className:`dark:!univer-text-white`})})})]})]})]})},V=()=>{let e=(0,f.useDependency)(U),n=(0,f.useObservable)(e.currentPopup$,e.currentPopup),r=(0,f.useDependency)(t.IUniverInstanceService);if(!n)return null;if(n.showAll){var i;let e=r.getUnit(n.unitId,t.UniverInstanceType.UNIVER_SHEET),a=e==null?void 0:e.getSheetBySheetId(n.subUnitId),o=a==null?void 0:a.getCell(n.row,n.col),s=o==null||(i=o.p)==null||(i=i.body)==null?void 0:i.customRanges;return s!=null&&s.length?(0,m.jsx)(`div`,{children:s.map(e=>(0,m.jsx)(de,{...n,customRange:e},e.rangeId))}):null}return(0,m.jsx)(de,{...n})};V.componentKey=`univer.sheet.cell-link-popup`;let H=(e,t)=>{var n,r;return e.unitId===t.unitId&&e.subUnitId===t.subUnitId&&e.row===t.row&&e.col===t.col&&((n=e.customRange)==null?void 0:n.rangeId)===((r=t.customRange)==null?void 0:r.rangeId)&&e.type===t.type},U=class extends t.Disposable{get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}constructor(e,t,n,r,i){super(),this._sheetCanvasPopManagerService=e,this._injector=t,this._univerInstanceService=n,this._editorBridgeService=r,this._textSelectionManagerService=i,k(this,`_currentPopup`,null),k(this,`_currentPopup$`,new s.Subject),k(this,`currentPopup$`,this._currentPopup$.asObservable()),k(this,`_currentEditingPopup`,null),k(this,`_currentEditing$`,new s.BehaviorSubject(null)),k(this,`currentEditing$`,this._currentEditing$.asObservable()),k(this,`_isKeepVisible`,!1),this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&H(e,this._currentPopup))return;this.hideCurrentPopup(void 0,!0);let t=this._currentEditing$.getValue();if(t&&H(e,t))return;let{unitId:n,subUnitId:r,row:i,col:a,customRangeRect:o,customRange:s}=e,c,l={componentKey:V.componentKey,direction:`bottom`,onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===`editing`){if(!s)return;c=o&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(o,l)}else if(e.showAll)c=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,l,n,r);else{if(!s)return;c=o&&this._sheetCanvasPopManagerService.attachPopupByPosition(o,l,e)}if(c){if(this._currentPopup){var u;(u=this._currentPopup.disposable)==null||u.dispose()}this._currentPopup={unitId:n,subUnitId:r,disposable:c,row:i,col:a,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:s,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup)}}hideCurrentPopup(e,t){if(this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||t)){var n;(n=this._currentPopup)==null||(n=n.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null)}}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){let e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){var r,i;let e=this._textSelectionManagerService.getActiveTextRange(),a=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!a)return null;if(!e||e.collapsed)return{startOffset:0,endOffset:a.dataStream.length-2,collapsed:a.dataStream.length-2==0,label:t.BuildTextUtils.transform.getPlainText(a.dataStream)};let o=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(e,((i=a.customRanges)==null?void 0:i.filter(e=>e.rangeType===t.CustomRangeType.HYPERLINK))??[]),s=e.startOffset,c=e.endOffset;return o.forEach(e=>{s=Math.min(s,e.startIndex),c=Math.max(c,e.endIndex+1)}),{startOffset:s,endOffset:c,collapsed:s===c,label:t.BuildTextUtils.transform.getPlainText(a.dataStream.slice(s,c))}}return null}get _editPopup(){return{componentKey:A.componentKey,direction:`vertical`,onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:`hide`}}startAddEditing(e){let{unitId:n,subUnitId:r,type:i}=e;if(i===`editing`){let i=this._getEditingRange();if(!i)return;this._textSelectionManagerService.replaceDocRanges([{...i}],{unitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});let s=this._injector.get(o.IRenderManagerService).getRenderUnitById(t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!s)return;let c=(0,a.calcDocRangePositions)(i,s);if(!(c!=null&&c.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(c.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(i==null?void 0:i.label)??``})}else{var s;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);let i=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET),a=i==null?void 0:i.getSheetBySheetId(r),o=a==null?void 0:a.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:o!=null&&o.p?t.BuildTextUtils.transform.getPlainText(((s=o.p.body)==null?void 0:s.dataStream)??``):((o==null?void 0:o.v)??``).toString()})}}startEditing(e){var n;(n=this._currentEditingPopup)==null||n.dispose(),this.hideCurrentPopup(void 0,!0);let{unitId:i,subUnitId:a}=e,o,s;if(e.type===`editing`){var c;let t=(0,r.getEditingCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!t||!((c=t.rects)!=null&&c.length))return;o=t.customRange,s=t.label,this._textSelectionManagerService.replaceDocRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(t.rects.pop(),this._editPopup,i,a)}else{var l;let n=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),c=n==null?void 0:n.getSheetBySheetId(a),u=c==null?void 0:c.getCellRaw(e.row,e.col),d=n==null?void 0:n.getStyles().getStyleByCell(u),f=d==null?void 0:d.tr,p=(0,r.getCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!p||!((l=p.rects)!=null&&l.length))return;o=p.customRange,s=p.label,f?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,a):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(p.rects.pop(),this._editPopup,{unitId:i,subUnitId:a,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:o,label:s})}endEditing(e){if(this.getIsKeepVisible())return;let t=this._currentEditing$.getValue();if(t&&(!e||e===t.type)){var n;(n=this._currentEditingPopup)==null||n.dispose(),this._currentEditing$.next(null)}}};U=C([S(0,(0,t.Inject)(r.SheetCanvasPopManagerService)),S(1,(0,t.Inject)(t.Injector)),S(2,t.IUniverInstanceService),S(3,r.IEditorBridgeService),S(4,(0,t.Inject)(i.DocSelectionManagerService))],U);let fe=new Set([t.DataValidationType.CHECKBOX,t.DataValidationType.LIST,t.DataValidationType.LIST_MULTIPLE]),W=(e,t,n,r)=>{var i,a;let o=t.getCell(n,r);if(o!=null&&o.f||o!=null&&o.si||o!=null&&(i=o.p)!=null&&(i=i.body)!=null&&(i=i.customBlocks)!=null&&i.length)return 1;let s=e.has(h.SheetDataValidationModel)?e.get(h.SheetDataValidationModel):null,c=s==null?void 0:s.getRuleByLocation(t.getUnitId(),t.getSheetId(),n,r);return c&&fe.has(c.type)?!0:o!=null&&(a=o.p)!=null&&(a=a.drawingsOrder)!=null&&a.length?2:0},G=e=>{let r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!r)return!0;let i=r.getActiveSheet(),a=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!a.length)return!0;let o=a[0].range.startRow,s=a[0].range.startColumn;return W(e,i,o,s)===1},K=e=>{var n;let r=e.get(i.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=r.getTextRanges();if(!(o!=null&&o.length))return!0;let s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);return!!(!s||o.every(e=>e.collapsed)||!((n=s.getSelfOrHeaderFooterModel(o[0].segmentId))!=null&&n.getBody()))},q={type:t.CommandType.OPERATION,id:`sheet.operation.open-hyper-link-edit-panel`,handler(e,t){if(!t)return!1;let n=e.get(U);return t.customRangeId?n.startEditing(t):n.startAddEditing(t),!0}},J={type:t.CommandType.OPERATION,id:`sheet.operation.close-hyper-link-popup`,handler(e){return e.get(U).endEditing(),!0}},Y={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link`,handler(e){let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService)),a=e.get(r.IEditorBridgeService);if(!i)return!1;let o=e.get(t.ICommandService),s=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!s)return!1;let c=s.range.startRow,l=s.range.startColumn,u=a.isVisible();return o.executeCommand(q.id,{unitId:i.unitId,subUnitId:i.subUnitId,row:c,col:l,type:u.visible?`editing`:`viewing`})}},X={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link-toolbar`,handler(e){if(G(e))return!1;let n=e.get(t.ICommandService);return e.get(U).currentEditing?n.executeCommand(J.id):n.executeCommand(Y.id)}},pe=`SHEET_HYPER_LINK_UI_PLUGIN`,Z=class extends t.Disposable{registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(t=>t(e))}constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._hyperLinkModel=t,this._injector=n,this._resolverService=r,k(this,`_plainTextFilter`,new Set),k(this,`_copyInfo`,void 0),this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:pe,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,i)=>{let{copyType:a=r.COPY_TYPE.COPY,pasteType:o}=i,{range:s}=e||{},{range:c,unitId:l,subUnitId:u}=t;return this._generateMutations(c,{copyType:a,pasteType:o,copyRange:s,unitId:l,subUnitId:u})},onPastePlainText:(e,n)=>{let i=this._filterPlainText(n);if(g(n)&&i){let{range:n,unitId:i,subUnitId:a}=e,{ranges:[o],mapFunc:s}=(0,r.virtualizeDiscreteRanges)([n]),c=[],l=[];return t.Range.foreach(o,(e,t)=>{let{row:n,col:r}=s(e,t),o=this._hyperLinkModel.getHyperLinkByLocation(i,a,n,r);o&&c.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:i,subUnitId:a,id:o.id}}),o&&l.push({id:d.AddHyperLinkMutation.id,params:{unitId:i,subUnitId:a,link:o}})}),{redos:c,undos:l}}return{undos:[],redos:[]}},priority:99})}_collect(e,r,i){let a=new t.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:r,matrix:a};let o=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!o)return;let{rows:s,cols:c}=o;s.forEach((t,n)=>{c.forEach((i,o)=>{let s=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,i);a.setValue(n,o,(s==null?void 0:s.id)??``)})})}_generateMutations(e,n){if(!this._copyInfo||!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange||[r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};let{unitId:i,subUnitId:a}=this._copyInfo,o=[],s=[],{ranges:[c,l],mapFunc:u}=(0,r.virtualizeDiscreteRanges)([n.copyRange,e]);return(0,r.getRepeatRange)(c,l,!0).forEach(({startRange:e})=>{var r;(r=this._copyInfo)==null||r.matrix.forValue((r,c,l)=>{let f=t.Rectangle.getPositionRange({startRow:r,endRow:r,startColumn:c,endColumn:c},e),p=this._hyperLinkModel.getHyperLink(i,a,l),{row:m,col:h}=u(f.startRow,f.startColumn),g=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,m,h),_=(0,t.generateRandomId)();g&&o.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:g.id}}),p&&(o.push({id:d.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...p,id:_,row:m,column:h}}}),s.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:_}})),g&&s.push({id:d.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:g}})})}),{redos:o,undos:s}}};Z=C([S(0,r.ISheetClipboardService),S(1,(0,t.Inject)(d.HyperLinkModel)),S(2,(0,t.Inject)(t.Injector)),S(3,(0,t.Inject)(T))],Z);let me=(e,i=t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)=>{var c;let l=e.get(t.IUniverInstanceService),u=(c=e.get(o.IRenderManagerService).getRenderUnitById(i))==null?void 0:c.with(a.DocSelectionRenderService);return u?u.textSelectionInner$.pipe((0,s.map)(()=>{let t=e.get(r.IEditorBridgeService).getEditCellState();if(!t)return!0;let i=(0,n.getSheetCommandTarget)(l,{unitId:t.unitId,subUnitId:t.sheetId});return!(i!=null&&i.worksheet)||W(e,i.worksheet,t.row,t.column)===1||K(e)})):(0,s.of)(!0)},Q=e=>{let i=e.get(t.IUniverInstanceService),a=e.has(r.IEditorBridgeService)?e.get(r.IEditorBridgeService):null;return((a==null?void 0:a.currentEditCellState$.pipe((0,s.map)(t=>{if(!t)return 1;let r=(0,n.getSheetCommandTarget)(i,{unitId:t.unitId,subUnitId:t.sheetId});return r?W(e,r.worksheet,t.row,t.column):1}),(0,s.switchMap)(n=>n===1?(0,s.of)(!0):(0,s.combineLatest)([a?a.visible$:(0,s.of)(null),i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC)]).pipe((0,s.switchMap)(([r,i])=>r!=null&&r.visible?(i==null?void 0:i.getUnitId())===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?(0,s.of)(!0):me(e,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):(0,s.of)(n!==0))))))??(0,s.of)(!0)).pipe((0,s.switchMap)(t=>t?(0,s.of)(!0):(0,r.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},!0)))},he=e=>({commandId:Y.id,type:f.MenuItemType.BUTTON,title:`sheets-hyper-link-ui.menu.add`,icon:`LinkIcon`,id:Y.id,hidden$:(0,f.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:Q(e)}),ge=e=>({tooltip:`sheets-hyper-link-ui.form.addTitle`,commandId:X.id,type:f.MenuItemType.BUTTON,icon:`LinkIcon`,id:X.id,hidden$:(0,f.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:Q(e)}),_e={id:X.id,binding:f.KeyCode.K|f.MetaKeys.CTRL_COMMAND,preconditions:r.whenSheetEditorFocused},ve={[f.RibbonInsertGroup.MEDIA]:{[X.id]:{order:1,gridLayout:{row:1,column:2,rowSpan:2,showLabel:!0},menuItemFactory:ge}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:1,[X.id]:{order:0,menuItemFactory:he}}}};var ye=`@univerjs/sheets-hyper-link-ui`,be=`1.0.0-beta.0`;let xe=class extends t.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,i)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,l=(0,r.virtualizeDiscreteRanges)([a,o]),[u,f]=l.ranges,{mapFunc:p}=l,m={row:u.startRow,col:u.startColumn},h=n.AutoFillTools.getAutoFillRepeatRange(u,f),g=[],_=[];return h.forEach(e=>{let r=e.repeatStartCell,a=e.relativeRange,o={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},l={startRow:r.row,startColumn:r.col,endColumn:r.col,endRow:r.row};t.Range.foreach(a,(e,r)=>{let a=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},o),{row:u,col:f}=p(a.startRow,a.startColumn),m=this._hyperLinkModel.getHyperLinkByLocation(s,c,u,f),h=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},l),{row:v,col:y}=p(h.startRow,h.startColumn),b=(0,t.generateRandomId)(),x=this._hyperLinkModel.getHyperLinkByLocation(s,c,v,y);x&&g.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:x.id}}),(n.AUTO_FILL_APPLY_TYPE.COPY===i||n.AUTO_FILL_APPLY_TYPE.SERIES===i)&&m&&(g.push({id:d.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{...m,id:b,row:v,column:y}}}),_.push({id:d.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:b}})),x&&_.push({id:d.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:x}})})}),{undos:_,redos:g}},a={id:pe,onFillData:(t,r,a)=>a===n.AUTO_FILL_APPLY_TYPE.COPY||a===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===n.AUTO_FILL_APPLY_TYPE.SERIES?i(t,a):e()};this.disposeWithMe(this._autoFillService.addHook(a))}};xe=C([S(0,n.IAutoFillService),S(1,(0,t.Inject)(d.HyperLinkModel))],xe);let Se=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[V.componentKey,V],[A.componentKey,A]].forEach(([e,t])=>{this._componentManager.register(e,t)})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:L}))}};Se=C([S(0,(0,t.Inject)(f.ComponentManager)),S(1,(0,t.Inject)(f.IconManager))],Se);let Ce=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===_e.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-hyper-link-ui.permission.hyperLinkErr`)))}))}};Ce=C([S(0,(0,t.Inject)(t.LocaleService)),S(1,t.ICommandService),S(2,(0,t.Inject)(n.SheetPermissionCheckController))],Ce);let we=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=s,this._univerInstanceService=c,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener()}_getLinkPermission(e){let{unitId:r,subUnitId:i,row:a,col:o}=e,s=this._univerInstanceService.getUnit(r,t.UniverInstanceType.UNIVER_SHEET),c=s==null?void 0:s.getSheetBySheetId(i);if(!c)return{viewPermission:!1,editPermission:!1,copyPermission:!1};let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookViewPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),d=c.getCellRaw(a,o);d!=null&&d.f&&d.f.startsWith(`=HYPERLINK(`)&&(u=!1);let f=this._permissionService.composePermission([new n.WorkbookCopyPermission(r).id,new n.WorksheetCopyPermission(r,i).id]).every(e=>e.value);return{viewPermission:l,editPermission:u,copyPermission:f}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe((0,s.debounceTime)(200)).subscribe(e=>{var n,i,a;if(!e||((n=e.customRange)==null?void 0:n.rangeType)!==t.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let{unitId:o,subUnitId:s,row:c,col:l}=e,u=this._renderManagerService.getRenderUnitById(o);if(!u)return;let d=this._univerInstanceService.getUnit(o,t.UniverInstanceType.UNIVER_SHEET),f=d==null?void 0:d.getSheetBySheetId(s);if(!f)return;if(!u.with(r.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(`viewing`);return}let p=u==null||(i=u.with(r.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:i.skeleton,m=l,h=c,g=h,_=m;p&&p.overflowCache.forValue((e,n,r)=>{t.Rectangle.contains(r,{startColumn:m,endColumn:m,startRow:h,endRow:h})&&(g=e,_=n)});let{viewPermission:v,editPermission:y,copyPermission:b}=this._getLinkPermission(e);if(!v){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let x=f.getCellStyleOnly(g,_),S=d.getStyles().getStyleByCell(x),C=S==null||(a=S.tr)==null?void 0:a.a;if(!C&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:g,col:_,editPermission:y,copyPermission:b,customRange:e.customRange,customRangeRect:e.rect,type:`viewing`,unitId:o,subUnitId:s,showAll:!!C})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe((0,s.switchMap)(e=>this._editorBridgeService.visible$.pipe((0,s.map)(t=>({visible:t,state:e}))))).subscribe(({visible:n,state:i})=>{if(!i||i.editorUnitId!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(`editing`),this._sheetsHyperLinkPopupService.endEditing(`editing`);return}let{editorUnitId:o,unitId:c,sheetId:l,row:u,column:d}=i,f=this._renderManagerService.getRenderUnitById(o);if(!f)return;let{editPermission:p,viewPermission:m,copyPermission:h}=this._getLinkPermission({unitId:c,subUnitId:l,row:u,col:d}),g=f.with(a.DocEventManagerService);m&&(e==null||e.unsubscribe(),e=g.hoverCustomRanges$.pipe((0,s.debounceTime)(200)).subscribe(e=>{var n;let i=e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK);if(!i){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let a=i.rects[i.rects.length-1];if(!((n=this._renderManagerService.getRenderUnitById(c))!=null&&(n=n.with(r.SheetSkeletonManagerService).getSkeletonParam(l))!=null&&n.skeleton)||!a)return;let o=f.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:c,subUnitId:l,row:u,col:d,customRange:i.range,customRangeRect:{left:a.left+o.left,top:a.top+o.top,bottom:a.bottom+o.top,right:a.right+o.left},editPermission:p,copyPermission:h,type:`editing`})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(`editing`)}))}_initCommandListener(){let e=[n.ClearSelectionContentCommand.id,n.ClearSelectionAllCommand.id,n.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};we=C([S(0,(0,t.Inject)(r.HoverManagerService)),S(1,(0,t.Inject)(U)),S(2,(0,t.Inject)(o.IRenderManagerService)),S(3,(0,t.Inject)(t.IPermissionService)),S(4,(0,t.Inject)(n.SheetPermissionCheckController)),S(5,t.ICommandService),S(6,r.IEditorBridgeService),S(7,(0,t.Inject)(i.DocSelectionManagerService)),S(8,t.IUniverInstanceService)],we);let Te=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._hyperLinkModel=t,this._initSkeletonChange()}_initSkeletonChange(){let e=()=>{var e;(e=this._context.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe((0,s.debounceTime)(16)).subscribe(()=>{e()}))}};Te=C([S(1,(0,t.Inject)(d.HyperLinkModel))],Te);let Ee=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortCut()}_initCommands(){[q,J,Y,X].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(ve)}_initShortCut(){this._shortcutService.registerShortcut(_e)}};Ee=C([S(0,t.ICommandService),S(1,f.IMenuManagerService),S(2,(0,t.Inject)(f.IShortcutService))],Ee);let De=class extends t.Disposable{constructor(e,t){super(),this._parserService=e,this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){let e=location.hash;if(e){let t=this._parserService.parseHyperLink(e);this._resolverService.navigate(t)}}};De=C([S(0,(0,t.Inject)(d.SheetsHyperLinkParserService)),S(1,(0,t.Inject)(T))],De);let $=class extends t.Plugin{constructor(e=x,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},x,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(b,a)}onStarting(){this._injector.add([Se]),this._injector.get(Se),[[T],[U],[ee],[we],[Ee],[xe],[Z],[Ce],[De]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(o.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[Te]),this._injector.get(xe),this._injector.get(Z),this._injector.get(Ee)}onRendered(){this._injector.get(Ce),this._injector.get(De),this._injector.get(we)}};k($,`pluginName`,pe),k($,`packageName`,ye),k($,`version`,be),k($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=C([(0,t.DependentOn)(i.UniverDocsPlugin,l.UniverFormulaEnginePlugin,o.UniverRenderEnginePlugin,n.UniverSheetsPlugin,a.UniverDocsUIPlugin,d.UniverSheetsHyperLinkPlugin,r.UniverSheetsUIPlugin),S(1,(0,t.Inject)(t.Injector)),S(2,t.IConfigService)],$),e.CloseHyperLinkPopupOperation=J,e.InsertHyperLinkOperation=Y,e.InsertLinkShortcut=_e,e.OpenHyperLinkEditPanelOperation=q,Object.defineProperty(e,"SheetsHyperLinkCopyPasteController",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"SheetsHyperLinkPopupService",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SheetsHyperLinkResolverService",{enumerable:!0,get:function(){return T}}),e.SheetsHyperLinkSidePanelService=ee,e.SheetsHyperLinkUIMenuSchema=ve,Object.defineProperty(e,"UniverSheetsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
|
package/lib/umd/locale/zh-HK.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsHyperLinkUiZhHK=t())})(this,function(){return{"sheets-hyper-link-ui":{form:{editTitle:`編輯連結`,addTitle:`插入連結`,label
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsHyperLinkUiZhHK=t())})(this,function(){return{"sheets-hyper-link-ui":{form:{editTitle:`編輯連結`,addTitle:`插入連結`,label:`文字`,labelPlaceholder:`輸入文字`,type:`類型`,link:`連結`,linkPlaceholder:`輸入連結位址`,range:`儲存格`,worksheet:`工作表`,definedName:`定義的名稱`,ok:`確認`,cancel:`取消`,inputError:`請輸入`,selectError:`請選擇`,linkError:`請輸入合法的連結`},menu:{add:`新增連結`},permission:{hyperLinkErr:`你沒有權限插入連結。`},message:{noSheet:`該子表已被刪除`,refError:`錯誤的引用`,hiddenSheet:`無法開啟被隱藏的子表`,coped:`連結已複製到剪貼簿`},popup:{copy:`複製`,edit:`編輯`,cancel:`取消連結`}}}});
|
package/lib/umd/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsHyperLinkUiZhTW=t())})(this,function(){return{"sheets-hyper-link-ui":{form:{editTitle:`編輯連結`,addTitle:`插入連結`,label
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsHyperLinkUiZhTW=t())})(this,function(){return{"sheets-hyper-link-ui":{form:{editTitle:`編輯連結`,addTitle:`插入連結`,label:`文字`,labelPlaceholder:`輸入文字`,type:`類型`,link:`連結`,linkPlaceholder:`輸入連結位址`,range:`儲存格`,worksheet:`工作表`,definedName:`定義的名稱`,ok:`確認`,cancel:`取消`,inputError:`請輸入`,selectError:`請選擇`,linkError:`請輸入合法的連結`},menu:{add:`新增連結`},permission:{hyperLinkErr:`你沒有權限插入連結。`},message:{noSheet:`該子表已被刪除`,refError:`錯誤的引用`,hiddenSheet:`無法開啟被隱藏的子表`,coped:`連結已複製到剪貼簿`},popup:{copy:`複製`,edit:`編輯`,cancel:`取消連結`}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link-ui",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Hyperlink editing UI for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -68,28 +68,28 @@
|
|
|
68
68
|
"rxjs": ">=7.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@univerjs/icons": "1.
|
|
72
|
-
"@univerjs/core": "1.0.0-
|
|
73
|
-
"@univerjs/design": "1.0.0-
|
|
74
|
-
"@univerjs/
|
|
75
|
-
"@univerjs/docs-ui": "1.0.0-
|
|
76
|
-
"@univerjs/
|
|
77
|
-
"@univerjs/engine-render": "1.0.0-
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/sheets-
|
|
80
|
-
"@univerjs/sheets-
|
|
81
|
-
"@univerjs/sheets-ui": "1.0.0-
|
|
82
|
-
"@univerjs/ui": "1.0.0-
|
|
83
|
-
"@univerjs/sheets-
|
|
71
|
+
"@univerjs/icons": "1.35.0",
|
|
72
|
+
"@univerjs/core": "1.0.0-beta.0",
|
|
73
|
+
"@univerjs/design": "1.0.0-beta.0",
|
|
74
|
+
"@univerjs/engine-formula": "1.0.0-beta.0",
|
|
75
|
+
"@univerjs/docs-ui": "1.0.0-beta.0",
|
|
76
|
+
"@univerjs/sheets": "1.0.0-beta.0",
|
|
77
|
+
"@univerjs/engine-render": "1.0.0-beta.0",
|
|
78
|
+
"@univerjs/docs": "1.0.0-beta.0",
|
|
79
|
+
"@univerjs/sheets-data-validation": "1.0.0-beta.0",
|
|
80
|
+
"@univerjs/sheets-hyper-link": "1.0.0-beta.0",
|
|
81
|
+
"@univerjs/sheets-formula-ui": "1.0.0-beta.0",
|
|
82
|
+
"@univerjs/ui": "1.0.0-beta.0",
|
|
83
|
+
"@univerjs/sheets-ui": "1.0.0-beta.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"postcss": "^8.5.
|
|
86
|
+
"postcss": "^8.5.25",
|
|
87
87
|
"react": "18.3.1",
|
|
88
88
|
"rxjs": "^7.8.2",
|
|
89
89
|
"tailwindcss": "3.4.18",
|
|
90
90
|
"typescript": "^6.0.3",
|
|
91
91
|
"vitest": "^4.1.10",
|
|
92
|
-
"@univerjs-infra/shared": "1.0.0-
|
|
92
|
+
"@univerjs-infra/shared": "1.0.0-beta.0"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
95
|
"test": "vitest run",
|