@univerjs/sheets-ui 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, EnterCommand, IEditorService, IMEInputCommand, InnerPasteCommand, MobileRichTextToolbar, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetDocInputStyleCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
1
+ import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, EditorColorPicker, EnterCommand, IEditorService, IMEInputCommand, InnerPasteCommand, MobileRichTextToolbar, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetDocInputStyleCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
2
2
  import { AbsoluteRefType, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, CellModeEnum, CellValueType, ColorKit, CommandType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_HEIGHT, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_UNIVER_EDITOR, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, LocaleType, LookUp, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WorksheetHiddenState, WrapStrategy, cloneCellData, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, composeStyles, convertCellToRange, createDocumentModelWithStyle, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numberToABC, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
3
3
  import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory, AddRangeProtectionCommand, AddRangeProtectionMutation, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeMutation, AddWorksheetMergeVerticalCommand, AddWorksheetProtectionCommand, AutoClearContentCommand, AutoFillCommand, AutoFillController, BEFORE_CELL_EDIT, BorderStyleManagerService, COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, CancelMarkDirtyRowAutoHeightOperation, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, EditStateEnum, IAutoFillService, IExclusiveRangeService, INTERCEPTOR_POINT, INumfmtService, IRefSelectionsService, InsertColBeforeCommand, InsertColCommand, InsertColMutation, InsertDefinedNameCommand, InsertMultiColsLeftCommand, InsertMultiColsRightCommand, InsertMultiRowsAboveCommand, InsertMultiRowsAfterCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowBeforeCommand, InsertRowCommand, InsertRowMutation, InsertSheetCommand, InsertSheetMutation, MAX_CELL_PER_SHEET_KEY, MERGE_CELL_INTERCEPTOR_CHECK, MarkDirtyRowAutoHeightOperation, MergeCellController, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, REF_SELECTIONS_ENABLED, RangeProtectionCache, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RefRangeService, RefSelectionsService, RefillCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveMergeUndoMutationFactory, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, RemoveWorksheetMergeCommand, RemoveWorksheetMergeMutation, ResetBackgroundColorCommand, ResetTextColorCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SELECTIONS_ENABLED, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SHEETS_PLUGIN_CONFIG_KEY, ScrollToCellOperation, SelectionMoveType, SetBackgroundColorCommand, SetBoldCommand, SetBorderBasicCommand, SetBorderCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDefinedNameCommand, SetFontFamilyCommand, SetFontSizeCommand, SetFrozenCommand, SetFrozenMutation, SetFrozenMutationFactory, SetHorizontalTextAlignCommand, SetItalicCommand, SetProtectionCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSelectionsOperation, SetShrinkToFitCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStrikeThroughCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetPermissionPointsCommand, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetCopyDownCommand, SheetCopyRightCommand, SheetInterceptorService, SheetPermissionCheckController, SheetPermissionInitController, SheetSkeletonService, SheetsSelectionsService, TextToNumberCommand, ToggleCellCheckboxCommand, ToggleGridlinesCommand, ToggleGridlinesMutation, UniverSheetsPlugin, ViewStateEnum, WorkbookCopyPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission, adjustRangeOnMutation, alignToMergedCellsBorders, attachPrimaryWithCoord, attachRangeWithCoord, attachSelectionWithCoord, baseProtectionActions, convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, countCells, defaultLargeSheetOperationConfig, deserializeListOptions, discreteRangeToRange, expandToContinuousRange, findFirstNonEmptyCell, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getCellAtRowCol, getCellType, getCellValue, getClearContentMutationParamsForRanges, getMoveRangeCommandMutations, getPrimaryForRange, getSelectionsService, getSheetCommandTarget, isCellImage, rangeToDiscreteRange, serializeListOptions, setEndForRange, validateDefinedName } from "@univerjs/sheets";
4
- import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, IFontService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IUIRuntimeScopeService, IWorkbenchService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SheetPasteShortKeyCommandName, Slider, ToggleFullscreenOperation, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getEmbedBoundaryOwner, getEmbedChildUnitId, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useToolbarItemStatus, useVirtualList } from "@univerjs/ui";
4
+ import { AnchoredContextMenu, BuiltInUIPart, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, IFontService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IUIRuntimeScopeService, IWorkbenchService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SheetPasteShortKeyCommandName, Slider, ToggleFullscreenOperation, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, bindFormatPainterCanvas, connectInjector, getEmbedBoundaryOwner, getEmbedChildUnitId, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useToolbarItemStatus, useVirtualList } from "@univerjs/ui";
5
5
  import { CURSOR_TYPE, DashedRect, DeviceInputEventType, DeviceType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, calculateCellImageRect, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, getNextWheelZoomRatio, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
6
6
  import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, from, fromEvent, isObservable, map, merge as merge$1, of, shareReplay, skip, startWith, switchMap, takeUntil, tap, throttleTime, withLatestFrom } from "rxjs";
7
7
  import { DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
@@ -11459,6 +11459,29 @@ function processNumberStringWithSpaces(token, numStr) {
11459
11459
  };
11460
11460
  }
11461
11461
 
11462
+ //#endregion
11463
+ //#region src/controllers/editor/utils/get-edit-cell-input-position.ts
11464
+ /**
11465
+ * Get the position of the hidden editor input for the current edit cell.
11466
+ *
11467
+ * The OS anchors the IME candidate window to the focused input, so the input should stay on the
11468
+ * selected cell even before the cell editor opens. The position is kept inside the sheet canvas,
11469
+ * so a cell scrolled out of view never moves the input outside the sheet.
11470
+ */
11471
+ function getEditCellInputPosition(layout, canvasSize) {
11472
+ const { position, canvasOffset } = layout;
11473
+ const x = canvasOffset.left + position.startX;
11474
+ const y = canvasOffset.top + position.startY;
11475
+ if (!canvasSize) return {
11476
+ x,
11477
+ y
11478
+ };
11479
+ return {
11480
+ x: Math.min(Math.max(x, canvasOffset.left), canvasOffset.left + canvasSize.width),
11481
+ y: Math.min(Math.max(y, canvasOffset.top), canvasOffset.top + canvasSize.height)
11482
+ };
11483
+ }
11484
+
11462
11485
  //#endregion
11463
11486
  //#region src/controllers/editor/utils/is-range-selector.ts
11464
11487
  /**
@@ -11675,7 +11698,11 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11675
11698
  if ((cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 ? void 0 : cellSelectionRenderManager.canFocusing) || (formulaSelectionRenderManager === null || formulaSelectionRenderManager === void 0 ? void 0 : formulaSelectionRenderManager.canFocusing)) {
11676
11699
  this._univerInstanceService.setCurrentUnitForType(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
11677
11700
  if (this._contextService.getContextValue(DISABLE_AUTO_FOCUS_KEY)) cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.setInputPosition(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1);
11678
- else cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1, true);
11701
+ else {
11702
+ var _this$_renderManagerS5;
11703
+ const { x, y } = getEditCellInputPosition(state, (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(state.unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.engine);
11704
+ cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.activate(x, y, true);
11705
+ }
11679
11706
  }
11680
11707
  }));
11681
11708
  }
@@ -11749,7 +11776,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11749
11776
  }));
11750
11777
  }
11751
11778
  _handleEditorVisible(param) {
11752
- var _documentDataModel$ge, _this$_renderManagerS6;
11779
+ var _documentDataModel$ge, _this$_renderManagerS7;
11753
11780
  const { eventType, keycode } = param;
11754
11781
  this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
11755
11782
  const editCellState = this._editorBridgeService.getEditLocation();
@@ -11778,8 +11805,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11778
11805
  const resetPointerSelection = isInArrayFormulaRange && eventType === DeviceInputEventType.PointerDown;
11779
11806
  const editorId = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) ? DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
11780
11807
  if (resetPointerSelection) {
11781
- var _this$_renderManagerS5;
11782
- (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.with(DocSelectionRenderService).cancelPointerSelection();
11808
+ var _this$_renderManagerS6;
11809
+ (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.with(DocSelectionRenderService).cancelPointerSelection();
11783
11810
  }
11784
11811
  this._emptyDocumentDataModel(documentDataModel.getSnapshot().documentStyle, !!isInArrayFormulaRange);
11785
11812
  document.makeDirty();
@@ -11857,7 +11884,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11857
11884
  collapsed: true
11858
11885
  });
11859
11886
  }
11860
- (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.scene.resetCursor();
11887
+ (_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 || _this$_renderManagerS7.scene.resetCursor();
11861
11888
  }
11862
11889
  _resizeEditorOnOpen(param, editorObject, isInArrayFormulaRange) {
11863
11890
  var _this$_sheetCellEdito4;
@@ -11873,8 +11900,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11873
11900
  if (!pointerPosition || isInArrayFormulaRange) return;
11874
11901
  const rect = engine.getCanvasElement().getBoundingClientRect();
11875
11902
  if (rect.width > 0 && rect.height > 0) {
11876
- var _this$_renderManagerS7;
11877
- (_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS7 === void 0 || _this$_renderManagerS7.with(DocSelectionRenderService).setCursorManually((pointerPosition.x - rect.left) * engine.width / rect.width, (pointerPosition.y - rect.top) * engine.height / rect.height, true, true, { strict: false });
11903
+ var _this$_renderManagerS8;
11904
+ (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS8 === void 0 || _this$_renderManagerS8.with(DocSelectionRenderService).setCursorManually((pointerPosition.x - rect.left) * engine.width / rect.width, (pointerPosition.y - rect.top) * engine.height / rect.height, true, true, { strict: false });
11878
11905
  }
11879
11906
  });
11880
11907
  }
@@ -12076,12 +12103,12 @@ let EditingRenderController = class EditingRenderController extends Disposable {
12076
12103
  return this._univerInstanceService.getUnit(DOCS_NORMAL_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
12077
12104
  }
12078
12105
  _getEditorSkeleton(editorId) {
12079
- var _this$_renderManagerS8;
12080
- return (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(DocSkeletonManagerService).getSkeleton();
12106
+ var _this$_renderManagerS9;
12107
+ return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(DocSkeletonManagerService).getSkeleton();
12081
12108
  }
12082
12109
  _getEditorViewModel(editorId) {
12083
- var _this$_renderManagerS9;
12084
- return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(DocSkeletonManagerService).getViewModel();
12110
+ var _this$_renderManagerS10;
12111
+ return (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(DocSkeletonManagerService).getViewModel();
12085
12112
  }
12086
12113
  _getEditingUnit() {
12087
12114
  return this._editingUnit ? this._univerInstanceService.getUnit(this._editingUnit, UniverInstanceType.UNIVER_SHEET) : null;
@@ -12139,13 +12166,13 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
12139
12166
  cellData.si = null;
12140
12167
  cellData.p = snapshot;
12141
12168
  cellData.t = CellValueType.STRING;
12142
- } else if (cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
12169
+ } else if (newDataStream !== "" && cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
12143
12170
  cellData.v = newDataStream;
12144
12171
  cellData.f = null;
12145
12172
  cellData.si = null;
12146
12173
  cellData.p = null;
12147
12174
  cellData.t = CellValueType.STRING;
12148
- if (isRichText(body) && body.dataStream !== "\r\n") cellData.p = snapshot;
12175
+ if (isRichText(body)) cellData.p = snapshot;
12149
12176
  const style = getCellStyleBySnapshot(snapshot);
12150
12177
  if (style) cellData.s = style;
12151
12178
  } else if (isFormulaString(newDataStream)) {
@@ -12162,21 +12189,14 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
12162
12189
  cellData.si = null;
12163
12190
  cellData.p = null;
12164
12191
  cellData.t = CellValueType.FORCE_STRING;
12165
- } else if (isRichText(body)) {
12166
- if (body.dataStream === "\r\n") {
12167
- cellData.v = "";
12168
- cellData.f = null;
12169
- cellData.si = null;
12170
- cellData.p = null;
12171
- } else {
12172
- cellData.p = snapshot;
12173
- cellData.v = null;
12174
- cellData.f = null;
12175
- cellData.si = null;
12176
- }
12192
+ } else if (newDataStream !== "" && isRichText(body)) {
12193
+ cellData.p = snapshot;
12194
+ cellData.v = null;
12195
+ cellData.f = null;
12196
+ cellData.si = null;
12177
12197
  } else {
12178
- if (newDataStream === "" && cellData.v == null && cellData.p == null) return null;
12179
- cellData.v = newDataStream;
12198
+ if (newDataStream === "" && cellData.v == null && cellData.p == null && cellData.f == null && cellData.si == null) return null;
12199
+ cellData.v = newDataStream === "" ? null : newDataStream;
12180
12200
  cellData.f = null;
12181
12201
  cellData.si = null;
12182
12202
  cellData.p = null;
@@ -15896,7 +15916,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends Di
15896
15916
  if (Math.abs(initialType === 0 ? moveChangeY : moveChangeX) >= MINIMAL_OFFSET$1) isStartMove = true;
15897
15917
  if (initialType === 0) {
15898
15918
  if (moveChangeY > canvasMaxHeight - scrollBarHorizontalHeight + scrollXY.y - cell.startY) moveChangeY = canvasMaxHeight - scrollBarHorizontalHeight + scrollXY.y - cell.startY;
15899
- if (moveChangeY < -(cell.endY - cell.startY) + 2) moveChangeY = -(cell.endY - cell.startY) + 2;
15919
+ moveChangeY = Math.max(moveChangeY, -(cell.endY - cell.startY));
15900
15920
  if (isStartMove) {
15901
15921
  var _this$_resizeHelperSh, _this$_rowResizeRect4, _this$_rowResizeRect5;
15902
15922
  (_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.transformByState({ top: currentOffsetY + moveChangeY });
@@ -15906,7 +15926,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends Di
15906
15926
  }
15907
15927
  } else {
15908
15928
  if (moveChangeX > canvasMaxWidth - scrollBarVerticalWidth + scrollXY.x - cell.startX) moveChangeX = canvasMaxWidth - scrollBarVerticalWidth + scrollXY.x - cell.startX;
15909
- if (moveChangeX < -(cell.endX - cell.startX) + 2) moveChangeX = -(cell.endX - cell.startX) + 2;
15929
+ moveChangeX = Math.max(moveChangeX, -(cell.endX - cell.startX));
15910
15930
  if (isStartMove) {
15911
15931
  var _this$_resizeHelperSh2, _this$_columnResizeRe4, _this$_columnResizeRe5;
15912
15932
  (_this$_resizeHelperSh2 = this._resizeHelperShape) === null || _this$_resizeHelperSh2 === void 0 || _this$_resizeHelperSh2.transformByState({ left: currentOffsetX + moveChangeX });
@@ -15916,7 +15936,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends Di
15916
15936
  }
15917
15937
  }
15918
15938
  });
15919
- this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent((upEvt) => {
15939
+ this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent(() => {
15920
15940
  var _this$_resizeHelperSh3;
15921
15941
  const scene = this._context.scene;
15922
15942
  this._clearObserverEvent();
@@ -16266,6 +16286,7 @@ let HeaderUnhideRenderController = class HeaderUnhideRenderController extends Rx
16266
16286
  dispose() {
16267
16287
  super.dispose();
16268
16288
  this._clearShapes();
16289
+ this.interceptor.dispose();
16269
16290
  }
16270
16291
  _init() {
16271
16292
  let activeSheetId = "";
@@ -16294,18 +16315,54 @@ let HeaderUnhideRenderController = class HeaderUnhideRenderController extends Rx
16294
16315
  if (!skeleton) return;
16295
16316
  const visibleCheck = this.interceptor.fetchThroughInterceptors(HEADER_UNHIDE_RANGE_VISIBLE_CHECK);
16296
16317
  const shouldRenderRange = (payload) => this._headerUnhideRangeService.shouldRenderRange(visibleCheck(true, payload) ?? true, payload);
16297
- const hiddenRowRanges = worksheet.getHiddenRows().filter((range) => shouldRenderRange({
16318
+ const zeroHeightRowRanges = [];
16319
+ const rowData = worksheet.getRowManager().getRowData();
16320
+ for (const rowIndex of Object.keys(rowData)) {
16321
+ const row = Number(rowIndex);
16322
+ if (row >= 0 && row < worksheet.getRowCount() && worksheet.getRowVisible(row) && worksheet.getRowHeight(row) === 0) zeroHeightRowRanges.push({
16323
+ startRow: row,
16324
+ endRow: row,
16325
+ startColumn: 0,
16326
+ endColumn: worksheet.getColumnCount() - 1
16327
+ });
16328
+ }
16329
+ const rowRanges = [...worksheet.getHiddenRows(), ...Rectangle.mergeRanges(zeroHeightRowRanges)].map((range) => ({
16330
+ ...range,
16331
+ rangeType: RANGE_TYPE.ROW
16332
+ })).filter((range) => shouldRenderRange({
16298
16333
  axis: "row",
16299
16334
  range,
16300
16335
  workbook,
16301
16336
  worksheet
16302
16337
  }));
16303
- const hiddenColRanges = worksheet.getHiddenCols().filter((range) => shouldRenderRange({
16338
+ const hiddenRowRanges = Rectangle.mergeRanges(rowRanges).map((range) => ({
16339
+ ...range,
16340
+ rangeType: RANGE_TYPE.ROW
16341
+ }));
16342
+ const zeroWidthColRanges = [];
16343
+ const columnData = worksheet.getColumnManager().getColumnData();
16344
+ for (const columnIndex of Object.keys(columnData)) {
16345
+ const column = Number(columnIndex);
16346
+ if (column >= 0 && column < worksheet.getColumnCount() && worksheet.getColVisible(column) && worksheet.getColumnWidth(column) === 0) zeroWidthColRanges.push({
16347
+ startRow: 0,
16348
+ endRow: worksheet.getRowCount() - 1,
16349
+ startColumn: column,
16350
+ endColumn: column
16351
+ });
16352
+ }
16353
+ const columnRanges = [...worksheet.getHiddenCols(), ...Rectangle.mergeRanges(zeroWidthColRanges)].map((range) => ({
16354
+ ...range,
16355
+ rangeType: RANGE_TYPE.COLUMN
16356
+ })).filter((range) => shouldRenderRange({
16304
16357
  axis: "column",
16305
16358
  range,
16306
16359
  workbook,
16307
16360
  worksheet
16308
16361
  }));
16362
+ const hiddenColRanges = Rectangle.mergeRanges(columnRanges).map((range) => ({
16363
+ ...range,
16364
+ rangeType: RANGE_TYPE.COLUMN
16365
+ }));
16309
16366
  const { scene } = this._getSheetObject();
16310
16367
  const rowCount = worksheet.getRowCount();
16311
16368
  const rowShapes = hiddenRowRanges.map((range) => {
@@ -18372,11 +18429,7 @@ const MenuItemInput = (props) => {
18372
18429
  if (compositionEndTimerRef.current !== null) clearTimeout(compositionEndTimerRef.current);
18373
18430
  }, []);
18374
18431
  const handleChange = (value) => {
18375
- if (!value) {
18376
- setInputValue(min.toString());
18377
- return;
18378
- }
18379
- const inputValue = value.toString();
18432
+ const inputValue = (value ?? min).toString();
18380
18433
  setInputValue(inputValue);
18381
18434
  onChange(inputValue);
18382
18435
  };
@@ -19100,7 +19153,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
19100
19153
  type: MenuItemType.BUTTON_SELECTOR,
19101
19154
  selections: [{
19102
19155
  label: {
19103
- name: COLOR_PICKER_COMPONENT,
19156
+ name: EditorColorPicker.componentKey,
19104
19157
  hoverable: false,
19105
19158
  selectable: false
19106
19159
  },
@@ -19154,7 +19207,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
19154
19207
  icon: "PaintBucketDoubleIcon",
19155
19208
  selections: [{
19156
19209
  label: {
19157
- name: COLOR_PICKER_COMPONENT,
19210
+ name: EditorColorPicker.componentKey,
19158
19211
  hoverable: false,
19159
19212
  selectable: false
19160
19213
  },
@@ -19762,7 +19815,7 @@ function SetRowHeightMenuItemFactory(accessor) {
19762
19815
  const commandService = accessor.get(ICommandService);
19763
19816
  const univerInstanceService = accessor.get(IUniverInstanceService);
19764
19817
  const selectionManagerService = accessor.get(SheetsSelectionsService);
19765
- const min = 2;
19818
+ const min = 0;
19766
19819
  return {
19767
19820
  id: SetRowHeightCommand.id,
19768
19821
  type: MenuItemType.BUTTON,
@@ -19801,7 +19854,7 @@ function SetColWidthMenuItemFactory(accessor) {
19801
19854
  const commandService = accessor.get(ICommandService);
19802
19855
  const univerInstanceService = accessor.get(IUniverInstanceService);
19803
19856
  const selectionManagerService = accessor.get(SheetsSelectionsService);
19804
- const min = 2;
19857
+ const min = 0;
19805
19858
  return {
19806
19859
  id: SetColWidthCommand.id,
19807
19860
  type: MenuItemType.BUTTON,
@@ -20353,15 +20406,35 @@ function RenameSheetMenuItemFactory(accessor) {
20353
20406
  };
20354
20407
  }
20355
20408
  function ChangeColorSheetMenuItemFactory(accessor) {
20409
+ const univerInstanceService = accessor.get(IUniverInstanceService);
20410
+ const commandService = accessor.get(ICommandService);
20356
20411
  return {
20357
20412
  id: SetTabColorCommand.id,
20358
20413
  title: "sheets-ui.sheetConfig.changeColor",
20359
20414
  type: MenuItemType.SELECTOR,
20360
- selections: [{ label: {
20361
- name: COLOR_PICKER_COMPONENT,
20362
- hoverable: false,
20363
- selectable: false
20364
- } }],
20415
+ selections: [{
20416
+ label: "sheets-ui.toolbar.resetColor",
20417
+ icon: "NoColorDoubleIcon",
20418
+ value: ""
20419
+ }, {
20420
+ label: {
20421
+ name: EditorColorPicker.componentKey,
20422
+ hoverable: false,
20423
+ selectable: false
20424
+ },
20425
+ value$: new Observable((subscriber) => {
20426
+ const updateColor = () => {
20427
+ var _workbook$getActiveSh;
20428
+ const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
20429
+ subscriber.next((workbook === null || workbook === void 0 || (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getTabColor()) ?? "");
20430
+ };
20431
+ updateColor();
20432
+ const disposable = commandService.onCommandExecuted(({ id }) => {
20433
+ if (id === SetTabColorMutation.id || id === SetWorksheetActiveOperation.id) updateColor();
20434
+ });
20435
+ return () => disposable.dispose();
20436
+ })
20437
+ }],
20365
20438
  hidden$: getWorkbookPermissionDisable$(accessor, [WorkbookEditablePermission])
20366
20439
  };
20367
20440
  }
@@ -22795,6 +22868,7 @@ function keepTextSelected(inputHtml) {
22795
22868
  if (!selection) return;
22796
22869
  const range = document.createRange();
22797
22870
  range.selectNodeContents(inputHtml);
22871
+ if (!getEditorText(inputHtml)) range.collapse(true);
22798
22872
  selection.removeAllRanges();
22799
22873
  selection.addRange(range);
22800
22874
  });
@@ -23694,7 +23768,7 @@ function SheetBarTabs() {
23694
23768
  embedChildType != null && /* @__PURE__ */ jsx(EmbedSheetTabProductIcon, { childType: embedChildType }),
23695
23769
  hasProtection && /* @__PURE__ */ jsx(LockIcon, { className: "univer-shrink-0" }),
23696
23770
  /* @__PURE__ */ jsx("span", {
23697
- className: "univer-truncate univer-outline-none",
23771
+ className: "univer-min-w-px univer-truncate univer-outline-none",
23698
23772
  children: sheet.getName()
23699
23773
  })
23700
23774
  ] }),
@@ -25071,7 +25145,7 @@ const useHighlightRange = (ranges = []) => {
25071
25145
  //#endregion
25072
25146
  //#region package.json
25073
25147
  var name = "@univerjs/sheets-ui";
25074
- var version = "1.1.0";
25148
+ var version = "1.3.0";
25075
25149
 
25076
25150
  //#endregion
25077
25151
  //#region src/views/cell-popup/config.ts
@@ -27588,7 +27662,7 @@ const DefinedNameContainer = ({ ConfirmComponent = Confirm, DefinedNameInputComp
27588
27662
  children: [/* @__PURE__ */ jsxs("div", {
27589
27663
  className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-gray-0",
27590
27664
  children: [definedName.name, /* @__PURE__ */ jsx("span", {
27591
- className: "univer-text-xxs univer-ml-1 univer-text-gray-400",
27665
+ className: "univer-ml-1 univer-text-xs univer-text-gray-400",
27592
27666
  children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
27593
27667
  })]
27594
27668
  }), /* @__PURE__ */ jsx("div", {
@@ -28716,7 +28790,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
28716
28790
  }).filter((r) => !!r).join(",") : ""})`;
28717
28791
  } else if (rule.unitType === UnitObject.Worksheet) ruleName = targetName || "";
28718
28792
  return /* @__PURE__ */ jsxs("div", {
28719
- className: clsx("univer-mt-3 univer-rounded-lg univer-p-3 hover:univer-bg-gray-50", borderClassName),
28793
+ className: clsx("univer-mt-3 univer-rounded-lg univer-p-3 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800", borderClassName),
28720
28794
  onMouseMove: () => {
28721
28795
  const { subUnitId, unitType } = rule;
28722
28796
  const activeSheet = workbook.getActiveSheet();
@@ -28750,14 +28824,14 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
28750
28824
  children: [hasManagerPermission && /* @__PURE__ */ jsx(Tooltip, {
28751
28825
  title: localeService.t("sheets-ui.permission.panel.edit"),
28752
28826
  children: /* @__PURE__ */ jsx("div", {
28753
- className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200",
28827
+ className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-700",
28754
28828
  onClick: () => handleEdit(rule),
28755
28829
  children: /* @__PURE__ */ jsx(WriteIcon, {})
28756
28830
  })
28757
28831
  }), hasDeletePermission && /* @__PURE__ */ jsx(Tooltip, {
28758
28832
  title: localeService.t("sheets-ui.permission.panel.delete"),
28759
28833
  children: /* @__PURE__ */ jsx("div", {
28760
- className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200",
28834
+ className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-700",
28761
28835
  onClick: () => handleDelete(rule),
28762
28836
  children: /* @__PURE__ */ jsx(DeleteIcon, {})
28763
28837
  })
@@ -28800,7 +28874,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
28800
28874
  rule.description && /* @__PURE__ */ jsx(Tooltip, {
28801
28875
  title: rule.description,
28802
28876
  children: /* @__PURE__ */ jsx("div", {
28803
- className: "univer-text-3 univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm univer-text-gray-400",
28877
+ className: "univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm univer-text-gray-400",
28804
28878
  children: rule.description
28805
28879
  })
28806
28880
  })
@@ -32115,7 +32189,6 @@ let SheetUIMobileController = class SheetUIMobileController extends Disposable {
32115
32189
  const visualViewport = window.visualViewport;
32116
32190
  let stableHeight = Math.round(window.innerHeight);
32117
32191
  let stableWidth = Math.round(window.innerWidth);
32118
- let keyboardWasVisible = false;
32119
32192
  const update = () => {
32120
32193
  const width = Math.round(window.innerWidth);
32121
32194
  const visibleBottom = visualViewport ? visualViewport.offsetTop + visualViewport.height : window.innerHeight;
@@ -32125,15 +32198,6 @@ let SheetUIMobileController = class SheetUIMobileController extends Disposable {
32125
32198
  } else if (!isMobileKeyboardVisible(stableHeight, visibleBottom)) stableHeight = Math.round(Math.max(stableHeight, window.innerHeight, visibleBottom));
32126
32199
  const keyboardVisible = isMobileKeyboardVisible(stableHeight, visibleBottom);
32127
32200
  this._contextService.setContextValue(MOBILE_KEYBOARD_VISIBLE, keyboardVisible);
32128
- if (shouldHideMobileEditorOnKeyboardClose(keyboardWasVisible && !keyboardVisible, this._contextService.getContextValue("MOBILE_FX_EDITOR_EXPANDED"), this._contextService.getContextValue("MOBILE_FORMULA_FUNCTION_PANEL_OPEN"), this._editorBridgeService.isForceKeepVisible())) {
32129
- const visibleState = this._editorBridgeService.isVisible();
32130
- if (visibleState.visible) this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
32131
- ...visibleState,
32132
- visible: false,
32133
- eventType: DeviceInputEventType.PointerDown
32134
- });
32135
- }
32136
- keyboardWasVisible = keyboardVisible;
32137
32201
  };
32138
32202
  update();
32139
32203
  window.addEventListener("resize", update);
@@ -32190,9 +32254,6 @@ SheetUIMobileController = __decorate([
32190
32254
  function isMobileKeyboardVisible(stableHeight, visibleBottom) {
32191
32255
  return stableHeight - visibleBottom > 80;
32192
32256
  }
32193
- function shouldHideMobileEditorOnKeyboardClose(keyboardClosed, editorExpanded, functionPanelOpen, forceKeepVisible) {
32194
- return keyboardClosed && !editorExpanded && !functionPanelOpen && !forceKeepVisible;
32195
- }
32196
32257
 
32197
32258
  //#endregion
32198
32259
  //#region src/controllers/move-range.controller.ts
@@ -32816,7 +32877,7 @@ let FormatPainterRenderController = class FormatPainterRenderController extends
32816
32877
  getTarget: (event) => {
32817
32878
  var _this$_selections$get, _this$_context$unit$g;
32818
32879
  const picked = this._context.scene.pick(new Vector2(event.offsetX, event.offsetY));
32819
- if (picked && picked !== this._context.mainComponent) return null;
32880
+ if (picked && picked !== this._context.mainComponent && picked !== this._context.components.get("__SpreadsheetRowHeader__") && picked !== this._context.components.get("__SpreadsheetColumnHeader__")) return null;
32820
32881
  const range = (_this$_selections$get = this._selections.getCurrentLastSelection()) === null || _this$_selections$get === void 0 ? void 0 : _this$_selections$get.range;
32821
32882
  return range ? {
32822
32883
  unitId: this._context.unitId,
@@ -33143,27 +33204,22 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
33143
33204
  _defineProperty(this, "_columnResizeButton", void 0);
33144
33205
  _defineProperty(this, "_resizeHelperShape", void 0);
33145
33206
  _defineProperty(this, "_isDragging", false);
33146
- _defineProperty(this, "_touchStartX", 0);
33147
- _defineProperty(this, "_touchStartY", 0);
33148
- _defineProperty(this, "_touchMoveHandler", void 0);
33149
- _defineProperty(this, "_touchEndHandler", void 0);
33207
+ _defineProperty(this, "_resizeListeners", void 0);
33150
33208
  _defineProperty(this, "_selectionSubscription", void 0);
33151
33209
  _defineProperty(this, "_scrollSubscription", void 0);
33152
33210
  this._init();
33153
33211
  }
33154
33212
  dispose() {
33155
- var _this$_rowResizeButto, _this$_columnResizeBu, _this$_resizeHelperSh, _this$_selectionSubsc, _this$_scrollSubscrip;
33213
+ var _this$_rowResizeButto, _this$_columnResizeBu, _this$_selectionSubsc, _this$_scrollSubscrip;
33214
+ this._cancelResize();
33156
33215
  (_this$_rowResizeButto = this._rowResizeButton) === null || _this$_rowResizeButto === void 0 || _this$_rowResizeButto.dispose();
33157
33216
  this._rowResizeButton = null;
33158
33217
  (_this$_columnResizeBu = this._columnResizeButton) === null || _this$_columnResizeBu === void 0 || _this$_columnResizeBu.dispose();
33159
33218
  this._columnResizeButton = null;
33160
- (_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.dispose();
33161
- this._resizeHelperShape = null;
33162
33219
  (_this$_selectionSubsc = this._selectionSubscription) === null || _this$_selectionSubsc === void 0 || _this$_selectionSubsc.unsubscribe();
33163
33220
  this._selectionSubscription = null;
33164
33221
  (_this$_scrollSubscrip = this._scrollSubscription) === null || _this$_scrollSubscrip === void 0 || _this$_scrollSubscrip.unsubscribe();
33165
33222
  this._scrollSubscription = null;
33166
- this._cleanupTouchHandlers();
33167
33223
  super.dispose();
33168
33224
  }
33169
33225
  _init() {
@@ -33184,8 +33240,8 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
33184
33240
  zIndex: 100
33185
33241
  });
33186
33242
  scene.addObjects([this._rowResizeButton, this._columnResizeButton], 10);
33187
- this._bindTouchEventsToButton(this._rowResizeButton, "row");
33188
- this._bindTouchEventsToButton(this._columnResizeButton, "column");
33243
+ this._bindPointerEventsToButton(this._rowResizeButton, "row");
33244
+ this._bindPointerEventsToButton(this._columnResizeButton, "column");
33189
33245
  }
33190
33246
  _initSelectionListener() {
33191
33247
  this._selectionSubscription = this._selectionManagerService.selectionMoveEnd$.subscribe((selections) => {
@@ -33270,12 +33326,13 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
33270
33326
  });
33271
33327
  }
33272
33328
  }
33273
- _bindTouchEventsToButton(button, type) {
33274
- button.onPointerDown$.subscribeEvent((evt) => {
33329
+ _bindPointerEventsToButton(button, type) {
33330
+ this.disposeWithMe(button.onPointerDown$.subscribeEvent((evt) => {
33331
+ if (evt.button !== 0) return;
33275
33332
  if (this._contextService.getContextValue("MOBILE_PINCH_ZOOMING")) return;
33276
33333
  if (this._contextService.getContextValue("MOBILE_EXPANDING_SELECTION")) return;
33277
33334
  this._startResize(evt, type);
33278
- });
33335
+ }));
33279
33336
  }
33280
33337
  _startResize(evt, type) {
33281
33338
  const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
@@ -33284,69 +33341,80 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
33284
33341
  const engine = scene.getEngine();
33285
33342
  const canvasElement = engine === null || engine === void 0 ? void 0 : engine.getCanvasElement();
33286
33343
  if (!canvasElement) return;
33287
- this._touchStartX = evt.offsetX;
33288
- this._touchStartY = evt.offsetY;
33289
- this._isDragging = false;
33344
+ this._cancelResize();
33290
33345
  const currentOffset = type === "row" ? skeleton.getOffsetByRow(this._currentRow) : skeleton.getOffsetByColumn(this._currentColumn);
33291
33346
  this._createResizeHelper(type, currentOffset, skeleton);
33292
33347
  scene.disableObjectsEvent();
33293
- this._setupTouchHandlers(canvasElement, type, currentOffset);
33348
+ this._setupPointerHandlers(canvasElement, evt, type, currentOffset);
33294
33349
  }
33295
- _setupTouchHandlers(canvasElement, type, initialOffset) {
33296
- if (!this._sheetSkeletonManagerService.getCurrentSkeleton()) return;
33297
- const scene = this._context.scene;
33350
+ _setupPointerHandlers(canvasElement, evt, type, initialOffset) {
33298
33351
  const worksheet = this._context.unit.getActiveSheet();
33299
- const zoomRatio = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getZoomRatio()) || 1;
33352
+ if (!worksheet) {
33353
+ this._cancelResize();
33354
+ return;
33355
+ }
33356
+ const zoomRatio = worksheet.getZoomRatio() || 1;
33357
+ const initialSize = type === "row" ? worksheet.getRowHeight(this._currentRow) : worksheet.getColumnWidth(this._currentColumn);
33358
+ const anchor = type === "row" ? this._currentRow : this._currentColumn;
33359
+ const pointerId = "pointerId" in evt ? evt.pointerId : 0;
33360
+ const startX = evt.offsetX;
33361
+ const startY = evt.offsetY;
33300
33362
  let totalDelta = 0;
33301
- this._touchMoveHandler = (e) => {
33363
+ const handlePointerMove = (e) => {
33364
+ if (e.pointerId !== pointerId) return;
33302
33365
  if (this._contextService.getContextValue("MOBILE_PINCH_ZOOMING")) {
33303
33366
  this._cancelResize();
33304
33367
  return;
33305
33368
  }
33306
- if (e.touches.length !== 1) return;
33307
- const touch = e.touches[0];
33308
33369
  const rect = canvasElement.getBoundingClientRect();
33309
- const offsetX = touch.clientX - rect.left;
33310
- const offsetY = touch.clientY - rect.top;
33311
- const adjustedDelta = (type === "row" ? offsetY - this._touchStartY : offsetX - this._touchStartX) / zoomRatio;
33370
+ const offsetX = e.clientX - rect.left;
33371
+ const offsetY = e.clientY - rect.top;
33372
+ const adjustedDelta = (type === "row" ? offsetY - startY : offsetX - startX) / zoomRatio;
33312
33373
  if (Math.abs(adjustedDelta) >= MINIMAL_OFFSET) this._isDragging = true;
33313
33374
  if (this._isDragging) {
33314
- totalDelta = adjustedDelta;
33315
- this._updateResizeHelper(type, initialOffset + adjustedDelta);
33316
- this._updateResizeButton(type, initialOffset + adjustedDelta);
33375
+ totalDelta = Math.max(adjustedDelta, -initialSize);
33376
+ this._updateResizeHelper(type, initialOffset + totalDelta);
33377
+ this._updateResizeButton(type, initialOffset + totalDelta);
33317
33378
  }
33318
33379
  e.preventDefault();
33319
33380
  };
33320
- this._touchEndHandler = (e) => {
33321
- scene.enableObjectsEvent();
33322
- if (this._isDragging && Math.abs(totalDelta) >= MINIMAL_OFFSET) {
33323
- if (type === "row") this._commandService.executeCommand(DeltaRowHeightCommand.id, {
33324
- deltaY: totalDelta,
33325
- anchorRow: this._currentRow
33326
- });
33327
- else this._commandService.executeCommand(DeltaColumnWidthCommand.id, {
33328
- deltaX: totalDelta,
33329
- anchorCol: this._currentColumn
33330
- });
33331
- }
33381
+ const handlePointerUp = async (e) => {
33382
+ if (e.pointerId !== pointerId) return;
33383
+ const shouldResize = this._isDragging && totalDelta !== 0;
33332
33384
  this._cleanupResize();
33333
- if (this._touchMoveHandler) canvasElement.removeEventListener("touchmove", this._touchMoveHandler);
33334
- if (this._touchEndHandler) {
33335
- canvasElement.removeEventListener("touchend", this._touchEndHandler);
33336
- canvasElement.removeEventListener("touchcancel", this._touchEndHandler);
33337
- }
33338
33385
  e.preventDefault();
33386
+ if (shouldResize) await this._commandService.executeCommand(type === "row" ? DeltaRowHeightCommand.id : DeltaColumnWidthCommand.id, type === "row" ? {
33387
+ deltaY: totalDelta,
33388
+ anchorRow: anchor
33389
+ } : {
33390
+ deltaX: totalDelta,
33391
+ anchorCol: anchor
33392
+ });
33339
33393
  };
33340
- canvasElement.addEventListener("touchmove", this._touchMoveHandler, { passive: false });
33341
- canvasElement.addEventListener("touchend", this._touchEndHandler, { passive: false });
33342
- canvasElement.addEventListener("touchcancel", this._touchEndHandler, { passive: false });
33343
- this.disposeWithMe(toDisposable(() => {
33344
- if (this._touchMoveHandler) canvasElement.removeEventListener("touchmove", this._touchMoveHandler);
33345
- if (this._touchEndHandler) {
33346
- canvasElement.removeEventListener("touchend", this._touchEndHandler);
33347
- canvasElement.removeEventListener("touchcancel", this._touchEndHandler);
33348
- }
33349
- }));
33394
+ this._bindResizeListeners(canvasElement, pointerId, handlePointerMove, handlePointerUp);
33395
+ }
33396
+ _bindResizeListeners(canvasElement, pointerId, handlePointerMove, handlePointerUp) {
33397
+ const ownerDocument = canvasElement.ownerDocument;
33398
+ const ownerWindow = ownerDocument.defaultView;
33399
+ const handlePointerCancel = (e) => {
33400
+ if (e.pointerId === pointerId) this._cancelResize();
33401
+ };
33402
+ const handlePointerDown = (e) => {
33403
+ if (e.pointerId !== pointerId) this._cancelResize();
33404
+ };
33405
+ const handleBlur = () => this._cancelResize();
33406
+ ownerDocument.addEventListener("pointermove", handlePointerMove, { passive: false });
33407
+ ownerDocument.addEventListener("pointerup", handlePointerUp);
33408
+ ownerDocument.addEventListener("pointercancel", handlePointerCancel);
33409
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
33410
+ ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("blur", handleBlur);
33411
+ this._resizeListeners = toDisposable(() => {
33412
+ ownerDocument.removeEventListener("pointermove", handlePointerMove);
33413
+ ownerDocument.removeEventListener("pointerup", handlePointerUp);
33414
+ ownerDocument.removeEventListener("pointercancel", handlePointerCancel);
33415
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
33416
+ ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("blur", handleBlur);
33417
+ });
33350
33418
  }
33351
33419
  _createResizeHelper(type, offset, skeleton) {
33352
33420
  const scene = this._context.scene;
@@ -33387,30 +33455,18 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
33387
33455
  else button.transformByState({ left: newOffset - buttonSize / 2 });
33388
33456
  }
33389
33457
  _cleanupResize() {
33390
- var _this$_resizeHelperSh2;
33391
- (_this$_resizeHelperSh2 = this._resizeHelperShape) === null || _this$_resizeHelperSh2 === void 0 || _this$_resizeHelperSh2.dispose();
33458
+ var _this$_resizeListener, _this$_resizeHelperSh;
33459
+ (_this$_resizeListener = this._resizeListeners) === null || _this$_resizeListener === void 0 || _this$_resizeListener.dispose();
33460
+ this._resizeListeners = null;
33461
+ this._context.scene.enableObjectsEvent();
33462
+ (_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.dispose();
33392
33463
  this._resizeHelperShape = null;
33393
33464
  this._isDragging = false;
33394
33465
  }
33395
- _cleanupTouchHandlers() {
33396
- const engine = this._context.scene.getEngine();
33397
- const canvasElement = engine === null || engine === void 0 ? void 0 : engine.getCanvasElement();
33398
- if (canvasElement) {
33399
- if (this._touchMoveHandler) {
33400
- canvasElement.removeEventListener("touchmove", this._touchMoveHandler);
33401
- this._touchMoveHandler = null;
33402
- }
33403
- if (this._touchEndHandler) {
33404
- canvasElement.removeEventListener("touchend", this._touchEndHandler);
33405
- canvasElement.removeEventListener("touchcancel", this._touchEndHandler);
33406
- this._touchEndHandler = null;
33407
- }
33408
- }
33409
- }
33410
33466
  _cancelResize() {
33411
- this._context.scene.enableObjectsEvent();
33467
+ if (!this._resizeHelperShape && !this._resizeListeners) return;
33412
33468
  this._cleanupResize();
33413
- this._cleanupTouchHandlers();
33469
+ this._updateButtonPositionOnScroll();
33414
33470
  }
33415
33471
  };
33416
33472
  MobileHeaderResizeRenderController = __decorate([
@@ -33424,6 +33480,7 @@ MobileHeaderResizeRenderController = __decorate([
33424
33480
  //#endregion
33425
33481
  //#region src/controllers/render-controllers/mobile/mobile-hover.render-controller.ts
33426
33482
  const TAP_MOVE_THRESHOLD = 10;
33483
+ const DOUBLE_TAP_MOVE_THRESHOLD = 20;
33427
33484
  const DOUBLE_TAP_DELAY = 500;
33428
33485
  function getPointerId(event) {
33429
33486
  return "pointerId" in event ? event.pointerId : void 0;
@@ -33499,6 +33556,7 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33499
33556
  next: ([event, state]) => {
33500
33557
  state.stopPropagation();
33501
33558
  state.skipNextObservers = true;
33559
+ if (event.deviceType === DeviceType.Touch) return;
33502
33560
  if (this._suppressEngineDoubleClick) {
33503
33561
  this._clearEngineDoubleClickSuppression();
33504
33562
  return;
@@ -33549,15 +33607,15 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33549
33607
  return;
33550
33608
  }
33551
33609
  this._tapState = {
33552
- offsetX: event.offsetX,
33553
- offsetY: event.offsetY,
33610
+ clientX: event.clientX,
33611
+ clientY: event.clientY,
33554
33612
  pointerId: getPointerId(event)
33555
33613
  };
33556
33614
  }
33557
33615
  _updateTapState(event) {
33558
33616
  const pointerId = getPointerId(event);
33559
33617
  if (!this._tapState || pointerId != null && pointerId !== this._tapState.pointerId) return;
33560
- if (Math.abs(event.offsetX - this._tapState.offsetX) > TAP_MOVE_THRESHOLD || Math.abs(event.offsetY - this._tapState.offsetY) > TAP_MOVE_THRESHOLD) this._resetTapSequence();
33618
+ if (Math.abs(event.clientX - this._tapState.clientX) > TAP_MOVE_THRESHOLD || Math.abs(event.clientY - this._tapState.clientY) > TAP_MOVE_THRESHOLD) this._resetTapSequence();
33561
33619
  }
33562
33620
  _finishTap(event) {
33563
33621
  const tapState = this._tapState;
@@ -33567,14 +33625,28 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33567
33625
  this._resetCompletedTap();
33568
33626
  return false;
33569
33627
  }
33570
- const completed = Math.abs(event.offsetX - tapState.offsetX) <= TAP_MOVE_THRESHOLD && Math.abs(event.offsetY - tapState.offsetY) <= TAP_MOVE_THRESHOLD && !this._contextService.getContextValue("MOBILE_PINCH_ZOOMING") && !this._contextService.getContextValue("MOBILE_EXPANDING_SELECTION") && !this._contextService.getContextValue("MOBILE_TRIGGER_CONTEXT_MENU");
33628
+ const completed = Math.abs(event.clientX - tapState.clientX) <= TAP_MOVE_THRESHOLD && Math.abs(event.clientY - tapState.clientY) <= TAP_MOVE_THRESHOLD && !this._contextService.getContextValue("MOBILE_PINCH_ZOOMING") && !this._contextService.getContextValue("MOBILE_EXPANDING_SELECTION") && !this._contextService.getContextValue("MOBILE_TRIGGER_CONTEXT_MENU");
33571
33629
  if (!completed) this._resetCompletedTap();
33572
33630
  return completed;
33573
33631
  }
33574
33632
  _completeTap(unitId, event) {
33633
+ const skeletonParam = this._sheetSkeletonManagerService.getCurrentParam();
33634
+ const cellIndex = skeletonParam && getCellIndexByOffsetWithMerge(event.offsetX, event.offsetY, this._context.scene, skeletonParam.skeleton);
33635
+ if (!cellIndex || !skeletonParam) {
33636
+ this._resetCompletedTap();
33637
+ return;
33638
+ }
33639
+ const cell = {
33640
+ unitId,
33641
+ subUnitId: skeletonParam.sheetId,
33642
+ row: cellIndex.actualRow,
33643
+ col: cellIndex.actualCol
33644
+ };
33645
+ const timeStamp = Number.isFinite(event.timeStamp) ? event.timeStamp : performance.now();
33575
33646
  const lastCompletedTap = this._lastCompletedTap;
33576
- if (lastCompletedTap && Math.abs(event.offsetX - lastCompletedTap.offsetX) <= TAP_MOVE_THRESHOLD && Math.abs(event.offsetY - lastCompletedTap.offsetY) <= TAP_MOVE_THRESHOLD) {
33647
+ if (lastCompletedTap && timeStamp >= lastCompletedTap.timeStamp && timeStamp - lastCompletedTap.timeStamp <= DOUBLE_TAP_DELAY && cell.unitId === lastCompletedTap.cell.unitId && cell.subUnitId === lastCompletedTap.cell.subUnitId && cell.row === lastCompletedTap.cell.row && cell.col === lastCompletedTap.cell.col && Math.abs(event.clientX - lastCompletedTap.clientX) <= DOUBLE_TAP_MOVE_THRESHOLD && Math.abs(event.clientY - lastCompletedTap.clientY) <= DOUBLE_TAP_MOVE_THRESHOLD) {
33577
33648
  this._resetCompletedTap();
33649
+ this._clearEngineDoubleClickSuppression();
33578
33650
  this._suppressEngineDoubleClick = true;
33579
33651
  this._suppressEngineDoubleClickTimer = setTimeout(() => {
33580
33652
  this._suppressEngineDoubleClick = false;
@@ -33585,9 +33657,10 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33585
33657
  }
33586
33658
  this._resetCompletedTap();
33587
33659
  this._lastCompletedTap = {
33588
- offsetX: event.offsetX,
33589
- offsetY: event.offsetY,
33590
- pointerId: getPointerId(event)
33660
+ clientX: event.clientX,
33661
+ clientY: event.clientY,
33662
+ timeStamp,
33663
+ cell
33591
33664
  };
33592
33665
  this._completedTapTimer = setTimeout(() => this._resetCompletedTap(), DOUBLE_TAP_DELAY);
33593
33666
  }
@@ -35420,7 +35493,7 @@ _defineProperty(UniverSheetsMobileUIPlugin, "packageName", name);
35420
35493
  _defineProperty(UniverSheetsMobileUIPlugin, "version", version);
35421
35494
  _defineProperty(UniverSheetsMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
35422
35495
  UniverSheetsMobileUIPlugin = __decorate([
35423
- DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverMobileUIPlugin, UniverDocsUIPlugin),
35496
+ DependentOn(UniverDocsPlugin, UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverMobileUIPlugin, UniverDocsMobileUIPlugin),
35424
35497
  __decorateParam(1, Inject(Injector)),
35425
35498
  __decorateParam(2, IRenderManagerService),
35426
35499
  __decorateParam(3, IConfigService),
@@ -35790,6 +35863,12 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
35790
35863
  var _params;
35791
35864
  if (params === null || params === void 0 || (_params = params[params.length - 1]) === null || _params === void 0 ? void 0 : _params.primary) this._updateInputPosition();
35792
35865
  }));
35866
+ const viewportMain = this._context.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
35867
+ if (viewportMain) d.add(viewportMain.onScrollEnd$.subscribeEvent(() => {
35868
+ if (this._editorBridgeService.isVisible().visible) return;
35869
+ this._editorBridgeService.refreshEditCellPosition(false);
35870
+ this._updateInputPosition();
35871
+ }));
35793
35872
  }
35794
35873
  _updateInputPosition() {
35795
35874
  var _this$_renderManagerS;
@@ -35797,8 +35876,8 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
35797
35876
  const layout = this._editorBridgeService.getEditCellLayout();
35798
35877
  const docSelectionRenderService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocSelectionRenderService);
35799
35878
  if (!layout || !docSelectionRenderService) return;
35800
- const { position, canvasOffset } = layout;
35801
- docSelectionRenderService.setInputPosition(canvasOffset.left + position.startX, canvasOffset.top + position.startY);
35879
+ const { x, y } = getEditCellInputPosition(layout, this._context.engine);
35880
+ docSelectionRenderService.setInputPosition(x, y);
35802
35881
  }
35803
35882
  _focusCellEditorInput() {
35804
35883
  const focusedChildUnitId = getEmbedChildUnitId(typeof document === "undefined" ? null : document.activeElement);