@univerjs/sheets-ui 1.0.3 → 1.0.4

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
@@ -2,7 +2,7 @@ import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX,
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
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, ZoomInput, bindFormatPainterCanvas, connectInjector, getEmbedBoundaryOwner, getEmbedChildUnitId, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useToolbarItemStatus, useVirtualList } from "@univerjs/ui";
5
- import { CURSOR_TYPE, DashedRect, DeviceInputEventType, DeviceType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, 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";
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";
8
8
  import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
@@ -437,6 +437,15 @@ const SetColumnHeaderHeightCommand = {
437
437
  }
438
438
  };
439
439
 
440
+ //#endregion
441
+ //#region src/common/selection-input.ts
442
+ function isSheetContextMenuGesture(event, isMac, refSelectionsEnabled) {
443
+ return event.button === 2 || isMac && !refSelectionsEnabled && event.button === 0 && event.ctrlKey;
444
+ }
445
+ function isSheetMultiSelectModifier(event, isMac) {
446
+ return isMac ? event.metaKey : event.ctrlKey;
447
+ }
448
+
440
449
  //#endregion
441
450
  //#region src/services/selection/selection-layer.ts
442
451
  var SelectionLayer = class extends Layer {
@@ -941,9 +950,15 @@ var BaseSelectionRenderService = class extends Disposable {
941
950
  rangeWithCoord
942
951
  };
943
952
  }
953
+ _isContextMenuGesture(evt) {
954
+ return isSheetContextMenuGesture(evt, this._injector.get(IPlatformService).isMac, this.inRefSelectionMode());
955
+ }
956
+ _isMultiSelectModifier(evt) {
957
+ return isSheetMultiSelectModifier(evt, this._injector.get(IPlatformService).isMac);
958
+ }
944
959
  _checkClearPreviousControls(evt) {
945
960
  if (this.getSelectionControls().length === 0) return;
946
- if (!evt.ctrlKey && !evt.metaKey && !evt.shiftKey && !this._remainLastEnabled || this._singleSelectionEnabled && !evt.shiftKey) this._clearAllSelectionControls();
961
+ if (this._isContextMenuGesture(evt) && !this.inRefSelectionMode() || !this._isMultiSelectModifier(evt) && !evt.shiftKey && !this._remainLastEnabled || this._singleSelectionEnabled && !evt.shiftKey) this._clearAllSelectionControls();
947
962
  }
948
963
  _makeSelectionByTwoCells(currentCell, startSelectionRange, skeleton, rangeType, activeControl) {
949
964
  const { actualRow, actualColumn, mergeInfo: actualMergeInfo } = currentCell;
@@ -1849,6 +1864,7 @@ var SelectionShapeExtension = class {
1849
1864
  //#endregion
1850
1865
  //#region src/services/selection/selection-control.ts
1851
1866
  const SELECTION_TITLE_HIGHLIGHT_ALPHA = .3;
1867
+ const SELECTION_MOVE_DURATION = 120;
1852
1868
  /**
1853
1869
  * The main selection canvas component, includes leftControl,rightControl,topControl,bottomControl,backgroundControlTop,backgroundControlMiddleLeft,backgroundControlMiddleRight,backgroundControlBottom,fillControl
1854
1870
  */
@@ -1858,6 +1874,9 @@ var SelectionControl = class extends Disposable {
1858
1874
  this._scene = _scene;
1859
1875
  this._zIndex = _zIndex;
1860
1876
  this._themeService = _themeService;
1877
+ _defineProperty(this, "_moveAnimationFrame", -1);
1878
+ _defineProperty(this, "_animatedRange", null);
1879
+ _defineProperty(this, "_restoreMoveEvents", null);
1861
1880
  _defineProperty(this, "_isHelperSelection", true);
1862
1881
  _defineProperty(this, "_enableAutoFill", true);
1863
1882
  _defineProperty(this, "_showAutoFill", false);
@@ -1969,6 +1988,7 @@ var SelectionControl = class extends Disposable {
1969
1988
  scene.addObject(this._selectionShapeGroup, 1);
1970
1989
  this.disposeWithMe(toDisposable(scene.onTransformChange$.subscribeEvent((state) => {
1971
1990
  if (state.type !== TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale) return;
1991
+ this._stopMoveAnimation();
1972
1992
  this._updateLayoutOfSelectionControl(this._currentStyle);
1973
1993
  this._updateControlCoord();
1974
1994
  })));
@@ -2131,6 +2151,11 @@ var SelectionControl = class extends Disposable {
2131
2151
  if (this._controlExtension) this._controlExtension.setDisabled(disable);
2132
2152
  }
2133
2153
  setEvent(state) {
2154
+ if (this._animatedRange) {
2155
+ this._stopMoveAnimation();
2156
+ this._updateLayoutOfSelectionControl();
2157
+ this._updateControlCoord();
2158
+ }
2134
2159
  this.leftControl.evented = state;
2135
2160
  this.rightControl.evented = state;
2136
2161
  this.topControl.evented = state;
@@ -2157,7 +2182,7 @@ var SelectionControl = class extends Disposable {
2157
2182
  autofillStrokeWidth /= scale < 1 ? 1 : scale;
2158
2183
  const borderBuffer = SELECTION_CONTROL_BORDER_BUFFER_WIDTH / scale;
2159
2184
  const fixOnePixelBlurOffset = FIX_ONE_PIXEL_BLUR_OFFSET / scale;
2160
- const { startX, startY, endX, endY } = this._selectionRenderModel;
2185
+ const { startX, startY, endX, endY } = this._animatedRange ?? this._selectionRenderModel;
2161
2186
  this.leftControl.transformByState({
2162
2187
  height: endY - startY,
2163
2188
  left: -leftAdjustWidth + fixOnePixelBlurOffset,
@@ -2238,19 +2263,20 @@ var SelectionControl = class extends Disposable {
2238
2263
  this._autoFillControl.show();
2239
2264
  } else this._autoFillControl.hide();
2240
2265
  this._updateBackgroundControl(currentStyle);
2241
- this._updateHeaderBackground(currentStyle);
2266
+ if (!this._animatedRange) this._updateHeaderBackground(currentStyle);
2242
2267
  this._updateWidgets(currentStyle);
2243
2268
  }
2244
2269
  /**
2245
2270
  * update selection control coordination by curr selection model
2246
2271
  */
2247
2272
  _updateControlCoord() {
2248
- const { startX, startY } = this._selectionRenderModel;
2273
+ const { startX, startY } = this._animatedRange ?? this._selectionRenderModel;
2249
2274
  this.selectionShapeGroup.show();
2250
2275
  this.selectionShapeGroup.translate(startX, startY);
2251
2276
  this.selectionShapeGroup.makeDirtyNoDebounce(true);
2252
2277
  }
2253
2278
  updateStyle(style) {
2279
+ this._stopMoveAnimation();
2254
2280
  this._updateLayoutOfSelectionControl(style);
2255
2281
  this._updateControlCoord();
2256
2282
  }
@@ -2264,6 +2290,7 @@ var SelectionControl = class extends Disposable {
2264
2290
  * @param primaryWithCoord
2265
2291
  */
2266
2292
  updateRange(rangeWithCoord, primaryWithCoord) {
2293
+ this._stopMoveAnimation();
2267
2294
  this._selectionRenderModel.setValue(rangeWithCoord, primaryWithCoord);
2268
2295
  this._showAutoFill = primaryWithCoord !== null;
2269
2296
  this._updateLayoutOfSelectionControl();
@@ -2273,7 +2300,11 @@ var SelectionControl = class extends Disposable {
2273
2300
  * Update range and primary range and style.
2274
2301
  * @param selectionWthCoord
2275
2302
  */
2276
- updateRangeBySelectionWithCoord(selectionWthCoord, sk) {
2303
+ updateRangeBySelectionWithCoord(selectionWthCoord, sk, animate = false) {
2304
+ const previousRange = this._animatedRange ?? this.getRange();
2305
+ const targetRange = selectionWthCoord.rangeWithCoord;
2306
+ const rangeChanged = !Rectangle.equals(this.model, targetRange) || this.model.startX !== targetRange.startX || this.model.startY !== targetRange.startY || this.model.endX !== targetRange.endX || this.model.endY !== targetRange.endY;
2307
+ if (animate || rangeChanged || selectionWthCoord.primaryWithCoord === null) this._stopMoveAnimation();
2277
2308
  if (sk) {
2278
2309
  this._rowHeaderWidth = sk.rowHeaderWidth;
2279
2310
  this._columnHeaderHeight = sk.columnHeaderHeight;
@@ -2284,6 +2315,47 @@ var SelectionControl = class extends Disposable {
2284
2315
  this._showAutoFill = selectionWthCoord.primaryWithCoord !== null;
2285
2316
  this._updateLayoutOfSelectionControl(selectionWthCoord.style);
2286
2317
  this._updateControlCoord();
2318
+ if (animate && rangeChanged && !window.matchMedia("(prefers-reduced-motion: reduce)").matches) this._animateMove(previousRange);
2319
+ }
2320
+ _animateMove(from) {
2321
+ const target = this.getRange();
2322
+ const startedAt = Tools.now();
2323
+ const eventedShapes = this.selectionShapeGroup.getObjects().filter((shape) => shape.evented);
2324
+ eventedShapes.forEach((shape) => {
2325
+ shape.evented = false;
2326
+ });
2327
+ this._restoreMoveEvents = () => eventedShapes.forEach((shape) => {
2328
+ shape.evented = true;
2329
+ });
2330
+ this._animatedRange = from;
2331
+ this._updateLayoutOfSelectionControl();
2332
+ this._updateControlCoord();
2333
+ const frame = () => {
2334
+ const progress = Math.min(1, (Tools.now() - startedAt) / SELECTION_MOVE_DURATION);
2335
+ const eased = 1 - (1 - progress) ** 3;
2336
+ if (progress === 1) this._stopMoveAnimation();
2337
+ this._animatedRange = progress < 1 ? {
2338
+ ...target,
2339
+ startX: from.startX + (target.startX - from.startX) * eased,
2340
+ startY: from.startY + (target.startY - from.startY) * eased,
2341
+ endX: from.endX + (target.endX - from.endX) * eased,
2342
+ endY: from.endY + (target.endY - from.endY) * eased
2343
+ } : null;
2344
+ this._updateLayoutOfSelectionControl();
2345
+ this._updateControlCoord();
2346
+ this._moveAnimationFrame = progress < 1 ? requestNewFrame(frame) : -1;
2347
+ };
2348
+ this._moveAnimationFrame = requestNewFrame(frame);
2349
+ }
2350
+ _stopMoveAnimation() {
2351
+ var _this$_restoreMoveEve;
2352
+ if (this._moveAnimationFrame !== -1) {
2353
+ cancelRequestFrame(this._moveAnimationFrame);
2354
+ this._moveAnimationFrame = -1;
2355
+ }
2356
+ this._animatedRange = null;
2357
+ (_this$_restoreMoveEve = this._restoreMoveEvents) === null || _this$_restoreMoveEve === void 0 || _this$_restoreMoveEve.call(this);
2358
+ this._restoreMoveEvents = null;
2287
2359
  }
2288
2360
  /**
2289
2361
  * Update primary range.
@@ -2298,40 +2370,22 @@ var SelectionControl = class extends Disposable {
2298
2370
  this._selectionRenderModel.setCurrentCell(primaryCell);
2299
2371
  }
2300
2372
  clearHighlight() {
2373
+ this._stopMoveAnimation();
2301
2374
  this._showAutoFill = false;
2302
2375
  this._selectionRenderModel.clearCurrentCell();
2303
2376
  this._updateLayoutOfSelectionControl(this._currentStyle);
2377
+ this._updateControlCoord();
2304
2378
  }
2305
2379
  getScene() {
2306
2380
  return this._scene;
2307
2381
  }
2308
2382
  dispose() {
2309
- var _this$_leftBorder, _this$_rightBorder, _this$_topBorder, _this$_bottomBorder, _this$_backgroundCont, _this$_backgroundCont2, _this$_backgroundCont3, _this$_backgroundCont4, _this$_selectionShape, _this$_rowHeaderBackg, _this$_rowHeaderBorde, _this$_rowHeaderGroup, _this$_rowHeaderBackg2, _this$_columnHeaderBa, _this$_columnHeaderBo, _this$_columnHeaderGr, _this$_topLeftWidget, _this$_topCenterWidge, _this$_topRightWidget, _this$_middleLeftWidg, _this$_middleRightWid, _this$_bottomLeftWidg, _this$_bottomCenterWi, _this$_bottomRightWid, _this$_controlExtensi;
2310
- (_this$_leftBorder = this._leftBorder) === null || _this$_leftBorder === void 0 || _this$_leftBorder.dispose();
2311
- (_this$_rightBorder = this._rightBorder) === null || _this$_rightBorder === void 0 || _this$_rightBorder.dispose();
2312
- (_this$_topBorder = this._topBorder) === null || _this$_topBorder === void 0 || _this$_topBorder.dispose();
2313
- (_this$_bottomBorder = this._bottomBorder) === null || _this$_bottomBorder === void 0 || _this$_bottomBorder.dispose();
2314
- (_this$_backgroundCont = this._backgroundControlTop) === null || _this$_backgroundCont === void 0 || _this$_backgroundCont.dispose();
2315
- (_this$_backgroundCont2 = this._backgroundControlMiddleLeft) === null || _this$_backgroundCont2 === void 0 || _this$_backgroundCont2.dispose();
2316
- (_this$_backgroundCont3 = this._backgroundControlMiddleRight) === null || _this$_backgroundCont3 === void 0 || _this$_backgroundCont3.dispose();
2317
- (_this$_backgroundCont4 = this._backgroundControlBottom) === null || _this$_backgroundCont4 === void 0 || _this$_backgroundCont4.dispose();
2318
- this._autoFillControl.dispose();
2319
- (_this$_selectionShape = this._selectionShapeGroup) === null || _this$_selectionShape === void 0 || _this$_selectionShape.dispose();
2320
- (_this$_rowHeaderBackg = this._rowHeaderBackground) === null || _this$_rowHeaderBackg === void 0 || _this$_rowHeaderBackg.dispose();
2321
- (_this$_rowHeaderBorde = this._rowHeaderBorder) === null || _this$_rowHeaderBorde === void 0 || _this$_rowHeaderBorde.dispose();
2322
- (_this$_rowHeaderGroup = this._rowHeaderGroup) === null || _this$_rowHeaderGroup === void 0 || _this$_rowHeaderGroup.dispose();
2323
- (_this$_rowHeaderBackg2 = this._rowHeaderBackground) === null || _this$_rowHeaderBackg2 === void 0 || _this$_rowHeaderBackg2.dispose();
2324
- (_this$_columnHeaderBa = this._columnHeaderBackground) === null || _this$_columnHeaderBa === void 0 || _this$_columnHeaderBa.dispose();
2325
- (_this$_columnHeaderBo = this._columnHeaderBorder) === null || _this$_columnHeaderBo === void 0 || _this$_columnHeaderBo.dispose();
2326
- (_this$_columnHeaderGr = this._columnHeaderGroup) === null || _this$_columnHeaderGr === void 0 || _this$_columnHeaderGr.dispose();
2327
- (_this$_topLeftWidget = this._topLeftWidget) === null || _this$_topLeftWidget === void 0 || _this$_topLeftWidget.dispose();
2328
- (_this$_topCenterWidge = this._topCenterWidget) === null || _this$_topCenterWidge === void 0 || _this$_topCenterWidge.dispose();
2329
- (_this$_topRightWidget = this._topRightWidget) === null || _this$_topRightWidget === void 0 || _this$_topRightWidget.dispose();
2330
- (_this$_middleLeftWidg = this._middleLeftWidget) === null || _this$_middleLeftWidg === void 0 || _this$_middleLeftWidg.dispose();
2331
- (_this$_middleRightWid = this._middleRightWidget) === null || _this$_middleRightWid === void 0 || _this$_middleRightWid.dispose();
2332
- (_this$_bottomLeftWidg = this._bottomLeftWidget) === null || _this$_bottomLeftWidg === void 0 || _this$_bottomLeftWidg.dispose();
2333
- (_this$_bottomCenterWi = this._bottomCenterWidget) === null || _this$_bottomCenterWi === void 0 || _this$_bottomCenterWi.dispose();
2334
- (_this$_bottomRightWid = this._bottomRightWidget) === null || _this$_bottomRightWid === void 0 || _this$_bottomRightWid.dispose();
2383
+ var _this$_controlExtensi;
2384
+ this._stopMoveAnimation();
2385
+ this._stopAntLineAnimation();
2386
+ this._selectionShapeGroup.dispose();
2387
+ this._rowHeaderGroup.dispose();
2388
+ this._columnHeaderGroup.dispose();
2335
2389
  (_this$_controlExtensi = this._controlExtension) === null || _this$_controlExtensi === void 0 || _this$_controlExtensi.dispose();
2336
2390
  super.dispose();
2337
2391
  this._dispose$.next(this);
@@ -2431,12 +2485,12 @@ var SelectionControl = class extends Disposable {
2431
2485
  this._rowHeaderGroup.makeDirty(true);
2432
2486
  }
2433
2487
  _updateBackgroundControl(style) {
2434
- const { startX, startY, endX, endY } = this._selectionRenderModel;
2488
+ const { startX, startY, endX, endY } = this._animatedRange ?? this._selectionRenderModel;
2435
2489
  const scale = this._getScale();
2436
2490
  const { fill = style.fill } = style;
2437
2491
  let { strokeWidth } = style;
2438
2492
  strokeWidth /= scale;
2439
- const highlightSelection = this._selectionRenderModel.highlightToSelection();
2493
+ const highlightSelection = this._animatedRange ?? this._selectionRenderModel.highlightToSelection();
2440
2494
  if (!highlightSelection) {
2441
2495
  this._backgroundControlTop.resize(endX - startX, endY - startY);
2442
2496
  this._backgroundControlTop.setProps({ fill });
@@ -2497,7 +2551,7 @@ var SelectionControl = class extends Disposable {
2497
2551
  this._backgroundControlBottom.setProps({ fill });
2498
2552
  }
2499
2553
  _updateWidgets(style) {
2500
- const { startX, startY, endX, endY } = this._selectionRenderModel;
2554
+ const { startX, startY, endX, endY } = this._animatedRange ?? this._selectionRenderModel;
2501
2555
  const { stroke = style.stroke, widgets = style.widgets, widgetStroke = style.widgetStroke } = style;
2502
2556
  const scale = this._getScale();
2503
2557
  let { widgetSize, widgetStrokeWidth } = style;
@@ -4621,6 +4675,19 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4621
4675
  const start = pasteTarget.pastedRange.rows[0];
4622
4676
  const end = range.rows[range.rows.length - 1] - range.rows[0] + start;
4623
4677
  pasteTarget.pastedRange.rows = Array.from(new Array(end + 1).keys()).slice(start);
4678
+ if (!skipCellCopy) {
4679
+ if (!await this._injector.get(SheetInterceptorService).beforeCommandExecute({
4680
+ id: MoveRangeCommand.id,
4681
+ params: {
4682
+ fromUnitId: copyUnitId,
4683
+ fromSubUnitId: copySubUnitId,
4684
+ fromRange: discreteRangeToRange(range),
4685
+ toUnitId: target.unitId,
4686
+ toSubUnitId: target.subUnitId,
4687
+ toRange: discreteRangeToRange(pasteTarget.pastedRange)
4688
+ }
4689
+ })) return false;
4690
+ }
4624
4691
  }
4625
4692
  const pasteRes = this._pasteUSM({
4626
4693
  cellMatrix,
@@ -6951,6 +7018,30 @@ const SetFirstColumnFrozenCommand = {
6951
7018
  }
6952
7019
  };
6953
7020
 
7021
+ //#endregion
7022
+ //#region src/config/config.ts
7023
+ const SHEETS_UI_PLUGIN_CONFIG_KEY = "sheets-ui.config";
7024
+ const configSymbol = Symbol(SHEETS_UI_PLUGIN_CONFIG_KEY);
7025
+ const defaultPluginConfig = {
7026
+ allowArrowKeyWrapOnSheetBoundary: true,
7027
+ formulaBar: true,
7028
+ protectedRangeShadow: true,
7029
+ maxAutoHeightCount: 1e3
7030
+ };
7031
+ /**
7032
+ * Convert the protectedRangeShadow config to shadow strategy
7033
+ * - true -> 'always'
7034
+ * - false -> 'none'
7035
+ * - string values remain unchanged
7036
+ * @param config The protectedRangeShadow config value
7037
+ * @returns The shadow strategy
7038
+ */
7039
+ function convertToShadowStrategy(config) {
7040
+ if (config === true) return "always";
7041
+ if (config === false) return "none";
7042
+ return config || "always";
7043
+ }
7044
+
6954
7045
  //#endregion
6955
7046
  //#region src/services/select-all/select-all.service.ts
6956
7047
  var SelectAllService = class extends Disposable {
@@ -7044,7 +7135,9 @@ const MoveSelectionCommand = {
7044
7135
  }
7045
7136
  }
7046
7137
  const startRange = getStartRange(range, primary, direction);
7047
- const next = jumpOver === 1 ? findNextGapRange(startRange, direction, worksheet) : findNextRange(startRange, direction, worksheet);
7138
+ const config = accessor.get(IConfigService).getConfig(SHEETS_UI_PLUGIN_CONFIG_KEY);
7139
+ const allowWrap = (config === null || config === void 0 ? void 0 : config.allowArrowKeyWrapOnSheetBoundary) ?? true;
7140
+ const next = jumpOver === 1 ? findNextGapRange(startRange, direction, worksheet) : findNextRange(startRange, direction, worksheet, void 0, true, 1, allowWrap);
7048
7141
  const destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
7049
7142
  if (Rectangle.equals(destRange, startRange)) return false;
7050
7143
  const unitId = workbook.getUnitId();
@@ -7167,13 +7260,7 @@ const MoveSelectionEnterAndTabCommand = {
7167
7260
  keycode: KeyCode.TAB
7168
7261
  });
7169
7262
  }
7170
- /**
7171
- * The start range is from the primary selection range.
7172
- * If the edited cell is the last row/column of the worksheet, and the submitted operation is Enter/Tab to move down/right, the next selected cell should still be the current cell (not move to the first row/column of the worksheet).
7173
- */
7174
- const isLastRowCell = keycode === KeyCode.ENTER && direction === Direction.DOWN && startRange.endRow === worksheet.getMaxRows() - 1;
7175
- const isLastColumnCell = keycode === KeyCode.TAB && direction === Direction.RIGHT && startRange.endColumn === worksheet.getMaxColumns() - 1;
7176
- const next = isLastRowCell || isLastColumnCell ? startRange : findNextRange(startRange, direction, worksheet);
7263
+ const next = findNextRange(startRange, direction, worksheet, void 0, true, 1, false);
7177
7264
  const destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
7178
7265
  if (Rectangle.equals(destRange, startRange)) return false;
7179
7266
  resultRange = {
@@ -7217,11 +7304,19 @@ const ExpandSelectionCommand = {
7217
7304
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
7218
7305
  if (!target) return false;
7219
7306
  const { worksheet, unitId, subUnitId } = target;
7220
- const selection = getSelectionsService(accessor).getCurrentLastSelection();
7307
+ const selectionsService = getSelectionsService(accessor, params.fromCurrentSelection);
7308
+ const selection = selectionsService.getCurrentLastSelection();
7221
7309
  if (!selection) return false;
7222
7310
  const { jumpOver, direction, extra } = params;
7223
7311
  let { range: startRange, primary } = selection;
7224
7312
  if (extra === "formula-editor") {
7313
+ if (params.fromCurrentSelection && primary) startRange = {
7314
+ startRow: primary.startRow,
7315
+ endRow: primary.endRow,
7316
+ startColumn: primary.startColumn,
7317
+ endColumn: primary.endColumn,
7318
+ rangeType: RANGE_TYPE.NORMAL
7319
+ };
7225
7320
  if (startRange.startRow === startRange.endRow && startRange.startColumn === startRange.endColumn) {
7226
7321
  const mergedCell = worksheet.getMergedCell(startRange.startRow, startRange.startColumn);
7227
7322
  if (mergedCell) startRange = {
@@ -7230,18 +7325,21 @@ const ExpandSelectionCommand = {
7230
7325
  };
7231
7326
  }
7232
7327
  if (!primary) {
7233
- const lastSelectionPrimary = getSelectionsService(accessor).getCurrentLastSelectionPrimaryCell();
7328
+ const lastSelectionPrimary = selectionsService.getCurrentLastSelectionPrimaryCell();
7234
7329
  if (lastSelectionPrimary && Rectangle.contains(startRange, lastSelectionPrimary)) primary = lastSelectionPrimary;
7235
7330
  }
7236
7331
  }
7237
- const destRange = !checkIfShrink({
7332
+ const isShrink = checkIfShrink({
7238
7333
  range: startRange,
7239
7334
  primary
7240
- }, direction, worksheet) ? jumpOver === 1 ? expandToNextGapRange(startRange, direction, worksheet) : expandToNextCell(startRange, direction, worksheet) : jumpOver === 1 ? shrinkToNextGapRange(startRange, {
7335
+ }, direction, worksheet);
7336
+ let destRange;
7337
+ if (isShrink) destRange = jumpOver === 1 ? shrinkToNextGapRange(startRange, {
7241
7338
  ...Rectangle.clone(primary),
7242
7339
  rangeType: RANGE_TYPE.NORMAL
7243
7340
  }, direction, worksheet) : shrinkToNextCell(startRange, direction, worksheet);
7244
- destRange.rangeType = selection.range.rangeType;
7341
+ else destRange = jumpOver === 1 ? expandToNextGapRange(startRange, direction, worksheet) : expandToNextCell(startRange, direction, worksheet);
7342
+ destRange.rangeType = startRange.rangeType;
7245
7343
  if (Rectangle.equals(destRange, startRange)) return false;
7246
7344
  return accessor.get(ICommandService).syncExecuteCommand(SetSelectionsOperation.id, {
7247
7345
  unitId,
@@ -8292,7 +8390,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8292
8390
  }
8293
8391
  refreshEditCellPosition(resetSizeOnly) {
8294
8392
  if (!this._currentEditCell || !this._currentEditCellState) return;
8295
- const { unitId, sheetId, primary, scene, engine } = this._currentEditCell;
8393
+ const { unitId, sheetId, primary: selectedCell, scene, engine } = this._currentEditCell;
8296
8394
  const workbook = this._getWorkbookForEditUnit(unitId);
8297
8395
  if (!workbook || workbook.getUnitId() !== unitId) return;
8298
8396
  const worksheet = workbook.getActiveSheet();
@@ -8300,6 +8398,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8300
8398
  if (!this._renderManagerService.getRenderUnitById(unitId)) return;
8301
8399
  const skeleton = this._sheetSkeletonService.getSkeleton(unitId, sheetId);
8302
8400
  if (!skeleton) return;
8401
+ const primary = worksheet.getCellInfoInMergeData(selectedCell.actualRow, selectedCell.actualColumn);
8303
8402
  const primaryWithCoord = attachPrimaryWithCoord(skeleton, primary);
8304
8403
  const actualRangeWithCoord = convertCellToRange(primaryWithCoord);
8305
8404
  const canvasOffset = getCanvasOffsetByEngine(engine);
@@ -8397,7 +8496,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8397
8496
  getLatestEditCellState() {
8398
8497
  var _documentLayoutObject, _documentLayoutObject2;
8399
8498
  if (!this._currentEditCell) return;
8400
- const { unitId, sheetId, primary, scene, engine } = this._currentEditCell;
8499
+ const { unitId, sheetId, primary: selectedCell, scene, engine } = this._currentEditCell;
8401
8500
  const workbook = this._getWorkbookForEditUnit(unitId);
8402
8501
  if (!workbook || workbook.getUnitId() !== unitId) return;
8403
8502
  const worksheet = workbook.getActiveSheet();
@@ -8405,6 +8504,7 @@ let EditorBridgeService = class EditorBridgeService extends Disposable {
8405
8504
  if (!this._renderManagerService.getRenderUnitById(unitId)) return;
8406
8505
  const skeleton = this._sheetSkeletonService.getSkeleton(unitId, sheetId);
8407
8506
  if (!skeleton) return;
8507
+ const primary = worksheet.getCellInfoInMergeData(selectedCell.actualRow, selectedCell.actualColumn);
8408
8508
  const { startRow, startColumn } = primary;
8409
8509
  const primaryWithCoord = attachPrimaryWithCoord(skeleton, primary);
8410
8510
  const actualRangeWithCoord = convertCellToRange(primaryWithCoord);
@@ -8776,29 +8876,6 @@ const SetActivateCellEditOperation = {
8776
8876
  }
8777
8877
  };
8778
8878
 
8779
- //#endregion
8780
- //#region src/config/config.ts
8781
- const SHEETS_UI_PLUGIN_CONFIG_KEY = "sheets-ui.config";
8782
- const configSymbol = Symbol(SHEETS_UI_PLUGIN_CONFIG_KEY);
8783
- const defaultPluginConfig = {
8784
- formulaBar: true,
8785
- protectedRangeShadow: true,
8786
- maxAutoHeightCount: 1e3
8787
- };
8788
- /**
8789
- * Convert the protectedRangeShadow config to shadow strategy
8790
- * - true -> 'always'
8791
- * - false -> 'none'
8792
- * - string values remain unchanged
8793
- * @param config The protectedRangeShadow config value
8794
- * @returns The shadow strategy
8795
- */
8796
- function convertToShadowStrategy(config) {
8797
- if (config === true) return "always";
8798
- if (config === false) return "none";
8799
- return config || "always";
8800
- }
8801
-
8802
8879
  //#endregion
8803
8880
  //#region src/commands/operations/cell-edit.operation.ts
8804
8881
  const SetCellEditVisibleOperation = {
@@ -10977,27 +11054,6 @@ function generateArrowSelectionShortCutItem() {
10977
11054
  }
10978
11055
  });
10979
11056
  }
10980
- for (const [binding, macArrow, direction] of [[
10981
- KeyCode.HOME,
10982
- KeyCode.ARROW_LEFT,
10983
- Direction.LEFT
10984
- ], [
10985
- KeyCode.END,
10986
- KeyCode.ARROW_RIGHT,
10987
- Direction.RIGHT
10988
- ]]) for (const extend of [false, true]) {
10989
- const shift = extend ? MetaKeys.SHIFT : 0;
10990
- shortcutList.push({
10991
- id: extend ? MoveSelectionOperation.id : MoveCursorOperation.id,
10992
- binding: binding | shift,
10993
- mac: macArrow | MetaKeys.CTRL_COMMAND | shift,
10994
- preconditions: whenEditorDidNotInputFormulaActivated,
10995
- staticParameters: {
10996
- direction,
10997
- granularity: "line"
10998
- }
10999
- });
11000
- }
11001
11057
  return shortcutList;
11002
11058
  }
11003
11059
  const StartEditWithF2Shortcut = {
@@ -11398,15 +11454,15 @@ function getPercentOffset(editCellState, dataStream) {
11398
11454
  }
11399
11455
  function getPercentEditorSelection(editCellState, visibleParam, dataStream) {
11400
11456
  const percentOffset = getPercentOffset(editCellState, dataStream);
11401
- if (percentOffset == null) return null;
11402
- const { eventType, initialValue, keycode } = visibleParam;
11403
- if (isFormulaString(dataStream) && (eventType === DeviceInputEventType.Dblclick || keycode === KeyCode.F2)) return null;
11404
- if (eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) return {
11457
+ if (percentOffset == null || visibleParam.eventType !== DeviceInputEventType.Keyboard) return null;
11458
+ const { initialValue, keycode } = visibleParam;
11459
+ if (isFormulaString(dataStream) && keycode === KeyCode.F2) return null;
11460
+ if (keycode === KeyCode.F2) return {
11405
11461
  startOffset: percentOffset,
11406
11462
  endOffset: percentOffset,
11407
11463
  collapsed: true
11408
11464
  };
11409
- if (eventType !== DeviceInputEventType.Dblclick && (eventType !== DeviceInputEventType.Keyboard || keycode === KeyCode.BACKSPACE || keycode === KeyCode.DELETE || !/^\d/.test(initialValue ?? ""))) return null;
11465
+ if (keycode === KeyCode.BACKSPACE || keycode === KeyCode.DELETE || !/^\d/.test(initialValue ?? "")) return null;
11410
11466
  return {
11411
11467
  startOffset: 0,
11412
11468
  endOffset: percentOffset,
@@ -11656,7 +11712,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11656
11712
  }));
11657
11713
  }
11658
11714
  _handleEditorVisible(param) {
11659
- var _this$_sheetCellEdito4, _documentDataModel$ge, _this$_renderManagerS5;
11715
+ var _documentDataModel$ge, _this$_renderManagerS6;
11660
11716
  const { eventType, keycode } = param;
11661
11717
  this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
11662
11718
  const editCellState = this._editorBridgeService.getEditLocation();
@@ -11675,21 +11731,25 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11675
11731
  this._editorBridgeService.refreshEditCellPosition(false);
11676
11732
  const editorObject = this._getEditorObject();
11677
11733
  if (editorObject == null) return;
11678
- const { document, scene } = editorObject;
11734
+ const { document } = editorObject;
11679
11735
  this._contextService.setContextValue(EDITOR_ACTIVATED, true);
11680
11736
  const documentDataModel = this._getDocumentDataModel();
11681
11737
  const skeleton = this._getEditorSkeleton(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
11682
11738
  if (!skeleton || !documentDataModel) return;
11683
- (_this$_sheetCellEdito4 = this._sheetCellEditorResizeService) === null || _this$_sheetCellEdito4 === void 0 || _this$_sheetCellEdito4.fitTextSize(() => {
11684
- const viewMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
11685
- viewMain === null || viewMain === void 0 || viewMain.scrollToViewportPos({
11686
- viewportScrollX: Number.POSITIVE_INFINITY,
11687
- viewportScrollY: Number.POSITIVE_INFINITY
11688
- });
11689
- });
11739
+ this._resizeEditorOnOpen(param, editorObject, !!isInArrayFormulaRange);
11690
11740
  const clearAndEdit = () => {
11741
+ const resetPointerSelection = isInArrayFormulaRange && eventType === DeviceInputEventType.PointerDown;
11742
+ const editorId = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) ? DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
11743
+ if (resetPointerSelection) {
11744
+ var _this$_renderManagerS5;
11745
+ (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.with(DocSelectionRenderService).cancelPointerSelection();
11746
+ }
11691
11747
  this._emptyDocumentDataModel(documentDataModel.getSnapshot().documentStyle, !!isInArrayFormulaRange);
11692
11748
  document.makeDirty();
11749
+ if (resetPointerSelection) {
11750
+ var _this$_getEditorSkele;
11751
+ (_this$_getEditorSkele = this._getEditorSkeleton(editorId)) === null || _this$_getEditorSkele === void 0 || _this$_getEditorSkele.calculate();
11752
+ }
11693
11753
  if (keycode === KeyCode.BACKSPACE || eventType === DeviceInputEventType.Dblclick) {
11694
11754
  skeleton.calculate();
11695
11755
  this._editorBridgeService.changeEditorDirty(true);
@@ -11701,6 +11761,27 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11701
11761
  unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
11702
11762
  subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11703
11763
  });
11764
+ if (resetPointerSelection && editorId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {
11765
+ const selectionTarget = {
11766
+ unitId: editorId,
11767
+ subUnitId: editorId
11768
+ };
11769
+ const previousSelection = this._textSelectionManagerService.getSelectionInfo(selectionTarget);
11770
+ this._textSelectionManagerService.replaceSelectionInfoWithoutRefresh({
11771
+ textRanges: [{
11772
+ startOffset: 0,
11773
+ endOffset: 0,
11774
+ collapsed: true,
11775
+ isActive: true
11776
+ }],
11777
+ rectRanges: [],
11778
+ segmentId: "",
11779
+ segmentPage: -1,
11780
+ style: (previousSelection === null || previousSelection === void 0 ? void 0 : previousSelection.style) ?? NORMAL_TEXT_SELECTION_PLUGIN_STYLE,
11781
+ isEditing: true
11782
+ }, selectionTarget);
11783
+ this._textSelectionManagerService.refreshSelection(selectionTarget, true);
11784
+ }
11704
11785
  };
11705
11786
  const replaceSelection = (selection) => {
11706
11787
  this._textSelectionManagerService.replaceDocRanges([selection], {
@@ -11711,7 +11792,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11711
11792
  const percentSelection = getPercentEditorSelection(editCellState, param, (_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.dataStream);
11712
11793
  const cellImage = isCellImage(documentDataModel.getSnapshot());
11713
11794
  this._submitEmptyCellImageEdit = cellImage && eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.BACKSPACE;
11714
- if (cellImage) clearAndEdit();
11795
+ if (cellImage || isInArrayFormulaRange) clearAndEdit();
11715
11796
  else if (eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) {
11716
11797
  var _documentDataModel$ge2;
11717
11798
  document.makeDirty();
@@ -11726,19 +11807,39 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11726
11807
  endOffset,
11727
11808
  collapsed: true
11728
11809
  });
11729
- } else if (eventType === DeviceInputEventType.Keyboard || eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange) {
11810
+ } else if (eventType === DeviceInputEventType.Keyboard) {
11730
11811
  if (percentSelection) replaceSelection(percentSelection);
11731
11812
  else clearAndEdit();
11732
11813
  } else if (eventType === DeviceInputEventType.Dblclick) {
11733
11814
  if (this._contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)) return;
11734
- const endOffset = documentDataModel.getBody().dataStream.length - 2 || 0;
11735
- replaceSelection(percentSelection ?? {
11736
- startOffset: 0,
11815
+ const dataStream = documentDataModel.getBody().dataStream;
11816
+ const endOffset = (!isFormulaString(dataStream) ? getPercentOffset(editCellState, dataStream) : null) ?? dataStream.length - 2;
11817
+ replaceSelection({
11818
+ startOffset: endOffset,
11737
11819
  endOffset,
11738
- collapsed: endOffset === 0
11820
+ collapsed: true
11739
11821
  });
11740
11822
  }
11741
- (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.scene.resetCursor();
11823
+ (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.scene.resetCursor();
11824
+ }
11825
+ _resizeEditorOnOpen(param, editorObject, isInArrayFormulaRange) {
11826
+ var _this$_sheetCellEdito4;
11827
+ const pointerPosition = param.eventType === DeviceInputEventType.Dblclick ? param.pointerPosition : void 0;
11828
+ (_this$_sheetCellEdito4 = this._sheetCellEditorResizeService) === null || _this$_sheetCellEdito4 === void 0 || _this$_sheetCellEdito4.fitTextSize(() => {
11829
+ var _scene$getViewport;
11830
+ if (pointerPosition && this._editorBridgeService.isVisible() !== param) return;
11831
+ const { engine, scene } = editorObject;
11832
+ (_scene$getViewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) === null || _scene$getViewport === void 0 || _scene$getViewport.scrollToViewportPos({
11833
+ viewportScrollX: pointerPosition ? 0 : Number.POSITIVE_INFINITY,
11834
+ viewportScrollY: pointerPosition ? 0 : Number.POSITIVE_INFINITY
11835
+ });
11836
+ if (!pointerPosition || isInArrayFormulaRange) return;
11837
+ const rect = engine.getCanvasElement().getBoundingClientRect();
11838
+ if (rect.width > 0 && rect.height > 0) {
11839
+ var _this$_renderManagerS7;
11840
+ (_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 });
11841
+ }
11842
+ });
11742
11843
  }
11743
11844
  _cacheEmptyCellTextStyle() {
11744
11845
  var _this$_editorBridgeSe, _sourceBody$textRuns;
@@ -11871,8 +11972,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11871
11972
  const editorUnitId = this._editorBridgeService.getCurrentEditorId();
11872
11973
  if (editorUnitId == null || !this._editorService.isSheetEditor(editorUnitId)) return;
11873
11974
  if (editorUnitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {
11874
- var _this$_getEditorSkele;
11875
- (_this$_getEditorSkele = this._getEditorSkeleton(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_getEditorSkele === void 0 || _this$_getEditorSkele.resetInitialWidth();
11975
+ var _this$_getEditorSkele2;
11976
+ (_this$_getEditorSkele2 = this._getEditorSkeleton(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_getEditorSkele2 === void 0 || _this$_getEditorSkele2.resetInitialWidth();
11876
11977
  }
11877
11978
  this._clearEditorHistory();
11878
11979
  }
@@ -11938,12 +12039,12 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11938
12039
  return this._univerInstanceService.getUnit(DOCS_NORMAL_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
11939
12040
  }
11940
12041
  _getEditorSkeleton(editorId) {
11941
- var _this$_renderManagerS6;
11942
- return (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS6 === void 0 ? void 0 : _this$_renderManagerS6.with(DocSkeletonManagerService).getSkeleton();
12042
+ var _this$_renderManagerS8;
12043
+ return (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(DocSkeletonManagerService).getSkeleton();
11943
12044
  }
11944
12045
  _getEditorViewModel(editorId) {
11945
- var _this$_renderManagerS7;
11946
- return (_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS7 === void 0 ? void 0 : _this$_renderManagerS7.with(DocSkeletonManagerService).getViewModel();
12046
+ var _this$_renderManagerS9;
12047
+ return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(DocSkeletonManagerService).getViewModel();
11947
12048
  }
11948
12049
  _getEditingUnit() {
11949
12050
  return this._editingUnit ? this._univerInstanceService.getUnit(this._editingUnit, UniverInstanceType.UNIVER_SHEET) : null;
@@ -13914,14 +14015,15 @@ let HoverManagerService = class HoverManagerService extends Disposable {
13914
14015
  location: getLocationBase(activeCell.location)
13915
14016
  });
13916
14017
  }
13917
- triggerDbClick(unitId, offsetX, offsetY) {
14018
+ triggerDbClick(unitId, event) {
13918
14019
  const deps = this._getCalcDeps(unitId);
13919
14020
  if (!deps) return;
13920
14021
  const { currentRender, workbook, worksheet, skeletonParam } = deps;
13921
- const activeCell = this._calcActiveCell(currentRender, workbook, worksheet, skeletonParam, offsetX, offsetY);
14022
+ const activeCell = this._calcActiveCell(currentRender, workbook, worksheet, skeletonParam, event.offsetX, event.offsetY);
13922
14023
  if (activeCell) this._currentDbClickedCell$.next({
13923
14024
  ...activeCell,
13924
- location: getLocationBase(activeCell.location)
14025
+ location: getLocationBase(activeCell.location),
14026
+ event
13925
14027
  });
13926
14028
  }
13927
14029
  triggerScroll() {
@@ -13991,7 +14093,7 @@ let HoverRenderController = class HoverRenderController extends Disposable {
13991
14093
  if (!skeletonParam) return;
13992
14094
  const { mainComponent, unitId, components } = this._context;
13993
14095
  if (!mainComponent) return;
13994
- disposeSet.add(mainComponent.onPointerEnter$.subscribeEvent((evt) => {
14096
+ disposeSet.add(mainComponent.onPointerEnter$.subscribeEvent(() => {
13995
14097
  this._active = true;
13996
14098
  }));
13997
14099
  disposeSet.add(fromEventSubject(mainComponent.onPointerMove$).subscribe((evt) => {
@@ -14008,7 +14110,7 @@ let HoverRenderController = class HoverRenderController extends Disposable {
14008
14110
  this._hoverManagerService.triggerClick(unitId, evt.offsetX, evt.offsetY);
14009
14111
  }));
14010
14112
  disposeSet.add(mainComponent.onDblclick$.subscribeEvent((evt) => {
14011
- this._hoverManagerService.triggerDbClick(unitId, evt.offsetX, evt.offsetY);
14113
+ this._hoverManagerService.triggerDbClick(unitId, evt);
14012
14114
  }));
14013
14115
  disposeSet.add(mainComponent.onPointerLeave$.subscribeEvent(() => {
14014
14116
  this._active = false;
@@ -17201,6 +17303,10 @@ const MoveRangeConfirmCommand = {
17201
17303
  id: "sheet.command.move-range-confirm",
17202
17304
  handler: async (accessor, params) => {
17203
17305
  if (!params) return false;
17306
+ if (!await accessor.get(SheetInterceptorService).beforeCommandExecute({
17307
+ id: MoveRangeCommand.id,
17308
+ params
17309
+ })) return false;
17204
17310
  const commandService = accessor.get(ICommandService);
17205
17311
  const univerInstanceService = accessor.get(IUniverInstanceService);
17206
17312
  const sourceTarget = getSheetCommandTarget(univerInstanceService, {
@@ -19197,7 +19303,7 @@ function WrapTextMenuItemFactory(accessor) {
19197
19303
  const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
19198
19304
  var _selectionManagerServ14;
19199
19305
  const id = c.id;
19200
- if (id !== SetTextWrapCommand.id && id !== SetSelectionsOperation.id && id !== SetWorksheetActiveOperation.id) return;
19306
+ if (id !== SetRangeValuesMutation.id && id !== SetSelectionsOperation.id && id !== SetWorksheetActiveOperation.id) return;
19201
19307
  const primary = (_selectionManagerServ14 = selectionManagerService.getCurrentLastSelection()) === null || _selectionManagerServ14 === void 0 ? void 0 : _selectionManagerServ14.primary;
19202
19308
  let tb;
19203
19309
  if (primary != null) {
@@ -19229,33 +19335,34 @@ function ShrinkToFitMenuItemFactory(accessor) {
19229
19335
  const commandService = accessor.get(ICommandService);
19230
19336
  const univerInstanceService = accessor.get(IUniverInstanceService);
19231
19337
  const selectionManagerService = accessor.get(SheetsSelectionsService);
19338
+ const style$ = deriveStateFromActiveSheet$(univerInstanceService, {}, ({ worksheet }) => new Observable((subscriber) => {
19339
+ const update = () => {
19340
+ var _selectionManagerServ16;
19341
+ const primary = (_selectionManagerServ16 = selectionManagerService.getCurrentLastSelection()) === null || _selectionManagerServ16 === void 0 ? void 0 : _selectionManagerServ16.primary;
19342
+ subscriber.next(primary != null ? worksheet.getComposedCellStyle(primary.startRow, primary.startColumn) ?? {} : {});
19343
+ };
19344
+ const disposable = commandService.onCommandExecuted((command) => {
19345
+ if ([
19346
+ SetRangeValuesMutation.id,
19347
+ SetSelectionsOperation.id,
19348
+ SetWorksheetActiveOperation.id
19349
+ ].includes(command.id)) update();
19350
+ });
19351
+ update();
19352
+ return disposable.dispose;
19353
+ }));
19232
19354
  return {
19233
19355
  id: SetShrinkToFitCommand.id,
19234
19356
  type: MenuItemType.BUTTON,
19235
19357
  icon: "ShrinkToFitIcon",
19236
19358
  title: "sheets-ui.toolbar.shrinkToFit",
19237
19359
  tooltip: "sheets-ui.toolbar.shrinkToFit",
19238
- activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable((subscriber) => {
19239
- const update = () => {
19240
- var _selectionManagerServ16, _worksheet$getCompose;
19241
- const primary = (_selectionManagerServ16 = selectionManagerService.getCurrentLastSelection()) === null || _selectionManagerServ16 === void 0 ? void 0 : _selectionManagerServ16.primary;
19242
- subscriber.next(primary != null && ((_worksheet$getCompose = worksheet.getComposedCellStyle(primary.startRow, primary.startColumn)) === null || _worksheet$getCompose === void 0 ? void 0 : _worksheet$getCompose.stf) === BooleanNumber.TRUE);
19243
- };
19244
- const disposable = commandService.onCommandExecuted((command) => {
19245
- if ([
19246
- SetRangeValuesMutation.id,
19247
- SetSelectionsOperation.id,
19248
- SetWorksheetActiveOperation.id
19249
- ].includes(command.id)) update();
19250
- });
19251
- update();
19252
- return disposable.dispose;
19253
- })),
19254
- disabled$: getCurrentRangeDisable$(accessor, {
19360
+ activated$: style$.pipe(map((style) => style.stf === BooleanNumber.TRUE && style.tb !== WrapStrategy.WRAP)),
19361
+ disabled$: combineLatest([getCurrentRangeDisable$(accessor, {
19255
19362
  workbookTypes: [WorkbookEditablePermission],
19256
19363
  worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission],
19257
19364
  rangeTypes: [RangeProtectionPermissionEditPoint]
19258
- }),
19365
+ }), style$]).pipe(map(([disabled, style]) => disabled || style.tb === WrapStrategy.WRAP)),
19259
19366
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
19260
19367
  };
19261
19368
  }
@@ -21106,14 +21213,12 @@ function useWorkbooks() {
21106
21213
 
21107
21214
  //#endregion
21108
21215
  //#region src/views/editor-container/focus-editor.ts
21109
- const SHEET_CELL_EDITOR_ELEMENT_ID = `__editor_${DOCS_NORMAL_EDITOR_UNIT_ID_KEY}`;
21110
- const SHEET_CELL_EDITOR_SELECTION_CONTAINER_ID = `univer-doc-selection-container-${DOCS_NORMAL_EDITOR_UNIT_ID_KEY}`;
21111
- function focusSheetCellEditorElement(ownerDocument = document) {
21112
- const element = ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
21113
- if (element == null || ownerDocument.activeElement === element) return false;
21114
- if (!element.hasAttribute("tabindex")) element.tabIndex = -1;
21115
- element.focus({ preventScroll: true });
21116
- return ownerDocument.activeElement === element;
21216
+ function focusSheetCellEditorElement(editorService) {
21217
+ var _editorService$getEdi;
21218
+ const selection = (_editorService$getEdi = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _editorService$getEdi === void 0 ? void 0 : _editorService$getEdi.docSelectionRenderService;
21219
+ if (!selection || selection.isFocusing) return false;
21220
+ selection.focus();
21221
+ return selection.isFocusing;
21117
21222
  }
21118
21223
  function registerSheetCellEditorRuntimePortal(options) {
21119
21224
  const ownerDocument = options.ownerDocument ?? (typeof document === "undefined" ? void 0 : document);
@@ -21126,8 +21231,10 @@ function registerSheetCellEditorRuntimePortal(options) {
21126
21231
  const frameHandles = [];
21127
21232
  let observer;
21128
21233
  const tryRegister = () => {
21234
+ var _options$editorServic;
21129
21235
  if (disposed) return;
21130
- const portalRoot = resolveSheetCellEditorPortalRoot(ownerDocument);
21236
+ const selection = (_options$editorServic = options.editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _options$editorServic === void 0 ? void 0 : _options$editorServic.docSelectionRenderService;
21237
+ const portalRoot = (selection === null || selection === void 0 ? void 0 : selection.selectionContainer.isConnected) ? selection.selectionContainer : null;
21131
21238
  if (portalRoot === registeredPortalRoot) return;
21132
21239
  portalRegistration === null || portalRegistration === void 0 || portalRegistration.dispose();
21133
21240
  portalRegistration = void 0;
@@ -21142,7 +21249,7 @@ function registerSheetCellEditorRuntimePortal(options) {
21142
21249
  role: "child-editor",
21143
21250
  element: portalRoot
21144
21251
  }));
21145
- const editorElement = ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
21252
+ const editorElement = selection === null || selection === void 0 ? void 0 : selection.inputElement;
21146
21253
  if (editorElement && editorElement !== portalRoot) rootRegistration.add(options.focusCoordinator.registerElement({
21147
21254
  embedId: options.embedId,
21148
21255
  role: "child-editor",
@@ -21185,9 +21292,6 @@ function registerSheetCellEditorRuntimePortal(options) {
21185
21292
  }));
21186
21293
  return collection;
21187
21294
  }
21188
- function resolveSheetCellEditorPortalRoot(ownerDocument = document) {
21189
- return ownerDocument.getElementById(SHEET_CELL_EDITOR_SELECTION_CONTAINER_ID) ?? ownerDocument.getElementById(SHEET_CELL_EDITOR_ELEMENT_ID);
21190
- }
21191
21295
 
21192
21296
  //#endregion
21193
21297
  //#region src/views/editor-container/hooks.ts
@@ -21257,19 +21361,6 @@ const EDITOR_DEFAULT_POSITION = {
21257
21361
  };
21258
21362
  const CELL_EDITOR_DARK_SURFACE_THEME_COLOR = "gray.800";
21259
21363
  const CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR = "gray.0";
21260
- /**
21261
- * @returns the host background color for the cell editor.
21262
- */
21263
- function getCellEditorHostBackgroundColor(editState, options = {}) {
21264
- var _options$getColorFrom;
21265
- const cellFill = editState === null || editState === void 0 ? void 0 : editState.documentLayoutObject.fill;
21266
- if (cellFill && !isTransparentColor(cellFill)) return cellFill;
21267
- return (_options$getColorFrom = options.getColorFromTheme) === null || _options$getColorFrom === void 0 ? void 0 : _options$getColorFrom.call(options, options.darkMode ? CELL_EDITOR_DARK_SURFACE_THEME_COLOR : CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR);
21268
- }
21269
- function isTransparentColor(color) {
21270
- const normalizedColor = color.trim().toLowerCase().replace(/\s+/g, "");
21271
- return normalizedColor === "transparent" || normalizedColor === "rgba(0,0,0,0)";
21272
- }
21273
21364
  function shouldRefocusCellEditorAfterPointerDown(options) {
21274
21365
  const { root, target, activeElement, isEditorFocusing } = options;
21275
21366
  if (!root || !(target instanceof HTMLElement) || !(activeElement instanceof HTMLElement)) return true;
@@ -21334,10 +21425,13 @@ function EditorContainer({ hidden = false }) {
21334
21425
  const workbook = editState ? instanceService.getUnit(editState.unitId, UniverInstanceType.UNIVER_SHEET) ?? null : null;
21335
21426
  const activeSheet = useActiveWorksheet(workbook);
21336
21427
  const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
21428
+ const cellFill = editState === null || editState === void 0 ? void 0 : editState.documentLayoutObject.fill;
21429
+ const normalizedFill = cellFill === null || cellFill === void 0 ? void 0 : cellFill.trim().toLowerCase().replace(/\s+/g, "");
21430
+ const editorBackgroundColor = cellFill && normalizedFill !== "transparent" && normalizedFill !== "rgba(0,0,0,0)" ? cellFill : themeService.getColorFromTheme(darkMode ? CELL_EDITOR_DARK_SURFACE_THEME_COLOR : CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR);
21337
21431
  const [showEditCellAddress, setShowEditCellAddress] = useState(false);
21338
21432
  const editSheetName = editState ? workbook === null || workbook === void 0 || (_workbook$getSheetByS = workbook.getSheetBySheetId(editState.sheetId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName() : null;
21339
21433
  const editCellAddress = editState ? `${activeSheet && editSheetName && activeSheet.getSheetId() !== editState.sheetId ? `'${quoteSheetName(editSheetName)}'!` : ""}${numberToABC(editState.column)}${editState.row + 1}` : null;
21340
- const editorBorderColor = genNormalSelectionStyle(themeService).stroke;
21434
+ const { stroke: editorBorderColor, strokeWidth: editorBorderWidth } = genNormalSelectionStyle(themeService);
21341
21435
  const focusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
21342
21436
  const resolveRuntimeFocusState = () => {
21343
21437
  var _instanceService$getF;
@@ -21426,21 +21520,18 @@ function EditorContainer({ hidden = false }) {
21426
21520
  const focusCellEditorElement = () => {
21427
21521
  const scope = rootRef.current ? resolveSheetEmbedRuntimeDomScope(rootRef.current) ?? resolveActiveSheetEmbedRuntimeDomScope(ownerDocument) : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument);
21428
21522
  if (shouldPreserveEmbedInteractiveFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
21429
- focusSheetCellEditorElement(ownerDocument);
21523
+ focusSheetCellEditorElement(editorService);
21430
21524
  if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
21431
21525
  delayedFocusTimer = ownerWindow.setTimeout(() => {
21432
21526
  delayedFocusTimer = void 0;
21433
21527
  if (shouldPreserveEmbedInteractiveFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
21434
- focusSheetCellEditorElement(ownerDocument);
21528
+ focusSheetCellEditorElement(editorService);
21435
21529
  }, 0);
21436
21530
  };
21437
21531
  const focusEditor = () => {
21438
21532
  if (contextService.getContextValue(FOCUSING_FX_BAR_EDITOR)) return;
21439
21533
  const scope = rootRef.current ? resolveSheetEmbedRuntimeDomScope(rootRef.current) ?? resolveActiveSheetEmbedRuntimeDomScope(ownerDocument) : resolveActiveSheetEmbedRuntimeDomScope(ownerDocument);
21440
21534
  if (shouldPreserveEmbedControlFocus(scope === null || scope === void 0 ? void 0 : scope.embedId, ownerDocument)) return;
21441
- const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
21442
- const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
21443
- if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
21444
21535
  focusCellEditorElement();
21445
21536
  };
21446
21537
  focusEditor();
@@ -21492,6 +21583,7 @@ function EditorContainer({ hidden = false }) {
21492
21583
  element: editorRoot
21493
21584
  }));
21494
21585
  collection.add(registerSheetCellEditorRuntimePortal({
21586
+ editorService,
21495
21587
  embedId: scope.embedId,
21496
21588
  ownerDocument: rootRef.current.ownerDocument,
21497
21589
  interactionBoundaryService,
@@ -21502,10 +21594,7 @@ function EditorContainer({ hidden = false }) {
21502
21594
  let pointerRetryFrame = 0;
21503
21595
  const focusEditor = () => {
21504
21596
  if (contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) || shouldPreserveEmbedControlFocus(scope.embedId, ownerDocument)) return;
21505
- const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
21506
- const docSelectionRenderService = editor === null || editor === void 0 ? void 0 : editor.render.with(DocSelectionRenderService);
21507
- if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
21508
- focusSheetCellEditorElement(ownerDocument);
21597
+ focusSheetCellEditorElement(editorService);
21509
21598
  };
21510
21599
  const refocusEditorAfterRuntimePointer = (event) => {
21511
21600
  if (!focusCoordinator.isChildUnitRuntimeEvent(scope.childUnitId, event.target, event) || isEmbedRuntimeEditorOrPopup(event.target)) return;
@@ -21540,6 +21629,7 @@ function EditorContainer({ hidden = false }) {
21540
21629
  const ownerDocument = ((_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.ownerDocument) ?? document;
21541
21630
  const interactionBoundaryService = injector.has(ISheetEmbedInteractionBoundaryService) ? injector.get(ISheetEmbedInteractionBoundaryService) : void 0;
21542
21631
  const portalRegistration = registerSheetCellEditorRuntimePortal({
21632
+ editorService,
21543
21633
  embedId: activeSessionScope.embedId,
21544
21634
  ownerDocument,
21545
21635
  interactionBoundaryService,
@@ -21549,12 +21639,12 @@ function EditorContainer({ hidden = false }) {
21549
21639
  let delayedFocusTimer;
21550
21640
  const focusCellEditorElement = () => {
21551
21641
  if (shouldPreserveEmbedInteractiveFocus(activeSessionScope.embedId, ownerDocument)) return;
21552
- focusSheetCellEditorElement(ownerDocument);
21642
+ focusSheetCellEditorElement(editorService);
21553
21643
  if (delayedFocusTimer != null) ownerWindow.clearTimeout(delayedFocusTimer);
21554
21644
  delayedFocusTimer = ownerWindow.setTimeout(() => {
21555
21645
  delayedFocusTimer = void 0;
21556
21646
  if (shouldPreserveEmbedInteractiveFocus(activeSessionScope.embedId, ownerDocument)) return;
21557
- focusSheetCellEditorElement(ownerDocument);
21647
+ focusSheetCellEditorElement(editorService);
21558
21648
  }, 0);
21559
21649
  };
21560
21650
  const focusHiddenEditor = () => {
@@ -21602,9 +21692,9 @@ function EditorContainer({ hidden = false }) {
21602
21692
  visible === null || visible === void 0 ? void 0 : visible.visible
21603
21693
  ]);
21604
21694
  useEffect(() => {
21695
+ var _rootRef$current3;
21696
+ const ownerWindow = (_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.ownerDocument.defaultView;
21605
21697
  return () => {
21606
- var _rootRef$current3;
21607
- const ownerWindow = (_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.ownerDocument.defaultView;
21608
21698
  if (ownerWindow && pointerRefocusTimerRef.current != null) ownerWindow.clearTimeout(pointerRefocusTimerRef.current);
21609
21699
  };
21610
21700
  }, []);
@@ -21626,12 +21716,11 @@ function EditorContainer({ hidden = false }) {
21626
21716
  if (pointerRefocusTimerRef.current != null) ownerWindow.clearTimeout(pointerRefocusTimerRef.current);
21627
21717
  pointerRefocusTimerRef.current = ownerWindow.setTimeout(() => {
21628
21718
  pointerRefocusTimerRef.current = void 0;
21629
- if (!(docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing)) docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.focus();
21630
- focusSheetCellEditorElement(ownerDocument);
21719
+ focusSheetCellEditorElement(editorService);
21631
21720
  }, 0);
21632
21721
  });
21633
21722
  const handleClickSideBar = useEvent(() => {
21634
- if (editorBridgeService.isVisible().visible) commandService.executeCommand(SetCellEditVisibleOperation.id, {
21723
+ if (editorBridgeService.isVisible().visible) return commandService.executeCommand(SetCellEditVisibleOperation.id, {
21635
21724
  visible: false,
21636
21725
  eventType: DeviceInputEventType.PointerUp,
21637
21726
  unitId: editState === null || editState === void 0 ? void 0 : editState.unitId
@@ -21640,7 +21729,7 @@ function EditorContainer({ hidden = false }) {
21640
21729
  useSidebarClick(handleClickSideBar);
21641
21730
  const keyCodeConfig = useKeyEventConfig(editState === null || editState === void 0 ? void 0 : editState.unitId);
21642
21731
  const onMoveInEditor = useEvent((keycode, metaKey) => {
21643
- commandService.executeCommand(SetCellEditVisibleArrowOperation.id, {
21732
+ return commandService.executeCommand(SetCellEditVisibleArrowOperation.id, {
21644
21733
  keycode,
21645
21734
  visible: false,
21646
21735
  eventType: DeviceInputEventType.Keyboard,
@@ -21660,41 +21749,51 @@ function EditorContainer({ hidden = false }) {
21660
21749
  height: state.height,
21661
21750
  opacity: hidden ? 0 : void 0,
21662
21751
  pointerEvents: hidden ? "none" : void 0,
21663
- backgroundColor: getCellEditorHostBackgroundColor(editState, {
21664
- darkMode,
21665
- getColorFromTheme: themeService.getColorFromTheme.bind(themeService)
21666
- })
21752
+ backgroundColor: editorBackgroundColor
21667
21753
  },
21668
- children: [(visible === null || visible === void 0 ? void 0 : visible.visible) && showEditCellAddress && editCellAddress && /* @__PURE__ */ jsx("div", {
21669
- "data-u-comp": "sheet-cell-editor-address",
21670
- className: "univer-pointer-events-none univer-absolute univer-left-0 univer-top-0 univer-z-10 univer-whitespace-nowrap univer-rounded-t univer-px-1.5 univer-text-xs univer-leading-5",
21671
- style: {
21672
- backgroundColor: editorBorderColor,
21673
- color: themeService.getColorFromTheme("gray.0"),
21674
- transform: "translateY(-100%)"
21675
- },
21676
- children: editCellAddress
21677
- }), FormulaEditor && /* @__PURE__ */ jsx(FormulaEditor, {
21678
- editorId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
21679
- className: "univer-relative univer-flex univer-size-full [&_canvas]:univer-absolute",
21680
- initValue: "",
21681
- onChange: () => {},
21682
- isFocus: !hidden && (visible === null || visible === void 0 ? void 0 : visible.visible),
21683
- unitId: editState === null || editState === void 0 ? void 0 : editState.unitId,
21684
- subUnitId: editState === null || editState === void 0 ? void 0 : editState.sheetId,
21685
- keyboardEventConfig: keyCodeConfig,
21686
- onMoveInEditor,
21687
- isSupportAcrossSheet: true,
21688
- resetSelectionOnBlur: false,
21689
- isSingle: false,
21690
- autoScrollbar: false,
21691
- onFormulaSelectingChange: (isSelecting) => {
21692
- if (isSelecting) editorBridgeService.enableForceKeepVisible();
21693
- else editorBridgeService.disableForceKeepVisible();
21694
- },
21695
- disableContextMenu: false,
21696
- canvasStyle: { backgroundColor: "transparent" }
21697
- })]
21754
+ children: [
21755
+ (visible === null || visible === void 0 ? void 0 : visible.visible) && showEditCellAddress && editCellAddress && /* @__PURE__ */ jsx("div", {
21756
+ "data-u-comp": "sheet-cell-editor-address",
21757
+ className: "univer-pointer-events-none univer-absolute univer-left-0 univer-top-0 univer-z-10 univer-whitespace-nowrap univer-rounded-t univer-px-1.5 univer-text-xs univer-leading-5",
21758
+ style: {
21759
+ backgroundColor: editorBorderColor,
21760
+ color: themeService.getColorFromTheme("gray.0"),
21761
+ transform: "translateY(-100%)"
21762
+ },
21763
+ children: editCellAddress
21764
+ }),
21765
+ FormulaEditor && /* @__PURE__ */ jsx(FormulaEditor, {
21766
+ editorId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
21767
+ className: "univer-relative univer-flex univer-size-full [&_canvas]:univer-absolute",
21768
+ initValue: "",
21769
+ onChange: () => {},
21770
+ isFocus: !hidden && (visible === null || visible === void 0 ? void 0 : visible.visible),
21771
+ unitId: editState === null || editState === void 0 ? void 0 : editState.unitId,
21772
+ subUnitId: editState === null || editState === void 0 ? void 0 : editState.sheetId,
21773
+ keyboardEventConfig: keyCodeConfig,
21774
+ onMoveInEditor,
21775
+ isSupportAcrossSheet: true,
21776
+ resetSelectionOnBlur: false,
21777
+ isSingle: false,
21778
+ autoScrollbar: false,
21779
+ borderless: true,
21780
+ onFormulaSelectingChange: (isSelecting) => {
21781
+ if (isSelecting) editorBridgeService.enableForceKeepVisible();
21782
+ else editorBridgeService.disableForceKeepVisible();
21783
+ },
21784
+ disableContextMenu: false,
21785
+ canvasStyle: { backgroundColor: "transparent" }
21786
+ }),
21787
+ (visible === null || visible === void 0 ? void 0 : visible.visible) && /* @__PURE__ */ jsx("div", {
21788
+ "aria-hidden": true,
21789
+ className: "univer-pointer-events-none univer-absolute univer-left-0 univer-top-0 univer-z-10 univer-box-border",
21790
+ style: {
21791
+ width: state.width + editorBorderWidth,
21792
+ height: state.height + editorBorderWidth,
21793
+ border: `${editorBorderWidth}px solid ${editorBorderColor}`
21794
+ }
21795
+ })
21796
+ ]
21698
21797
  });
21699
21798
  }
21700
21799
 
@@ -21739,7 +21838,7 @@ function getAbsoluteRefStringFromSelection(workbook, selections, lexerTreeBuilde
21739
21838
 
21740
21839
  //#endregion
21741
21840
  //#region src/views/defined-name/DefinedNameOverlay.tsx
21742
- function DefinedNameOverlay({ search, isInputEvent }) {
21841
+ function DefinedNameOverlay({ search, isInputEvent, onClose }) {
21743
21842
  const commandService = useDependency(ICommandService);
21744
21843
  const localeService = useDependency(LocaleService);
21745
21844
  const definedNamesService = useDependency(IDefinedNamesService);
@@ -21783,8 +21882,9 @@ function DefinedNameOverlay({ search, isInputEvent }) {
21783
21882
  itemHeight: 30,
21784
21883
  overscan: 6
21785
21884
  });
21786
- const openSlider = () => {
21787
- commandService.executeCommand(SidebarDefinedNameOperation.id, { value: "open" });
21885
+ const openSlider = async () => {
21886
+ onClose();
21887
+ await commandService.executeCommand(SidebarDefinedNameOperation.id, { value: "open" });
21788
21888
  };
21789
21889
  const focusDefinedName = async (definedName) => {
21790
21890
  const { formulaOrRefString, id } = definedName;
@@ -21809,8 +21909,9 @@ function DefinedNameOverlay({ search, isInputEvent }) {
21809
21909
  children: virtualDefinedNames.map(({ data: definedName, index }) => {
21810
21910
  return /* @__PURE__ */ jsx("li", {
21811
21911
  className: "univer-cursor-pointer univer-px-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",
21812
- onClick: () => {
21813
- focusDefinedName(definedName);
21912
+ onClick: async () => {
21913
+ onClose();
21914
+ await focusDefinedName(definedName);
21814
21915
  },
21815
21916
  children: /* @__PURE__ */ jsxs("div", {
21816
21917
  "data-u-comp": "defined-name-overlay-row",
@@ -21864,6 +21965,7 @@ function DefinedName({ disable }) {
21864
21965
  const themeService = useDependency(ThemeService);
21865
21966
  const [open, setOpen] = useState(false);
21866
21967
  const [isInputEvent, setIsInputEvent] = useState(false);
21968
+ const nameBoxRef = useRef(null);
21867
21969
  const inputRef = useRef(null);
21868
21970
  const getDefinedNameMap = () => {
21869
21971
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
@@ -22016,6 +22118,7 @@ function DefinedName({ disable }) {
22016
22118
  return selections;
22017
22119
  }
22018
22120
  return /* @__PURE__ */ jsxs("div", {
22121
+ ref: nameBoxRef,
22019
22122
  "data-u-comp": "defined-name",
22020
22123
  className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",
22021
22124
  children: [/* @__PURE__ */ jsx("input", {
@@ -22027,11 +22130,14 @@ function DefinedName({ disable }) {
22027
22130
  onKeyDown: handleKeyDown,
22028
22131
  onBlur: () => setIsInputEvent(false)
22029
22132
  }), /* @__PURE__ */ jsx(Dropdown, {
22133
+ align: "start",
22134
+ anchorRef: nameBoxRef,
22030
22135
  overlay: /* @__PURE__ */ jsx("div", {
22031
22136
  className: "univer-z-[1001]",
22032
22137
  children: /* @__PURE__ */ jsx(DefinedNameOverlay, {
22033
22138
  search: inputValue,
22034
- isInputEvent
22139
+ isInputEvent,
22140
+ onClose: () => setOpen(false)
22035
22141
  })
22036
22142
  }),
22037
22143
  disabled: disable,
@@ -24909,7 +25015,7 @@ const useHighlightRange = (ranges = []) => {
24909
25015
  //#endregion
24910
25016
  //#region package.json
24911
25017
  var name = "@univerjs/sheets-ui";
24912
- var version = "1.0.3";
25018
+ var version = "1.0.4";
24913
25019
 
24914
25020
  //#endregion
24915
25021
  //#region src/views/cell-popup/config.ts
@@ -26487,6 +26593,66 @@ const BorderDashed = ({ className }) => /* @__PURE__ */ jsxs("svg", {
26487
26593
  ]
26488
26594
  });
26489
26595
 
26596
+ //#endregion
26597
+ //#region src/views/border-panel/border-line/icons/BorderDotted.tsx
26598
+ /**
26599
+ * Copyright 2023-present DreamNum Co., Ltd.
26600
+ *
26601
+ * Licensed under the Apache License, Version 2.0 (the "License");
26602
+ * you may not use this file except in compliance with the License.
26603
+ * You may obtain a copy of the License at
26604
+ *
26605
+ * http://www.apache.org/licenses/LICENSE-2.0
26606
+ *
26607
+ * Unless required by applicable law or agreed to in writing, software
26608
+ * distributed under the License is distributed on an "AS IS" BASIS,
26609
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26610
+ * See the License for the specific language governing permissions and
26611
+ * limitations under the License.
26612
+ */
26613
+ const BorderDotted = ({ className }) => /* @__PURE__ */ jsxs("svg", {
26614
+ className,
26615
+ width: "120",
26616
+ height: "2",
26617
+ viewBox: "0 0 120 2",
26618
+ fill: "none",
26619
+ xmlns: "http://www.w3.org/2000/svg",
26620
+ children: [
26621
+ /* @__PURE__ */ jsx("path", { d: "M0.491699 1.69537H1.4917V0.695374H0.491699V1.69537Z" }),
26622
+ /* @__PURE__ */ jsx("path", { d: "M4.2981 1.69537H5.2981V0.695374H4.2981V1.69537Z" }),
26623
+ /* @__PURE__ */ jsx("path", { d: "M9.10449 1.69537H8.10449V0.695374H9.10449V1.69537Z" }),
26624
+ /* @__PURE__ */ jsx("path", { d: "M11.9109 1.69537H12.9109V0.695374H11.9109V1.69537Z" }),
26625
+ /* @__PURE__ */ jsx("path", { d: "M16.7173 1.69537H15.7173V0.695374H16.7173V1.69537Z" }),
26626
+ /* @__PURE__ */ jsx("path", { d: "M19.5237 1.69537H20.5237V0.695374H19.5237V1.69537Z" }),
26627
+ /* @__PURE__ */ jsx("path", { d: "M24.3301 1.69537H23.3301V0.695374H24.3301V1.69537Z" }),
26628
+ /* @__PURE__ */ jsx("path", { d: "M27.1365 1.69537H28.1365V0.695374H27.1365V1.69537Z" }),
26629
+ /* @__PURE__ */ jsx("path", { d: "M31.9429 1.69537H30.9429V0.695374H31.9429V1.69537Z" }),
26630
+ /* @__PURE__ */ jsx("path", { d: "M34.7493 1.69537H35.7493V0.695374H34.7493V1.69537Z" }),
26631
+ /* @__PURE__ */ jsx("path", { d: "M39.5557 1.69537H38.5557V0.695374H39.5557V1.69537Z" }),
26632
+ /* @__PURE__ */ jsx("path", { d: "M42.3621 1.69537H43.3621V0.695374H42.3621V1.69537Z" }),
26633
+ /* @__PURE__ */ jsx("path", { d: "M47.1685 1.69537H46.1685V0.695374H47.1685V1.69537Z" }),
26634
+ /* @__PURE__ */ jsx("path", { d: "M49.9749 1.69537H50.9749V0.695374H49.9749V1.69537Z" }),
26635
+ /* @__PURE__ */ jsx("path", { d: "M54.7812 1.69537H53.7812V0.695374H54.7812V1.69537Z" }),
26636
+ /* @__PURE__ */ jsx("path", { d: "M57.5876 1.69537H58.5876V0.695374H57.5876V1.69537Z" }),
26637
+ /* @__PURE__ */ jsx("path", { d: "M62.394 1.69537H61.394V0.695374H62.394V1.69537Z" }),
26638
+ /* @__PURE__ */ jsx("path", { d: "M65.2004 1.69537H66.2004V0.695374H65.2004V1.69537Z" }),
26639
+ /* @__PURE__ */ jsx("path", { d: "M70.0068 1.69537H69.0068V0.695374H70.0068V1.69537Z" }),
26640
+ /* @__PURE__ */ jsx("path", { d: "M72.8132 1.69537H73.8132V0.695374H72.8132V1.69537Z" }),
26641
+ /* @__PURE__ */ jsx("path", { d: "M77.6196 1.69537H76.6196V0.695374H77.6196V1.69537Z" }),
26642
+ /* @__PURE__ */ jsx("path", { d: "M80.426 1.69537H81.426V0.695374H80.426V1.69537Z" }),
26643
+ /* @__PURE__ */ jsx("path", { d: "M85.2324 1.69537H84.2324V0.695374H85.2324V1.69537Z" }),
26644
+ /* @__PURE__ */ jsx("path", { d: "M88.0388 1.69537H89.0388V0.695374H88.0388V1.69537Z" }),
26645
+ /* @__PURE__ */ jsx("path", { d: "M92.8452 1.69537H91.8452V0.695374H92.8452V1.69537Z" }),
26646
+ /* @__PURE__ */ jsx("path", { d: "M95.6516 1.69537H96.6516V0.695374H95.6516V1.69537Z" }),
26647
+ /* @__PURE__ */ jsx("path", { d: "M100.458 1.69537H99.458V0.695374H100.458V1.69537Z" }),
26648
+ /* @__PURE__ */ jsx("path", { d: "M103.264 1.69537H104.264V0.695374H103.264V1.69537Z" }),
26649
+ /* @__PURE__ */ jsx("path", { d: "M108.071 1.69537H107.071V0.695374H108.071V1.69537Z" }),
26650
+ /* @__PURE__ */ jsx("path", { d: "M110.877 1.69537H111.877V0.695374H110.877V1.69537Z" }),
26651
+ /* @__PURE__ */ jsx("path", { d: "M115.684 1.69537H114.684V0.695374H115.684V1.69537Z" }),
26652
+ /* @__PURE__ */ jsx("path", { d: "M118.49 1.69537H119.49V0.695374H118.49V1.69537Z" })
26653
+ ]
26654
+ });
26655
+
26490
26656
  //#endregion
26491
26657
  //#region src/views/border-panel/border-line/icons/BorderDouble.tsx
26492
26658
  /**
@@ -26860,6 +27026,7 @@ function BorderLine(props) {
26860
27026
  case BorderStyleTypes.DASH_DOT: return /* @__PURE__ */ jsx(BorderDashDot, { className });
26861
27027
  case BorderStyleTypes.DASH_DOT_DOT: return /* @__PURE__ */ jsx(BorderDashDotDot, { className });
26862
27028
  case BorderStyleTypes.DASHED: return /* @__PURE__ */ jsx(BorderDashed, { className });
27029
+ case BorderStyleTypes.DOTTED: return /* @__PURE__ */ jsx(BorderDotted, { className });
26863
27030
  case BorderStyleTypes.HAIR: return /* @__PURE__ */ jsx(BorderHair, { className });
26864
27031
  case BorderStyleTypes.MEDIUM: return /* @__PURE__ */ jsx(BorderMedium, { className });
26865
27032
  case BorderStyleTypes.MEDIUM_DASH_DOT: return /* @__PURE__ */ jsx(BorderMediumDashDot, { className });
@@ -26874,31 +27041,21 @@ function BorderLine(props) {
26874
27041
 
26875
27042
  //#endregion
26876
27043
  //#region src/views/border-panel/BorderPanel.tsx
26877
- function getBorderColor(borderData) {
26878
- if (!borderData) return;
26879
- for (const key in borderData) {
26880
- var _border$cl;
26881
- const border = borderData[key];
26882
- if (border === null || border === void 0 || (_border$cl = border.cl) === null || _border$cl === void 0 ? void 0 : _border$cl.rgb) return border.cl.rgb;
26883
- }
26884
- }
26885
- function getBorderStyle(borderData) {
26886
- if (!borderData) return;
26887
- for (const key in borderData) {
26888
- var _border$cl2;
26889
- const border = borderData[key];
26890
- if (border === null || border === void 0 || (_border$cl2 = border.cl) === null || _border$cl2 === void 0 ? void 0 : _border$cl2.rgb) return border.s;
26891
- }
26892
- }
26893
27044
  function BorderPanel(props) {
26894
27045
  const iconManager = useDependency(IconManager);
26895
- const borderStyleManagerService = useDependency(BorderStyleManagerService);
26896
27046
  const selectionManagerService = useDependency(SheetsSelectionsService);
26897
27047
  const { direction } = useContext(ConfigContext);
26898
27048
  const { isAllValuesSame, value: currentValue } = selectionManagerService.getCellStylesProperty("bd");
26899
27049
  const color = isAllValuesSame ? getBorderColor(currentValue) : void 0;
26900
- const type = isAllValuesSame ? getBorderStyle(currentValue) : void 0;
26901
27050
  const { onChange, value, ColorPickerComponent = ColorPicker, DropdownComponent = Dropdown } = props;
27051
+ function getBorderColor(borderData) {
27052
+ if (!borderData) return;
27053
+ for (const key in borderData) {
27054
+ var _border$cl;
27055
+ const border = borderData[key];
27056
+ if (border === null || border === void 0 || (_border$cl = border.cl) === null || _border$cl === void 0 ? void 0 : _border$cl.rgb) return border.cl.rgb;
27057
+ }
27058
+ }
26902
27059
  function handleClick(v, type) {
26903
27060
  onChange === null || onChange === void 0 || onChange({
26904
27061
  ...value,
@@ -26916,7 +27073,7 @@ function BorderPanel(props) {
26916
27073
  /* @__PURE__ */ jsx("div", {
26917
27074
  className: "univer-box-border univer-grid univer-grid-cols-5 univer-gap-2 univer-text-gray-600 dark:!univer-text-gray-200",
26918
27075
  children: BORDER_LINE_CHILDREN.map((item) => /* @__PURE__ */ jsx("a", {
26919
- className: clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-200 dark:!univer-bg-gray-600": borderStyleManagerService.getBorderInfo().type === item.value }),
27076
+ className: clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-200 dark:!univer-bg-gray-600": value.type === item.value }),
26920
27077
  onClick: (e) => {
26921
27078
  e.stopPropagation();
26922
27079
  handleClick(item.value, "type");
@@ -26948,14 +27105,17 @@ function BorderPanel(props) {
26948
27105
  className: "univer-rounded-lg univer-p-1.5",
26949
27106
  children: /* @__PURE__ */ jsx("ul", {
26950
27107
  className: "univer-m-0 univer-grid univer-list-none univer-gap-1 univer-p-0",
26951
- children: BORDER_SIZE_CHILDREN.map((item) => /* @__PURE__ */ jsxs("li", {
26952
- className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-px-1 univer-py-3 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
27108
+ children: BORDER_SIZE_CHILDREN.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
27109
+ type: "button",
27110
+ "aria-label": BorderStyleTypes[item.value],
27111
+ "aria-pressed": item.value === value.style,
27112
+ className: clsx("univer-flex univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-1 univer-py-3 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-200 dark:!univer-bg-gray-600": item.value === value.style }),
26953
27113
  onClick: () => handleClick(item.value, "style"),
26954
- children: [item.value === type && /* @__PURE__ */ jsx(CheckMarkIcon, { className: "univer-absolute univer-left-3 univer-text-primary-600" }), /* @__PURE__ */ jsx(BorderLine, {
26955
- className: "univer-ml-6 univer-fill-gray-900 dark:!univer-fill-gray-0",
27114
+ children: /* @__PURE__ */ jsx(BorderLine, {
27115
+ className: "univer-fill-gray-900 dark:!univer-fill-gray-0",
26956
27116
  type: item.value
26957
- })]
26958
- }, item.value))
27117
+ })
27118
+ }) }, item.value))
26959
27119
  })
26960
27120
  }),
26961
27121
  children: /* @__PURE__ */ jsxs("button", {
@@ -26963,7 +27123,7 @@ function BorderPanel(props) {
26963
27123
  type: "button",
26964
27124
  children: [/* @__PURE__ */ jsx(BorderLine, {
26965
27125
  className: "univer-fill-gray-900 dark:!univer-fill-gray-0",
26966
- type: type ?? BorderStyleTypes.THIN
27126
+ type: value.style
26967
27127
  }), /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
26968
27128
  })
26969
27129
  }) })]
@@ -28974,7 +29134,8 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
28974
29134
  let body = Tools.deepClone((_param$documentLayout = param.documentLayoutObject.documentModel) === null || _param$documentLayout === void 0 ? void 0 : _param$documentLayout.getBody());
28975
29135
  const drawings = Tools.deepClone((_param$documentLayout2 = param.documentLayoutObject.documentModel) === null || _param$documentLayout2 === void 0 ? void 0 : _param$documentLayout2.drawings);
28976
29136
  const drawingsOrder = Tools.deepClone((_param$documentLayout3 = param.documentLayoutObject.documentModel) === null || _param$documentLayout3 === void 0 ? void 0 : _param$documentLayout3.getDrawingsOrder());
28977
- if (!body || param.isInArrayFormulaRange === true && this._editorBridgeService.isVisible().eventType === DeviceInputEventType.Dblclick) body = {
29137
+ const { visible } = this._editorBridgeService.isVisible();
29138
+ if (!body || param.isInArrayFormulaRange === true && visible) body = {
28978
29139
  dataStream: "\r\n",
28979
29140
  paragraphs: [{
28980
29141
  startIndex: 0,
@@ -29112,7 +29273,7 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
29112
29273
  ...formulaEditorStyle,
29113
29274
  pageSize: { ...formulaEditorStyle.pageSize },
29114
29275
  renderConfig: { ...formulaEditorStyle.renderConfig },
29115
- textStyle: { cl: { rgb: this._themeService.getColorFromTheme("gray.900") } }
29276
+ textStyle: { cl: { rgb: this._getFormulaBarTextColor() } }
29116
29277
  };
29117
29278
  else snapshot.documentStyle ??= {};
29118
29279
  let renderConfig = snapshot.documentStyle.renderConfig;
@@ -29135,6 +29296,11 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
29135
29296
  const isFocusFxBar = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
29136
29297
  renderConfig.isRenderStyle = isFormulaBar === isFocusFxBar ? BooleanNumber.TRUE : BooleanNumber.FALSE;
29137
29298
  }
29299
+ _getFormulaBarTextColor() {
29300
+ var _this$_editorBridgeSe;
29301
+ const isInheritedFormula = ((_this$_editorBridgeSe = this._editorBridgeService.getEditLocation()) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.isInArrayFormulaRange) === true && !this._editorBridgeService.isVisible().visible;
29302
+ return this._themeService.getColorFromTheme(isInheritedFormula ? "gray.300" : "gray.900");
29303
+ }
29138
29304
  _getSourceStyleRenderValue(isFormulaBar) {
29139
29305
  return isFormulaBar ? BooleanNumber.FALSE : BooleanNumber.TRUE;
29140
29306
  }
@@ -32801,10 +32967,14 @@ let MobileCellEditRenderController = class MobileCellEditRenderController extend
32801
32967
  if (cell.location.unitId !== this._context.unitId) return;
32802
32968
  const snapshot = (_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getSnapshot();
32803
32969
  if (isCellImage(snapshot)) return;
32804
- this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
32970
+ this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
32805
32971
  visible: true,
32806
32972
  eventType: DeviceInputEventType.Dblclick,
32807
- unitId: this._context.unitId
32973
+ unitId: this._context.unitId,
32974
+ pointerPosition: {
32975
+ x: cell.event.clientX,
32976
+ y: cell.event.clientY
32977
+ }
32808
32978
  });
32809
32979
  }));
32810
32980
  this.disposeWithMe(hoverManagerService.currentPointerDownCell$.subscribe((cell) => {
@@ -33237,7 +33407,7 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33237
33407
  return;
33238
33408
  }
33239
33409
  this._resetCompletedTap();
33240
- this._hoverManagerService.triggerDbClick(unitId, event.offsetX, event.offsetY);
33410
+ this._hoverManagerService.triggerDbClick(unitId, event);
33241
33411
  },
33242
33412
  priority: -1
33243
33413
  }));
@@ -33313,7 +33483,7 @@ let MobileHoverRenderController = class MobileHoverRenderController extends Disp
33313
33483
  this._suppressEngineDoubleClick = false;
33314
33484
  this._suppressEngineDoubleClickTimer = null;
33315
33485
  });
33316
- this._hoverManagerService.triggerDbClick(unitId, event.offsetX, event.offsetY);
33486
+ this._hoverManagerService.triggerDbClick(unitId, event);
33317
33487
  return;
33318
33488
  }
33319
33489
  this._resetCompletedTap();
@@ -35321,20 +35491,22 @@ const ISheetHostChromeOverrideService = createIdentifier("sheet-ui.host-chrome-o
35321
35491
  //#endregion
35322
35492
  //#region src/controllers/render-controllers/contextmenu.render-controller.ts
35323
35493
  let SheetContextMenuRenderController = class SheetContextMenuRenderController extends Disposable {
35324
- constructor(_context, _contextMenuService, _selectionManagerService, _selectionRenderService, _injector) {
35494
+ constructor(_context, _contextMenuService, _selectionManagerService, _selectionRenderService, _injector, _platformService, _contextService) {
35325
35495
  super();
35326
35496
  this._context = _context;
35327
35497
  this._contextMenuService = _contextMenuService;
35328
35498
  this._selectionManagerService = _selectionManagerService;
35329
35499
  this._selectionRenderService = _selectionRenderService;
35330
35500
  this._injector = _injector;
35501
+ this._platformService = _platformService;
35502
+ this._contextService = _contextService;
35331
35503
  this._init();
35332
35504
  this._initEmbedRuntimeSessionListener();
35333
35505
  }
35334
35506
  _init() {
35335
35507
  var _this$_context;
35336
35508
  const spreadsheetSubscription = ((_this$_context = this._context) === null || _this$_context === void 0 || (_this$_context = _this$_context.mainComponent) === null || _this$_context === void 0 ? void 0 : _this$_context.onPointerDown$).subscribeEvent((event) => {
35337
- if (event.button === 2) {
35509
+ if (this._isContextMenuGesture(event)) {
35338
35510
  const selections = this._selectionManagerService.getCurrentSelections();
35339
35511
  const currentSelection = selections === null || selections === void 0 ? void 0 : selections[0];
35340
35512
  if (!currentSelection) return;
@@ -35364,20 +35536,23 @@ let SheetContextMenuRenderController = class SheetContextMenuRenderController ex
35364
35536
  this.disposeWithMe(spreadsheetSubscription);
35365
35537
  const spreadsheetColumnHeader = this._context.components.get("__SpreadsheetColumnHeader__");
35366
35538
  const rowHeaderSub = this._context.components.get("__SpreadsheetRowHeader__").onPointerDown$.subscribeEvent((event) => {
35367
- if (event.button === 2) {
35539
+ if (this._isContextMenuGesture(event)) {
35368
35540
  if (this._shouldSuppressHostContextMenu()) return;
35369
35541
  this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.ROW_HEADER);
35370
35542
  }
35371
35543
  });
35372
35544
  this.disposeWithMe(rowHeaderSub);
35373
35545
  const colHeaderObserver = spreadsheetColumnHeader.onPointerDown$.subscribeEvent((event) => {
35374
- if (event.button === 2) {
35546
+ if (this._isContextMenuGesture(event)) {
35375
35547
  if (this._shouldSuppressHostContextMenu()) return;
35376
35548
  this._contextMenuService.triggerContextMenu(event, ContextMenuPosition.COL_HEADER);
35377
35549
  }
35378
35550
  });
35379
35551
  this.disposeWithMe(colHeaderObserver);
35380
35552
  }
35553
+ _isContextMenuGesture(event) {
35554
+ return isSheetContextMenuGesture(event, this._platformService.isMac, this._contextService.getContextValue(REF_SELECTIONS_ENABLED));
35555
+ }
35381
35556
  _initEmbedRuntimeSessionListener() {
35382
35557
  const runtimeFocusCoordinator = this._getSheetEmbedRuntimeFocusCoordinator();
35383
35558
  if (!runtimeFocusCoordinator) return;
@@ -35400,7 +35575,9 @@ SheetContextMenuRenderController = __decorate([
35400
35575
  __decorateParam(1, IContextMenuService),
35401
35576
  __decorateParam(2, Inject(SheetsSelectionsService)),
35402
35577
  __decorateParam(3, ISheetSelectionRenderService),
35403
- __decorateParam(4, Inject(Injector))
35578
+ __decorateParam(4, Inject(Injector)),
35579
+ __decorateParam(5, IPlatformService),
35580
+ __decorateParam(6, IContextService)
35404
35581
  ], SheetContextMenuRenderController);
35405
35582
  function shouldHideSheetHostContextMenuForEmbedSession(hostUnitId, activeScope) {
35406
35583
  return (activeScope === null || activeScope === void 0 ? void 0 : activeScope.hostUnitId) === hostUnitId && activeScope.sessionMode !== "host-passive";
@@ -35412,7 +35589,7 @@ function shouldSuppressSheetContextMenuForEmbedOverride(hostUnitId, override) {
35412
35589
  //#endregion
35413
35590
  //#region src/controllers/render-controllers/desktop-cell-edit.render-controller.ts
35414
35591
  let DesktopCellEditRenderController = class DesktopCellEditRenderController extends RxDisposable {
35415
- constructor(_context, _instanceService, _commandService, _editorBridgeService, _selectionManagerService, _contextService, _renderManagerService, _embedRuntimeFocusCoordinator) {
35592
+ constructor(_context, _instanceService, _commandService, _editorBridgeService, _selectionManagerService, _contextService, _renderManagerService, _platformService, _embedRuntimeFocusCoordinator) {
35416
35593
  super();
35417
35594
  this._context = _context;
35418
35595
  this._instanceService = _instanceService;
@@ -35421,6 +35598,7 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
35421
35598
  this._selectionManagerService = _selectionManagerService;
35422
35599
  this._contextService = _contextService;
35423
35600
  this._renderManagerService = _renderManagerService;
35601
+ this._platformService = _platformService;
35424
35602
  this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
35425
35603
  _defineProperty(this, "_d", void 0);
35426
35604
  this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
@@ -35448,13 +35626,17 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
35448
35626
  const { spreadsheet, spreadsheetColumnHeader, spreadsheetLeftTopPlaceholder, spreadsheetRowHeader } = sheetObject;
35449
35627
  d.add(spreadsheet.onDblclick$.subscribeEvent((evt) => {
35450
35628
  var _this$_editorBridgeSe;
35451
- if (evt.button === 2) return;
35629
+ if (isSheetContextMenuGesture(evt, this._platformService.isMac, this._contextService.getContextValue(REF_SELECTIONS_ENABLED))) return;
35452
35630
  const snapshot = (_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getSnapshot();
35453
35631
  if (isCellImage(snapshot)) return;
35454
- this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
35632
+ this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
35455
35633
  visible: true,
35456
35634
  eventType: DeviceInputEventType.Dblclick,
35457
- unitId: this._context.unitId
35635
+ unitId: this._context.unitId,
35636
+ pointerPosition: {
35637
+ x: evt.clientX,
35638
+ y: evt.clientY
35639
+ }
35458
35640
  });
35459
35641
  }));
35460
35642
  d.add(spreadsheet.onPointerDown$.subscribeEvent({
@@ -35583,7 +35765,8 @@ DesktopCellEditRenderController = __decorate([
35583
35765
  __decorateParam(4, Inject(SheetsSelectionsService)),
35584
35766
  __decorateParam(5, IContextService),
35585
35767
  __decorateParam(6, IRenderManagerService),
35586
- __decorateParam(7, Optional(ISheetEmbedRuntimeFocusCoordinator))
35768
+ __decorateParam(7, IPlatformService),
35769
+ __decorateParam(8, Optional(ISheetEmbedRuntimeFocusCoordinator))
35587
35770
  ], DesktopCellEditRenderController);
35588
35771
  function resolvePointerEventPayload(payload) {
35589
35772
  return Array.isArray(payload) ? payload[0] : payload;
@@ -35747,38 +35930,34 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35747
35930
  const { spreadsheetRowHeader, spreadsheetColumnHeader, spreadsheet, spreadsheetLeftTopPlaceholder } = sheetObject;
35748
35931
  const { scene } = this._context;
35749
35932
  this.disposeWithMe(spreadsheet === null || spreadsheet === void 0 ? void 0 : spreadsheet.onPointerDown$.subscribeEvent((evt, state) => {
35750
- if (this.isSelectionDisabled()) return;
35751
- if (this.inRefSelectionMode()) return;
35933
+ if (this.isSelectionDisabled() || this.inRefSelectionMode()) return;
35752
35934
  this._onPointerDown(evt, spreadsheet.zIndex + 1, RANGE_TYPE.NORMAL, this._getActiveViewport(evt));
35753
- if (evt.button !== 2) state.stopPropagation();
35935
+ if (!this._isContextMenuGesture(evt)) state.stopPropagation();
35754
35936
  }));
35755
35937
  this.disposeWithMe(spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 ? void 0 : spreadsheetRowHeader.onPointerDown$.subscribeEvent((evt, state) => {
35756
- if (this.isSelectionDisabled()) return;
35757
- if (this.inRefSelectionMode()) return;
35938
+ if (this.isSelectionDisabled() || this.inRefSelectionMode()) return;
35758
35939
  const skeleton = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
35759
35940
  const { row } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
35760
35941
  if (isThisRowSelected(this._workbookSelections.getCurrentSelections(), row)) return;
35761
35942
  this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.ROW, this._getActiveViewport(evt), ScrollTimerType.Y);
35762
- if (evt.button !== 2) state.stopPropagation();
35943
+ if (!this._isContextMenuGesture(evt)) state.stopPropagation();
35763
35944
  }));
35764
35945
  this.disposeWithMe(spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 ? void 0 : spreadsheetColumnHeader.onPointerDown$.subscribeEvent((evt, state) => {
35765
- if (this.isSelectionDisabled()) return;
35766
- if (this.inRefSelectionMode()) return;
35946
+ if (this.isSelectionDisabled() || this.inRefSelectionMode()) return;
35767
35947
  const skeleton = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
35768
35948
  const { column } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
35769
35949
  if (isThisColSelected(this._workbookSelections.getCurrentSelections(), column)) return;
35770
35950
  this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.COLUMN, this._getActiveViewport(evt), ScrollTimerType.X);
35771
- if (evt.button !== 2) state.stopPropagation();
35951
+ if (!this._isContextMenuGesture(evt)) state.stopPropagation();
35772
35952
  }));
35773
35953
  this.disposeWithMe(spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 ? void 0 : spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent((evt, state) => {
35774
- if (this.isSelectionDisabled()) return;
35775
- if (this.inRefSelectionMode()) return;
35954
+ if (this.isSelectionDisabled() || this.inRefSelectionMode()) return;
35776
35955
  this._reset();
35777
35956
  const skeleton = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
35778
35957
  const selectionWithStyle = selectionDataForSelectAll(skeleton);
35779
35958
  this._addSelectionControlByModelData(selectionWithStyle);
35780
35959
  this.refreshSelectionMoveEnd();
35781
- if (evt.button !== 2) state.stopPropagation();
35960
+ if (!this._isContextMenuGesture(evt)) state.stopPropagation();
35782
35961
  }));
35783
35962
  }
35784
35963
  _initThemeChangeListener() {
@@ -35859,7 +36038,7 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35859
36038
  const sheetId = workbook.getActiveSheet().getSheetId();
35860
36039
  if (selectionDataWithStyleList.length === 0) return;
35861
36040
  const selectionWithStyles = selectionDataWithStyleList.map((selectionDataWithStyle) => convertSelectionDataToRange(selectionDataWithStyle));
35862
- this._commandService.executeCommand(SetSelectionsOperation.id, {
36041
+ this._commandService.syncExecuteCommand(SetSelectionsOperation.id, {
35863
36042
  unitId,
35864
36043
  subUnitId: sheetId,
35865
36044
  type,
@@ -35880,6 +36059,7 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35880
36059
  const prevSheetId = (_this$_skeleton = this._skeleton) === null || _this$_skeleton === void 0 || (_this$_skeleton = _this$_skeleton.worksheet) === null || _this$_skeleton === void 0 ? void 0 : _this$_skeleton.getSheetId();
35881
36060
  this._changeRuntime(skeleton, scene, viewportMain);
35882
36061
  if (prevSheetId !== skeleton.worksheet.getSheetId()) {
36062
+ this._reset();
35883
36063
  const selections = this._workbookSelections.getCurrentSelections();
35884
36064
  this._commandService.syncExecuteCommand(SetSelectionsOperation.id, {
35885
36065
  unitId,
@@ -35914,11 +36094,10 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35914
36094
  this._rangeType = rangeType;
35915
36095
  const skeleton = this._skeleton;
35916
36096
  const scene = this._scene;
35917
- if (!scene || !skeleton) return;
36097
+ const viewportMain = scene === null || scene === void 0 ? void 0 : scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
36098
+ if (!scene || !skeleton || !viewportMain) return;
35918
36099
  if (viewport) this._activeViewport = viewport;
35919
36100
  const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt;
35920
- const viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
35921
- if (!viewportMain) return;
35922
36101
  const relativeCoords = scene.getCoordRelativeToViewport(Vector2.FromArray([evtOffsetX, evtOffsetY]));
35923
36102
  const { x: offsetX, y: offsetY } = relativeCoords;
35924
36103
  this._startViewportPosX = offsetX;
@@ -35928,7 +36107,6 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35928
36107
  const selectCell = this._skeleton.getCellByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY);
35929
36108
  if (!selectCell) return;
35930
36109
  switch (rangeType) {
35931
- case RANGE_TYPE.NORMAL: break;
35932
36110
  case RANGE_TYPE.ROW:
35933
36111
  selectCell.startColumn = 0;
35934
36112
  selectCell.endColumn = this._skeleton.getColumnCount() - 1;
@@ -35955,6 +36133,11 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35955
36133
  selectionWithStyle.range.rangeType = rangeType;
35956
36134
  const activeSelectionControl = this._updateSelectionControl(evt, selectionWithStyle);
35957
36135
  if (!activeSelectionControl) return;
36136
+ if (this._isContextMenuGesture(evt)) {
36137
+ this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
36138
+ this.endSelection();
36139
+ return;
36140
+ }
35958
36141
  scene.disableObjectsEvent();
35959
36142
  this._clearUpdatingListeners();
35960
36143
  this._addEndingListeners();
@@ -35966,20 +36149,32 @@ let SheetSelectionRenderService = class SheetSelectionRenderService extends Base
35966
36149
  (_this$_scene$getEngin = this._scene.getEngine()) === null || _this$_scene$getEngin === void 0 || _this$_scene$getEngin.setCapture();
35967
36150
  }
35968
36151
  _updateSelectionControl(evt, selection) {
35969
- const cursorRange = attachSelectionWithCoord(selection, this._skeleton).rangeWithCoord;
36152
+ const selectionWithCoord = attachSelectionWithCoord(selection, this._skeleton);
36153
+ const cursorRange = selectionWithCoord.rangeWithCoord;
35970
36154
  this._startRangeWhenPointerDown = { ...cursorRange };
35971
36155
  const controls = this.getSelectionControls();
35972
36156
  const isSelected = controls.some((control) => Rectangle.contains(control.model, cursorRange));
35973
- if (evt.button === 2 && isSelected) return;
35974
- if (evt.button === 0 && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey && !this._singleSelectionEnabled && this._rangeType === RANGE_TYPE.NORMAL && isSelected) this._selectionBeforeModifierClick = this.getSelectionDataWithStyle().map(convertSelectionDataToRange);
36157
+ if (this._isContextMenuGesture(evt) && isSelected) return;
36158
+ if (evt.button === 0 && !this._isContextMenuGesture(evt) && this._isMultiSelectModifier(evt) && !evt.shiftKey && !this._singleSelectionEnabled && this._rangeType === RANGE_TYPE.NORMAL && isSelected) this._selectionBeforeModifierClick = this.getSelectionDataWithStyle().map(convertSelectionDataToRange);
35975
36159
  let activeControl = this.getActiveSelectionControl();
36160
+ if (activeControl && this._canAnimateSelection(evt, activeControl, cursorRange)) {
36161
+ activeControl.updateRangeBySelectionWithCoord(selectionWithCoord, this._skeleton, true);
36162
+ return activeControl;
36163
+ }
35976
36164
  this._checkClearPreviousControls(evt);
35977
36165
  const currentCell = activeControl === null || activeControl === void 0 ? void 0 : activeControl.model.currentCell;
35978
- if (evt.shiftKey && currentCell && activeControl) this._makeSelectionByTwoCells(currentCell, cursorRange, this._skeleton, this._rangeType, activeControl);
36166
+ if (!this._isContextMenuGesture(evt) && evt.shiftKey && currentCell && activeControl) this._makeSelectionByTwoCells(currentCell, cursorRange, this._skeleton, this._rangeType, activeControl);
35979
36167
  else activeControl = this.newSelectionControl(this._scene, this._skeleton, selection);
35980
36168
  for (let i = 0; i < controls.length - 1; i++) controls[i].clearHighlight();
35981
36169
  return activeControl;
35982
36170
  }
36171
+ _canAnimateSelection(evt, control, target) {
36172
+ if (this.getSelectionControls().length !== 1 || this._rangeType !== RANGE_TYPE.NORMAL || this._remainLastEnabled || evt.button !== 0 || evt.ctrlKey || evt.metaKey || evt.shiftKey || evt.altKey) return false;
36173
+ const current = control.getCurrentCellInfo();
36174
+ if (!current || !Rectangle.equals(control.model, current)) return false;
36175
+ const freeze = this._skeleton.worksheet.getFreeze();
36176
+ return current.startRow < freeze.startRow === target.startRow < freeze.startRow && current.startColumn < freeze.startColumn === target.startColumn < freeze.startColumn;
36177
+ }
35983
36178
  endSelection() {
35984
36179
  const previousSelections = this._selectionBeforeModifierClick;
35985
36180
  this._selectionBeforeModifierClick = null;
@@ -36169,4 +36364,4 @@ UniverSheetsUIPlugin = __decorate([
36169
36364
  ], UniverSheetsUIPlugin);
36170
36365
 
36171
36366
  //#endregion
36172
- export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillPopupMenu, AutoFillUIController, AutoHeightController, AutoWidthController, BORDER_LINE_CHILDREN, BORDER_SIZE_CHILDREN, BaseSelectionRenderService, BorderLine, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, EditorContainer, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaBar, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetBarService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetEmbedFloatingGeometryService, ISheetEmbedInteractionBoundaryService, ISheetEmbedRuntimeFocusCoordinator, ISheetEmbedRuntimeService, ISheetHostChromeOverrideService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MOBILE_CONTEXT_MENU, MOBILE_EXPANDING_SELECTION, MOBILE_FORMULA_FUNCTION_PANEL_OPEN, MOBILE_PINCH_ZOOMING, MarkSelectionService, MobileSelectionControl, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEETS_UI_PLUGIN_CONFIG_KEY, SHEET_EMBED_CHILD_TYPE_ATTRIBUTE, SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE, SHEET_EMBED_FLOAT_DOM_ATTRIBUTE, SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE, SHEET_EMBED_ID_ATTRIBUTE, SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE, SHEET_FOOTER_BAR_HEIGHT, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetBar, SheetBarService, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetContextMenuMobileRenderController, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetPrintingResourceCollector, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, resolveActiveSheetEmbedRuntimeDomScope, resolveSheetEmbedRuntimeDomScope, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };
36367
+ export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillPopupMenu, AutoFillUIController, AutoHeightController, AutoWidthController, BORDER_LINE_CHILDREN, BORDER_SIZE_CHILDREN, BaseSelectionRenderService, BorderLine, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DEFINED_NAME_CONTAINER, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, EditorContainer, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaBar, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetBarService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetEmbedFloatingGeometryService, ISheetEmbedInteractionBoundaryService, ISheetEmbedRuntimeFocusCoordinator, ISheetEmbedRuntimeService, ISheetHostChromeOverrideService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MOBILE_CONTEXT_MENU, MOBILE_EXPANDING_SELECTION, MOBILE_FORMULA_FUNCTION_PANEL_OPEN, MOBILE_PINCH_ZOOMING, MarkSelectionService, MobileSelectionControl, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEETS_UI_PLUGIN_CONFIG_KEY, SHEET_EMBED_CHILD_TYPE_ATTRIBUTE, SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE, SHEET_EMBED_FLOAT_DOM_ATTRIBUTE, SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE, SHEET_EMBED_ID_ATTRIBUTE, SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE, SHEET_FOOTER_BAR_HEIGHT, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetBar, SheetBarService, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetContextMenuMobileRenderController, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetPrintingResourceCollector, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, resolveActiveSheetEmbedRuntimeDomScope, resolveSheetEmbedRuntimeDomScope, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };