@univerjs/sheets-formula-ui 0.21.1 → 0.22.0-insiders.20260513-09bbeca
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/README.md +26 -23
- package/lib/cjs/index.js +21 -29
- package/lib/es/index.js +21 -29
- package/lib/index.js +21 -29
- package/lib/types/services/prompt.service.d.ts +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +22 -17
- package/LICENSE +0 -176
package/README.md
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
# @univerjs/sheets-formula-ui
|
|
2
2
|
|
|
3
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula-ui)
|
|
4
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula-ui)
|
|
5
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula-ui)
|
|
6
|
+
|
|
7
|
+
`@univerjs/sheets-formula-ui` adds formula editing UI for Univer Sheets, including formula input, suggestions, highlighting, and range selection.
|
|
8
|
+
|
|
3
9
|
## Package Overview
|
|
4
10
|
|
|
5
|
-
| Package
|
|
6
|
-
| --- | --- |
|
|
7
|
-
| `@univerjs/sheets-formula-ui` | `UniverSheetsFormulaUi` |
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/sheets-formula-ui` | `UniverSheetsFormulaUi` | Yes | Yes | Yes |
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## Installation
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @univerjs/sheets-formula-ui
|
|
19
|
+
# or
|
|
20
|
+
npm install @univerjs/sheets-formula-ui
|
|
21
|
+
```
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
> Formula calculation is one of the core functionalities of spreadsheets, and formula calculation scheduling is done in `@univerjs/sheets`.
|
|
23
|
+
Keep all `@univerjs/*` packages on the same version.
|
|
15
24
|
|
|
16
25
|
## Usage
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
```ts
|
|
28
|
+
import '@univerjs/sheets-formula-ui/lib/index.css';
|
|
29
|
+
import EnUS from '@univerjs/sheets-formula-ui/locale/en-US';
|
|
30
|
+
import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
# Using npm
|
|
22
|
-
npm install @univerjs/sheets-formula-ui
|
|
32
|
+
univer.registerPlugin(UniverSheetsFormulaUIPlugin);
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
pnpm add @univerjs/sheets-formula-ui
|
|
34
|
+
// Merge EnUS into your Univer locale map when this package contributes UI text.
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
If the officially provided formula does not meet your needs, you can expand the formula yourself. Depending on different needs, we provide multiple ways to support registering one or more custom formulas.
|
|
37
|
+
## Resources
|
|
31
38
|
|
|
32
|
-
- [
|
|
33
|
-
- [
|
|
39
|
+
- [Documentation](https://docs.univer.ai)
|
|
40
|
+
- [NPM package](https://npmjs.com/package/@univerjs/sheets-formula-ui)
|
|
41
|
+
- [GitHub repository](https://github.com/dream-num/univer)
|
|
34
42
|
|
|
35
|
-
<!-- Links -->
|
|
36
|
-
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-formula?style=flat-square
|
|
37
|
-
[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-formula
|
|
38
|
-
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-formula?style=flat-square
|
|
39
|
-
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-formula?style=flat-square
|
package/lib/cjs/index.js
CHANGED
|
@@ -32,7 +32,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region \0@oxc-project+runtime@0.
|
|
35
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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.
|
|
46
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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.
|
|
66
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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.
|
|
85
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/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);
|
|
@@ -781,7 +781,7 @@ FormulaReorderController = __decorate([
|
|
|
781
781
|
//#endregion
|
|
782
782
|
//#region package.json
|
|
783
783
|
var name = "@univerjs/sheets-formula-ui";
|
|
784
|
-
var version = "0.
|
|
784
|
+
var version = "0.22.0-insiders.20260513-09bbeca";
|
|
785
785
|
|
|
786
786
|
//#endregion
|
|
787
787
|
//#region src/config/config.ts
|
|
@@ -2883,14 +2883,6 @@ function getCurrentBodyDataStreamAndOffset(accssor) {
|
|
|
2883
2883
|
offset: 0
|
|
2884
2884
|
};
|
|
2885
2885
|
}
|
|
2886
|
-
let FormulaSelectingType = /* @__PURE__ */ function(FormulaSelectingType) {
|
|
2887
|
-
FormulaSelectingType[FormulaSelectingType["NOT_SELECT"] = 0] = "NOT_SELECT";
|
|
2888
|
-
FormulaSelectingType[FormulaSelectingType["NEED_ADD"] = 1] = "NEED_ADD";
|
|
2889
|
-
FormulaSelectingType[FormulaSelectingType["CAN_EDIT"] = 2] = "CAN_EDIT";
|
|
2890
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_SHEET_REFERENCE"] = 3] = "EDIT_OTHER_SHEET_REFERENCE";
|
|
2891
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_WORKBOOK_REFERENCE"] = 4] = "EDIT_OTHER_WORKBOOK_REFERENCE";
|
|
2892
|
-
return FormulaSelectingType;
|
|
2893
|
-
}({});
|
|
2894
2886
|
function useFormulaSelecting(opts) {
|
|
2895
2887
|
var _renderer$mainCompone2;
|
|
2896
2888
|
const { editorId, isFocus, disableOnClick, unitId, subUnitId } = opts;
|
|
@@ -2901,7 +2893,7 @@ function useFormulaSelecting(opts) {
|
|
|
2901
2893
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(_univerjs_docs_ui.DocSelectionRenderService);
|
|
2902
2894
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
2903
2895
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
2904
|
-
const [isSelecting, innerSetIsSelecting] = (0, react.useState)(
|
|
2896
|
+
const [isSelecting, innerSetIsSelecting] = (0, react.useState)(0);
|
|
2905
2897
|
const lexerTreeBuilder = (0, _univerjs_ui.useDependency)(_univerjs_engine_formula.LexerTreeBuilder);
|
|
2906
2898
|
const isDisabledByPointer = (0, react.useRef)(true);
|
|
2907
2899
|
const refSelectionsRenderService = sheetRenderer === null || sheetRenderer === void 0 ? void 0 : sheetRenderer.with(RefSelectionsRenderService);
|
|
@@ -2909,7 +2901,7 @@ function useFormulaSelecting(opts) {
|
|
|
2909
2901
|
const workbook = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2910
2902
|
const sourceSheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
2911
2903
|
const setIsSelecting = (0, _univerjs_ui.useEvent)((v) => {
|
|
2912
|
-
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v ===
|
|
2904
|
+
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v === 1 || v === 3 || v === 4);
|
|
2913
2905
|
isSelectingRef.current = v;
|
|
2914
2906
|
innerSetIsSelecting(v);
|
|
2915
2907
|
});
|
|
@@ -2946,14 +2938,14 @@ function useFormulaSelecting(opts) {
|
|
|
2946
2938
|
if (isDisabledByPointer.current) return;
|
|
2947
2939
|
const { sheetName, unitId } = focusingNode.range;
|
|
2948
2940
|
const currentUnitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
2949
|
-
if (unitId && unitId !== currentUnitId) setIsSelecting(
|
|
2950
|
-
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(
|
|
2951
|
-
else setIsSelecting(
|
|
2941
|
+
if (unitId && unitId !== currentUnitId) setIsSelecting(4);
|
|
2942
|
+
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(2);
|
|
2943
|
+
else setIsSelecting(3);
|
|
2952
2944
|
} else {
|
|
2953
2945
|
isDisabledByPointer.current = false;
|
|
2954
|
-
setIsSelecting(
|
|
2946
|
+
setIsSelecting(1);
|
|
2955
2947
|
}
|
|
2956
|
-
else setIsSelecting(
|
|
2948
|
+
else setIsSelecting(0);
|
|
2957
2949
|
});
|
|
2958
2950
|
(0, react.useEffect)(() => {
|
|
2959
2951
|
const sub = docSelectionManagerService.textSelection$.pipe((0, rxjs.filter)((param) => param.unitId === editorId)).subscribe(() => {
|
|
@@ -2967,7 +2959,7 @@ function useFormulaSelecting(opts) {
|
|
|
2967
2959
|
]);
|
|
2968
2960
|
(0, react.useEffect)(() => {
|
|
2969
2961
|
if (!isFocus) {
|
|
2970
|
-
setIsSelecting(
|
|
2962
|
+
setIsSelecting(0);
|
|
2971
2963
|
isDisabledByPointer.current = true;
|
|
2972
2964
|
}
|
|
2973
2965
|
}, [isFocus, setIsSelecting]);
|
|
@@ -2975,7 +2967,7 @@ function useFormulaSelecting(opts) {
|
|
|
2975
2967
|
var _renderer$mainCompone;
|
|
2976
2968
|
if (!disableOnClick) return;
|
|
2977
2969
|
const sub = renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.onPointerDown$.subscribeEvent(() => {
|
|
2978
|
-
setIsSelecting(
|
|
2970
|
+
setIsSelecting(0);
|
|
2979
2971
|
isDisabledByPointer.current = true;
|
|
2980
2972
|
});
|
|
2981
2973
|
return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
@@ -3318,7 +3310,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3318
3310
|
direction,
|
|
3319
3311
|
jumpOver: _univerjs_sheets_ui.JumpOver.moveGap,
|
|
3320
3312
|
extra: "formula-editor",
|
|
3321
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3313
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3322
3314
|
});
|
|
3323
3315
|
else if (metaKey === _univerjs_ui.MetaKeys.SHIFT) commandService.executeCommand(_univerjs_sheets_ui.ExpandSelectionCommand.id, {
|
|
3324
3316
|
direction,
|
|
@@ -3332,7 +3324,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3332
3324
|
else commandService.executeCommand(_univerjs_sheets_ui.MoveSelectionCommand.id, {
|
|
3333
3325
|
direction,
|
|
3334
3326
|
extra: "formula-editor",
|
|
3335
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3327
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3336
3328
|
});
|
|
3337
3329
|
else handleMoveInEditor(keycode, metaKey);
|
|
3338
3330
|
};
|
|
@@ -3573,7 +3565,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3573
3565
|
});
|
|
3574
3566
|
if (!ctx) return;
|
|
3575
3567
|
const { nodeIndex, updatingRefIndex, sequenceNodes, offset } = ctx;
|
|
3576
|
-
if (isSelectingRef.current ===
|
|
3568
|
+
if (isSelectingRef.current === 1) if (offset !== 0) {
|
|
3577
3569
|
var _range$sheetId, _range$unitId, _range$unitId2;
|
|
3578
3570
|
if (nodeIndex === -1 && sequenceNodes.length) return;
|
|
3579
3571
|
const range = selections[selections.length - 1];
|
|
@@ -3610,7 +3602,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3610
3602
|
});
|
|
3611
3603
|
handleRangeChange(sequenceNodeToText(sequenceNodes), refRanges[0].length, isEnd);
|
|
3612
3604
|
}
|
|
3613
|
-
else if (isSelectingRef.current ===
|
|
3605
|
+
else if (isSelectingRef.current === 3 || isSelectingRef.current === 4) {
|
|
3614
3606
|
const last = selections.pop();
|
|
3615
3607
|
if (!last) return;
|
|
3616
3608
|
const node = sequenceNodes[nodeIndex];
|
|
@@ -3770,7 +3762,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3770
3762
|
}
|
|
3771
3763
|
range.unitId = params.unitId;
|
|
3772
3764
|
range.sheetId = params.subUnitId;
|
|
3773
|
-
const isAdd = isSelectingRef.current ===
|
|
3765
|
+
const isAdd = isSelectingRef.current === 1;
|
|
3774
3766
|
const selections = ((_refSelectionsRenderS = refSelectionsRenderService === null || refSelectionsRenderService === void 0 ? void 0 : refSelectionsRenderService.getSelectionDataWithStyle()) !== null && _refSelectionsRenderS !== void 0 ? _refSelectionsRenderS : []).map((i) => i.rangeWithCoord);
|
|
3775
3767
|
if (isAdd) selections.push(range);
|
|
3776
3768
|
else selections[selections.length - 1] = range;
|
package/lib/es/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
35
35
|
function _typeof(o) {
|
|
36
36
|
"@babel/helpers - typeof";
|
|
37
37
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -42,7 +42,7 @@ function _typeof(o) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region \0@oxc-project+runtime@0.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
46
46
|
function toPrimitive(t, r) {
|
|
47
47
|
if ("object" != _typeof(t) || !t) return t;
|
|
48
48
|
var e = t[Symbol.toPrimitive];
|
|
@@ -55,14 +55,14 @@ function toPrimitive(t, r) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
59
59
|
function toPropertyKey(t) {
|
|
60
60
|
var i = toPrimitive(t, "string");
|
|
61
61
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
66
66
|
function _defineProperty(e, r, t) {
|
|
67
67
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
68
68
|
value: t,
|
|
@@ -73,7 +73,7 @@ function _defineProperty(e, r, t) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
77
77
|
function __decorateParam(paramIndex, decorator) {
|
|
78
78
|
return function(target, key) {
|
|
79
79
|
decorator(target, key, paramIndex);
|
|
@@ -81,7 +81,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
84
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
85
85
|
function __decorate(decorators, target, key, desc) {
|
|
86
86
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
87
87
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -780,7 +780,7 @@ FormulaReorderController = __decorate([
|
|
|
780
780
|
//#endregion
|
|
781
781
|
//#region package.json
|
|
782
782
|
var name = "@univerjs/sheets-formula-ui";
|
|
783
|
-
var version = "0.
|
|
783
|
+
var version = "0.22.0-insiders.20260513-09bbeca";
|
|
784
784
|
|
|
785
785
|
//#endregion
|
|
786
786
|
//#region src/config/config.ts
|
|
@@ -2882,14 +2882,6 @@ function getCurrentBodyDataStreamAndOffset(accssor) {
|
|
|
2882
2882
|
offset: 0
|
|
2883
2883
|
};
|
|
2884
2884
|
}
|
|
2885
|
-
let FormulaSelectingType = /* @__PURE__ */ function(FormulaSelectingType) {
|
|
2886
|
-
FormulaSelectingType[FormulaSelectingType["NOT_SELECT"] = 0] = "NOT_SELECT";
|
|
2887
|
-
FormulaSelectingType[FormulaSelectingType["NEED_ADD"] = 1] = "NEED_ADD";
|
|
2888
|
-
FormulaSelectingType[FormulaSelectingType["CAN_EDIT"] = 2] = "CAN_EDIT";
|
|
2889
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_SHEET_REFERENCE"] = 3] = "EDIT_OTHER_SHEET_REFERENCE";
|
|
2890
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_WORKBOOK_REFERENCE"] = 4] = "EDIT_OTHER_WORKBOOK_REFERENCE";
|
|
2891
|
-
return FormulaSelectingType;
|
|
2892
|
-
}({});
|
|
2893
2885
|
function useFormulaSelecting(opts) {
|
|
2894
2886
|
var _renderer$mainCompone2;
|
|
2895
2887
|
const { editorId, isFocus, disableOnClick, unitId, subUnitId } = opts;
|
|
@@ -2900,7 +2892,7 @@ function useFormulaSelecting(opts) {
|
|
|
2900
2892
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
2901
2893
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
2902
2894
|
const injector = useDependency(Injector);
|
|
2903
|
-
const [isSelecting, innerSetIsSelecting] = useState(
|
|
2895
|
+
const [isSelecting, innerSetIsSelecting] = useState(0);
|
|
2904
2896
|
const lexerTreeBuilder = useDependency(LexerTreeBuilder);
|
|
2905
2897
|
const isDisabledByPointer = useRef(true);
|
|
2906
2898
|
const refSelectionsRenderService = sheetRenderer === null || sheetRenderer === void 0 ? void 0 : sheetRenderer.with(RefSelectionsRenderService);
|
|
@@ -2908,7 +2900,7 @@ function useFormulaSelecting(opts) {
|
|
|
2908
2900
|
const workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
2909
2901
|
const sourceSheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
2910
2902
|
const setIsSelecting = useEvent((v) => {
|
|
2911
|
-
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v ===
|
|
2903
|
+
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v === 1 || v === 3 || v === 4);
|
|
2912
2904
|
isSelectingRef.current = v;
|
|
2913
2905
|
innerSetIsSelecting(v);
|
|
2914
2906
|
});
|
|
@@ -2945,14 +2937,14 @@ function useFormulaSelecting(opts) {
|
|
|
2945
2937
|
if (isDisabledByPointer.current) return;
|
|
2946
2938
|
const { sheetName, unitId } = focusingNode.range;
|
|
2947
2939
|
const currentUnitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
2948
|
-
if (unitId && unitId !== currentUnitId) setIsSelecting(
|
|
2949
|
-
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(
|
|
2950
|
-
else setIsSelecting(
|
|
2940
|
+
if (unitId && unitId !== currentUnitId) setIsSelecting(4);
|
|
2941
|
+
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(2);
|
|
2942
|
+
else setIsSelecting(3);
|
|
2951
2943
|
} else {
|
|
2952
2944
|
isDisabledByPointer.current = false;
|
|
2953
|
-
setIsSelecting(
|
|
2945
|
+
setIsSelecting(1);
|
|
2954
2946
|
}
|
|
2955
|
-
else setIsSelecting(
|
|
2947
|
+
else setIsSelecting(0);
|
|
2956
2948
|
});
|
|
2957
2949
|
useEffect(() => {
|
|
2958
2950
|
const sub = docSelectionManagerService.textSelection$.pipe(filter((param) => param.unitId === editorId)).subscribe(() => {
|
|
@@ -2966,7 +2958,7 @@ function useFormulaSelecting(opts) {
|
|
|
2966
2958
|
]);
|
|
2967
2959
|
useEffect(() => {
|
|
2968
2960
|
if (!isFocus) {
|
|
2969
|
-
setIsSelecting(
|
|
2961
|
+
setIsSelecting(0);
|
|
2970
2962
|
isDisabledByPointer.current = true;
|
|
2971
2963
|
}
|
|
2972
2964
|
}, [isFocus, setIsSelecting]);
|
|
@@ -2974,7 +2966,7 @@ function useFormulaSelecting(opts) {
|
|
|
2974
2966
|
var _renderer$mainCompone;
|
|
2975
2967
|
if (!disableOnClick) return;
|
|
2976
2968
|
const sub = renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.onPointerDown$.subscribeEvent(() => {
|
|
2977
|
-
setIsSelecting(
|
|
2969
|
+
setIsSelecting(0);
|
|
2978
2970
|
isDisabledByPointer.current = true;
|
|
2979
2971
|
});
|
|
2980
2972
|
return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
@@ -3317,7 +3309,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3317
3309
|
direction,
|
|
3318
3310
|
jumpOver: JumpOver.moveGap,
|
|
3319
3311
|
extra: "formula-editor",
|
|
3320
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3312
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3321
3313
|
});
|
|
3322
3314
|
else if (metaKey === MetaKeys.SHIFT) commandService.executeCommand(ExpandSelectionCommand.id, {
|
|
3323
3315
|
direction,
|
|
@@ -3331,7 +3323,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3331
3323
|
else commandService.executeCommand(MoveSelectionCommand.id, {
|
|
3332
3324
|
direction,
|
|
3333
3325
|
extra: "formula-editor",
|
|
3334
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3326
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3335
3327
|
});
|
|
3336
3328
|
else handleMoveInEditor(keycode, metaKey);
|
|
3337
3329
|
};
|
|
@@ -3572,7 +3564,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3572
3564
|
});
|
|
3573
3565
|
if (!ctx) return;
|
|
3574
3566
|
const { nodeIndex, updatingRefIndex, sequenceNodes, offset } = ctx;
|
|
3575
|
-
if (isSelectingRef.current ===
|
|
3567
|
+
if (isSelectingRef.current === 1) if (offset !== 0) {
|
|
3576
3568
|
var _range$sheetId, _range$unitId, _range$unitId2;
|
|
3577
3569
|
if (nodeIndex === -1 && sequenceNodes.length) return;
|
|
3578
3570
|
const range = selections[selections.length - 1];
|
|
@@ -3609,7 +3601,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3609
3601
|
});
|
|
3610
3602
|
handleRangeChange(sequenceNodeToText(sequenceNodes), refRanges[0].length, isEnd);
|
|
3611
3603
|
}
|
|
3612
|
-
else if (isSelectingRef.current ===
|
|
3604
|
+
else if (isSelectingRef.current === 3 || isSelectingRef.current === 4) {
|
|
3613
3605
|
const last = selections.pop();
|
|
3614
3606
|
if (!last) return;
|
|
3615
3607
|
const node = sequenceNodes[nodeIndex];
|
|
@@ -3769,7 +3761,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3769
3761
|
}
|
|
3770
3762
|
range.unitId = params.unitId;
|
|
3771
3763
|
range.sheetId = params.subUnitId;
|
|
3772
|
-
const isAdd = isSelectingRef.current ===
|
|
3764
|
+
const isAdd = isSelectingRef.current === 1;
|
|
3773
3765
|
const selections = ((_refSelectionsRenderS = refSelectionsRenderService === null || refSelectionsRenderService === void 0 ? void 0 : refSelectionsRenderService.getSelectionDataWithStyle()) !== null && _refSelectionsRenderS !== void 0 ? _refSelectionsRenderS : []).map((i) => i.rangeWithCoord);
|
|
3774
3766
|
if (isAdd) selections.push(range);
|
|
3775
3767
|
else selections[selections.length - 1] = range;
|
package/lib/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
35
35
|
function _typeof(o) {
|
|
36
36
|
"@babel/helpers - typeof";
|
|
37
37
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -42,7 +42,7 @@ function _typeof(o) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region \0@oxc-project+runtime@0.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
46
46
|
function toPrimitive(t, r) {
|
|
47
47
|
if ("object" != _typeof(t) || !t) return t;
|
|
48
48
|
var e = t[Symbol.toPrimitive];
|
|
@@ -55,14 +55,14 @@ function toPrimitive(t, r) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
59
59
|
function toPropertyKey(t) {
|
|
60
60
|
var i = toPrimitive(t, "string");
|
|
61
61
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
66
66
|
function _defineProperty(e, r, t) {
|
|
67
67
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
68
68
|
value: t,
|
|
@@ -73,7 +73,7 @@ function _defineProperty(e, r, t) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
77
77
|
function __decorateParam(paramIndex, decorator) {
|
|
78
78
|
return function(target, key) {
|
|
79
79
|
decorator(target, key, paramIndex);
|
|
@@ -81,7 +81,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
84
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
85
85
|
function __decorate(decorators, target, key, desc) {
|
|
86
86
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
87
87
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -780,7 +780,7 @@ FormulaReorderController = __decorate([
|
|
|
780
780
|
//#endregion
|
|
781
781
|
//#region package.json
|
|
782
782
|
var name = "@univerjs/sheets-formula-ui";
|
|
783
|
-
var version = "0.
|
|
783
|
+
var version = "0.22.0-insiders.20260513-09bbeca";
|
|
784
784
|
|
|
785
785
|
//#endregion
|
|
786
786
|
//#region src/config/config.ts
|
|
@@ -2882,14 +2882,6 @@ function getCurrentBodyDataStreamAndOffset(accssor) {
|
|
|
2882
2882
|
offset: 0
|
|
2883
2883
|
};
|
|
2884
2884
|
}
|
|
2885
|
-
let FormulaSelectingType = /* @__PURE__ */ function(FormulaSelectingType) {
|
|
2886
|
-
FormulaSelectingType[FormulaSelectingType["NOT_SELECT"] = 0] = "NOT_SELECT";
|
|
2887
|
-
FormulaSelectingType[FormulaSelectingType["NEED_ADD"] = 1] = "NEED_ADD";
|
|
2888
|
-
FormulaSelectingType[FormulaSelectingType["CAN_EDIT"] = 2] = "CAN_EDIT";
|
|
2889
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_SHEET_REFERENCE"] = 3] = "EDIT_OTHER_SHEET_REFERENCE";
|
|
2890
|
-
FormulaSelectingType[FormulaSelectingType["EDIT_OTHER_WORKBOOK_REFERENCE"] = 4] = "EDIT_OTHER_WORKBOOK_REFERENCE";
|
|
2891
|
-
return FormulaSelectingType;
|
|
2892
|
-
}({});
|
|
2893
2885
|
function useFormulaSelecting(opts) {
|
|
2894
2886
|
var _renderer$mainCompone2;
|
|
2895
2887
|
const { editorId, isFocus, disableOnClick, unitId, subUnitId } = opts;
|
|
@@ -2900,7 +2892,7 @@ function useFormulaSelecting(opts) {
|
|
|
2900
2892
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
2901
2893
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
2902
2894
|
const injector = useDependency(Injector);
|
|
2903
|
-
const [isSelecting, innerSetIsSelecting] = useState(
|
|
2895
|
+
const [isSelecting, innerSetIsSelecting] = useState(0);
|
|
2904
2896
|
const lexerTreeBuilder = useDependency(LexerTreeBuilder);
|
|
2905
2897
|
const isDisabledByPointer = useRef(true);
|
|
2906
2898
|
const refSelectionsRenderService = sheetRenderer === null || sheetRenderer === void 0 ? void 0 : sheetRenderer.with(RefSelectionsRenderService);
|
|
@@ -2908,7 +2900,7 @@ function useFormulaSelecting(opts) {
|
|
|
2908
2900
|
const workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
2909
2901
|
const sourceSheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
2910
2902
|
const setIsSelecting = useEvent((v) => {
|
|
2911
|
-
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v ===
|
|
2903
|
+
if (refSelectionsRenderService) refSelectionsRenderService.setSkipLastEnabled(v === 1 || v === 3 || v === 4);
|
|
2912
2904
|
isSelectingRef.current = v;
|
|
2913
2905
|
innerSetIsSelecting(v);
|
|
2914
2906
|
});
|
|
@@ -2945,14 +2937,14 @@ function useFormulaSelecting(opts) {
|
|
|
2945
2937
|
if (isDisabledByPointer.current) return;
|
|
2946
2938
|
const { sheetName, unitId } = focusingNode.range;
|
|
2947
2939
|
const currentUnitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
2948
|
-
if (unitId && unitId !== currentUnitId) setIsSelecting(
|
|
2949
|
-
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(
|
|
2950
|
-
else setIsSelecting(
|
|
2940
|
+
if (unitId && unitId !== currentUnitId) setIsSelecting(4);
|
|
2941
|
+
else if (!sheetName && currentSheet.getSheetId() === (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.getSheetId()) || sheetName === currentSheet.getName()) setIsSelecting(2);
|
|
2942
|
+
else setIsSelecting(3);
|
|
2951
2943
|
} else {
|
|
2952
2944
|
isDisabledByPointer.current = false;
|
|
2953
|
-
setIsSelecting(
|
|
2945
|
+
setIsSelecting(1);
|
|
2954
2946
|
}
|
|
2955
|
-
else setIsSelecting(
|
|
2947
|
+
else setIsSelecting(0);
|
|
2956
2948
|
});
|
|
2957
2949
|
useEffect(() => {
|
|
2958
2950
|
const sub = docSelectionManagerService.textSelection$.pipe(filter((param) => param.unitId === editorId)).subscribe(() => {
|
|
@@ -2966,7 +2958,7 @@ function useFormulaSelecting(opts) {
|
|
|
2966
2958
|
]);
|
|
2967
2959
|
useEffect(() => {
|
|
2968
2960
|
if (!isFocus) {
|
|
2969
|
-
setIsSelecting(
|
|
2961
|
+
setIsSelecting(0);
|
|
2970
2962
|
isDisabledByPointer.current = true;
|
|
2971
2963
|
}
|
|
2972
2964
|
}, [isFocus, setIsSelecting]);
|
|
@@ -2974,7 +2966,7 @@ function useFormulaSelecting(opts) {
|
|
|
2974
2966
|
var _renderer$mainCompone;
|
|
2975
2967
|
if (!disableOnClick) return;
|
|
2976
2968
|
const sub = renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.onPointerDown$.subscribeEvent(() => {
|
|
2977
|
-
setIsSelecting(
|
|
2969
|
+
setIsSelecting(0);
|
|
2978
2970
|
isDisabledByPointer.current = true;
|
|
2979
2971
|
});
|
|
2980
2972
|
return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
@@ -3317,7 +3309,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3317
3309
|
direction,
|
|
3318
3310
|
jumpOver: JumpOver.moveGap,
|
|
3319
3311
|
extra: "formula-editor",
|
|
3320
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3312
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3321
3313
|
});
|
|
3322
3314
|
else if (metaKey === MetaKeys.SHIFT) commandService.executeCommand(ExpandSelectionCommand.id, {
|
|
3323
3315
|
direction,
|
|
@@ -3331,7 +3323,7 @@ const useLeftAndRightArrow = (isNeed, shouldMoveSelection, editor, onMoveInEdito
|
|
|
3331
3323
|
else commandService.executeCommand(MoveSelectionCommand.id, {
|
|
3332
3324
|
direction,
|
|
3333
3325
|
extra: "formula-editor",
|
|
3334
|
-
fromCurrentSelection: shouldMoveSelectionRef.current ===
|
|
3326
|
+
fromCurrentSelection: shouldMoveSelectionRef.current === 1 || shouldMoveSelectionRef.current === 3
|
|
3335
3327
|
});
|
|
3336
3328
|
else handleMoveInEditor(keycode, metaKey);
|
|
3337
3329
|
};
|
|
@@ -3572,7 +3564,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3572
3564
|
});
|
|
3573
3565
|
if (!ctx) return;
|
|
3574
3566
|
const { nodeIndex, updatingRefIndex, sequenceNodes, offset } = ctx;
|
|
3575
|
-
if (isSelectingRef.current ===
|
|
3567
|
+
if (isSelectingRef.current === 1) if (offset !== 0) {
|
|
3576
3568
|
var _range$sheetId, _range$unitId, _range$unitId2;
|
|
3577
3569
|
if (nodeIndex === -1 && sequenceNodes.length) return;
|
|
3578
3570
|
const range = selections[selections.length - 1];
|
|
@@ -3609,7 +3601,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3609
3601
|
});
|
|
3610
3602
|
handleRangeChange(sequenceNodeToText(sequenceNodes), refRanges[0].length, isEnd);
|
|
3611
3603
|
}
|
|
3612
|
-
else if (isSelectingRef.current ===
|
|
3604
|
+
else if (isSelectingRef.current === 3 || isSelectingRef.current === 4) {
|
|
3613
3605
|
const last = selections.pop();
|
|
3614
3606
|
if (!last) return;
|
|
3615
3607
|
const node = sequenceNodes[nodeIndex];
|
|
@@ -3769,7 +3761,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3769
3761
|
}
|
|
3770
3762
|
range.unitId = params.unitId;
|
|
3771
3763
|
range.sheetId = params.subUnitId;
|
|
3772
|
-
const isAdd = isSelectingRef.current ===
|
|
3764
|
+
const isAdd = isSelectingRef.current === 1;
|
|
3773
3765
|
const selections = ((_refSelectionsRenderS = refSelectionsRenderService === null || refSelectionsRenderService === void 0 ? void 0 : refSelectionsRenderService.getSelectionDataWithStyle()) !== null && _refSelectionsRenderS !== void 0 ? _refSelectionsRenderS : []).map((i) => i.rangeWithCoord);
|
|
3774
3766
|
if (isAdd) selections.push(range);
|
|
3775
3767
|
else selections[selections.length - 1] = range;
|
|
@@ -111,7 +111,7 @@ export interface IFormulaPromptService {
|
|
|
111
111
|
disableLockedSelectionInsert(): void;
|
|
112
112
|
isLockedSelectionInsert(): boolean;
|
|
113
113
|
}
|
|
114
|
-
export declare const IFormulaPromptService: import("@wendellhu/redi").IdentifierDecorator<
|
|
114
|
+
export declare const IFormulaPromptService: import("@wendellhu/redi").IdentifierDecorator<IFormulaPromptService>;
|
|
115
115
|
export declare class FormulaPromptService implements IFormulaPromptService, IDisposable {
|
|
116
116
|
private readonly _contextService;
|
|
117
117
|
private readonly _search$;
|