@univerjs/sheets-hyper-link-ui 0.2.6 → 0.2.7

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/es/index.js CHANGED
@@ -8,7 +8,7 @@ import { RemoveHyperLinkMutation, AddHyperLinkMutation, HyperLinkModel, ERROR_RA
8
8
  import { SheetSkeletonManagerService, ScrollToRangeOperation, SheetCanvasPopManagerService, IEditorBridgeService, HoverManagerService, SheetPermissionInterceptorBaseController, whenSheetEditorFocused, getCurrentRangeDisable$, APPLY_TYPE, IAutoFillService, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService } from "@univerjs/sheets-ui";
9
9
  import { IRenderManagerService } from "@univerjs/engine-render";
10
10
  import { debounceTime, Subject, BehaviorSubject } from "rxjs";
11
- import require$$0, { forwardRef, useRef, createElement, useState, useEffect, useMemo } from "react";
11
+ import require$$0, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
12
12
  import cs from "clsx";
13
13
  import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
14
14
  import { IMessageService, useObservable, useEvent, RangeSelector, ISidebarService, KeyCode, MetaKeys, MenuItemType, MenuPosition, getMenuHiddenObservable, MenuGroup, ComponentManager, IShortcutService, IMenuService } from "@univerjs/ui";
@@ -131,6 +131,37 @@ SheetsHyperLinkRenderManagerController = __decorateClass$a([
131
131
  __decorateParam$a(1, Inject(HyperLinkModel)),
132
132
  __decorateParam$a(2, Inject(ThemeService))
133
133
  ], SheetsHyperLinkRenderManagerController);
134
+ var LinkType = /* @__PURE__ */ ((LinkType2) => (LinkType2.link = "link", LinkType2.range = "range", LinkType2.sheet = "gid", LinkType2.definedName = "rangeid", LinkType2))(LinkType || {});
135
+ const _SheetsHyperLinkSidePanelService = class _SheetsHyperLinkSidePanelService extends Disposable {
136
+ constructor() {
137
+ super(...arguments);
138
+ __publicField(this, "_customHyperLinks", /* @__PURE__ */ new Map());
139
+ }
140
+ isBuiltInLinkType(type) {
141
+ return !!LinkType[type];
142
+ }
143
+ getOptions() {
144
+ return Array.from(this._customHyperLinks.values()).map(({ option }) => option);
145
+ }
146
+ findCustomHyperLink(link) {
147
+ return Array.from(this._customHyperLinks.values()).find((item) => item.match(link));
148
+ }
149
+ registerCustomHyperLink(customHyperLink) {
150
+ this._customHyperLinks.set(customHyperLink.type, customHyperLink);
151
+ }
152
+ getCustomHyperLink(type) {
153
+ return this._customHyperLinks.get(type);
154
+ }
155
+ removeCustomHyperLink(type) {
156
+ const { _customHyperLinks } = this;
157
+ _customHyperLinks.delete(type);
158
+ }
159
+ dispose() {
160
+ super.dispose(), this._customHyperLinks.clear();
161
+ }
162
+ };
163
+ __name(_SheetsHyperLinkSidePanelService, "SheetsHyperLinkSidePanelService");
164
+ let SheetsHyperLinkSidePanelService = _SheetsHyperLinkSidePanelService;
134
165
  var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
135
166
  /**
136
167
  * @license React
@@ -266,8 +297,8 @@ function getContainRange(range, worksheet) {
266
297
  __name(getContainRange, "getContainRange");
267
298
  var _a4;
268
299
  let SheetsHyperLinkResolverService = (_a4 = class {
269
- constructor(_univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
270
- this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
300
+ constructor(_urlHandler, _univerInstanceService, _commandService, _definedNamesService, _messageService, _localeService) {
301
+ this._urlHandler = _urlHandler, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._definedNamesService = _definedNamesService, this._messageService = _messageService, this._localeService = _localeService;
271
302
  }
272
303
  _getURLName(params) {
273
304
  var _a14;
@@ -409,15 +440,18 @@ let SheetsHyperLinkResolverService = (_a4 = class {
409
440
  return this._definedNamesService.focusRange(unitId, rangeid), !0;
410
441
  }
411
442
  async navigateToOtherWebsite(url) {
443
+ var _a14;
444
+ if ((_a14 = this._urlHandler) != null && _a14.navigateToOtherWebsite)
445
+ return this._urlHandler.navigateToOtherWebsite(url);
412
446
  window.open(url, "_blank", "noopener noreferrer");
413
447
  }
414
448
  }, __name(_a4, "SheetsHyperLinkResolverService"), _a4);
415
449
  SheetsHyperLinkResolverService = __decorateClass$9([
416
- __decorateParam$9(0, IUniverInstanceService),
417
- __decorateParam$9(1, ICommandService),
418
- __decorateParam$9(2, IDefinedNamesService),
419
- __decorateParam$9(3, IMessageService),
420
- __decorateParam$9(4, Inject(LocaleService))
450
+ __decorateParam$9(1, IUniverInstanceService),
451
+ __decorateParam$9(2, ICommandService),
452
+ __decorateParam$9(3, IDefinedNamesService),
453
+ __decorateParam$9(4, IMessageService),
454
+ __decorateParam$9(5, Inject(LocaleService))
421
455
  ], SheetsHyperLinkResolverService);
422
456
  function isLegalLink(link) {
423
457
  return Tools.isLegalUrl(link);
@@ -433,7 +467,13 @@ function isEmail(url) {
433
467
  __name(isEmail, "isEmail");
434
468
  function serializeUrl(urlStr) {
435
469
  if (isLegalLink(urlStr)) {
436
- const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`, url = new URL(transformedUrl);
470
+ const transformedUrl = hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `http://${urlStr}`;
471
+ let url;
472
+ try {
473
+ url = new URL(transformedUrl);
474
+ } catch {
475
+ return urlStr;
476
+ }
437
477
  return url.hostname === location.hostname && url.port === location.port && url.protocol === location.protocol && url.pathname === location.pathname && url.hash && !url.search ? url.hash : transformedUrl;
438
478
  }
439
479
  return urlStr;
@@ -456,37 +496,36 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
456
496
  cellLinkEditButtons
457
497
  }, CellLinkEdit = /* @__PURE__ */ __name(() => {
458
498
  var _a14;
459
- const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(
460
- "link"
461
- /* link */
462
- ), [payload, setPayload] = useState(""), localeService = useDependency(LocaleService), definedNameService = useDependency(IDefinedNamesService), univerInstanceService = useDependency(IUniverInstanceService), popupService = useDependency(SheetsHyperLinkPopupService), editing = useObservable(popupService.currentEditing$), hyperLinkModel = useDependency(HyperLinkModel), resolverService = useDependency(SheetsHyperLinkResolverService), commandService = useDependency(ICommandService), [showError, setShowError] = useState(!1), setByPayload = useRef(!1);
499
+ const [id, setId] = useState(""), [display, setDisplay] = useState(""), [type, setType] = useState(LinkType.link), [payload, setPayload] = useState(""), localeService = useDependency(LocaleService), definedNameService = useDependency(IDefinedNamesService), univerInstanceService = useDependency(IUniverInstanceService), popupService = useDependency(SheetsHyperLinkPopupService), editing = useObservable(popupService.currentEditing$), hyperLinkModel = useDependency(HyperLinkModel), resolverService = useDependency(SheetsHyperLinkResolverService), commandService = useDependency(ICommandService), sidePanelService = useDependency(SheetsHyperLinkSidePanelService), sidePanelOptions = useMemo(() => sidePanelService.getOptions(), [sidePanelService]), customHyperLinkSidePanel = useMemo(() => {
500
+ if (!sidePanelService.isBuiltInLinkType(type))
501
+ return sidePanelService.getCustomHyperLink(type);
502
+ }, [sidePanelService, type]), [showError, setShowError] = useState(!1), setByPayload = useRef(!1);
463
503
  useEffect(() => {
464
504
  var _a15, _b, _c;
465
505
  if ((editing == null ? void 0 : editing.row) !== void 0 && editing.column !== void 0) {
466
506
  const link = hyperLinkModel.getHyperLinkByLocationSync(editing.unitId, editing.subUnitId, editing.row, editing.column);
467
507
  if (link) {
508
+ setId(link.id);
509
+ const customLink = sidePanelService.findCustomHyperLink(link);
510
+ if (customLink) {
511
+ const customLinkInfo = customLink.convert(link);
512
+ setType(customLinkInfo.type), setPayload(customLinkInfo.payload), setDisplay(customLinkInfo.display);
513
+ return;
514
+ }
515
+ setDisplay(link.display);
468
516
  const linkInfo = resolverService.parseHyperLink(link.payload);
469
- if (setId(link.id), setDisplay(link.display), linkInfo.type === "outer") {
470
- setType(
471
- "link"
472
- /* link */
473
- ), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
517
+ if (linkInfo.type === "outer") {
518
+ setType(LinkType.link), setPayload(linkInfo.url), linkInfo.url === link.display && (setByPayload.current = !0);
474
519
  return;
475
520
  } else {
476
521
  const params = linkInfo.searchObj;
477
522
  if (params.rangeid) {
478
- setType(
479
- "rangeid"
480
- /* definedName */
481
- ), setPayload(params.rangeid);
523
+ setType(LinkType.definedName), setPayload(params.rangeid);
482
524
  return;
483
525
  }
484
526
  if (params.range) {
485
527
  const sheetName = params.gid && (_c = (_b = (_a15 = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _a15.getSheetBySheetId(params.gid)) == null ? void 0 : _b.getName()) != null ? _c : "";
486
- if (setType(
487
- "range"
488
- /* range */
489
- ), params.range === ERROR_RANGE)
528
+ if (setType(LinkType.range), params.range === ERROR_RANGE)
490
529
  setPayload("");
491
530
  else {
492
531
  const payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
@@ -495,47 +534,35 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
495
534
  return;
496
535
  }
497
536
  if (params.gid) {
498
- setType(
499
- "gid"
500
- /* sheet */
501
- ), setPayload(params.gid);
537
+ setType(LinkType.sheet), setPayload(params.gid);
502
538
  return;
503
539
  }
504
540
  }
505
541
  }
506
542
  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.column), cellValue = getCellValueOrigin(cell);
507
- setType(
508
- "link"
509
- /* link */
510
- ), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
543
+ setType(LinkType.link), setPayload(""), setDisplay((cellValue != null ? cellValue : "").toString()), setId("");
511
544
  return;
512
545
  }
513
- setType(
514
- "link"
515
- /* link */
516
- ), setPayload(""), setDisplay(""), setId("");
546
+ setType(LinkType.link), setPayload(""), setDisplay(""), setId("");
517
547
  }, [editing, hyperLinkModel, resolverService, univerInstanceService]);
518
548
  const payloadInitial = useMemo(() => payload, [type]), linkTypeOptions = [
519
549
  {
520
550
  label: localeService.t("hyperLink.form.link"),
521
- value: "link"
522
- /* link */
551
+ value: LinkType.link
523
552
  },
524
553
  {
525
554
  label: localeService.t("hyperLink.form.range"),
526
- value: "range"
527
- /* range */
555
+ value: LinkType.range
528
556
  },
529
557
  {
530
558
  label: localeService.t("hyperLink.form.worksheet"),
531
- value: "gid"
532
- /* sheet */
559
+ value: LinkType.sheet
533
560
  },
534
561
  {
535
562
  label: localeService.t("hyperLink.form.definedName"),
536
- value: "rangeid"
537
- /* definedName */
538
- }
563
+ value: LinkType.definedName
564
+ },
565
+ ...sidePanelOptions
539
566
  ], workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
540
567
  if (!workbook)
541
568
  return;
@@ -543,9 +570,9 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
543
570
  label: value.name,
544
571
  value: value.id
545
572
  })), formatUrl = /* @__PURE__ */ __name((type2, payload2) => {
546
- if (type2 === "link")
573
+ if (type2 === LinkType.link)
547
574
  return serializeUrl(payload2);
548
- if (type2 === "range") {
575
+ if (type2 === LinkType.range) {
549
576
  const info = deserializeRangeWithSheet(payload2), worksheet = workbook.getSheetBySheetName(info.sheetName);
550
577
  if (worksheet)
551
578
  return `#gid=${worksheet.getSheetId()}&range=${serializeRange(info.range)}`;
@@ -623,7 +650,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
623
650
  }, "onChange")
624
651
  }
625
652
  ) }),
626
- type === "link" && /* @__PURE__ */ jsxRuntimeExports.jsx(
653
+ type === LinkType.link && /* @__PURE__ */ jsxRuntimeExports.jsx(
627
654
  FormLayout,
628
655
  {
629
656
  error: showError ? payload ? isLegalLink(payload) ? "" : localeService.t("hyperLink.form.linkError") : localeService.t("hyperLink.form.inputError") : "",
@@ -639,7 +666,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
639
666
  )
640
667
  }
641
668
  ),
642
- type === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
669
+ type === LinkType.range && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
643
670
  RangeSelector,
644
671
  {
645
672
  openForSheetUnitId: workbook.getUnitId(),
@@ -649,7 +676,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
649
676
  onChange: handleRangeChange
650
677
  }
651
678
  ) }),
652
- type === "gid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
679
+ type === LinkType.sheet && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
653
680
  Select,
654
681
  {
655
682
  options: sheetsOption,
@@ -662,7 +689,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
662
689
  }, "onChange")
663
690
  }
664
691
  ) }),
665
- type === "rangeid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
692
+ type === LinkType.definedName && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: showError && !payload ? localeService.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
666
693
  Select,
667
694
  {
668
695
  options: definedNames,
@@ -675,6 +702,20 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
675
702
  }, "onChange")
676
703
  }
677
704
  ) }),
705
+ (customHyperLinkSidePanel == null ? void 0 : customHyperLinkSidePanel.Form) && /* @__PURE__ */ jsxRuntimeExports.jsx(
706
+ customHyperLinkSidePanel.Form,
707
+ {
708
+ linkId: id,
709
+ payload,
710
+ display,
711
+ showError,
712
+ setByPayload,
713
+ setDisplay: /* @__PURE__ */ __name((newLink) => {
714
+ setDisplay(newLink), setByPayload.current = !0;
715
+ }, "setDisplay"),
716
+ setPayload
717
+ }
718
+ ),
678
719
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cellLinkEditButtons, children: [
679
720
  /* @__PURE__ */ jsxRuntimeExports.jsx(
680
721
  Button,
@@ -694,7 +735,7 @@ const cellLinkEditButtons = "univer-cell-link-edit-buttons", styles$1 = {
694
735
  type: "primary",
695
736
  style: { marginLeft: 8 },
696
737
  onClick: /* @__PURE__ */ __name(async () => {
697
- if (!display || !payload || type === "link" && !isLegalLink(payload)) {
738
+ if (!display || !payload || type === LinkType.link && !isLegalLink(payload)) {
698
739
  setShowError(!0);
699
740
  return;
700
741
  }
@@ -1303,52 +1344,49 @@ let SheetsHyperLinkAutoFillController = (_a9 = class extends Disposable {
1303
1344
  endRow: row
1304
1345
  },
1305
1346
  sourceRange2
1306
- ), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol);
1307
- if (link) {
1308
- const targetPositionRange = Rectangle.getPositionRange(
1309
- {
1310
- startRow: row,
1311
- startColumn: col,
1312
- endColumn: col,
1313
- endRow: row
1314
- },
1315
- targetRange2
1316
- ), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
1317
- currentLink && redos.push({
1318
- id: RemoveHyperLinkMutation.id,
1319
- params: {
1320
- unitId,
1321
- subUnitId,
1322
- id: currentLink.id
1323
- }
1324
- }), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && (redos.push({
1325
- id: AddHyperLinkMutation.id,
1326
- params: {
1327
- unitId,
1328
- subUnitId,
1329
- link: {
1330
- ...link,
1331
- id,
1332
- row: targetRow,
1333
- column: targetCol
1334
- }
1335
- }
1336
- }), undos.push({
1337
- id: RemoveHyperLinkMutation.id,
1338
- params: {
1339
- unitId,
1340
- subUnitId,
1341
- id
1342
- }
1343
- })), currentLink && undos.push({
1344
- id: AddHyperLinkMutation.id,
1345
- params: {
1346
- unitId,
1347
- subUnitId,
1348
- link: currentLink
1347
+ ), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol), targetPositionRange = Rectangle.getPositionRange(
1348
+ {
1349
+ startRow: row,
1350
+ startColumn: col,
1351
+ endColumn: col,
1352
+ endRow: row
1353
+ },
1354
+ targetRange2
1355
+ ), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn), id = Tools.generateRandomId(), currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
1356
+ currentLink && redos.push({
1357
+ id: RemoveHyperLinkMutation.id,
1358
+ params: {
1359
+ unitId,
1360
+ subUnitId,
1361
+ id: currentLink.id
1362
+ }
1363
+ }), (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link && (redos.push({
1364
+ id: AddHyperLinkMutation.id,
1365
+ params: {
1366
+ unitId,
1367
+ subUnitId,
1368
+ link: {
1369
+ ...link,
1370
+ id,
1371
+ row: targetRow,
1372
+ column: targetCol
1349
1373
  }
1350
- });
1351
- }
1374
+ }
1375
+ }), undos.push({
1376
+ id: RemoveHyperLinkMutation.id,
1377
+ params: {
1378
+ unitId,
1379
+ subUnitId,
1380
+ id
1381
+ }
1382
+ })), currentLink && undos.push({
1383
+ id: AddHyperLinkMutation.id,
1384
+ params: {
1385
+ unitId,
1386
+ subUnitId,
1387
+ link: currentLink
1388
+ }
1389
+ });
1352
1390
  });
1353
1391
  }), {
1354
1392
  undos,
@@ -1374,8 +1412,21 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
1374
1412
  let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
1375
1413
  constructor(_sheetClipboardService, _hyperLinkModel, _injector, _resolverService) {
1376
1414
  super();
1415
+ __publicField(this, "_plainTextFilter", /* @__PURE__ */ new Set());
1377
1416
  __publicField(this, "_copyInfo");
1378
- this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste();
1417
+ this._sheetClipboardService = _sheetClipboardService, this._hyperLinkModel = _hyperLinkModel, this._injector = _injector, this._resolverService = _resolverService, this._initCopyPaste(), this.disposeWithMe(() => {
1418
+ this._plainTextFilter.clear();
1419
+ });
1420
+ }
1421
+ registerPlainTextFilter(filter) {
1422
+ this._plainTextFilter.add(filter);
1423
+ }
1424
+ removePlainTextFilter(filter) {
1425
+ this._plainTextFilter.delete(filter);
1426
+ }
1427
+ /* If return false the process of paste text will be stop */
1428
+ _filterPlainText(text) {
1429
+ return Array.from(this._plainTextFilter).every((filter) => filter(text));
1379
1430
  }
1380
1431
  _initCopyPaste() {
1381
1432
  this._sheetClipboardService.addClipboardHook({
@@ -1386,7 +1437,8 @@ let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
1386
1437
  return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
1387
1438
  }, "onPasteCells"),
1388
1439
  onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => {
1389
- if (isLegalLink(clipText)) {
1440
+ const filterResult = this._filterPlainText(clipText);
1441
+ if (isLegalLink(clipText) && filterResult) {
1390
1442
  const text = serializeUrl(clipText), { range, unitId, subUnitId } = pasteTo, { ranges: [pasteToRange], mapFunc } = virtualizeDiscreteRanges([range]), redos = [], undos = [];
1391
1443
  return Range.foreach(pasteToRange, (originRow, originCol) => {
1392
1444
  const { row, col: column } = mapFunc(originRow, originCol), link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, row, column);
@@ -1429,7 +1481,8 @@ let SheetsHyperLinkCopyPasteController = (_a10 = class extends Disposable {
1429
1481
  }), { redos, undos };
1430
1482
  }
1431
1483
  return { undos: [], redos: [] };
1432
- }, "onPastePlainText")
1484
+ }, "onPastePlainText"),
1485
+ priority: 99
1433
1486
  });
1434
1487
  }
1435
1488
  _collect(unitId, subUnitId, range) {
@@ -1582,8 +1635,17 @@ let UniverSheetsHyperLinkUIPlugin = (_a13 = class extends Plugin {
1582
1635
  }
1583
1636
  onStarting() {
1584
1637
  [
1585
- [SheetsHyperLinkResolverService],
1638
+ [
1639
+ SheetsHyperLinkResolverService,
1640
+ {
1641
+ useFactory: /* @__PURE__ */ __name(() => {
1642
+ var _a14;
1643
+ return this._injector.createInstance(SheetsHyperLinkResolverService, (_a14 = this._config) == null ? void 0 : _a14.urlHandler);
1644
+ }, "useFactory")
1645
+ }
1646
+ ],
1586
1647
  [SheetsHyperLinkPopupService],
1648
+ [SheetsHyperLinkSidePanelService],
1587
1649
  [SheetsHyperLinkRemoveSheetController],
1588
1650
  [SheetsHyperLinkRenderManagerController],
1589
1651
  [SheetHyperLinkSetRangeController],
@@ -1628,6 +1690,7 @@ export {
1628
1690
  SheetsHyperLinkRenderController,
1629
1691
  SheetsHyperLinkRenderManagerController,
1630
1692
  SheetsHyperLinkResolverService,
1693
+ SheetsHyperLinkSidePanelService,
1631
1694
  SheetsHyperLinkUIController,
1632
1695
  UniverSheetsHyperLinkUIPlugin
1633
1696
  };
@@ -8,6 +8,10 @@ export declare class SheetsHyperLinkCopyPasteController extends Disposable {
8
8
  private _hyperLinkModel;
9
9
  private _injector;
10
10
  private _resolverService;
11
+ private _plainTextFilter;
12
+ registerPlainTextFilter(filter: (text: string) => boolean): void;
13
+ removePlainTextFilter(filter: (text: string) => boolean): void;
14
+ private _filterPlainText;
11
15
  private _copyInfo;
12
16
  constructor(_sheetClipboardService: ISheetClipboardService, _hyperLinkModel: HyperLinkModel, _injector: Injector, _resolverService: SheetsHyperLinkResolverService);
13
17
  private _initCopyPaste;
@@ -1,9 +1,7 @@
1
- import { Disposable, ICommandService, Injector, LocaleService } from '@univerjs/core';
2
- import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
1
+ import { Nullable, Disposable, ICommandService, Injector, LocaleService } from '@univerjs/core';
2
+ import { ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
+ import { IUniverSheetsHyperLinkUIConfig } from '../types/interfaces/i-config';
3
4
 
4
- export interface IUniverSheetsHyperLinkUIConfig {
5
- menu?: MenuConfig;
6
- }
7
5
  export declare class SheetsHyperLinkUIController extends Disposable {
8
6
  private _config;
9
7
  private _componentManager;
@@ -12,7 +10,7 @@ export declare class SheetsHyperLinkUIController extends Disposable {
12
10
  private _menuService;
13
11
  private _injector;
14
12
  private _shortcutService;
15
- constructor(_config: IUniverSheetsHyperLinkUIConfig | undefined, _componentManager: ComponentManager, _commandService: ICommandService, _localeService: LocaleService, _menuService: IMenuService, _injector: Injector, _shortcutService: IShortcutService);
13
+ constructor(_config: Nullable<IUniverSheetsHyperLinkUIConfig>, _componentManager: ComponentManager, _commandService: ICommandService, _localeService: LocaleService, _menuService: IMenuService, _injector: Injector, _shortcutService: IShortcutService);
16
14
  private _initComponents;
17
15
  private _initCommands;
18
16
  private _initMenus;
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export { SheetsHyperLinkRemoveSheetController } from './controllers/remove-sheet.controller';
17
17
  export { SheetsHyperLinkRenderManagerController, SheetsHyperLinkRenderController } from './controllers/render-controllers/render.controller';
18
+ export { SheetsHyperLinkSidePanelService, type ICustomHyperLinkView } from './services/side-panel.service';
18
19
  export { SheetsHyperLinkPopupService } from './services/popup.service';
19
20
  export { SheetsHyperLinkResolverService } from './services/resolver.service';
20
21
  export { SheetHyperLinkSetRangeController } from './controllers/set-range.controller';
@@ -25,4 +26,5 @@ export { SheetsHyperLinkCopyPasteController } from './controllers/copy-paste.con
25
26
  export { SheetHyperLinkUrlController } from './controllers/url.controller';
26
27
  export { UniverSheetsHyperLinkUIPlugin } from './plugin';
27
28
  export { InsertLinkShortcut } from './controllers/menu';
29
+ export type { IUrlHandler, IUniverSheetsHyperLinkUIConfig } from './types/interfaces/i-config';
28
30
  export { OpenHyperLinkSidebarOperation, InsertHyperLinkOperation, CloseHyperLinkSidebarOperation, type IOpenHyperLinkSidebarOperationParams, } from './commands/operations/sidebar.operations';
@@ -1,6 +1,6 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { Nullable, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
- import { IUniverSheetsHyperLinkUIConfig } from './controllers/ui.controller';
3
+ import { IUniverSheetsHyperLinkUIConfig } from './types/interfaces/i-config';
4
4
 
5
5
  export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
6
6
  private _config;
@@ -8,7 +8,7 @@ export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
8
8
  private readonly _renderManagerService;
9
9
  static pluginName: string;
10
10
  static type: UniverInstanceType;
11
- constructor(_config: IUniverSheetsHyperLinkUIConfig, _injector: Injector, _renderManagerService: IRenderManagerService);
11
+ constructor(_config: Nullable<IUniverSheetsHyperLinkUIConfig>, _injector: Injector, _renderManagerService: IRenderManagerService);
12
12
  onStarting(): void;
13
13
  onReady(): void;
14
14
  }
@@ -1,19 +1,27 @@
1
- import { IRange, Worksheet, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { IRange, Nullable, Worksheet, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { IDefinedNamesService } from '@univerjs/engine-formula';
3
3
  import { IMessageService } from '@univerjs/ui';
4
+ import { IUrlHandler } from '../types/interfaces/i-config';
4
5
 
5
6
  interface ISheetUrlParams {
6
7
  gid?: string;
7
8
  range?: string;
8
9
  rangeid?: string;
9
10
  }
11
+ export interface IHyperLinkInfo<T extends string> {
12
+ type: T;
13
+ name: string;
14
+ url: string;
15
+ handler: () => void;
16
+ }
10
17
  export declare class SheetsHyperLinkResolverService {
18
+ private _urlHandler;
11
19
  private _univerInstanceService;
12
20
  private _commandService;
13
21
  private _definedNamesService;
14
22
  private _messageService;
15
23
  private _localeService;
16
- constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _definedNamesService: IDefinedNamesService, _messageService: IMessageService, _localeService: LocaleService);
24
+ constructor(_urlHandler: Nullable<IUrlHandler>, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _definedNamesService: IDefinedNamesService, _messageService: IMessageService, _localeService: LocaleService);
17
25
  private _getURLName;
18
26
  navigateTo(params: ISheetUrlParams): void;
19
27
  parseHyperLink(urlStr: string): {
@@ -0,0 +1,46 @@
1
+ import { Disposable } from '@univerjs/core';
2
+ import { ICellHyperLink } from '@univerjs/sheets-hyper-link';
3
+ import { default as React } from 'react';
4
+
5
+ export interface CustomHyperLinkFormProps {
6
+ linkId: string;
7
+ payload: string;
8
+ display: string;
9
+ setByPayload: React.MutableRefObject<boolean>;
10
+ showError: boolean;
11
+ setDisplay: (display: string) => void;
12
+ setPayload: (payload: string) => void;
13
+ }
14
+ export interface ICustomHyperLinkView {
15
+ type: string;
16
+ option: {
17
+ label: string;
18
+ value: string;
19
+ };
20
+ Form: React.FC<CustomHyperLinkFormProps>;
21
+ convert: (link: ICellHyperLink) => {
22
+ display: string;
23
+ payload: string;
24
+ type: string;
25
+ };
26
+ match: (link: ICellHyperLink) => boolean;
27
+ }
28
+ export declare enum LinkType {
29
+ link = "link",
30
+ range = "range",
31
+ sheet = "gid",
32
+ definedName = "rangeid"
33
+ }
34
+ export declare class SheetsHyperLinkSidePanelService extends Disposable {
35
+ private _customHyperLinks;
36
+ isBuiltInLinkType(type: string): boolean;
37
+ getOptions(): {
38
+ label: string;
39
+ value: string;
40
+ }[];
41
+ findCustomHyperLink(link: ICellHyperLink): ICustomHyperLinkView | undefined;
42
+ registerCustomHyperLink(customHyperLink: ICustomHyperLinkView): void;
43
+ getCustomHyperLink(type: string): ICustomHyperLinkView | undefined;
44
+ removeCustomHyperLink(type: string): void;
45
+ dispose(): void;
46
+ }
@@ -0,0 +1,9 @@
1
+ import { MenuConfig } from '@univerjs/ui';
2
+
3
+ export interface IUrlHandler {
4
+ navigateToOtherWebsite?: (url: string) => void;
5
+ }
6
+ export interface IUniverSheetsHyperLinkUIConfig {
7
+ menu?: MenuConfig;
8
+ urlHandler?: IUrlHandler;
9
+ }