@univerjs/sheets-hyper-link-ui 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +295 -283
- package/lib/index.css +1 -1
- package/lib/types/common/util.d.ts +15 -2
- package/lib/types/controllers/menu.d.ts +2 -3
- package/lib/types/services/popup.service.d.ts +5 -5
- package/lib/types/utils/index.d.ts +4 -0
- package/lib/umd/index.js +2 -2
- package/package.json +22 -22
package/lib/es/index.js
CHANGED
|
@@ -2,19 +2,19 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, UniverInstanceType, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId,
|
|
5
|
+
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, UniverInstanceType, Tools, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, sequenceExecute, getBodySlice, isValidRange, Inject, LocaleService, RANGE_TYPE, Rectangle, IConfigService, Disposable, useDependency, IContextService, getOriginCellValue, createInternalEditorID, FOCUSING_SHEET, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Injector, DataValidationType, Range, ObjectMatrix, OnLifecycle, LifecycleStages, ThemeService, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, IPermissionService, DisposableCollection, Plugin, DependentOn } from "@univerjs/core";
|
|
6
6
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
7
|
-
import { addCustomRangeBySelectionFactory, deleteCustomRangeFactory, replaceSelectionFactory,
|
|
7
|
+
import { addCustomRangeBySelectionFactory, deleteCustomRangeFactory, replaceSelectionFactory, DocCanvasPopManagerService, DocEventManagerService, UniverDocsUIPlugin } from "@univerjs/docs-ui";
|
|
8
8
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
9
|
-
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorksheetActiveOperation,
|
|
9
|
+
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorksheetActiveOperation, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission, RangeProtectionPermissionEditPoint, RemoveSheetCommand, SheetInterceptorService, INTERCEPTOR_POINT, SetRangeValuesCommand, ClearSelectionContentCommand, ClearSelectionAllCommand, ClearSelectionFormatCommand, WorkbookViewPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, WorkbookCopyPermission, WorksheetCopyPermission, RefRangeService, handleDefaultRangeChangeWithEffectRefCommands } from "@univerjs/sheets";
|
|
10
10
|
import { HyperLinkModel, RemoveHyperLinkMutation, AddHyperLinkMutation, SheetHyperLinkType, ERROR_RANGE, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
11
11
|
import { SheetSkeletonManagerService, ScrollToRangeOperation, IEditorBridgeService, IMarkSelectionService, getEditingCustomRangePosition, getCustomRangePosition, SheetCanvasPopManagerService, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, whenSheetEditorFocused, getCurrentRangeDisable$, HoverRenderController, HoverManagerService, SheetPermissionInterceptorBaseController, APPLY_TYPE, IAutoFillService, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
|
|
12
|
-
import { Subject, BehaviorSubject, map, mergeMap, Observable, debounceTime } from "rxjs";
|
|
13
12
|
import { IMessageService, useObservable, IZenZoneService, useEvent, KeyCode, RangeSelector, IEditorService, IRangeSelectorService, MenuItemType, MenuPosition, MenuGroup, MetaKeys, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IShortcutService, IMenuManagerService } from "@univerjs/ui";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { MessageType,
|
|
13
|
+
import { Subject, BehaviorSubject, map, mergeMap, Observable, debounceTime } from "rxjs";
|
|
14
|
+
import require$$0, { useState, useMemo, useRef, useEffect, forwardRef, createElement } from "react";
|
|
15
|
+
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
17
16
|
import { deserializeRangeWithSheet, serializeRangeWithSheet, serializeRange, IDefinedNamesService, serializeRangeToRefString } from "@univerjs/engine-formula";
|
|
17
|
+
import cs from "clsx";
|
|
18
18
|
const AddHyperLinkCommand = {
|
|
19
19
|
type: CommandType.COMMAND,
|
|
20
20
|
id: "sheets.command.add-hyper-link",
|
|
@@ -29,7 +29,7 @@ const AddHyperLinkCommand = {
|
|
|
29
29
|
const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), skeleton = (_a15 = currentRender.with(SheetSkeletonManagerService).getCurrent()) == null ? void 0 : _a15.skeleton;
|
|
30
30
|
if (!worksheet || !skeleton)
|
|
31
31
|
return !1;
|
|
32
|
-
const { payload, display, row, column, id } = link, cellData = worksheet.getCell(row, column), doc = skeleton.getBlankCellDocumentModel(cellData), snapshot = doc.documentModel.getSnapshot(), body = snapshot.body;
|
|
32
|
+
const { payload, display, row, column, id } = link, cellData = worksheet.getCell(row, column), doc = skeleton.getBlankCellDocumentModel(cellData), snapshot = doc.documentModel.getSnapshot(), body = Tools.deepClone(snapshot.body);
|
|
33
33
|
if (!body)
|
|
34
34
|
return !1;
|
|
35
35
|
let textX;
|
|
@@ -262,7 +262,7 @@ const AddHyperLinkCommand = {
|
|
|
262
262
|
});
|
|
263
263
|
if (!replaceSelection)
|
|
264
264
|
return !1;
|
|
265
|
-
const newBody = TextX.apply(snapshot.body, replaceSelection.textX.serialize()), redo = {
|
|
265
|
+
const newBody = TextX.apply(Tools.deepClone(snapshot.body), replaceSelection.textX.serialize()), redo = {
|
|
266
266
|
id: SetRangeValuesMutation.id,
|
|
267
267
|
params: {
|
|
268
268
|
unitId,
|
|
@@ -343,7 +343,7 @@ const AddHyperLinkCommand = {
|
|
|
343
343
|
return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
|
|
344
344
|
}, "handler")
|
|
345
345
|
};
|
|
346
|
-
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
346
|
+
var HyperLinkEditSourceType = /* @__PURE__ */ ((HyperLinkEditSourceType2) => (HyperLinkEditSourceType2.EDITING = "editing", HyperLinkEditSourceType2.VIEWING = "viewing", HyperLinkEditSourceType2.ZEN_EDITOR = "zen_mode", HyperLinkEditSourceType2))(HyperLinkEditSourceType || {}), jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
347
347
|
/**
|
|
348
348
|
* @license React
|
|
349
349
|
* react-jsx-runtime.production.min.js
|
|
@@ -366,101 +366,33 @@ reactJsxRuntime_production_min.Fragment = l;
|
|
|
366
366
|
reactJsxRuntime_production_min.jsx = q;
|
|
367
367
|
reactJsxRuntime_production_min.jsxs = q;
|
|
368
368
|
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
369
|
-
var jsxRuntimeExports = jsxRuntime.exports
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
s = arguments[i];
|
|
373
|
-
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
|
|
374
|
-
}
|
|
375
|
-
return t;
|
|
376
|
-
}, __assign.apply(this, arguments);
|
|
377
|
-
}, __rest = function(s, e) {
|
|
378
|
-
var t = {};
|
|
379
|
-
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
|
|
380
|
-
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
381
|
-
for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
|
|
382
|
-
e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
|
|
383
|
-
return t;
|
|
384
|
-
}, IconBase = forwardRef(function(props, ref) {
|
|
385
|
-
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
386
|
-
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
387
|
-
});
|
|
388
|
-
function render(node, id, runtimeProps, rootProps, extend) {
|
|
389
|
-
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
390
|
-
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
391
|
-
}));
|
|
369
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
370
|
+
function isLegalLink(link) {
|
|
371
|
+
return Tools.isLegalUrl(link);
|
|
392
372
|
}
|
|
393
|
-
__name(
|
|
394
|
-
function
|
|
395
|
-
|
|
396
|
-
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
397
|
-
var defIds = runtimeProps.defIds;
|
|
398
|
-
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a15) {
|
|
399
|
-
var key = _a15[0], value = _a15[1];
|
|
400
|
-
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
401
|
-
})), attrs;
|
|
373
|
+
__name(isLegalLink, "isLegalLink");
|
|
374
|
+
function hasProtocol(urlString) {
|
|
375
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
402
376
|
}
|
|
403
|
-
__name(
|
|
404
|
-
function
|
|
405
|
-
|
|
406
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a15 = node.children) === null || _a15 === void 0) && _a15.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
407
|
-
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
408
|
-
}) }) : node;
|
|
377
|
+
__name(hasProtocol, "hasProtocol");
|
|
378
|
+
function isEmail(url) {
|
|
379
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
409
380
|
}
|
|
410
|
-
__name(
|
|
411
|
-
function
|
|
412
|
-
|
|
381
|
+
__name(isEmail, "isEmail");
|
|
382
|
+
function serializeUrl(urlStr) {
|
|
383
|
+
if (isLegalLink(urlStr)) {
|
|
384
|
+
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
|
|
385
|
+
let url;
|
|
386
|
+
try {
|
|
387
|
+
url = new URL(transformedUrl);
|
|
388
|
+
} catch {
|
|
389
|
+
return urlStr;
|
|
390
|
+
}
|
|
391
|
+
return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
|
|
392
|
+
}
|
|
393
|
+
return urlStr;
|
|
413
394
|
}
|
|
414
|
-
__name(
|
|
415
|
-
IconBase.displayName = "UniverIcon";
|
|
416
|
-
var element$5 = { tag: "svg", attrs: { 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" } }] }, AllBorderSingle = forwardRef(function(props, ref) {
|
|
417
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
418
|
-
id: "all-border-single",
|
|
419
|
-
ref,
|
|
420
|
-
icon: element$5
|
|
421
|
-
}));
|
|
422
|
-
});
|
|
423
|
-
AllBorderSingle.displayName = "AllBorderSingle";
|
|
424
|
-
var element$4 = { tag: "svg", attrs: { 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" } }] }, CopySingle = forwardRef(function(props, ref) {
|
|
425
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
426
|
-
id: "copy-single",
|
|
427
|
-
ref,
|
|
428
|
-
icon: element$4
|
|
429
|
-
}));
|
|
430
|
-
});
|
|
431
|
-
CopySingle.displayName = "CopySingle";
|
|
432
|
-
var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, LinkSingle = forwardRef(function(props, ref) {
|
|
433
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
434
|
-
id: "link-single",
|
|
435
|
-
ref,
|
|
436
|
-
icon: element$3
|
|
437
|
-
}));
|
|
438
|
-
});
|
|
439
|
-
LinkSingle.displayName = "LinkSingle";
|
|
440
|
-
var element$2 = { tag: "svg", attrs: { 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.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.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.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, UnlinkSingle = forwardRef(function(props, ref) {
|
|
441
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
442
|
-
id: "unlink-single",
|
|
443
|
-
ref,
|
|
444
|
-
icon: element$2
|
|
445
|
-
}));
|
|
446
|
-
});
|
|
447
|
-
UnlinkSingle.displayName = "UnlinkSingle";
|
|
448
|
-
var element$1 = { tag: "svg", attrs: { 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" } }] }, WriteSingle = forwardRef(function(props, ref) {
|
|
449
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
450
|
-
id: "write-single",
|
|
451
|
-
ref,
|
|
452
|
-
icon: element$1
|
|
453
|
-
}));
|
|
454
|
-
});
|
|
455
|
-
WriteSingle.displayName = "WriteSingle";
|
|
456
|
-
var element = { tag: "svg", attrs: { 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: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Xlsx = forwardRef(function(props, ref) {
|
|
457
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
458
|
-
id: "xlsx",
|
|
459
|
-
ref,
|
|
460
|
-
icon: element
|
|
461
|
-
}));
|
|
462
|
-
});
|
|
463
|
-
Xlsx.displayName = "Xlsx";
|
|
395
|
+
__name(serializeUrl, "serializeUrl");
|
|
464
396
|
const PLUGIN_CONFIG_KEY = "sheets-hyper-link-ui.config", defaultPluginConfig = {};
|
|
465
397
|
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
466
398
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -530,7 +462,7 @@ let SheetsHyperLinkResolverService = (_a = class {
|
|
|
530
462
|
}
|
|
531
463
|
}
|
|
532
464
|
buildHyperLink(unitId, sheetId, range) {
|
|
533
|
-
return `#${SheetHyperLinkType.SHEET}=${sheetId}
|
|
465
|
+
return `#${SheetHyperLinkType.SHEET}=${sheetId}${range ? `&${typeof range == "string" ? SheetHyperLinkType.DEFINE_NAME : SheetHyperLinkType.RANGE}=${typeof range == "string" ? range : serializeRange(range)}` : ""}`;
|
|
534
466
|
}
|
|
535
467
|
parseHyperLink(urlStr) {
|
|
536
468
|
var _a15, _b, _c, _d;
|
|
@@ -637,145 +569,6 @@ SheetsHyperLinkResolverService = __decorateClass$c([
|
|
|
637
569
|
__decorateParam$c(4, Inject(LocaleService)),
|
|
638
570
|
__decorateParam$c(5, IConfigService)
|
|
639
571
|
], SheetsHyperLinkResolverService);
|
|
640
|
-
var HyperLinkEditSourceType = /* @__PURE__ */ ((HyperLinkEditSourceType2) => (HyperLinkEditSourceType2.EDITING = "editing", HyperLinkEditSourceType2.VIEWING = "viewing", HyperLinkEditSourceType2.ZEN_EDITOR = "zen_mode", HyperLinkEditSourceType2))(HyperLinkEditSourceType || {});
|
|
641
|
-
const cellLink = "univer-cell-link", cellLinkType = "univer-cell-link-type", cellLinkContent = "univer-cell-link-content", cellLinkContentError = "univer-cell-link-content-error", cellLinkUrl = "univer-cell-link-url", cellLinkOperations = "univer-cell-link-operations", cellLinkOperation = "univer-cell-link-operation", cellLinkOperationError = "univer-cell-link-operation-error", styles$1 = {
|
|
642
|
-
cellLink,
|
|
643
|
-
cellLinkType,
|
|
644
|
-
cellLinkContent,
|
|
645
|
-
cellLinkContentError,
|
|
646
|
-
cellLinkUrl,
|
|
647
|
-
cellLinkOperations,
|
|
648
|
-
cellLinkOperation,
|
|
649
|
-
cellLinkOperationError
|
|
650
|
-
}, iconsMap = {
|
|
651
|
-
[SheetHyperLinkType.URL]: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
|
|
652
|
-
[SheetHyperLinkType.SHEET]: /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {}),
|
|
653
|
-
[SheetHyperLinkType.RANGE]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
654
|
-
[SheetHyperLinkType.DEFINE_NAME]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
655
|
-
[SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {})
|
|
656
|
-
}, CellLinkPopup = /* @__PURE__ */ __name(() => {
|
|
657
|
-
var _a15, _b;
|
|
658
|
-
const popupService = useDependency(SheetsHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), [currentPopup, setCurrentPopup] = useState(null), resolverService = useDependency(SheetsHyperLinkResolverService), editorBridgeService = useDependency(IEditorBridgeService);
|
|
659
|
-
if (useEffect(() => {
|
|
660
|
-
setCurrentPopup(popupService.currentPopup);
|
|
661
|
-
const ob = popupService.currentPopup$.subscribe((popup) => {
|
|
662
|
-
setCurrentPopup(popup);
|
|
663
|
-
});
|
|
664
|
-
return () => {
|
|
665
|
-
ob.unsubscribe();
|
|
666
|
-
};
|
|
667
|
-
}, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
|
|
668
|
-
return null;
|
|
669
|
-
const { unitId, subUnitId, customRange, row, col } = currentPopup;
|
|
670
|
-
if (!((_a15 = customRange == null ? void 0 : customRange.properties) != null && _a15.url))
|
|
671
|
-
return null;
|
|
672
|
-
const linkObj = resolverService.parseHyperLink((_b = customRange.properties.url) != null ? _b : ""), isError = linkObj.type === SheetHyperLinkType.INVALID;
|
|
673
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
|
|
674
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cs(styles$1.cellLinkContent, { [styles$1.cellLinkContentError]: isError }), onClick: linkObj.handler, children: [
|
|
675
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.cellLinkType, children: iconsMap[linkObj.type] }),
|
|
676
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles$1.cellLinkUrl, children: linkObj.name }) })
|
|
677
|
-
] }),
|
|
678
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkOperations, children: [
|
|
679
|
-
currentPopup.copyPermission && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
680
|
-
"div",
|
|
681
|
-
{
|
|
682
|
-
className: cs(styles$1.cellLinkOperation, { [styles$1.cellLinkOperationError]: isError }),
|
|
683
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
684
|
-
if (!isError) {
|
|
685
|
-
if (linkObj.type !== SheetHyperLinkType.URL) {
|
|
686
|
-
const url = new URL(window.location.href);
|
|
687
|
-
url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
|
|
688
|
-
} else
|
|
689
|
-
navigator.clipboard.writeText(linkObj.url);
|
|
690
|
-
messageService.show({
|
|
691
|
-
content: localeService.t("hyperLink.message.coped"),
|
|
692
|
-
type: MessageType.Info
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
}, "onClick"),
|
|
696
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
|
|
697
|
-
}
|
|
698
|
-
),
|
|
699
|
-
currentPopup.editPermission && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
700
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
701
|
-
"div",
|
|
702
|
-
{
|
|
703
|
-
className: styles$1.cellLinkOperation,
|
|
704
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
705
|
-
commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
|
|
706
|
-
unitId,
|
|
707
|
-
subUnitId,
|
|
708
|
-
row,
|
|
709
|
-
col,
|
|
710
|
-
customRangeId: customRange.rangeId,
|
|
711
|
-
type: currentPopup.type
|
|
712
|
-
});
|
|
713
|
-
}, "onClick"),
|
|
714
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
|
|
715
|
-
}
|
|
716
|
-
),
|
|
717
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
718
|
-
"div",
|
|
719
|
-
{
|
|
720
|
-
className: styles$1.cellLinkOperation,
|
|
721
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
722
|
-
const commandId = currentPopup.type === HyperLinkEditSourceType.EDITING || currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? CancelRichHyperLinkCommand.id : CancelHyperLinkCommand.id;
|
|
723
|
-
commandService.syncExecuteCommand(commandId, {
|
|
724
|
-
unitId,
|
|
725
|
-
subUnitId,
|
|
726
|
-
id: customRange.rangeId,
|
|
727
|
-
row,
|
|
728
|
-
column: col,
|
|
729
|
-
documentId: currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
|
|
730
|
-
}) && popupService.hideCurrentPopup(void 0, !0);
|
|
731
|
-
}, "onClick"),
|
|
732
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
|
|
733
|
-
}
|
|
734
|
-
)
|
|
735
|
-
] })
|
|
736
|
-
] })
|
|
737
|
-
] });
|
|
738
|
-
}, "CellLinkPopup");
|
|
739
|
-
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
740
|
-
function isLegalLink(link) {
|
|
741
|
-
return Tools.isLegalUrl(link);
|
|
742
|
-
}
|
|
743
|
-
__name(isLegalLink, "isLegalLink");
|
|
744
|
-
function hasProtocol(urlString) {
|
|
745
|
-
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
746
|
-
}
|
|
747
|
-
__name(hasProtocol, "hasProtocol");
|
|
748
|
-
function isEmail(url) {
|
|
749
|
-
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
750
|
-
}
|
|
751
|
-
__name(isEmail, "isEmail");
|
|
752
|
-
function serializeUrl(urlStr) {
|
|
753
|
-
if (isLegalLink(urlStr)) {
|
|
754
|
-
const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
|
|
755
|
-
let url;
|
|
756
|
-
try {
|
|
757
|
-
url = new URL(transformedUrl);
|
|
758
|
-
} catch {
|
|
759
|
-
return urlStr;
|
|
760
|
-
}
|
|
761
|
-
return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
|
|
762
|
-
}
|
|
763
|
-
return urlStr;
|
|
764
|
-
}
|
|
765
|
-
__name(serializeUrl, "serializeUrl");
|
|
766
|
-
function getCellValueOrigin(cell) {
|
|
767
|
-
if (cell === null)
|
|
768
|
-
return "";
|
|
769
|
-
if (cell != null && cell.p) {
|
|
770
|
-
const body = cell == null ? void 0 : cell.p.body;
|
|
771
|
-
if (body == null)
|
|
772
|
-
return "";
|
|
773
|
-
const data = body.dataStream;
|
|
774
|
-
return data.substring(data.length - 2, data.length) === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data;
|
|
775
|
-
}
|
|
776
|
-
return cell == null ? void 0 : cell.v;
|
|
777
|
-
}
|
|
778
|
-
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
779
572
|
const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
|
|
780
573
|
constructor() {
|
|
781
574
|
super(...arguments);
|
|
@@ -806,7 +599,7 @@ const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService
|
|
|
806
599
|
};
|
|
807
600
|
__name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
|
|
808
601
|
let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
|
|
809
|
-
const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell-link-edit-buttons", styles = {
|
|
602
|
+
const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
|
|
810
603
|
cellLinkEdit,
|
|
811
604
|
cellLinkEditButtons
|
|
812
605
|
}, CellLinkEdit = /* @__PURE__ */ __name(() => {
|
|
@@ -832,7 +625,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
832
625
|
const workbook2 = univerInstanceService.getUnit(editing.unitId), worksheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(editing.subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(editing.row, editing.col), range = (_f = (_e = (_d = cell == null ? void 0 : cell.p) == null ? void 0 : _d.body) == null ? void 0 : _e.customRanges) == null ? void 0 : _f.find((range2) => {
|
|
833
626
|
var _a17;
|
|
834
627
|
return range2.rangeType === CustomRangeType.HYPERLINK && ((_a17 = range2.properties) == null ? void 0 : _a17.url);
|
|
835
|
-
}), cellValue = `${(_g =
|
|
628
|
+
}), cellValue = `${(_g = getOriginCellValue(cell)) != null ? _g : ""}`;
|
|
836
629
|
cell && (cell.p || cellValue) && setShowLabel(!1), link = {
|
|
837
630
|
id: "",
|
|
838
631
|
display: "",
|
|
@@ -1006,7 +799,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
1006
799
|
}
|
|
1007
800
|
commandService.executeCommand(CloseHyperLinkPopupOperation.id);
|
|
1008
801
|
}, "handleSubmit");
|
|
1009
|
-
return editing ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkEdit, style: { display: hide ? "none" : "block" }, children: [
|
|
802
|
+
return editing ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEdit, style: { display: hide ? "none" : "block" }, children: [
|
|
1010
803
|
showLabel ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1011
804
|
FormLayout,
|
|
1012
805
|
{
|
|
@@ -1116,7 +909,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
1116
909
|
setPayload
|
|
1117
910
|
}
|
|
1118
911
|
),
|
|
1119
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkEditButtons, children: [
|
|
912
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
|
|
1120
913
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1121
914
|
Button,
|
|
1122
915
|
{
|
|
@@ -1141,6 +934,200 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
1141
934
|
] }) : null;
|
|
1142
935
|
}, "CellLinkEdit");
|
|
1143
936
|
CellLinkEdit.componentKey = "univer.sheet.cell-link-edit";
|
|
937
|
+
var __assign = function() {
|
|
938
|
+
return __assign = Object.assign || function(t) {
|
|
939
|
+
for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
|
|
940
|
+
s = arguments[i];
|
|
941
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
|
|
942
|
+
}
|
|
943
|
+
return t;
|
|
944
|
+
}, __assign.apply(this, arguments);
|
|
945
|
+
}, __rest = function(s, e) {
|
|
946
|
+
var t = {};
|
|
947
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
|
|
948
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
949
|
+
for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
|
|
950
|
+
e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
|
|
951
|
+
return t;
|
|
952
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
953
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
954
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
955
|
+
});
|
|
956
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
957
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
958
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
959
|
+
}));
|
|
960
|
+
}
|
|
961
|
+
__name(render, "render");
|
|
962
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
963
|
+
var attrs = __assign({}, node.attrs);
|
|
964
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
965
|
+
var defIds = runtimeProps.defIds;
|
|
966
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a15) {
|
|
967
|
+
var key = _a15[0], value = _a15[1];
|
|
968
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
969
|
+
})), attrs;
|
|
970
|
+
}
|
|
971
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
972
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
973
|
+
var _a15, defIds = runtimeProps.defIds;
|
|
974
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a15 = node.children) === null || _a15 === void 0) && _a15.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
975
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
976
|
+
}) }) : node;
|
|
977
|
+
}
|
|
978
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
979
|
+
function generateShortUuid() {
|
|
980
|
+
return Math.random().toString(36).substring(2, 8);
|
|
981
|
+
}
|
|
982
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
983
|
+
IconBase.displayName = "UniverIcon";
|
|
984
|
+
var element$5 = { tag: "svg", attrs: { 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" } }] }, AllBorderSingle = forwardRef(function(props, ref) {
|
|
985
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
986
|
+
id: "all-border-single",
|
|
987
|
+
ref,
|
|
988
|
+
icon: element$5
|
|
989
|
+
}));
|
|
990
|
+
});
|
|
991
|
+
AllBorderSingle.displayName = "AllBorderSingle";
|
|
992
|
+
var element$4 = { tag: "svg", attrs: { 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" } }] }, CopySingle = forwardRef(function(props, ref) {
|
|
993
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
994
|
+
id: "copy-single",
|
|
995
|
+
ref,
|
|
996
|
+
icon: element$4
|
|
997
|
+
}));
|
|
998
|
+
});
|
|
999
|
+
CopySingle.displayName = "CopySingle";
|
|
1000
|
+
var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332", fillRule: "evenodd", clipRule: "evenodd" } }] }, LinkSingle = forwardRef(function(props, ref) {
|
|
1001
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
1002
|
+
id: "link-single",
|
|
1003
|
+
ref,
|
|
1004
|
+
icon: element$3
|
|
1005
|
+
}));
|
|
1006
|
+
});
|
|
1007
|
+
LinkSingle.displayName = "LinkSingle";
|
|
1008
|
+
var element$2 = { tag: "svg", attrs: { 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.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.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.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, UnlinkSingle = forwardRef(function(props, ref) {
|
|
1009
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
1010
|
+
id: "unlink-single",
|
|
1011
|
+
ref,
|
|
1012
|
+
icon: element$2
|
|
1013
|
+
}));
|
|
1014
|
+
});
|
|
1015
|
+
UnlinkSingle.displayName = "UnlinkSingle";
|
|
1016
|
+
var element$1 = { tag: "svg", attrs: { 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" } }] }, WriteSingle = forwardRef(function(props, ref) {
|
|
1017
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
1018
|
+
id: "write-single",
|
|
1019
|
+
ref,
|
|
1020
|
+
icon: element$1
|
|
1021
|
+
}));
|
|
1022
|
+
});
|
|
1023
|
+
WriteSingle.displayName = "WriteSingle";
|
|
1024
|
+
var element = { tag: "svg", attrs: { 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: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Xlsx = forwardRef(function(props, ref) {
|
|
1025
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
1026
|
+
id: "xlsx",
|
|
1027
|
+
ref,
|
|
1028
|
+
icon: element
|
|
1029
|
+
}));
|
|
1030
|
+
});
|
|
1031
|
+
Xlsx.displayName = "Xlsx";
|
|
1032
|
+
const cellLink = "univer-cell-link", cellLinkType = "univer-cell-link-type", cellLinkContent = "univer-cell-link-content", cellLinkContentError = "univer-cell-link-content-error", cellLinkUrl = "univer-cell-link-url", cellLinkOperations = "univer-cell-link-operations", cellLinkOperation = "univer-cell-link-operation", cellLinkOperationError = "univer-cell-link-operation-error", styles = {
|
|
1033
|
+
cellLink,
|
|
1034
|
+
cellLinkType,
|
|
1035
|
+
cellLinkContent,
|
|
1036
|
+
cellLinkContentError,
|
|
1037
|
+
cellLinkUrl,
|
|
1038
|
+
cellLinkOperations,
|
|
1039
|
+
cellLinkOperation,
|
|
1040
|
+
cellLinkOperationError
|
|
1041
|
+
}, iconsMap = {
|
|
1042
|
+
[SheetHyperLinkType.URL]: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkSingle, {}),
|
|
1043
|
+
[SheetHyperLinkType.SHEET]: /* @__PURE__ */ jsxRuntimeExports.jsx(Xlsx, {}),
|
|
1044
|
+
[SheetHyperLinkType.RANGE]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
1045
|
+
[SheetHyperLinkType.DEFINE_NAME]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {}),
|
|
1046
|
+
[SheetHyperLinkType.INVALID]: /* @__PURE__ */ jsxRuntimeExports.jsx(AllBorderSingle, {})
|
|
1047
|
+
}, CellLinkPopup = /* @__PURE__ */ __name(() => {
|
|
1048
|
+
var _a15, _b;
|
|
1049
|
+
const popupService = useDependency(SheetsHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), [currentPopup, setCurrentPopup] = useState(null), resolverService = useDependency(SheetsHyperLinkResolverService), editorBridgeService = useDependency(IEditorBridgeService);
|
|
1050
|
+
if (useEffect(() => {
|
|
1051
|
+
setCurrentPopup(popupService.currentPopup);
|
|
1052
|
+
const ob = popupService.currentPopup$.subscribe((popup) => {
|
|
1053
|
+
setCurrentPopup(popup);
|
|
1054
|
+
});
|
|
1055
|
+
return () => {
|
|
1056
|
+
ob.unsubscribe();
|
|
1057
|
+
};
|
|
1058
|
+
}, [popupService.currentPopup, popupService.currentPopup$]), !currentPopup)
|
|
1059
|
+
return null;
|
|
1060
|
+
const { unitId, subUnitId, customRange, row, col } = currentPopup;
|
|
1061
|
+
if (!((_a15 = customRange == null ? void 0 : customRange.properties) != null && _a15.url))
|
|
1062
|
+
return null;
|
|
1063
|
+
const linkObj = resolverService.parseHyperLink((_b = customRange.properties.url) != null ? _b : ""), isError = linkObj.type === SheetHyperLinkType.INVALID;
|
|
1064
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLink, onClick: /* @__PURE__ */ __name(() => popupService.hideCurrentPopup(), "onClick"), children: [
|
|
1065
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cs(styles.cellLinkContent, { [styles.cellLinkContentError]: isError }), onClick: linkObj.handler, children: [
|
|
1066
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.cellLinkType, children: iconsMap[linkObj.type] }),
|
|
1067
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { showIfEllipsis: !0, title: linkObj.name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles.cellLinkUrl, children: linkObj.name }) })
|
|
1068
|
+
] }),
|
|
1069
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.cellLinkOperations, children: [
|
|
1070
|
+
currentPopup.copyPermission && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1071
|
+
"div",
|
|
1072
|
+
{
|
|
1073
|
+
className: cs(styles.cellLinkOperation, { [styles.cellLinkOperationError]: isError }),
|
|
1074
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
1075
|
+
if (!isError) {
|
|
1076
|
+
if (linkObj.type !== SheetHyperLinkType.URL) {
|
|
1077
|
+
const url = new URL(window.location.href);
|
|
1078
|
+
url.hash = linkObj.url.slice(1), navigator.clipboard.writeText(url.href);
|
|
1079
|
+
} else
|
|
1080
|
+
navigator.clipboard.writeText(linkObj.url);
|
|
1081
|
+
messageService.show({
|
|
1082
|
+
content: localeService.t("hyperLink.message.coped"),
|
|
1083
|
+
type: MessageType.Info
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
}, "onClick"),
|
|
1087
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.copy"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopySingle, {}) })
|
|
1088
|
+
}
|
|
1089
|
+
),
|
|
1090
|
+
currentPopup.editPermission && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1091
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1092
|
+
"div",
|
|
1093
|
+
{
|
|
1094
|
+
className: styles.cellLinkOperation,
|
|
1095
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
1096
|
+
commandService.executeCommand(OpenHyperLinkEditPanelOperation.id, {
|
|
1097
|
+
unitId,
|
|
1098
|
+
subUnitId,
|
|
1099
|
+
row,
|
|
1100
|
+
col,
|
|
1101
|
+
customRangeId: customRange.rangeId,
|
|
1102
|
+
type: currentPopup.type
|
|
1103
|
+
});
|
|
1104
|
+
}, "onClick"),
|
|
1105
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.edit"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteSingle, {}) })
|
|
1106
|
+
}
|
|
1107
|
+
),
|
|
1108
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1109
|
+
"div",
|
|
1110
|
+
{
|
|
1111
|
+
className: styles.cellLinkOperation,
|
|
1112
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
1113
|
+
const commandId = currentPopup.type === HyperLinkEditSourceType.EDITING || currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? CancelRichHyperLinkCommand.id : CancelHyperLinkCommand.id;
|
|
1114
|
+
commandService.syncExecuteCommand(commandId, {
|
|
1115
|
+
unitId,
|
|
1116
|
+
subUnitId,
|
|
1117
|
+
id: customRange.rangeId,
|
|
1118
|
+
row,
|
|
1119
|
+
column: col,
|
|
1120
|
+
documentId: currentPopup.type === HyperLinkEditSourceType.ZEN_EDITOR ? DOCS_ZEN_EDITOR_UNIT_ID_KEY : editorBridgeService.getCurrentEditorId()
|
|
1121
|
+
}) && popupService.hideCurrentPopup(void 0, !0);
|
|
1122
|
+
}, "onClick"),
|
|
1123
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { placement: "bottom", title: localeService.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(UnlinkSingle, {}) })
|
|
1124
|
+
}
|
|
1125
|
+
)
|
|
1126
|
+
] })
|
|
1127
|
+
] })
|
|
1128
|
+
] });
|
|
1129
|
+
}, "CellLinkPopup");
|
|
1130
|
+
CellLinkPopup.componentKey = "univer.sheet.cell-link-popup";
|
|
1144
1131
|
var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1145
1132
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1146
1133
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -1232,7 +1219,7 @@ let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
|
1232
1219
|
startOffset: 0,
|
|
1233
1220
|
endOffset: body.dataStream.length - 2,
|
|
1234
1221
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1235
|
-
label:
|
|
1222
|
+
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1236
1223
|
};
|
|
1237
1224
|
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithRange(textRange, (_c = (_b = body.customRanges) == null ? void 0 : _b.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) != null ? _c : []);
|
|
1238
1225
|
let start = textRange.startOffset, end = textRange.endOffset;
|
|
@@ -1242,7 +1229,7 @@ let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
|
1242
1229
|
startOffset: start,
|
|
1243
1230
|
endOffset: end,
|
|
1244
1231
|
collapsed: start === end,
|
|
1245
|
-
label: getPlainText(body.dataStream.slice(start, end))
|
|
1232
|
+
label: BuildTextUtils.transform.getPlainText(body.dataStream.slice(start, end))
|
|
1246
1233
|
};
|
|
1247
1234
|
}
|
|
1248
1235
|
return null;
|
|
@@ -1259,7 +1246,7 @@ let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
|
1259
1246
|
};
|
|
1260
1247
|
}
|
|
1261
1248
|
startAddEditing(link) {
|
|
1262
|
-
var _a15, _b, _c;
|
|
1249
|
+
var _a15, _b, _c, _d, _e;
|
|
1263
1250
|
const { unitId, subUnitId, type } = link;
|
|
1264
1251
|
if (type === HyperLinkEditSourceType.ZEN_EDITOR) {
|
|
1265
1252
|
const document = this._univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
|
|
@@ -1301,7 +1288,7 @@ let SheetsHyperLinkPopupService = (_a2 = class extends Disposable {
|
|
|
1301
1288
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId), cell = worksheet == null ? void 0 : worksheet.getCellRaw(link.row, link.col);
|
|
1302
1289
|
this._currentEditing$.next({
|
|
1303
1290
|
...link,
|
|
1304
|
-
label: cell != null && cell.p ?
|
|
1291
|
+
label: cell != null && cell.p ? BuildTextUtils.transform.getPlainText((_d = (_c = cell.p.body) == null ? void 0 : _c.dataStream) != null ? _d : "") : ((_e = cell == null ? void 0 : cell.v) != null ? _e : "").toString()
|
|
1305
1292
|
});
|
|
1306
1293
|
}
|
|
1307
1294
|
}
|
|
@@ -1377,7 +1364,45 @@ SheetsHyperLinkPopupService = __decorateClass$b([
|
|
|
1377
1364
|
__decorateParam$b(7, IRangeSelectorService),
|
|
1378
1365
|
__decorateParam$b(8, IZenZoneService)
|
|
1379
1366
|
], SheetsHyperLinkPopupService);
|
|
1380
|
-
const
|
|
1367
|
+
const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) => {
|
|
1368
|
+
const cell = worksheet.getCell(row, col);
|
|
1369
|
+
if (cell != null && cell.f || cell != null && cell.si)
|
|
1370
|
+
return !0;
|
|
1371
|
+
const disables = [
|
|
1372
|
+
DataValidationType.CHECKBOX,
|
|
1373
|
+
DataValidationType.LIST,
|
|
1374
|
+
DataValidationType.LIST_MULTIPLE
|
|
1375
|
+
];
|
|
1376
|
+
return !!(cell != null && cell.dataValidation && disables.includes(cell.dataValidation.rule.type));
|
|
1377
|
+
}, "getShouldDisableCellLink"), getShouldDisableCurrentCellLink = /* @__PURE__ */ __name((accessor) => {
|
|
1378
|
+
const unit = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1379
|
+
if (!unit)
|
|
1380
|
+
return !0;
|
|
1381
|
+
const worksheet = unit.getActiveSheet(), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
1382
|
+
if (!selections.length)
|
|
1383
|
+
return !0;
|
|
1384
|
+
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1385
|
+
return getShouldDisableCellLink(worksheet, row, col);
|
|
1386
|
+
}, "getShouldDisableCurrentCellLink"), shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
1387
|
+
var _a15;
|
|
1388
|
+
const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getDocRanges();
|
|
1389
|
+
if (!textRanges.length || textRanges.length > 1)
|
|
1390
|
+
return !0;
|
|
1391
|
+
const activeRange = textRanges[0], doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
1392
|
+
if (!doc || !activeRange || activeRange.collapsed)
|
|
1393
|
+
return !0;
|
|
1394
|
+
const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(), paragraphs = body == null ? void 0 : body.paragraphs;
|
|
1395
|
+
if (!paragraphs)
|
|
1396
|
+
return !0;
|
|
1397
|
+
for (let i = 0, len = paragraphs.length; i < len; i++) {
|
|
1398
|
+
const p2 = paragraphs[i];
|
|
1399
|
+
if (activeRange.startOffset <= p2.startIndex && activeRange.endOffset > p2.startIndex)
|
|
1400
|
+
return !0;
|
|
1401
|
+
if (p2.startIndex > activeRange.endOffset)
|
|
1402
|
+
break;
|
|
1403
|
+
}
|
|
1404
|
+
return !BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange, (_a15 = body.customRanges) != null ? _a15 : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
|
|
1405
|
+
}, "shouldDisableAddLink"), OpenHyperLinkEditPanelOperation = {
|
|
1381
1406
|
type: CommandType.OPERATION,
|
|
1382
1407
|
id: "sheet.operation.open-hyper-link-edit-panel",
|
|
1383
1408
|
handler(accessor, params) {
|
|
@@ -1416,6 +1441,8 @@ const OpenHyperLinkEditPanelOperation = {
|
|
|
1416
1441
|
type: CommandType.OPERATION,
|
|
1417
1442
|
id: "sheet.operation.insert-hyper-link-toolbar",
|
|
1418
1443
|
handler(accessor) {
|
|
1444
|
+
if (getShouldDisableCurrentCellLink(accessor))
|
|
1445
|
+
return !1;
|
|
1419
1446
|
const commandService = accessor.get(ICommandService);
|
|
1420
1447
|
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkPopupOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
1421
1448
|
}
|
|
@@ -1585,41 +1612,26 @@ const getLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
|
1585
1612
|
const { selections, sheet } = sheetWithSelection;
|
|
1586
1613
|
if (!selections.length)
|
|
1587
1614
|
return !0;
|
|
1588
|
-
const row = selections[0].range.startRow, col = selections[0].range.startColumn
|
|
1589
|
-
|
|
1590
|
-
return !0;
|
|
1591
|
-
const disables = [
|
|
1592
|
-
DataValidationType.CHECKBOX,
|
|
1593
|
-
DataValidationType.LIST,
|
|
1594
|
-
DataValidationType.LIST_MULTIPLE
|
|
1595
|
-
];
|
|
1596
|
-
return !!(cell != null && cell.dataValidation && disables.includes(cell.dataValidation.rule.type));
|
|
1615
|
+
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1616
|
+
return getShouldDisableCellLink(sheet, row, col);
|
|
1597
1617
|
})
|
|
1598
1618
|
);
|
|
1599
1619
|
return disableRange$.pipe(mergeMap((disableRange) => disableCell$.pipe(map((disableCell) => disableRange || disableCell))));
|
|
1600
|
-
}, "getLinkDisable$"),
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
if (p2.startIndex > activeRange.endOffset)
|
|
1616
|
-
break;
|
|
1617
|
-
}
|
|
1618
|
-
return !BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange, (_a15 = body.customRanges) != null ? _a15 : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
|
|
1619
|
-
}, "shouldDisableAddLink"), getZenLinkDisable$ = /* @__PURE__ */ __name((accessor) => accessor.get(IUniverInstanceService).focused$.pipe(
|
|
1620
|
-
mergeMap((focused) => !focused || focused !== DOCS_ZEN_EDITOR_UNIT_ID_KEY ? new Observable((sub) => sub.next(null)) : accessor.get(DocSelectionManagerService).textSelection$),
|
|
1621
|
-
map((selection) => !selection || selection.unitId !== DOCS_ZEN_EDITOR_UNIT_ID_KEY ? !0 : shouldDisableAddLink(accessor))
|
|
1622
|
-
), "getZenLinkDisable$"), linkMenu = {
|
|
1620
|
+
}, "getLinkDisable$"), getZenLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
1621
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1622
|
+
return univerInstanceService.focused$.pipe(
|
|
1623
|
+
mergeMap((focused) => !focused || focused !== DOCS_ZEN_EDITOR_UNIT_ID_KEY ? new Observable((sub) => sub.next(null)) : accessor.get(DocSelectionManagerService).textSelection$),
|
|
1624
|
+
map((selection) => {
|
|
1625
|
+
if (!selection || selection.unitId !== DOCS_ZEN_EDITOR_UNIT_ID_KEY)
|
|
1626
|
+
return !0;
|
|
1627
|
+
const state = accessor.get(IEditorBridgeService).getEditCellState();
|
|
1628
|
+
if (!state)
|
|
1629
|
+
return !0;
|
|
1630
|
+
const target = getSheetCommandTarget(univerInstanceService, { unitId: state.unitId, subUnitId: state.sheetId });
|
|
1631
|
+
return !(target != null && target.worksheet) || getShouldDisableCellLink(target.worksheet, state.row, state.column) ? !0 : shouldDisableAddLink(accessor);
|
|
1632
|
+
})
|
|
1633
|
+
);
|
|
1634
|
+
}, "getZenLinkDisable$"), linkMenu = {
|
|
1623
1635
|
commandId: InsertHyperLinkOperation.id,
|
|
1624
1636
|
type: MenuItemType.BUTTON,
|
|
1625
1637
|
positions: [MenuPosition.CONTEXT_MENU],
|
|
@@ -1874,7 +1886,7 @@ let SheetHyperLinkSetRangeController = (_a7 = class extends Disposable {
|
|
|
1874
1886
|
dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${cell.v}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
|
|
1875
1887
|
customRanges: [{
|
|
1876
1888
|
startIndex: 0,
|
|
1877
|
-
endIndex: cell.v.length,
|
|
1889
|
+
endIndex: cell.v.length + 1,
|
|
1878
1890
|
rangeId: generateRandomId(),
|
|
1879
1891
|
rangeType: CustomRangeType.HYPERLINK,
|
|
1880
1892
|
properties: {
|