@univerjs/sheets-hyper-link-ui 0.4.0 → 0.4.1-experimental.20241023-bbb123f
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 +1 -1
- package/lib/es/index.js +22 -24
- package/lib/types/controllers/menu.d.ts +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Tools, Inject, LocaleService, UniverInstanceType, isValidRange, IUniverInstanceService, ICommandService, IConfigService, RANGE_TYPE, Rectangle, Injector, Disposable, Range, ObjectMatrix, CommandType, IUndoRedoService, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, getBodySlice, useDependency, IContextService, ThemeService, ColorKit, DisposableCollection, FOCUSING_SHEET,
|
|
5
|
+
import { Tools, Inject, LocaleService, UniverInstanceType, isValidRange, IUniverInstanceService, ICommandService, IConfigService, RANGE_TYPE, Rectangle, Injector, Disposable, Range, ObjectMatrix, CommandType, IUndoRedoService, BuildTextUtils, DataStreamTreeTokenType, CustomRangeType, TextX, CellValueType, sequenceExecuteAsync, generateRandomId, getBodySlice, useDependency, IContextService, ThemeService, ColorKit, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DisposableCollection, FOCUSING_SHEET, sequenceExecute, useObservable as useObservable$1, DataValidationType, IPermissionService, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, InterceptorEffectEnum, DependentOn, Plugin } from "@univerjs/core";
|
|
6
6
|
import { SheetHyperLinkType, ERROR_RANGE, HyperLinkModel, RemoveHyperLinkMutation, AddHyperLinkMutation, UniverSheetsHyperLinkPlugin } from "@univerjs/sheets-hyper-link";
|
|
7
7
|
import { ScrollToRangeOperation, COPY_TYPE, virtualizeDiscreteRanges, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, IEditorBridgeService, SheetSkeletonManagerService, IMarkSelectionService, SheetCanvasPopManagerService, getEditingCustomRangePosition, getCustomRangePosition, whenSheetEditorFocused, getCurrentRangeDisable$, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange, SheetPermissionInterceptorBaseController, HoverManagerService, HoverRenderController } from "@univerjs/sheets-ui";
|
|
8
8
|
import { MessageType, FormLayout, Input, Select, Button, Tooltip } from "@univerjs/design";
|
|
@@ -510,10 +510,7 @@ const AddHyperLinkCommand = {
|
|
|
510
510
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
511
511
|
if (!params)
|
|
512
512
|
return !1;
|
|
513
|
-
const { documentId, link } = params, commandService = accessor.get(ICommandService),
|
|
514
|
-
if (!textSelectionService.getActiveTextRange())
|
|
515
|
-
return !1;
|
|
516
|
-
const replaceSelection = addCustomRangeBySelectionFactory(accessor, {
|
|
513
|
+
const { documentId, link } = params, commandService = accessor.get(ICommandService), newId = generateRandomId(), { payload } = link, replaceSelection = addCustomRangeBySelectionFactory(accessor, {
|
|
517
514
|
unitId: documentId,
|
|
518
515
|
rangeId: newId,
|
|
519
516
|
rangeType: CustomRangeType.HYPERLINK,
|
|
@@ -695,7 +692,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
695
692
|
useEffect(() => {
|
|
696
693
|
isFocusRangeSelectorSet(!1);
|
|
697
694
|
}, [subUnitId]), useEffect(() => {
|
|
698
|
-
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
695
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
699
696
|
if ((editing == null ? void 0 : editing.row) !== void 0 && editing.col !== void 0) {
|
|
700
697
|
const { label, customRange, row, col } = editing;
|
|
701
698
|
let link;
|
|
@@ -720,11 +717,11 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
720
717
|
column: col
|
|
721
718
|
};
|
|
722
719
|
} else {
|
|
723
|
-
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC),
|
|
720
|
+
const doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), currentSelection = textSelectionService.getActiveTextRange(), body = doc == null ? void 0 : doc.getBody(), selection = currentSelection && body ? BuildTextUtils.selection.getInsertSelection(currentSelection, body) : null, customRange2 = selection && ((_l = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_k = body == null ? void 0 : body.customRanges) != null ? _k : [])) == null ? void 0 : _l[0]);
|
|
724
721
|
setShowLabel(!1), link = {
|
|
725
722
|
id: "",
|
|
726
723
|
display: label != null ? label : "",
|
|
727
|
-
payload: (
|
|
724
|
+
payload: (_n = (_m = customRange2 == null ? void 0 : customRange2.properties) == null ? void 0 : _m.url) != null ? _n : "",
|
|
728
725
|
row,
|
|
729
726
|
column: col
|
|
730
727
|
};
|
|
@@ -744,7 +741,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
744
741
|
break;
|
|
745
742
|
}
|
|
746
743
|
case SheetHyperLinkType.RANGE: {
|
|
747
|
-
const params = linkInfo.searchObj, sheetName = params.gid && (
|
|
744
|
+
const params = linkInfo.searchObj, sheetName = params.gid && (_q = (_p = (_o = univerInstanceService.getUnit(editing.unitId)) == null ? void 0 : _o.getSheetBySheetId(params.gid)) == null ? void 0 : _p.getName()) != null ? _q : "", payload2 = serializeRangeWithSheet(sheetName, deserializeRangeWithSheet(params.range).range);
|
|
748
745
|
setPayload(payload2), payload2 === link.display && (setByPayload.current = !0);
|
|
749
746
|
break;
|
|
750
747
|
}
|
|
@@ -791,10 +788,12 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
791
788
|
return () => {
|
|
792
789
|
id2 && markSelectionService.removeShape(id2);
|
|
793
790
|
};
|
|
794
|
-
}, [editing, markSelectionService, themeService, univerInstanceService])
|
|
791
|
+
}, [editing, markSelectionService, themeService, univerInstanceService]), useEffect(() => {
|
|
792
|
+
type === SheetHyperLinkType.RANGE && !showLabel && !isFocusRangeSelector && isFocusRangeSelectorSet(!0);
|
|
793
|
+
}, [type, isFocusRangeSelector, showLabel, editorBridgeService]);
|
|
795
794
|
const payloadInitial = useMemo(() => payload, [type]);
|
|
796
795
|
useEffect(() => {
|
|
797
|
-
const render2 = renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()), disposeCollection = new DisposableCollection();
|
|
796
|
+
const render2 = (editing == null ? void 0 : editing.type) === HyperLinkEditSourceType.ZEN_EDITOR ? renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY) : renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()), disposeCollection = new DisposableCollection();
|
|
798
797
|
if (render2) {
|
|
799
798
|
const selectionRenderService = render2.with(DocSelectionRenderService);
|
|
800
799
|
selectionRenderService.setReserveRangesStatus(!0), disposeCollection.add(() => {
|
|
@@ -804,9 +803,9 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
804
803
|
return () => {
|
|
805
804
|
editorBridgeService.disableForceKeepVisible(), disposeCollection.dispose();
|
|
806
805
|
};
|
|
807
|
-
}, [editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(
|
|
806
|
+
}, [editorBridgeService, renderManagerService]), useEffect(() => (popupService.setIsKeepVisible(isFocusRangeSelector), () => {
|
|
808
807
|
popupService.setIsKeepVisible(!1);
|
|
809
|
-
}), [
|
|
808
|
+
}), [isFocusRangeSelector, popupService]), useEffect(() => () => {
|
|
810
809
|
zenZoneService.temporaryHidden && (zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1));
|
|
811
810
|
}, [contextService, zenZoneService]);
|
|
812
811
|
const linkTypeOptions = [
|
|
@@ -952,7 +951,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
952
951
|
setPayload(newLink), newLink && (setByPayload.current || !display || display === payload) && (setDisplay(newLink), setByPayload.current = !0);
|
|
953
952
|
}, "onChange"),
|
|
954
953
|
placeholder: localeService.t("hyperLink.form.linkPlaceholder"),
|
|
955
|
-
autoFocus: !
|
|
954
|
+
autoFocus: !0,
|
|
956
955
|
onKeyDown: /* @__PURE__ */ __name((e) => {
|
|
957
956
|
e.keyCode === KeyCode.ENTER && handleSubmit();
|
|
958
957
|
}, "onKeyDown")
|
|
@@ -986,9 +985,7 @@ const cellLinkEdit = "univer-cell-link-edit", cellLinkEditButtons = "univer-cell
|
|
|
986
985
|
selections: [{ range: { startRow: editing.row, endRow: editing.row, startColumn: editing.col, endColumn: editing.col } }]
|
|
987
986
|
}), zenZoneService.show(), contextService.setContextValue(FOCUSING_SHEET, !1);
|
|
988
987
|
const docBackScrollRenderController = (_a16 = renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a16.with(DocBackScrollRenderController), range = (_b = docSelectionManagerService.getTextRanges({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY })) == null ? void 0 : _b[0];
|
|
989
|
-
docBackScrollRenderController && range &&
|
|
990
|
-
docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY });
|
|
991
|
-
}, 100);
|
|
988
|
+
docBackScrollRenderController && range && (docBackScrollRenderController.scrollToRange(range), docSelectionManagerService.refreshSelection({ unitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_ZEN_EDITOR_UNIT_ID_KEY }));
|
|
992
989
|
}
|
|
993
990
|
editorBridgeService.disableForceKeepVisible(), setHide(!1);
|
|
994
991
|
}
|
|
@@ -1466,7 +1463,7 @@ let SheetsHyperLinkPopupService = (_a3 = class extends Disposable {
|
|
|
1466
1463
|
collapsed: body.dataStream.length - 2 === 0,
|
|
1467
1464
|
label: BuildTextUtils.transform.getPlainText(body.dataStream)
|
|
1468
1465
|
};
|
|
1469
|
-
const links = BuildTextUtils.customRange.
|
|
1466
|
+
const links = BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange, (_c = (_b = body.customRanges) == null ? void 0 : _b.filter((i) => i.rangeType === CustomRangeType.HYPERLINK)) != null ? _c : []);
|
|
1470
1467
|
let start = textRange.startOffset, end = textRange.endOffset;
|
|
1471
1468
|
return links.forEach((link) => {
|
|
1472
1469
|
start = Math.min(start, link.startIndex), end = Math.max(end, link.endIndex + 1);
|
|
@@ -1631,16 +1628,17 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1631
1628
|
const row = selections[0].range.startRow, col = selections[0].range.startColumn;
|
|
1632
1629
|
return getShouldDisableCellLink(worksheet, row, col);
|
|
1633
1630
|
}, "getShouldDisableCurrentCellLink"), shouldDisableAddLink = /* @__PURE__ */ __name((accessor) => {
|
|
1634
|
-
var _a15;
|
|
1631
|
+
var _a15, _b;
|
|
1635
1632
|
const textSelectionService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), textRanges = textSelectionService.getDocRanges();
|
|
1636
1633
|
if (!textRanges.length || textRanges.length > 1)
|
|
1637
1634
|
return !0;
|
|
1638
1635
|
const activeRange = textRanges[0], doc = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
1639
1636
|
if (!doc || !activeRange || activeRange.collapsed)
|
|
1640
1637
|
return !0;
|
|
1641
|
-
const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody()
|
|
1642
|
-
if (!
|
|
1638
|
+
const body = doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody();
|
|
1639
|
+
if (!body)
|
|
1643
1640
|
return !0;
|
|
1641
|
+
const paragraphs = (_a15 = body == null ? void 0 : body.paragraphs) != null ? _a15 : [];
|
|
1644
1642
|
for (let i = 0, len = paragraphs.length; i < len; i++) {
|
|
1645
1643
|
const p2 = paragraphs[i];
|
|
1646
1644
|
if (activeRange.startOffset <= p2.startIndex && activeRange.endOffset > p2.startIndex)
|
|
@@ -1648,7 +1646,7 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1648
1646
|
if (p2.startIndex > activeRange.endOffset)
|
|
1649
1647
|
break;
|
|
1650
1648
|
}
|
|
1651
|
-
return !BuildTextUtils.customRange.
|
|
1649
|
+
return !BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(activeRange, (_b = body.customRanges) != null ? _b : []).every((range) => range.rangeType === CustomRangeType.HYPERLINK);
|
|
1652
1650
|
}, "shouldDisableAddLink"), OpenHyperLinkEditPanelOperation = {
|
|
1653
1651
|
type: CommandType.OPERATION,
|
|
1654
1652
|
id: "sheet.operation.open-hyper-link-edit-panel",
|
|
@@ -1694,7 +1692,7 @@ const getShouldDisableCellLink = /* @__PURE__ */ __name((worksheet, row, col) =>
|
|
|
1694
1692
|
return accessor.get(SheetsHyperLinkPopupService).currentEditing ? commandService.executeCommand(CloseHyperLinkPopupOperation.id) : commandService.executeCommand(InsertHyperLinkOperation.id);
|
|
1695
1693
|
}
|
|
1696
1694
|
}, getLinkDisable$ = /* @__PURE__ */ __name((accessor) => {
|
|
1697
|
-
const disableRange$ = getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }), univerInstanceService = accessor.get(IUniverInstanceService), sheetSelectionService = accessor.get(SheetsSelectionsService), disableCell$ = univerInstanceService.focused$.pipe(
|
|
1695
|
+
const disableRange$ = getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }, !0), univerInstanceService = accessor.get(IUniverInstanceService), sheetSelectionService = accessor.get(SheetsSelectionsService), disableCell$ = univerInstanceService.focused$.pipe(
|
|
1698
1696
|
map((focused) => focused ? univerInstanceService.getUnit(focused, UniverInstanceType.UNIVER_SHEET) : null),
|
|
1699
1697
|
mergeMap((unit) => unit ? unit.activeSheet$ : new Observable((sub) => {
|
|
1700
1698
|
sub.next(null);
|
|
@@ -2008,7 +2006,7 @@ let SheetsHyperLinkPopupController = (_a6 = class extends Disposable {
|
|
|
2008
2006
|
_initZenEditor() {
|
|
2009
2007
|
this.disposeWithMe(
|
|
2010
2008
|
this._zenZoneService.visible$.subscribe((visible) => {
|
|
2011
|
-
visible
|
|
2009
|
+
visible ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.ZEN_EDITOR));
|
|
2012
2010
|
})
|
|
2013
2011
|
), this.disposeWithMe(
|
|
2014
2012
|
this._univerInstanceService.focused$.pipe(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MenuGroup, MenuItemType, MenuPosition, IMenuItem, IShortcutItem } from '@univerjs/ui';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
1
|
import { IAccessor } from '@univerjs/core';
|
|
2
|
+
import { IMenuItem, IShortcutItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
4
|
export declare const genZenEditorMenuId: (id: string) => string;
|
|
5
5
|
export declare const insertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
6
6
|
export declare const zenEditorInsertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|