@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.
- package/lib/cjs/index.js +361 -215
- package/lib/cjs/locale/ar-SA.js +14 -0
- package/lib/cjs/locale/ca-ES.js +14 -0
- package/lib/cjs/locale/de-DE.js +14 -0
- package/lib/cjs/locale/en-US.js +14 -0
- package/lib/cjs/locale/es-ES.js +14 -0
- package/lib/cjs/locale/fa-IR.js +14 -0
- package/lib/cjs/locale/fr-FR.js +14 -0
- package/lib/cjs/locale/id-ID.js +14 -0
- package/lib/cjs/locale/it-IT.js +14 -0
- package/lib/cjs/locale/ja-JP.js +14 -0
- package/lib/cjs/locale/ko-KR.js +14 -0
- package/lib/cjs/locale/pl-PL.js +14 -0
- package/lib/cjs/locale/pt-BR.js +14 -0
- package/lib/cjs/locale/ru-RU.js +14 -0
- package/lib/cjs/locale/sk-SK.js +14 -0
- package/lib/cjs/locale/vi-VN.js +14 -0
- package/lib/cjs/locale/zh-CN.js +14 -0
- package/lib/cjs/locale/zh-HK.js +14 -0
- package/lib/cjs/locale/zh-TW.js +14 -0
- package/lib/es/index.js +366 -215
- package/lib/es/locale/ar-SA.js +14 -0
- package/lib/es/locale/ca-ES.js +14 -0
- package/lib/es/locale/de-DE.js +14 -0
- package/lib/es/locale/en-US.js +14 -0
- package/lib/es/locale/es-ES.js +14 -0
- package/lib/es/locale/fa-IR.js +14 -0
- package/lib/es/locale/fr-FR.js +14 -0
- package/lib/es/locale/id-ID.js +14 -0
- package/lib/es/locale/it-IT.js +14 -0
- package/lib/es/locale/ja-JP.js +14 -0
- package/lib/es/locale/ko-KR.js +14 -0
- package/lib/es/locale/pl-PL.js +14 -0
- package/lib/es/locale/pt-BR.js +14 -0
- package/lib/es/locale/ru-RU.js +14 -0
- package/lib/es/locale/sk-SK.js +14 -0
- package/lib/es/locale/vi-VN.js +14 -0
- package/lib/es/locale/zh-CN.js +14 -0
- package/lib/es/locale/zh-HK.js +14 -0
- package/lib/es/locale/zh-TW.js +14 -0
- package/lib/index.css +4 -20
- package/lib/index.js +366 -215
- package/lib/locale/ar-SA.js +14 -0
- package/lib/locale/ca-ES.js +14 -0
- package/lib/locale/de-DE.js +14 -0
- package/lib/locale/en-US.js +14 -0
- package/lib/locale/es-ES.js +14 -0
- package/lib/locale/fa-IR.js +14 -0
- package/lib/locale/fr-FR.js +14 -0
- package/lib/locale/id-ID.js +14 -0
- package/lib/locale/it-IT.js +14 -0
- package/lib/locale/ja-JP.js +14 -0
- package/lib/locale/ko-KR.js +14 -0
- package/lib/locale/pl-PL.js +14 -0
- package/lib/locale/pt-BR.js +14 -0
- package/lib/locale/ru-RU.js +14 -0
- package/lib/locale/sk-SK.js +14 -0
- package/lib/locale/vi-VN.js +14 -0
- package/lib/locale/zh-CN.js +14 -0
- package/lib/locale/zh-HK.js +14 -0
- package/lib/locale/zh-TW.js +14 -0
- package/lib/types/commands/operations/calculation-options.operation.d.ts +19 -0
- package/lib/types/controllers/formula-alert-render.controller.d.ts +14 -6
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +14 -0
- package/lib/types/menu/menu.d.ts +1 -0
- package/lib/types/mobile-plugin.d.ts +0 -1
- package/lib/types/plugin.d.ts +0 -1
- package/lib/types/views/calculation-options/CalculationOptions.d.ts +19 -0
- package/lib/types/views/calculation-options/interface.d.ts +17 -0
- package/lib/types/views/formula-editor/formula-embed-integration.service.d.ts +2 -0
- package/lib/types/views/formula-editor/hooks/use-focus.d.ts +1 -5
- package/lib/types/views/formula-editor/hooks/use-highlight.d.ts +2 -8
- package/lib/umd/index.js +5 -5
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +15 -15
- package/lib/types/controllers/formula-reorder.controller.d.ts +0 -27
package/lib/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
37
37
|
function _typeof(o) {
|
|
38
38
|
"@babel/helpers - typeof";
|
|
39
39
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -44,7 +44,7 @@ function _typeof(o) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
48
48
|
function toPrimitive(t, r) {
|
|
49
49
|
if ("object" != _typeof(t) || !t) return t;
|
|
50
50
|
var e = t[Symbol.toPrimitive];
|
|
@@ -57,14 +57,14 @@ function toPrimitive(t, r) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
61
61
|
function toPropertyKey(t) {
|
|
62
62
|
var i = toPrimitive(t, "string");
|
|
63
63
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region \0@oxc-project+runtime@0.
|
|
67
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
68
68
|
function _defineProperty(e, r, t) {
|
|
69
69
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
70
70
|
value: t,
|
|
@@ -75,7 +75,7 @@ function _defineProperty(e, r, t) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region \0@oxc-project+runtime@0.
|
|
78
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
79
79
|
function __decorateParam(paramIndex, decorator) {
|
|
80
80
|
return function(target, key) {
|
|
81
81
|
decorator(target, key, paramIndex);
|
|
@@ -83,7 +83,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
//#endregion
|
|
86
|
-
//#region \0@oxc-project+runtime@0.
|
|
86
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
87
87
|
function __decorate(decorators, target, key, desc) {
|
|
88
88
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
89
89
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -727,86 +727,49 @@ function genFormulaRefSelectionStyle(themeService, refColor, id) {
|
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
//#endregion
|
|
730
|
-
//#region src/
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
const formulaString = this._formulaDataModel.getFormulaStringByCell(targetRow, col, subUnitId, unitId);
|
|
770
|
-
const shiftedFormula = this._lexerTreeBuilder.moveFormulaRefOffset(formulaString, 0, row - targetRow);
|
|
771
|
-
const newCell = _univerjs_core.Tools.deepClone(targetCell);
|
|
772
|
-
newCell.f = shiftedFormula;
|
|
773
|
-
newCell.si = null;
|
|
774
|
-
redoFormulaMatrix.setValue(row, col, newCell);
|
|
775
|
-
} else redoFormulaMatrix.setValue(row, col, targetCell);
|
|
776
|
-
undoFormulaMatrix.setValue(row, col, cellMatrix.getValue(row, col));
|
|
777
|
-
});
|
|
778
|
-
if (!hasFormula) return {
|
|
779
|
-
redos,
|
|
780
|
-
undos
|
|
781
|
-
};
|
|
782
|
-
redos.push({
|
|
783
|
-
id: _univerjs_sheets.SetRangeValuesMutation.id,
|
|
784
|
-
params: {
|
|
785
|
-
unitId,
|
|
786
|
-
subUnitId,
|
|
787
|
-
cellValue: redoFormulaMatrix.getMatrix()
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
undos.push({
|
|
791
|
-
id: _univerjs_sheets.SetRangeValuesMutation.id,
|
|
792
|
-
params: {
|
|
793
|
-
unitId,
|
|
794
|
-
subUnitId,
|
|
795
|
-
cellValue: undoFormulaMatrix.getMatrix()
|
|
796
|
-
}
|
|
730
|
+
//#region src/views/calculation-options/interface.ts
|
|
731
|
+
/**
|
|
732
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
733
|
+
*
|
|
734
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
735
|
+
* you may not use this file except in compliance with the License.
|
|
736
|
+
* You may obtain a copy of the License at
|
|
737
|
+
*
|
|
738
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
739
|
+
*
|
|
740
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
741
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
742
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
743
|
+
* See the License for the specific language governing permissions and
|
|
744
|
+
* limitations under the License.
|
|
745
|
+
*/
|
|
746
|
+
const CALCULATION_OPTIONS_COMPONENT = "sheets-formula-ui.calculation-options";
|
|
747
|
+
const CALCULATION_OPTIONS_DIALOG = "sheets-formula-ui.calculation-options-dialog";
|
|
748
|
+
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/commands/operations/calculation-options.operation.ts
|
|
751
|
+
const CalculationOptionsOperation = {
|
|
752
|
+
id: "sheets-formula-ui.operation.calculation-options",
|
|
753
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
754
|
+
handler: (accessor, params) => {
|
|
755
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
756
|
+
const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? instanceService.getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) : instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
757
|
+
if (!workbook) return false;
|
|
758
|
+
const dialogService = accessor.get(_univerjs_ui.IDialogService);
|
|
759
|
+
dialogService.close(CALCULATION_OPTIONS_DIALOG);
|
|
760
|
+
dialogService.open({
|
|
761
|
+
id: CALCULATION_OPTIONS_DIALOG,
|
|
762
|
+
title: { title: "sheets-formula-ui.calculation.title" },
|
|
763
|
+
children: { label: {
|
|
764
|
+
name: CALCULATION_OPTIONS_COMPONENT,
|
|
765
|
+
props: { unitId: workbook.getUnitId() }
|
|
766
|
+
} },
|
|
767
|
+
width: 420,
|
|
768
|
+
onClose: () => dialogService.close(CALCULATION_OPTIONS_DIALOG)
|
|
797
769
|
});
|
|
798
|
-
return
|
|
799
|
-
redos,
|
|
800
|
-
undos
|
|
801
|
-
};
|
|
770
|
+
return true;
|
|
802
771
|
}
|
|
803
772
|
};
|
|
804
|
-
FormulaReorderController = __decorate([
|
|
805
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
806
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
807
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
808
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
809
|
-
], FormulaReorderController);
|
|
810
773
|
|
|
811
774
|
//#endregion
|
|
812
775
|
//#region src/menu/menu.ts
|
|
@@ -926,6 +889,16 @@ function PasteFormulaMenuItemFactory(accessor) {
|
|
|
926
889
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
|
|
927
890
|
};
|
|
928
891
|
}
|
|
892
|
+
function CalculationOptionsMenuItemFactory(accessor) {
|
|
893
|
+
return {
|
|
894
|
+
id: CalculationOptionsOperation.id,
|
|
895
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
896
|
+
icon: "CalculationOptionsIcon",
|
|
897
|
+
title: "sheets-formula-ui.calculation.title",
|
|
898
|
+
tooltip: "sheets-formula-ui.calculation.title",
|
|
899
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
|
|
900
|
+
};
|
|
901
|
+
}
|
|
929
902
|
|
|
930
903
|
//#endregion
|
|
931
904
|
//#region src/menu/schema.ts
|
|
@@ -986,6 +959,17 @@ const menuSchema = {
|
|
|
986
959
|
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
987
960
|
}
|
|
988
961
|
},
|
|
962
|
+
[_univerjs_ui.RibbonFormulasGroup.OTHERS]: { [CalculationOptionsOperation.id]: {
|
|
963
|
+
order: 0,
|
|
964
|
+
gridLayout: {
|
|
965
|
+
row: 1,
|
|
966
|
+
column: 1,
|
|
967
|
+
rowSpan: 2,
|
|
968
|
+
columnSpan: 2,
|
|
969
|
+
showLabel: true
|
|
970
|
+
},
|
|
971
|
+
menuItemFactory: CalculationOptionsMenuItemFactory
|
|
972
|
+
} },
|
|
989
973
|
[_univerjs_sheets_ui.COPY_SPECIAL_MENU_ID]: { [SheetCopyFormulaOnlyCommand.id]: {
|
|
990
974
|
order: 0,
|
|
991
975
|
menuItemFactory: CopyFormulaOnlyMenuItemFactory
|
|
@@ -999,7 +983,7 @@ const menuSchema = {
|
|
|
999
983
|
//#endregion
|
|
1000
984
|
//#region package.json
|
|
1001
985
|
var name = "@univerjs/sheets-formula-ui";
|
|
1002
|
-
var version = "1.0
|
|
986
|
+
var version = "1.1.0";
|
|
1003
987
|
|
|
1004
988
|
//#endregion
|
|
1005
989
|
//#region src/config/config.ts
|
|
@@ -1028,63 +1012,120 @@ const ErrorTypeToMessageMap = {
|
|
|
1028
1012
|
[_univerjs_engine_formula.ErrorType.NULL]: "null"
|
|
1029
1013
|
};
|
|
1030
1014
|
let FormulaAlertRenderController = class FormulaAlertRenderController extends _univerjs_core.Disposable {
|
|
1031
|
-
constructor(_context,
|
|
1015
|
+
constructor(_context, _selectionsService, _cellAlertManagerService, _localeService, _formulaDataModel, _sheetSkeletonService, _sheetSkeletonManagerService, _commandService, _instanceService, _editorBridgeService) {
|
|
1032
1016
|
super();
|
|
1033
1017
|
this._context = _context;
|
|
1034
|
-
this.
|
|
1018
|
+
this._selectionsService = _selectionsService;
|
|
1035
1019
|
this._cellAlertManagerService = _cellAlertManagerService;
|
|
1036
1020
|
this._localeService = _localeService;
|
|
1037
1021
|
this._formulaDataModel = _formulaDataModel;
|
|
1038
|
-
this.
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
this.
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
this.disposeWithMe(this.
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
if (
|
|
1061
|
-
|
|
1062
|
-
return;
|
|
1063
|
-
}
|
|
1064
|
-
this._cellAlertManagerService.showAlert({
|
|
1065
|
-
type: _univerjs_sheets_ui.CellAlertType.ERROR,
|
|
1066
|
-
title: this._localeService.t("sheets-formula-ui.error.title"),
|
|
1067
|
-
message: this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[errorType]}`),
|
|
1068
|
-
location: cellPos.location,
|
|
1069
|
-
width: 200,
|
|
1070
|
-
height: 74,
|
|
1071
|
-
key: ALERT_KEY
|
|
1072
|
-
});
|
|
1073
|
-
return;
|
|
1022
|
+
this._sheetSkeletonService = _sheetSkeletonService;
|
|
1023
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1024
|
+
this._commandService = _commandService;
|
|
1025
|
+
this._instanceService = _instanceService;
|
|
1026
|
+
this._editorBridgeService = _editorBridgeService;
|
|
1027
|
+
_defineProperty(this, "_circularLocations", /* @__PURE__ */ new Set());
|
|
1028
|
+
this.disposeWithMe(this._selectionsService.selectionChanged$.subscribe(() => this._updateAlert()));
|
|
1029
|
+
this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._updateAlert()));
|
|
1030
|
+
this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe(() => this._updateAlert()));
|
|
1031
|
+
this.disposeWithMe(this._editorBridgeService.visible$.subscribe(() => this._updateAlert()));
|
|
1032
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1033
|
+
if (command.id === _univerjs_engine_formula.SetFormulaCalculationNotificationMutation.id) {
|
|
1034
|
+
const params = command.params;
|
|
1035
|
+
if (params.circularReferences) {
|
|
1036
|
+
const locations = new Set(params.circularReferences.filter((cell) => cell.unitId === this._context.unit.getUnitId()).map((cell) => JSON.stringify([
|
|
1037
|
+
cell.sheetId,
|
|
1038
|
+
cell.row,
|
|
1039
|
+
cell.column
|
|
1040
|
+
])));
|
|
1041
|
+
const changed = locations.size !== this._circularLocations.size || Array.from(locations).some((location) => !this._circularLocations.has(location));
|
|
1042
|
+
this._circularLocations = locations;
|
|
1043
|
+
this._formulaDataModel.setCircularReferences(params.circularReferences);
|
|
1044
|
+
if (changed) this._refreshMarkers();
|
|
1045
|
+
this._updateAlert();
|
|
1074
1046
|
}
|
|
1047
|
+
} else if (command.id === _univerjs_sheets.SetRangeValuesMutation.id || command.id === _univerjs_sheets.SetWorkbookCalculationSettingsMutation.id) {
|
|
1048
|
+
if (command.id === _univerjs_sheets.SetWorkbookCalculationSettingsMutation.id && command.params.unitId === this._context.unit.getUnitId()) this._refreshMarkers();
|
|
1049
|
+
this._updateAlert();
|
|
1075
1050
|
}
|
|
1076
|
-
this._hideAlert();
|
|
1077
1051
|
}));
|
|
1052
|
+
this.disposeWithMe(() => this._hideAlert());
|
|
1053
|
+
}
|
|
1054
|
+
_updateAlert() {
|
|
1055
|
+
var _selections, _this$_formulaDataMod, _this$_cellAlertManag;
|
|
1056
|
+
const workbook = this._context.unit;
|
|
1057
|
+
const worksheet = workbook.getActiveSheet();
|
|
1058
|
+
const selection = this._selectionsService.currentSelectionParam;
|
|
1059
|
+
const currentWorkbook = this._instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
1060
|
+
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) {
|
|
1061
|
+
this._hideAlert();
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
const selections = this._selectionsService.getCurrentSelections();
|
|
1065
|
+
const primary = selections === null || selections === void 0 || (_selections = selections[selections.length - 1]) === null || _selections === void 0 ? void 0 : _selections.primary;
|
|
1066
|
+
if (!primary) {
|
|
1067
|
+
this._hideAlert();
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
const row = primary.actualRow;
|
|
1071
|
+
const col = primary.actualColumn;
|
|
1072
|
+
const unitId = workbook.getUnitId();
|
|
1073
|
+
const subUnitId = worksheet.getSheetId();
|
|
1074
|
+
const cell = worksheet.getCell(row, col);
|
|
1075
|
+
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);
|
|
1076
|
+
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];
|
|
1077
|
+
const error = (0, _univerjs_core.isICellData)(cell) ? (0, _univerjs_engine_formula.extractFormulaError)(cell, !!arrayCell) : void 0;
|
|
1078
|
+
if (!circular && !error) {
|
|
1079
|
+
this._hideAlert();
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const message = circular ? this._localeService.t("sheets-formula-ui.calculation.circular") : this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[error]}`);
|
|
1083
|
+
const previous = (_this$_cellAlertManag = this._cellAlertManagerService.currentAlert.get(this._alertKey)) === null || _this$_cellAlertManag === void 0 ? void 0 : _this$_cellAlertManag.alert;
|
|
1084
|
+
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;
|
|
1085
|
+
this._cellAlertManagerService.showAlert({
|
|
1086
|
+
type: _univerjs_sheets_ui.CellAlertType.ERROR,
|
|
1087
|
+
title: this._localeService.t(circular ? "sheets-formula-ui.calculation.circularTitle" : "sheets-formula-ui.error.title"),
|
|
1088
|
+
message,
|
|
1089
|
+
location: {
|
|
1090
|
+
unitId,
|
|
1091
|
+
subUnitId,
|
|
1092
|
+
row,
|
|
1093
|
+
col
|
|
1094
|
+
},
|
|
1095
|
+
width: 240,
|
|
1096
|
+
height: circular ? 124 : 74,
|
|
1097
|
+
key: this._alertKey,
|
|
1098
|
+
action: circular ? {
|
|
1099
|
+
label: this._localeService.t("sheets-formula-ui.calculation.action"),
|
|
1100
|
+
onSelect: () => {
|
|
1101
|
+
this._commandService.syncExecuteCommand(CalculationOptionsOperation.id, { unitId });
|
|
1102
|
+
}
|
|
1103
|
+
} : void 0
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
get _alertKey() {
|
|
1107
|
+
return `${ALERT_KEY}:${this._context.unit.getUnitId()}`;
|
|
1108
|
+
}
|
|
1109
|
+
_refreshMarkers() {
|
|
1110
|
+
var _this$_context$mainCo;
|
|
1111
|
+
this._sheetSkeletonService.getSkeletonsByUnitId(this._context.unit.getUnitId()).forEach((skeleton) => skeleton.resetCache());
|
|
1112
|
+
this._sheetSkeletonManagerService.reCalculate();
|
|
1113
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
|
|
1078
1114
|
}
|
|
1079
1115
|
_hideAlert() {
|
|
1080
|
-
this._cellAlertManagerService.removeAlert(
|
|
1116
|
+
this._cellAlertManagerService.removeAlert(this._alertKey);
|
|
1081
1117
|
}
|
|
1082
1118
|
};
|
|
1083
1119
|
FormulaAlertRenderController = __decorate([
|
|
1084
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(
|
|
1120
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
1085
1121
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellAlertManagerService)),
|
|
1086
1122
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1087
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
1123
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
1124
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
1125
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1126
|
+
__decorateParam(7, _univerjs_core.ICommandService),
|
|
1127
|
+
__decorateParam(8, _univerjs_core.IUniverInstanceService),
|
|
1128
|
+
__decorateParam(9, _univerjs_sheets_ui.IEditorBridgeService)
|
|
1088
1129
|
], FormulaAlertRenderController);
|
|
1089
1130
|
|
|
1090
1131
|
//#endregion
|
|
@@ -1582,6 +1623,10 @@ let FormulaEditorShowController = class FormulaEditorShowController extends _uni
|
|
|
1582
1623
|
if (range == null) return true;
|
|
1583
1624
|
const { startRow, startColumn, endRow, endColumn } = range;
|
|
1584
1625
|
if (rowIndex === row && columnIndex === col) {
|
|
1626
|
+
result = {
|
|
1627
|
+
...cellInfo,
|
|
1628
|
+
isInArrayFormulaRange: false
|
|
1629
|
+
};
|
|
1585
1630
|
this._createArrayFormulaRangeShape(range, unitId, subUnitId);
|
|
1586
1631
|
return false;
|
|
1587
1632
|
}
|
|
@@ -1712,7 +1757,9 @@ let FormulaRenderManagerController = class FormulaRenderManagerController extend
|
|
|
1712
1757
|
handler: (cell, pos, next) => {
|
|
1713
1758
|
var _this$_formulaDataMod;
|
|
1714
1759
|
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];
|
|
1715
|
-
|
|
1760
|
+
const errorType = (0, _univerjs_engine_formula.extractFormulaError)(cell, !!arrayFormulaCellData);
|
|
1761
|
+
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);
|
|
1762
|
+
if (!errorType && !circular) return next(cell);
|
|
1716
1763
|
if (!cell) return next(cell);
|
|
1717
1764
|
if (cell === pos.rawData) cell = { ...pos.rawData };
|
|
1718
1765
|
cell.markers = {
|
|
@@ -1772,15 +1819,17 @@ function registerFormulaEditorRuntimePortal(options) {
|
|
|
1772
1819
|
let registeredPortalRoot = null;
|
|
1773
1820
|
let disposed = false;
|
|
1774
1821
|
const tryRegister = () => {
|
|
1822
|
+
var _options$editorServic;
|
|
1775
1823
|
if (disposed) return;
|
|
1776
|
-
const
|
|
1824
|
+
const selection = (_options$editorServic = options.editorService.getEditor(options.editorId)) === null || _options$editorServic === void 0 ? void 0 : _options$editorServic.docSelectionRenderService;
|
|
1825
|
+
const portalRoot = (selection === null || selection === void 0 ? void 0 : selection.selectionContainer.isConnected) ? selection.selectionContainer : null;
|
|
1777
1826
|
if (portalRoot === registeredPortalRoot) return;
|
|
1778
1827
|
portalRegistration === null || portalRegistration === void 0 || portalRegistration.dispose();
|
|
1779
1828
|
portalRegistration = void 0;
|
|
1780
1829
|
registeredPortalRoot = null;
|
|
1781
|
-
if (!portalRoot) return;
|
|
1830
|
+
if (!portalRoot || !selection) return;
|
|
1782
1831
|
registeredPortalRoot = portalRoot;
|
|
1783
|
-
portalRegistration = registerFormulaEditorPortalRoot(options,
|
|
1832
|
+
portalRegistration = registerFormulaEditorPortalRoot(options, selection);
|
|
1784
1833
|
};
|
|
1785
1834
|
const scheduleRetry = (remaining) => {
|
|
1786
1835
|
if (remaining <= 0 || !(view === null || view === void 0 ? void 0 : view.requestAnimationFrame)) return;
|
|
@@ -1816,13 +1865,9 @@ function registerFormulaEditorRuntimePortal(options) {
|
|
|
1816
1865
|
}));
|
|
1817
1866
|
return collection;
|
|
1818
1867
|
}
|
|
1819
|
-
function
|
|
1820
|
-
return ownerDocument.getElementById(`univer-doc-selection-container-${editorId}`) ?? ownerDocument.getElementById(`__editor_${editorId}`);
|
|
1821
|
-
}
|
|
1822
|
-
function registerFormulaEditorPortalRoot(options, ownerDocument, portalRoot) {
|
|
1868
|
+
function registerFormulaEditorPortalRoot(options, selection) {
|
|
1823
1869
|
const collection = new _univerjs_core.DisposableCollection();
|
|
1824
|
-
|
|
1825
|
-
(editorElement && editorElement !== portalRoot ? [portalRoot, editorElement] : [portalRoot]).forEach((element) => {
|
|
1870
|
+
[selection.selectionContainer, selection.inputElement].forEach((element) => {
|
|
1826
1871
|
if (options.interactionBoundaryService) collection.add(options.interactionBoundaryService.registerOwnedElement(options.embedId, element));
|
|
1827
1872
|
if (options.focusCoordinator) collection.add(options.focusCoordinator.registerElement({
|
|
1828
1873
|
embedId: options.embedId,
|
|
@@ -1862,7 +1907,7 @@ function focusFormulaEditor(editorService, editor, offset) {
|
|
|
1862
1907
|
if (!editor) return;
|
|
1863
1908
|
const selections = [...editor.getSelectionRanges()];
|
|
1864
1909
|
editorService.focus(editor.getEditorId());
|
|
1865
|
-
|
|
1910
|
+
editor.docSelectionRenderService.focus();
|
|
1866
1911
|
if (editor.docSelectionRenderService.isOnPointerEvent) return;
|
|
1867
1912
|
if (_univerjs_core.Tools.isDefine(offset)) editor.setSelectionRanges([{
|
|
1868
1913
|
startOffset: offset,
|
|
@@ -1878,16 +1923,7 @@ function focusFormulaEditor(editorService, editor, offset) {
|
|
|
1878
1923
|
}]);
|
|
1879
1924
|
} else editor.setSelectionRanges(selections);
|
|
1880
1925
|
}
|
|
1881
|
-
function focusFormulaEditorElement(editor) {
|
|
1882
|
-
var _editor$editorDOM;
|
|
1883
|
-
const editorElement = (((_editor$editorDOM = editor.editorDOM) === null || _editor$editorDOM === void 0 ? void 0 : _editor$editorDOM.ownerDocument) ?? document).getElementById(`__editor_${editor.getEditorId()}`);
|
|
1884
|
-
editorElement === null || editorElement === void 0 || editorElement.focus({ preventScroll: true });
|
|
1885
|
-
}
|
|
1886
|
-
function shouldSkipFormulaEditorMouseUpFocus(_target) {
|
|
1887
|
-
return false;
|
|
1888
|
-
}
|
|
1889
1926
|
function shouldRefocusFormulaEditorOnMouseUp(options) {
|
|
1890
|
-
if (shouldSkipFormulaEditorMouseUpFocus(options.target)) return false;
|
|
1891
1927
|
if (options.isPointerSelecting || options.isFocusing) return false;
|
|
1892
1928
|
return true;
|
|
1893
1929
|
}
|
|
@@ -1975,18 +2011,16 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends _unive
|
|
|
1975
2011
|
if (evt.button !== 2) state.stopPropagation();
|
|
1976
2012
|
}));
|
|
1977
2013
|
listenerDisposables.add(spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 ? void 0 : spreadsheetRowHeader.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1978
|
-
if (!this.inRefSelectionMode()) return;
|
|
1979
2014
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1980
|
-
if (!skeleton) return;
|
|
2015
|
+
if (!this.inRefSelectionMode() || !skeleton) return;
|
|
1981
2016
|
const { row } = (0, _univerjs_sheets_ui.getCoordByOffset)(evt.offsetX, evt.offsetY, scene, skeleton);
|
|
1982
2017
|
if ((0, _univerjs_sheets_ui.checkInHeaderRanges)(this._workbookSelections.getCurrentSelections(), row, _univerjs_core.RANGE_TYPE.ROW)) return;
|
|
1983
2018
|
this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, _univerjs_core.RANGE_TYPE.ROW, this._getActiveViewport(evt), _univerjs_engine_render.ScrollTimerType.Y);
|
|
1984
2019
|
if (evt.button !== 2) state.stopPropagation();
|
|
1985
2020
|
}));
|
|
1986
2021
|
listenerDisposables.add(spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 ? void 0 : spreadsheetColumnHeader.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1987
|
-
if (!this.inRefSelectionMode()) return;
|
|
1988
2022
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1989
|
-
if (!skeleton) return;
|
|
2023
|
+
if (!this.inRefSelectionMode() || !skeleton) return;
|
|
1990
2024
|
const { column } = (0, _univerjs_sheets_ui.getCoordByOffset)(evt.offsetX, evt.offsetY, scene, skeleton);
|
|
1991
2025
|
if ((0, _univerjs_sheets_ui.checkInHeaderRanges)(this._workbookSelections.getCurrentSelections(), column, _univerjs_core.RANGE_TYPE.COLUMN)) return;
|
|
1992
2026
|
this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, _univerjs_core.RANGE_TYPE.COLUMN, this._getActiveViewport(evt), _univerjs_engine_render.ScrollTimerType.X);
|
|
@@ -1994,9 +2028,8 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends _unive
|
|
|
1994
2028
|
}));
|
|
1995
2029
|
listenerDisposables.add(spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 ? void 0 : spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1996
2030
|
this._reset();
|
|
1997
|
-
if (!this.inRefSelectionMode()) return;
|
|
1998
2031
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1999
|
-
if (!skeleton) return;
|
|
2032
|
+
if (!this.inRefSelectionMode() || !skeleton) return;
|
|
2000
2033
|
const selectionWithStyle = (0, _univerjs_sheets_ui.getAllSelection)(skeleton);
|
|
2001
2034
|
this._addSelectionControlByModelData(selectionWithStyle);
|
|
2002
2035
|
this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
|
|
@@ -2162,7 +2195,7 @@ let RefSelectionsRenderService = class RefSelectionsRenderService extends _unive
|
|
|
2162
2195
|
endRow: activeSelectionControl.model.endRow,
|
|
2163
2196
|
endColumn: activeSelectionControl.model.endColumn
|
|
2164
2197
|
} : null;
|
|
2165
|
-
const remainLastEnable = this._remainLastEnabled && !
|
|
2198
|
+
const remainLastEnable = this._remainLastEnabled && !this._isMultiSelectModifier(evt) && !evt.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
|
|
2166
2199
|
if (expandByShiftKey && currentCell) this._makeSelectionByTwoCells(currentCell, cursorCellRangeWithRangeType, skeleton, rangeType, activeSelectionControl);
|
|
2167
2200
|
else if (remainLastEnable && activeSelectionControl) activeSelectionControl.updateRangeBySelectionWithCoord(selectionCellWithCoord);
|
|
2168
2201
|
else activeSelectionControl = this.newSelectionControl(scene, skeleton, selectionWithStyle);
|
|
@@ -2343,6 +2376,7 @@ function useFormulaSelecting(opts) {
|
|
|
2343
2376
|
});
|
|
2344
2377
|
const calculateSelectingType = (0, _univerjs_ui.useEvent)(() => {
|
|
2345
2378
|
var _editor$getSelectionR, _config$dataStream;
|
|
2379
|
+
if (!isFocus) return;
|
|
2346
2380
|
const currentWorkbook = resolveFormulaSelectionWorkbook(univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET), workbook);
|
|
2347
2381
|
if (!currentWorkbook) return;
|
|
2348
2382
|
const currentSheet = currentWorkbook.getActiveSheet();
|
|
@@ -2618,7 +2652,7 @@ function useDocHight(_leadingCharacter = "") {
|
|
|
2618
2652
|
});
|
|
2619
2653
|
return [];
|
|
2620
2654
|
} else {
|
|
2621
|
-
const { textRuns, refSelections } =
|
|
2655
|
+
const { textRuns, refSelections } = (0, _univerjs_engine_formula.buildFormulaTextRuns)(descriptionService, colorMap, sequenceNodes);
|
|
2622
2656
|
if (leadingCharacterLength) textRuns.forEach((e) => {
|
|
2623
2657
|
e.ed = e.ed + leadingCharacterLength;
|
|
2624
2658
|
e.st = e.st + leadingCharacterLength;
|
|
@@ -2663,31 +2697,28 @@ function createHighlightTextRuns(textRuns, leadingCharacterLength) {
|
|
|
2663
2697
|
}
|
|
2664
2698
|
function useColor() {
|
|
2665
2699
|
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
2666
|
-
const
|
|
2700
|
+
const canvasColorService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.ICanvasColorService);
|
|
2701
|
+
const theme = (0, _univerjs_ui.useObservable)(themeService.currentTheme$, themeService.getCurrentTheme());
|
|
2702
|
+
const darkMode = (0, _univerjs_ui.useObservable)(themeService.darkMode$, themeService.darkMode);
|
|
2667
2703
|
return (0, react.useMemo)(() => {
|
|
2668
2704
|
return {
|
|
2669
|
-
formulaRefColors: [
|
|
2670
|
-
themeService.getColorFromTheme(
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
themeService.getColorFromTheme("loop-color.7"),
|
|
2677
|
-
themeService.getColorFromTheme("loop-color.8"),
|
|
2678
|
-
themeService.getColorFromTheme("loop-color.9"),
|
|
2679
|
-
themeService.getColorFromTheme("loop-color.10"),
|
|
2680
|
-
themeService.getColorFromTheme("loop-color.11"),
|
|
2681
|
-
themeService.getColorFromTheme("loop-color.12")
|
|
2682
|
-
].map((color) => themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color),
|
|
2705
|
+
formulaRefColors: Object.values(theme["loop-color"]).map((color) => {
|
|
2706
|
+
const resolvedColor = themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color;
|
|
2707
|
+
if (!darkMode) return resolvedColor;
|
|
2708
|
+
let referenceColor = new _univerjs_core.ColorKit(resolvedColor);
|
|
2709
|
+
while (referenceColor.toHsl().l > 0 && _univerjs_core.ColorKit.getContrastRatio(canvasColorService.getRenderColor(referenceColor.toHexString()), theme.gray[800]) < 4.5) referenceColor = referenceColor.darken(5);
|
|
2710
|
+
return referenceColor.toHexString();
|
|
2711
|
+
}),
|
|
2683
2712
|
numberColor: themeService.getColorFromTheme("blue.700"),
|
|
2684
2713
|
stringColor: themeService.getColorFromTheme("jiqing.800"),
|
|
2685
2714
|
plainTextColor: themeService.getColorFromTheme("gray.1000")
|
|
2686
2715
|
};
|
|
2687
|
-
}, [
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2716
|
+
}, [
|
|
2717
|
+
theme,
|
|
2718
|
+
darkMode,
|
|
2719
|
+
themeService,
|
|
2720
|
+
canvasColorService
|
|
2721
|
+
]);
|
|
2691
2722
|
}
|
|
2692
2723
|
|
|
2693
2724
|
//#endregion
|
|
@@ -2735,8 +2766,8 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
2735
2766
|
if (keycode === _univerjs_ui.KeyCode.ARROW_DOWN) direction = _univerjs_core.Direction.DOWN;
|
|
2736
2767
|
else if (keycode === _univerjs_ui.KeyCode.ARROW_UP) direction = _univerjs_core.Direction.UP;
|
|
2737
2768
|
else if (keycode === _univerjs_ui.KeyCode.ARROW_RIGHT) direction = _univerjs_core.Direction.RIGHT;
|
|
2738
|
-
if (metaKey === _univerjs_ui.MetaKeys.SHIFT) commandService.
|
|
2739
|
-
else commandService.
|
|
2769
|
+
if (metaKey === _univerjs_ui.MetaKeys.SHIFT) return commandService.syncExecuteCommand(_univerjs_docs_ui.MoveSelectionOperation.id, { direction });
|
|
2770
|
+
else return commandService.syncExecuteCommand(_univerjs_docs_ui.MoveCursorOperation.id, { direction });
|
|
2740
2771
|
};
|
|
2741
2772
|
const handleKeycode = (keycode, metaKey) => {
|
|
2742
2773
|
let direction = _univerjs_core.Direction.DOWN;
|
|
@@ -2746,35 +2777,38 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
2746
2777
|
else if (keycode === _univerjs_ui.KeyCode.ARROW_RIGHT) direction = _univerjs_core.Direction.RIGHT;
|
|
2747
2778
|
if (shouldMoveSelectionRef.current) {
|
|
2748
2779
|
var _getRefSelectionCount;
|
|
2749
|
-
const
|
|
2750
|
-
|
|
2780
|
+
const refSelectionCount = ((_getRefSelectionCount = getRefSelectionCountRef.current) === null || _getRefSelectionCount === void 0 ? void 0 : _getRefSelectionCount.call(getRefSelectionCountRef)) ?? 0;
|
|
2781
|
+
const fromCurrentSelection = shouldMoveFormulaSelectionFromCurrentSelection(shouldMoveSelectionRef.current, refSelectionCount);
|
|
2782
|
+
if (metaKey === _univerjs_ui.MetaKeys.CTRL_COMMAND) return commandService.executeCommand(_univerjs_sheets_ui.MoveSelectionCommand.id, {
|
|
2751
2783
|
direction,
|
|
2752
2784
|
jumpOver: _univerjs_sheets_ui.JumpOver.moveGap,
|
|
2753
2785
|
extra: "formula-editor",
|
|
2754
2786
|
fromCurrentSelection
|
|
2755
2787
|
});
|
|
2756
|
-
else if (metaKey === _univerjs_ui.MetaKeys.SHIFT) commandService.executeCommand(_univerjs_sheets_ui.ExpandSelectionCommand.id, {
|
|
2788
|
+
else if (metaKey === _univerjs_ui.MetaKeys.SHIFT) return commandService.executeCommand(_univerjs_sheets_ui.ExpandSelectionCommand.id, {
|
|
2757
2789
|
direction,
|
|
2758
|
-
extra: "formula-editor"
|
|
2790
|
+
extra: "formula-editor",
|
|
2791
|
+
fromCurrentSelection: refSelectionCount === 0
|
|
2759
2792
|
});
|
|
2760
|
-
else if (metaKey === (_univerjs_ui.MetaKeys.CTRL_COMMAND | _univerjs_ui.MetaKeys.SHIFT)) commandService.executeCommand(_univerjs_sheets_ui.ExpandSelectionCommand.id, {
|
|
2793
|
+
else if (metaKey === (_univerjs_ui.MetaKeys.CTRL_COMMAND | _univerjs_ui.MetaKeys.SHIFT)) return commandService.executeCommand(_univerjs_sheets_ui.ExpandSelectionCommand.id, {
|
|
2761
2794
|
direction,
|
|
2762
2795
|
jumpOver: _univerjs_sheets_ui.JumpOver.moveGap,
|
|
2763
|
-
extra: "formula-editor"
|
|
2796
|
+
extra: "formula-editor",
|
|
2797
|
+
fromCurrentSelection: refSelectionCount === 0
|
|
2764
2798
|
});
|
|
2765
|
-
else commandService.executeCommand(_univerjs_sheets_ui.MoveSelectionCommand.id, {
|
|
2799
|
+
else return commandService.executeCommand(_univerjs_sheets_ui.MoveSelectionCommand.id, {
|
|
2766
2800
|
direction,
|
|
2767
2801
|
extra: "formula-editor",
|
|
2768
2802
|
fromCurrentSelection
|
|
2769
2803
|
});
|
|
2770
|
-
} else handleMoveInEditor(keycode, metaKey);
|
|
2804
|
+
} else return handleMoveInEditor(keycode, metaKey);
|
|
2771
2805
|
};
|
|
2772
2806
|
d.add(commandService.registerCommand({
|
|
2773
2807
|
id: operationId,
|
|
2774
2808
|
type: _univerjs_core.CommandType.OPERATION,
|
|
2775
2809
|
handler(_event, params) {
|
|
2776
2810
|
const { keyCode, metaKey } = params;
|
|
2777
|
-
handleKeycode(keyCode, metaKey);
|
|
2811
|
+
return handleKeycode(keyCode, metaKey);
|
|
2778
2812
|
}
|
|
2779
2813
|
}));
|
|
2780
2814
|
[
|
|
@@ -2834,7 +2868,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
2834
2868
|
return {
|
|
2835
2869
|
id: operationId,
|
|
2836
2870
|
binding: metaKey ? keyCode | metaKey : keyCode,
|
|
2837
|
-
preconditions: shouldHandleShortcut,
|
|
2871
|
+
preconditions: () => shouldHandleShortcut() && (!(metaKey && metaKey & _univerjs_ui.MetaKeys.CTRL_COMMAND) || Boolean(shouldMoveSelectionRef.current)),
|
|
2838
2872
|
priority: 900,
|
|
2839
2873
|
staticParameters: {
|
|
2840
2874
|
eventType: _univerjs_engine_render.DeviceInputEventType.Keyboard,
|
|
@@ -3752,12 +3786,11 @@ function MobileFunctionPanel(props) {
|
|
|
3752
3786
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3753
3787
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3754
3788
|
className: "univer-px-4 univer-pb-3",
|
|
3755
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3789
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
3756
3790
|
value: query,
|
|
3757
3791
|
"aria-label": copy.search,
|
|
3758
3792
|
placeholder: copy.search,
|
|
3759
|
-
|
|
3760
|
-
onChange: (event) => setQuery(event.target.value)
|
|
3793
|
+
onChange: setQuery
|
|
3761
3794
|
})
|
|
3762
3795
|
}),
|
|
3763
3796
|
!query && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -4392,6 +4425,7 @@ const MobileFormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
4392
4425
|
element: formulaEditorContainer
|
|
4393
4426
|
}));
|
|
4394
4427
|
collection.add(registerFormulaEditorRuntimePortal({
|
|
4428
|
+
editorService,
|
|
4395
4429
|
embedId: scope.embedId,
|
|
4396
4430
|
editorId,
|
|
4397
4431
|
ownerDocument: formulaEditorContainer.ownerDocument,
|
|
@@ -4401,6 +4435,7 @@ const MobileFormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
4401
4435
|
return () => collection.dispose();
|
|
4402
4436
|
}, [
|
|
4403
4437
|
editorId,
|
|
4438
|
+
editorService,
|
|
4404
4439
|
injector,
|
|
4405
4440
|
isFocus
|
|
4406
4441
|
]);
|
|
@@ -4544,10 +4579,9 @@ const MobileFormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
4544
4579
|
contextService.setContextValue(_univerjs_sheets_ui.MOBILE_FORMULA_FUNCTION_PANEL_OPEN, false);
|
|
4545
4580
|
});
|
|
4546
4581
|
};
|
|
4547
|
-
const handleMouseUp = (
|
|
4582
|
+
const handleMouseUp = () => {
|
|
4548
4583
|
if (hasActiveFormulaEmbedInteraction(formulaEditorContainerRef.current)) return;
|
|
4549
4584
|
if (!shouldRefocusFormulaEditorOnMouseUp({
|
|
4550
|
-
target: event.target,
|
|
4551
4585
|
isFocusing,
|
|
4552
4586
|
isPointerSelecting: docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isOnPointerEvent
|
|
4553
4587
|
})) return;
|
|
@@ -5213,6 +5247,7 @@ function RangeSelector(props) {
|
|
|
5213
5247
|
const { className, onVerify, selectorRef, unitId, subUnitId, maxRangeCount, supportAcrossSheet, keepSheetReference, autoFocus, onChange, onRangeSelectorDialogVisibleChange, onClickOutside, onFocusChange, forceShowDialogWhenSelectionChanged, hideEditor, resetRange, onClose } = props;
|
|
5214
5248
|
const [focusing, setFocusing] = (0, react.useState)(autoFocus ?? false);
|
|
5215
5249
|
const [popupVisible, setPopupVisible] = (0, react.useState)(false);
|
|
5250
|
+
const [tooltipVisible, setTooltipVisible] = (0, react.useState)(false);
|
|
5216
5251
|
const [rangeSelectorRanges, setRangeSelectorRanges] = (0, react.useState)([]);
|
|
5217
5252
|
const editorService = (0, _univerjs_ui.useDependency)(_univerjs_docs_ui.IEditorService);
|
|
5218
5253
|
const { sequenceNodes } = useRangesHighlight(editor, focusing, unitId, subUnitId);
|
|
@@ -5226,6 +5261,7 @@ function RangeSelector(props) {
|
|
|
5226
5261
|
});
|
|
5227
5262
|
const handleOpenModal = (0, _univerjs_ui.useEvent)(() => {
|
|
5228
5263
|
var _editor$getDocumentDa;
|
|
5264
|
+
setTooltipVisible(false);
|
|
5229
5265
|
blurEditor();
|
|
5230
5266
|
setRangeSelectorRanges(parseRanges((editor === null || editor === void 0 || (_editor$getDocumentDa = editor.getDocumentDataModel()) === null || _editor$getDocumentDa === void 0 ? void 0 : _editor$getDocumentDa.getPlainText()) ?? ""));
|
|
5231
5267
|
setPopupVisible(true);
|
|
@@ -5242,6 +5278,7 @@ function RangeSelector(props) {
|
|
|
5242
5278
|
blur: blurEditor,
|
|
5243
5279
|
verify: () => verifyRange(sequenceNodesRef.current),
|
|
5244
5280
|
showDialog: (ranges) => {
|
|
5281
|
+
setTooltipVisible(false);
|
|
5245
5282
|
blurEditor();
|
|
5246
5283
|
setRangeSelectorRanges(ranges);
|
|
5247
5284
|
setPopupVisible(true);
|
|
@@ -5297,6 +5334,8 @@ function RangeSelector(props) {
|
|
|
5297
5334
|
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
5298
5335
|
title: localeService.t("sheets-formula-ui.rangeSelector.buttonTooltip"),
|
|
5299
5336
|
placement: "bottom",
|
|
5337
|
+
visible: tooltipVisible && !popupVisible,
|
|
5338
|
+
onVisibleChange: (visible) => setTooltipVisible(visible && !popupVisible),
|
|
5300
5339
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SelectRangeIcon, {
|
|
5301
5340
|
className: "-univer-translate-y-0.5 univer-cursor-pointer dark:!univer-text-gray-300",
|
|
5302
5341
|
onClick: handleOpenModal
|
|
@@ -5328,6 +5367,7 @@ function RangeSelector(props) {
|
|
|
5328
5367
|
keepSheetReference,
|
|
5329
5368
|
onShowBySelection: (ranges) => {
|
|
5330
5369
|
if (focusing || forceShowDialogWhenSelectionChanged) {
|
|
5370
|
+
setTooltipVisible(false);
|
|
5331
5371
|
setRangeSelectorRanges(ranges);
|
|
5332
5372
|
setPopupVisible(true);
|
|
5333
5373
|
return false;
|
|
@@ -5641,6 +5681,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
|
|
|
5641
5681
|
}
|
|
5642
5682
|
_registerIcons() {
|
|
5643
5683
|
this.disposeWithMe(this._iconManager.register({
|
|
5684
|
+
CalculationOptionsIcon: _univerjs_icons.CalculationOptionsIcon,
|
|
5644
5685
|
DatabaseFunctionIcon: _univerjs_icons.DatabaseFunctionIcon,
|
|
5645
5686
|
DateFunctionIcon: _univerjs_icons.DateFunctionIcon,
|
|
5646
5687
|
EngineeringFunctionIcon: _univerjs_icons.EngineeringFunctionIcon,
|
|
@@ -5741,6 +5782,7 @@ let FormulaUIController = class FormulaUIController extends _univerjs_core.Dispo
|
|
|
5741
5782
|
SheetOnlyPasteFormulaCommand,
|
|
5742
5783
|
InsertFunctionOperation,
|
|
5743
5784
|
MoreFunctionsOperation,
|
|
5785
|
+
CalculationOptionsOperation,
|
|
5744
5786
|
SearchFunctionOperation,
|
|
5745
5787
|
HelpFunctionOperation,
|
|
5746
5788
|
ReferenceAbsoluteOperation
|
|
@@ -6147,7 +6189,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
|
|
|
6147
6189
|
[FormulaClipboardController],
|
|
6148
6190
|
[FormulaEditorShowController],
|
|
6149
6191
|
[FormulaRenderManagerController],
|
|
6150
|
-
[FormulaReorderController],
|
|
6151
6192
|
[ImageFormulaRenderController]
|
|
6152
6193
|
]);
|
|
6153
6194
|
this._initUIPart();
|
|
@@ -6169,9 +6210,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
|
|
|
6169
6210
|
[ImageFormulaRenderController]
|
|
6170
6211
|
]);
|
|
6171
6212
|
}
|
|
6172
|
-
onSteady() {
|
|
6173
|
-
this._injector.get(FormulaReorderController);
|
|
6174
|
-
}
|
|
6175
6213
|
_initUIPart() {
|
|
6176
6214
|
this.disposeWithMe(this._uiPartsService.registerComponent(_univerjs_ui.BuiltInUIPart.GLOBAL, () => (0, _univerjs_ui.connectInjector)(MobileGlobalRangeSelector, this._injector)));
|
|
6177
6215
|
}
|
|
@@ -6188,6 +6226,125 @@ UniverSheetsFormulaMobileUIPlugin = __decorate([
|
|
|
6188
6226
|
__decorateParam(4, _univerjs_ui.IUIPartsService)
|
|
6189
6227
|
], UniverSheetsFormulaMobileUIPlugin);
|
|
6190
6228
|
|
|
6229
|
+
//#endregion
|
|
6230
|
+
//#region src/views/calculation-options/CalculationOptions.tsx
|
|
6231
|
+
function CalculationOptions({ unitId }) {
|
|
6232
|
+
var _permissionService$ge;
|
|
6233
|
+
const instanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
6234
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
6235
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
6236
|
+
const dialogService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IDialogService);
|
|
6237
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
6238
|
+
const workbook = instanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
6239
|
+
const permissionId = new _univerjs_sheets.WorkbookEditablePermission(unitId).id;
|
|
6240
|
+
const permission = (0, _univerjs_ui.useObservable)(permissionService.getPermissionPoint$(permissionId), void 0, false);
|
|
6241
|
+
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;
|
|
6242
|
+
const [draft, setDraft] = (0, react.useState)(() => {
|
|
6243
|
+
const settings = (0, _univerjs_core.normalizeWorkbookCalculationSettings)(workbook === null || workbook === void 0 ? void 0 : workbook.getCalculationSettings());
|
|
6244
|
+
return {
|
|
6245
|
+
enabled: settings.iterativeCalculation,
|
|
6246
|
+
count: String(settings.maxIterations),
|
|
6247
|
+
change: String(settings.maxChange)
|
|
6248
|
+
};
|
|
6249
|
+
});
|
|
6250
|
+
const [submitted, setSubmitted] = (0, react.useState)(false);
|
|
6251
|
+
const settings = {
|
|
6252
|
+
iterativeCalculation: draft.enabled,
|
|
6253
|
+
maxIterations: draft.count.trim() ? Number(draft.count) : NaN,
|
|
6254
|
+
maxChange: draft.change.trim() ? Number(draft.change) : NaN
|
|
6255
|
+
};
|
|
6256
|
+
const validCount = Number.isInteger(settings.maxIterations) && settings.maxIterations >= 1 && settings.maxIterations <= _univerjs_core.MAX_ITERATION_COUNT;
|
|
6257
|
+
const validChange = Number.isFinite(settings.maxChange) && settings.maxChange > 0;
|
|
6258
|
+
const showCountError = submitted && draft.enabled && !validCount;
|
|
6259
|
+
const showChangeError = submitted && draft.enabled && !validChange;
|
|
6260
|
+
function close() {
|
|
6261
|
+
dialogService.close(CALCULATION_OPTIONS_DIALOG);
|
|
6262
|
+
}
|
|
6263
|
+
function submit() {
|
|
6264
|
+
if (readOnly) return;
|
|
6265
|
+
setSubmitted(true);
|
|
6266
|
+
if (draft.enabled && (!validCount || !validChange)) return;
|
|
6267
|
+
const nextSettings = draft.enabled ? settings : {
|
|
6268
|
+
...workbook.getCalculationSettings(),
|
|
6269
|
+
iterativeCalculation: false
|
|
6270
|
+
};
|
|
6271
|
+
if (commandService.syncExecuteCommand(_univerjs_sheets.SetWorkbookCalculationSettingsCommand.id, {
|
|
6272
|
+
unitId,
|
|
6273
|
+
settings: nextSettings
|
|
6274
|
+
})) close();
|
|
6275
|
+
}
|
|
6276
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6277
|
+
className: "univer-flex univer-flex-col univer-gap-4 univer-p-4",
|
|
6278
|
+
children: [
|
|
6279
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6280
|
+
className: "univer-m-0 univer-text-sm",
|
|
6281
|
+
children: localeService.t("sheets-formula-ui.calculation.workbook")
|
|
6282
|
+
}),
|
|
6283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
6284
|
+
checked: draft.enabled,
|
|
6285
|
+
disabled: readOnly,
|
|
6286
|
+
onChange: (enabled) => setDraft((previous) => ({
|
|
6287
|
+
...previous,
|
|
6288
|
+
enabled: Boolean(enabled)
|
|
6289
|
+
})),
|
|
6290
|
+
children: localeService.t("sheets-formula-ui.calculation.enable")
|
|
6291
|
+
}),
|
|
6292
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
6293
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
|
|
6294
|
+
children: [
|
|
6295
|
+
localeService.t("sheets-formula-ui.calculation.iterations", String(_univerjs_core.MAX_ITERATION_COUNT)),
|
|
6296
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
6297
|
+
value: draft.count,
|
|
6298
|
+
inputClass: showCountError ? "univer-border-red-500" : void 0,
|
|
6299
|
+
disabled: readOnly || !draft.enabled,
|
|
6300
|
+
onChange: (count) => setDraft((previous) => ({
|
|
6301
|
+
...previous,
|
|
6302
|
+
count
|
|
6303
|
+
}))
|
|
6304
|
+
}),
|
|
6305
|
+
showCountError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6306
|
+
role: "alert",
|
|
6307
|
+
className: "univer-text-red-500",
|
|
6308
|
+
children: localeService.t("sheets-formula-ui.calculation.invalidIterations", String(_univerjs_core.MAX_ITERATION_COUNT))
|
|
6309
|
+
})
|
|
6310
|
+
]
|
|
6311
|
+
}),
|
|
6312
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
6313
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
|
|
6314
|
+
children: [
|
|
6315
|
+
localeService.t("sheets-formula-ui.calculation.change"),
|
|
6316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
6317
|
+
value: draft.change,
|
|
6318
|
+
inputClass: showChangeError ? "univer-border-red-500" : void 0,
|
|
6319
|
+
disabled: readOnly || !draft.enabled,
|
|
6320
|
+
onChange: (change) => setDraft((previous) => ({
|
|
6321
|
+
...previous,
|
|
6322
|
+
change
|
|
6323
|
+
}))
|
|
6324
|
+
}),
|
|
6325
|
+
showChangeError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6326
|
+
role: "alert",
|
|
6327
|
+
className: "univer-text-red-500",
|
|
6328
|
+
children: localeService.t("sheets-formula-ui.calculation.invalidChange")
|
|
6329
|
+
})
|
|
6330
|
+
]
|
|
6331
|
+
}),
|
|
6332
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6333
|
+
className: "univer-flex univer-justify-end univer-gap-2",
|
|
6334
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
6335
|
+
onClick: close,
|
|
6336
|
+
children: localeService.t("sheets-formula-ui.calculation.cancel")
|
|
6337
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
6338
|
+
variant: "primary",
|
|
6339
|
+
disabled: readOnly,
|
|
6340
|
+
onClick: submit,
|
|
6341
|
+
children: localeService.t("sheets-formula-ui.calculation.confirm")
|
|
6342
|
+
})]
|
|
6343
|
+
})
|
|
6344
|
+
]
|
|
6345
|
+
});
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6191
6348
|
//#endregion
|
|
6192
6349
|
//#region src/views/formula-editor/hooks/use-formula-describe.ts
|
|
6193
6350
|
const useFormulaDescribe = (isNeed, formulaText, editor) => {
|
|
@@ -6427,10 +6584,6 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6427
6584
|
if (!isEnableMouseEnterOrOut.current) return;
|
|
6428
6585
|
setActive(index);
|
|
6429
6586
|
}
|
|
6430
|
-
function handleLiMouseLeave() {
|
|
6431
|
-
if (!isEnableMouseEnterOrOut.current) return;
|
|
6432
|
-
setActive(-1);
|
|
6433
|
-
}
|
|
6434
6587
|
(0, react.useEffect)(() => {
|
|
6435
6588
|
if (!searchList.length) return;
|
|
6436
6589
|
const operationId = `sheet.formula-embedding-editor.search_function.${editorId}`;
|
|
@@ -6455,7 +6608,7 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6455
6608
|
case _univerjs_ui.KeyCode.TAB:
|
|
6456
6609
|
case _univerjs_ui.KeyCode.ENTER: {
|
|
6457
6610
|
const item = searchList[active];
|
|
6458
|
-
handleFunctionSelect(item.name, item.functionType);
|
|
6611
|
+
if (item) handleFunctionSelect(item.name, item.functionType);
|
|
6459
6612
|
break;
|
|
6460
6613
|
}
|
|
6461
6614
|
case _univerjs_ui.KeyCode.ESC:
|
|
@@ -6537,7 +6690,6 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6537
6690
|
children: searchList.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
6538
6691
|
className: (0, _univerjs_design.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 }),
|
|
6539
6692
|
onMouseEnter: () => handleLiMouseEnter(index),
|
|
6540
|
-
onMouseLeave: handleLiMouseLeave,
|
|
6541
6693
|
onMouseMove: debounceResetMouseState,
|
|
6542
6694
|
onClick: () => {
|
|
6543
6695
|
handleFunctionSelect(item.name, item.functionType);
|
|
@@ -6764,6 +6916,7 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
6764
6916
|
element: formulaEditorContainer
|
|
6765
6917
|
}));
|
|
6766
6918
|
collection.add(registerFormulaEditorRuntimePortal({
|
|
6919
|
+
editorService,
|
|
6767
6920
|
embedId: scope.embedId,
|
|
6768
6921
|
editorId,
|
|
6769
6922
|
ownerDocument: formulaEditorContainer.ownerDocument,
|
|
@@ -6773,6 +6926,7 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
6773
6926
|
return () => collection.dispose();
|
|
6774
6927
|
}, [
|
|
6775
6928
|
editorId,
|
|
6929
|
+
editorService,
|
|
6776
6930
|
injector,
|
|
6777
6931
|
isFocus
|
|
6778
6932
|
]);
|
|
@@ -6866,10 +7020,9 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
6866
7020
|
highlight(`=${res.text}`);
|
|
6867
7021
|
}
|
|
6868
7022
|
};
|
|
6869
|
-
const handleMouseUp = (
|
|
7023
|
+
const handleMouseUp = () => {
|
|
6870
7024
|
if (hasActiveFormulaEmbedInteraction(formulaEditorContainerRef.current)) return;
|
|
6871
7025
|
if (!shouldRefocusFormulaEditorOnMouseUp({
|
|
6872
|
-
target: event.target,
|
|
6873
7026
|
isFocusing,
|
|
6874
7027
|
isPointerSelecting: docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isOnPointerEvent
|
|
6875
7028
|
})) return;
|
|
@@ -6942,6 +7095,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
6942
7095
|
}
|
|
6943
7096
|
_registerIcons() {
|
|
6944
7097
|
this.disposeWithMe(this._iconManager.register({
|
|
7098
|
+
CalculationOptionsIcon: _univerjs_icons.CalculationOptionsIcon,
|
|
6945
7099
|
DatabaseFunctionIcon: _univerjs_icons.DatabaseFunctionIcon,
|
|
6946
7100
|
DateFunctionIcon: _univerjs_icons.DateFunctionIcon,
|
|
6947
7101
|
EngineeringFunctionIcon: _univerjs_icons.EngineeringFunctionIcon,
|
|
@@ -6959,6 +7113,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
6959
7113
|
this.disposeWithMe(this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions));
|
|
6960
7114
|
this.disposeWithMe(this._componentManager.register(_univerjs_sheets_ui.RANGE_SELECTOR_COMPONENT_KEY, RangeSelector));
|
|
6961
7115
|
this.disposeWithMe(this._componentManager.register(_univerjs_sheets_ui.EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, FormulaEditor));
|
|
7116
|
+
this.disposeWithMe(this._componentManager.register(CALCULATION_OPTIONS_COMPONENT, CalculationOptions));
|
|
6962
7117
|
}
|
|
6963
7118
|
};
|
|
6964
7119
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
@@ -7042,7 +7197,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends _uni
|
|
|
7042
7197
|
[FormulaClipboardController],
|
|
7043
7198
|
[FormulaEditorShowController],
|
|
7044
7199
|
[FormulaRenderManagerController],
|
|
7045
|
-
[FormulaReorderController],
|
|
7046
7200
|
[ImageFormulaRenderController]
|
|
7047
7201
|
]);
|
|
7048
7202
|
this._initUIPart();
|
|
@@ -7064,9 +7218,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends _uni
|
|
|
7064
7218
|
[ImageFormulaRenderController]
|
|
7065
7219
|
]);
|
|
7066
7220
|
}
|
|
7067
|
-
onSteady() {
|
|
7068
|
-
this._injector.get(FormulaReorderController);
|
|
7069
|
-
}
|
|
7070
7221
|
_initUIPart() {
|
|
7071
7222
|
this.disposeWithMe(this._uiPartsService.registerComponent(_univerjs_ui.BuiltInUIPart.GLOBAL, () => (0, _univerjs_ui.connectInjector)(GlobalRangeSelector, this._injector)));
|
|
7072
7223
|
}
|
|
@@ -7086,19 +7237,14 @@ UniverSheetsFormulaUIPlugin = __decorate([
|
|
|
7086
7237
|
//#endregion
|
|
7087
7238
|
exports.FORMULA_PROMPT_ACTIVATED = FORMULA_PROMPT_ACTIVATED;
|
|
7088
7239
|
exports.FormulaEditor = FormulaEditor;
|
|
7089
|
-
Object.defineProperty(exports, 'FormulaReorderController', {
|
|
7090
|
-
enumerable: true,
|
|
7091
|
-
get: function () {
|
|
7092
|
-
return FormulaReorderController;
|
|
7093
|
-
}
|
|
7094
|
-
});
|
|
7095
7240
|
exports.GlobalRangeSelectorService = GlobalRangeSelectorService;
|
|
7096
7241
|
exports.HelpFunctionOperation = HelpFunctionOperation;
|
|
7097
7242
|
exports.InsertFunctionOperation = InsertFunctionOperation;
|
|
7243
|
+
exports.MORE_FUNCTIONS_COMPONENT = MORE_FUNCTIONS_COMPONENT;
|
|
7098
7244
|
exports.MobileRangeSelector = MobileRangeSelector;
|
|
7099
7245
|
exports.MoreFunctionsOperation = MoreFunctionsOperation;
|
|
7100
7246
|
exports.RangeSelector = RangeSelector;
|
|
7101
|
-
Object.defineProperty(exports,
|
|
7247
|
+
Object.defineProperty(exports, "RefSelectionsRenderService", {
|
|
7102
7248
|
enumerable: true,
|
|
7103
7249
|
get: function () {
|
|
7104
7250
|
return RefSelectionsRenderService;
|
|
@@ -7109,13 +7255,13 @@ exports.SearchFunctionOperation = SearchFunctionOperation;
|
|
|
7109
7255
|
exports.SheetCopyFormulaOnlyCommand = SheetCopyFormulaOnlyCommand;
|
|
7110
7256
|
exports.SheetOnlyPasteFormulaCommand = SheetOnlyPasteFormulaCommand;
|
|
7111
7257
|
exports.SheetsFormulaUIMenuSchema = menuSchema;
|
|
7112
|
-
Object.defineProperty(exports,
|
|
7258
|
+
Object.defineProperty(exports, "UniverSheetsFormulaMobileUIPlugin", {
|
|
7113
7259
|
enumerable: true,
|
|
7114
7260
|
get: function () {
|
|
7115
7261
|
return UniverSheetsFormulaMobileUIPlugin;
|
|
7116
7262
|
}
|
|
7117
7263
|
});
|
|
7118
|
-
Object.defineProperty(exports,
|
|
7264
|
+
Object.defineProperty(exports, "UniverSheetsFormulaUIPlugin", {
|
|
7119
7265
|
enumerable: true,
|
|
7120
7266
|
get: function () {
|
|
7121
7267
|
return UniverSheetsFormulaUIPlugin;
|