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