@univerjs/sheets-formula-ui 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/lib/cjs/index.js +361 -215
  2. package/lib/cjs/locale/ar-SA.js +14 -0
  3. package/lib/cjs/locale/ca-ES.js +14 -0
  4. package/lib/cjs/locale/de-DE.js +14 -0
  5. package/lib/cjs/locale/en-US.js +14 -0
  6. package/lib/cjs/locale/es-ES.js +14 -0
  7. package/lib/cjs/locale/fa-IR.js +14 -0
  8. package/lib/cjs/locale/fr-FR.js +14 -0
  9. package/lib/cjs/locale/id-ID.js +14 -0
  10. package/lib/cjs/locale/it-IT.js +14 -0
  11. package/lib/cjs/locale/ja-JP.js +14 -0
  12. package/lib/cjs/locale/ko-KR.js +14 -0
  13. package/lib/cjs/locale/pl-PL.js +14 -0
  14. package/lib/cjs/locale/pt-BR.js +14 -0
  15. package/lib/cjs/locale/ru-RU.js +14 -0
  16. package/lib/cjs/locale/sk-SK.js +14 -0
  17. package/lib/cjs/locale/vi-VN.js +14 -0
  18. package/lib/cjs/locale/zh-CN.js +14 -0
  19. package/lib/cjs/locale/zh-HK.js +14 -0
  20. package/lib/cjs/locale/zh-TW.js +14 -0
  21. package/lib/es/index.js +366 -215
  22. package/lib/es/locale/ar-SA.js +14 -0
  23. package/lib/es/locale/ca-ES.js +14 -0
  24. package/lib/es/locale/de-DE.js +14 -0
  25. package/lib/es/locale/en-US.js +14 -0
  26. package/lib/es/locale/es-ES.js +14 -0
  27. package/lib/es/locale/fa-IR.js +14 -0
  28. package/lib/es/locale/fr-FR.js +14 -0
  29. package/lib/es/locale/id-ID.js +14 -0
  30. package/lib/es/locale/it-IT.js +14 -0
  31. package/lib/es/locale/ja-JP.js +14 -0
  32. package/lib/es/locale/ko-KR.js +14 -0
  33. package/lib/es/locale/pl-PL.js +14 -0
  34. package/lib/es/locale/pt-BR.js +14 -0
  35. package/lib/es/locale/ru-RU.js +14 -0
  36. package/lib/es/locale/sk-SK.js +14 -0
  37. package/lib/es/locale/vi-VN.js +14 -0
  38. package/lib/es/locale/zh-CN.js +14 -0
  39. package/lib/es/locale/zh-HK.js +14 -0
  40. package/lib/es/locale/zh-TW.js +14 -0
  41. package/lib/index.css +4 -20
  42. package/lib/index.js +366 -215
  43. package/lib/locale/ar-SA.js +14 -0
  44. package/lib/locale/ca-ES.js +14 -0
  45. package/lib/locale/de-DE.js +14 -0
  46. package/lib/locale/en-US.js +14 -0
  47. package/lib/locale/es-ES.js +14 -0
  48. package/lib/locale/fa-IR.js +14 -0
  49. package/lib/locale/fr-FR.js +14 -0
  50. package/lib/locale/id-ID.js +14 -0
  51. package/lib/locale/it-IT.js +14 -0
  52. package/lib/locale/ja-JP.js +14 -0
  53. package/lib/locale/ko-KR.js +14 -0
  54. package/lib/locale/pl-PL.js +14 -0
  55. package/lib/locale/pt-BR.js +14 -0
  56. package/lib/locale/ru-RU.js +14 -0
  57. package/lib/locale/sk-SK.js +14 -0
  58. package/lib/locale/vi-VN.js +14 -0
  59. package/lib/locale/zh-CN.js +14 -0
  60. package/lib/locale/zh-HK.js +14 -0
  61. package/lib/locale/zh-TW.js +14 -0
  62. package/lib/types/commands/operations/calculation-options.operation.d.ts +19 -0
  63. package/lib/types/controllers/formula-alert-render.controller.d.ts +14 -6
  64. package/lib/types/index.d.ts +1 -1
  65. package/lib/types/locale/en-US.d.ts +14 -0
  66. package/lib/types/menu/menu.d.ts +1 -0
  67. package/lib/types/mobile-plugin.d.ts +0 -1
  68. package/lib/types/plugin.d.ts +0 -1
  69. package/lib/types/views/calculation-options/CalculationOptions.d.ts +19 -0
  70. package/lib/types/views/calculation-options/interface.d.ts +17 -0
  71. package/lib/types/views/formula-editor/formula-embed-integration.service.d.ts +2 -0
  72. package/lib/types/views/formula-editor/hooks/use-focus.d.ts +1 -5
  73. package/lib/types/views/formula-editor/hooks/use-highlight.d.ts +2 -8
  74. package/lib/umd/index.js +5 -5
  75. package/lib/umd/locale/ar-SA.js +1 -1
  76. package/lib/umd/locale/ca-ES.js +1 -1
  77. package/lib/umd/locale/de-DE.js +1 -1
  78. package/lib/umd/locale/en-US.js +1 -1
  79. package/lib/umd/locale/es-ES.js +1 -1
  80. package/lib/umd/locale/fa-IR.js +1 -1
  81. package/lib/umd/locale/fr-FR.js +1 -1
  82. package/lib/umd/locale/id-ID.js +1 -1
  83. package/lib/umd/locale/it-IT.js +1 -1
  84. package/lib/umd/locale/ja-JP.js +1 -1
  85. package/lib/umd/locale/ko-KR.js +1 -1
  86. package/lib/umd/locale/pl-PL.js +1 -1
  87. package/lib/umd/locale/pt-BR.js +1 -1
  88. package/lib/umd/locale/ru-RU.js +1 -1
  89. package/lib/umd/locale/sk-SK.js +1 -1
  90. package/lib/umd/locale/vi-VN.js +1 -1
  91. package/lib/umd/locale/zh-CN.js +1 -1
  92. package/lib/umd/locale/zh-HK.js +1 -1
  93. package/lib/umd/locale/zh-TW.js +1 -1
  94. package/package.json +15 -15
  95. package/lib/types/controllers/formula-reorder.controller.d.ts +0 -27
package/lib/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { AbsoluteRefType, BuildTextUtils, CellValueType, ColorKit, CommandType, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, HorizontalAlign, ICommandService, IConfigService, IContextService, ILogService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RANGE_TYPE, Range, Rectangle, RichTextBuilder, RxDisposable, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, createInternalEditorID, generateRandomId, getCellValueType, getEmptyCell, isFormulaId, isFormulaString, isICellData, isRealNum, merge, noop, regexp, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, JumpOver, MOBILE_EXPANDING_SELECTION, MOBILE_FORMULA_FUNCTION_PANEL_OPEN, MOBILE_PINCH_ZOOMING, MobileSelectionControl, MoveSelectionCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, SELECTION_SHAPE_DEPTH, SelectionControl, SetCellEditVisibleOperation, SheetPasteCommand, SheetSkeletonManagerService, SheetsUIPart, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, checkInHeaderRanges, genNormalSelectionStyle, getAllSelection, getCoordByOffset, getCurrentRangeDisable$, getSheetObject, menuClipboardDisabledObservable, useActiveWorkbook, whenSheetEditorActivated, whenSheetEditorFocused } from "@univerjs/sheets-ui";
3
- import { ErrorType, FormulaDataModel, FunctionType, IDescriptionService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, UniverFormulaEnginePlugin, buildFormulaTextRuns, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReplaceResult, handleRefStringInfo, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, matchRefDrawToken, matchToken, operatorToken, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
1
+ import { AbsoluteRefType, BuildTextUtils, CellValueType, ColorKit, CommandType, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, HorizontalAlign, ICommandService, IConfigService, IContextService, ILogService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, MAX_ITERATION_COUNT, ObjectMatrix, Plugin, RANGE_TYPE, Rectangle, RichTextBuilder, RxDisposable, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, createInternalEditorID, generateRandomId, getCellValueType, getEmptyCell, isFormulaId, isFormulaString, isICellData, isRealNum, merge, noop, normalizeWorkbookCalculationSettings, regexp, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
2
+ import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, JumpOver, MOBILE_EXPANDING_SELECTION, MOBILE_FORMULA_FUNCTION_PANEL_OPEN, MOBILE_PINCH_ZOOMING, MobileSelectionControl, MoveSelectionCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, SELECTION_SHAPE_DEPTH, SelectionControl, SetCellEditVisibleOperation, SheetPasteCommand, SheetSkeletonManagerService, SheetsUIPart, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, checkInHeaderRanges, genNormalSelectionStyle, getAllSelection, getCoordByOffset, getCurrentRangeDisable$, getSheetObject, menuClipboardDisabledObservable, useActiveWorkbook, whenSheetEditorActivated, whenSheetEditorFocused } from "@univerjs/sheets-ui";
3
+ import { ErrorType, FormulaDataModel, FunctionType, IDescriptionService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, UniverFormulaEnginePlugin, buildFormulaTextRuns, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReplaceResult, handleRefStringInfo, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, matchRefDrawToken, matchToken, operatorToken, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
4
4
  import { BehaviorSubject, Subject, combineLatestWith, debounceTime, distinctUntilChanged, filter, map, merge as merge$1, throttleTime } from "rxjs";
5
5
  import { DocBackScrollRenderController, DocSelectionRenderService, IEditorService, MoveCursorOperation, MoveSelectionOperation, ReplaceTextRunsCommand, RichTextEditor, createEditorUndoRedoKeyboardConfig, useKeyboardEvent, useResize } from "@univerjs/docs-ui";
6
- import { DeviceInputEventType, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimer, ScrollTimerType, UniverRenderEnginePlugin, Vector2 } from "@univerjs/engine-render";
7
- import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, ReorderRangeCommand, SelectionMoveType, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCopyPermission, WorkbookEditablePermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetSetCellValuePermission, attachSelectionWithCoord, convertSelectionDataToRange, getCellAtRowCol, getSheetCommandTarget, setEndForRange } from "@univerjs/sheets";
6
+ import { DeviceInputEventType, ICanvasColorService, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimer, ScrollTimerType, UniverRenderEnginePlugin, Vector2 } from "@univerjs/engine-render";
7
+ import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, SelectionMoveType, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorkbookCalculationSettingsCommand, SetWorkbookCalculationSettingsMutation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCopyPermission, WorkbookEditablePermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetSetCellValuePermission, attachSelectionWithCoord, convertSelectionDataToRange, getCellAtRowCol, getSheetCommandTarget, setEndForRange } from "@univerjs/sheets";
8
8
  import { ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, TriggerCalculationController, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
9
- import { BuiltInUIPart, ComponentManager, IContextMenuService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, ProgressBar, RectPopup, RibbonFormulasGroup, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
9
+ import { BuiltInUIPart, ComponentManager, IContextMenuService, IDialogService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, ProgressBar, RectPopup, RibbonFormulasGroup, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
10
10
  import { DocSelectionManagerService } from "@univerjs/docs";
11
- import { CheckMarkIcon, CloseIcon, DatabaseFunctionIcon, DateFunctionIcon, DeleteIcon, EngineeringFunctionIcon, FinancialFunctionIcon, FunctionIcon, IncreaseIcon, InformationFunctionIcon, LogicalFunctionIcon, LookupFunctionIcon, MathFunctionIcon, MoreRightIcon, SelectRangeIcon, StatisticalFunctionIcon, TextFunctionIcon } from "@univerjs/icons";
12
- import { Button, ConfigContext, Dialog, Input, MobileActionRowGroup, MobileSelect, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
11
+ import { CalculationOptionsIcon, CheckMarkIcon, CloseIcon, DatabaseFunctionIcon, DateFunctionIcon, DeleteIcon, EngineeringFunctionIcon, FinancialFunctionIcon, FunctionIcon, IncreaseIcon, InformationFunctionIcon, LogicalFunctionIcon, LookupFunctionIcon, MathFunctionIcon, MoreRightIcon, SelectRangeIcon, StatisticalFunctionIcon, TextFunctionIcon } from "@univerjs/icons";
12
+ import { Button, Checkbox, ConfigContext, Dialog, Input, MobileActionRowGroup, MobileSelect, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
13
13
  import { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
14
14
  import { debounceTime as debounceTime$1 } from "rxjs/operators";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -32,7 +32,7 @@ const SheetOnlyPasteFormulaCommand = {
32
32
  };
33
33
 
34
34
  //#endregion
35
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
35
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
36
36
  function _typeof(o) {
37
37
  "@babel/helpers - typeof";
38
38
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -43,7 +43,7 @@ function _typeof(o) {
43
43
  }
44
44
 
45
45
  //#endregion
46
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
46
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
47
47
  function toPrimitive(t, r) {
48
48
  if ("object" != _typeof(t) || !t) return t;
49
49
  var e = t[Symbol.toPrimitive];
@@ -56,14 +56,14 @@ function toPrimitive(t, r) {
56
56
  }
57
57
 
58
58
  //#endregion
59
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
59
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
60
60
  function toPropertyKey(t) {
61
61
  var i = toPrimitive(t, "string");
62
62
  return "symbol" == _typeof(i) ? i : i + "";
63
63
  }
64
64
 
65
65
  //#endregion
66
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
66
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
67
67
  function _defineProperty(e, r, t) {
68
68
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
69
69
  value: t,
@@ -74,7 +74,7 @@ function _defineProperty(e, r, t) {
74
74
  }
75
75
 
76
76
  //#endregion
77
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
77
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
78
78
  function __decorateParam(paramIndex, decorator) {
79
79
  return function(target, key) {
80
80
  decorator(target, key, paramIndex);
@@ -82,7 +82,7 @@ function __decorateParam(paramIndex, decorator) {
82
82
  }
83
83
 
84
84
  //#endregion
85
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
85
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
86
86
  function __decorate(decorators, target, key, desc) {
87
87
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
88
88
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -726,86 +726,49 @@ function genFormulaRefSelectionStyle(themeService, refColor, id) {
726
726
  }
727
727
 
728
728
  //#endregion
729
- //#region src/controllers/formula-reorder.controller.ts
730
- let FormulaReorderController = class FormulaReorderController extends Disposable {
731
- constructor(_sheetInterceptorService, _univerInstanceService, _formulaDataModel, _lexerTreeBuilder) {
732
- super();
733
- this._sheetInterceptorService = _sheetInterceptorService;
734
- this._univerInstanceService = _univerInstanceService;
735
- this._formulaDataModel = _formulaDataModel;
736
- this._lexerTreeBuilder = _lexerTreeBuilder;
737
- this._initialize();
738
- }
739
- _initialize() {
740
- this.disposeWithMe(this._sheetInterceptorService.interceptCommand({ getMutations: (command) => {
741
- if (command.id === ReorderRangeCommand.id) return this._reorderFormula(command.params);
742
- return {
743
- redos: [],
744
- undos: []
745
- };
746
- } }));
747
- }
748
- _reorderFormula(params) {
749
- const redos = [];
750
- const undos = [];
751
- const { unitId, subUnitId, range, order } = params;
752
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
753
- const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
754
- if (!worksheet) return {
755
- redos,
756
- undos
757
- };
758
- const cellMatrix = worksheet.getCellMatrix();
759
- const redoFormulaMatrix = new ObjectMatrix();
760
- const undoFormulaMatrix = new ObjectMatrix();
761
- let hasFormula = false;
762
- Range.foreach(range, (row, col) => {
763
- let targetRow = row;
764
- if (order.hasOwnProperty(row)) targetRow = order[row];
765
- const targetCell = cellMatrix.getValue(targetRow, col);
766
- if ((targetCell === null || targetCell === void 0 ? void 0 : targetCell.f) || (targetCell === null || targetCell === void 0 ? void 0 : targetCell.si)) {
767
- hasFormula = true;
768
- const formulaString = this._formulaDataModel.getFormulaStringByCell(targetRow, col, subUnitId, unitId);
769
- const shiftedFormula = this._lexerTreeBuilder.moveFormulaRefOffset(formulaString, 0, row - targetRow);
770
- const newCell = Tools.deepClone(targetCell);
771
- newCell.f = shiftedFormula;
772
- newCell.si = null;
773
- redoFormulaMatrix.setValue(row, col, newCell);
774
- } else redoFormulaMatrix.setValue(row, col, targetCell);
775
- undoFormulaMatrix.setValue(row, col, cellMatrix.getValue(row, col));
776
- });
777
- if (!hasFormula) return {
778
- redos,
779
- undos
780
- };
781
- redos.push({
782
- id: SetRangeValuesMutation.id,
783
- params: {
784
- unitId,
785
- subUnitId,
786
- cellValue: redoFormulaMatrix.getMatrix()
787
- }
788
- });
789
- undos.push({
790
- id: SetRangeValuesMutation.id,
791
- params: {
792
- unitId,
793
- subUnitId,
794
- cellValue: undoFormulaMatrix.getMatrix()
795
- }
729
+ //#region src/views/calculation-options/interface.ts
730
+ /**
731
+ * Copyright 2023-present DreamNum Co., Ltd.
732
+ *
733
+ * Licensed under the Apache License, Version 2.0 (the "License");
734
+ * you may not use this file except in compliance with the License.
735
+ * You may obtain a copy of the License at
736
+ *
737
+ * http://www.apache.org/licenses/LICENSE-2.0
738
+ *
739
+ * Unless required by applicable law or agreed to in writing, software
740
+ * distributed under the License is distributed on an "AS IS" BASIS,
741
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
742
+ * See the License for the specific language governing permissions and
743
+ * limitations under the License.
744
+ */
745
+ const CALCULATION_OPTIONS_COMPONENT = "sheets-formula-ui.calculation-options";
746
+ const CALCULATION_OPTIONS_DIALOG = "sheets-formula-ui.calculation-options-dialog";
747
+
748
+ //#endregion
749
+ //#region src/commands/operations/calculation-options.operation.ts
750
+ const CalculationOptionsOperation = {
751
+ id: "sheets-formula-ui.operation.calculation-options",
752
+ type: CommandType.OPERATION,
753
+ handler: (accessor, params) => {
754
+ const instanceService = accessor.get(IUniverInstanceService);
755
+ const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? instanceService.getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET) : instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
756
+ if (!workbook) return false;
757
+ const dialogService = accessor.get(IDialogService);
758
+ dialogService.close(CALCULATION_OPTIONS_DIALOG);
759
+ dialogService.open({
760
+ id: CALCULATION_OPTIONS_DIALOG,
761
+ title: { title: "sheets-formula-ui.calculation.title" },
762
+ children: { label: {
763
+ name: CALCULATION_OPTIONS_COMPONENT,
764
+ props: { unitId: workbook.getUnitId() }
765
+ } },
766
+ width: 420,
767
+ onClose: () => dialogService.close(CALCULATION_OPTIONS_DIALOG)
796
768
  });
797
- return {
798
- redos,
799
- undos
800
- };
769
+ return true;
801
770
  }
802
771
  };
803
- FormulaReorderController = __decorate([
804
- __decorateParam(0, Inject(SheetInterceptorService)),
805
- __decorateParam(1, Inject(IUniverInstanceService)),
806
- __decorateParam(2, Inject(FormulaDataModel)),
807
- __decorateParam(3, Inject(LexerTreeBuilder))
808
- ], FormulaReorderController);
809
772
 
810
773
  //#endregion
811
774
  //#region src/menu/menu.ts
@@ -925,6 +888,16 @@ function PasteFormulaMenuItemFactory(accessor) {
925
888
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
926
889
  };
927
890
  }
891
+ function CalculationOptionsMenuItemFactory(accessor) {
892
+ return {
893
+ id: CalculationOptionsOperation.id,
894
+ type: MenuItemType.BUTTON,
895
+ icon: "CalculationOptionsIcon",
896
+ title: "sheets-formula-ui.calculation.title",
897
+ tooltip: "sheets-formula-ui.calculation.title",
898
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
899
+ };
900
+ }
928
901
 
929
902
  //#endregion
930
903
  //#region src/menu/schema.ts
@@ -985,6 +958,17 @@ const menuSchema = {
985
958
  menuItemFactory: InsertDatabaseFunctionMenuItemFactory
986
959
  }
987
960
  },
961
+ [RibbonFormulasGroup.OTHERS]: { [CalculationOptionsOperation.id]: {
962
+ order: 0,
963
+ gridLayout: {
964
+ row: 1,
965
+ column: 1,
966
+ rowSpan: 2,
967
+ columnSpan: 2,
968
+ showLabel: true
969
+ },
970
+ menuItemFactory: CalculationOptionsMenuItemFactory
971
+ } },
988
972
  [COPY_SPECIAL_MENU_ID]: { [SheetCopyFormulaOnlyCommand.id]: {
989
973
  order: 0,
990
974
  menuItemFactory: CopyFormulaOnlyMenuItemFactory
@@ -998,7 +982,7 @@ const menuSchema = {
998
982
  //#endregion
999
983
  //#region package.json
1000
984
  var name = "@univerjs/sheets-formula-ui";
1001
- var version = "1.0.3";
985
+ var version = "1.1.0";
1002
986
 
1003
987
  //#endregion
1004
988
  //#region src/config/config.ts
@@ -1027,63 +1011,120 @@ const ErrorTypeToMessageMap = {
1027
1011
  [ErrorType.NULL]: "null"
1028
1012
  };
1029
1013
  let FormulaAlertRenderController = class FormulaAlertRenderController extends Disposable {
1030
- constructor(_context, _hoverManagerService, _cellAlertManagerService, _localeService, _formulaDataModel) {
1014
+ constructor(_context, _selectionsService, _cellAlertManagerService, _localeService, _formulaDataModel, _sheetSkeletonService, _sheetSkeletonManagerService, _commandService, _instanceService, _editorBridgeService) {
1031
1015
  super();
1032
1016
  this._context = _context;
1033
- this._hoverManagerService = _hoverManagerService;
1017
+ this._selectionsService = _selectionsService;
1034
1018
  this._cellAlertManagerService = _cellAlertManagerService;
1035
1019
  this._localeService = _localeService;
1036
1020
  this._formulaDataModel = _formulaDataModel;
1037
- this._init();
1038
- }
1039
- _init() {
1040
- this._initCellAlertPopup();
1041
- }
1042
- _initCellAlertPopup() {
1043
- this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cellPos) => {
1044
- if (cellPos) {
1045
- var _this$_formulaDataMod;
1046
- const worksheet = this._context.unit.getActiveSheet();
1047
- if (!worksheet) return this._hideAlert();
1048
- const cellData = worksheet.getCell(cellPos.location.row, cellPos.location.col);
1049
- const arrayFormulaCellData = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaCellData()) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[cellPos.location.unitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[cellPos.location.subUnitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[cellPos.location.row]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[cellPos.location.col];
1050
- if (isICellData(cellData)) {
1051
- var _currentAlert$alert;
1052
- const errorType = extractFormulaError(cellData, !!arrayFormulaCellData);
1053
- if (!errorType) {
1054
- this._hideAlert();
1055
- return;
1056
- }
1057
- const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY);
1058
- const currentLoc = currentAlert === null || currentAlert === void 0 || (_currentAlert$alert = currentAlert.alert) === null || _currentAlert$alert === void 0 ? void 0 : _currentAlert$alert.location;
1059
- if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId) {
1060
- this._hideAlert();
1061
- return;
1062
- }
1063
- this._cellAlertManagerService.showAlert({
1064
- type: CellAlertType.ERROR,
1065
- title: this._localeService.t("sheets-formula-ui.error.title"),
1066
- message: this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[errorType]}`),
1067
- location: cellPos.location,
1068
- width: 200,
1069
- height: 74,
1070
- key: ALERT_KEY
1071
- });
1072
- return;
1021
+ this._sheetSkeletonService = _sheetSkeletonService;
1022
+ this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
1023
+ this._commandService = _commandService;
1024
+ this._instanceService = _instanceService;
1025
+ this._editorBridgeService = _editorBridgeService;
1026
+ _defineProperty(this, "_circularLocations", /* @__PURE__ */ new Set());
1027
+ this.disposeWithMe(this._selectionsService.selectionChanged$.subscribe(() => this._updateAlert()));
1028
+ this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._updateAlert()));
1029
+ this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe(() => this._updateAlert()));
1030
+ this.disposeWithMe(this._editorBridgeService.visible$.subscribe(() => this._updateAlert()));
1031
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1032
+ if (command.id === SetFormulaCalculationNotificationMutation.id) {
1033
+ const params = command.params;
1034
+ if (params.circularReferences) {
1035
+ const locations = new Set(params.circularReferences.filter((cell) => cell.unitId === this._context.unit.getUnitId()).map((cell) => JSON.stringify([
1036
+ cell.sheetId,
1037
+ cell.row,
1038
+ cell.column
1039
+ ])));
1040
+ const changed = locations.size !== this._circularLocations.size || Array.from(locations).some((location) => !this._circularLocations.has(location));
1041
+ this._circularLocations = locations;
1042
+ this._formulaDataModel.setCircularReferences(params.circularReferences);
1043
+ if (changed) this._refreshMarkers();
1044
+ this._updateAlert();
1073
1045
  }
1046
+ } else if (command.id === SetRangeValuesMutation.id || command.id === SetWorkbookCalculationSettingsMutation.id) {
1047
+ if (command.id === SetWorkbookCalculationSettingsMutation.id && command.params.unitId === this._context.unit.getUnitId()) this._refreshMarkers();
1048
+ this._updateAlert();
1074
1049
  }
1075
- this._hideAlert();
1076
1050
  }));
1051
+ this.disposeWithMe(() => this._hideAlert());
1052
+ }
1053
+ _updateAlert() {
1054
+ var _selections, _this$_formulaDataMod, _this$_cellAlertManag;
1055
+ const workbook = this._context.unit;
1056
+ const worksheet = workbook.getActiveSheet();
1057
+ const selection = this._selectionsService.currentSelectionParam;
1058
+ const currentWorkbook = this._instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1059
+ if (!worksheet || (selection === null || selection === void 0 ? void 0 : selection.unitId) !== workbook.getUnitId() || selection.sheetId !== worksheet.getSheetId() || (currentWorkbook === null || currentWorkbook === void 0 ? void 0 : currentWorkbook.getUnitId()) !== workbook.getUnitId() || this._editorBridgeService.isVisible().visible) {
1060
+ this._hideAlert();
1061
+ return;
1062
+ }
1063
+ const selections = this._selectionsService.getCurrentSelections();
1064
+ const primary = selections === null || selections === void 0 || (_selections = selections[selections.length - 1]) === null || _selections === void 0 ? void 0 : _selections.primary;
1065
+ if (!primary) {
1066
+ this._hideAlert();
1067
+ return;
1068
+ }
1069
+ const row = primary.actualRow;
1070
+ const col = primary.actualColumn;
1071
+ const unitId = workbook.getUnitId();
1072
+ const subUnitId = worksheet.getSheetId();
1073
+ const cell = worksheet.getCell(row, col);
1074
+ const circular = !workbook.getCalculationSettings().iterativeCalculation && Boolean((cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si)) && this._formulaDataModel.isCircularReference(unitId, subUnitId, row, col);
1075
+ const arrayCell = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaCellData()) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[unitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[subUnitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[row]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[col];
1076
+ const error = isICellData(cell) ? extractFormulaError(cell, !!arrayCell) : void 0;
1077
+ if (!circular && !error) {
1078
+ this._hideAlert();
1079
+ return;
1080
+ }
1081
+ const message = circular ? this._localeService.t("sheets-formula-ui.calculation.circular") : this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[error]}`);
1082
+ const previous = (_this$_cellAlertManag = this._cellAlertManagerService.currentAlert.get(this._alertKey)) === null || _this$_cellAlertManag === void 0 ? void 0 : _this$_cellAlertManag.alert;
1083
+ if ((previous === null || previous === void 0 ? void 0 : previous.location.row) === row && previous.location.col === col && previous.location.subUnitId === subUnitId && previous.message === message && Boolean(previous.action) === circular) return;
1084
+ this._cellAlertManagerService.showAlert({
1085
+ type: CellAlertType.ERROR,
1086
+ title: this._localeService.t(circular ? "sheets-formula-ui.calculation.circularTitle" : "sheets-formula-ui.error.title"),
1087
+ message,
1088
+ location: {
1089
+ unitId,
1090
+ subUnitId,
1091
+ row,
1092
+ col
1093
+ },
1094
+ width: 240,
1095
+ height: circular ? 124 : 74,
1096
+ key: this._alertKey,
1097
+ action: circular ? {
1098
+ label: this._localeService.t("sheets-formula-ui.calculation.action"),
1099
+ onSelect: () => {
1100
+ this._commandService.syncExecuteCommand(CalculationOptionsOperation.id, { unitId });
1101
+ }
1102
+ } : void 0
1103
+ });
1104
+ }
1105
+ get _alertKey() {
1106
+ return `${ALERT_KEY}:${this._context.unit.getUnitId()}`;
1107
+ }
1108
+ _refreshMarkers() {
1109
+ var _this$_context$mainCo;
1110
+ this._sheetSkeletonService.getSkeletonsByUnitId(this._context.unit.getUnitId()).forEach((skeleton) => skeleton.resetCache());
1111
+ this._sheetSkeletonManagerService.reCalculate();
1112
+ (_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
1077
1113
  }
1078
1114
  _hideAlert() {
1079
- this._cellAlertManagerService.removeAlert(ALERT_KEY);
1115
+ this._cellAlertManagerService.removeAlert(this._alertKey);
1080
1116
  }
1081
1117
  };
1082
1118
  FormulaAlertRenderController = __decorate([
1083
- __decorateParam(1, Inject(HoverManagerService)),
1119
+ __decorateParam(1, Inject(SheetsSelectionsService)),
1084
1120
  __decorateParam(2, Inject(CellAlertManagerService)),
1085
1121
  __decorateParam(3, Inject(LocaleService)),
1086
- __decorateParam(4, Inject(FormulaDataModel))
1122
+ __decorateParam(4, Inject(FormulaDataModel)),
1123
+ __decorateParam(5, Inject(SheetSkeletonService)),
1124
+ __decorateParam(6, Inject(SheetSkeletonManagerService)),
1125
+ __decorateParam(7, ICommandService),
1126
+ __decorateParam(8, IUniverInstanceService),
1127
+ __decorateParam(9, IEditorBridgeService)
1087
1128
  ], FormulaAlertRenderController);
1088
1129
 
1089
1130
  //#endregion
@@ -1581,6 +1622,10 @@ let FormulaEditorShowController = class FormulaEditorShowController extends Disp
1581
1622
  if (range == null) return true;
1582
1623
  const { startRow, startColumn, endRow, endColumn } = range;
1583
1624
  if (rowIndex === row && columnIndex === col) {
1625
+ result = {
1626
+ ...cellInfo,
1627
+ isInArrayFormulaRange: false
1628
+ };
1584
1629
  this._createArrayFormulaRangeShape(range, unitId, subUnitId);
1585
1630
  return false;
1586
1631
  }
@@ -1711,7 +1756,9 @@ let FormulaRenderManagerController = class FormulaRenderManagerController extend
1711
1756
  handler: (cell, pos, next) => {
1712
1757
  var _this$_formulaDataMod;
1713
1758
  const arrayFormulaCellData = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaCellData()) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.unitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.subUnitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.row]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[pos.col];
1714
- if (!extractFormulaError(cell, !!arrayFormulaCellData)) return next(cell);
1759
+ const errorType = extractFormulaError(cell, !!arrayFormulaCellData);
1760
+ const circular = Boolean((cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si)) && !pos.workbook.getCalculationSettings().iterativeCalculation && this._formulaDataModel.isCircularReference(pos.unitId, pos.subUnitId, pos.row, pos.col);
1761
+ if (!errorType && !circular) return next(cell);
1715
1762
  if (!cell) return next(cell);
1716
1763
  if (cell === pos.rawData) cell = { ...pos.rawData };
1717
1764
  cell.markers = {
@@ -1771,15 +1818,17 @@ function registerFormulaEditorRuntimePortal(options) {
1771
1818
  let registeredPortalRoot = null;
1772
1819
  let disposed = false;
1773
1820
  const tryRegister = () => {
1821
+ var _options$editorServic;
1774
1822
  if (disposed) return;
1775
- const portalRoot = resolveFormulaEditorPortalRoot(options.editorId, ownerDocument);
1823
+ const selection = (_options$editorServic = options.editorService.getEditor(options.editorId)) === null || _options$editorServic === void 0 ? void 0 : _options$editorServic.docSelectionRenderService;
1824
+ const portalRoot = (selection === null || selection === void 0 ? void 0 : selection.selectionContainer.isConnected) ? selection.selectionContainer : null;
1776
1825
  if (portalRoot === registeredPortalRoot) return;
1777
1826
  portalRegistration === null || portalRegistration === void 0 || portalRegistration.dispose();
1778
1827
  portalRegistration = void 0;
1779
1828
  registeredPortalRoot = null;
1780
- if (!portalRoot) return;
1829
+ if (!portalRoot || !selection) return;
1781
1830
  registeredPortalRoot = portalRoot;
1782
- portalRegistration = registerFormulaEditorPortalRoot(options, ownerDocument, portalRoot);
1831
+ portalRegistration = registerFormulaEditorPortalRoot(options, selection);
1783
1832
  };
1784
1833
  const scheduleRetry = (remaining) => {
1785
1834
  if (remaining <= 0 || !(view === null || view === void 0 ? void 0 : view.requestAnimationFrame)) return;
@@ -1815,13 +1864,9 @@ function registerFormulaEditorRuntimePortal(options) {
1815
1864
  }));
1816
1865
  return collection;
1817
1866
  }
1818
- function resolveFormulaEditorPortalRoot(editorId, ownerDocument) {
1819
- return ownerDocument.getElementById(`univer-doc-selection-container-${editorId}`) ?? ownerDocument.getElementById(`__editor_${editorId}`);
1820
- }
1821
- function registerFormulaEditorPortalRoot(options, ownerDocument, portalRoot) {
1867
+ function registerFormulaEditorPortalRoot(options, selection) {
1822
1868
  const collection = new DisposableCollection();
1823
- const editorElement = ownerDocument.getElementById(`__editor_${options.editorId}`);
1824
- (editorElement && editorElement !== portalRoot ? [portalRoot, editorElement] : [portalRoot]).forEach((element) => {
1869
+ [selection.selectionContainer, selection.inputElement].forEach((element) => {
1825
1870
  if (options.interactionBoundaryService) collection.add(options.interactionBoundaryService.registerOwnedElement(options.embedId, element));
1826
1871
  if (options.focusCoordinator) collection.add(options.focusCoordinator.registerElement({
1827
1872
  embedId: options.embedId,
@@ -1861,7 +1906,7 @@ function focusFormulaEditor(editorService, editor, offset) {
1861
1906
  if (!editor) return;
1862
1907
  const selections = [...editor.getSelectionRanges()];
1863
1908
  editorService.focus(editor.getEditorId());
1864
- focusFormulaEditorElement(editor);
1909
+ editor.docSelectionRenderService.focus();
1865
1910
  if (editor.docSelectionRenderService.isOnPointerEvent) return;
1866
1911
  if (Tools.isDefine(offset)) editor.setSelectionRanges([{
1867
1912
  startOffset: offset,
@@ -1877,16 +1922,7 @@ function focusFormulaEditor(editorService, editor, offset) {
1877
1922
  }]);
1878
1923
  } else editor.setSelectionRanges(selections);
1879
1924
  }
1880
- function focusFormulaEditorElement(editor) {
1881
- var _editor$editorDOM;
1882
- const editorElement = (((_editor$editorDOM = editor.editorDOM) === null || _editor$editorDOM === void 0 ? void 0 : _editor$editorDOM.ownerDocument) ?? document).getElementById(`__editor_${editor.getEditorId()}`);
1883
- editorElement === null || editorElement === void 0 || editorElement.focus({ preventScroll: true });
1884
- }
1885
- function shouldSkipFormulaEditorMouseUpFocus(_target) {
1886
- return false;
1887
- }
1888
1925
  function shouldRefocusFormulaEditorOnMouseUp(options) {
1889
- if (shouldSkipFormulaEditorMouseUpFocus(options.target)) return false;
1890
1926
  if (options.isPointerSelecting || options.isFocusing) return false;
1891
1927
  return true;
1892
1928
  }
@@ -1974,18 +2010,16 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends BaseSe
1974
2010
  if (evt.button !== 2) state.stopPropagation();
1975
2011
  }));
1976
2012
  listenerDisposables.add(spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 ? void 0 : spreadsheetRowHeader.onPointerDown$.subscribeEvent((evt, state) => {
1977
- if (!this.inRefSelectionMode()) return;
1978
2013
  const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
1979
- if (!skeleton) return;
2014
+ if (!this.inRefSelectionMode() || !skeleton) return;
1980
2015
  const { row } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
1981
2016
  if (checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), row, RANGE_TYPE.ROW)) return;
1982
2017
  this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.ROW, this._getActiveViewport(evt), ScrollTimerType.Y);
1983
2018
  if (evt.button !== 2) state.stopPropagation();
1984
2019
  }));
1985
2020
  listenerDisposables.add(spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 ? void 0 : spreadsheetColumnHeader.onPointerDown$.subscribeEvent((evt, state) => {
1986
- if (!this.inRefSelectionMode()) return;
1987
2021
  const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
1988
- if (!skeleton) return;
2022
+ if (!this.inRefSelectionMode() || !skeleton) return;
1989
2023
  const { column } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
1990
2024
  if (checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), column, RANGE_TYPE.COLUMN)) return;
1991
2025
  this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.COLUMN, this._getActiveViewport(evt), ScrollTimerType.X);
@@ -1993,9 +2027,8 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends BaseSe
1993
2027
  }));
1994
2028
  listenerDisposables.add(spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 ? void 0 : spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent((evt, state) => {
1995
2029
  this._reset();
1996
- if (!this.inRefSelectionMode()) return;
1997
2030
  const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
1998
- if (!skeleton) return;
2031
+ if (!this.inRefSelectionMode() || !skeleton) return;
1999
2032
  const selectionWithStyle = getAllSelection(skeleton);
2000
2033
  this._addSelectionControlByModelData(selectionWithStyle);
2001
2034
  this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
@@ -2161,7 +2194,7 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends BaseSe
2161
2194
  endRow: activeSelectionControl.model.endRow,
2162
2195
  endColumn: activeSelectionControl.model.endColumn
2163
2196
  } : null;
2164
- const remainLastEnable = this._remainLastEnabled && !evt.ctrlKey && !evt.metaKey && !evt.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
2197
+ const remainLastEnable = this._remainLastEnabled && !this._isMultiSelectModifier(evt) && !evt.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
2165
2198
  if (expandByShiftKey && currentCell) this._makeSelectionByTwoCells(currentCell, cursorCellRangeWithRangeType, skeleton, rangeType, activeSelectionControl);
2166
2199
  else if (remainLastEnable && activeSelectionControl) activeSelectionControl.updateRangeBySelectionWithCoord(selectionCellWithCoord);
2167
2200
  else activeSelectionControl = this.newSelectionControl(scene, skeleton, selectionWithStyle);
@@ -2342,6 +2375,7 @@ function useFormulaSelecting(opts) {
2342
2375
  });
2343
2376
  const calculateSelectingType = useEvent(() => {
2344
2377
  var _editor$getSelectionR, _config$dataStream;
2378
+ if (!isFocus) return;
2345
2379
  const currentWorkbook = resolveFormulaSelectionWorkbook(univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET), workbook);
2346
2380
  if (!currentWorkbook) return;
2347
2381
  const currentSheet = currentWorkbook.getActiveSheet();
@@ -2617,7 +2651,7 @@ function useDocHight(_leadingCharacter = "") {
2617
2651
  });
2618
2652
  return [];
2619
2653
  } else {
2620
- const { textRuns, refSelections } = buildTextRuns(descriptionService, colorMap, sequenceNodes);
2654
+ const { textRuns, refSelections } = buildFormulaTextRuns(descriptionService, colorMap, sequenceNodes);
2621
2655
  if (leadingCharacterLength) textRuns.forEach((e) => {
2622
2656
  e.ed = e.ed + leadingCharacterLength;
2623
2657
  e.st = e.st + leadingCharacterLength;
@@ -2662,31 +2696,28 @@ function createHighlightTextRuns(textRuns, leadingCharacterLength) {
2662
2696
  }
2663
2697
  function useColor() {
2664
2698
  const themeService = useDependency(ThemeService);
2665
- const theme = themeService.getCurrentTheme();
2699
+ const canvasColorService = useDependency(ICanvasColorService);
2700
+ const theme = useObservable(themeService.currentTheme$, themeService.getCurrentTheme());
2701
+ const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
2666
2702
  return useMemo(() => {
2667
2703
  return {
2668
- formulaRefColors: [
2669
- themeService.getColorFromTheme("loop-color.1"),
2670
- themeService.getColorFromTheme("loop-color.2"),
2671
- themeService.getColorFromTheme("loop-color.3"),
2672
- themeService.getColorFromTheme("loop-color.4"),
2673
- themeService.getColorFromTheme("loop-color.5"),
2674
- themeService.getColorFromTheme("loop-color.6"),
2675
- themeService.getColorFromTheme("loop-color.7"),
2676
- themeService.getColorFromTheme("loop-color.8"),
2677
- themeService.getColorFromTheme("loop-color.9"),
2678
- themeService.getColorFromTheme("loop-color.10"),
2679
- themeService.getColorFromTheme("loop-color.11"),
2680
- themeService.getColorFromTheme("loop-color.12")
2681
- ].map((color) => themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color),
2704
+ formulaRefColors: Object.values(theme["loop-color"]).map((color) => {
2705
+ const resolvedColor = themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color;
2706
+ if (!darkMode) return resolvedColor;
2707
+ let referenceColor = new ColorKit(resolvedColor);
2708
+ while (referenceColor.toHsl().l > 0 && ColorKit.getContrastRatio(canvasColorService.getRenderColor(referenceColor.toHexString()), theme.gray[800]) < 4.5) referenceColor = referenceColor.darken(5);
2709
+ return referenceColor.toHexString();
2710
+ }),
2682
2711
  numberColor: themeService.getColorFromTheme("blue.700"),
2683
2712
  stringColor: themeService.getColorFromTheme("jiqing.800"),
2684
2713
  plainTextColor: themeService.getColorFromTheme("gray.1000")
2685
2714
  };
2686
- }, [theme]);
2687
- }
2688
- function buildTextRuns(descriptionService, colorMap, sequenceNodes) {
2689
- return buildFormulaTextRuns(descriptionService, colorMap, sequenceNodes);
2715
+ }, [
2716
+ theme,
2717
+ darkMode,
2718
+ themeService,
2719
+ canvasColorService
2720
+ ]);
2690
2721
  }
2691
2722
 
2692
2723
  //#endregion
@@ -2734,8 +2765,8 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
2734
2765
  if (keycode === KeyCode.ARROW_DOWN) direction = Direction.DOWN;
2735
2766
  else if (keycode === KeyCode.ARROW_UP) direction = Direction.UP;
2736
2767
  else if (keycode === KeyCode.ARROW_RIGHT) direction = Direction.RIGHT;
2737
- if (metaKey === MetaKeys.SHIFT) commandService.executeCommand(MoveSelectionOperation.id, { direction });
2738
- else commandService.executeCommand(MoveCursorOperation.id, { direction });
2768
+ if (metaKey === MetaKeys.SHIFT) return commandService.syncExecuteCommand(MoveSelectionOperation.id, { direction });
2769
+ else return commandService.syncExecuteCommand(MoveCursorOperation.id, { direction });
2739
2770
  };
2740
2771
  const handleKeycode = (keycode, metaKey) => {
2741
2772
  let direction = Direction.DOWN;
@@ -2745,35 +2776,38 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
2745
2776
  else if (keycode === KeyCode.ARROW_RIGHT) direction = Direction.RIGHT;
2746
2777
  if (shouldMoveSelectionRef.current) {
2747
2778
  var _getRefSelectionCount;
2748
- const fromCurrentSelection = shouldMoveFormulaSelectionFromCurrentSelection(shouldMoveSelectionRef.current, ((_getRefSelectionCount = getRefSelectionCountRef.current) === null || _getRefSelectionCount === void 0 ? void 0 : _getRefSelectionCount.call(getRefSelectionCountRef)) ?? 0);
2749
- if (metaKey === MetaKeys.CTRL_COMMAND) commandService.executeCommand(MoveSelectionCommand.id, {
2779
+ const refSelectionCount = ((_getRefSelectionCount = getRefSelectionCountRef.current) === null || _getRefSelectionCount === void 0 ? void 0 : _getRefSelectionCount.call(getRefSelectionCountRef)) ?? 0;
2780
+ const fromCurrentSelection = shouldMoveFormulaSelectionFromCurrentSelection(shouldMoveSelectionRef.current, refSelectionCount);
2781
+ if (metaKey === MetaKeys.CTRL_COMMAND) return commandService.executeCommand(MoveSelectionCommand.id, {
2750
2782
  direction,
2751
2783
  jumpOver: JumpOver.moveGap,
2752
2784
  extra: "formula-editor",
2753
2785
  fromCurrentSelection
2754
2786
  });
2755
- else if (metaKey === MetaKeys.SHIFT) commandService.executeCommand(ExpandSelectionCommand.id, {
2787
+ else if (metaKey === MetaKeys.SHIFT) return commandService.executeCommand(ExpandSelectionCommand.id, {
2756
2788
  direction,
2757
- extra: "formula-editor"
2789
+ extra: "formula-editor",
2790
+ fromCurrentSelection: refSelectionCount === 0
2758
2791
  });
2759
- else if (metaKey === (MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT)) commandService.executeCommand(ExpandSelectionCommand.id, {
2792
+ else if (metaKey === (MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT)) return commandService.executeCommand(ExpandSelectionCommand.id, {
2760
2793
  direction,
2761
2794
  jumpOver: JumpOver.moveGap,
2762
- extra: "formula-editor"
2795
+ extra: "formula-editor",
2796
+ fromCurrentSelection: refSelectionCount === 0
2763
2797
  });
2764
- else commandService.executeCommand(MoveSelectionCommand.id, {
2798
+ else return commandService.executeCommand(MoveSelectionCommand.id, {
2765
2799
  direction,
2766
2800
  extra: "formula-editor",
2767
2801
  fromCurrentSelection
2768
2802
  });
2769
- } else handleMoveInEditor(keycode, metaKey);
2803
+ } else return handleMoveInEditor(keycode, metaKey);
2770
2804
  };
2771
2805
  d.add(commandService.registerCommand({
2772
2806
  id: operationId,
2773
2807
  type: CommandType.OPERATION,
2774
2808
  handler(_event, params) {
2775
2809
  const { keyCode, metaKey } = params;
2776
- handleKeycode(keyCode, metaKey);
2810
+ return handleKeycode(keyCode, metaKey);
2777
2811
  }
2778
2812
  }));
2779
2813
  [
@@ -2833,7 +2867,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
2833
2867
  return {
2834
2868
  id: operationId,
2835
2869
  binding: metaKey ? keyCode | metaKey : keyCode,
2836
- preconditions: shouldHandleShortcut,
2870
+ preconditions: () => shouldHandleShortcut() && (!(metaKey && metaKey & MetaKeys.CTRL_COMMAND) || Boolean(shouldMoveSelectionRef.current)),
2837
2871
  priority: 900,
2838
2872
  staticParameters: {
2839
2873
  eventType: DeviceInputEventType.Keyboard,
@@ -3751,12 +3785,11 @@ function MobileFunctionPanel(props) {
3751
3785
  }) : /* @__PURE__ */ jsxs(Fragment, { children: [
3752
3786
  /* @__PURE__ */ jsx("div", {
3753
3787
  className: "univer-px-4 univer-pb-3",
3754
- children: /* @__PURE__ */ jsx("input", {
3788
+ children: /* @__PURE__ */ jsx(Input, {
3755
3789
  value: query,
3756
3790
  "aria-label": copy.search,
3757
3791
  placeholder: copy.search,
3758
- className: "univer-box-border univer-h-11 univer-w-full univer-rounded-xl univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-50 univer-px-4 univer-text-base univer-outline-none focus:univer-border-primary-500 dark:!univer-border-gray-700 dark:!univer-bg-gray-800 dark:!univer-text-gray-0",
3759
- onChange: (event) => setQuery(event.target.value)
3792
+ onChange: setQuery
3760
3793
  })
3761
3794
  }),
3762
3795
  !query && /* @__PURE__ */ jsx("div", {
@@ -4391,6 +4424,7 @@ const MobileFormulaEditor = forwardRef((props, ref) => {
4391
4424
  element: formulaEditorContainer
4392
4425
  }));
4393
4426
  collection.add(registerFormulaEditorRuntimePortal({
4427
+ editorService,
4394
4428
  embedId: scope.embedId,
4395
4429
  editorId,
4396
4430
  ownerDocument: formulaEditorContainer.ownerDocument,
@@ -4400,6 +4434,7 @@ const MobileFormulaEditor = forwardRef((props, ref) => {
4400
4434
  return () => collection.dispose();
4401
4435
  }, [
4402
4436
  editorId,
4437
+ editorService,
4403
4438
  injector,
4404
4439
  isFocus
4405
4440
  ]);
@@ -4543,10 +4578,9 @@ const MobileFormulaEditor = forwardRef((props, ref) => {
4543
4578
  contextService.setContextValue(MOBILE_FORMULA_FUNCTION_PANEL_OPEN, false);
4544
4579
  });
4545
4580
  };
4546
- const handleMouseUp = (event) => {
4581
+ const handleMouseUp = () => {
4547
4582
  if (hasActiveFormulaEmbedInteraction(formulaEditorContainerRef.current)) return;
4548
4583
  if (!shouldRefocusFormulaEditorOnMouseUp({
4549
- target: event.target,
4550
4584
  isFocusing,
4551
4585
  isPointerSelecting: docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isOnPointerEvent
4552
4586
  })) return;
@@ -5212,6 +5246,7 @@ function RangeSelector(props) {
5212
5246
  const { className, onVerify, selectorRef, unitId, subUnitId, maxRangeCount, supportAcrossSheet, keepSheetReference, autoFocus, onChange, onRangeSelectorDialogVisibleChange, onClickOutside, onFocusChange, forceShowDialogWhenSelectionChanged, hideEditor, resetRange, onClose } = props;
5213
5247
  const [focusing, setFocusing] = useState(autoFocus ?? false);
5214
5248
  const [popupVisible, setPopupVisible] = useState(false);
5249
+ const [tooltipVisible, setTooltipVisible] = useState(false);
5215
5250
  const [rangeSelectorRanges, setRangeSelectorRanges] = useState([]);
5216
5251
  const editorService = useDependency(IEditorService);
5217
5252
  const { sequenceNodes } = useRangesHighlight(editor, focusing, unitId, subUnitId);
@@ -5225,6 +5260,7 @@ function RangeSelector(props) {
5225
5260
  });
5226
5261
  const handleOpenModal = useEvent(() => {
5227
5262
  var _editor$getDocumentDa;
5263
+ setTooltipVisible(false);
5228
5264
  blurEditor();
5229
5265
  setRangeSelectorRanges(parseRanges((editor === null || editor === void 0 || (_editor$getDocumentDa = editor.getDocumentDataModel()) === null || _editor$getDocumentDa === void 0 ? void 0 : _editor$getDocumentDa.getPlainText()) ?? ""));
5230
5266
  setPopupVisible(true);
@@ -5241,6 +5277,7 @@ function RangeSelector(props) {
5241
5277
  blur: blurEditor,
5242
5278
  verify: () => verifyRange(sequenceNodesRef.current),
5243
5279
  showDialog: (ranges) => {
5280
+ setTooltipVisible(false);
5244
5281
  blurEditor();
5245
5282
  setRangeSelectorRanges(ranges);
5246
5283
  setPopupVisible(true);
@@ -5296,6 +5333,8 @@ function RangeSelector(props) {
5296
5333
  icon: /* @__PURE__ */ jsx(Tooltip, {
5297
5334
  title: localeService.t("sheets-formula-ui.rangeSelector.buttonTooltip"),
5298
5335
  placement: "bottom",
5336
+ visible: tooltipVisible && !popupVisible,
5337
+ onVisibleChange: (visible) => setTooltipVisible(visible && !popupVisible),
5299
5338
  children: /* @__PURE__ */ jsx(SelectRangeIcon, {
5300
5339
  className: "-univer-translate-y-0.5 univer-cursor-pointer dark:!univer-text-gray-300",
5301
5340
  onClick: handleOpenModal
@@ -5327,6 +5366,7 @@ function RangeSelector(props) {
5327
5366
  keepSheetReference,
5328
5367
  onShowBySelection: (ranges) => {
5329
5368
  if (focusing || forceShowDialogWhenSelectionChanged) {
5369
+ setTooltipVisible(false);
5330
5370
  setRangeSelectorRanges(ranges);
5331
5371
  setPopupVisible(true);
5332
5372
  return false;
@@ -5640,6 +5680,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
5640
5680
  }
5641
5681
  _registerIcons() {
5642
5682
  this.disposeWithMe(this._iconManager.register({
5683
+ CalculationOptionsIcon,
5643
5684
  DatabaseFunctionIcon,
5644
5685
  DateFunctionIcon,
5645
5686
  EngineeringFunctionIcon,
@@ -5740,6 +5781,7 @@ let FormulaUIController = class FormulaUIController extends Disposable {
5740
5781
  SheetOnlyPasteFormulaCommand,
5741
5782
  InsertFunctionOperation,
5742
5783
  MoreFunctionsOperation,
5784
+ CalculationOptionsOperation,
5743
5785
  SearchFunctionOperation,
5744
5786
  HelpFunctionOperation,
5745
5787
  ReferenceAbsoluteOperation
@@ -6146,7 +6188,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
6146
6188
  [FormulaClipboardController],
6147
6189
  [FormulaEditorShowController],
6148
6190
  [FormulaRenderManagerController],
6149
- [FormulaReorderController],
6150
6191
  [ImageFormulaRenderController]
6151
6192
  ]);
6152
6193
  this._initUIPart();
@@ -6168,9 +6209,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
6168
6209
  [ImageFormulaRenderController]
6169
6210
  ]);
6170
6211
  }
6171
- onSteady() {
6172
- this._injector.get(FormulaReorderController);
6173
- }
6174
6212
  _initUIPart() {
6175
6213
  this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(MobileGlobalRangeSelector, this._injector)));
6176
6214
  }
@@ -6187,6 +6225,125 @@ UniverSheetsFormulaMobileUIPlugin = __decorate([
6187
6225
  __decorateParam(4, IUIPartsService)
6188
6226
  ], UniverSheetsFormulaMobileUIPlugin);
6189
6227
 
6228
+ //#endregion
6229
+ //#region src/views/calculation-options/CalculationOptions.tsx
6230
+ function CalculationOptions({ unitId }) {
6231
+ var _permissionService$ge;
6232
+ const instanceService = useDependency(IUniverInstanceService);
6233
+ const commandService = useDependency(ICommandService);
6234
+ const permissionService = useDependency(IPermissionService);
6235
+ const dialogService = useDependency(IDialogService);
6236
+ const localeService = useDependency(LocaleService);
6237
+ const workbook = instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
6238
+ const permissionId = new WorkbookEditablePermission(unitId).id;
6239
+ const permission = useObservable(permissionService.getPermissionPoint$(permissionId), void 0, false);
6240
+ const readOnly = !workbook || ((permission === null || permission === void 0 ? void 0 : permission.value) ?? ((_permissionService$ge = permissionService.getPermissionPoint(permissionId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value)) === false;
6241
+ const [draft, setDraft] = useState(() => {
6242
+ const settings = normalizeWorkbookCalculationSettings(workbook === null || workbook === void 0 ? void 0 : workbook.getCalculationSettings());
6243
+ return {
6244
+ enabled: settings.iterativeCalculation,
6245
+ count: String(settings.maxIterations),
6246
+ change: String(settings.maxChange)
6247
+ };
6248
+ });
6249
+ const [submitted, setSubmitted] = useState(false);
6250
+ const settings = {
6251
+ iterativeCalculation: draft.enabled,
6252
+ maxIterations: draft.count.trim() ? Number(draft.count) : NaN,
6253
+ maxChange: draft.change.trim() ? Number(draft.change) : NaN
6254
+ };
6255
+ const validCount = Number.isInteger(settings.maxIterations) && settings.maxIterations >= 1 && settings.maxIterations <= MAX_ITERATION_COUNT;
6256
+ const validChange = Number.isFinite(settings.maxChange) && settings.maxChange > 0;
6257
+ const showCountError = submitted && draft.enabled && !validCount;
6258
+ const showChangeError = submitted && draft.enabled && !validChange;
6259
+ function close() {
6260
+ dialogService.close(CALCULATION_OPTIONS_DIALOG);
6261
+ }
6262
+ function submit() {
6263
+ if (readOnly) return;
6264
+ setSubmitted(true);
6265
+ if (draft.enabled && (!validCount || !validChange)) return;
6266
+ const nextSettings = draft.enabled ? settings : {
6267
+ ...workbook.getCalculationSettings(),
6268
+ iterativeCalculation: false
6269
+ };
6270
+ if (commandService.syncExecuteCommand(SetWorkbookCalculationSettingsCommand.id, {
6271
+ unitId,
6272
+ settings: nextSettings
6273
+ })) close();
6274
+ }
6275
+ return /* @__PURE__ */ jsxs("div", {
6276
+ className: "univer-flex univer-flex-col univer-gap-4 univer-p-4",
6277
+ children: [
6278
+ /* @__PURE__ */ jsx("p", {
6279
+ className: "univer-m-0 univer-text-sm",
6280
+ children: localeService.t("sheets-formula-ui.calculation.workbook")
6281
+ }),
6282
+ /* @__PURE__ */ jsx(Checkbox, {
6283
+ checked: draft.enabled,
6284
+ disabled: readOnly,
6285
+ onChange: (enabled) => setDraft((previous) => ({
6286
+ ...previous,
6287
+ enabled: Boolean(enabled)
6288
+ })),
6289
+ children: localeService.t("sheets-formula-ui.calculation.enable")
6290
+ }),
6291
+ /* @__PURE__ */ jsxs("label", {
6292
+ className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
6293
+ children: [
6294
+ localeService.t("sheets-formula-ui.calculation.iterations", String(MAX_ITERATION_COUNT)),
6295
+ /* @__PURE__ */ jsx(Input, {
6296
+ value: draft.count,
6297
+ inputClass: showCountError ? "univer-border-red-500" : void 0,
6298
+ disabled: readOnly || !draft.enabled,
6299
+ onChange: (count) => setDraft((previous) => ({
6300
+ ...previous,
6301
+ count
6302
+ }))
6303
+ }),
6304
+ showCountError && /* @__PURE__ */ jsx("span", {
6305
+ role: "alert",
6306
+ className: "univer-text-red-500",
6307
+ children: localeService.t("sheets-formula-ui.calculation.invalidIterations", String(MAX_ITERATION_COUNT))
6308
+ })
6309
+ ]
6310
+ }),
6311
+ /* @__PURE__ */ jsxs("label", {
6312
+ className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
6313
+ children: [
6314
+ localeService.t("sheets-formula-ui.calculation.change"),
6315
+ /* @__PURE__ */ jsx(Input, {
6316
+ value: draft.change,
6317
+ inputClass: showChangeError ? "univer-border-red-500" : void 0,
6318
+ disabled: readOnly || !draft.enabled,
6319
+ onChange: (change) => setDraft((previous) => ({
6320
+ ...previous,
6321
+ change
6322
+ }))
6323
+ }),
6324
+ showChangeError && /* @__PURE__ */ jsx("span", {
6325
+ role: "alert",
6326
+ className: "univer-text-red-500",
6327
+ children: localeService.t("sheets-formula-ui.calculation.invalidChange")
6328
+ })
6329
+ ]
6330
+ }),
6331
+ /* @__PURE__ */ jsxs("div", {
6332
+ className: "univer-flex univer-justify-end univer-gap-2",
6333
+ children: [/* @__PURE__ */ jsx(Button, {
6334
+ onClick: close,
6335
+ children: localeService.t("sheets-formula-ui.calculation.cancel")
6336
+ }), /* @__PURE__ */ jsx(Button, {
6337
+ variant: "primary",
6338
+ disabled: readOnly,
6339
+ onClick: submit,
6340
+ children: localeService.t("sheets-formula-ui.calculation.confirm")
6341
+ })]
6342
+ })
6343
+ ]
6344
+ });
6345
+ }
6346
+
6190
6347
  //#endregion
6191
6348
  //#region src/views/formula-editor/hooks/use-formula-describe.ts
6192
6349
  const useFormulaDescribe = (isNeed, formulaText, editor) => {
@@ -6426,10 +6583,6 @@ function SearchFunctionFactory(props, ref) {
6426
6583
  if (!isEnableMouseEnterOrOut.current) return;
6427
6584
  setActive(index);
6428
6585
  }
6429
- function handleLiMouseLeave() {
6430
- if (!isEnableMouseEnterOrOut.current) return;
6431
- setActive(-1);
6432
- }
6433
6586
  useEffect(() => {
6434
6587
  if (!searchList.length) return;
6435
6588
  const operationId = `sheet.formula-embedding-editor.search_function.${editorId}`;
@@ -6454,7 +6607,7 @@ function SearchFunctionFactory(props, ref) {
6454
6607
  case KeyCode.TAB:
6455
6608
  case KeyCode.ENTER: {
6456
6609
  const item = searchList[active];
6457
- handleFunctionSelect(item.name, item.functionType);
6610
+ if (item) handleFunctionSelect(item.name, item.functionType);
6458
6611
  break;
6459
6612
  }
6460
6613
  case KeyCode.ESC:
@@ -6536,7 +6689,6 @@ function SearchFunctionFactory(props, ref) {
6536
6689
  children: searchList.map((item, index) => /* @__PURE__ */ jsxs("li", {
6537
6690
  className: clsx("univer-box-border univer-cursor-pointer univer-rounded univer-px-2 univer-py-1 univer-text-gray-900 univer-transition-colors dark:!univer-text-gray-0", { "univer-bg-gray-200 dark:!univer-bg-gray-600": active === index }),
6538
6691
  onMouseEnter: () => handleLiMouseEnter(index),
6539
- onMouseLeave: handleLiMouseLeave,
6540
6692
  onMouseMove: debounceResetMouseState,
6541
6693
  onClick: () => {
6542
6694
  handleFunctionSelect(item.name, item.functionType);
@@ -6763,6 +6915,7 @@ const FormulaEditor = forwardRef((props, ref) => {
6763
6915
  element: formulaEditorContainer
6764
6916
  }));
6765
6917
  collection.add(registerFormulaEditorRuntimePortal({
6918
+ editorService,
6766
6919
  embedId: scope.embedId,
6767
6920
  editorId,
6768
6921
  ownerDocument: formulaEditorContainer.ownerDocument,
@@ -6772,6 +6925,7 @@ const FormulaEditor = forwardRef((props, ref) => {
6772
6925
  return () => collection.dispose();
6773
6926
  }, [
6774
6927
  editorId,
6928
+ editorService,
6775
6929
  injector,
6776
6930
  isFocus
6777
6931
  ]);
@@ -6865,10 +7019,9 @@ const FormulaEditor = forwardRef((props, ref) => {
6865
7019
  highlight(`=${res.text}`);
6866
7020
  }
6867
7021
  };
6868
- const handleMouseUp = (event) => {
7022
+ const handleMouseUp = () => {
6869
7023
  if (hasActiveFormulaEmbedInteraction(formulaEditorContainerRef.current)) return;
6870
7024
  if (!shouldRefocusFormulaEditorOnMouseUp({
6871
- target: event.target,
6872
7025
  isFocusing,
6873
7026
  isPointerSelecting: docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isOnPointerEvent
6874
7027
  })) return;
@@ -6941,6 +7094,7 @@ let ComponentsController = class ComponentsController extends Disposable {
6941
7094
  }
6942
7095
  _registerIcons() {
6943
7096
  this.disposeWithMe(this._iconManager.register({
7097
+ CalculationOptionsIcon,
6944
7098
  DatabaseFunctionIcon,
6945
7099
  DateFunctionIcon,
6946
7100
  EngineeringFunctionIcon,
@@ -6958,6 +7112,7 @@ let ComponentsController = class ComponentsController extends Disposable {
6958
7112
  this.disposeWithMe(this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions));
6959
7113
  this.disposeWithMe(this._componentManager.register(RANGE_SELECTOR_COMPONENT_KEY, RangeSelector));
6960
7114
  this.disposeWithMe(this._componentManager.register(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, FormulaEditor));
7115
+ this.disposeWithMe(this._componentManager.register(CALCULATION_OPTIONS_COMPONENT, CalculationOptions));
6961
7116
  }
6962
7117
  };
6963
7118
  ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
@@ -7041,7 +7196,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends Plug
7041
7196
  [FormulaClipboardController],
7042
7197
  [FormulaEditorShowController],
7043
7198
  [FormulaRenderManagerController],
7044
- [FormulaReorderController],
7045
7199
  [ImageFormulaRenderController]
7046
7200
  ]);
7047
7201
  this._initUIPart();
@@ -7063,9 +7217,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends Plug
7063
7217
  [ImageFormulaRenderController]
7064
7218
  ]);
7065
7219
  }
7066
- onSteady() {
7067
- this._injector.get(FormulaReorderController);
7068
- }
7069
7220
  _initUIPart() {
7070
7221
  this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(GlobalRangeSelector, this._injector)));
7071
7222
  }
@@ -7083,4 +7234,4 @@ UniverSheetsFormulaUIPlugin = __decorate([
7083
7234
  ], UniverSheetsFormulaUIPlugin);
7084
7235
 
7085
7236
  //#endregion
7086
- export { FORMULA_PROMPT_ACTIVATED, FormulaEditor, FormulaReorderController, GlobalRangeSelectorService, HelpFunctionOperation, InsertFunctionOperation, MobileRangeSelector, MoreFunctionsOperation, RangeSelector, RefSelectionsRenderService, ReferenceAbsoluteOperation, SearchFunctionOperation, SheetCopyFormulaOnlyCommand, SheetOnlyPasteFormulaCommand, menuSchema as SheetsFormulaUIMenuSchema, UniverSheetsFormulaMobileUIPlugin, UniverSheetsFormulaUIPlugin, genFormulaRefSelectionStyle };
7237
+ export { FORMULA_PROMPT_ACTIVATED, FormulaEditor, GlobalRangeSelectorService, HelpFunctionOperation, InsertFunctionOperation, MORE_FUNCTIONS_COMPONENT, MobileRangeSelector, MoreFunctionsOperation, RangeSelector, RefSelectionsRenderService, ReferenceAbsoluteOperation, SearchFunctionOperation, SheetCopyFormulaOnlyCommand, SheetOnlyPasteFormulaCommand, menuSchema as SheetsFormulaUIMenuSchema, UniverSheetsFormulaMobileUIPlugin, UniverSheetsFormulaUIPlugin, genFormulaRefSelectionStyle };