@univerjs/sheets-formula 0.1.0-alpha.1 → 0.1.0-alpha.2
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/LICENSE.txt +178 -0
- package/lib/cjs/index.js +11 -4215
- package/lib/es/index.js +4346 -0
- package/lib/index.css +1 -214
- package/lib/types/commands/commands/formula-clipboard.command.d.ts +18 -0
- package/lib/types/commands/commands/insert-function.command.d.ts +15 -1
- package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts +15 -1
- package/lib/types/commands/operations/editor-formula.operation.d.ts +15 -1
- package/lib/types/commands/operations/help-function.operation.d.ts +15 -1
- package/lib/types/commands/operations/insert-function.operation.d.ts +15 -1
- package/lib/types/commands/operations/more-functions.operation.d.ts +15 -1
- package/lib/types/commands/operations/reference-absolute.operation.d.ts +15 -1
- package/lib/types/commands/operations/search-function.operation.d.ts +15 -1
- package/lib/types/common/plugin-name.d.ts +15 -1
- package/lib/types/common/prompt.d.ts +15 -1
- package/lib/types/common/selection.d.ts +15 -1
- package/lib/types/controllers/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts +15 -1
- package/lib/types/controllers/__tests__/formula-clipboard.controller.spec.d.ts +16 -0
- package/lib/types/controllers/__tests__/update-formula.controller.spec.d.ts +16 -0
- package/lib/types/controllers/__tests__/utils.spec.d.ts +16 -0
- package/lib/types/controllers/active-dirty.controller.d.ts +40 -0
- package/lib/types/controllers/array-formula-display.controller.d.ts +27 -0
- package/lib/types/controllers/formula-auto-fill.controller.d.ts +18 -4
- package/lib/types/controllers/formula-clipboard.controller.d.ts +41 -0
- package/lib/types/controllers/formula-editor-show.controller.d.ts +35 -0
- package/lib/types/controllers/formula-input.controller.d.ts +18 -4
- package/lib/types/controllers/formula-ui.controller.d.ts +15 -1
- package/lib/types/controllers/menu.d.ts +16 -1
- package/lib/types/controllers/prompt.controller.d.ts +18 -4
- package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts +15 -1
- package/lib/types/controllers/trigger-calculation.controller.d.ts +32 -0
- package/lib/types/controllers/update-formula.controller.d.ts +75 -0
- package/lib/types/controllers/utils.d.ts +26 -0
- package/lib/types/formula-ui-plugin.d.ts +16 -2
- package/lib/types/index.d.ts +17 -2
- package/lib/types/locale/en-US.d.ts +18 -1
- package/lib/types/locale/function-list/array/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/array/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/compatibility/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/compatibility/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/cube/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/cube/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/database/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/database/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/date/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/date/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/engineering/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/engineering/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/financial/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/financial/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/information/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/information/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/logical/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/logical/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/lookup/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/lookup/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/math/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/math/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/statistical/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/statistical/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/text/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/text/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/univer/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/univer/zh-CN.d.ts +15 -1
- package/lib/types/locale/function-list/web/en-US.d.ts +15 -1
- package/lib/types/locale/function-list/web/zh-CN.d.ts +15 -1
- package/lib/types/locale/index.d.ts +15 -1
- package/lib/types/locale/zh-CN.d.ts +18 -1
- package/lib/types/services/active-dirty-manager.service.d.ts +48 -0
- package/lib/types/services/description.service.d.ts +21 -7
- package/lib/types/services/formula-input.service.d.ts +15 -4
- package/lib/types/services/function-list/array.d.ts +15 -1
- package/lib/types/services/function-list/compatibility.d.ts +15 -1
- package/lib/types/services/function-list/cube.d.ts +15 -1
- package/lib/types/services/function-list/database.d.ts +15 -1
- package/lib/types/services/function-list/date.d.ts +15 -1
- package/lib/types/services/function-list/engineering.d.ts +15 -1
- package/lib/types/services/function-list/financial.d.ts +15 -1
- package/lib/types/services/function-list/function-list.d.ts +15 -1
- package/lib/types/services/function-list/information.d.ts +15 -1
- package/lib/types/services/function-list/logical.d.ts +15 -1
- package/lib/types/services/function-list/lookup.d.ts +15 -1
- package/lib/types/services/function-list/math.d.ts +15 -1
- package/lib/types/services/function-list/statistical.d.ts +15 -1
- package/lib/types/services/function-list/text.d.ts +15 -1
- package/lib/types/services/function-list/univer.d.ts +15 -1
- package/lib/types/services/function-list/web.d.ts +15 -1
- package/lib/types/services/prompt.service.d.ts +15 -1
- package/lib/types/services/utils.d.ts +15 -1
- package/lib/types/views/FormulaPromptContainer.d.ts +15 -1
- package/lib/types/views/more-functions/MoreFunctions.d.ts +15 -1
- package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts +15 -1
- package/lib/types/views/more-functions/function-params/FunctionParams.d.ts +15 -1
- package/lib/types/views/more-functions/input-params/InputParams.d.ts +15 -1
- package/lib/types/views/more-functions/interface.d.ts +15 -1
- package/lib/types/views/more-functions/select-function/SelectFunction.d.ts +15 -1
- package/lib/types/views/prompt/error-function/error-function.d.ts +15 -1
- package/lib/types/views/prompt/help-function/HelpFunction.d.ts +15 -1
- package/lib/types/views/prompt/search-function/SearchFunction.d.ts +15 -1
- package/lib/umd/index.js +11 -0
- package/package.json +42 -31
- package/LICENSE +0 -21
- package/lib/cjs/locale/en-US.js +0 -223
- package/lib/cjs/locale/zh-CN.js +0 -223
- package/lib/esm/index.js +0 -4205
- package/lib/esm/locale/en-US.js +0 -200
- package/lib/esm/locale/zh-CN.js +0 -200
- package/lib/types/commands/commands/insert-function.command.d.ts.map +0 -1
- package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts.map +0 -1
- package/lib/types/commands/operations/editor-formula.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/help-function.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/insert-function.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/more-functions.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/reference-absolute.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/search-function.operation.d.ts.map +0 -1
- package/lib/types/common/plugin-name.d.ts.map +0 -1
- package/lib/types/common/prompt.d.ts.map +0 -1
- package/lib/types/common/selection.d.ts.map +0 -1
- package/lib/types/controllers/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts.map +0 -1
- package/lib/types/controllers/formula-auto-fill.controller.d.ts.map +0 -1
- package/lib/types/controllers/formula-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/formula-ui.controller.d.ts.map +0 -1
- package/lib/types/controllers/menu.d.ts.map +0 -1
- package/lib/types/controllers/prompt.controller.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts.map +0 -1
- package/lib/types/formula-ui-plugin.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/locale/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/array/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/array/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/compatibility/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/compatibility/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/cube/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/cube/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/database/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/database/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/date/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/date/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/engineering/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/engineering/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/financial/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/financial/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/information/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/information/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/logical/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/logical/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/lookup/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/lookup/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/math/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/math/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/statistical/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/statistical/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/text/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/text/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/univer/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/univer/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/function-list/web/en-US.d.ts.map +0 -1
- package/lib/types/locale/function-list/web/zh-CN.d.ts.map +0 -1
- package/lib/types/locale/index.d.ts.map +0 -1
- package/lib/types/locale/zh-CN.d.ts.map +0 -1
- package/lib/types/services/description.service.d.ts.map +0 -1
- package/lib/types/services/formula-input.service.d.ts.map +0 -1
- package/lib/types/services/function-list/array.d.ts.map +0 -1
- package/lib/types/services/function-list/compatibility.d.ts.map +0 -1
- package/lib/types/services/function-list/cube.d.ts.map +0 -1
- package/lib/types/services/function-list/database.d.ts.map +0 -1
- package/lib/types/services/function-list/date.d.ts.map +0 -1
- package/lib/types/services/function-list/engineering.d.ts.map +0 -1
- package/lib/types/services/function-list/financial.d.ts.map +0 -1
- package/lib/types/services/function-list/function-list.d.ts.map +0 -1
- package/lib/types/services/function-list/information.d.ts.map +0 -1
- package/lib/types/services/function-list/logical.d.ts.map +0 -1
- package/lib/types/services/function-list/lookup.d.ts.map +0 -1
- package/lib/types/services/function-list/math.d.ts.map +0 -1
- package/lib/types/services/function-list/statistical.d.ts.map +0 -1
- package/lib/types/services/function-list/text.d.ts.map +0 -1
- package/lib/types/services/function-list/univer.d.ts.map +0 -1
- package/lib/types/services/function-list/web.d.ts.map +0 -1
- package/lib/types/services/prompt.service.d.ts.map +0 -1
- package/lib/types/services/utils.d.ts.map +0 -1
- package/lib/types/views/FormulaPromptContainer.d.ts.map +0 -1
- package/lib/types/views/more-functions/MoreFunctions.d.ts.map +0 -1
- package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts.map +0 -1
- package/lib/types/views/more-functions/function-params/FunctionParams.d.ts.map +0 -1
- package/lib/types/views/more-functions/input-params/InputParams.d.ts.map +0 -1
- package/lib/types/views/more-functions/interface.d.ts.map +0 -1
- package/lib/types/views/more-functions/select-function/SelectFunction.d.ts.map +0 -1
- package/lib/types/views/prompt/error-function/error-function.d.ts.map +0 -1
- package/lib/types/views/prompt/help-function/HelpFunction.d.ts.map +0 -1
- package/lib/types/views/prompt/search-function/SearchFunction.d.ts.map +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -1,4215 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
function _array_without_holes(arr) {
|
|
11
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
-
}
|
|
13
|
-
function _assert_this_initialized(self) {
|
|
14
|
-
if (self === void 0) {
|
|
15
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16
|
-
}
|
|
17
|
-
return self;
|
|
18
|
-
}
|
|
19
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
20
|
-
try {
|
|
21
|
-
var info = gen[key](arg);
|
|
22
|
-
var value = info.value;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
reject(error);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (info.done) {
|
|
28
|
-
resolve(value);
|
|
29
|
-
} else {
|
|
30
|
-
Promise.resolve(value).then(_next, _throw);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function _async_to_generator(fn) {
|
|
34
|
-
return function() {
|
|
35
|
-
var self = this, args = arguments;
|
|
36
|
-
return new Promise(function(resolve, reject) {
|
|
37
|
-
var gen = fn.apply(self, args);
|
|
38
|
-
function _next(value) {
|
|
39
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
40
|
-
}
|
|
41
|
-
function _throw(err) {
|
|
42
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
43
|
-
}
|
|
44
|
-
_next(undefined);
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function _class_call_check(instance, Constructor) {
|
|
49
|
-
if (!(instance instanceof Constructor)) {
|
|
50
|
-
throw new TypeError("Cannot call a class as a function");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function _defineProperties(target, props) {
|
|
54
|
-
for(var i = 0; i < props.length; i++){
|
|
55
|
-
var descriptor = props[i];
|
|
56
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
57
|
-
descriptor.configurable = true;
|
|
58
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
59
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
63
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
64
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
65
|
-
return Constructor;
|
|
66
|
-
}
|
|
67
|
-
function _define_property(obj, key, value) {
|
|
68
|
-
if (key in obj) {
|
|
69
|
-
Object.defineProperty(obj, key, {
|
|
70
|
-
value: value,
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
obj[key] = value;
|
|
77
|
-
}
|
|
78
|
-
return obj;
|
|
79
|
-
}
|
|
80
|
-
function _get_prototype_of(o) {
|
|
81
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
82
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
83
|
-
};
|
|
84
|
-
return _get_prototype_of(o);
|
|
85
|
-
}
|
|
86
|
-
function _inherits(subClass, superClass) {
|
|
87
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
88
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
89
|
-
}
|
|
90
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
91
|
-
constructor: {
|
|
92
|
-
value: subClass,
|
|
93
|
-
writable: true,
|
|
94
|
-
configurable: true
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
98
|
-
}
|
|
99
|
-
function _iterable_to_array(iter) {
|
|
100
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
101
|
-
}
|
|
102
|
-
function _iterable_to_array_limit(arr, i) {
|
|
103
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
104
|
-
if (_i == null) return;
|
|
105
|
-
var _arr = [];
|
|
106
|
-
var _n = true;
|
|
107
|
-
var _d = false;
|
|
108
|
-
var _s, _e;
|
|
109
|
-
try {
|
|
110
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
111
|
-
_arr.push(_s.value);
|
|
112
|
-
if (i && _arr.length === i) break;
|
|
113
|
-
}
|
|
114
|
-
} catch (err) {
|
|
115
|
-
_d = true;
|
|
116
|
-
_e = err;
|
|
117
|
-
} finally{
|
|
118
|
-
try {
|
|
119
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
120
|
-
} finally{
|
|
121
|
-
if (_d) throw _e;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return _arr;
|
|
125
|
-
}
|
|
126
|
-
function _non_iterable_rest() {
|
|
127
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
128
|
-
}
|
|
129
|
-
function _non_iterable_spread() {
|
|
130
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
131
|
-
}
|
|
132
|
-
function _object_spread(target) {
|
|
133
|
-
for(var i = 1; i < arguments.length; i++){
|
|
134
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
135
|
-
var ownKeys = Object.keys(source);
|
|
136
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
137
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
138
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
ownKeys.forEach(function(key) {
|
|
142
|
-
_define_property(target, key, source[key]);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return target;
|
|
146
|
-
}
|
|
147
|
-
function _possible_constructor_return(self, call) {
|
|
148
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
149
|
-
return call;
|
|
150
|
-
}
|
|
151
|
-
return _assert_this_initialized(self);
|
|
152
|
-
}
|
|
153
|
-
function _set_prototype_of(o, p) {
|
|
154
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
155
|
-
o.__proto__ = p;
|
|
156
|
-
return o;
|
|
157
|
-
};
|
|
158
|
-
return _set_prototype_of(o, p);
|
|
159
|
-
}
|
|
160
|
-
function _sliced_to_array(arr, i) {
|
|
161
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
162
|
-
}
|
|
163
|
-
function _to_consumable_array(arr) {
|
|
164
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
165
|
-
}
|
|
166
|
-
function _type_of(obj) {
|
|
167
|
-
"@swc/helpers - typeof";
|
|
168
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
169
|
-
}
|
|
170
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
171
|
-
if (!o) return;
|
|
172
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
173
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
174
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
175
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
176
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
177
|
-
}
|
|
178
|
-
function _is_native_reflect_construct() {
|
|
179
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
180
|
-
if (Reflect.construct.sham) return false;
|
|
181
|
-
if (typeof Proxy === "function") return true;
|
|
182
|
-
try {
|
|
183
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
184
|
-
return true;
|
|
185
|
-
} catch (e) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function _create_super(Derived) {
|
|
190
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
191
|
-
return function _createSuperInternal() {
|
|
192
|
-
var Super = _get_prototype_of(Derived), result;
|
|
193
|
-
if (hasNativeReflectConstruct) {
|
|
194
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
195
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
196
|
-
} else {
|
|
197
|
-
result = Super.apply(this, arguments);
|
|
198
|
-
}
|
|
199
|
-
return _possible_constructor_return(this, result);
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function _ts_generator(thisArg, body) {
|
|
203
|
-
var f, y, t, g, _ = {
|
|
204
|
-
label: 0,
|
|
205
|
-
sent: function() {
|
|
206
|
-
if (t[0] & 1) throw t[1];
|
|
207
|
-
return t[1];
|
|
208
|
-
},
|
|
209
|
-
trys: [],
|
|
210
|
-
ops: []
|
|
211
|
-
};
|
|
212
|
-
return g = {
|
|
213
|
-
next: verb(0),
|
|
214
|
-
"throw": verb(1),
|
|
215
|
-
"return": verb(2)
|
|
216
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
217
|
-
return this;
|
|
218
|
-
}), g;
|
|
219
|
-
function verb(n) {
|
|
220
|
-
return function(v) {
|
|
221
|
-
return step([
|
|
222
|
-
n,
|
|
223
|
-
v
|
|
224
|
-
]);
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function step(op) {
|
|
228
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
229
|
-
while(_)try {
|
|
230
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
231
|
-
if (y = 0, t) op = [
|
|
232
|
-
op[0] & 2,
|
|
233
|
-
t.value
|
|
234
|
-
];
|
|
235
|
-
switch(op[0]){
|
|
236
|
-
case 0:
|
|
237
|
-
case 1:
|
|
238
|
-
t = op;
|
|
239
|
-
break;
|
|
240
|
-
case 4:
|
|
241
|
-
_.label++;
|
|
242
|
-
return {
|
|
243
|
-
value: op[1],
|
|
244
|
-
done: false
|
|
245
|
-
};
|
|
246
|
-
case 5:
|
|
247
|
-
_.label++;
|
|
248
|
-
y = op[1];
|
|
249
|
-
op = [
|
|
250
|
-
0
|
|
251
|
-
];
|
|
252
|
-
continue;
|
|
253
|
-
case 7:
|
|
254
|
-
op = _.ops.pop();
|
|
255
|
-
_.trys.pop();
|
|
256
|
-
continue;
|
|
257
|
-
default:
|
|
258
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
259
|
-
_ = 0;
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
263
|
-
_.label = op[1];
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
267
|
-
_.label = t[1];
|
|
268
|
-
t = op;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
if (t && _.label < t[2]) {
|
|
272
|
-
_.label = t[2];
|
|
273
|
-
_.ops.push(op);
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
if (t[2]) _.ops.pop();
|
|
277
|
-
_.trys.pop();
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
op = body.call(thisArg, _);
|
|
281
|
-
} catch (e) {
|
|
282
|
-
op = [
|
|
283
|
-
6,
|
|
284
|
-
e
|
|
285
|
-
];
|
|
286
|
-
y = 0;
|
|
287
|
-
} finally{
|
|
288
|
-
f = t = 0;
|
|
289
|
-
}
|
|
290
|
-
if (op[0] & 5) throw op[1];
|
|
291
|
-
return {
|
|
292
|
-
value: op[0] ? op[1] : void 0,
|
|
293
|
-
done: true
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
var _import_core17_Plugin, _class;
|
|
298
|
-
var __create = Object.create;
|
|
299
|
-
var __defProp = Object.defineProperty;
|
|
300
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
301
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
302
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
303
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
304
|
-
var __export = function(target, all) {
|
|
305
|
-
for(var name in all)__defProp(target, name, {
|
|
306
|
-
get: all[name],
|
|
307
|
-
enumerable: true
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
var __copyProps = function(to, from, except, desc) {
|
|
311
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
312
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
313
|
-
try {
|
|
314
|
-
var _loop = function() {
|
|
315
|
-
var key = _step.value;
|
|
316
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
317
|
-
get: function() {
|
|
318
|
-
return from[key];
|
|
319
|
-
},
|
|
320
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
324
|
-
} catch (err) {
|
|
325
|
-
_didIteratorError = true;
|
|
326
|
-
_iteratorError = err;
|
|
327
|
-
} finally{
|
|
328
|
-
try {
|
|
329
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
330
|
-
_iterator.return();
|
|
331
|
-
}
|
|
332
|
-
} finally{
|
|
333
|
-
if (_didIteratorError) {
|
|
334
|
-
throw _iteratorError;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return to;
|
|
340
|
-
};
|
|
341
|
-
var __toESM = function(mod, isNodeMode, target) {
|
|
342
|
-
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
343
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
344
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
345
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
346
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
347
|
-
value: mod,
|
|
348
|
-
enumerable: true
|
|
349
|
-
}) : target, mod);
|
|
350
|
-
};
|
|
351
|
-
var __toCommonJS = function(mod) {
|
|
352
|
-
return __copyProps(__defProp({}, "__esModule", {
|
|
353
|
-
value: true
|
|
354
|
-
}), mod);
|
|
355
|
-
};
|
|
356
|
-
var __decorateClass = function(decorators, target, key, kind) {
|
|
357
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
358
|
-
for(var i = decorators.length - 1, decorator; i >= 0; i--)if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
359
|
-
if (kind && result) __defProp(target, key, result);
|
|
360
|
-
return result;
|
|
361
|
-
};
|
|
362
|
-
var __decorateParam = function(index, decorator) {
|
|
363
|
-
return function(target, key) {
|
|
364
|
-
return decorator(target, key, index);
|
|
365
|
-
};
|
|
366
|
-
};
|
|
367
|
-
// src/index.ts
|
|
368
|
-
var src_exports = {};
|
|
369
|
-
__export(src_exports, {
|
|
370
|
-
FormulaUIPlugin: function() {
|
|
371
|
-
return FormulaUIPlugin;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
module.exports = __toCommonJS(src_exports);
|
|
375
|
-
// src/formula-ui-plugin.ts
|
|
376
|
-
var import_core17 = require("@univerjs/core");
|
|
377
|
-
var import_redi8 = require("@wendellhu/redi");
|
|
378
|
-
// src/common/plugin-name.ts
|
|
379
|
-
var FORMULA_UI_PLUGIN_NAME = "formula-ui";
|
|
380
|
-
// src/controllers/formula-auto-fill.controller.ts
|
|
381
|
-
var import_core = require("@univerjs/core");
|
|
382
|
-
var import_engine_formula = require("@univerjs/engine-formula");
|
|
383
|
-
var import_sheets_ui = require("@univerjs/sheets-ui");
|
|
384
|
-
var import_redi = require("@wendellhu/redi");
|
|
385
|
-
var FormulaAutoFillController = /*#__PURE__*/ function(_import_core_Disposable) {
|
|
386
|
-
_inherits(FormulaAutoFillController, _import_core_Disposable);
|
|
387
|
-
var _super = _create_super(FormulaAutoFillController);
|
|
388
|
-
function FormulaAutoFillController(_autoFillService, _formulaEngineService) {
|
|
389
|
-
_class_call_check(this, FormulaAutoFillController);
|
|
390
|
-
var _this;
|
|
391
|
-
_this = _super.call(this);
|
|
392
|
-
_this._autoFillService = _autoFillService;
|
|
393
|
-
_this._formulaEngineService = _formulaEngineService;
|
|
394
|
-
_this._initialize();
|
|
395
|
-
return _this;
|
|
396
|
-
}
|
|
397
|
-
_create_class(FormulaAutoFillController, [
|
|
398
|
-
{
|
|
399
|
-
key: "_initialize",
|
|
400
|
-
value: function _initialize() {
|
|
401
|
-
this._registerAutoFill();
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
key: "_registerAutoFill",
|
|
406
|
-
value: function _registerAutoFill() {
|
|
407
|
-
var _this = this;
|
|
408
|
-
var formulaRule = {
|
|
409
|
-
type: import_sheets_ui.DATA_TYPE.FORMULA,
|
|
410
|
-
priority: 1001,
|
|
411
|
-
match: function(cellData) {
|
|
412
|
-
return (0, import_core.isFormulaString)(cellData === null || cellData === void 0 ? void 0 : cellData.f);
|
|
413
|
-
},
|
|
414
|
-
isContinue: function(prev, cur) {
|
|
415
|
-
if (prev.type === import_sheets_ui.DATA_TYPE.FORMULA) {
|
|
416
|
-
return true;
|
|
417
|
-
}
|
|
418
|
-
return false;
|
|
419
|
-
},
|
|
420
|
-
applyFunctions: _define_property({}, import_sheets_ui.APPLY_TYPE.COPY, function(dataWithIndex, len, direction, copyDataPiece) {
|
|
421
|
-
var data = dataWithIndex.data, index = dataWithIndex.index;
|
|
422
|
-
return _this._fillCopyFormula(data, len, direction, index, copyDataPiece);
|
|
423
|
-
})
|
|
424
|
-
};
|
|
425
|
-
this._autoFillService.registerRule(formulaRule);
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
key: "_fillCopyFormula",
|
|
430
|
-
value: function _fillCopyFormula(data, len, direction, index, copyDataPiece) {
|
|
431
|
-
var step = getDataLength(copyDataPiece);
|
|
432
|
-
var applyData = [];
|
|
433
|
-
var formulaIdMap = /* @__PURE__ */ new Map();
|
|
434
|
-
for(var i = 1; i <= len; i++){
|
|
435
|
-
var index2 = (i - 1) % data.length;
|
|
436
|
-
var d = import_core.Tools.deepClone(data[index2]);
|
|
437
|
-
if (d) {
|
|
438
|
-
var _data_index2;
|
|
439
|
-
var originalFormula = (_data_index2 = data[index2]) === null || _data_index2 === void 0 ? void 0 : _data_index2.f;
|
|
440
|
-
if (originalFormula) {
|
|
441
|
-
var formulaId = formulaIdMap.get(index2);
|
|
442
|
-
if (!formulaId) {
|
|
443
|
-
formulaId = import_core.Tools.generateRandomId(6);
|
|
444
|
-
formulaIdMap.set(index2, formulaId);
|
|
445
|
-
var _directionToOffset = directionToOffset(step, direction), offsetX = _directionToOffset.offsetX, offsetY = _directionToOffset.offsetY;
|
|
446
|
-
var shiftedFormula = this._formulaEngineService.moveFormulaRefOffset(originalFormula, offsetX, offsetY);
|
|
447
|
-
d.si = formulaId;
|
|
448
|
-
d.f = shiftedFormula;
|
|
449
|
-
d.v = null;
|
|
450
|
-
d.p = null;
|
|
451
|
-
} else {
|
|
452
|
-
d.si = formulaId;
|
|
453
|
-
d.f = null;
|
|
454
|
-
d.v = null;
|
|
455
|
-
d.p = null;
|
|
456
|
-
}
|
|
457
|
-
if (direction === import_core.Direction.DOWN || direction === import_core.Direction.RIGHT) {
|
|
458
|
-
applyData.push(d);
|
|
459
|
-
} else {
|
|
460
|
-
applyData.unshift(d);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return applyData;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
]);
|
|
469
|
-
return FormulaAutoFillController;
|
|
470
|
-
}(import_core.Disposable);
|
|
471
|
-
FormulaAutoFillController = __decorateClass([
|
|
472
|
-
(0, import_core.OnLifecycle)(import_core.LifecycleStages.Ready, FormulaAutoFillController),
|
|
473
|
-
__decorateParam(0, import_sheets_ui.IAutoFillService),
|
|
474
|
-
__decorateParam(1, (0, import_redi.Inject)(import_engine_formula.FormulaEngineService))
|
|
475
|
-
], FormulaAutoFillController);
|
|
476
|
-
function directionToOffset(step, direction) {
|
|
477
|
-
var offsetX = 0;
|
|
478
|
-
var offsetY = 0;
|
|
479
|
-
switch(direction){
|
|
480
|
-
case import_core.Direction.UP:
|
|
481
|
-
offsetY = -step;
|
|
482
|
-
break;
|
|
483
|
-
case import_core.Direction.RIGHT:
|
|
484
|
-
offsetX = step;
|
|
485
|
-
break;
|
|
486
|
-
case import_core.Direction.DOWN:
|
|
487
|
-
offsetY = step;
|
|
488
|
-
break;
|
|
489
|
-
case import_core.Direction.LEFT:
|
|
490
|
-
offsetX = -step;
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
return {
|
|
494
|
-
offsetX: offsetX,
|
|
495
|
-
offsetY: offsetY
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
function getDataLength(copyDataPiece) {
|
|
499
|
-
var length = 0;
|
|
500
|
-
for(var t in copyDataPiece){
|
|
501
|
-
copyDataPiece[t].forEach(function(item) {
|
|
502
|
-
length += item.data.length;
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
return length;
|
|
506
|
-
}
|
|
507
|
-
// src/controllers/formula-input.controller.ts
|
|
508
|
-
var import_core3 = require("@univerjs/core");
|
|
509
|
-
var import_engine_formula3 = require("@univerjs/engine-formula");
|
|
510
|
-
var import_engine_render = require("@univerjs/engine-render");
|
|
511
|
-
var import_sheets_ui2 = require("@univerjs/sheets-ui");
|
|
512
|
-
var import_ui = require("@univerjs/ui");
|
|
513
|
-
var import_redi3 = require("@wendellhu/redi");
|
|
514
|
-
// src/commands/operations/reference-absolute.operation.ts
|
|
515
|
-
var import_core2 = require("@univerjs/core");
|
|
516
|
-
var ReferenceAbsoluteOperation = {
|
|
517
|
-
id: "formula-ui.operation.change-ref-to-absolute",
|
|
518
|
-
type: import_core2.CommandType.OPERATION,
|
|
519
|
-
handler: function() {
|
|
520
|
-
var _ref = _async_to_generator(function(accessor) {
|
|
521
|
-
return _ts_generator(this, function(_state) {
|
|
522
|
-
return [
|
|
523
|
-
2,
|
|
524
|
-
true
|
|
525
|
-
];
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
return function(accessor) {
|
|
529
|
-
return _ref.apply(this, arguments);
|
|
530
|
-
};
|
|
531
|
-
}()
|
|
532
|
-
};
|
|
533
|
-
// src/services/formula-input.service.ts
|
|
534
|
-
var import_engine_formula2 = require("@univerjs/engine-formula");
|
|
535
|
-
var import_redi2 = require("@wendellhu/redi");
|
|
536
|
-
var import_rxjs = require("rxjs");
|
|
537
|
-
var FormulaInputService = /*#__PURE__*/ function() {
|
|
538
|
-
function FormulaInputService(_formulaEngineService) {
|
|
539
|
-
_class_call_check(this, FormulaInputService);
|
|
540
|
-
_define_property(this, "_sequenceNodes", []);
|
|
541
|
-
_define_property(this, "_isSelectionMoving", false);
|
|
542
|
-
_define_property(this, "_isLockedOnSelectionChangeRefString", false);
|
|
543
|
-
_define_property(this, "_isLockedOnSelectionInsertRefString", false);
|
|
544
|
-
_define_property(this, "_syncToEditor$", new import_rxjs.Subject());
|
|
545
|
-
_define_property(this, "syncToEditor$", this._syncToEditor$.asObservable());
|
|
546
|
-
_define_property(this, "_changeRef$", new import_rxjs.Subject());
|
|
547
|
-
_define_property(this, "changeRef$", this._changeRef$.asObservable());
|
|
548
|
-
_define_property(this, "_inputFormula$", new import_rxjs.Subject());
|
|
549
|
-
_define_property(this, "inputFormula$", this._inputFormula$.asObservable());
|
|
550
|
-
this._formulaEngineService = _formulaEngineService;
|
|
551
|
-
}
|
|
552
|
-
_create_class(FormulaInputService, [
|
|
553
|
-
{
|
|
554
|
-
key: "dispose",
|
|
555
|
-
value: function dispose() {
|
|
556
|
-
this._sequenceNodes = [];
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
key: "inputFormula",
|
|
561
|
-
value: function inputFormula(formulaString) {
|
|
562
|
-
this._inputFormula$.next(formulaString);
|
|
563
|
-
}
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
key: "syncToEditor",
|
|
567
|
-
value: function syncToEditor(textSelectionOffset) {
|
|
568
|
-
this._syncToEditor$.next({
|
|
569
|
-
sequences: this.getSequenceNodes(),
|
|
570
|
-
textSelectionOffset: textSelectionOffset
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
key: "getSequenceNodes",
|
|
576
|
-
value: function getSequenceNodes() {
|
|
577
|
-
return _to_consumable_array(this._sequenceNodes);
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
key: "setSequenceNodes",
|
|
582
|
-
value: function setSequenceNodes(nodes) {
|
|
583
|
-
this._sequenceNodes = nodes;
|
|
584
|
-
}
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
key: "clearSequenceNodes",
|
|
588
|
-
value: function clearSequenceNodes() {
|
|
589
|
-
this._sequenceNodes = [];
|
|
590
|
-
}
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
key: "getCurrentSequenceNode",
|
|
594
|
-
value: function getCurrentSequenceNode(strIndex) {
|
|
595
|
-
return this._sequenceNodes[this.getCurrentSequenceNodeIndex(strIndex)];
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
key: "getCurrentSequenceNodeByIndex",
|
|
600
|
-
value: function getCurrentSequenceNodeByIndex(nodeIndex) {
|
|
601
|
-
return this._sequenceNodes[nodeIndex];
|
|
602
|
-
}
|
|
603
|
-
},
|
|
604
|
-
{
|
|
605
|
-
/**
|
|
606
|
-
* Query the text coordinates in the sequenceNodes and determine the actual insertion index.
|
|
607
|
-
* @param sequenceNodes
|
|
608
|
-
* @param strIndex
|
|
609
|
-
* @returns
|
|
610
|
-
*/ key: "getCurrentSequenceNodeIndex",
|
|
611
|
-
value: function getCurrentSequenceNodeIndex(strIndex) {
|
|
612
|
-
var nodeIndex = 0;
|
|
613
|
-
for(var i = 0, len = this._sequenceNodes.length; i < len; i++){
|
|
614
|
-
var node = this._sequenceNodes[i];
|
|
615
|
-
if (typeof node === "string") {
|
|
616
|
-
nodeIndex++;
|
|
617
|
-
} else {
|
|
618
|
-
var endIndex = node.endIndex;
|
|
619
|
-
nodeIndex = endIndex;
|
|
620
|
-
}
|
|
621
|
-
if (strIndex <= nodeIndex) {
|
|
622
|
-
return i;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
return this._sequenceNodes.length;
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
/**
|
|
630
|
-
* Synchronize the reference text based on the changes of the selection.
|
|
631
|
-
* @param refIndex
|
|
632
|
-
* @param rangeWithCoord
|
|
633
|
-
* @returns
|
|
634
|
-
*/ key: "updateSequenceRef",
|
|
635
|
-
value: function updateSequenceRef(nodeIndex, refString) {
|
|
636
|
-
var node = this._sequenceNodes[nodeIndex];
|
|
637
|
-
if (typeof node === "string" || node.nodeType !== import_engine_formula2.sequenceNodeType.REFERENCE) {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
var difference = refString.length - node.token.length;
|
|
641
|
-
var newNode = _object_spread({}, node);
|
|
642
|
-
newNode.token = refString;
|
|
643
|
-
newNode.endIndex += difference;
|
|
644
|
-
this._sequenceNodes[nodeIndex] = newNode;
|
|
645
|
-
for(var i = nodeIndex + 1, len = this._sequenceNodes.length; i < len; i++){
|
|
646
|
-
var node2 = this._sequenceNodes[i];
|
|
647
|
-
if (typeof node2 === "string") {
|
|
648
|
-
continue;
|
|
649
|
-
}
|
|
650
|
-
var newNode2 = _object_spread({}, node2);
|
|
651
|
-
newNode2.startIndex += difference;
|
|
652
|
-
newNode2.endIndex += difference;
|
|
653
|
-
this._sequenceNodes[i] = newNode2;
|
|
654
|
-
}
|
|
655
|
-
this._changeRef$.next(true);
|
|
656
|
-
}
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
/**
|
|
660
|
-
* When the cursor is on the right side of a formula token,
|
|
661
|
-
* you can add reference text to the formula by drawing a selection.
|
|
662
|
-
* @param index
|
|
663
|
-
* @param range
|
|
664
|
-
*/ key: "insertSequenceRef",
|
|
665
|
-
value: function insertSequenceRef(index, refString) {
|
|
666
|
-
var refStringCount = refString.length;
|
|
667
|
-
var nodeIndex = this.getCurrentSequenceNodeIndex(index);
|
|
668
|
-
this._sequenceNodes.splice(nodeIndex, 0, {
|
|
669
|
-
token: refString,
|
|
670
|
-
startIndex: index,
|
|
671
|
-
endIndex: index + refStringCount - 1,
|
|
672
|
-
nodeType: import_engine_formula2.sequenceNodeType.REFERENCE
|
|
673
|
-
});
|
|
674
|
-
for(var i = nodeIndex + 1, len = this._sequenceNodes.length; i < len; i++){
|
|
675
|
-
var node = this._sequenceNodes[i];
|
|
676
|
-
if (typeof node === "string") {
|
|
677
|
-
continue;
|
|
678
|
-
}
|
|
679
|
-
var newNode = _object_spread({}, node);
|
|
680
|
-
newNode.startIndex += refStringCount;
|
|
681
|
-
newNode.endIndex += refStringCount;
|
|
682
|
-
this._sequenceNodes[i] = newNode;
|
|
683
|
-
}
|
|
684
|
-
this._changeRef$.next(true);
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
/**
|
|
689
|
-
* Insert a string at the cursor position in the text corresponding to the sequenceNodes.
|
|
690
|
-
* @param sequenceNodes
|
|
691
|
-
* @param index
|
|
692
|
-
* @param content
|
|
693
|
-
*/ key: "insertSequenceString",
|
|
694
|
-
value: function insertSequenceString(index, content) {
|
|
695
|
-
var _this__sequenceNodes;
|
|
696
|
-
var nodeIndex = this.getCurrentSequenceNodeIndex(index);
|
|
697
|
-
var str = content.split("");
|
|
698
|
-
(_this__sequenceNodes = this._sequenceNodes).splice.apply(_this__sequenceNodes, [
|
|
699
|
-
nodeIndex,
|
|
700
|
-
0
|
|
701
|
-
].concat(_to_consumable_array(str)));
|
|
702
|
-
var contentCount = str.length;
|
|
703
|
-
for(var i = nodeIndex + contentCount, len = this._sequenceNodes.length; i < len; i++){
|
|
704
|
-
var node = this._sequenceNodes[i];
|
|
705
|
-
if (typeof node === "string") {
|
|
706
|
-
continue;
|
|
707
|
-
}
|
|
708
|
-
var newNode = _object_spread({}, node);
|
|
709
|
-
newNode.startIndex += contentCount;
|
|
710
|
-
newNode.endIndex += contentCount;
|
|
711
|
-
this._sequenceNodes[i] = newNode;
|
|
712
|
-
}
|
|
713
|
-
this._changeRef$.next(true);
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
key: "enableSelectionMoving",
|
|
718
|
-
value: function enableSelectionMoving() {
|
|
719
|
-
this._isSelectionMoving = true;
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
key: "disableSelectionMoving",
|
|
724
|
-
value: function disableSelectionMoving() {
|
|
725
|
-
this._isSelectionMoving = false;
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
key: "isSelectionMoving",
|
|
730
|
-
value: function isSelectionMoving() {
|
|
731
|
-
return this._isSelectionMoving;
|
|
732
|
-
}
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
key: "enableLockedSelectionChange",
|
|
736
|
-
value: function enableLockedSelectionChange() {
|
|
737
|
-
this._isLockedOnSelectionChangeRefString = true;
|
|
738
|
-
}
|
|
739
|
-
},
|
|
740
|
-
{
|
|
741
|
-
key: "disableLockedSelectionChange",
|
|
742
|
-
value: function disableLockedSelectionChange() {
|
|
743
|
-
this._isLockedOnSelectionChangeRefString = false;
|
|
744
|
-
}
|
|
745
|
-
},
|
|
746
|
-
{
|
|
747
|
-
key: "isLockedSelectionChange",
|
|
748
|
-
value: function isLockedSelectionChange() {
|
|
749
|
-
return this._isLockedOnSelectionChangeRefString;
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
key: "enableLockedSelectionInsert",
|
|
754
|
-
value: function enableLockedSelectionInsert() {
|
|
755
|
-
this._isLockedOnSelectionInsertRefString = true;
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
key: "disableLockedSelectionInsert",
|
|
760
|
-
value: function disableLockedSelectionInsert() {
|
|
761
|
-
this._isLockedOnSelectionInsertRefString = false;
|
|
762
|
-
}
|
|
763
|
-
},
|
|
764
|
-
{
|
|
765
|
-
key: "isLockedSelectionInsert",
|
|
766
|
-
value: function isLockedSelectionInsert() {
|
|
767
|
-
return this._isLockedOnSelectionInsertRefString;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
]);
|
|
771
|
-
return FormulaInputService;
|
|
772
|
-
}();
|
|
773
|
-
FormulaInputService = __decorateClass([
|
|
774
|
-
__decorateParam(0, (0, import_redi2.Inject)(import_engine_formula2.FormulaEngineService))
|
|
775
|
-
], FormulaInputService);
|
|
776
|
-
var IFormulaInputService = (0, import_redi2.createIdentifier)("formula-ui.input-service");
|
|
777
|
-
// src/controllers/formula-input.controller.ts
|
|
778
|
-
var FormulaInputController = /*#__PURE__*/ function(_import_core3_Disposable) {
|
|
779
|
-
_inherits(FormulaInputController, _import_core3_Disposable);
|
|
780
|
-
var _super = _create_super(FormulaInputController);
|
|
781
|
-
function FormulaInputController(_commandService, _textSelectionRenderManager, _editorBridgeService, _formulaEngineService, _renderManagerService, _formulaInputService) {
|
|
782
|
-
_class_call_check(this, FormulaInputController);
|
|
783
|
-
var _this;
|
|
784
|
-
_this = _super.call(this);
|
|
785
|
-
_define_property(_assert_this_initialized(_this), "_userCursorMove", false);
|
|
786
|
-
_this._commandService = _commandService;
|
|
787
|
-
_this._textSelectionRenderManager = _textSelectionRenderManager;
|
|
788
|
-
_this._editorBridgeService = _editorBridgeService;
|
|
789
|
-
_this._formulaEngineService = _formulaEngineService;
|
|
790
|
-
_this._renderManagerService = _renderManagerService;
|
|
791
|
-
_this._formulaInputService = _formulaInputService;
|
|
792
|
-
_this._initialize();
|
|
793
|
-
return _this;
|
|
794
|
-
}
|
|
795
|
-
_create_class(FormulaInputController, [
|
|
796
|
-
{
|
|
797
|
-
key: "_initialize",
|
|
798
|
-
value: function _initialize() {
|
|
799
|
-
this._commandExecutedListener();
|
|
800
|
-
this._initialEditorInputChange();
|
|
801
|
-
this._userMouseListener();
|
|
802
|
-
this._inputFormulaListener();
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
{
|
|
806
|
-
key: "_initialEditorInputChange",
|
|
807
|
-
value: function _initialEditorInputChange() {
|
|
808
|
-
var _this = this;
|
|
809
|
-
this.disposeWithMe((0, import_core3.toDisposable)(this._textSelectionRenderManager.onInputBefore$.subscribe(function(param) {
|
|
810
|
-
var e = param === null || param === void 0 ? void 0 : param.event;
|
|
811
|
-
if (e == null) {
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
if (e.which !== import_ui.KeyCode.F4) {
|
|
815
|
-
_this._userCursorMove = false;
|
|
816
|
-
}
|
|
817
|
-
})));
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
key: "_userMouseListener",
|
|
822
|
-
value: function _userMouseListener() {
|
|
823
|
-
var _this = this;
|
|
824
|
-
var editorObject = this._getEditorObject();
|
|
825
|
-
if (editorObject == null) {
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
var documentComponent = editorObject.document;
|
|
829
|
-
this.disposeWithMe((0, import_core3.toDisposable)(documentComponent.onPointerDownObserver.add(function() {
|
|
830
|
-
_this._userCursorMove = true;
|
|
831
|
-
})));
|
|
832
|
-
}
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
key: "_inputFormulaListener",
|
|
836
|
-
value: function _inputFormulaListener() {
|
|
837
|
-
var _this = this;
|
|
838
|
-
this.disposeWithMe((0, import_core3.toDisposable)(this._formulaInputService.inputFormula$.subscribe(function(formulaString) {
|
|
839
|
-
var visibleState = _this._editorBridgeService.isVisible();
|
|
840
|
-
if (visibleState.visible === false) {
|
|
841
|
-
_this._editorBridgeService.changeVisible({
|
|
842
|
-
visible: true,
|
|
843
|
-
eventType: import_engine_render.DeviceInputEventType.Dblclick
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
var lastSequenceNodes = _this._formulaEngineService.buildSequenceNodes(formulaString) || [];
|
|
847
|
-
_this._formulaInputService.setSequenceNodes(lastSequenceNodes);
|
|
848
|
-
_this._formulaInputService.syncToEditor(formulaString.length - 1);
|
|
849
|
-
})));
|
|
850
|
-
}
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
key: "_changeRefString",
|
|
854
|
-
value: function _changeRefString() {
|
|
855
|
-
var activeRange = this._textSelectionRenderManager.getActiveRange();
|
|
856
|
-
if (activeRange == null) {
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
|
-
var startOffset = activeRange.startOffset;
|
|
860
|
-
var strIndex = startOffset - 2;
|
|
861
|
-
var nodeIndex = this._formulaInputService.getCurrentSequenceNodeIndex(strIndex);
|
|
862
|
-
var node = this._formulaInputService.getCurrentSequenceNodeByIndex(nodeIndex);
|
|
863
|
-
if (node == null || typeof node === "string" || node.nodeType !== import_engine_formula3.sequenceNodeType.REFERENCE) {
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
var tokenArray = node.token.split("!");
|
|
867
|
-
var token = node.token;
|
|
868
|
-
if (tokenArray.length > 1) {
|
|
869
|
-
token = tokenArray[tokenArray.length - 1];
|
|
870
|
-
}
|
|
871
|
-
var unitIDAndSheetName = "";
|
|
872
|
-
for(var i = 0, len = tokenArray.length; i < len - 1; i++){
|
|
873
|
-
unitIDAndSheetName += tokenArray[i];
|
|
874
|
-
}
|
|
875
|
-
var finalToken = token;
|
|
876
|
-
if (token.indexOf(import_engine_formula3.matchToken.COLON) > -1) {
|
|
877
|
-
if (!this._userCursorMove) {
|
|
878
|
-
finalToken = this._changeRangeRef(token);
|
|
879
|
-
} else {
|
|
880
|
-
var refStringSplit = token.split(import_engine_formula3.matchToken.COLON);
|
|
881
|
-
var prefix = refStringSplit[0];
|
|
882
|
-
var suffix = refStringSplit[1];
|
|
883
|
-
var relativeIndex = strIndex - node.startIndex;
|
|
884
|
-
if (relativeIndex <= prefix.length) {
|
|
885
|
-
finalToken = this._changeSingleRef(prefix) + import_engine_formula3.matchToken.COLON + suffix;
|
|
886
|
-
} else {
|
|
887
|
-
finalToken = prefix + import_engine_formula3.matchToken.COLON + this._changeSingleRef(suffix);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
} else {
|
|
891
|
-
finalToken = this._changeSingleRef(token);
|
|
892
|
-
}
|
|
893
|
-
finalToken = unitIDAndSheetName + finalToken;
|
|
894
|
-
var difference = finalToken.length - node.token.length;
|
|
895
|
-
this._formulaInputService.updateSequenceRef(nodeIndex, finalToken);
|
|
896
|
-
this._formulaInputService.syncToEditor(strIndex + difference + 1);
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
|
-
{
|
|
900
|
-
key: "_changeRangeRef",
|
|
901
|
-
value: function _changeRangeRef(token) {
|
|
902
|
-
var range = (0, import_core3.deserializeRangeWithSheet)(token).range;
|
|
903
|
-
var resultToken = "";
|
|
904
|
-
if (range.startAbsoluteRefType === import_core3.AbsoluteRefType.NONE || range.startAbsoluteRefType == null) {
|
|
905
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
|
|
906
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
|
|
907
|
-
} else {
|
|
908
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
|
|
909
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
|
|
910
|
-
}
|
|
911
|
-
resultToken = (0, import_core3.serializeRange)(range);
|
|
912
|
-
return resultToken;
|
|
913
|
-
}
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
key: "_changeSingleRef",
|
|
917
|
-
value: function _changeSingleRef(token) {
|
|
918
|
-
var range = (0, import_core3.deserializeRangeWithSheet)(token).range;
|
|
919
|
-
var type = range.startAbsoluteRefType;
|
|
920
|
-
var resultToken = "";
|
|
921
|
-
if (type === import_core3.AbsoluteRefType.NONE || type == null) {
|
|
922
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
|
|
923
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
|
|
924
|
-
} else if (type === import_core3.AbsoluteRefType.ALL) {
|
|
925
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.ROW;
|
|
926
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.ROW;
|
|
927
|
-
} else if (type === import_core3.AbsoluteRefType.ROW) {
|
|
928
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.COLUMN;
|
|
929
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.COLUMN;
|
|
930
|
-
} else {
|
|
931
|
-
range.startAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
|
|
932
|
-
range.endAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
|
|
933
|
-
}
|
|
934
|
-
resultToken = (0, import_core3.serializeRange)(range);
|
|
935
|
-
return resultToken;
|
|
936
|
-
}
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
key: "_commandExecutedListener",
|
|
940
|
-
value: function _commandExecutedListener() {
|
|
941
|
-
var _this = this;
|
|
942
|
-
var updateCommandList = [
|
|
943
|
-
ReferenceAbsoluteOperation.id
|
|
944
|
-
];
|
|
945
|
-
this.disposeWithMe(this._commandService.onCommandExecuted(function(command) {
|
|
946
|
-
if (!updateCommandList.includes(command.id)) {
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
_this._changeRefString();
|
|
950
|
-
}));
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
key: "_getEditorObject",
|
|
955
|
-
value: function _getEditorObject() {
|
|
956
|
-
return (0, import_sheets_ui2.getEditorObject)(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
]);
|
|
960
|
-
return FormulaInputController;
|
|
961
|
-
}(import_core3.Disposable);
|
|
962
|
-
FormulaInputController = __decorateClass([
|
|
963
|
-
(0, import_core3.OnLifecycle)(import_core3.LifecycleStages.Steady, FormulaInputController),
|
|
964
|
-
__decorateParam(0, import_core3.ICommandService),
|
|
965
|
-
__decorateParam(1, import_engine_render.ITextSelectionRenderManager),
|
|
966
|
-
__decorateParam(2, (0, import_redi3.Inject)(import_sheets_ui2.IEditorBridgeService)),
|
|
967
|
-
__decorateParam(3, (0, import_redi3.Inject)(import_engine_formula3.FormulaEngineService)),
|
|
968
|
-
__decorateParam(4, import_engine_render.IRenderManagerService),
|
|
969
|
-
__decorateParam(5, IFormulaInputService)
|
|
970
|
-
], FormulaInputController);
|
|
971
|
-
// src/controllers/formula-ui.controller.ts
|
|
972
|
-
var import_core15 = require("@univerjs/core");
|
|
973
|
-
var import_ui6 = require("@univerjs/ui");
|
|
974
|
-
var import_redi6 = require("@wendellhu/redi");
|
|
975
|
-
var import_react_bindings6 = require("@wendellhu/redi/react-bindings");
|
|
976
|
-
// src/commands/commands/insert-function.command.ts
|
|
977
|
-
var import_core4 = require("@univerjs/core");
|
|
978
|
-
var import_sheets = require("@univerjs/sheets");
|
|
979
|
-
var InsertFunctionCommand = {
|
|
980
|
-
id: "formula-ui.command.insert-function",
|
|
981
|
-
type: import_core4.CommandType.COMMAND,
|
|
982
|
-
handler: function() {
|
|
983
|
-
var _ref = _async_to_generator(function(accessor, params) {
|
|
984
|
-
var list, commandService, cellMatrix, setRangeValuesParams;
|
|
985
|
-
return _ts_generator(this, function(_state) {
|
|
986
|
-
list = params.list;
|
|
987
|
-
commandService = accessor.get(import_core4.ICommandService);
|
|
988
|
-
cellMatrix = new import_core4.ObjectMatrix();
|
|
989
|
-
list.forEach(function(item) {
|
|
990
|
-
var range = item.range, primary = item.primary, formula = item.formula;
|
|
991
|
-
var row = primary.row, column = primary.column;
|
|
992
|
-
var formulaId = import_core4.Tools.generateRandomId(6);
|
|
993
|
-
cellMatrix.setValue(row, column, {
|
|
994
|
-
f: formula,
|
|
995
|
-
si: formulaId
|
|
996
|
-
});
|
|
997
|
-
var startRow = range.startRow, startColumn = range.startColumn, endRow = range.endRow, endColumn = range.endColumn;
|
|
998
|
-
for(var i = startRow; i <= endRow; i++){
|
|
999
|
-
for(var j = startColumn; j <= endColumn; j++){
|
|
1000
|
-
if (i !== row || j !== column) {
|
|
1001
|
-
cellMatrix.setValue(i, j, {
|
|
1002
|
-
si: formulaId
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
setRangeValuesParams = {
|
|
1009
|
-
value: cellMatrix.getData()
|
|
1010
|
-
};
|
|
1011
|
-
return [
|
|
1012
|
-
2,
|
|
1013
|
-
commandService.executeCommand(import_sheets.SetRangeValuesCommand.id, setRangeValuesParams)
|
|
1014
|
-
];
|
|
1015
|
-
});
|
|
1016
|
-
});
|
|
1017
|
-
return function(accessor, params) {
|
|
1018
|
-
return _ref.apply(this, arguments);
|
|
1019
|
-
};
|
|
1020
|
-
}()
|
|
1021
|
-
};
|
|
1022
|
-
// src/commands/operations/editor-formula.operation.ts
|
|
1023
|
-
var import_core5 = require("@univerjs/core");
|
|
1024
|
-
var SelectEditorFormulaOperation = {
|
|
1025
|
-
id: "formula-ui.operation.select-editor-formula",
|
|
1026
|
-
type: import_core5.CommandType.OPERATION,
|
|
1027
|
-
handler: function(accessor, params) {
|
|
1028
|
-
return(// const { eventType, keycode } = params;
|
|
1029
|
-
// const formulaPromptService = accessor.get(IFormulaPromptService);
|
|
1030
|
-
// const editorBridgeService = accessor.get(IEditorBridgeService);
|
|
1031
|
-
// switch (keycode) {
|
|
1032
|
-
// case KeyCode.ARROW_DOWN:
|
|
1033
|
-
// formulaPromptService.navigate({ direction: Direction.DOWN });
|
|
1034
|
-
// break;
|
|
1035
|
-
// case KeyCode.ARROW_UP:
|
|
1036
|
-
// formulaPromptService.navigate({ direction: Direction.UP });
|
|
1037
|
-
// break;
|
|
1038
|
-
// // case KeyCode.ENTER:
|
|
1039
|
-
// // case KeyCode.TAB:
|
|
1040
|
-
// // if (formulaPromptService.isSearching()) {
|
|
1041
|
-
// // formulaPromptService.accept(true);
|
|
1042
|
-
// // } else {
|
|
1043
|
-
// // const editorBridgeParameters = {
|
|
1044
|
-
// // visible: false,
|
|
1045
|
-
// // eventType,
|
|
1046
|
-
// // keycode,
|
|
1047
|
-
// // };
|
|
1048
|
-
// // editorBridgeService.changeVisible(editorBridgeParameters);
|
|
1049
|
-
// // }
|
|
1050
|
-
// // break;
|
|
1051
|
-
// default:
|
|
1052
|
-
// break;
|
|
1053
|
-
// }
|
|
1054
|
-
true);
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
// src/commands/operations/help-function.operation.ts
|
|
1058
|
-
var import_core6 = require("@univerjs/core");
|
|
1059
|
-
// src/services/prompt.service.ts
|
|
1060
|
-
var import_redi4 = require("@wendellhu/redi");
|
|
1061
|
-
var import_rxjs2 = require("rxjs");
|
|
1062
|
-
var IFormulaPromptService = (0, import_redi4.createIdentifier)("formula-ui.prompt-service");
|
|
1063
|
-
var FormulaPromptService = /*#__PURE__*/ function() {
|
|
1064
|
-
function FormulaPromptService() {
|
|
1065
|
-
_class_call_check(this, FormulaPromptService);
|
|
1066
|
-
_define_property(this, "_search$", new import_rxjs2.Subject());
|
|
1067
|
-
_define_property(this, "_help$", new import_rxjs2.Subject());
|
|
1068
|
-
_define_property(this, "_navigate$", new import_rxjs2.Subject());
|
|
1069
|
-
_define_property(this, "_accept$", new import_rxjs2.Subject());
|
|
1070
|
-
_define_property(this, "_acceptFormulaName$", new import_rxjs2.Subject());
|
|
1071
|
-
_define_property(this, "search$", this._search$.asObservable());
|
|
1072
|
-
_define_property(this, "help$", this._help$.asObservable());
|
|
1073
|
-
_define_property(this, "navigate$", this._navigate$.asObservable());
|
|
1074
|
-
_define_property(this, "accept$", this._accept$.asObservable());
|
|
1075
|
-
_define_property(this, "acceptFormulaName$", this._acceptFormulaName$.asObservable());
|
|
1076
|
-
_define_property(this, "_searching", false);
|
|
1077
|
-
_define_property(this, "_helping", false);
|
|
1078
|
-
_define_property(this, "_isInsertRefString", false);
|
|
1079
|
-
}
|
|
1080
|
-
_create_class(FormulaPromptService, [
|
|
1081
|
-
{
|
|
1082
|
-
key: "dispose",
|
|
1083
|
-
value: function dispose() {
|
|
1084
|
-
this._search$.complete();
|
|
1085
|
-
this._help$.complete();
|
|
1086
|
-
this._navigate$.complete();
|
|
1087
|
-
this._accept$.complete();
|
|
1088
|
-
this._acceptFormulaName$.complete();
|
|
1089
|
-
}
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
key: "search",
|
|
1093
|
-
value: function search(param) {
|
|
1094
|
-
this._searching = param.visible;
|
|
1095
|
-
this._search$.next(param);
|
|
1096
|
-
}
|
|
1097
|
-
},
|
|
1098
|
-
{
|
|
1099
|
-
key: "isSearching",
|
|
1100
|
-
value: function isSearching() {
|
|
1101
|
-
return this._searching;
|
|
1102
|
-
}
|
|
1103
|
-
},
|
|
1104
|
-
{
|
|
1105
|
-
key: "help",
|
|
1106
|
-
value: function help(param) {
|
|
1107
|
-
this._helping = param.visible;
|
|
1108
|
-
this._help$.next(param);
|
|
1109
|
-
}
|
|
1110
|
-
},
|
|
1111
|
-
{
|
|
1112
|
-
key: "isHelping",
|
|
1113
|
-
value: function isHelping() {
|
|
1114
|
-
return this._helping;
|
|
1115
|
-
}
|
|
1116
|
-
},
|
|
1117
|
-
{
|
|
1118
|
-
key: "navigate",
|
|
1119
|
-
value: function navigate(param) {
|
|
1120
|
-
this._navigate$.next(param);
|
|
1121
|
-
}
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
key: "accept",
|
|
1125
|
-
value: function accept(param) {
|
|
1126
|
-
this._accept$.next(param);
|
|
1127
|
-
}
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
key: "acceptFormulaName",
|
|
1131
|
-
value: function acceptFormulaName(param) {
|
|
1132
|
-
this._acceptFormulaName$.next(param);
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
]);
|
|
1136
|
-
return FormulaPromptService;
|
|
1137
|
-
}();
|
|
1138
|
-
// src/commands/operations/help-function.operation.ts
|
|
1139
|
-
var HelpFunctionOperation = {
|
|
1140
|
-
id: "formula-ui.operation.help-function",
|
|
1141
|
-
type: import_core6.CommandType.OPERATION,
|
|
1142
|
-
handler: function() {
|
|
1143
|
-
var _ref = _async_to_generator(function(accessor, params) {
|
|
1144
|
-
var promptService;
|
|
1145
|
-
return _ts_generator(this, function(_state) {
|
|
1146
|
-
promptService = accessor.get(IFormulaPromptService);
|
|
1147
|
-
promptService.help(params);
|
|
1148
|
-
return [
|
|
1149
|
-
2,
|
|
1150
|
-
true
|
|
1151
|
-
];
|
|
1152
|
-
});
|
|
1153
|
-
});
|
|
1154
|
-
return function(accessor, params) {
|
|
1155
|
-
return _ref.apply(this, arguments);
|
|
1156
|
-
};
|
|
1157
|
-
}()
|
|
1158
|
-
};
|
|
1159
|
-
// src/commands/operations/insert-function.operation.ts
|
|
1160
|
-
var import_core7 = require("@univerjs/core");
|
|
1161
|
-
var import_sheets2 = require("@univerjs/sheets");
|
|
1162
|
-
var InsertFunctionOperation = {
|
|
1163
|
-
id: "formula-ui.operation.insert-function",
|
|
1164
|
-
type: import_core7.CommandType.OPERATION,
|
|
1165
|
-
handler: function() {
|
|
1166
|
-
var _ref = _async_to_generator(function(accessor, params) {
|
|
1167
|
-
var selectionManagerService, formulaInputService, currentSelections, univerInstanceService, cellMatrix, value, commandService, list;
|
|
1168
|
-
return _ts_generator(this, function(_state) {
|
|
1169
|
-
selectionManagerService = accessor.get(import_sheets2.SelectionManagerService);
|
|
1170
|
-
formulaInputService = accessor.get(IFormulaInputService);
|
|
1171
|
-
currentSelections = selectionManagerService.getSelections();
|
|
1172
|
-
if (!currentSelections || !currentSelections.length) {
|
|
1173
|
-
return [
|
|
1174
|
-
2,
|
|
1175
|
-
false
|
|
1176
|
-
];
|
|
1177
|
-
}
|
|
1178
|
-
univerInstanceService = accessor.get(import_core7.IUniverInstanceService);
|
|
1179
|
-
cellMatrix = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix();
|
|
1180
|
-
value = params.value;
|
|
1181
|
-
commandService = accessor.get(import_core7.ICommandService);
|
|
1182
|
-
list = [];
|
|
1183
|
-
currentSelections.some(function(selection) {
|
|
1184
|
-
var range = selection.range, primary = selection.primary;
|
|
1185
|
-
var _primary_actualRow;
|
|
1186
|
-
var row = (_primary_actualRow = primary === null || primary === void 0 ? void 0 : primary.actualRow) !== null && _primary_actualRow !== void 0 ? _primary_actualRow : range.startRow;
|
|
1187
|
-
var _primary_actualColumn;
|
|
1188
|
-
var column = (_primary_actualColumn = primary === null || primary === void 0 ? void 0 : primary.actualColumn) !== null && _primary_actualColumn !== void 0 ? _primary_actualColumn : range.startColumn;
|
|
1189
|
-
var refRange = findRefRange(cellMatrix, row, column);
|
|
1190
|
-
if (!refRange) {
|
|
1191
|
-
formulaInputService.inputFormula("=".concat(value, "("));
|
|
1192
|
-
return true;
|
|
1193
|
-
}
|
|
1194
|
-
var rangeString = (0, import_core7.serializeRange)(refRange);
|
|
1195
|
-
var formulaString = "=".concat(value, "(").concat(rangeString, ")");
|
|
1196
|
-
list.push({
|
|
1197
|
-
range: range,
|
|
1198
|
-
primary: {
|
|
1199
|
-
row: row,
|
|
1200
|
-
column: column
|
|
1201
|
-
},
|
|
1202
|
-
formula: formulaString
|
|
1203
|
-
});
|
|
1204
|
-
return false;
|
|
1205
|
-
});
|
|
1206
|
-
if (list.length === 0) return [
|
|
1207
|
-
2,
|
|
1208
|
-
false
|
|
1209
|
-
];
|
|
1210
|
-
return [
|
|
1211
|
-
2,
|
|
1212
|
-
commandService.executeCommand(InsertFunctionCommand.id, {
|
|
1213
|
-
list: list
|
|
1214
|
-
})
|
|
1215
|
-
];
|
|
1216
|
-
});
|
|
1217
|
-
});
|
|
1218
|
-
return function(accessor, params) {
|
|
1219
|
-
return _ref.apply(this, arguments);
|
|
1220
|
-
};
|
|
1221
|
-
}()
|
|
1222
|
-
};
|
|
1223
|
-
function findRefRange(cellMatrix, row, column) {
|
|
1224
|
-
var startRow = findStartRow(cellMatrix, row, column);
|
|
1225
|
-
if (startRow !== row) {
|
|
1226
|
-
return {
|
|
1227
|
-
startRow: startRow,
|
|
1228
|
-
endRow: row - 1,
|
|
1229
|
-
startColumn: column,
|
|
1230
|
-
endColumn: column
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
var startColumn = findStartColumn(cellMatrix, row, column);
|
|
1234
|
-
if (startColumn !== column) {
|
|
1235
|
-
return {
|
|
1236
|
-
startRow: row,
|
|
1237
|
-
endRow: row,
|
|
1238
|
-
startColumn: startColumn,
|
|
1239
|
-
endColumn: column - 1
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
|
-
return null;
|
|
1243
|
-
}
|
|
1244
|
-
function findStartRow(cellMatrix, row, column) {
|
|
1245
|
-
var isFirstNumber = false;
|
|
1246
|
-
if (row === 0) return row;
|
|
1247
|
-
for(var r = row - 1; r >= 0; r--){
|
|
1248
|
-
var cell = cellMatrix.getValue(r, column);
|
|
1249
|
-
if (isNumberCell(cell) && !isFirstNumber) {
|
|
1250
|
-
if (r === 0) return 0;
|
|
1251
|
-
isFirstNumber = true;
|
|
1252
|
-
} else if (isFirstNumber && !isNumberCell(cell)) {
|
|
1253
|
-
return r + 1;
|
|
1254
|
-
} else if (isFirstNumber && r === 0) {
|
|
1255
|
-
return 0;
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
return row;
|
|
1259
|
-
}
|
|
1260
|
-
function findStartColumn(cellMatrix, row, column) {
|
|
1261
|
-
var isFirstNumber = false;
|
|
1262
|
-
if (column === 0) return column;
|
|
1263
|
-
for(var c = column - 1; c >= 0; c--){
|
|
1264
|
-
var cell = cellMatrix.getValue(row, c);
|
|
1265
|
-
if (isNumberCell(cell) && !isFirstNumber) {
|
|
1266
|
-
if (c === 0) return 0;
|
|
1267
|
-
isFirstNumber = true;
|
|
1268
|
-
} else if (isFirstNumber && !isNumberCell(cell)) {
|
|
1269
|
-
return c + 1;
|
|
1270
|
-
} else if (isFirstNumber && c === 0) {
|
|
1271
|
-
return 0;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
return column;
|
|
1275
|
-
}
|
|
1276
|
-
function isNumberCell(cell) {
|
|
1277
|
-
return cell && (import_core7.Tools.isStringNumber(cell.v) || (0, import_core7.getCellValueType)(cell) === import_core7.CellValueType.NUMBER);
|
|
1278
|
-
}
|
|
1279
|
-
// src/commands/operations/more-functions.operation.ts
|
|
1280
|
-
var import_core8 = require("@univerjs/core");
|
|
1281
|
-
var import_ui2 = require("@univerjs/ui");
|
|
1282
|
-
// src/views/more-functions/interface.ts
|
|
1283
|
-
var MORE_FUNCTIONS_COMPONENT = "".concat(FORMULA_UI_PLUGIN_NAME, "_MORE_FUNCTIONS_COMPONENT");
|
|
1284
|
-
// src/commands/operations/more-functions.operation.ts
|
|
1285
|
-
var MoreFunctionsOperation = {
|
|
1286
|
-
id: "formula-ui.operation.more-functions",
|
|
1287
|
-
type: import_core8.CommandType.OPERATION,
|
|
1288
|
-
handler: function() {
|
|
1289
|
-
var _ref = _async_to_generator(function(accessor) {
|
|
1290
|
-
var sidebarService;
|
|
1291
|
-
return _ts_generator(this, function(_state) {
|
|
1292
|
-
sidebarService = accessor.get(import_ui2.ISidebarService);
|
|
1293
|
-
sidebarService.open({
|
|
1294
|
-
header: {
|
|
1295
|
-
title: "formula.insert.tooltip"
|
|
1296
|
-
},
|
|
1297
|
-
children: {
|
|
1298
|
-
label: MORE_FUNCTIONS_COMPONENT
|
|
1299
|
-
}
|
|
1300
|
-
});
|
|
1301
|
-
return [
|
|
1302
|
-
2,
|
|
1303
|
-
true
|
|
1304
|
-
];
|
|
1305
|
-
});
|
|
1306
|
-
});
|
|
1307
|
-
return function(accessor) {
|
|
1308
|
-
return _ref.apply(this, arguments);
|
|
1309
|
-
};
|
|
1310
|
-
}()
|
|
1311
|
-
};
|
|
1312
|
-
// src/commands/operations/search-function.operation.ts
|
|
1313
|
-
var import_core9 = require("@univerjs/core");
|
|
1314
|
-
var SearchFunctionOperation = {
|
|
1315
|
-
id: "formula-ui.operation.search-function",
|
|
1316
|
-
type: import_core9.CommandType.OPERATION,
|
|
1317
|
-
handler: function() {
|
|
1318
|
-
var _ref = _async_to_generator(function(accessor, params) {
|
|
1319
|
-
var promptService;
|
|
1320
|
-
return _ts_generator(this, function(_state) {
|
|
1321
|
-
promptService = accessor.get(IFormulaPromptService);
|
|
1322
|
-
promptService.search(params);
|
|
1323
|
-
return [
|
|
1324
|
-
2,
|
|
1325
|
-
true
|
|
1326
|
-
];
|
|
1327
|
-
});
|
|
1328
|
-
});
|
|
1329
|
-
return function(accessor, params) {
|
|
1330
|
-
return _ref.apply(this, arguments);
|
|
1331
|
-
};
|
|
1332
|
-
}()
|
|
1333
|
-
};
|
|
1334
|
-
// src/views/FormulaPromptContainer.tsx
|
|
1335
|
-
var import_react4 = __toESM(require("react"));
|
|
1336
|
-
// src/views/prompt/error-function/error-function.tsx
|
|
1337
|
-
var import_sheets_ui3 = require("@univerjs/sheets-ui");
|
|
1338
|
-
var import_react_bindings = require("@wendellhu/redi/react-bindings");
|
|
1339
|
-
var import_react = __toESM(require("react"));
|
|
1340
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/error-function/index.module.less
|
|
1341
|
-
var index_module_default = {
|
|
1342
|
-
"formulaErrorFunction": "univer-formula-error-function"
|
|
1343
|
-
};
|
|
1344
|
-
// src/views/prompt/error-function/error-function.tsx
|
|
1345
|
-
function ErrorFunction() {
|
|
1346
|
-
var _ref = _sliced_to_array((0, import_react.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
|
|
1347
|
-
var _ref1 = _sliced_to_array((0, import_react.useState)({
|
|
1348
|
-
left: 0,
|
|
1349
|
-
top: 0
|
|
1350
|
-
}), 2), position = _ref1[0], setPosition = _ref1[1];
|
|
1351
|
-
var promptService = (0, import_react_bindings.useDependency)(IFormulaPromptService);
|
|
1352
|
-
var cellEditorManagerService = (0, import_react_bindings.useDependency)(import_sheets_ui3.ICellEditorManagerService);
|
|
1353
|
-
(0, import_react.useEffect)(function() {
|
|
1354
|
-
var subscription = promptService.help$.subscribe(function(params) {
|
|
1355
|
-
var selection = cellEditorManagerService.getState();
|
|
1356
|
-
if (!selection) return;
|
|
1357
|
-
var visible2 = params.visible;
|
|
1358
|
-
if (!visible2) {
|
|
1359
|
-
setVisible(visible2);
|
|
1360
|
-
return;
|
|
1361
|
-
}
|
|
1362
|
-
var _selection_endX = selection.endX, endX = _selection_endX === void 0 ? 0 : _selection_endX, _selection_startY = selection.startY, startY = _selection_startY === void 0 ? 0 : _selection_startY;
|
|
1363
|
-
setPosition({
|
|
1364
|
-
left: endX,
|
|
1365
|
-
top: startY
|
|
1366
|
-
});
|
|
1367
|
-
setVisible(visible2);
|
|
1368
|
-
});
|
|
1369
|
-
return function() {
|
|
1370
|
-
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
1371
|
-
};
|
|
1372
|
-
}, []);
|
|
1373
|
-
return visible ? /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1374
|
-
className: index_module_default.formulaErrorFunction,
|
|
1375
|
-
style: {
|
|
1376
|
-
left: position.left,
|
|
1377
|
-
top: position.top
|
|
1378
|
-
}
|
|
1379
|
-
}) : null;
|
|
1380
|
-
}
|
|
1381
|
-
// src/views/prompt/help-function/HelpFunction.tsx
|
|
1382
|
-
var import_core10 = require("@univerjs/core");
|
|
1383
|
-
var import_design = require("@univerjs/design");
|
|
1384
|
-
var import_icons = require("@univerjs/icons");
|
|
1385
|
-
var import_sheets_ui4 = require("@univerjs/sheets-ui");
|
|
1386
|
-
var import_react_bindings2 = require("@wendellhu/redi/react-bindings");
|
|
1387
|
-
var import_react2 = __toESM(require("react"));
|
|
1388
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/help-function/index.module.less
|
|
1389
|
-
var index_module_default2 = {
|
|
1390
|
-
"formulaHelpFunction": "univer-formula-help-function",
|
|
1391
|
-
"formulaHelpFunctionTitle": "univer-formula-help-function-title",
|
|
1392
|
-
"formulaHelpFunctionTitleIcons": "univer-formula-help-function-title-icons",
|
|
1393
|
-
"formulaHelpFunctionTitleIcon": "univer-formula-help-function-title-icon",
|
|
1394
|
-
"formulaHelpFunctionContent": "univer-formula-help-function-content",
|
|
1395
|
-
"formulaHelpFunctionContentInner": "univer-formula-help-function-content-inner",
|
|
1396
|
-
"formulaHelpFunctionContentParams": "univer-formula-help-function-content-params",
|
|
1397
|
-
"formulaHelpFunctionContentParamsTitle": "univer-formula-help-function-content-params-title",
|
|
1398
|
-
"formulaHelpFunctionContentParamsDetail": "univer-formula-help-function-content-params-detail",
|
|
1399
|
-
"formulaHelpFunctionActive": "univer-formula-help-function-active",
|
|
1400
|
-
"formulaHelpDecorator": "univer-formula-help-decorator"
|
|
1401
|
-
};
|
|
1402
|
-
// src/views/prompt/help-function/HelpFunction.tsx
|
|
1403
|
-
function HelpFunction() {
|
|
1404
|
-
var _ref = _sliced_to_array((0, import_react2.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
|
|
1405
|
-
var _ref1 = _sliced_to_array((0, import_react2.useState)(true), 2), contentVisible = _ref1[0], setContentVisible = _ref1[1];
|
|
1406
|
-
var _ref2 = _sliced_to_array((0, import_react2.useState)(true), 2), helpVisible = _ref2[0], setHelpVisible = _ref2[1];
|
|
1407
|
-
var _ref3 = _sliced_to_array((0, import_react2.useState)(0), 2), paramIndex = _ref3[0], setParamIndex = _ref3[1];
|
|
1408
|
-
var _ref4 = _sliced_to_array((0, import_react2.useState)([
|
|
1409
|
-
0,
|
|
1410
|
-
0
|
|
1411
|
-
]), 2), offset = _ref4[0], setOffset = _ref4[1];
|
|
1412
|
-
var _ref5 = _sliced_to_array((0, import_react2.useState)({
|
|
1413
|
-
left: 0,
|
|
1414
|
-
top: 0
|
|
1415
|
-
}), 2), decoratorPosition = _ref5[0], setDecoratorPosition = _ref5[1];
|
|
1416
|
-
var _ref6 = _sliced_to_array((0, import_react2.useState)(null), 2), functionInfo = _ref6[0], setFunctionInfo = _ref6[1];
|
|
1417
|
-
var promptService = (0, import_react_bindings2.useDependency)(IFormulaPromptService);
|
|
1418
|
-
var cellEditorManagerService = (0, import_react_bindings2.useDependency)(import_sheets_ui4.ICellEditorManagerService);
|
|
1419
|
-
var localeService = (0, import_react_bindings2.useDependency)(import_core10.LocaleService);
|
|
1420
|
-
var formulaEditorManagerService = (0, import_react_bindings2.useDependency)(import_sheets_ui4.IFormulaEditorManagerService);
|
|
1421
|
-
var contextService = (0, import_react_bindings2.useDependency)(import_core10.IContextService);
|
|
1422
|
-
var required = localeService.t("formula.prompt.required");
|
|
1423
|
-
var optional = localeService.t("formula.prompt.optional");
|
|
1424
|
-
(0, import_react2.useEffect)(function() {
|
|
1425
|
-
var subscription = promptService.help$.subscribe(function(params) {
|
|
1426
|
-
var visible2 = params.visible, paramIndex2 = params.paramIndex, functionInfo2 = params.functionInfo;
|
|
1427
|
-
if (!visible2) {
|
|
1428
|
-
setVisible(visible2);
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
var isFocusFormulaEditor = contextService.getContextValue(import_core10.FOCUSING_FORMULA_EDITOR);
|
|
1432
|
-
var position = isFocusFormulaEditor ? formulaEditorManagerService.getPosition() : cellEditorManagerService.getRect();
|
|
1433
|
-
if (position == null) {
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
var left = position.left, top = position.top, height = position.height;
|
|
1437
|
-
var localeInfo = {
|
|
1438
|
-
functionName: functionInfo2.functionName,
|
|
1439
|
-
functionType: functionInfo2.functionType,
|
|
1440
|
-
description: localeService.t(functionInfo2.description),
|
|
1441
|
-
abstract: localeService.t(functionInfo2.abstract),
|
|
1442
|
-
functionParameter: functionInfo2.functionParameter.map(function(item) {
|
|
1443
|
-
return {
|
|
1444
|
-
name: localeService.t(item.name),
|
|
1445
|
-
detail: localeService.t(item.detail),
|
|
1446
|
-
example: item.example,
|
|
1447
|
-
require: item.require,
|
|
1448
|
-
repeat: item.repeat
|
|
1449
|
-
};
|
|
1450
|
-
})
|
|
1451
|
-
};
|
|
1452
|
-
setOffset([
|
|
1453
|
-
left,
|
|
1454
|
-
top + height
|
|
1455
|
-
]);
|
|
1456
|
-
setParamIndex(paramIndex2);
|
|
1457
|
-
setFunctionInfo(localeInfo);
|
|
1458
|
-
setDecoratorPosition({
|
|
1459
|
-
left: left,
|
|
1460
|
-
top: top
|
|
1461
|
-
});
|
|
1462
|
-
setVisible(visible2);
|
|
1463
|
-
});
|
|
1464
|
-
return function() {
|
|
1465
|
-
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
1466
|
-
};
|
|
1467
|
-
}, []);
|
|
1468
|
-
function handleSwitchActive(paramIndex2) {
|
|
1469
|
-
setParamIndex(paramIndex2);
|
|
1470
|
-
}
|
|
1471
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, helpVisible ? /* @__PURE__ */ import_react2.default.createElement(import_design.Popup, {
|
|
1472
|
-
visible: visible,
|
|
1473
|
-
offset: offset
|
|
1474
|
-
}, functionInfo ? /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1475
|
-
className: index_module_default2.formulaHelpFunction
|
|
1476
|
-
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1477
|
-
className: index_module_default2.formulaHelpFunctionTitle
|
|
1478
|
-
}, /* @__PURE__ */ import_react2.default.createElement(Help, {
|
|
1479
|
-
prefix: functionInfo.functionName,
|
|
1480
|
-
value: functionInfo.functionParameter,
|
|
1481
|
-
active: paramIndex,
|
|
1482
|
-
onClick: handleSwitchActive
|
|
1483
|
-
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1484
|
-
className: index_module_default2.formulaHelpFunctionTitleIcons
|
|
1485
|
-
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1486
|
-
className: index_module_default2.formulaHelpFunctionTitleIcon,
|
|
1487
|
-
style: {
|
|
1488
|
-
transform: contentVisible ? "rotateZ(-90deg)" : "rotateZ(90deg)"
|
|
1489
|
-
},
|
|
1490
|
-
onClick: function() {
|
|
1491
|
-
return setContentVisible(!contentVisible);
|
|
1492
|
-
}
|
|
1493
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_icons.MoreSingle, null)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1494
|
-
className: index_module_default2.formulaHelpFunctionTitleIcon,
|
|
1495
|
-
onClick: function() {
|
|
1496
|
-
return setHelpVisible(!helpVisible);
|
|
1497
|
-
}
|
|
1498
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_icons.CloseSingle, null)))), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1499
|
-
className: index_module_default2.formulaHelpFunctionContent,
|
|
1500
|
-
style: {
|
|
1501
|
-
height: contentVisible ? "unset" : 0
|
|
1502
|
-
}
|
|
1503
|
-
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1504
|
-
className: index_module_default2.formulaHelpFunctionContentInner
|
|
1505
|
-
}, /* @__PURE__ */ import_react2.default.createElement(Params, {
|
|
1506
|
-
title: localeService.t("formula.prompt.helpExample"),
|
|
1507
|
-
value: "".concat(functionInfo.functionName, "(").concat(functionInfo.functionParameter.map(function(item) {
|
|
1508
|
-
return item.example;
|
|
1509
|
-
}).join(","), ")")
|
|
1510
|
-
}), /* @__PURE__ */ import_react2.default.createElement(Params, {
|
|
1511
|
-
title: localeService.t("formula.prompt.helpAbstract"),
|
|
1512
|
-
value: functionInfo.description
|
|
1513
|
-
}), functionInfo && functionInfo.functionParameter && functionInfo.functionParameter.map(function(item, i) {
|
|
1514
|
-
return /* @__PURE__ */ import_react2.default.createElement(Params, {
|
|
1515
|
-
key: i,
|
|
1516
|
-
className: paramIndex === i ? index_module_default2.formulaHelpFunctionActive : "",
|
|
1517
|
-
title: item.name,
|
|
1518
|
-
value: "".concat(item.require ? required : optional, " ").concat(item.detail)
|
|
1519
|
-
});
|
|
1520
|
-
})))) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null)) : visible ? /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1521
|
-
className: index_module_default2.formulaHelpDecorator,
|
|
1522
|
-
onClick: function() {
|
|
1523
|
-
return setHelpVisible(!helpVisible);
|
|
1524
|
-
},
|
|
1525
|
-
style: {
|
|
1526
|
-
left: decoratorPosition.left - 24,
|
|
1527
|
-
top: decoratorPosition.top
|
|
1528
|
-
}
|
|
1529
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_icons.DetailsSingle, null)) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null));
|
|
1530
|
-
}
|
|
1531
|
-
var Params = function(props) {
|
|
1532
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1533
|
-
className: index_module_default2.formulaHelpFunctionContentParams
|
|
1534
|
-
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1535
|
-
className: "".concat(index_module_default2.formulaHelpFunctionContentParamsTitle, " ").concat(props.className)
|
|
1536
|
-
}, props.title), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1537
|
-
className: index_module_default2.formulaHelpFunctionContentParamsDetail
|
|
1538
|
-
}, props.value));
|
|
1539
|
-
};
|
|
1540
|
-
var Help = function(props) {
|
|
1541
|
-
var prefix = props.prefix, value = props.value, active = props.active, onClick = props.onClick;
|
|
1542
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", null, /* @__PURE__ */ import_react2.default.createElement("span", null, prefix, "("), value && value.map(function(item, i) {
|
|
1543
|
-
return(// TODO@Dushusir: more params needs to be active
|
|
1544
|
-
/* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1545
|
-
key: i
|
|
1546
|
-
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1547
|
-
className: active === i ? index_module_default2.formulaHelpFunctionActive : "",
|
|
1548
|
-
onClick: function() {
|
|
1549
|
-
return onClick(i);
|
|
1550
|
-
}
|
|
1551
|
-
}, item.repeat ? "[".concat(item.name, ",...]") : item.name), i === value.length - 1 ? "" : ","));
|
|
1552
|
-
}), ")");
|
|
1553
|
-
};
|
|
1554
|
-
// src/views/prompt/search-function/SearchFunction.tsx
|
|
1555
|
-
var import_core11 = require("@univerjs/core");
|
|
1556
|
-
var import_design2 = require("@univerjs/design");
|
|
1557
|
-
var import_sheets_ui5 = require("@univerjs/sheets-ui");
|
|
1558
|
-
var import_react_bindings3 = require("@wendellhu/redi/react-bindings");
|
|
1559
|
-
var import_react3 = __toESM(require("react"));
|
|
1560
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/search-function/index.module.less
|
|
1561
|
-
var index_module_default3 = {
|
|
1562
|
-
"formulaSearchFunction": "univer-formula-search-function",
|
|
1563
|
-
"formulaSearchFunctionItem": "univer-formula-search-function-item",
|
|
1564
|
-
"formulaSearchFunctionItemName": "univer-formula-search-function-item-name",
|
|
1565
|
-
"formulaSearchFunctionItemNameLight": "univer-formula-search-function-item-name-light",
|
|
1566
|
-
"formulaSearchFunctionItemDesc": "univer-formula-search-function-item-desc",
|
|
1567
|
-
"formulaSearchFunctionItemActive": "univer-formula-search-function-item-active"
|
|
1568
|
-
};
|
|
1569
|
-
// src/views/prompt/search-function/SearchFunction.tsx
|
|
1570
|
-
function SearchFunction() {
|
|
1571
|
-
var _ref = _sliced_to_array((0, import_react3.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
|
|
1572
|
-
var _ref1 = _sliced_to_array((0, import_react3.useState)(0), 2), active = _ref1[0], setActive = _ref1[1];
|
|
1573
|
-
var _ref2 = _sliced_to_array((0, import_react3.useState)([
|
|
1574
|
-
0,
|
|
1575
|
-
0
|
|
1576
|
-
]), 2), offset = _ref2[0], setOffset = _ref2[1];
|
|
1577
|
-
var _ref3 = _sliced_to_array((0, import_react3.useState)([]), 2), searchList = _ref3[0], setSearchList = _ref3[1];
|
|
1578
|
-
var _ref4 = _sliced_to_array((0, import_react3.useState)(""), 2), searchText = _ref4[0], setSearchText = _ref4[1];
|
|
1579
|
-
var promptService = (0, import_react_bindings3.useDependency)(IFormulaPromptService);
|
|
1580
|
-
var cellEditorManagerService = (0, import_react_bindings3.useDependency)(import_sheets_ui5.ICellEditorManagerService);
|
|
1581
|
-
var formulaEditorManagerService = (0, import_react_bindings3.useDependency)(import_sheets_ui5.IFormulaEditorManagerService);
|
|
1582
|
-
var contextService = (0, import_react_bindings3.useDependency)(import_core11.IContextService);
|
|
1583
|
-
(0, import_react3.useEffect)(function() {
|
|
1584
|
-
var updatedSearchList = [];
|
|
1585
|
-
var updatedActive = 0;
|
|
1586
|
-
var subscribeSearch = promptService.search$.subscribe(function(params) {
|
|
1587
|
-
var visible2 = params.visible, searchText2 = params.searchText, searchList2 = params.searchList;
|
|
1588
|
-
if (!visible2) {
|
|
1589
|
-
setVisible(visible2);
|
|
1590
|
-
return;
|
|
1591
|
-
}
|
|
1592
|
-
var isFocusFormulaEditor = contextService.getContextValue(import_core11.FOCUSING_FORMULA_EDITOR);
|
|
1593
|
-
var position = isFocusFormulaEditor ? formulaEditorManagerService.getPosition() : cellEditorManagerService.getRect();
|
|
1594
|
-
if (position == null) {
|
|
1595
|
-
return;
|
|
1596
|
-
}
|
|
1597
|
-
var left = position.left, top = position.top, height = position.height;
|
|
1598
|
-
setSearchText(searchText2);
|
|
1599
|
-
setSearchList(searchList2);
|
|
1600
|
-
updatedSearchList = searchList2;
|
|
1601
|
-
setOffset([
|
|
1602
|
-
left,
|
|
1603
|
-
top + height
|
|
1604
|
-
]);
|
|
1605
|
-
setVisible(visible2);
|
|
1606
|
-
setActive(0);
|
|
1607
|
-
});
|
|
1608
|
-
var subscribeNavigate = promptService.navigate$.subscribe(function(params) {
|
|
1609
|
-
var direction = params.direction;
|
|
1610
|
-
if (direction === import_core11.Direction.UP) {
|
|
1611
|
-
var nextActive = updatedActive - 1;
|
|
1612
|
-
nextActive = nextActive < 0 ? updatedSearchList.length - 1 : nextActive;
|
|
1613
|
-
setActive(nextActive);
|
|
1614
|
-
updatedActive = nextActive;
|
|
1615
|
-
} else if (direction === import_core11.Direction.DOWN) {
|
|
1616
|
-
var nextActive1 = updatedActive + 1;
|
|
1617
|
-
nextActive1 = nextActive1 >= updatedSearchList.length ? 0 : nextActive1;
|
|
1618
|
-
setActive(nextActive1);
|
|
1619
|
-
updatedActive = nextActive1;
|
|
1620
|
-
}
|
|
1621
|
-
});
|
|
1622
|
-
var subscribeAccept = promptService.accept$.subscribe(function(params) {
|
|
1623
|
-
var functionName = updatedSearchList[updatedActive].name;
|
|
1624
|
-
promptService.acceptFormulaName(functionName);
|
|
1625
|
-
});
|
|
1626
|
-
return function() {
|
|
1627
|
-
subscribeSearch === null || subscribeSearch === void 0 ? void 0 : subscribeSearch.unsubscribe();
|
|
1628
|
-
subscribeNavigate === null || subscribeNavigate === void 0 ? void 0 : subscribeNavigate.unsubscribe();
|
|
1629
|
-
subscribeAccept === null || subscribeAccept === void 0 ? void 0 : subscribeAccept.unsubscribe();
|
|
1630
|
-
};
|
|
1631
|
-
}, []);
|
|
1632
|
-
function handleLiMouseEnter(index) {
|
|
1633
|
-
setActive(index);
|
|
1634
|
-
}
|
|
1635
|
-
function handleLiMouseLeave() {
|
|
1636
|
-
setActive(-1);
|
|
1637
|
-
}
|
|
1638
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_design2.Popup, {
|
|
1639
|
-
visible: visible,
|
|
1640
|
-
offset: offset
|
|
1641
|
-
}, /* @__PURE__ */ import_react3.default.createElement("ul", {
|
|
1642
|
-
className: index_module_default3.formulaSearchFunction
|
|
1643
|
-
}, searchList.map(function(item, index) {
|
|
1644
|
-
return /* @__PURE__ */ import_react3.default.createElement("li", {
|
|
1645
|
-
key: index,
|
|
1646
|
-
className: active === index ? "".concat(index_module_default3.formulaSearchFunctionItem, " ").concat(index_module_default3.formulaSearchFunctionItemActive) : index_module_default3.formulaSearchFunctionItem,
|
|
1647
|
-
onMouseEnter: function() {
|
|
1648
|
-
return handleLiMouseEnter(index);
|
|
1649
|
-
},
|
|
1650
|
-
onMouseLeave: handleLiMouseLeave,
|
|
1651
|
-
onClick: function() {
|
|
1652
|
-
return promptService.acceptFormulaName(item.name);
|
|
1653
|
-
}
|
|
1654
|
-
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
1655
|
-
className: index_module_default3.formulaSearchFunctionItemName
|
|
1656
|
-
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
1657
|
-
className: index_module_default3.formulaSearchFunctionItemNameLight
|
|
1658
|
-
}, searchText), /* @__PURE__ */ import_react3.default.createElement("span", null, item.name.slice(searchText.length))), /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
1659
|
-
className: index_module_default3.formulaSearchFunctionItemDesc
|
|
1660
|
-
}, item.desc));
|
|
1661
|
-
})));
|
|
1662
|
-
}
|
|
1663
|
-
// src/views/FormulaPromptContainer.tsx
|
|
1664
|
-
function RenderFormulaPromptContent() {
|
|
1665
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(SearchFunction, null), /* @__PURE__ */ import_react4.default.createElement(HelpFunction, null), /* @__PURE__ */ import_react4.default.createElement(ErrorFunction, null));
|
|
1666
|
-
}
|
|
1667
|
-
// src/views/more-functions/MoreFunctions.tsx
|
|
1668
|
-
var import_core14 = require("@univerjs/core");
|
|
1669
|
-
var import_design4 = require("@univerjs/design");
|
|
1670
|
-
var import_ui3 = require("@univerjs/ui");
|
|
1671
|
-
var import_react_bindings5 = require("@wendellhu/redi/react-bindings");
|
|
1672
|
-
var import_react9 = __toESM(require("react"));
|
|
1673
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/index.module.less
|
|
1674
|
-
var index_module_default4 = {
|
|
1675
|
-
"formulaMoreFunctions": "univer-formula-more-functions",
|
|
1676
|
-
"formulaMoreFunctionsOperation": "univer-formula-more-functions-operation"
|
|
1677
|
-
};
|
|
1678
|
-
// src/views/more-functions/input-params/InputParams.tsx
|
|
1679
|
-
var import_sheets_ui6 = require("@univerjs/sheets-ui");
|
|
1680
|
-
var import_react7 = __toESM(require("react"));
|
|
1681
|
-
// src/views/more-functions/function-help/FunctionHelp.tsx
|
|
1682
|
-
var import_react5 = __toESM(require("react"));
|
|
1683
|
-
function FunctionHelp(props) {
|
|
1684
|
-
var prefix = props.prefix, value = props.value;
|
|
1685
|
-
return /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("span", null, prefix, "("), value && value.map(function(item, i) {
|
|
1686
|
-
return /* @__PURE__ */ import_react5.default.createElement("span", {
|
|
1687
|
-
key: i
|
|
1688
|
-
}, /* @__PURE__ */ import_react5.default.createElement("span", null, item.repeat ? "[".concat(item.name, ",...]") : item.name), i === value.length - 1 ? "" : ",");
|
|
1689
|
-
}), ")");
|
|
1690
|
-
}
|
|
1691
|
-
// src/views/more-functions/function-params/FunctionParams.tsx
|
|
1692
|
-
var import_react6 = __toESM(require("react"));
|
|
1693
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/function-params/index.module.less
|
|
1694
|
-
var index_module_default5 = {
|
|
1695
|
-
"formulaFunctionParams": "univer-formula-function-params",
|
|
1696
|
-
"formulaFunctionParamsTitle": "univer-formula-function-params-title",
|
|
1697
|
-
"formulaFunctionParamsDetail": "univer-formula-function-params-detail"
|
|
1698
|
-
};
|
|
1699
|
-
// src/views/more-functions/function-params/FunctionParams.tsx
|
|
1700
|
-
function FunctionParams(props) {
|
|
1701
|
-
var className = props.className, value = props.value, title = props.title;
|
|
1702
|
-
return /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1703
|
-
className: index_module_default5.formulaFunctionParams
|
|
1704
|
-
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1705
|
-
className: "".concat(index_module_default5.formulaFunctionParamsTitle, " ").concat(className)
|
|
1706
|
-
}, title), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1707
|
-
className: index_module_default5.formulaFunctionParamsDetail
|
|
1708
|
-
}, value));
|
|
1709
|
-
}
|
|
1710
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/input-params/index.module.less
|
|
1711
|
-
var index_module_default6 = {
|
|
1712
|
-
"formulaInputParamsList": "univer-formula-input-params-list",
|
|
1713
|
-
"formulaInputParamsListItemName": "univer-formula-input-params-list-item-name",
|
|
1714
|
-
"formulaInputParamsListItemSelector": "univer-formula-input-params-list-item-selector"
|
|
1715
|
-
};
|
|
1716
|
-
// src/views/more-functions/input-params/InputParams.tsx
|
|
1717
|
-
function InputParams(props) {
|
|
1718
|
-
var functionInfo = props.functionInfo, onChange = props.onChange;
|
|
1719
|
-
if (!functionInfo) return null;
|
|
1720
|
-
var _ref = _sliced_to_array((0, import_react7.useState)([]), 2), params = _ref[0], setParams = _ref[1];
|
|
1721
|
-
var _ref1 = _sliced_to_array((0, import_react7.useState)(functionInfo.functionParameter), 2), functionParameter = _ref1[0], setFunctionParameter = _ref1[1];
|
|
1722
|
-
var _ref2 = _sliced_to_array((0, import_react7.useState)(-1), 2), activeIndex = _ref2[0], setActiveIndex = _ref2[1];
|
|
1723
|
-
function handleChange(range, paramIndex) {
|
|
1724
|
-
var newParams = _to_consumable_array(params);
|
|
1725
|
-
newParams[paramIndex] = range;
|
|
1726
|
-
setParams(newParams);
|
|
1727
|
-
onChange(newParams);
|
|
1728
|
-
}
|
|
1729
|
-
function handleActive(i) {
|
|
1730
|
-
if (i === functionParameter.length - 1 && functionParameter[i].repeat) {
|
|
1731
|
-
var newFunctionParameter = _to_consumable_array(functionParameter);
|
|
1732
|
-
newFunctionParameter.push(functionParameter[i]);
|
|
1733
|
-
setFunctionParameter(newFunctionParameter);
|
|
1734
|
-
}
|
|
1735
|
-
setActiveIndex(i);
|
|
1736
|
-
}
|
|
1737
|
-
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1738
|
-
className: index_module_default6.formulaInputParams
|
|
1739
|
-
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1740
|
-
className: index_module_default6.formulaInputParamsList
|
|
1741
|
-
}, functionParameter.map(function(item, i) {
|
|
1742
|
-
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1743
|
-
key: i
|
|
1744
|
-
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1745
|
-
className: index_module_default6.formulaInputParamsListItemName
|
|
1746
|
-
}, item.name), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1747
|
-
className: index_module_default6.formulaInputParamsListItemSelector
|
|
1748
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_sheets_ui6.RangeSelector, {
|
|
1749
|
-
onChange: function(range) {
|
|
1750
|
-
return handleChange(range, i);
|
|
1751
|
-
},
|
|
1752
|
-
onActive: function() {
|
|
1753
|
-
return handleActive(i);
|
|
1754
|
-
}
|
|
1755
|
-
})));
|
|
1756
|
-
})), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1757
|
-
className: index_module_default6.formulaInputParamsInfo
|
|
1758
|
-
}, /* @__PURE__ */ import_react7.default.createElement(FunctionParams, {
|
|
1759
|
-
title: activeIndex === -1 ? /* @__PURE__ */ import_react7.default.createElement(FunctionHelp, {
|
|
1760
|
-
prefix: functionInfo.functionName,
|
|
1761
|
-
value: functionParameter
|
|
1762
|
-
}) : functionParameter[activeIndex].name,
|
|
1763
|
-
value: activeIndex === -1 ? functionInfo.description : functionParameter[activeIndex].detail
|
|
1764
|
-
})));
|
|
1765
|
-
}
|
|
1766
|
-
// src/views/more-functions/select-function/SelectFunction.tsx
|
|
1767
|
-
var import_core13 = require("@univerjs/core");
|
|
1768
|
-
var import_design3 = require("@univerjs/design");
|
|
1769
|
-
var import_engine_formula7 = require("@univerjs/engine-formula");
|
|
1770
|
-
var import_icons2 = require("@univerjs/icons");
|
|
1771
|
-
var import_react_bindings4 = require("@wendellhu/redi/react-bindings");
|
|
1772
|
-
var import_react8 = __toESM(require("react"));
|
|
1773
|
-
// src/services/description.service.ts
|
|
1774
|
-
var import_core12 = require("@univerjs/core");
|
|
1775
|
-
var import_engine_formula6 = require("@univerjs/engine-formula");
|
|
1776
|
-
var import_redi5 = require("@wendellhu/redi");
|
|
1777
|
-
// src/services/function-list/array.ts
|
|
1778
|
-
var FUNCTION_LIST_ARRAY = [];
|
|
1779
|
-
// src/services/function-list/compatibility.ts
|
|
1780
|
-
var FUNCTION_LIST_COMPATIBILITY = [];
|
|
1781
|
-
// src/services/function-list/cube.ts
|
|
1782
|
-
var FUNCTION_LIST_CUBE = [];
|
|
1783
|
-
// src/services/function-list/database.ts
|
|
1784
|
-
var FUNCTION_LIST_DATABASE = [];
|
|
1785
|
-
// src/services/function-list/date.ts
|
|
1786
|
-
var FUNCTION_LIST_DATE = [];
|
|
1787
|
-
// src/services/function-list/engineering.ts
|
|
1788
|
-
var FUNCTION_LIST_ENGINEERING = [];
|
|
1789
|
-
// src/services/function-list/financial.ts
|
|
1790
|
-
var FUNCTION_LIST_FINANCIAL = [];
|
|
1791
|
-
// src/services/function-list/information.ts
|
|
1792
|
-
var FUNCTION_LIST_INFORMATION = [];
|
|
1793
|
-
// src/services/function-list/logical.ts
|
|
1794
|
-
var FUNCTION_LIST_LOGICAL = [];
|
|
1795
|
-
// src/services/function-list/lookup.ts
|
|
1796
|
-
var FUNCTION_LIST_LOOKUP = [];
|
|
1797
|
-
// src/services/function-list/math.ts
|
|
1798
|
-
var import_engine_formula4 = require("@univerjs/engine-formula");
|
|
1799
|
-
var import_formula = require("@univerjs/formula");
|
|
1800
|
-
var FUNCTION_LIST_MATH = [
|
|
1801
|
-
{
|
|
1802
|
-
functionName: import_engine_formula4.FUNCTION_NAMES.SUM,
|
|
1803
|
-
aliasFunctionName: "formula.functionList.SUM.aliasFunctionName",
|
|
1804
|
-
functionType: import_engine_formula4.FunctionType.Math,
|
|
1805
|
-
description: "formula.functionList.SUM.description",
|
|
1806
|
-
abstract: "formula.functionList.SUM.abstract",
|
|
1807
|
-
functionParameter: [
|
|
1808
|
-
{
|
|
1809
|
-
name: "formula.functionList.SUM.functionParameter.number1.name",
|
|
1810
|
-
detail: "formula.functionList.SUM.functionParameter.number1.detail",
|
|
1811
|
-
example: "A1:A20",
|
|
1812
|
-
require: 1,
|
|
1813
|
-
repeat: 0
|
|
1814
|
-
},
|
|
1815
|
-
{
|
|
1816
|
-
name: "formula.functionList.SUM.functionParameter.number2.name",
|
|
1817
|
-
detail: "formula.functionList.SUM.functionParameter.number2.detail",
|
|
1818
|
-
example: "B2:B10",
|
|
1819
|
-
require: 0,
|
|
1820
|
-
repeat: 1
|
|
1821
|
-
}
|
|
1822
|
-
]
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
functionName: import_formula.FUNCTION_NAMES_MATH.SUMIF,
|
|
1826
|
-
aliasFunctionName: "formula.functionList.SUMIF.aliasFunctionName",
|
|
1827
|
-
functionType: import_engine_formula4.FunctionType.Math,
|
|
1828
|
-
description: "formula.functionList.SUMIF.description",
|
|
1829
|
-
abstract: "formula.functionList.SUMIF.abstract",
|
|
1830
|
-
functionParameter: [
|
|
1831
|
-
{
|
|
1832
|
-
name: "formula.functionList.SUMIF.functionParameter.range.name",
|
|
1833
|
-
detail: "formula.functionList.SUMIF.functionParameter.range.detail",
|
|
1834
|
-
example: "A1:A20",
|
|
1835
|
-
require: 1,
|
|
1836
|
-
repeat: 0
|
|
1837
|
-
},
|
|
1838
|
-
{
|
|
1839
|
-
name: "formula.functionList.SUMIF.functionParameter.criteria.name",
|
|
1840
|
-
detail: "formula.functionList.SUMIF.functionParameter.criteria.detail",
|
|
1841
|
-
example: ">5",
|
|
1842
|
-
require: 1,
|
|
1843
|
-
repeat: 0
|
|
1844
|
-
},
|
|
1845
|
-
{
|
|
1846
|
-
name: "formula.functionList.SUMIF.functionParameter.sum_range.name",
|
|
1847
|
-
detail: "formula.functionList.SUMIF.functionParameter.sum_range.detail",
|
|
1848
|
-
example: "B1:B20",
|
|
1849
|
-
require: 0,
|
|
1850
|
-
repeat: 0
|
|
1851
|
-
}
|
|
1852
|
-
]
|
|
1853
|
-
}
|
|
1854
|
-
];
|
|
1855
|
-
// src/services/function-list/statistical.ts
|
|
1856
|
-
var import_engine_formula5 = require("@univerjs/engine-formula");
|
|
1857
|
-
var FUNCTION_LIST_STATISTICAL = [
|
|
1858
|
-
{
|
|
1859
|
-
functionName: import_engine_formula5.FUNCTION_NAMES.AVERAGE,
|
|
1860
|
-
aliasFunctionName: "formula.functionList.AVERAGE.aliasFunctionName",
|
|
1861
|
-
functionType: import_engine_formula5.FunctionType.Statistical,
|
|
1862
|
-
description: "formula.functionList.AVERAGE.description",
|
|
1863
|
-
abstract: "formula.functionList.AVERAGE.abstract",
|
|
1864
|
-
functionParameter: [
|
|
1865
|
-
{
|
|
1866
|
-
name: "formula.functionList.AVERAGE.functionParameter.number1.name",
|
|
1867
|
-
detail: "formula.functionList.AVERAGE.functionParameter.number1.detail",
|
|
1868
|
-
example: "A1:A20",
|
|
1869
|
-
require: 1,
|
|
1870
|
-
repeat: 0
|
|
1871
|
-
},
|
|
1872
|
-
{
|
|
1873
|
-
name: "formula.functionList.AVERAGE.functionParameter.number2.name",
|
|
1874
|
-
detail: "formula.functionList.AVERAGE.functionParameter.number2.detail",
|
|
1875
|
-
example: "B2:B10",
|
|
1876
|
-
require: 0,
|
|
1877
|
-
repeat: 1
|
|
1878
|
-
}
|
|
1879
|
-
]
|
|
1880
|
-
},
|
|
1881
|
-
{
|
|
1882
|
-
functionName: import_engine_formula5.FUNCTION_NAMES.MAX,
|
|
1883
|
-
aliasFunctionName: "formula.functionList.MAX.aliasFunctionName",
|
|
1884
|
-
functionType: import_engine_formula5.FunctionType.Statistical,
|
|
1885
|
-
description: "formula.functionList.MAX.description",
|
|
1886
|
-
abstract: "formula.functionList.MAX.abstract",
|
|
1887
|
-
functionParameter: [
|
|
1888
|
-
{
|
|
1889
|
-
name: "formula.functionList.MAX.functionParameter.number1.name",
|
|
1890
|
-
detail: "formula.functionList.MAX.functionParameter.number1.detail",
|
|
1891
|
-
example: "A1:A20",
|
|
1892
|
-
require: 1,
|
|
1893
|
-
repeat: 0
|
|
1894
|
-
},
|
|
1895
|
-
{
|
|
1896
|
-
name: "formula.functionList.MAX.functionParameter.number2.name",
|
|
1897
|
-
detail: "formula.functionList.MAX.functionParameter.number2.detail",
|
|
1898
|
-
example: "B2:B10",
|
|
1899
|
-
require: 0,
|
|
1900
|
-
repeat: 1
|
|
1901
|
-
}
|
|
1902
|
-
]
|
|
1903
|
-
},
|
|
1904
|
-
{
|
|
1905
|
-
functionName: import_engine_formula5.FUNCTION_NAMES.COUNT,
|
|
1906
|
-
aliasFunctionName: "formula.functionList.COUNT.aliasFunctionName",
|
|
1907
|
-
functionType: import_engine_formula5.FunctionType.Statistical,
|
|
1908
|
-
description: "formula.functionList.COUNT.description",
|
|
1909
|
-
abstract: "formula.functionList.COUNT.abstract",
|
|
1910
|
-
functionParameter: [
|
|
1911
|
-
{
|
|
1912
|
-
name: "formula.functionList.COUNT.functionParameter.value1.name",
|
|
1913
|
-
detail: "formula.functionList.COUNT.functionParameter.value1.detail",
|
|
1914
|
-
example: "A1:A20",
|
|
1915
|
-
require: 1,
|
|
1916
|
-
repeat: 0
|
|
1917
|
-
},
|
|
1918
|
-
{
|
|
1919
|
-
name: "formula.functionList.COUNT.functionParameter.value2.name",
|
|
1920
|
-
detail: "formula.functionList.COUNT.functionParameter.value2.detail",
|
|
1921
|
-
example: "B2:B10",
|
|
1922
|
-
require: 0,
|
|
1923
|
-
repeat: 1
|
|
1924
|
-
}
|
|
1925
|
-
]
|
|
1926
|
-
},
|
|
1927
|
-
{
|
|
1928
|
-
functionName: import_engine_formula5.FUNCTION_NAMES.MIN,
|
|
1929
|
-
aliasFunctionName: "formula.functionList.MIN.aliasFunctionName",
|
|
1930
|
-
functionType: import_engine_formula5.FunctionType.Statistical,
|
|
1931
|
-
description: "formula.functionList.MIN.description",
|
|
1932
|
-
abstract: "formula.functionList.MIN.abstract",
|
|
1933
|
-
functionParameter: [
|
|
1934
|
-
{
|
|
1935
|
-
name: "formula.functionList.MIN.functionParameter.number1.name",
|
|
1936
|
-
detail: "formula.functionList.MIN.functionParameter.number1.detail",
|
|
1937
|
-
example: "A1:A20",
|
|
1938
|
-
require: 1,
|
|
1939
|
-
repeat: 0
|
|
1940
|
-
},
|
|
1941
|
-
{
|
|
1942
|
-
name: "formula.functionList.MIN.functionParameter.number2.name",
|
|
1943
|
-
detail: "formula.functionList.MIN.functionParameter.number2.detail",
|
|
1944
|
-
example: "B2:B10",
|
|
1945
|
-
require: 0,
|
|
1946
|
-
repeat: 1
|
|
1947
|
-
}
|
|
1948
|
-
]
|
|
1949
|
-
}
|
|
1950
|
-
];
|
|
1951
|
-
// src/services/function-list/text.ts
|
|
1952
|
-
var FUNCTION_LIST_TEXT = [];
|
|
1953
|
-
// src/services/function-list/univer.ts
|
|
1954
|
-
var FUNCTION_LIST_UNIVER = [];
|
|
1955
|
-
// src/services/function-list/web.ts
|
|
1956
|
-
var FUNCTION_LIST_WEB = [];
|
|
1957
|
-
// src/services/function-list/function-list.ts
|
|
1958
|
-
var FUNCTION_LIST = _to_consumable_array(FUNCTION_LIST_FINANCIAL).concat(_to_consumable_array(FUNCTION_LIST_DATE), _to_consumable_array(FUNCTION_LIST_MATH), _to_consumable_array(FUNCTION_LIST_STATISTICAL), _to_consumable_array(FUNCTION_LIST_LOOKUP), _to_consumable_array(FUNCTION_LIST_DATABASE), _to_consumable_array(FUNCTION_LIST_TEXT), _to_consumable_array(FUNCTION_LIST_LOGICAL), _to_consumable_array(FUNCTION_LIST_INFORMATION), _to_consumable_array(FUNCTION_LIST_ENGINEERING), _to_consumable_array(FUNCTION_LIST_CUBE), _to_consumable_array(FUNCTION_LIST_COMPATIBILITY), _to_consumable_array(FUNCTION_LIST_WEB), _to_consumable_array(FUNCTION_LIST_ARRAY), _to_consumable_array(FUNCTION_LIST_UNIVER));
|
|
1959
|
-
// src/services/utils.ts
|
|
1960
|
-
function getFunctionTypeValues(enumObj, localeService) {
|
|
1961
|
-
return Object.keys(enumObj).filter(function(key) {
|
|
1962
|
-
return isNaN(Number(key));
|
|
1963
|
-
}).map(function(key) {
|
|
1964
|
-
return {
|
|
1965
|
-
label: localeService.t("formula.functionType.".concat(key.toLocaleLowerCase())),
|
|
1966
|
-
value: "".concat(enumObj[key])
|
|
1967
|
-
};
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
function getFunctionName(item, localeService) {
|
|
1971
|
-
var functionName = "";
|
|
1972
|
-
if (item.aliasFunctionName) {
|
|
1973
|
-
functionName = localeService.t(item.aliasFunctionName);
|
|
1974
|
-
if (functionName === item.aliasFunctionName) {
|
|
1975
|
-
functionName = item.functionName;
|
|
1976
|
-
}
|
|
1977
|
-
} else {
|
|
1978
|
-
functionName = item.functionName;
|
|
1979
|
-
}
|
|
1980
|
-
return functionName;
|
|
1981
|
-
}
|
|
1982
|
-
// src/services/description.service.ts
|
|
1983
|
-
var IDescriptionService = (0, import_redi5.createIdentifier)("formula-ui.description-service");
|
|
1984
|
-
var DescriptionService = /*#__PURE__*/ function() {
|
|
1985
|
-
function DescriptionService(_description, _formulaEngineService, _localeService) {
|
|
1986
|
-
_class_call_check(this, DescriptionService);
|
|
1987
|
-
this._description = _description;
|
|
1988
|
-
this._formulaEngineService = _formulaEngineService;
|
|
1989
|
-
this._localeService = _localeService;
|
|
1990
|
-
this._initialize();
|
|
1991
|
-
this._registerDescription();
|
|
1992
|
-
}
|
|
1993
|
-
_create_class(DescriptionService, [
|
|
1994
|
-
{
|
|
1995
|
-
key: "dispose",
|
|
1996
|
-
value: function dispose() {
|
|
1997
|
-
this._localeService.localeChanged$.complete();
|
|
1998
|
-
}
|
|
1999
|
-
},
|
|
2000
|
-
{
|
|
2001
|
-
key: "getDescriptions",
|
|
2002
|
-
value: function getDescriptions() {
|
|
2003
|
-
return this._formulaEngineService.getDescriptions();
|
|
2004
|
-
}
|
|
2005
|
-
},
|
|
2006
|
-
{
|
|
2007
|
-
key: "hasFunction",
|
|
2008
|
-
value: function hasFunction(searchText) {
|
|
2009
|
-
var functionList = this._formulaEngineService.getDescriptions();
|
|
2010
|
-
return functionList.get(searchText.toLocaleUpperCase()) !== void 0;
|
|
2011
|
-
}
|
|
2012
|
-
},
|
|
2013
|
-
{
|
|
2014
|
-
key: "getFunctionInfo",
|
|
2015
|
-
value: function getFunctionInfo(searchText) {
|
|
2016
|
-
var functionList = this._formulaEngineService.getDescriptions();
|
|
2017
|
-
return functionList.get(searchText.toLocaleUpperCase());
|
|
2018
|
-
}
|
|
2019
|
-
},
|
|
2020
|
-
{
|
|
2021
|
-
key: "getSearchListByName",
|
|
2022
|
-
value: function getSearchListByName(searchText) {
|
|
2023
|
-
var searchList = [];
|
|
2024
|
-
var functionList = this._formulaEngineService.getDescriptions();
|
|
2025
|
-
searchText = searchText.toLocaleUpperCase();
|
|
2026
|
-
functionList.forEach(function(item) {
|
|
2027
|
-
var functionName = item.functionName, abstract = item.abstract;
|
|
2028
|
-
if (functionName.indexOf(searchText) > -1) {
|
|
2029
|
-
searchList.push({
|
|
2030
|
-
name: functionName,
|
|
2031
|
-
desc: abstract
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
});
|
|
2035
|
-
return searchList;
|
|
2036
|
-
}
|
|
2037
|
-
},
|
|
2038
|
-
{
|
|
2039
|
-
key: "getSearchListByType",
|
|
2040
|
-
value: function getSearchListByType(type) {
|
|
2041
|
-
var searchList = [];
|
|
2042
|
-
var functionList = this._formulaEngineService.getDescriptions();
|
|
2043
|
-
functionList.forEach(function(item) {
|
|
2044
|
-
var functionName = item.functionName, functionType = item.functionType, abstract = item.abstract;
|
|
2045
|
-
if (functionType === type || type === -1) {
|
|
2046
|
-
searchList.push({
|
|
2047
|
-
name: functionName,
|
|
2048
|
-
desc: abstract
|
|
2049
|
-
});
|
|
2050
|
-
}
|
|
2051
|
-
});
|
|
2052
|
-
return searchList;
|
|
2053
|
-
}
|
|
2054
|
-
},
|
|
2055
|
-
{
|
|
2056
|
-
key: "_initialize",
|
|
2057
|
-
value: function _initialize() {
|
|
2058
|
-
var _this = this;
|
|
2059
|
-
this._localeService.localeChanged$.subscribe(function() {
|
|
2060
|
-
_this._registerDescription();
|
|
2061
|
-
});
|
|
2062
|
-
}
|
|
2063
|
-
},
|
|
2064
|
-
{
|
|
2065
|
-
key: "_registerDescription",
|
|
2066
|
-
value: function _registerDescription() {
|
|
2067
|
-
var _this__formulaEngineService;
|
|
2068
|
-
var localeService = this._localeService;
|
|
2069
|
-
var functionList = FUNCTION_LIST.concat(this._description || []);
|
|
2070
|
-
var functionListLocale = functionList.map(function(functionInfo) {
|
|
2071
|
-
return {
|
|
2072
|
-
functionName: getFunctionName(functionInfo, localeService),
|
|
2073
|
-
functionType: functionInfo.functionType,
|
|
2074
|
-
description: localeService.t(functionInfo.description),
|
|
2075
|
-
abstract: localeService.t(functionInfo.abstract),
|
|
2076
|
-
functionParameter: functionInfo.functionParameter.map(function(item) {
|
|
2077
|
-
return {
|
|
2078
|
-
name: localeService.t(item.name),
|
|
2079
|
-
detail: localeService.t(item.detail),
|
|
2080
|
-
example: item.example,
|
|
2081
|
-
require: item.require,
|
|
2082
|
-
repeat: item.repeat
|
|
2083
|
-
};
|
|
2084
|
-
})
|
|
2085
|
-
};
|
|
2086
|
-
});
|
|
2087
|
-
(_this__formulaEngineService = this._formulaEngineService).registerDescription.apply(_this__formulaEngineService, _to_consumable_array(functionListLocale));
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
]);
|
|
2091
|
-
return DescriptionService;
|
|
2092
|
-
}();
|
|
2093
|
-
DescriptionService = __decorateClass([
|
|
2094
|
-
__decorateParam(1, (0, import_redi5.Inject)(import_engine_formula6.FormulaEngineService)),
|
|
2095
|
-
__decorateParam(2, (0, import_redi5.Inject)(import_core12.LocaleService))
|
|
2096
|
-
], DescriptionService);
|
|
2097
|
-
// stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/select-function/index.module.less
|
|
2098
|
-
var index_module_default7 = {
|
|
2099
|
-
"formulaSelectFunctionSelect": "univer-formula-select-function-select",
|
|
2100
|
-
"formulaSelectFunctionResult": "univer-formula-select-function-result",
|
|
2101
|
-
"formulaSelectFunctionResultItem": "univer-formula-select-function-result-item",
|
|
2102
|
-
"formulaSelectFunctionResultItemNameLight": "univer-formula-select-function-result-item-name-light",
|
|
2103
|
-
"formulaSelectFunctionResultItemSelected": "univer-formula-select-function-result-item-selected",
|
|
2104
|
-
"formulaSelectFunctionResultItemActive": "univer-formula-select-function-result-item-active",
|
|
2105
|
-
"formulaSelectFunctionContent": "univer-formula-select-function-content"
|
|
2106
|
-
};
|
|
2107
|
-
// src/views/more-functions/select-function/SelectFunction.tsx
|
|
2108
|
-
function SelectFunction(props) {
|
|
2109
|
-
var onChange = props.onChange;
|
|
2110
|
-
var allTypeValue = "-1";
|
|
2111
|
-
var _ref = _sliced_to_array((0, import_react8.useState)(""), 2), searchText = _ref[0], setSearchText = _ref[1];
|
|
2112
|
-
var _ref1 = _sliced_to_array((0, import_react8.useState)([]), 2), selectList = _ref1[0], setSelectList = _ref1[1];
|
|
2113
|
-
var _ref2 = _sliced_to_array((0, import_react8.useState)(0), 2), active = _ref2[0], setActive = _ref2[1];
|
|
2114
|
-
var _ref3 = _sliced_to_array((0, import_react8.useState)(allTypeValue), 2), typeSelected = _ref3[0], setTypeSelected = _ref3[1];
|
|
2115
|
-
var _ref4 = _sliced_to_array((0, import_react8.useState)(0), 2), nameSelected = _ref4[0], setNameSelected = _ref4[1];
|
|
2116
|
-
var _ref5 = _sliced_to_array((0, import_react8.useState)(null), 2), functionInfo = _ref5[0], setFunctionInfo = _ref5[1];
|
|
2117
|
-
var descriptionService = (0, import_react_bindings4.useDependency)(IDescriptionService);
|
|
2118
|
-
var localeService = (0, import_react_bindings4.useDependency)(import_core13.LocaleService);
|
|
2119
|
-
var options = getFunctionTypeValues(import_engine_formula7.FunctionType, localeService);
|
|
2120
|
-
options.unshift({
|
|
2121
|
-
label: localeService.t("formula.moreFunctions.allFunctions"),
|
|
2122
|
-
value: allTypeValue
|
|
2123
|
-
});
|
|
2124
|
-
var required = localeService.t("formula.prompt.required");
|
|
2125
|
-
var optional = localeService.t("formula.prompt.optional");
|
|
2126
|
-
(0, import_react8.useEffect)(function() {
|
|
2127
|
-
handleSelectChange(allTypeValue);
|
|
2128
|
-
}, []);
|
|
2129
|
-
(0, import_react8.useEffect)(function() {
|
|
2130
|
-
setCurrentFunctionInfo(0);
|
|
2131
|
-
}, [
|
|
2132
|
-
selectList
|
|
2133
|
-
]);
|
|
2134
|
-
var highlightSearchText = function(text) {
|
|
2135
|
-
var regex = new RegExp("(".concat(searchText.toLocaleUpperCase(), ")"));
|
|
2136
|
-
var parts = text.split(regex).filter(Boolean);
|
|
2137
|
-
return parts.map(function(part, index) {
|
|
2138
|
-
if (part.match(regex)) {
|
|
2139
|
-
return /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
2140
|
-
key: index,
|
|
2141
|
-
className: index_module_default7.formulaSelectFunctionResultItemNameLight
|
|
2142
|
-
}, part);
|
|
2143
|
-
}
|
|
2144
|
-
return part;
|
|
2145
|
-
});
|
|
2146
|
-
};
|
|
2147
|
-
var setCurrentFunctionInfo = function(selectedIndex) {
|
|
2148
|
-
if (selectList.length === 0) {
|
|
2149
|
-
setFunctionInfo(null);
|
|
2150
|
-
return;
|
|
2151
|
-
}
|
|
2152
|
-
setNameSelected(selectedIndex);
|
|
2153
|
-
var functionInfo2 = descriptionService.getFunctionInfo(selectList[selectedIndex].name);
|
|
2154
|
-
if (!functionInfo2) {
|
|
2155
|
-
setFunctionInfo(null);
|
|
2156
|
-
return;
|
|
2157
|
-
}
|
|
2158
|
-
setFunctionInfo(functionInfo2);
|
|
2159
|
-
onChange(functionInfo2);
|
|
2160
|
-
};
|
|
2161
|
-
function handleSelectChange(value) {
|
|
2162
|
-
setTypeSelected(value);
|
|
2163
|
-
var selectList2 = descriptionService.getSearchListByType(+value);
|
|
2164
|
-
setSelectList(selectList2);
|
|
2165
|
-
}
|
|
2166
|
-
function handleSearchInputChange(value) {
|
|
2167
|
-
setSearchText(value);
|
|
2168
|
-
var selectList2 = descriptionService.getSearchListByName(value);
|
|
2169
|
-
setSelectList(selectList2);
|
|
2170
|
-
}
|
|
2171
|
-
function handleSelectListKeyDown(e) {
|
|
2172
|
-
e.stopPropagation();
|
|
2173
|
-
if (e.key === "ArrowDown") {
|
|
2174
|
-
var nextActive = active + 1;
|
|
2175
|
-
setActive(nextActive === selectList.length ? 0 : nextActive);
|
|
2176
|
-
} else if (e.key === "ArrowUp") {
|
|
2177
|
-
var nextActive1 = active - 1;
|
|
2178
|
-
setActive(nextActive1 === -1 ? selectList.length - 1 : nextActive1);
|
|
2179
|
-
} else if (e.key === "Enter") {
|
|
2180
|
-
setCurrentFunctionInfo(active);
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
var handleLiMouseEnter = function(index) {
|
|
2184
|
-
setActive(index);
|
|
2185
|
-
};
|
|
2186
|
-
var handleLiMouseLeave = function() {
|
|
2187
|
-
setActive(-1);
|
|
2188
|
-
};
|
|
2189
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2190
|
-
className: index_module_default7.formulaSelectFunctionSelect
|
|
2191
|
-
}, /* @__PURE__ */ import_react8.default.createElement(import_design3.Select, {
|
|
2192
|
-
value: typeSelected,
|
|
2193
|
-
options: options,
|
|
2194
|
-
onChange: handleSelectChange
|
|
2195
|
-
}), /* @__PURE__ */ import_react8.default.createElement(import_design3.Input, {
|
|
2196
|
-
placeholder: localeService.t("formula.moreFunctions.searchFunctionPlaceholder"),
|
|
2197
|
-
onKeyDown: handleSelectListKeyDown,
|
|
2198
|
-
value: searchText,
|
|
2199
|
-
onChange: handleSearchInputChange,
|
|
2200
|
-
size: "large",
|
|
2201
|
-
allowClear: true
|
|
2202
|
-
})), /* @__PURE__ */ import_react8.default.createElement("ul", {
|
|
2203
|
-
className: index_module_default7.formulaSelectFunctionResult,
|
|
2204
|
-
onKeyDown: handleSelectListKeyDown,
|
|
2205
|
-
tabIndex: -1
|
|
2206
|
-
}, selectList.map(function(param, index) {
|
|
2207
|
-
var name = param.name;
|
|
2208
|
-
return /* @__PURE__ */ import_react8.default.createElement("li", {
|
|
2209
|
-
key: index,
|
|
2210
|
-
className: active === index ? "".concat(index_module_default7.formulaSelectFunctionResultItem, " ").concat(index_module_default7.formulaSelectFunctionResultItemActive) : index_module_default7.formulaSelectFunctionResultItem,
|
|
2211
|
-
onMouseEnter: function() {
|
|
2212
|
-
return handleLiMouseEnter(index);
|
|
2213
|
-
},
|
|
2214
|
-
onMouseLeave: handleLiMouseLeave,
|
|
2215
|
-
onClick: function() {
|
|
2216
|
-
return setCurrentFunctionInfo(index);
|
|
2217
|
-
}
|
|
2218
|
-
}, nameSelected === index && /* @__PURE__ */ import_react8.default.createElement(import_icons2.CheckMarkSingle, {
|
|
2219
|
-
className: index_module_default7.formulaSelectFunctionResultItemSelected
|
|
2220
|
-
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
2221
|
-
className: index_module_default7.formulaSelectFunctionResultItemName
|
|
2222
|
-
}, highlightSearchText(name)));
|
|
2223
|
-
})), functionInfo && /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2224
|
-
className: index_module_default7.formulaSelectFunctionContent
|
|
2225
|
-
}, /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
|
|
2226
|
-
title: functionInfo.functionName,
|
|
2227
|
-
value: functionInfo.description
|
|
2228
|
-
}), /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
|
|
2229
|
-
title: localeService.t("formula.moreFunctions.syntax"),
|
|
2230
|
-
value: /* @__PURE__ */ import_react8.default.createElement(FunctionHelp, {
|
|
2231
|
-
prefix: functionInfo.functionName,
|
|
2232
|
-
value: functionInfo.functionParameter
|
|
2233
|
-
})
|
|
2234
|
-
}), /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
|
|
2235
|
-
title: localeService.t("formula.prompt.helpExample"),
|
|
2236
|
-
value: "".concat(functionInfo.functionName, "(").concat(functionInfo.functionParameter.map(function(item) {
|
|
2237
|
-
return item.example;
|
|
2238
|
-
}).join(","), ")")
|
|
2239
|
-
}), functionInfo.functionParameter && functionInfo.functionParameter.map(function(item, i) {
|
|
2240
|
-
return /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
|
|
2241
|
-
key: i,
|
|
2242
|
-
title: item.name,
|
|
2243
|
-
value: "".concat(item.require ? required : optional, " ").concat(item.detail)
|
|
2244
|
-
});
|
|
2245
|
-
})));
|
|
2246
|
-
}
|
|
2247
|
-
// src/views/more-functions/MoreFunctions.tsx
|
|
2248
|
-
function MoreFunctions() {
|
|
2249
|
-
var _ref = _sliced_to_array((0, import_react9.useState)(true), 2), selectFunction = _ref[0], setSelectFunction = _ref[1];
|
|
2250
|
-
var _ref1 = _sliced_to_array((0, import_react9.useState)(false), 2), inputParams = _ref1[0], setInputParams = _ref1[1];
|
|
2251
|
-
var _ref2 = _sliced_to_array((0, import_react9.useState)([]), 2), params = _ref2[0], setParams = _ref2[1];
|
|
2252
|
-
var _ref3 = _sliced_to_array((0, import_react9.useState)(null), 2), functionInfo = _ref3[0], setFunctionInfo = _ref3[1];
|
|
2253
|
-
var localeService = (0, import_react_bindings5.useDependency)(import_core14.LocaleService);
|
|
2254
|
-
var sidebarService = (0, import_react_bindings5.useDependency)(import_ui3.ISidebarService);
|
|
2255
|
-
var formulaInputService = (0, import_react_bindings5.useDependency)(IFormulaInputService);
|
|
2256
|
-
function handleClickNextPrev() {
|
|
2257
|
-
if (selectFunction) {}
|
|
2258
|
-
setSelectFunction(!selectFunction);
|
|
2259
|
-
setInputParams(!inputParams);
|
|
2260
|
-
}
|
|
2261
|
-
function handleConfirm() {
|
|
2262
|
-
formulaInputService.inputFormula("=".concat(functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.functionName, "("));
|
|
2263
|
-
}
|
|
2264
|
-
return /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
2265
|
-
className: index_module_default4.formulaMoreFunctions
|
|
2266
|
-
}, selectFunction && /* @__PURE__ */ import_react9.default.createElement(SelectFunction, {
|
|
2267
|
-
onChange: setFunctionInfo
|
|
2268
|
-
}), inputParams && /* @__PURE__ */ import_react9.default.createElement(InputParams, {
|
|
2269
|
-
functionInfo: functionInfo,
|
|
2270
|
-
onChange: setParams
|
|
2271
|
-
}), /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
2272
|
-
className: index_module_default4.formulaMoreFunctionsOperation
|
|
2273
|
-
}, inputParams && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
|
|
2274
|
-
type: "primary",
|
|
2275
|
-
onClick: handleClickNextPrev
|
|
2276
|
-
}, localeService.t("formula.moreFunctions.next")), inputParams && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
|
|
2277
|
-
onClick: handleClickNextPrev
|
|
2278
|
-
}, localeService.t("formula.moreFunctions.prev")), selectFunction && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
|
|
2279
|
-
type: "primary",
|
|
2280
|
-
onClick: handleConfirm
|
|
2281
|
-
}, localeService.t("formula.moreFunctions.confirm"))));
|
|
2282
|
-
}
|
|
2283
|
-
// src/controllers/menu.ts
|
|
2284
|
-
var import_ui4 = require("@univerjs/ui");
|
|
2285
|
-
function InsertFunctionMenuItemFactory(accessor) {
|
|
2286
|
-
return {
|
|
2287
|
-
id: InsertFunctionOperation.id,
|
|
2288
|
-
icon: "FunctionSingle",
|
|
2289
|
-
tooltip: "formula.insert.tooltip",
|
|
2290
|
-
group: import_ui4.MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
2291
|
-
type: import_ui4.MenuItemType.SELECTOR,
|
|
2292
|
-
positions: [
|
|
2293
|
-
import_ui4.MenuPosition.TOOLBAR_START
|
|
2294
|
-
],
|
|
2295
|
-
selections: [
|
|
2296
|
-
{
|
|
2297
|
-
label: "SUM",
|
|
2298
|
-
value: "SUM",
|
|
2299
|
-
icon: "SumSingle"
|
|
2300
|
-
},
|
|
2301
|
-
{
|
|
2302
|
-
label: "AVERAGE",
|
|
2303
|
-
value: "AVERAGE",
|
|
2304
|
-
icon: "AvgSingle"
|
|
2305
|
-
},
|
|
2306
|
-
{
|
|
2307
|
-
label: "COUNT",
|
|
2308
|
-
value: "COUNT",
|
|
2309
|
-
icon: "CntSingle"
|
|
2310
|
-
},
|
|
2311
|
-
{
|
|
2312
|
-
label: "MAX",
|
|
2313
|
-
value: "MAX",
|
|
2314
|
-
icon: "MaxSingle"
|
|
2315
|
-
},
|
|
2316
|
-
{
|
|
2317
|
-
label: "MIN",
|
|
2318
|
-
value: "MIN",
|
|
2319
|
-
icon: "MinSingle"
|
|
2320
|
-
}
|
|
2321
|
-
]
|
|
2322
|
-
};
|
|
2323
|
-
}
|
|
2324
|
-
function MoreFunctionsMenuItemFactory(accessor) {
|
|
2325
|
-
return {
|
|
2326
|
-
id: MoreFunctionsOperation.id,
|
|
2327
|
-
title: "formula.insert.more",
|
|
2328
|
-
positions: InsertFunctionOperation.id,
|
|
2329
|
-
type: import_ui4.MenuItemType.BUTTON
|
|
2330
|
-
};
|
|
2331
|
-
}
|
|
2332
|
-
// src/controllers/shortcuts/prompt.shortcut.ts
|
|
2333
|
-
var import_engine_render2 = require("@univerjs/engine-render");
|
|
2334
|
-
var import_sheets_ui7 = require("@univerjs/sheets-ui");
|
|
2335
|
-
var import_ui5 = require("@univerjs/ui");
|
|
2336
|
-
// src/common/prompt.ts
|
|
2337
|
-
var META_KEY_CTRL_AND_SHIFT = "meta_key_ctrl_And_Shift";
|
|
2338
|
-
// src/controllers/shortcuts/prompt.shortcut.ts
|
|
2339
|
-
var PROMPT_SELECTION_KEYCODE_ARROW_LIST = [
|
|
2340
|
-
import_ui5.KeyCode.ARROW_DOWN,
|
|
2341
|
-
import_ui5.KeyCode.ARROW_UP,
|
|
2342
|
-
import_ui5.KeyCode.ARROW_LEFT,
|
|
2343
|
-
import_ui5.KeyCode.ARROW_RIGHT
|
|
2344
|
-
];
|
|
2345
|
-
var PROMPT_SELECTION_KEYCODE_LIST = _to_consumable_array(PROMPT_SELECTION_KEYCODE_ARROW_LIST).concat([
|
|
2346
|
-
import_ui5.KeyCode.ENTER,
|
|
2347
|
-
import_ui5.KeyCode.TAB
|
|
2348
|
-
]);
|
|
2349
|
-
function promptSelectionShortcutItem() {
|
|
2350
|
-
var shortcutList = [];
|
|
2351
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2352
|
-
try {
|
|
2353
|
-
for(var _iterator = PROMPT_SELECTION_KEYCODE_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2354
|
-
var keycode = _step.value;
|
|
2355
|
-
shortcutList.push({
|
|
2356
|
-
id: SelectEditorFormulaOperation.id,
|
|
2357
|
-
binding: keycode,
|
|
2358
|
-
preconditions: function(contextService) {
|
|
2359
|
-
return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
|
|
2360
|
-
},
|
|
2361
|
-
staticParameters: {
|
|
2362
|
-
eventType: import_engine_render2.DeviceInputEventType.Keyboard,
|
|
2363
|
-
keycode: keycode
|
|
2364
|
-
}
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2367
|
-
} catch (err) {
|
|
2368
|
-
_didIteratorError = true;
|
|
2369
|
-
_iteratorError = err;
|
|
2370
|
-
} finally{
|
|
2371
|
-
try {
|
|
2372
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2373
|
-
_iterator.return();
|
|
2374
|
-
}
|
|
2375
|
-
} finally{
|
|
2376
|
-
if (_didIteratorError) {
|
|
2377
|
-
throw _iteratorError;
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
return shortcutList;
|
|
2382
|
-
}
|
|
2383
|
-
function promptSelectionShortcutItemShift() {
|
|
2384
|
-
var shortcutList = [];
|
|
2385
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2386
|
-
try {
|
|
2387
|
-
for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2388
|
-
var keycode = _step.value;
|
|
2389
|
-
shortcutList.push({
|
|
2390
|
-
id: SelectEditorFormulaOperation.id,
|
|
2391
|
-
binding: keycode | import_ui5.MetaKeys.SHIFT,
|
|
2392
|
-
preconditions: function(contextService) {
|
|
2393
|
-
return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
|
|
2394
|
-
},
|
|
2395
|
-
staticParameters: {
|
|
2396
|
-
eventType: import_engine_render2.DeviceInputEventType.Keyboard,
|
|
2397
|
-
keycode: keycode,
|
|
2398
|
-
metaKey: import_ui5.MetaKeys.SHIFT
|
|
2399
|
-
}
|
|
2400
|
-
});
|
|
2401
|
-
}
|
|
2402
|
-
} catch (err) {
|
|
2403
|
-
_didIteratorError = true;
|
|
2404
|
-
_iteratorError = err;
|
|
2405
|
-
} finally{
|
|
2406
|
-
try {
|
|
2407
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2408
|
-
_iterator.return();
|
|
2409
|
-
}
|
|
2410
|
-
} finally{
|
|
2411
|
-
if (_didIteratorError) {
|
|
2412
|
-
throw _iteratorError;
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
return shortcutList;
|
|
2417
|
-
}
|
|
2418
|
-
function promptSelectionShortcutItemCtrl() {
|
|
2419
|
-
var shortcutList = [];
|
|
2420
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2421
|
-
try {
|
|
2422
|
-
for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2423
|
-
var keycode = _step.value;
|
|
2424
|
-
shortcutList.push({
|
|
2425
|
-
id: SelectEditorFormulaOperation.id,
|
|
2426
|
-
binding: keycode | import_ui5.MetaKeys.CTRL_COMMAND,
|
|
2427
|
-
preconditions: function(contextService) {
|
|
2428
|
-
return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
|
|
2429
|
-
},
|
|
2430
|
-
staticParameters: {
|
|
2431
|
-
eventType: import_engine_render2.DeviceInputEventType.Keyboard,
|
|
2432
|
-
keycode: keycode,
|
|
2433
|
-
metaKey: import_ui5.MetaKeys.CTRL_COMMAND
|
|
2434
|
-
}
|
|
2435
|
-
});
|
|
2436
|
-
}
|
|
2437
|
-
} catch (err) {
|
|
2438
|
-
_didIteratorError = true;
|
|
2439
|
-
_iteratorError = err;
|
|
2440
|
-
} finally{
|
|
2441
|
-
try {
|
|
2442
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2443
|
-
_iterator.return();
|
|
2444
|
-
}
|
|
2445
|
-
} finally{
|
|
2446
|
-
if (_didIteratorError) {
|
|
2447
|
-
throw _iteratorError;
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
return shortcutList;
|
|
2452
|
-
}
|
|
2453
|
-
function promptSelectionShortcutItemCtrlAndShift() {
|
|
2454
|
-
var shortcutList = [];
|
|
2455
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2456
|
-
try {
|
|
2457
|
-
for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2458
|
-
var keycode = _step.value;
|
|
2459
|
-
shortcutList.push({
|
|
2460
|
-
id: SelectEditorFormulaOperation.id,
|
|
2461
|
-
binding: keycode | import_ui5.MetaKeys.SHIFT | import_ui5.MetaKeys.CTRL_COMMAND,
|
|
2462
|
-
preconditions: function(contextService) {
|
|
2463
|
-
return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
|
|
2464
|
-
},
|
|
2465
|
-
staticParameters: {
|
|
2466
|
-
eventType: import_engine_render2.DeviceInputEventType.Keyboard,
|
|
2467
|
-
keycode: keycode,
|
|
2468
|
-
metaKey: META_KEY_CTRL_AND_SHIFT
|
|
2469
|
-
}
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
} catch (err) {
|
|
2473
|
-
_didIteratorError = true;
|
|
2474
|
-
_iteratorError = err;
|
|
2475
|
-
} finally{
|
|
2476
|
-
try {
|
|
2477
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2478
|
-
_iterator.return();
|
|
2479
|
-
}
|
|
2480
|
-
} finally{
|
|
2481
|
-
if (_didIteratorError) {
|
|
2482
|
-
throw _iteratorError;
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
return shortcutList;
|
|
2487
|
-
}
|
|
2488
|
-
var ChangeRefToAbsoluteShortcut = {
|
|
2489
|
-
id: ReferenceAbsoluteOperation.id,
|
|
2490
|
-
binding: import_ui5.KeyCode.F4,
|
|
2491
|
-
preconditions: function(contextService) {
|
|
2492
|
-
return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
|
|
2493
|
-
}
|
|
2494
|
-
};
|
|
2495
|
-
// src/controllers/formula-ui.controller.ts
|
|
2496
|
-
var FormulaUIController = /*#__PURE__*/ function(_import_core15_Disposable) {
|
|
2497
|
-
_inherits(FormulaUIController, _import_core15_Disposable);
|
|
2498
|
-
var _super = _create_super(FormulaUIController);
|
|
2499
|
-
function FormulaUIController(_injector, _menuService, _commandService, _shortcutService, _uiController, _componentManager) {
|
|
2500
|
-
_class_call_check(this, FormulaUIController);
|
|
2501
|
-
var _this;
|
|
2502
|
-
_this = _super.call(this);
|
|
2503
|
-
_this._injector = _injector;
|
|
2504
|
-
_this._menuService = _menuService;
|
|
2505
|
-
_this._commandService = _commandService;
|
|
2506
|
-
_this._shortcutService = _shortcutService;
|
|
2507
|
-
_this._uiController = _uiController;
|
|
2508
|
-
_this._componentManager = _componentManager;
|
|
2509
|
-
_this._initialize();
|
|
2510
|
-
return _this;
|
|
2511
|
-
}
|
|
2512
|
-
_create_class(FormulaUIController, [
|
|
2513
|
-
{
|
|
2514
|
-
key: "_initialize",
|
|
2515
|
-
value: function _initialize() {
|
|
2516
|
-
this._registerCommands();
|
|
2517
|
-
this._registerMenus();
|
|
2518
|
-
this._registerShortcuts();
|
|
2519
|
-
this._registerComponents();
|
|
2520
|
-
}
|
|
2521
|
-
},
|
|
2522
|
-
{
|
|
2523
|
-
key: "_registerMenus",
|
|
2524
|
-
value: function _registerMenus() {
|
|
2525
|
-
var _this = this;
|
|
2526
|
-
[
|
|
2527
|
-
InsertFunctionMenuItemFactory,
|
|
2528
|
-
MoreFunctionsMenuItemFactory
|
|
2529
|
-
].forEach(function(factory) {
|
|
2530
|
-
_this.disposeWithMe(_this._menuService.addMenuItem(_this._injector.invoke(factory)));
|
|
2531
|
-
});
|
|
2532
|
-
}
|
|
2533
|
-
},
|
|
2534
|
-
{
|
|
2535
|
-
key: "_registerCommands",
|
|
2536
|
-
value: function _registerCommands() {
|
|
2537
|
-
var _this = this;
|
|
2538
|
-
[
|
|
2539
|
-
InsertFunctionCommand,
|
|
2540
|
-
InsertFunctionOperation,
|
|
2541
|
-
MoreFunctionsOperation,
|
|
2542
|
-
SearchFunctionOperation,
|
|
2543
|
-
HelpFunctionOperation,
|
|
2544
|
-
SelectEditorFormulaOperation,
|
|
2545
|
-
ReferenceAbsoluteOperation
|
|
2546
|
-
].forEach(function(command) {
|
|
2547
|
-
return _this.disposeWithMe(_this._commandService.registerCommand(command));
|
|
2548
|
-
});
|
|
2549
|
-
}
|
|
2550
|
-
},
|
|
2551
|
-
{
|
|
2552
|
-
key: "_registerShortcuts",
|
|
2553
|
-
value: function _registerShortcuts() {
|
|
2554
|
-
var _this = this;
|
|
2555
|
-
_to_consumable_array(promptSelectionShortcutItem()).concat(_to_consumable_array(promptSelectionShortcutItemShift()), _to_consumable_array(promptSelectionShortcutItemCtrl()), _to_consumable_array(promptSelectionShortcutItemCtrlAndShift()), [
|
|
2556
|
-
ChangeRefToAbsoluteShortcut
|
|
2557
|
-
]).forEach(function(item) {
|
|
2558
|
-
_this.disposeWithMe(_this._shortcutService.registerShortcut(item));
|
|
2559
|
-
});
|
|
2560
|
-
}
|
|
2561
|
-
},
|
|
2562
|
-
{
|
|
2563
|
-
key: "_registerComponents",
|
|
2564
|
-
value: function _registerComponents() {
|
|
2565
|
-
var _this = this;
|
|
2566
|
-
this.disposeWithMe(this._uiController.registerContentComponent(function() {
|
|
2567
|
-
return (0, import_react_bindings6.connectInjector)(RenderFormulaPromptContent, _this._injector);
|
|
2568
|
-
}));
|
|
2569
|
-
this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions);
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
]);
|
|
2573
|
-
return FormulaUIController;
|
|
2574
|
-
}(import_core15.Disposable);
|
|
2575
|
-
FormulaUIController = __decorateClass([
|
|
2576
|
-
(0, import_core15.OnLifecycle)(import_core15.LifecycleStages.Ready, FormulaUIController),
|
|
2577
|
-
__decorateParam(0, (0, import_redi6.Inject)(import_redi6.Injector)),
|
|
2578
|
-
__decorateParam(1, import_ui6.IMenuService),
|
|
2579
|
-
__decorateParam(2, import_core15.ICommandService),
|
|
2580
|
-
__decorateParam(3, import_ui6.IShortcutService),
|
|
2581
|
-
__decorateParam(4, import_ui6.IUIController),
|
|
2582
|
-
__decorateParam(5, (0, import_redi6.Inject)(import_ui6.ComponentManager))
|
|
2583
|
-
], FormulaUIController);
|
|
2584
|
-
// src/controllers/prompt.controller.ts
|
|
2585
|
-
var import_core16 = require("@univerjs/core");
|
|
2586
|
-
var import_docs = require("@univerjs/docs");
|
|
2587
|
-
var import_engine_formula8 = require("@univerjs/engine-formula");
|
|
2588
|
-
var import_engine_render3 = require("@univerjs/engine-render");
|
|
2589
|
-
var import_sheets3 = require("@univerjs/sheets");
|
|
2590
|
-
var import_sheets_ui8 = require("@univerjs/sheets-ui");
|
|
2591
|
-
var import_ui7 = require("@univerjs/ui");
|
|
2592
|
-
var import_redi7 = require("@wendellhu/redi");
|
|
2593
|
-
// src/common/selection.ts
|
|
2594
|
-
var import_tinycolor = require("@ctrl/tinycolor");
|
|
2595
|
-
var FORMULA_REF_SELECTION_PLUGIN_NAME = "formula_reference_selection_plugin_name";
|
|
2596
|
-
function getFormulaRefSelectionStyle(themeService, refColor, id) {
|
|
2597
|
-
var style = themeService.getCurrentTheme();
|
|
2598
|
-
var fill = new import_tinycolor.TinyColor(refColor).setAlpha(0.05).toString();
|
|
2599
|
-
return {
|
|
2600
|
-
id: id,
|
|
2601
|
-
strokeWidth: 2,
|
|
2602
|
-
stroke: refColor,
|
|
2603
|
-
// strokeDash: 10,
|
|
2604
|
-
fill: fill,
|
|
2605
|
-
widgets: {
|
|
2606
|
-
tl: true,
|
|
2607
|
-
tc: true,
|
|
2608
|
-
tr: true,
|
|
2609
|
-
ml: true,
|
|
2610
|
-
mr: true,
|
|
2611
|
-
bl: true,
|
|
2612
|
-
bc: true,
|
|
2613
|
-
br: true
|
|
2614
|
-
},
|
|
2615
|
-
widgetSize: 6,
|
|
2616
|
-
widgetStrokeWidth: 1,
|
|
2617
|
-
widgetStroke: style.colorWhite,
|
|
2618
|
-
hasAutoFill: false,
|
|
2619
|
-
hasRowHeader: false,
|
|
2620
|
-
hasColumnHeader: false
|
|
2621
|
-
};
|
|
2622
|
-
}
|
|
2623
|
-
// src/controllers/prompt.controller.ts
|
|
2624
|
-
var PromptController = /*#__PURE__*/ function(_import_core16_Disposable) {
|
|
2625
|
-
_inherits(PromptController, _import_core16_Disposable);
|
|
2626
|
-
var _super = _create_super(PromptController);
|
|
2627
|
-
function PromptController(_commandService, _localeService, _contextService, _textSelectionRenderManager, _editorBridgeService, _formulaPromptService, _formulaEngineService, _renderManagerService, _themeService, _selectionManagerService, _sheetSkeletonManagerService, _currentUniverService, _selectionRenderService, _descriptionService, _textSelectionManagerService, _formulaInputService, _docViewModelManagerService) {
|
|
2628
|
-
_class_call_check(this, PromptController);
|
|
2629
|
-
var _this;
|
|
2630
|
-
_this = _super.call(this);
|
|
2631
|
-
_define_property(_assert_this_initialized(_this), "_formulaRefColors", []);
|
|
2632
|
-
_define_property(_assert_this_initialized(_this), "_previousSequenceNodes", void 0);
|
|
2633
|
-
_define_property(_assert_this_initialized(_this), "_previousRangesCount", 0);
|
|
2634
|
-
_define_property(_assert_this_initialized(_this), "_previousInsertRefStringIndex", void 0);
|
|
2635
|
-
_define_property(_assert_this_initialized(_this), "_currentInsertRefStringIndex", -1);
|
|
2636
|
-
_define_property(_assert_this_initialized(_this), "_currentUnitId", void 0);
|
|
2637
|
-
_define_property(_assert_this_initialized(_this), "_currentSheetId", void 0);
|
|
2638
|
-
_define_property(_assert_this_initialized(_this), "_arrowMoveActionState", 0 /* InitialState */ );
|
|
2639
|
-
_define_property(_assert_this_initialized(_this), "_isSelectionMovingRefSelections", []);
|
|
2640
|
-
_define_property(_assert_this_initialized(_this), "_stringColor", "");
|
|
2641
|
-
_define_property(_assert_this_initialized(_this), "_numberColor", "");
|
|
2642
|
-
_define_property(_assert_this_initialized(_this), "_insertSelections", []);
|
|
2643
|
-
_define_property(_assert_this_initialized(_this), "_inputPanelState", 0 /* InitialState */ );
|
|
2644
|
-
_this._commandService = _commandService;
|
|
2645
|
-
_this._localeService = _localeService;
|
|
2646
|
-
_this._contextService = _contextService;
|
|
2647
|
-
_this._textSelectionRenderManager = _textSelectionRenderManager;
|
|
2648
|
-
_this._editorBridgeService = _editorBridgeService;
|
|
2649
|
-
_this._formulaPromptService = _formulaPromptService;
|
|
2650
|
-
_this._formulaEngineService = _formulaEngineService;
|
|
2651
|
-
_this._renderManagerService = _renderManagerService;
|
|
2652
|
-
_this._themeService = _themeService;
|
|
2653
|
-
_this._selectionManagerService = _selectionManagerService;
|
|
2654
|
-
_this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2655
|
-
_this._currentUniverService = _currentUniverService;
|
|
2656
|
-
_this._selectionRenderService = _selectionRenderService;
|
|
2657
|
-
_this._descriptionService = _descriptionService;
|
|
2658
|
-
_this._textSelectionManagerService = _textSelectionManagerService;
|
|
2659
|
-
_this._formulaInputService = _formulaInputService;
|
|
2660
|
-
_this._docViewModelManagerService = _docViewModelManagerService;
|
|
2661
|
-
_this._initialize();
|
|
2662
|
-
return _this;
|
|
2663
|
-
}
|
|
2664
|
-
_create_class(PromptController, [
|
|
2665
|
-
{
|
|
2666
|
-
key: "dispose",
|
|
2667
|
-
value: function dispose() {
|
|
2668
|
-
this._formulaRefColors = [];
|
|
2669
|
-
this._resetTemp();
|
|
2670
|
-
}
|
|
2671
|
-
},
|
|
2672
|
-
{
|
|
2673
|
-
key: "_resetTemp",
|
|
2674
|
-
value: function _resetTemp() {
|
|
2675
|
-
this._previousSequenceNodes = null;
|
|
2676
|
-
this._previousInsertRefStringIndex = null;
|
|
2677
|
-
this._currentUnitId = null;
|
|
2678
|
-
this._currentSheetId = null;
|
|
2679
|
-
this._isSelectionMovingRefSelections = [];
|
|
2680
|
-
this._previousRangesCount = 0;
|
|
2681
|
-
this._currentInsertRefStringIndex = -1;
|
|
2682
|
-
}
|
|
2683
|
-
},
|
|
2684
|
-
{
|
|
2685
|
-
key: "_initialize",
|
|
2686
|
-
value: function _initialize() {
|
|
2687
|
-
this._initialCursorSync();
|
|
2688
|
-
this._initAcceptFormula();
|
|
2689
|
-
this._initialFormulaTheme();
|
|
2690
|
-
this._initialRefSelectionUpdateEvent();
|
|
2691
|
-
this._initialRefSelectionInsertEvent();
|
|
2692
|
-
this._initialExitEditor();
|
|
2693
|
-
this._initialEditorInputChange();
|
|
2694
|
-
this._commandExecutedListener();
|
|
2695
|
-
this._cursorStateListener();
|
|
2696
|
-
this._syncEditorListener();
|
|
2697
|
-
}
|
|
2698
|
-
},
|
|
2699
|
-
{
|
|
2700
|
-
key: "_initialFormulaTheme",
|
|
2701
|
-
value: function _initialFormulaTheme() {
|
|
2702
|
-
var style = this._themeService.getCurrentTheme();
|
|
2703
|
-
this._formulaRefColors = [
|
|
2704
|
-
style.loopColor1,
|
|
2705
|
-
style.loopColor2,
|
|
2706
|
-
style.loopColor3,
|
|
2707
|
-
style.loopColor4,
|
|
2708
|
-
style.loopColor5,
|
|
2709
|
-
style.loopColor6,
|
|
2710
|
-
style.loopColor7,
|
|
2711
|
-
style.loopColor8,
|
|
2712
|
-
style.loopColor9,
|
|
2713
|
-
style.loopColor10,
|
|
2714
|
-
style.loopColor11,
|
|
2715
|
-
style.loopColor12
|
|
2716
|
-
];
|
|
2717
|
-
this._numberColor = style.hyacinth700;
|
|
2718
|
-
this._stringColor = style.verdancy800;
|
|
2719
|
-
}
|
|
2720
|
-
},
|
|
2721
|
-
{
|
|
2722
|
-
key: "_initialCursorSync",
|
|
2723
|
-
value: function _initialCursorSync() {
|
|
2724
|
-
var _this = this;
|
|
2725
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._textSelectionRenderManager.textSelection$.subscribe(function() {
|
|
2726
|
-
if (_this._editorBridgeService.isVisible().visible === false || _this._formulaInputService.isSelectionMoving()) {
|
|
2727
|
-
return;
|
|
2728
|
-
}
|
|
2729
|
-
var currentBody = _this._getCurrentBody();
|
|
2730
|
-
var dataStream = (currentBody === null || currentBody === void 0 ? void 0 : currentBody.dataStream) || "";
|
|
2731
|
-
_this._contextSwitch(dataStream);
|
|
2732
|
-
_this._changeKeepVisibleHideState();
|
|
2733
|
-
_this._switchSelectionPlugin();
|
|
2734
|
-
if (_this._formulaInputService.isLockedSelectionChange()) {
|
|
2735
|
-
return;
|
|
2736
|
-
}
|
|
2737
|
-
_this._highlightFormula();
|
|
2738
|
-
_this._changeFunctionPanelState();
|
|
2739
|
-
})));
|
|
2740
|
-
}
|
|
2741
|
-
},
|
|
2742
|
-
{
|
|
2743
|
-
key: "_initialEditorInputChange",
|
|
2744
|
-
value: function _initialEditorInputChange() {
|
|
2745
|
-
var _this = this;
|
|
2746
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._textSelectionRenderManager.onInputBefore$.subscribe(function(param) {
|
|
2747
|
-
_this._previousSequenceNodes = null;
|
|
2748
|
-
_this._previousInsertRefStringIndex = null;
|
|
2749
|
-
_this._selectionRenderService.enableSkipRemainLast();
|
|
2750
|
-
var e = param === null || param === void 0 ? void 0 : param.event;
|
|
2751
|
-
if (e == null) {
|
|
2752
|
-
return;
|
|
2753
|
-
}
|
|
2754
|
-
if (![
|
|
2755
|
-
import_ui7.KeyCode.ARROW_DOWN,
|
|
2756
|
-
import_ui7.KeyCode.ARROW_UP,
|
|
2757
|
-
import_ui7.KeyCode.ARROW_LEFT,
|
|
2758
|
-
import_ui7.KeyCode.ARROW_RIGHT
|
|
2759
|
-
].includes(e.which)) {
|
|
2760
|
-
if (_this._arrowMoveActionState !== 1 /* moveCursor */ ) {
|
|
2761
|
-
_this._arrowMoveActionState = 2 /* moveRefReady */ ;
|
|
2762
|
-
}
|
|
2763
|
-
_this._inputPanelState = 1 /* keyNormal */ ;
|
|
2764
|
-
} else {
|
|
2765
|
-
_this._inputPanelState = 2 /* keyArrow */ ;
|
|
2766
|
-
}
|
|
2767
|
-
})));
|
|
2768
|
-
}
|
|
2769
|
-
},
|
|
2770
|
-
{
|
|
2771
|
-
key: "_initialExitEditor",
|
|
2772
|
-
value: function _initialExitEditor() {
|
|
2773
|
-
var _this = this;
|
|
2774
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._editorBridgeService.afterVisible$.subscribe(function(visibleParam) {
|
|
2775
|
-
if (visibleParam.visible === true) {
|
|
2776
|
-
var _this__getCurrentUnitIdAndSheetId = _this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
|
|
2777
|
-
if (_this._currentUnitId == null) {
|
|
2778
|
-
_this._currentUnitId = unitId;
|
|
2779
|
-
}
|
|
2780
|
-
if (_this._currentSheetId == null) {
|
|
2781
|
-
_this._currentSheetId = sheetId;
|
|
2782
|
-
}
|
|
2783
|
-
return;
|
|
2784
|
-
}
|
|
2785
|
-
var current = _this._selectionManagerService.getCurrent();
|
|
2786
|
-
if ((current === null || current === void 0 ? void 0 : current.pluginName) === import_sheets3.NORMAL_SELECTION_PLUGIN_NAME) {
|
|
2787
|
-
_this._disableForceKeepVisible();
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
_this._selectionManagerService.clear();
|
|
2791
|
-
_this._selectionManagerService.changePlugin(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
|
|
2792
|
-
_this._updateEditorModel("\r\n", []);
|
|
2793
|
-
_this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, false);
|
|
2794
|
-
_this._disableForceKeepVisible();
|
|
2795
|
-
_this._selectionRenderService.resetStyle();
|
|
2796
|
-
_this._resetTemp();
|
|
2797
|
-
_this._hideFunctionPanel();
|
|
2798
|
-
})));
|
|
2799
|
-
}
|
|
2800
|
-
},
|
|
2801
|
-
{
|
|
2802
|
-
key: "_initialRefSelectionUpdateEvent",
|
|
2803
|
-
value: function _initialRefSelectionUpdateEvent() {
|
|
2804
|
-
var _this = this;
|
|
2805
|
-
var disposableCollection = new import_core16.DisposableCollection();
|
|
2806
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._selectionManagerService.selectionInfo$.subscribe(function() {
|
|
2807
|
-
disposableCollection.dispose();
|
|
2808
|
-
var current = _this._selectionManagerService.getCurrent();
|
|
2809
|
-
_this._formulaInputService.disableSelectionMoving();
|
|
2810
|
-
if ((current === null || current === void 0 ? void 0 : current.pluginName) !== FORMULA_REF_SELECTION_PLUGIN_NAME) {
|
|
2811
|
-
return;
|
|
2812
|
-
}
|
|
2813
|
-
_this._updateRefSelectionStyle(_this._isSelectionMovingRefSelections);
|
|
2814
|
-
var selectionControls = _this._selectionRenderService.getCurrentControls();
|
|
2815
|
-
selectionControls.forEach(function(controlSelection) {
|
|
2816
|
-
controlSelection.disableHelperSelection();
|
|
2817
|
-
disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionMoving$.subscribe(function(toRange) {
|
|
2818
|
-
_this._changeControlSelection(toRange, controlSelection);
|
|
2819
|
-
})));
|
|
2820
|
-
disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionScaling$.subscribe(function(toRange) {
|
|
2821
|
-
_this._changeControlSelection(toRange, controlSelection);
|
|
2822
|
-
})));
|
|
2823
|
-
disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionMoved$.subscribe(function() {
|
|
2824
|
-
_this._formulaInputService.disableLockedSelectionChange();
|
|
2825
|
-
})));
|
|
2826
|
-
disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionScaled$.subscribe(function() {
|
|
2827
|
-
_this._formulaInputService.disableLockedSelectionChange();
|
|
2828
|
-
})));
|
|
2829
|
-
});
|
|
2830
|
-
})));
|
|
2831
|
-
}
|
|
2832
|
-
},
|
|
2833
|
-
{
|
|
2834
|
-
key: "_syncEditorListener",
|
|
2835
|
-
value: function _syncEditorListener() {
|
|
2836
|
-
var _this = this;
|
|
2837
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._formulaInputService.syncToEditor$.subscribe(function(param) {
|
|
2838
|
-
var sequences = param.sequences, textSelectionOffset = param.textSelectionOffset;
|
|
2839
|
-
_this._syncToEditor(sequences, textSelectionOffset);
|
|
2840
|
-
})));
|
|
2841
|
-
}
|
|
2842
|
-
},
|
|
2843
|
-
{
|
|
2844
|
-
key: "_selectionChanging",
|
|
2845
|
-
value: function _selectionChanging(ranges) {
|
|
2846
|
-
var isSync = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2847
|
-
if (ranges == null) {
|
|
2848
|
-
return;
|
|
2849
|
-
}
|
|
2850
|
-
if (!this._formulaInputService.isLockedSelectionInsert()) {
|
|
2851
|
-
return;
|
|
2852
|
-
}
|
|
2853
|
-
this._formulaInputService.enableSelectionMoving();
|
|
2854
|
-
this._inertControlSelection(ranges);
|
|
2855
|
-
if (ranges == null || isSync === false) {
|
|
2856
|
-
return;
|
|
2857
|
-
}
|
|
2858
|
-
var currentRange = ranges[ranges.length - 1];
|
|
2859
|
-
this._inertControlSelectionReplace(currentRange);
|
|
2860
|
-
}
|
|
2861
|
-
},
|
|
2862
|
-
{
|
|
2863
|
-
key: "_initialRefSelectionInsertEvent",
|
|
2864
|
-
value: function _initialRefSelectionInsertEvent() {
|
|
2865
|
-
var _this = this;
|
|
2866
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._selectionRenderService.selectionMoving$.subscribe(this._selectionChanging.bind(this))));
|
|
2867
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._selectionRenderService.selectionMoveStart$.subscribe(function(ranges) {
|
|
2868
|
-
_this._selectionChanging(ranges, true);
|
|
2869
|
-
})));
|
|
2870
|
-
}
|
|
2871
|
-
},
|
|
2872
|
-
{
|
|
2873
|
-
key: "_initAcceptFormula",
|
|
2874
|
-
value: function _initAcceptFormula() {
|
|
2875
|
-
var _this = this;
|
|
2876
|
-
this.disposeWithMe((0, import_core16.toDisposable)(this._formulaPromptService.acceptFormulaName$.subscribe(function(formulaString) {
|
|
2877
|
-
var activeRange = _this._textSelectionRenderManager.getActiveRange();
|
|
2878
|
-
if (activeRange == null) {
|
|
2879
|
-
_this._hideFunctionPanel();
|
|
2880
|
-
return;
|
|
2881
|
-
}
|
|
2882
|
-
var startOffset = activeRange.startOffset;
|
|
2883
|
-
var lastSequenceNodes = _this._formulaInputService.getSequenceNodes();
|
|
2884
|
-
var nodeIndex = _this._formulaInputService.getCurrentSequenceNodeIndex(startOffset - 2);
|
|
2885
|
-
var node = lastSequenceNodes[nodeIndex];
|
|
2886
|
-
if (node == null || typeof node === "string") {
|
|
2887
|
-
_this._hideFunctionPanel();
|
|
2888
|
-
return;
|
|
2889
|
-
}
|
|
2890
|
-
var difference = formulaString.length - node.token.length;
|
|
2891
|
-
var newNode = _object_spread({}, node);
|
|
2892
|
-
newNode.token = formulaString;
|
|
2893
|
-
newNode.endIndex += difference;
|
|
2894
|
-
lastSequenceNodes[nodeIndex] = newNode;
|
|
2895
|
-
lastSequenceNodes.splice(nodeIndex + 1, 0, import_engine_formula8.matchToken.OPEN_BRACKET);
|
|
2896
|
-
var formulaStringCount = formulaString.length + 1;
|
|
2897
|
-
for(var i = nodeIndex + 2, len = lastSequenceNodes.length; i < len; i++){
|
|
2898
|
-
var node2 = lastSequenceNodes[i];
|
|
2899
|
-
if (typeof node2 === "string") {
|
|
2900
|
-
continue;
|
|
2901
|
-
}
|
|
2902
|
-
var newNode2 = _object_spread({}, node2);
|
|
2903
|
-
newNode2.startIndex += formulaStringCount;
|
|
2904
|
-
newNode2.endIndex += formulaStringCount;
|
|
2905
|
-
lastSequenceNodes[i] = newNode2;
|
|
2906
|
-
}
|
|
2907
|
-
_this._syncToEditor(lastSequenceNodes, newNode.endIndex + 2);
|
|
2908
|
-
})));
|
|
2909
|
-
}
|
|
2910
|
-
},
|
|
2911
|
-
{
|
|
2912
|
-
key: "_changeFunctionPanelState",
|
|
2913
|
-
value: function _changeFunctionPanelState() {
|
|
2914
|
-
var activeRange = this._textSelectionRenderManager.getActiveRange();
|
|
2915
|
-
if (activeRange == null) {
|
|
2916
|
-
this._hideFunctionPanel();
|
|
2917
|
-
return;
|
|
2918
|
-
}
|
|
2919
|
-
var startOffset = activeRange.startOffset;
|
|
2920
|
-
var currentSequenceNode = this._formulaInputService.getCurrentSequenceNode(startOffset - 2);
|
|
2921
|
-
if (currentSequenceNode == null) {
|
|
2922
|
-
this._hideFunctionPanel();
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
if (typeof currentSequenceNode !== "string" && currentSequenceNode.nodeType === import_engine_formula8.sequenceNodeType.FUNCTION) {
|
|
2926
|
-
var token = currentSequenceNode.token.toUpperCase();
|
|
2927
|
-
if (this._inputPanelState === 1 /* keyNormal */ ) {
|
|
2928
|
-
var searchList = this._descriptionService.getSearchListByName(token);
|
|
2929
|
-
this._hideFunctionPanel();
|
|
2930
|
-
if (searchList == null || searchList.length === 0) {
|
|
2931
|
-
return;
|
|
2932
|
-
}
|
|
2933
|
-
this._commandService.executeCommand(SearchFunctionOperation.id, {
|
|
2934
|
-
visible: true,
|
|
2935
|
-
searchText: token,
|
|
2936
|
-
searchList: searchList
|
|
2937
|
-
});
|
|
2938
|
-
} else if (this._descriptionService.hasFunction(token)) {
|
|
2939
|
-
this._changeHelpFunctionPanelState(token, -1);
|
|
2940
|
-
}
|
|
2941
|
-
return;
|
|
2942
|
-
}
|
|
2943
|
-
var currentBody = this._getCurrentBody();
|
|
2944
|
-
var dataStream = (currentBody === null || currentBody === void 0 ? void 0 : currentBody.dataStream) || "";
|
|
2945
|
-
var functionAndParameter = this._formulaEngineService.getFunctionAndParameter(dataStream, startOffset - 1);
|
|
2946
|
-
if (functionAndParameter == null) {
|
|
2947
|
-
this._hideFunctionPanel();
|
|
2948
|
-
return;
|
|
2949
|
-
}
|
|
2950
|
-
var functionName = functionAndParameter.functionName, paramIndex = functionAndParameter.paramIndex;
|
|
2951
|
-
this._changeHelpFunctionPanelState(functionName.toUpperCase(), paramIndex);
|
|
2952
|
-
}
|
|
2953
|
-
},
|
|
2954
|
-
{
|
|
2955
|
-
key: "_changeHelpFunctionPanelState",
|
|
2956
|
-
value: function _changeHelpFunctionPanelState(token, paramIndex) {
|
|
2957
|
-
var functionInfo = this._descriptionService.getFunctionInfo(token);
|
|
2958
|
-
this._hideFunctionPanel();
|
|
2959
|
-
if (functionInfo == null) {
|
|
2960
|
-
return;
|
|
2961
|
-
}
|
|
2962
|
-
this._commandService.executeCommand(HelpFunctionOperation.id, {
|
|
2963
|
-
visible: true,
|
|
2964
|
-
paramIndex: paramIndex,
|
|
2965
|
-
functionInfo: functionInfo
|
|
2966
|
-
});
|
|
2967
|
-
}
|
|
2968
|
-
},
|
|
2969
|
-
{
|
|
2970
|
-
key: "_hideFunctionPanel",
|
|
2971
|
-
value: function _hideFunctionPanel() {
|
|
2972
|
-
this._commandService.executeCommand(SearchFunctionOperation.id, {
|
|
2973
|
-
visible: false,
|
|
2974
|
-
searchText: ""
|
|
2975
|
-
});
|
|
2976
|
-
this._commandService.executeCommand(HelpFunctionOperation.id, {
|
|
2977
|
-
visible: false,
|
|
2978
|
-
paramIndex: -1
|
|
2979
|
-
});
|
|
2980
|
-
}
|
|
2981
|
-
},
|
|
2982
|
-
{
|
|
2983
|
-
/**
|
|
2984
|
-
* If the cursor is located at a formula token,
|
|
2985
|
-
* it is necessary to prohibit the behavior of closing the editor by clicking on the canvas,
|
|
2986
|
-
* in order to generate reference text for the formula.
|
|
2987
|
-
*/ key: "_changeKeepVisibleHideState",
|
|
2988
|
-
value: function _changeKeepVisibleHideState() {
|
|
2989
|
-
if (this._getContextState() === false) {
|
|
2990
|
-
this._disableForceKeepVisible();
|
|
2991
|
-
return;
|
|
2992
|
-
}
|
|
2993
|
-
var char = this._getCurrentChar();
|
|
2994
|
-
if (char == null) {
|
|
2995
|
-
this._disableForceKeepVisible();
|
|
2996
|
-
return;
|
|
2997
|
-
}
|
|
2998
|
-
if (this._matchRefDrawToken(char)) {
|
|
2999
|
-
this._editorBridgeService.enableForceKeepVisible();
|
|
3000
|
-
this._formulaInputService.enableLockedSelectionInsert();
|
|
3001
|
-
this._selectionRenderService.enableRemainLast();
|
|
3002
|
-
if (this._arrowMoveActionState !== 1 /* moveCursor */ ) {
|
|
3003
|
-
this._arrowMoveActionState = 2 /* moveRefReady */ ;
|
|
3004
|
-
}
|
|
3005
|
-
} else {
|
|
3006
|
-
this._disableForceKeepVisible();
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
},
|
|
3010
|
-
{
|
|
3011
|
-
/**
|
|
3012
|
-
* Determine whether the character is a token keyword for the formula engine.
|
|
3013
|
-
* @param char
|
|
3014
|
-
* @returns
|
|
3015
|
-
*/ key: "_matchRefDrawToken",
|
|
3016
|
-
value: function _matchRefDrawToken(char) {
|
|
3017
|
-
return (0, import_engine_formula8.isFormulaLexerToken)(char) && char !== import_engine_formula8.matchToken.CLOSE_BRACES && char !== import_engine_formula8.matchToken.CLOSE_BRACKET && char !== import_engine_formula8.matchToken.SINGLE_QUOTATION && char !== import_engine_formula8.matchToken.DOUBLE_QUOTATION || char === " ";
|
|
3018
|
-
}
|
|
3019
|
-
},
|
|
3020
|
-
{
|
|
3021
|
-
/**
|
|
3022
|
-
*
|
|
3023
|
-
* @returns Return the character under the current cursor in the editor.
|
|
3024
|
-
*/ key: "_getCurrentChar",
|
|
3025
|
-
value: function _getCurrentChar() {
|
|
3026
|
-
var activeRange = this._textSelectionRenderManager.getActiveRange();
|
|
3027
|
-
if (activeRange == null) {
|
|
3028
|
-
return;
|
|
3029
|
-
}
|
|
3030
|
-
var startOffset = activeRange.startOffset;
|
|
3031
|
-
var body = this._getCurrentBody();
|
|
3032
|
-
if (body == null || startOffset == null) {
|
|
3033
|
-
return;
|
|
3034
|
-
}
|
|
3035
|
-
var dataStream = body.dataStream;
|
|
3036
|
-
return dataStream[startOffset - 1];
|
|
3037
|
-
}
|
|
3038
|
-
},
|
|
3039
|
-
{
|
|
3040
|
-
/**
|
|
3041
|
-
* Disable the ref string generation mode. In the ref string generation mode,
|
|
3042
|
-
* users can select a certain area using the mouse and arrow keys, and convert the area into a ref string.
|
|
3043
|
-
*/ key: "_disableForceKeepVisible",
|
|
3044
|
-
value: function _disableForceKeepVisible() {
|
|
3045
|
-
this._editorBridgeService.disableForceKeepVisible();
|
|
3046
|
-
this._formulaInputService.disableLockedSelectionInsert();
|
|
3047
|
-
this._currentInsertRefStringIndex = -1;
|
|
3048
|
-
this._selectionRenderService.disableRemainLast();
|
|
3049
|
-
if (this._arrowMoveActionState === 2 /* moveRefReady */ ) {
|
|
3050
|
-
this._arrowMoveActionState = 4 /* exitInput */ ;
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
},
|
|
3054
|
-
{
|
|
3055
|
-
key: "_getCurrentBody",
|
|
3056
|
-
value: function _getCurrentBody() {
|
|
3057
|
-
var _documentModel_snapshot;
|
|
3058
|
-
var editorUnitId = this._editorBridgeService.getCurrentEditorId();
|
|
3059
|
-
if (editorUnitId == null) {
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
var documentModel = this._currentUniverService.getUniverDocInstance(editorUnitId);
|
|
3063
|
-
return documentModel === null || documentModel === void 0 ? void 0 : (_documentModel_snapshot = documentModel.snapshot) === null || _documentModel_snapshot === void 0 ? void 0 : _documentModel_snapshot.body;
|
|
3064
|
-
}
|
|
3065
|
-
},
|
|
3066
|
-
{
|
|
3067
|
-
key: "_getFormulaAndCellEditorBody",
|
|
3068
|
-
value: function _getFormulaAndCellEditorBody() {
|
|
3069
|
-
var _this = this;
|
|
3070
|
-
var unitIds = [
|
|
3071
|
-
import_core16.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
|
|
3072
|
-
import_core16.DOCS_NORMAL_EDITOR_UNIT_ID_KEY
|
|
3073
|
-
];
|
|
3074
|
-
return unitIds.map(function(unitId) {
|
|
3075
|
-
var dataModel = _this._currentUniverService.getUniverDocInstance(unitId);
|
|
3076
|
-
return dataModel === null || dataModel === void 0 ? void 0 : dataModel.getBody();
|
|
3077
|
-
});
|
|
3078
|
-
}
|
|
3079
|
-
},
|
|
3080
|
-
{
|
|
3081
|
-
/**
|
|
3082
|
-
* Detect whether the user's input content is a formula. If it is a formula,
|
|
3083
|
-
* serialize the current input content into a sequenceNode;
|
|
3084
|
-
* otherwise, close the formula panel.
|
|
3085
|
-
* @param currentInputValue The text content entered by the user in the editor.
|
|
3086
|
-
* @returns
|
|
3087
|
-
*/ key: "_contextSwitch",
|
|
3088
|
-
value: function _contextSwitch(currentInputValue) {
|
|
3089
|
-
if ((0, import_core16.isFormulaString)(currentInputValue)) {
|
|
3090
|
-
this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, true);
|
|
3091
|
-
var lastSequenceNodes = this._formulaEngineService.buildSequenceNodes(currentInputValue.replace(/\r/g, "").replace(/\n/g, "")) || [];
|
|
3092
|
-
this._formulaInputService.setSequenceNodes(lastSequenceNodes);
|
|
3093
|
-
var activeRange = this._textSelectionRenderManager.getActiveRange();
|
|
3094
|
-
if (activeRange == null) {
|
|
3095
|
-
return;
|
|
3096
|
-
}
|
|
3097
|
-
var startOffset = activeRange.startOffset;
|
|
3098
|
-
this._currentInsertRefStringIndex = startOffset - 1;
|
|
3099
|
-
} else {
|
|
3100
|
-
this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, false);
|
|
3101
|
-
this._formulaInputService.disableLockedSelectionChange();
|
|
3102
|
-
this._formulaInputService.disableLockedSelectionInsert();
|
|
3103
|
-
this._formulaInputService.clearSequenceNodes();
|
|
3104
|
-
this._hideFunctionPanel();
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
},
|
|
3108
|
-
{
|
|
3109
|
-
key: "_getContextState",
|
|
3110
|
-
value: function _getContextState() {
|
|
3111
|
-
return this._contextService.getContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA);
|
|
3112
|
-
}
|
|
3113
|
-
},
|
|
3114
|
-
{
|
|
3115
|
-
/**
|
|
3116
|
-
* Switch from formula selection state to regular selection state.
|
|
3117
|
-
*/ key: "_switchSelectionPlugin",
|
|
3118
|
-
value: function _switchSelectionPlugin() {
|
|
3119
|
-
if (this._getContextState() === true) {
|
|
3120
|
-
this._selectionManagerService.changePluginNoRefresh(FORMULA_REF_SELECTION_PLUGIN_NAME);
|
|
3121
|
-
var style = (0, import_sheets3.getNormalSelectionStyle)(this._themeService);
|
|
3122
|
-
style.strokeDash = 8;
|
|
3123
|
-
style.hasAutoFill = false;
|
|
3124
|
-
style.hasRowHeader = false;
|
|
3125
|
-
style.hasColumnHeader = false;
|
|
3126
|
-
this._selectionRenderService.setStyle(style);
|
|
3127
|
-
} else {
|
|
3128
|
-
this._selectionManagerService.changePluginNoRefresh(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
|
|
3129
|
-
this._selectionRenderService.resetStyle();
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
},
|
|
3133
|
-
{
|
|
3134
|
-
/**
|
|
3135
|
-
* Highlight cell editor and formula bar editor.
|
|
3136
|
-
*/ key: "_highlightFormula",
|
|
3137
|
-
value: function _highlightFormula() {
|
|
3138
|
-
if (this._getContextState() === false) {
|
|
3139
|
-
return;
|
|
3140
|
-
}
|
|
3141
|
-
var sequenceNodes = this._formulaInputService.getSequenceNodes();
|
|
3142
|
-
var bodyList = this._getFormulaAndCellEditorBody().filter(function(b) {
|
|
3143
|
-
return !!b;
|
|
3144
|
-
});
|
|
3145
|
-
this._selectionManagerService.clear();
|
|
3146
|
-
if (sequenceNodes == null || sequenceNodes.length === 0) {
|
|
3147
|
-
bodyList.forEach(function(body) {
|
|
3148
|
-
return body.textRuns = [];
|
|
3149
|
-
});
|
|
3150
|
-
} else {
|
|
3151
|
-
var _this__buildTextRuns = this._buildTextRuns(sequenceNodes), textRuns = _this__buildTextRuns.textRuns, refSelections = _this__buildTextRuns.refSelections;
|
|
3152
|
-
bodyList.forEach(function(body) {
|
|
3153
|
-
return body.textRuns = textRuns;
|
|
3154
|
-
});
|
|
3155
|
-
this._refreshSelectionForReference(refSelections);
|
|
3156
|
-
}
|
|
3157
|
-
this._refreshFormulaAndCellEditor();
|
|
3158
|
-
}
|
|
3159
|
-
},
|
|
3160
|
-
{
|
|
3161
|
-
/**
|
|
3162
|
-
* :
|
|
3163
|
-
* #
|
|
3164
|
-
* Generate styles for formula text, highlighting references, text, numbers, and arrays.
|
|
3165
|
-
* @returns
|
|
3166
|
-
*/ key: "_buildTextRuns",
|
|
3167
|
-
value: function _buildTextRuns(sequenceNodes) {
|
|
3168
|
-
var textRuns = [];
|
|
3169
|
-
var refSelections = [];
|
|
3170
|
-
var refColorIndex = 0;
|
|
3171
|
-
for(var i = 0, len = sequenceNodes.length; i < len; i++){
|
|
3172
|
-
var node = sequenceNodes[i];
|
|
3173
|
-
if (typeof node === "string") {
|
|
3174
|
-
continue;
|
|
3175
|
-
}
|
|
3176
|
-
var startIndex = node.startIndex, endIndex = node.endIndex, nodeType = node.nodeType, token = node.token;
|
|
3177
|
-
var themeColor = "";
|
|
3178
|
-
if (nodeType === import_engine_formula8.sequenceNodeType.REFERENCE) {
|
|
3179
|
-
var colorIndex = refColorIndex % this._formulaRefColors.length;
|
|
3180
|
-
themeColor = this._formulaRefColors[colorIndex];
|
|
3181
|
-
refSelections.push({
|
|
3182
|
-
refIndex: i,
|
|
3183
|
-
themeColor: themeColor,
|
|
3184
|
-
token: token
|
|
3185
|
-
});
|
|
3186
|
-
refColorIndex++;
|
|
3187
|
-
} else if (nodeType === import_engine_formula8.sequenceNodeType.NUMBER) {
|
|
3188
|
-
themeColor = this._numberColor;
|
|
3189
|
-
} else if (nodeType === import_engine_formula8.sequenceNodeType.STRING) {
|
|
3190
|
-
themeColor = this._stringColor;
|
|
3191
|
-
} else if (nodeType === import_engine_formula8.sequenceNodeType.ARRAY) {
|
|
3192
|
-
themeColor = this._stringColor;
|
|
3193
|
-
}
|
|
3194
|
-
if (themeColor.length > 0) {
|
|
3195
|
-
textRuns.push({
|
|
3196
|
-
st: startIndex + 1,
|
|
3197
|
-
ed: endIndex + 2,
|
|
3198
|
-
ts: {
|
|
3199
|
-
cl: {
|
|
3200
|
-
rgb: themeColor
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
}
|
|
3205
|
-
}
|
|
3206
|
-
return {
|
|
3207
|
-
textRuns: textRuns,
|
|
3208
|
-
refSelections: refSelections
|
|
3209
|
-
};
|
|
3210
|
-
}
|
|
3211
|
-
},
|
|
3212
|
-
{
|
|
3213
|
-
/**
|
|
3214
|
-
* Draw the referenced selection text based on the style and token.
|
|
3215
|
-
* @param refSelections
|
|
3216
|
-
* @returns
|
|
3217
|
-
*/ key: "_refreshSelectionForReference",
|
|
3218
|
-
value: function _refreshSelectionForReference(refSelections) {
|
|
3219
|
-
var _this = this, _loop = function(i, len) {
|
|
3220
|
-
var _this__insertSelections_find;
|
|
3221
|
-
var refSelection = refSelections[i];
|
|
3222
|
-
var themeColor = refSelection.themeColor, token = refSelection.token, refIndex = refSelection.refIndex;
|
|
3223
|
-
var gridRange = (0, import_core16.deserializeRangeWithSheet)(token);
|
|
3224
|
-
var refUnitId = gridRange.unitId, sheetName = gridRange.sheetName, range = gridRange.range;
|
|
3225
|
-
if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) {
|
|
3226
|
-
return "continue";
|
|
3227
|
-
}
|
|
3228
|
-
var refSheetId = _this._getSheetIdByName(unitId, sheetName.trim());
|
|
3229
|
-
if (refSheetId != null && refSheetId !== sheetId) {
|
|
3230
|
-
return "continue";
|
|
3231
|
-
}
|
|
3232
|
-
var primary = (_this__insertSelections_find = _this._insertSelections.find(function(selection) {
|
|
3233
|
-
var _selection_range = selection.range, startRow = _selection_range.startRow, startColumn = _selection_range.startColumn, endRow = _selection_range.endRow, endColumn = _selection_range.endColumn;
|
|
3234
|
-
if (startRow === range.startRow && startColumn === range.startColumn && endRow === range.endRow && endColumn === range.endColumn) {
|
|
3235
|
-
return true;
|
|
3236
|
-
}
|
|
3237
|
-
return false;
|
|
3238
|
-
})) === null || _this__insertSelections_find === void 0 ? void 0 : _this__insertSelections_find.primary;
|
|
3239
|
-
if (primary != null) {
|
|
3240
|
-
lastRange = {
|
|
3241
|
-
range: range,
|
|
3242
|
-
primary: primary,
|
|
3243
|
-
style: getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString())
|
|
3244
|
-
};
|
|
3245
|
-
return "continue";
|
|
3246
|
-
}
|
|
3247
|
-
selectionWithStyle.push({
|
|
3248
|
-
range: range,
|
|
3249
|
-
primary: primary,
|
|
3250
|
-
style: getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString())
|
|
3251
|
-
});
|
|
3252
|
-
};
|
|
3253
|
-
var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
|
|
3254
|
-
var selectionWithStyle = [];
|
|
3255
|
-
var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
|
|
3256
|
-
var worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
3257
|
-
if (worksheet == null) {
|
|
3258
|
-
return;
|
|
3259
|
-
}
|
|
3260
|
-
var lastRange = null;
|
|
3261
|
-
for(var i = 0, len = refSelections.length; i < len; i++)_loop(i, len);
|
|
3262
|
-
if (lastRange) {
|
|
3263
|
-
selectionWithStyle.push(lastRange);
|
|
3264
|
-
}
|
|
3265
|
-
if (selectionWithStyle.length === 0) {
|
|
3266
|
-
return;
|
|
3267
|
-
}
|
|
3268
|
-
this._selectionManagerService.add(selectionWithStyle);
|
|
3269
|
-
}
|
|
3270
|
-
},
|
|
3271
|
-
{
|
|
3272
|
-
key: "_getSheetIdByName",
|
|
3273
|
-
value: function _getSheetIdByName(unitId, sheetName) {
|
|
3274
|
-
var _workbook_getSheetBySheetName;
|
|
3275
|
-
var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
|
|
3276
|
-
return workbook === null || workbook === void 0 ? void 0 : (_workbook_getSheetBySheetName = workbook.getSheetBySheetName((0, import_engine_formula8.normalizeSheetName)(sheetName))) === null || _workbook_getSheetBySheetName === void 0 ? void 0 : _workbook_getSheetBySheetName.getSheetId();
|
|
3277
|
-
}
|
|
3278
|
-
},
|
|
3279
|
-
{
|
|
3280
|
-
key: "_getSheetNameById",
|
|
3281
|
-
value: function _getSheetNameById(unitId, sheetId) {
|
|
3282
|
-
var _workbook_getSheetBySheetId;
|
|
3283
|
-
var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
|
|
3284
|
-
var sheetName = (workbook === null || workbook === void 0 ? void 0 : (_workbook_getSheetBySheetId = workbook.getSheetBySheetId(sheetId)) === null || _workbook_getSheetBySheetId === void 0 ? void 0 : _workbook_getSheetBySheetId.getName()) || "";
|
|
3285
|
-
if (sheetName.length > 0 && (0, import_engine_formula8.includeFormulaLexerToken)(sheetName)) {
|
|
3286
|
-
sheetName = "'".concat(sheetName, "'");
|
|
3287
|
-
}
|
|
3288
|
-
return sheetName;
|
|
3289
|
-
}
|
|
3290
|
-
},
|
|
3291
|
-
{
|
|
3292
|
-
key: "_getCurrentUnitIdAndSheetId",
|
|
3293
|
-
value: function _getCurrentUnitIdAndSheetId() {
|
|
3294
|
-
var current = this._sheetSkeletonManagerService.getCurrent();
|
|
3295
|
-
if (current == null) {
|
|
3296
|
-
var workbook = this._currentUniverService.getCurrentUniverSheetInstance();
|
|
3297
|
-
var worksheet = workbook.getActiveSheet();
|
|
3298
|
-
return {
|
|
3299
|
-
unitId: workbook.getUnitId(),
|
|
3300
|
-
sheetId: worksheet.getSheetId()
|
|
3301
|
-
};
|
|
3302
|
-
}
|
|
3303
|
-
var unitId = current.unitId, sheetId = current.sheetId;
|
|
3304
|
-
return {
|
|
3305
|
-
unitId: unitId,
|
|
3306
|
-
sheetId: sheetId
|
|
3307
|
-
};
|
|
3308
|
-
}
|
|
3309
|
-
},
|
|
3310
|
-
{
|
|
3311
|
-
/**
|
|
3312
|
-
* Convert the selection range to a ref string for the formula engine, such as A1:B1
|
|
3313
|
-
* @param range
|
|
3314
|
-
* @returns
|
|
3315
|
-
*/ key: "_getRefString",
|
|
3316
|
-
value: function _getRefString(range) {
|
|
3317
|
-
var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
|
|
3318
|
-
var refUnitId = "";
|
|
3319
|
-
var refSheetName = "";
|
|
3320
|
-
if (unitId === this._currentUnitId) {
|
|
3321
|
-
refUnitId = "";
|
|
3322
|
-
} else {
|
|
3323
|
-
refUnitId = unitId;
|
|
3324
|
-
}
|
|
3325
|
-
if (sheetId === this._currentSheetId) {
|
|
3326
|
-
refSheetName = "";
|
|
3327
|
-
} else {
|
|
3328
|
-
refSheetName = this._getSheetNameById(unitId, sheetId);
|
|
3329
|
-
}
|
|
3330
|
-
var startRow = range.startRow, endRow = range.endRow, startColumn = range.startColumn, endColumn = range.endColumn;
|
|
3331
|
-
return (0, import_core16.serializeRangeToRefString)({
|
|
3332
|
-
sheetName: refSheetName,
|
|
3333
|
-
unitId: refUnitId,
|
|
3334
|
-
range: {
|
|
3335
|
-
startRow: startRow,
|
|
3336
|
-
endRow: endRow,
|
|
3337
|
-
startColumn: startColumn,
|
|
3338
|
-
endColumn: endColumn
|
|
3339
|
-
}
|
|
3340
|
-
});
|
|
3341
|
-
}
|
|
3342
|
-
},
|
|
3343
|
-
{
|
|
3344
|
-
key: "_syncToEditor",
|
|
3345
|
-
value: /**
|
|
3346
|
-
* Restore the sequenceNode generated by the lexer to the text in the editor, and set the cursor position.
|
|
3347
|
-
* @param sequenceNodes
|
|
3348
|
-
* @param textSelectionOffset
|
|
3349
|
-
* @returns
|
|
3350
|
-
*/ function _syncToEditor(sequenceNodes, textSelectionOffset) {
|
|
3351
|
-
var canUndo = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
3352
|
-
var _this = this;
|
|
3353
|
-
return _async_to_generator(function() {
|
|
3354
|
-
var dataStream, _this__buildTextRuns, textRuns, refSelections, activeRange, collapsed, style;
|
|
3355
|
-
return _ts_generator(this, function(_state) {
|
|
3356
|
-
switch(_state.label){
|
|
3357
|
-
case 0:
|
|
3358
|
-
dataStream = (0, import_engine_formula8.generateStringWithSequence)(sequenceNodes);
|
|
3359
|
-
_this__buildTextRuns = _this._buildTextRuns(sequenceNodes), textRuns = _this__buildTextRuns.textRuns, refSelections = _this__buildTextRuns.refSelections;
|
|
3360
|
-
_this._isSelectionMovingRefSelections = refSelections;
|
|
3361
|
-
activeRange = _this._textSelectionManagerService.getLast();
|
|
3362
|
-
if (activeRange == null) {
|
|
3363
|
-
return [
|
|
3364
|
-
2
|
|
3365
|
-
];
|
|
3366
|
-
}
|
|
3367
|
-
collapsed = activeRange.collapsed, style = activeRange.style;
|
|
3368
|
-
_this._currentInsertRefStringIndex = textSelectionOffset;
|
|
3369
|
-
return [
|
|
3370
|
-
4,
|
|
3371
|
-
_this._fitEditorSize()
|
|
3372
|
-
];
|
|
3373
|
-
case 1:
|
|
3374
|
-
_state.sent();
|
|
3375
|
-
if (canUndo) {
|
|
3376
|
-
_this._commandService.executeCommand(import_docs.ReplaceContentCommand.id, {
|
|
3377
|
-
unitId: _this._editorBridgeService.getCurrentEditorId(),
|
|
3378
|
-
body: {
|
|
3379
|
-
dataStream: "=".concat(dataStream),
|
|
3380
|
-
textRuns: textRuns
|
|
3381
|
-
},
|
|
3382
|
-
textRanges: [
|
|
3383
|
-
{
|
|
3384
|
-
startOffset: textSelectionOffset + 1,
|
|
3385
|
-
endOffset: textSelectionOffset + 1,
|
|
3386
|
-
collapsed: collapsed,
|
|
3387
|
-
style: style
|
|
3388
|
-
}
|
|
3389
|
-
],
|
|
3390
|
-
segmentId: null
|
|
3391
|
-
});
|
|
3392
|
-
} else {
|
|
3393
|
-
_this._updateEditorModel("=".concat(dataStream, "\r\n"), textRuns);
|
|
3394
|
-
_this._textSelectionManagerService.replaceTextRanges([
|
|
3395
|
-
{
|
|
3396
|
-
startOffset: textSelectionOffset + 1,
|
|
3397
|
-
endOffset: textSelectionOffset + 1,
|
|
3398
|
-
collapsed: collapsed,
|
|
3399
|
-
style: style
|
|
3400
|
-
}
|
|
3401
|
-
]);
|
|
3402
|
-
}
|
|
3403
|
-
return [
|
|
3404
|
-
2
|
|
3405
|
-
];
|
|
3406
|
-
}
|
|
3407
|
-
});
|
|
3408
|
-
})();
|
|
3409
|
-
}
|
|
3410
|
-
},
|
|
3411
|
-
{
|
|
3412
|
-
key: "_fitEditorSize",
|
|
3413
|
-
value: function _fitEditorSize() {
|
|
3414
|
-
var _this = this;
|
|
3415
|
-
return _async_to_generator(function() {
|
|
3416
|
-
var editorUnitId;
|
|
3417
|
-
return _ts_generator(this, function(_state) {
|
|
3418
|
-
switch(_state.label){
|
|
3419
|
-
case 0:
|
|
3420
|
-
editorUnitId = _this._editorBridgeService.getCurrentEditorId();
|
|
3421
|
-
if (editorUnitId == null) {
|
|
3422
|
-
return [
|
|
3423
|
-
2
|
|
3424
|
-
];
|
|
3425
|
-
}
|
|
3426
|
-
return [
|
|
3427
|
-
4,
|
|
3428
|
-
_this._commandService.syncExecuteCommand(import_sheets_ui8.SetEditorResizeOperation.id, {
|
|
3429
|
-
unitId: editorUnitId
|
|
3430
|
-
})
|
|
3431
|
-
];
|
|
3432
|
-
case 1:
|
|
3433
|
-
_state.sent();
|
|
3434
|
-
return [
|
|
3435
|
-
2
|
|
3436
|
-
];
|
|
3437
|
-
}
|
|
3438
|
-
});
|
|
3439
|
-
})();
|
|
3440
|
-
}
|
|
3441
|
-
},
|
|
3442
|
-
{
|
|
3443
|
-
/**
|
|
3444
|
-
* Update the editor's model value to facilitate formula updates.
|
|
3445
|
-
* @param dataStream
|
|
3446
|
-
* @param textRuns
|
|
3447
|
-
* @returns
|
|
3448
|
-
*/ key: "_updateEditorModel",
|
|
3449
|
-
value: function _updateEditorModel(dataStream, textRuns) {
|
|
3450
|
-
var editorUnitId = this._editorBridgeService.getCurrentEditorId();
|
|
3451
|
-
if (editorUnitId == null) {
|
|
3452
|
-
return;
|
|
3453
|
-
}
|
|
3454
|
-
var documentDataModel = this._currentUniverService.getUniverDocInstance(editorUnitId);
|
|
3455
|
-
var docViewModel = this._docViewModelManagerService.getViewModel(editorUnitId);
|
|
3456
|
-
if (docViewModel == null || documentDataModel == null) {
|
|
3457
|
-
return;
|
|
3458
|
-
}
|
|
3459
|
-
var snapshot = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getSnapshot();
|
|
3460
|
-
if (snapshot == null) {
|
|
3461
|
-
return;
|
|
3462
|
-
}
|
|
3463
|
-
var newBody = {
|
|
3464
|
-
dataStream: dataStream,
|
|
3465
|
-
textRuns: textRuns
|
|
3466
|
-
};
|
|
3467
|
-
snapshot.body = newBody;
|
|
3468
|
-
docViewModel.reset(documentDataModel);
|
|
3469
|
-
}
|
|
3470
|
-
},
|
|
3471
|
-
{
|
|
3472
|
-
key: "_inertControlSelectionReplace",
|
|
3473
|
-
value: function _inertControlSelectionReplace(currentRange) {
|
|
3474
|
-
var _this = this;
|
|
3475
|
-
if (this._previousSequenceNodes == null) {
|
|
3476
|
-
this._previousSequenceNodes = this._formulaInputService.getSequenceNodes();
|
|
3477
|
-
}
|
|
3478
|
-
if (this._previousInsertRefStringIndex == null) {
|
|
3479
|
-
this._previousInsertRefStringIndex = this._currentInsertRefStringIndex;
|
|
3480
|
-
}
|
|
3481
|
-
var insertNodes = import_core16.Tools.deepClone(this._previousSequenceNodes);
|
|
3482
|
-
if (insertNodes == null) {
|
|
3483
|
-
return;
|
|
3484
|
-
}
|
|
3485
|
-
var refString = this._getRefString(currentRange);
|
|
3486
|
-
this._formulaInputService.setSequenceNodes(insertNodes);
|
|
3487
|
-
this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex, refString);
|
|
3488
|
-
this._syncToEditor(insertNodes, this._previousInsertRefStringIndex + refString.length);
|
|
3489
|
-
var selectionDatas = this._selectionRenderService.getSelectionDataWithStyle();
|
|
3490
|
-
this._insertSelections = [];
|
|
3491
|
-
selectionDatas.forEach(function(currentSelection) {
|
|
3492
|
-
var range = (0, import_sheets3.convertSelectionDataToRange)(currentSelection);
|
|
3493
|
-
_this._insertSelections.push(range);
|
|
3494
|
-
});
|
|
3495
|
-
}
|
|
3496
|
-
},
|
|
3497
|
-
{
|
|
3498
|
-
key: "_inertControlSelection",
|
|
3499
|
-
value: function _inertControlSelection(ranges) {
|
|
3500
|
-
var currentRange = ranges[ranges.length - 1];
|
|
3501
|
-
if ((ranges.length === this._previousRangesCount || this._previousRangesCount === 0) && this._previousSequenceNodes != null) {
|
|
3502
|
-
this._inertControlSelectionReplace(currentRange);
|
|
3503
|
-
} else {
|
|
3504
|
-
var insertNodes = this._formulaInputService.getSequenceNodes();
|
|
3505
|
-
if (insertNodes == null) {
|
|
3506
|
-
return;
|
|
3507
|
-
}
|
|
3508
|
-
var char = this._getCurrentChar();
|
|
3509
|
-
if (char == null) {
|
|
3510
|
-
return;
|
|
3511
|
-
}
|
|
3512
|
-
this._previousInsertRefStringIndex = this._currentInsertRefStringIndex;
|
|
3513
|
-
if (!this._matchRefDrawToken(char)) {
|
|
3514
|
-
this._formulaInputService.insertSequenceString(this._currentInsertRefStringIndex, import_engine_formula8.matchToken.COMMA);
|
|
3515
|
-
insertNodes = this._formulaInputService.getSequenceNodes();
|
|
3516
|
-
this._previousInsertRefStringIndex += 1;
|
|
3517
|
-
}
|
|
3518
|
-
this._previousSequenceNodes = import_core16.Tools.deepClone(insertNodes);
|
|
3519
|
-
var refString = this._getRefString(currentRange);
|
|
3520
|
-
this._formulaInputService.setSequenceNodes(insertNodes);
|
|
3521
|
-
this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex, refString);
|
|
3522
|
-
this._selectionRenderService.disableSkipRemainLast();
|
|
3523
|
-
}
|
|
3524
|
-
this._arrowMoveActionState = 2 /* moveRefReady */ ;
|
|
3525
|
-
this._previousRangesCount = ranges.length;
|
|
3526
|
-
}
|
|
3527
|
-
},
|
|
3528
|
-
{
|
|
3529
|
-
key: "_updateRefSelectionStyle",
|
|
3530
|
-
value: function _updateRefSelectionStyle(refSelections) {
|
|
3531
|
-
var _this = this, _loop = function(i, len) {
|
|
3532
|
-
var refSelection = refSelections[i];
|
|
3533
|
-
var refIndex = refSelection.refIndex, themeColor = refSelection.themeColor, token = refSelection.token;
|
|
3534
|
-
var rangeWithSheet = (0, import_core16.deserializeRangeWithSheet)(token);
|
|
3535
|
-
var refUnitId = rangeWithSheet.unitId, sheetName = rangeWithSheet.sheetName, range = rangeWithSheet.range;
|
|
3536
|
-
if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) {
|
|
3537
|
-
return "continue";
|
|
3538
|
-
}
|
|
3539
|
-
var refSheetId = _this._getSheetIdByName(unitId, sheetName.trim());
|
|
3540
|
-
if (refSheetId != null && refSheetId !== sheetId) {
|
|
3541
|
-
return "continue";
|
|
3542
|
-
}
|
|
3543
|
-
var control = controls.find(function(c) {
|
|
3544
|
-
var _c_getRange = c.getRange(), startRow = _c_getRange.startRow, startColumn = _c_getRange.startColumn, endRow = _c_getRange.endRow, endColumn = _c_getRange.endColumn;
|
|
3545
|
-
if (startRow === range.startRow && startColumn === range.startColumn && endRow === range.endRow && endColumn === range.endColumn) {
|
|
3546
|
-
return true;
|
|
3547
|
-
}
|
|
3548
|
-
return false;
|
|
3549
|
-
});
|
|
3550
|
-
if (control == null) {
|
|
3551
|
-
return "continue";
|
|
3552
|
-
}
|
|
3553
|
-
var style = getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString());
|
|
3554
|
-
control.updateStyle(style);
|
|
3555
|
-
};
|
|
3556
|
-
var controls = this._selectionRenderService.getCurrentControls();
|
|
3557
|
-
var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
|
|
3558
|
-
for(var i = 0, len = refSelections.length; i < len; i++)_loop(i, len);
|
|
3559
|
-
}
|
|
3560
|
-
},
|
|
3561
|
-
{
|
|
3562
|
-
key: "_changeControlSelection",
|
|
3563
|
-
value: function _changeControlSelection(toRange, controlSelection) {
|
|
3564
|
-
var _controlSelection_selectionStyle;
|
|
3565
|
-
if (!toRange) {
|
|
3566
|
-
return;
|
|
3567
|
-
}
|
|
3568
|
-
this._formulaInputService.enableLockedSelectionChange();
|
|
3569
|
-
var id = (_controlSelection_selectionStyle = controlSelection.selectionStyle) === null || _controlSelection_selectionStyle === void 0 ? void 0 : _controlSelection_selectionStyle.id;
|
|
3570
|
-
if (id == null || !import_core16.Tools.isStringNumber(id)) {
|
|
3571
|
-
return;
|
|
3572
|
-
}
|
|
3573
|
-
var startRow = toRange.startRow, endRow = toRange.endRow, startColumn = toRange.startColumn, endColumn = toRange.endColumn;
|
|
3574
|
-
var refString = this._getRefString({
|
|
3575
|
-
startRow: startRow,
|
|
3576
|
-
endRow: endRow,
|
|
3577
|
-
startColumn: startColumn,
|
|
3578
|
-
endColumn: endColumn
|
|
3579
|
-
});
|
|
3580
|
-
var nodeIndex = Number(id);
|
|
3581
|
-
this._formulaInputService.updateSequenceRef(nodeIndex, refString);
|
|
3582
|
-
var sequenceNodes = this._formulaInputService.getSequenceNodes();
|
|
3583
|
-
var node = sequenceNodes[nodeIndex];
|
|
3584
|
-
if (typeof node === "string") {
|
|
3585
|
-
return;
|
|
3586
|
-
}
|
|
3587
|
-
this._syncToEditor(sequenceNodes, node.endIndex + 1);
|
|
3588
|
-
controlSelection.update(toRange);
|
|
3589
|
-
}
|
|
3590
|
-
},
|
|
3591
|
-
{
|
|
3592
|
-
key: "_refreshFormulaAndCellEditor",
|
|
3593
|
-
value: function _refreshFormulaAndCellEditor() {
|
|
3594
|
-
var unitIds = [
|
|
3595
|
-
import_core16.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
|
|
3596
|
-
import_core16.DOCS_NORMAL_EDITOR_UNIT_ID_KEY
|
|
3597
|
-
];
|
|
3598
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3599
|
-
try {
|
|
3600
|
-
for(var _iterator = unitIds[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3601
|
-
var unitId = _step.value;
|
|
3602
|
-
var _documentComponent_getSkeleton;
|
|
3603
|
-
var editorObject = (0, import_sheets_ui8.getEditorObject)(unitId, this._renderManagerService);
|
|
3604
|
-
var documentComponent = editorObject === null || editorObject === void 0 ? void 0 : editorObject.document;
|
|
3605
|
-
if (documentComponent == null) {
|
|
3606
|
-
continue;
|
|
3607
|
-
}
|
|
3608
|
-
(_documentComponent_getSkeleton = documentComponent.getSkeleton()) === null || _documentComponent_getSkeleton === void 0 ? void 0 : _documentComponent_getSkeleton.calculate();
|
|
3609
|
-
documentComponent.makeDirty();
|
|
3610
|
-
}
|
|
3611
|
-
} catch (err) {
|
|
3612
|
-
_didIteratorError = true;
|
|
3613
|
-
_iteratorError = err;
|
|
3614
|
-
} finally{
|
|
3615
|
-
try {
|
|
3616
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3617
|
-
_iterator.return();
|
|
3618
|
-
}
|
|
3619
|
-
} finally{
|
|
3620
|
-
if (_didIteratorError) {
|
|
3621
|
-
throw _iteratorError;
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
}
|
|
3626
|
-
},
|
|
3627
|
-
{
|
|
3628
|
-
key: "_cursorStateListener",
|
|
3629
|
-
value: function _cursorStateListener() {
|
|
3630
|
-
var _this = this;
|
|
3631
|
-
var editorObject = this._getEditorObject();
|
|
3632
|
-
if (editorObject == null) {
|
|
3633
|
-
return;
|
|
3634
|
-
}
|
|
3635
|
-
var documentComponent = editorObject.document;
|
|
3636
|
-
this.disposeWithMe((0, import_core16.toDisposable)(documentComponent.onPointerDownObserver.add(function() {
|
|
3637
|
-
_this._arrowMoveActionState = 1 /* moveCursor */ ;
|
|
3638
|
-
_this._inputPanelState = 3 /* mouse */ ;
|
|
3639
|
-
})));
|
|
3640
|
-
}
|
|
3641
|
-
},
|
|
3642
|
-
{
|
|
3643
|
-
key: "_commandExecutedListener",
|
|
3644
|
-
value: function _commandExecutedListener() {
|
|
3645
|
-
var _this = this;
|
|
3646
|
-
var updateCommandList = [
|
|
3647
|
-
SelectEditorFormulaOperation.id
|
|
3648
|
-
];
|
|
3649
|
-
this.disposeWithMe(this._commandService.onCommandExecuted(function(command) {
|
|
3650
|
-
if (updateCommandList.includes(command.id)) {
|
|
3651
|
-
var params = command.params;
|
|
3652
|
-
var keycode = params.keycode, metaKey = params.metaKey;
|
|
3653
|
-
if (keycode === import_ui7.KeyCode.ENTER) {
|
|
3654
|
-
if (_this._formulaPromptService.isSearching()) {
|
|
3655
|
-
_this._formulaPromptService.accept(true);
|
|
3656
|
-
return;
|
|
3657
|
-
}
|
|
3658
|
-
_this._editorBridgeService.changeVisible({
|
|
3659
|
-
visible: false,
|
|
3660
|
-
eventType: import_engine_render3.DeviceInputEventType.Keyboard,
|
|
3661
|
-
keycode: keycode
|
|
3662
|
-
});
|
|
3663
|
-
_this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
|
|
3664
|
-
direction: import_core16.Direction.DOWN
|
|
3665
|
-
});
|
|
3666
|
-
return;
|
|
3667
|
-
}
|
|
3668
|
-
if (keycode === import_ui7.KeyCode.TAB) {
|
|
3669
|
-
if (_this._formulaPromptService.isSearching()) {
|
|
3670
|
-
_this._formulaPromptService.accept(true);
|
|
3671
|
-
return;
|
|
3672
|
-
}
|
|
3673
|
-
_this._editorBridgeService.changeVisible({
|
|
3674
|
-
visible: false,
|
|
3675
|
-
eventType: import_engine_render3.DeviceInputEventType.Keyboard,
|
|
3676
|
-
keycode: keycode
|
|
3677
|
-
});
|
|
3678
|
-
_this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
|
|
3679
|
-
direction: import_core16.Direction.RIGHT
|
|
3680
|
-
});
|
|
3681
|
-
return;
|
|
3682
|
-
}
|
|
3683
|
-
if (_this._formulaPromptService.isSearching()) {
|
|
3684
|
-
if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
|
|
3685
|
-
_this._formulaPromptService.navigate({
|
|
3686
|
-
direction: import_core16.Direction.DOWN
|
|
3687
|
-
});
|
|
3688
|
-
return;
|
|
3689
|
-
}
|
|
3690
|
-
if (keycode === import_ui7.KeyCode.ARROW_UP) {
|
|
3691
|
-
_this._formulaPromptService.navigate({
|
|
3692
|
-
direction: import_core16.Direction.UP
|
|
3693
|
-
});
|
|
3694
|
-
return;
|
|
3695
|
-
}
|
|
3696
|
-
}
|
|
3697
|
-
if (_this._arrowMoveActionState === 1 /* moveCursor */ ) {
|
|
3698
|
-
_this._moveInEditor(keycode);
|
|
3699
|
-
return;
|
|
3700
|
-
}
|
|
3701
|
-
if (_this._arrowMoveActionState === 4 /* exitInput */ ) {
|
|
3702
|
-
_this._editorBridgeService.changeVisible({
|
|
3703
|
-
visible: false,
|
|
3704
|
-
eventType: import_engine_render3.DeviceInputEventType.Keyboard,
|
|
3705
|
-
keycode: keycode
|
|
3706
|
-
});
|
|
3707
|
-
return;
|
|
3708
|
-
}
|
|
3709
|
-
if (_this._arrowMoveActionState === 2 /* moveRefReady */ ) {
|
|
3710
|
-
_this._arrowMoveActionState = 3 /* movingRef */ ;
|
|
3711
|
-
}
|
|
3712
|
-
var previousRanges = _this._selectionManagerService.getSelectionRanges() || [];
|
|
3713
|
-
if (previousRanges.length === 0) {
|
|
3714
|
-
var selectionData = _this._selectionManagerService.getLastByPlugin(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
|
|
3715
|
-
if (selectionData != null) {
|
|
3716
|
-
var selectionDataNew = import_core16.Tools.deepClone(selectionData);
|
|
3717
|
-
_this._selectionManagerService.add([
|
|
3718
|
-
selectionDataNew
|
|
3719
|
-
]);
|
|
3720
|
-
}
|
|
3721
|
-
}
|
|
3722
|
-
var direction = import_core16.Direction.DOWN;
|
|
3723
|
-
if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
|
|
3724
|
-
direction = import_core16.Direction.DOWN;
|
|
3725
|
-
} else if (keycode === import_ui7.KeyCode.ARROW_UP) {
|
|
3726
|
-
direction = import_core16.Direction.UP;
|
|
3727
|
-
} else if (keycode === import_ui7.KeyCode.ARROW_LEFT) {
|
|
3728
|
-
direction = import_core16.Direction.LEFT;
|
|
3729
|
-
} else if (keycode === import_ui7.KeyCode.ARROW_RIGHT) {
|
|
3730
|
-
direction = import_core16.Direction.RIGHT;
|
|
3731
|
-
}
|
|
3732
|
-
if (metaKey === import_ui7.MetaKeys.CTRL_COMMAND) {
|
|
3733
|
-
_this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
|
|
3734
|
-
direction: direction,
|
|
3735
|
-
jumpOver: import_sheets_ui8.JumpOver.moveGap
|
|
3736
|
-
});
|
|
3737
|
-
} else if (metaKey === import_ui7.MetaKeys.SHIFT) {
|
|
3738
|
-
_this._commandService.executeCommand(import_sheets_ui8.ExpandSelectionCommand.id, {
|
|
3739
|
-
direction: direction
|
|
3740
|
-
});
|
|
3741
|
-
} else if (metaKey === META_KEY_CTRL_AND_SHIFT) {
|
|
3742
|
-
_this._commandService.executeCommand(import_sheets_ui8.ExpandSelectionCommand.id, {
|
|
3743
|
-
direction: direction,
|
|
3744
|
-
jumpOver: import_sheets_ui8.JumpOver.moveGap
|
|
3745
|
-
});
|
|
3746
|
-
} else {
|
|
3747
|
-
_this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
|
|
3748
|
-
direction: direction
|
|
3749
|
-
});
|
|
3750
|
-
}
|
|
3751
|
-
var ranges = _this._selectionManagerService.getSelectionRanges() || [];
|
|
3752
|
-
var currentRange = ranges[ranges.length - 1];
|
|
3753
|
-
_this._inertControlSelectionReplace(currentRange);
|
|
3754
|
-
}
|
|
3755
|
-
}));
|
|
3756
|
-
}
|
|
3757
|
-
},
|
|
3758
|
-
{
|
|
3759
|
-
key: "_moveInEditor",
|
|
3760
|
-
value: function _moveInEditor(keycode) {
|
|
3761
|
-
if (keycode == null) {
|
|
3762
|
-
return;
|
|
3763
|
-
}
|
|
3764
|
-
var direction = import_core16.Direction.LEFT;
|
|
3765
|
-
if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
|
|
3766
|
-
direction = import_core16.Direction.DOWN;
|
|
3767
|
-
} else if (keycode === import_ui7.KeyCode.ARROW_UP) {
|
|
3768
|
-
direction = import_core16.Direction.UP;
|
|
3769
|
-
} else if (keycode === import_ui7.KeyCode.ARROW_RIGHT) {
|
|
3770
|
-
direction = import_core16.Direction.RIGHT;
|
|
3771
|
-
}
|
|
3772
|
-
this._commandService.executeCommand(import_docs.MoveCursorOperation.id, {
|
|
3773
|
-
direction: direction
|
|
3774
|
-
});
|
|
3775
|
-
}
|
|
3776
|
-
},
|
|
3777
|
-
{
|
|
3778
|
-
key: "_getEditorObject",
|
|
3779
|
-
value: function _getEditorObject() {
|
|
3780
|
-
return (0, import_sheets_ui8.getEditorObject)(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
|
|
3781
|
-
}
|
|
3782
|
-
}
|
|
3783
|
-
]);
|
|
3784
|
-
return PromptController;
|
|
3785
|
-
}(import_core16.Disposable);
|
|
3786
|
-
PromptController = __decorateClass([
|
|
3787
|
-
(0, import_core16.OnLifecycle)(import_core16.LifecycleStages.Steady, PromptController),
|
|
3788
|
-
__decorateParam(0, import_core16.ICommandService),
|
|
3789
|
-
__decorateParam(1, (0, import_redi7.Inject)(import_core16.LocaleService)),
|
|
3790
|
-
__decorateParam(2, import_core16.IContextService),
|
|
3791
|
-
__decorateParam(3, import_engine_render3.ITextSelectionRenderManager),
|
|
3792
|
-
__decorateParam(4, (0, import_redi7.Inject)(import_sheets_ui8.IEditorBridgeService)),
|
|
3793
|
-
__decorateParam(5, (0, import_redi7.Inject)(IFormulaPromptService)),
|
|
3794
|
-
__decorateParam(6, (0, import_redi7.Inject)(import_engine_formula8.FormulaEngineService)),
|
|
3795
|
-
__decorateParam(7, import_engine_render3.IRenderManagerService),
|
|
3796
|
-
__decorateParam(8, (0, import_redi7.Inject)(import_core16.ThemeService)),
|
|
3797
|
-
__decorateParam(9, (0, import_redi7.Inject)(import_sheets3.SelectionManagerService)),
|
|
3798
|
-
__decorateParam(10, (0, import_redi7.Inject)(import_sheets_ui8.SheetSkeletonManagerService)),
|
|
3799
|
-
__decorateParam(11, import_core16.IUniverInstanceService),
|
|
3800
|
-
__decorateParam(12, (0, import_redi7.Inject)(import_sheets_ui8.ISelectionRenderService)),
|
|
3801
|
-
__decorateParam(13, (0, import_redi7.Inject)(IDescriptionService)),
|
|
3802
|
-
__decorateParam(14, (0, import_redi7.Inject)(import_docs.TextSelectionManagerService)),
|
|
3803
|
-
__decorateParam(15, IFormulaInputService),
|
|
3804
|
-
__decorateParam(16, (0, import_redi7.Inject)(import_docs.DocViewModelManagerService))
|
|
3805
|
-
], PromptController);
|
|
3806
|
-
// src/locale/function-list/array/en-US.ts
|
|
3807
|
-
var en_US_default = {};
|
|
3808
|
-
// src/locale/function-list/compatibility/en-US.ts
|
|
3809
|
-
var en_US_default2 = {};
|
|
3810
|
-
// src/locale/function-list/cube/en-US.ts
|
|
3811
|
-
var en_US_default3 = {};
|
|
3812
|
-
// src/locale/function-list/database/en-US.ts
|
|
3813
|
-
var en_US_default4 = {};
|
|
3814
|
-
// src/locale/function-list/date/en-US.ts
|
|
3815
|
-
var en_US_default5 = {};
|
|
3816
|
-
// src/locale/function-list/engineering/en-US.ts
|
|
3817
|
-
var en_US_default6 = {};
|
|
3818
|
-
// src/locale/function-list/financial/en-US.ts
|
|
3819
|
-
var en_US_default7 = {};
|
|
3820
|
-
// src/locale/function-list/information/en-US.ts
|
|
3821
|
-
var en_US_default8 = {};
|
|
3822
|
-
// src/locale/function-list/logical/en-US.ts
|
|
3823
|
-
var en_US_default9 = {};
|
|
3824
|
-
// src/locale/function-list/lookup/en-US.ts
|
|
3825
|
-
var en_US_default10 = {};
|
|
3826
|
-
// src/locale/function-list/math/en-US.ts
|
|
3827
|
-
var en_US_default11 = {
|
|
3828
|
-
SUM: {
|
|
3829
|
-
description: "You can add individual values, cell references or ranges or a mix of all three.",
|
|
3830
|
-
abstract: "Adds its arguments",
|
|
3831
|
-
functionParameter: {
|
|
3832
|
-
number1: {
|
|
3833
|
-
name: "number1",
|
|
3834
|
-
detail: "The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8."
|
|
3835
|
-
},
|
|
3836
|
-
number2: {
|
|
3837
|
-
name: "number2",
|
|
3838
|
-
detail: "This is the second number you want to add. You can specify up to 255 numbers in this way."
|
|
3839
|
-
}
|
|
3840
|
-
}
|
|
3841
|
-
},
|
|
3842
|
-
SUMIF: {
|
|
3843
|
-
description: "Sum the values in a range that meet criteria that you specify.",
|
|
3844
|
-
abstract: "Adds the cells specified by a given criteria",
|
|
3845
|
-
functionParameter: {
|
|
3846
|
-
range: {
|
|
3847
|
-
name: "range",
|
|
3848
|
-
detail: "The range of cells that you want evaluated by criteria."
|
|
3849
|
-
},
|
|
3850
|
-
criteria: {
|
|
3851
|
-
name: "criteria",
|
|
3852
|
-
detail: "The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included - a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character."
|
|
3853
|
-
},
|
|
3854
|
-
sum_range: {
|
|
3855
|
-
name: "sum_range",
|
|
3856
|
-
detail: "The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied)."
|
|
3857
|
-
}
|
|
3858
|
-
}
|
|
3859
|
-
}
|
|
3860
|
-
};
|
|
3861
|
-
// src/locale/function-list/statistical/en-US.ts
|
|
3862
|
-
var en_US_default12 = {
|
|
3863
|
-
AVERAGE: {
|
|
3864
|
-
description: "Returns the average (arithmetic mean) of the arguments.",
|
|
3865
|
-
abstract: "Returns the average of its arguments",
|
|
3866
|
-
functionParameter: {
|
|
3867
|
-
number1: {
|
|
3868
|
-
name: "number1",
|
|
3869
|
-
detail: "The first number, cell reference, or range for which you want the average."
|
|
3870
|
-
},
|
|
3871
|
-
number2: {
|
|
3872
|
-
name: "number2",
|
|
3873
|
-
detail: "Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255."
|
|
3874
|
-
}
|
|
3875
|
-
}
|
|
3876
|
-
},
|
|
3877
|
-
COUNT: {
|
|
3878
|
-
description: "Counts the number of cells that contain numbers, and counts numbers within the list of arguments.",
|
|
3879
|
-
abstract: "Counts how many numbers are in the list of arguments",
|
|
3880
|
-
functionParameter: {
|
|
3881
|
-
value1: {
|
|
3882
|
-
name: "value1",
|
|
3883
|
-
detail: "The first item, cell reference, or range within which you want to count numbers."
|
|
3884
|
-
},
|
|
3885
|
-
value2: {
|
|
3886
|
-
name: "value2",
|
|
3887
|
-
detail: "Up to 255 additional items, cell references, or ranges within which you want to count numbers."
|
|
3888
|
-
}
|
|
3889
|
-
}
|
|
3890
|
-
},
|
|
3891
|
-
MAX: {
|
|
3892
|
-
description: "Returns the largest value in a set of values.",
|
|
3893
|
-
abstract: "Returns the maximum value in a list of arguments",
|
|
3894
|
-
functionParameter: {
|
|
3895
|
-
number1: {
|
|
3896
|
-
name: "number1",
|
|
3897
|
-
detail: "The first number, cell reference, or range to calculate the maximum value from."
|
|
3898
|
-
},
|
|
3899
|
-
number2: {
|
|
3900
|
-
name: "number2",
|
|
3901
|
-
detail: "Additional numbers, cell references or ranges to calculate the maximum value from, up to a maximum of 255."
|
|
3902
|
-
}
|
|
3903
|
-
}
|
|
3904
|
-
},
|
|
3905
|
-
MIN: {
|
|
3906
|
-
description: "Returns the smallest number in a set of values.",
|
|
3907
|
-
abstract: "Returns the minimum value in a list of arguments",
|
|
3908
|
-
functionParameter: {
|
|
3909
|
-
number1: {
|
|
3910
|
-
name: "number1",
|
|
3911
|
-
detail: "The first number, cell reference, or range to calculate the minimum value from."
|
|
3912
|
-
},
|
|
3913
|
-
number2: {
|
|
3914
|
-
name: "number2",
|
|
3915
|
-
detail: "Additional numbers, cell references or ranges to calculate the minimum value from, up to a maximum of 255."
|
|
3916
|
-
}
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3919
|
-
};
|
|
3920
|
-
// src/locale/function-list/text/en-US.ts
|
|
3921
|
-
var en_US_default13 = {};
|
|
3922
|
-
// src/locale/function-list/univer/en-US.ts
|
|
3923
|
-
var en_US_default14 = {};
|
|
3924
|
-
// src/locale/function-list/web/en-US.ts
|
|
3925
|
-
var en_US_default15 = {};
|
|
3926
|
-
// src/locale/en-US.ts
|
|
3927
|
-
var en_US_default16 = {
|
|
3928
|
-
formula: {
|
|
3929
|
-
insert: {
|
|
3930
|
-
tooltip: "Functions",
|
|
3931
|
-
sum: "SUM",
|
|
3932
|
-
average: "AVERAGE",
|
|
3933
|
-
count: "COUNT",
|
|
3934
|
-
max: "MAX",
|
|
3935
|
-
min: "MIN",
|
|
3936
|
-
more: "More Functions..."
|
|
3937
|
-
},
|
|
3938
|
-
functionList: _object_spread({}, en_US_default7, en_US_default5, en_US_default11, en_US_default12, en_US_default10, en_US_default4, en_US_default13, en_US_default9, en_US_default8, en_US_default6, en_US_default3, en_US_default2, en_US_default15, en_US_default, en_US_default14),
|
|
3939
|
-
prompt: {
|
|
3940
|
-
helpExample: "EXAMPLE",
|
|
3941
|
-
helpAbstract: "ABOUT",
|
|
3942
|
-
required: "Required.",
|
|
3943
|
-
optional: "Optional."
|
|
3944
|
-
},
|
|
3945
|
-
functionType: {
|
|
3946
|
-
financial: "Financial",
|
|
3947
|
-
date: "Date & Time",
|
|
3948
|
-
math: "Math & Trig",
|
|
3949
|
-
statistical: "Statistical",
|
|
3950
|
-
lookup: "Lookup & Reference",
|
|
3951
|
-
database: "Database",
|
|
3952
|
-
text: "Text",
|
|
3953
|
-
logical: "Logical",
|
|
3954
|
-
information: "Information",
|
|
3955
|
-
engineering: "Engineering",
|
|
3956
|
-
cube: "Cube",
|
|
3957
|
-
compatibility: "Compatibility",
|
|
3958
|
-
web: "Web",
|
|
3959
|
-
array: "Array",
|
|
3960
|
-
univer: "Univer"
|
|
3961
|
-
},
|
|
3962
|
-
moreFunctions: {
|
|
3963
|
-
confirm: "Confirm",
|
|
3964
|
-
prev: "Previous",
|
|
3965
|
-
next: "Next",
|
|
3966
|
-
searchFunctionPlaceholder: "Search function",
|
|
3967
|
-
allFunctions: "All Functions",
|
|
3968
|
-
syntax: "SYNTAX"
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
};
|
|
3972
|
-
// src/locale/function-list/array/zh-CN.ts
|
|
3973
|
-
var zh_CN_default = {};
|
|
3974
|
-
// src/locale/function-list/compatibility/zh-CN.ts
|
|
3975
|
-
var zh_CN_default2 = {};
|
|
3976
|
-
// src/locale/function-list/cube/zh-CN.ts
|
|
3977
|
-
var zh_CN_default3 = {};
|
|
3978
|
-
// src/locale/function-list/database/zh-CN.ts
|
|
3979
|
-
var zh_CN_default4 = {};
|
|
3980
|
-
// src/locale/function-list/date/zh-CN.ts
|
|
3981
|
-
var zh_CN_default5 = {};
|
|
3982
|
-
// src/locale/function-list/engineering/zh-CN.ts
|
|
3983
|
-
var zh_CN_default6 = {};
|
|
3984
|
-
// src/locale/function-list/financial/zh-CN.ts
|
|
3985
|
-
var zh_CN_default7 = {};
|
|
3986
|
-
// src/locale/function-list/information/zh-CN.ts
|
|
3987
|
-
var zh_CN_default8 = {};
|
|
3988
|
-
// src/locale/function-list/logical/zh-CN.ts
|
|
3989
|
-
var zh_CN_default9 = {};
|
|
3990
|
-
// src/locale/function-list/lookup/zh-CN.ts
|
|
3991
|
-
var zh_CN_default10 = {};
|
|
3992
|
-
// src/locale/function-list/math/zh-CN.ts
|
|
3993
|
-
var zh_CN_default11 = {
|
|
3994
|
-
SUM: {
|
|
3995
|
-
description: "将单个值、单元格引用或是区域相加,或者将三者的组合相加。",
|
|
3996
|
-
abstract: "求参数的和",
|
|
3997
|
-
functionParameter: {
|
|
3998
|
-
number1: {
|
|
3999
|
-
name: "数值1",
|
|
4000
|
-
detail: "要相加的第一个数字。 该数字可以是 4 之类的数字,B6 之类的单元格引用或 B2:B8 之类的单元格范围。"
|
|
4001
|
-
},
|
|
4002
|
-
number2: {
|
|
4003
|
-
name: "数值2",
|
|
4004
|
-
detail: "这是要相加的第二个数字。 可以按照这种方式最多指定 255 个数字。"
|
|
4005
|
-
}
|
|
4006
|
-
}
|
|
4007
|
-
},
|
|
4008
|
-
SUMIF: {
|
|
4009
|
-
description: "对范围中符合指定条件的值求和。",
|
|
4010
|
-
abstract: "按给定条件对指定单元格求和",
|
|
4011
|
-
functionParameter: {
|
|
4012
|
-
range: {
|
|
4013
|
-
name: "范围",
|
|
4014
|
-
detail: "要根据条件进行检测的范围。"
|
|
4015
|
-
},
|
|
4016
|
-
criteria: {
|
|
4017
|
-
name: "条件",
|
|
4018
|
-
detail: "以数字、表达式、单元格引用、文本或函数的形式来定义将添加哪些单元格。可包括的通配符字符 - 问号(?)以匹配任意单个字符,星号(*)以匹配任意字符序列。 如果要查找实际的问号或星号,请在该字符前键入波形符(~)。"
|
|
4019
|
-
},
|
|
4020
|
-
sum_range: {
|
|
4021
|
-
name: "求和范围",
|
|
4022
|
-
detail: "要添加的实际单元格,如果要添加在范围参数指定以外的其他单元格。 如果省略sum_range参数,Excel就会添加范围参数中指定的单元格(与应用标准的单元格相同)。"
|
|
4023
|
-
}
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
};
|
|
4027
|
-
// src/locale/function-list/statistical/zh-CN.ts
|
|
4028
|
-
var zh_CN_default12 = {
|
|
4029
|
-
AVERAGE: {
|
|
4030
|
-
description: "返回参数的平均值(算术平均值)。",
|
|
4031
|
-
abstract: "返回参数平均值",
|
|
4032
|
-
functionParameter: {
|
|
4033
|
-
number1: {
|
|
4034
|
-
name: "数值1",
|
|
4035
|
-
detail: "要计算平均值的第一个数字、单元格引用或单元格区域。"
|
|
4036
|
-
},
|
|
4037
|
-
number2: {
|
|
4038
|
-
name: "数值2",
|
|
4039
|
-
detail: "要计算平均值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
|
|
4040
|
-
}
|
|
4041
|
-
}
|
|
4042
|
-
},
|
|
4043
|
-
COUNT: {
|
|
4044
|
-
description: "计算包含数字的单元格个数以及参数列表中数字的个数。",
|
|
4045
|
-
abstract: "计算参数列表中数字的个数",
|
|
4046
|
-
functionParameter: {
|
|
4047
|
-
value1: {
|
|
4048
|
-
name: "值1",
|
|
4049
|
-
detail: "要计算其中数字的个数的第一项、单元格引用或区域。"
|
|
4050
|
-
},
|
|
4051
|
-
value2: {
|
|
4052
|
-
name: "值2",
|
|
4053
|
-
detail: "要计算其中数字的个数的其他项、单元格引用或区域,最多可包含 255 个。"
|
|
4054
|
-
}
|
|
4055
|
-
}
|
|
4056
|
-
},
|
|
4057
|
-
MAX: {
|
|
4058
|
-
description: "返回一组值中的最大值。",
|
|
4059
|
-
abstract: "返回参数列表中的最大值",
|
|
4060
|
-
functionParameter: {
|
|
4061
|
-
number1: {
|
|
4062
|
-
name: "数值1",
|
|
4063
|
-
detail: "要计算最大值的第一个数字、单元格引用或单元格区域。"
|
|
4064
|
-
},
|
|
4065
|
-
number2: {
|
|
4066
|
-
name: "数值2",
|
|
4067
|
-
detail: "要计算最大值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
|
|
4068
|
-
}
|
|
4069
|
-
}
|
|
4070
|
-
},
|
|
4071
|
-
MIN: {
|
|
4072
|
-
description: "返回一组值中的最小值。",
|
|
4073
|
-
abstract: "返回参数列表中的最小值",
|
|
4074
|
-
functionParameter: {
|
|
4075
|
-
number1: {
|
|
4076
|
-
name: "数值1",
|
|
4077
|
-
detail: "要计算最小值的第一个数字、单元格引用或单元格区域。"
|
|
4078
|
-
},
|
|
4079
|
-
number2: {
|
|
4080
|
-
name: "数值2",
|
|
4081
|
-
detail: "要计算最小值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
|
|
4082
|
-
}
|
|
4083
|
-
}
|
|
4084
|
-
}
|
|
4085
|
-
};
|
|
4086
|
-
// src/locale/function-list/text/zh-CN.ts
|
|
4087
|
-
var zh_CN_default13 = {};
|
|
4088
|
-
// src/locale/function-list/univer/zh-CN.ts
|
|
4089
|
-
var zh_CN_default14 = {};
|
|
4090
|
-
// src/locale/function-list/web/zh-CN.ts
|
|
4091
|
-
var zh_CN_default15 = {};
|
|
4092
|
-
// src/locale/zh-CN.ts
|
|
4093
|
-
var zh_CN_default16 = {
|
|
4094
|
-
formula: {
|
|
4095
|
-
insert: {
|
|
4096
|
-
tooltip: "函数",
|
|
4097
|
-
sum: "求和",
|
|
4098
|
-
average: "平均值",
|
|
4099
|
-
count: "计数",
|
|
4100
|
-
max: "最大值",
|
|
4101
|
-
min: "最小值",
|
|
4102
|
-
more: "更多函数..."
|
|
4103
|
-
},
|
|
4104
|
-
functionList: _object_spread({}, zh_CN_default7, zh_CN_default5, zh_CN_default11, zh_CN_default12, zh_CN_default10, zh_CN_default4, zh_CN_default13, zh_CN_default9, zh_CN_default8, zh_CN_default6, zh_CN_default3, zh_CN_default2, zh_CN_default15, zh_CN_default, zh_CN_default14),
|
|
4105
|
-
prompt: {
|
|
4106
|
-
helpExample: "示例",
|
|
4107
|
-
helpAbstract: "简介",
|
|
4108
|
-
required: "必需。",
|
|
4109
|
-
optional: "可选。"
|
|
4110
|
-
},
|
|
4111
|
-
functionType: {
|
|
4112
|
-
financial: "财务",
|
|
4113
|
-
date: "日期与时间",
|
|
4114
|
-
math: "数学与三角函数",
|
|
4115
|
-
statistical: "统计",
|
|
4116
|
-
lookup: "查找与引用",
|
|
4117
|
-
database: "数据库",
|
|
4118
|
-
text: "文本",
|
|
4119
|
-
logical: "逻辑",
|
|
4120
|
-
information: "信息",
|
|
4121
|
-
engineering: "工程",
|
|
4122
|
-
cube: "多维数据集",
|
|
4123
|
-
compatibility: "兼容性",
|
|
4124
|
-
web: "Web",
|
|
4125
|
-
array: "数组",
|
|
4126
|
-
univer: "Univer"
|
|
4127
|
-
},
|
|
4128
|
-
moreFunctions: {
|
|
4129
|
-
confirm: "应用",
|
|
4130
|
-
prev: "上一步",
|
|
4131
|
-
next: "下一步",
|
|
4132
|
-
searchFunctionPlaceholder: "搜索函数",
|
|
4133
|
-
allFunctions: "全部函数",
|
|
4134
|
-
syntax: "语法"
|
|
4135
|
-
}
|
|
4136
|
-
}
|
|
4137
|
-
};
|
|
4138
|
-
// src/formula-ui-plugin.ts
|
|
4139
|
-
var FormulaUIPlugin = (_class = /*#__PURE__*/ function(_superClass) {
|
|
4140
|
-
_inherits(_class, _superClass);
|
|
4141
|
-
var _super = _create_super(_class);
|
|
4142
|
-
function _class(_config, _injector, _localeService, _currentUniverService) {
|
|
4143
|
-
_class_call_check(this, _class);
|
|
4144
|
-
var _this;
|
|
4145
|
-
_this = _super.call(this, FORMULA_UI_PLUGIN_NAME);
|
|
4146
|
-
_this._config = _config;
|
|
4147
|
-
_this._injector = _injector;
|
|
4148
|
-
_this._localeService = _localeService;
|
|
4149
|
-
_this._currentUniverService = _currentUniverService;
|
|
4150
|
-
return _this;
|
|
4151
|
-
}
|
|
4152
|
-
_create_class(_class, [
|
|
4153
|
-
{
|
|
4154
|
-
key: "initialize",
|
|
4155
|
-
value: function initialize() {
|
|
4156
|
-
var _this = this;
|
|
4157
|
-
this._localeService.load({
|
|
4158
|
-
enUS: en_US_default16
|
|
4159
|
-
});
|
|
4160
|
-
var dependencies = [
|
|
4161
|
-
// services
|
|
4162
|
-
[
|
|
4163
|
-
IFormulaPromptService,
|
|
4164
|
-
{
|
|
4165
|
-
useClass: FormulaPromptService
|
|
4166
|
-
}
|
|
4167
|
-
],
|
|
4168
|
-
[
|
|
4169
|
-
IFormulaInputService,
|
|
4170
|
-
{
|
|
4171
|
-
useClass: FormulaInputService
|
|
4172
|
-
}
|
|
4173
|
-
],
|
|
4174
|
-
[
|
|
4175
|
-
IDescriptionService,
|
|
4176
|
-
{
|
|
4177
|
-
useFactory: function() {
|
|
4178
|
-
var _this__config;
|
|
4179
|
-
return _this._injector.createInstance(DescriptionService, ((_this__config = _this._config) === null || _this__config === void 0 ? void 0 : _this__config.description) || []);
|
|
4180
|
-
}
|
|
4181
|
-
}
|
|
4182
|
-
],
|
|
4183
|
-
// controllers
|
|
4184
|
-
[
|
|
4185
|
-
FormulaUIController
|
|
4186
|
-
],
|
|
4187
|
-
[
|
|
4188
|
-
PromptController
|
|
4189
|
-
],
|
|
4190
|
-
[
|
|
4191
|
-
FormulaInputController
|
|
4192
|
-
],
|
|
4193
|
-
[
|
|
4194
|
-
FormulaAutoFillController
|
|
4195
|
-
]
|
|
4196
|
-
];
|
|
4197
|
-
dependencies.forEach(function(dependency) {
|
|
4198
|
-
return _this._injector.add(dependency);
|
|
4199
|
-
});
|
|
4200
|
-
}
|
|
4201
|
-
},
|
|
4202
|
-
{
|
|
4203
|
-
key: "onReady",
|
|
4204
|
-
value: function onReady() {
|
|
4205
|
-
this.initialize();
|
|
4206
|
-
}
|
|
4207
|
-
}
|
|
4208
|
-
]);
|
|
4209
|
-
return _class;
|
|
4210
|
-
}(_import_core17_Plugin = import_core17.Plugin), _define_property(_class, "type", import_core17.PluginType.Sheet), _class);
|
|
4211
|
-
FormulaUIPlugin = __decorateClass([
|
|
4212
|
-
__decorateParam(1, (0, import_redi8.Inject)(import_redi8.Injector)),
|
|
4213
|
-
__decorateParam(2, (0, import_redi8.Inject)(import_core17.LocaleService)),
|
|
4214
|
-
__decorateParam(3, import_core17.IUniverInstanceService)
|
|
4215
|
-
], FormulaUIPlugin);
|
|
1
|
+
"use strict";var dt=Object.defineProperty;var mt=(i,e,t)=>e in i?dt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var w=(i,e,t)=>(mt(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),O=require("@wendellhu/redi"),y=require("@univerjs/engine-formula"),h=require("@univerjs/sheets"),L=require("@univerjs/sheets-ui"),Ke=require("@ctrl/tinycolor"),q=require("@univerjs/engine-render"),E=require("@univerjs/ui"),G=require("rxjs"),k=require("@wendellhu/redi/react-bindings"),x=require("react"),Q=require("@univerjs/design"),Ie=require("@univerjs/docs"),Ge="formula-ui";class ft extends a.Disposable{constructor(){super(...arguments);w(this,"_dirtyConversionMap",new Map)}dispose(){this._dirtyConversionMap.clear()}remove(t){this._dirtyConversionMap.delete(t)}get(t){return this._dirtyConversionMap.get(t)}has(t){return this._dirtyConversionMap.has(t)}register(t,n){this._dirtyConversionMap.set(t,n)}getDirtyConversionMap(){return this._dirtyConversionMap}}const Ae=O.createIdentifier("univer.formula.active-dirty-manager.service");var ht=Object.defineProperty,gt=Object.getOwnPropertyDescriptor,pt=(i,e,t,n)=>{for(var r=n>1?void 0:n?gt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ht(e,t,r),r},be=(i,e)=>(t,n)=>e(t,n,i);let de=class extends a.Disposable{constructor(i,e,t){super(),this._activeDirtyManagerService=i,this._currentUniverService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._initialConversion()}_initialConversion(){this._activeDirtyManagerService.register(h.SetRangeValuesMutation.id,{commandId:h.SetRangeValuesMutation.id,getDirtyData:i=>{const e=i.params;return e.trigger===h.SetStyleCommand.id?{}:{dirtyRanges:this._getSetRangeValuesMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveRangeMutation.id,{commandId:h.MoveRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveRowsMutation.id,{commandId:h.MoveRowsMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRowsMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.MoveColsMutation.id,{commandId:h.MoveColsMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getMoveRowsMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.DeleteRangeMutation.id,{commandId:h.DeleteRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getDeleteRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.InsertRangeMutation.id,{commandId:h.InsertRangeMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getDeleteRangeMutationDirtyRange(e)}}}),this._activeDirtyManagerService.register(h.RemoveRowMutation.id,{commandId:h.RemoveRowMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getRemoveRowOrColumnMutation(e,!0)}}}),this._activeDirtyManagerService.register(h.RemoveColMutation.id,{commandId:h.RemoveColMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyRanges:this._getRemoveRowOrColumnMutation(e,!1)}}}),this._activeDirtyManagerService.register(h.RemoveSheetMutation.id,{commandId:h.RemoveSheetMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyNameMap:this._getRemoveSheetMutation(e)}}}),this._activeDirtyManagerService.register(h.InsertSheetMutation.id,{commandId:h.InsertSheetMutation.id,getDirtyData:i=>{const e=i.params;return{dirtyNameMap:this._getInsertSheetMutation(e)}}})}_getSetRangeValuesMutationDirtyRange(i){const{worksheetId:e,workbookId:t,cellValue:n}=i,r=[];return n==null||(r.push(...this._getDirtyRangesByCellValue(t,e,n)),r.push(...this._getDirtyRangesForArrayFormula(t,e,n))),r}_getMoveRangeMutationDirtyRange(i){const{worksheetId:e,workbookId:t,from:n,to:r}=i,o=[];return o.push(...this._getDirtyRangesByCellValue(t,e,n)),o.push(...this._getDirtyRangesByCellValue(t,e,r)),o.push(...this._getDirtyRangesForArrayFormula(t,e,r)),o}_getMoveRowsMutationDirtyRange(i){const{worksheetId:e,workbookId:t,sourceRange:n,targetRange:r}=i,o=[],s=this._rangeToMatrix(n).getData(),c=this._rangeToMatrix(r).getData();return o.push(...this._getDirtyRangesByCellValue(t,e,s)),o.push(...this._getDirtyRangesByCellValue(t,e,c)),o.push(...this._getDirtyRangesForArrayFormula(t,e,c)),o}_getDeleteRangeMutationDirtyRange(i){const{worksheetId:e,workbookId:t,ranges:n,shiftDimension:r}=i,o=[],s=this._currentUniverService.getUniverSheetInstance(t),c=s==null?void 0:s.getSheetBySheetId(e),l=(c==null?void 0:c.getLastRowWithContent())||0,u=(c==null?void 0:c.getLastColumnWithContent())||0,f=new a.ObjectMatrix;for(const m of n){let p=null;const{startRow:_,startColumn:I,endRow:d,endColumn:v}=m;r===a.Dimension.ROWS?p=this._rangeToMatrix({startRow:_,startColumn:I,endRow:l,endColumn:v}):r===a.Dimension.COLUMNS&&(p=this._rangeToMatrix({startRow:_,startColumn:I,endRow:d,endColumn:u})),p!=null&&f.merge(p)}const g=f.getData();return o.push(...this._getDirtyRangesByCellValue(t,e,g)),o.push(...this._getDirtyRangesForArrayFormula(t,e,g)),o}_getRemoveRowOrColumnMutation(i,e=!0){const{worksheetId:t,workbookId:n,ranges:r}=i,o=[],s=this._currentUniverService.getUniverSheetInstance(n),c=s==null?void 0:s.getSheetBySheetId(t),l=(c==null?void 0:c.getRowCount())||0,u=(c==null?void 0:c.getColumnCount())||0,f=new a.ObjectMatrix;for(const m of r){let p=null;const{startRow:_,endRow:I,startColumn:d,endColumn:v}=m;e===!0?p=this._rangeToMatrix({startRow:_,startColumn:0,endRow:I,endColumn:u-1}):p=this._rangeToMatrix({startRow:0,startColumn:d,endRow:l,endColumn:v}),p!=null&&f.merge(p)}const g=f.getData();return o.push(...this._getDirtyRangesByCellValue(n,t,g)),o.push(...this._getDirtyRangesForArrayFormula(n,t,g)),o}_getRemoveSheetMutation(i,e){const t={},{worksheetId:n,workbookId:r}=i;return t[r]==null&&(t[r]={}),t[r][n]=e,t}_getInsertSheetMutation(i,e){const t={},{sheet:n,workbookId:r}=i;return t[r]==null&&(t[r]={}),t[r][n.id]=e,t}_rangeToMatrix(i){const e=new a.ObjectMatrix,{startRow:t,startColumn:n,endRow:r,endColumn:o}=i;for(let s=t;s<=r;s++)for(let c=n;c<=o;c++)e.setValue(s,c,{});return e}_getDirtyRangesByCellValue(i,e,t){const n=[];return t==null||new a.ObjectMatrix(t).getDiscreteRanges().forEach(s=>{n.push({unitId:i,sheetId:e,range:s})}),n}_getDirtyRangesForArrayFormula(i,e,t){var s,c;const n=[];if(t==null)return n;const r=new a.ObjectMatrix(t),o=this._formulaDataModel.getArrayFormulaRange();if((s=o==null?void 0:o[i])!=null&&s[e]){const l=new a.ObjectMatrix((c=o==null?void 0:o[i])==null?void 0:c[e]);r.forValue((u,f)=>{l.forValue((g,m,p)=>{const{startRow:_,startColumn:I,endRow:d,endColumn:v}=p;u>=_&&u<=d&&f>=I&&f<=v&&n.push({unitId:i,sheetId:e,range:{startRow:_,startColumn:I,endRow:_,endColumn:I}})})})}return n}};de=pt([a.OnLifecycle(a.LifecycleStages.Ready,de),be(0,Ae),be(1,a.IUniverInstanceService),be(2,O.Inject(y.FormulaDataModel))],de);var St=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,vt=(i,e,t,n)=>{for(var r=n>1?void 0:n?_t(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&St(e,t,r),r},Fe=(i,e)=>(t,n)=>e(t,n,i);let me=class extends a.Disposable{constructor(i,e,t){super(),this._commandService=i,this._sheetInterceptorService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initInterceptorCellContent()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id!==y.SetArrayFormulaDataMutation.id)return;const e=i.params;if(e==null)return;const{arrayFormulaRange:t,arrayFormulaCellData:n}=e;this._formulaDataModel.setArrayFormulaRange(t),this._formulaDataModel.setArrayFormulaCellData(n)}))}_initInterceptorCellContent(){this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{priority:100,handler:(i,e,t)=>{var g,m,p,_,I,d;const{workbookId:n,worksheetId:r,row:o,col:s}=e,c=this._formulaDataModel.getArrayFormulaCellData(),l=this._formulaDataModel.getArrayFormulaRange(),u=(p=(m=(g=c==null?void 0:c[n])==null?void 0:g[r])==null?void 0:m[o])==null?void 0:p[s],f=(d=(I=(_=l==null?void 0:l[n])==null?void 0:_[r])==null?void 0:I[o])==null?void 0:d[s];return u==null||f!=null&&f.startRow===o&&f.startColumn===s?t(i):t({...i,...u})}}))}};me=vt([a.OnLifecycle(a.LifecycleStages.Ready,me),Fe(0,a.ICommandService),Fe(1,O.Inject(h.SheetInterceptorService)),Fe(2,O.Inject(y.FormulaDataModel))],me);var Rt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ct=(i,e,t,n)=>{for(var r=n>1?void 0:n?It(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Rt(e,t,r),r},$e=(i,e)=>(t,n)=>e(t,n,i);let fe=class extends a.Disposable{constructor(i,e){super(),this._autoFillService=i,this._lexerTreeBuilder=e,this._initialize()}_initialize(){this._registerAutoFill()}_registerAutoFill(){const i={type:L.DATA_TYPE.FORMULA,priority:1001,match:e=>a.isFormulaString(e==null?void 0:e.f)||a.isFormulaId(e==null?void 0:e.si),isContinue:(e,t)=>e.type===L.DATA_TYPE.FORMULA,applyFunctions:{[L.APPLY_TYPE.COPY]:(e,t,n,r)=>{const{data:o,index:s}=e;return this._fillCopyFormula(o,t,n,s,r)}}};this._autoFillService.registerRule(i)}_fillCopyFormula(i,e,t,n,r){var l,u;const o=Mt(r),s=[],c=new Map;for(let f=1;f<=e;f++){const g=(f-1)%i.length,m=a.Tools.deepClone(i[g]);if(m){const p=((l=i[g])==null?void 0:l.f)||"",_=((u=i[g])==null?void 0:u.si)||"",I=a.isFormulaString(p);if(a.isFormulaId(_))m.si=_,m.f=null,m.v=null,m.p=null,t===a.Direction.DOWN||t===a.Direction.RIGHT?s.push(m):s.unshift(m);else if(I){let v=c.get(g);if(v)m.si=v,m.f=null,m.v=null,m.p=null;else{v=a.Tools.generateRandomId(6),c.set(g,v);const{offsetX:S,offsetY:C}=yt(o,t),T=this._lexerTreeBuilder.moveFormulaRefOffset(p,S,C);m.si=v,m.f=T,m.v=null,m.p=null}t===a.Direction.DOWN||t===a.Direction.RIGHT?s.push(m):s.unshift(m)}}}return s}};fe=Ct([a.OnLifecycle(a.LifecycleStages.Ready,fe),$e(0,L.IAutoFillService),$e(1,O.Inject(y.LexerTreeBuilder))],fe);function yt(i,e){let t=0,n=0;switch(e){case a.Direction.UP:n=-i;break;case a.Direction.RIGHT:t=i;break;case a.Direction.DOWN:n=i;break;case a.Direction.LEFT:t=-i;break}return{offsetX:t,offsetY:n}}function Mt(i){let e=0;for(const t in i)i[t].forEach(n=>{e+=n.data.length});return e}const ze="special-paste-formula",Ye={id:"sheet.command.paste-formula",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(L.SheetPasteCommand.id,{value:ze})};var bt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Nt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ft(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&bt(e,t,r),r},le=(i,e)=>(t,n)=>e(t,n,i);const Tt="default-paste-formula";let he=class extends a.Disposable{constructor(i,e,t,n){super(),this._currentUniverSheet=i,this._lexerTreeBuilder=e,this._sheetClipboardService=t,this._injector=n,this._initialize()}_initialize(){this._registerClipboardHook()}_registerClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteFormulaHook())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteWithFormulaHook()))}_pasteFormulaHook(){return{hookName:ze,specialPasteInfo:{label:"specialPaste.formula"},onPasteCells:(e,t,n,r)=>{const o=this._currentUniverSheet.getCurrentUniverSheetInstance(),s=o.getUnitId(),c=o.getActiveSheet().getSheetId();return this._injector.invoke(l=>qe(s,c,e,t,l,r,this._lexerTreeBuilder,!0))}}}_pasteWithFormulaHook(){return{hookName:Tt,onPasteCells:(e,t,n,r)=>{const o=this._currentUniverSheet.getCurrentUniverSheetInstance(),s=o.getUnitId(),c=o.getActiveSheet().getSheetId();return this._injector.invoke(l=>qe(s,c,e,t,l,r,this._lexerTreeBuilder))}}}};he=Nt([a.OnLifecycle(a.LifecycleStages.Ready,he),le(0,a.IUniverInstanceService),le(1,O.Inject(y.LexerTreeBuilder)),le(2,L.ISheetClipboardService),le(3,O.Inject(O.Injector))],he);function qe(i,e,t,n,r,o,s,c=!1){const l=[],u=[],{startColumn:f,startRow:g}=t,m=new a.ObjectMatrix,p=new Map;let _=0,I=0,d=0,v=0;if(o){const{copyType:T,copyRange:F}=o;T===L.COPY_TYPE.COPY&&F&&(d=F.startRow,v=F.startColumn,_=F.endRow-d+1,I=F.endColumn-v+1)}n.forValue((T,F,M)=>{const b=M.f||"",D={};if(c&&(D.v=M.v),a.isFormulaString(b)&&_&&I){const U=T%_,N=F%I,P=`${U}_${N}`;let A=p.get(P);if(A)D.si=A,D.f=null,D.v=null,D.p=null;else{A=a.Tools.generateRandomId(6),p.set(P,A);const W=F+f-(v+N),$=T+g-(d+U),z=s.moveFormulaRefOffset(b,W,$);D.si=A,D.f=z,D.v=null,D.p=null}}m.setValue(T+g,F+f,D)});const S={workbookId:i,worksheetId:e,cellValue:m.getData()};l.push({id:h.SetRangeValuesMutation.id,params:S});const C=h.SetRangeValuesUndoMutationFactory(r,S);return u.push({id:h.SetRangeValuesMutation.id,params:C}),{undos:u,redos:l}}var wt=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Et=(i,e,t,n)=>{for(var r=n>1?void 0:n?xt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wt(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);let ge=class extends a.Disposable{constructor(e,t,n,r,o,s,c,l){super();w(this,"_previousShape");this._editorBridgeService=e,this._formulaDataModel=t,this._lexerTreeBuilder=n,this._themeService=r,this._renderManagerService=o,this._selectionRenderService=s,this._sheetSkeletonManagerService=c,this._commandService=l,this._initInterceptorEditorStart(),this._commandExecutedListener()}_initInterceptorEditorStart(){this.disposeWithMe(a.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(e,t,n)=>{var p,_,I,d;const{row:r,col:o,workbookId:s,worksheetId:c}=t,l=this._formulaDataModel.getArrayFormulaRange(),u=this._formulaDataModel.getArrayFormulaCellData();if(this._removeArrayFormulaRangeShape(),e==null)return n(e);let f=null;const g=this._formulaDataModel.getFormulaDataItem(r,o,c,s);if(g!=null){const{f:v,si:S,x:C=0,y:T=0}=g;if(S!=null&&(C>0||T>0)){let F="";if(v.length>0)F=v;else{const b=this._formulaDataModel.getFormulaItemBySId(S,c,s);if(b==null||b.f.length===0)return n(e);F=b.f}f={f:this._lexerTreeBuilder.moveFormulaRefOffset(F,C,T)}}}if(e.v!=null&&e.v!==""&&((I=(_=(p=u[s])==null?void 0:p[c])==null?void 0:_[r])==null?void 0:I[o])==null)return f||n(e);const m=(d=l==null?void 0:l[s])==null?void 0:d[c];return m!=null&&new a.ObjectMatrix(m).forValue((v,S,C)=>{if(C==null)return!0;const{startRow:T,startColumn:F,endRow:M,endColumn:b}=C;if(v===r&&S===o)return this._createArrayFormulaRangeShape(C,s),!1;if(r>=T&&r<=M&&o>=F&&o<=b){const D=this._formulaDataModel.getFormulaDataItem(v,S,c,s);return D==null||D.f==null?!0:(f==null&&(f={f:D.f,isInArrayFormulaRange:!0}),this._createArrayFormulaRangeShape(C,s),!1)}}),f||n(e)}})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===y.SetFormulaCalculationResultMutation.id&&this._removeArrayFormulaRangeShape()}))}_createArrayFormulaRangeShape(e,t){var p;const n=this._themeService.getCurrentTheme(),r=new Ke.TinyColor(n.colorWhite).setAlpha(0).toString(),o={strokeWidth:1,stroke:n.hyacinth700,fill:r,widgets:{},hasAutoFill:!1,hasRowHeader:!1,hasColumnHeader:!1},{scene:s}=this._renderManagerService.getRenderById(t)||{},{rangeWithCoord:c,primaryWithCoord:l}=this._selectionRenderService.convertSelectionRangeToData({range:e,primary:null,style:o}),u=(p=this._sheetSkeletonManagerService.getCurrent())==null?void 0:p.skeleton;if(!s||!u)return;const{rowHeaderWidth:f,columnHeaderHeight:g}=u,m=new L.SelectionShape(s,100,!1,this._themeService);m.update(c,f,g,o,l),this._previousShape=m}_removeArrayFormulaRangeShape(){this._previousShape!=null&&(this._previousShape.dispose(),this._previousShape=null)}};ge=Et([a.OnLifecycle(a.LifecycleStages.Rendered,ge),K(0,O.Inject(L.IEditorBridgeService)),K(1,O.Inject(y.FormulaDataModel)),K(2,O.Inject(y.LexerTreeBuilder)),K(3,O.Inject(a.ThemeService)),K(4,q.IRenderManagerService),K(5,L.ISelectionRenderService),K(6,O.Inject(L.SheetSkeletonManagerService)),K(7,a.ICommandService)],ge);const Pe={id:"formula-ui.operation.change-ref-to-absolute",type:a.CommandType.OPERATION,handler:async i=>!0};class Ot{constructor(){w(this,"_sequenceNodes",[]);w(this,"_isSelectionMoving",!1);w(this,"_isLockedOnSelectionChangeRefString",!1);w(this,"_isLockedOnSelectionInsertRefString",!1);w(this,"_syncToEditor$",new G.Subject);w(this,"syncToEditor$",this._syncToEditor$.asObservable());w(this,"_changeRef$",new G.Subject);w(this,"changeRef$",this._changeRef$.asObservable());w(this,"_inputFormula$",new G.Subject);w(this,"inputFormula$",this._inputFormula$.asObservable())}dispose(){this._sequenceNodes=[]}inputFormula(e){this._inputFormula$.next(e)}syncToEditor(e){this._syncToEditor$.next({sequences:this.getSequenceNodes(),textSelectionOffset:e})}getSequenceNodes(){return[...this._sequenceNodes]}setSequenceNodes(e){this._sequenceNodes=e}clearSequenceNodes(){this._sequenceNodes=[]}getCurrentSequenceNode(e){return this._sequenceNodes[this.getCurrentSequenceNodeIndex(e)]}getCurrentSequenceNodeByIndex(e){return this._sequenceNodes[e]}getCurrentSequenceNodeIndex(e){let t=0;for(let n=0,r=this._sequenceNodes.length;n<r;n++){const o=this._sequenceNodes[n];if(typeof o=="string")t++;else{const{endIndex:s}=o;t=s}if(e<=t)return n}return this._sequenceNodes.length}updateSequenceRef(e,t){const n=this._sequenceNodes[e];if(typeof n=="string"||n.nodeType!==y.sequenceNodeType.REFERENCE)return;const r=t.length-n.token.length,o={...n};o.token=t,o.endIndex+=r,this._sequenceNodes[e]=o;for(let s=e+1,c=this._sequenceNodes.length;s<c;s++){const l=this._sequenceNodes[s];if(typeof l=="string")continue;const u={...l};u.startIndex+=r,u.endIndex+=r,this._sequenceNodes[s]=u}this._changeRef$.next(!0)}insertSequenceRef(e,t){const n=t.length,r=this.getCurrentSequenceNodeIndex(e);this._sequenceNodes.splice(r,0,{token:t,startIndex:e,endIndex:e+n-1,nodeType:y.sequenceNodeType.REFERENCE});for(let o=r+1,s=this._sequenceNodes.length;o<s;o++){const c=this._sequenceNodes[o];if(typeof c=="string")continue;const l={...c};l.startIndex+=n,l.endIndex+=n,this._sequenceNodes[o]=l}this._changeRef$.next(!0)}insertSequenceString(e,t){const n=this.getCurrentSequenceNodeIndex(e),r=t.split("");this._sequenceNodes.splice(n,0,...r);const o=r.length;for(let s=n+o,c=this._sequenceNodes.length;s<c;s++){const l=this._sequenceNodes[s];if(typeof l=="string")continue;const u={...l};u.startIndex+=o,u.endIndex+=o,this._sequenceNodes[s]=u}this._changeRef$.next(!0)}enableSelectionMoving(){this._isSelectionMoving=!0}disableSelectionMoving(){this._isSelectionMoving=!1}isSelectionMoving(){return this._isSelectionMoving}enableLockedSelectionChange(){this._isLockedOnSelectionChangeRefString=!0}disableLockedSelectionChange(){this._isLockedOnSelectionChangeRefString=!1}isLockedSelectionChange(){return this._isLockedOnSelectionChangeRefString}enableLockedSelectionInsert(){this._isLockedOnSelectionInsertRefString=!0}disableLockedSelectionInsert(){this._isLockedOnSelectionInsertRefString=!1}isLockedSelectionInsert(){return this._isLockedOnSelectionInsertRefString}}const se=O.createIdentifier("formula-ui.input-service");var Dt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,At=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lt(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Dt(e,t,r),r},te=(i,e)=>(t,n)=>e(t,n,i);let pe=class extends a.Disposable{constructor(e,t,n,r,o,s){super();w(this,"_userCursorMove",!1);this._commandService=e,this._textSelectionRenderManager=t,this._editorBridgeService=n,this._lexerTreeBuilder=r,this._renderManagerService=o,this._formulaInputService=s,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialEditorInputChange(),this._userMouseListener(),this._inputFormulaListener()}_initialEditorInputChange(){this.disposeWithMe(a.toDisposable(this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=e==null?void 0:e.event;t!=null&&t.which!==E.KeyCode.F4&&(this._userCursorMove=!1)})))}_userMouseListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this.disposeWithMe(a.toDisposable(t.onPointerDownObserver.add(()=>{this._userCursorMove=!0})))}_inputFormulaListener(){this.disposeWithMe(a.toDisposable(this._formulaInputService.inputFormula$.subscribe(e=>{this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:q.DeviceInputEventType.Dblclick});const n=this._lexerTreeBuilder.sequenceNodesBuilder(e)||[];this._formulaInputService.setSequenceNodes(n),this._formulaInputService.syncToEditor(e.length-1)})))}_changeRefString(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null)return;const{startOffset:t}=e,n=t-2,r=this._formulaInputService.getCurrentSequenceNodeIndex(n),o=this._formulaInputService.getCurrentSequenceNodeByIndex(r);if(o==null||typeof o=="string"||o.nodeType!==y.sequenceNodeType.REFERENCE)return;const s=o.token.split("!");let c=o.token;s.length>1&&(c=s[s.length-1]);let l="";for(let g=0,m=s.length;g<m-1;g++)l+=s[g];let u=c;if(c.indexOf(y.matchToken.COLON)>-1)if(!this._userCursorMove)u=this._changeRangeRef(c);else{const g=c.split(y.matchToken.COLON),m=g[0],p=g[1];n-o.startIndex<=m.length?u=this._changeSingleRef(m)+y.matchToken.COLON+p:u=m+y.matchToken.COLON+this._changeSingleRef(p)}else u=this._changeSingleRef(c);u=l+u;const f=u.length-o.token.length;this._formulaInputService.updateSequenceRef(r,u),this._formulaInputService.syncToEditor(n+f+1)}_changeRangeRef(e){const t=a.deserializeRangeWithSheet(e).range;let n="";return t.startAbsoluteRefType===a.AbsoluteRefType.NONE||t.startAbsoluteRefType==null?(t.startAbsoluteRefType=a.AbsoluteRefType.ALL,t.endAbsoluteRefType=a.AbsoluteRefType.ALL):(t.startAbsoluteRefType=a.AbsoluteRefType.NONE,t.endAbsoluteRefType=a.AbsoluteRefType.NONE),n=a.serializeRange(t),n}_changeSingleRef(e){const t=a.deserializeRangeWithSheet(e).range,n=t.startAbsoluteRefType;let r="";return n===a.AbsoluteRefType.NONE||n==null?(t.startAbsoluteRefType=a.AbsoluteRefType.ALL,t.endAbsoluteRefType=a.AbsoluteRefType.ALL):n===a.AbsoluteRefType.ALL?(t.startAbsoluteRefType=a.AbsoluteRefType.ROW,t.endAbsoluteRefType=a.AbsoluteRefType.ROW):n===a.AbsoluteRefType.ROW?(t.startAbsoluteRefType=a.AbsoluteRefType.COLUMN,t.endAbsoluteRefType=a.AbsoluteRefType.COLUMN):(t.startAbsoluteRefType=a.AbsoluteRefType.NONE,t.endAbsoluteRefType=a.AbsoluteRefType.NONE),r=a.serializeRange(t),r}_commandExecutedListener(){const e=[Pe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._changeRefString()}))}_getEditorObject(){return L.getEditorObject(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};pe=At([a.OnLifecycle(a.LifecycleStages.Steady,pe),te(0,a.ICommandService),te(1,q.ITextSelectionRenderManager),te(2,O.Inject(L.IEditorBridgeService)),te(3,O.Inject(y.LexerTreeBuilder)),te(4,q.IRenderManagerService),te(5,se)],pe);const Xe={id:"formula-ui.command.insert-function",type:a.CommandType.COMMAND,handler:async(i,e)=>{const{list:t}=e,n=i.get(a.ICommandService),r=new a.ObjectMatrix;t.forEach(s=>{const{range:c,primary:l,formula:u}=s,{row:f,column:g}=l,m=a.Tools.generateRandomId(6);r.setValue(f,g,{f:u,si:m});const{startRow:p,startColumn:_,endRow:I,endColumn:d}=c;for(let v=p;v<=I;v++)for(let S=_;S<=d;S++)(v!==f||S!==g)&&r.setValue(v,S,{si:m})});const o={value:r.getData()};return n.executeCommand(h.SetRangeValuesCommand.id,o)}},re={id:"formula-ui.operation.select-editor-formula",type:a.CommandType.OPERATION,handler:(i,e)=>!0},J=O.createIdentifier("formula-ui.prompt-service");class Pt{constructor(){w(this,"_search$",new G.Subject);w(this,"_help$",new G.Subject);w(this,"_navigate$",new G.Subject);w(this,"_accept$",new G.Subject);w(this,"_acceptFormulaName$",new G.Subject);w(this,"search$",this._search$.asObservable());w(this,"help$",this._help$.asObservable());w(this,"navigate$",this._navigate$.asObservable());w(this,"accept$",this._accept$.asObservable());w(this,"acceptFormulaName$",this._acceptFormulaName$.asObservable());w(this,"_searching",!1);w(this,"_helping",!1);w(this,"_isInsertRefString",!1)}dispose(){this._search$.complete(),this._help$.complete(),this._navigate$.complete(),this._accept$.complete(),this._acceptFormulaName$.complete()}search(e){this._searching=e.visible,this._search$.next(e)}isSearching(){return this._searching}help(e){this._helping=e.visible,this._help$.next(e)}isHelping(){return this._helping}navigate(e){this._navigate$.next(e)}accept(e){this._accept$.next(e)}acceptFormulaName(e){this._acceptFormulaName$.next(e)}}const Oe={id:"formula-ui.operation.help-function",type:a.CommandType.OPERATION,handler:async(i,e)=>(i.get(J).help(e),!0)},Ue={id:"formula-ui.operation.insert-function",type:a.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(h.SelectionManagerService),n=i.get(se),r=t.getSelections();if(!r||!r.length)return!1;const o=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),s=o.getActiveSheet(),c=o.getUnitId(),l=s.getSheetId(),u=s.getCellMatrix(),{value:f}=e,g=i.get(a.ICommandService),m=[];let p=null,_=0,I=0;if(r.some(d=>{const{range:v,primary:S}=d,C=(S==null?void 0:S.actualRow)??v.startRow,T=(S==null?void 0:S.actualColumn)??v.startColumn,F=Ut(u,C,T);if(!F)return p=v,_=C,I=T,!0;const M=a.serializeRange(F),b=`=${f}(${M})`;return m.push({range:v,primary:{row:C,column:T},formula:b}),!1}),p){const d=h.getCellAtRowCol(_,I,s),v={range:a.Rectangle.clone(p),primary:{startRow:d.startRow,startColumn:d.startColumn,endRow:d.endRow,endColumn:d.endColumn,actualRow:_,actualColumn:I,isMerged:d.isMerged,isMergedMainCell:d.startRow===_&&d.startColumn===I}},S={unitId:c,sheetId:l,pluginName:h.NORMAL_SELECTION_PLUGIN_NAME,selections:[v]};await g.executeCommand(h.SetSelectionsOperation.id,S),setTimeout(()=>{n.inputFormula(`=${f}(`)},0)}return m.length===0?!1:g.executeCommand(Xe.id,{list:m})}};function Ut(i,e,t){const n=jt(i,e,t);if(n!==e)return{startRow:n,endRow:e-1,startColumn:t,endColumn:t};const r=kt(i,e,t);return r!==t?{startRow:e,endRow:e,startColumn:r,endColumn:t-1}:null}function jt(i,e,t){let n=!1;if(e===0)return e;for(let r=e-1;r>=0;r--){const o=i.getValue(r,t);if(Ce(o)&&!n){if(r===0)return 0;n=!0}else{if(n&&!Ce(o))return r+1;if(n&&r===0)return 0}}return e}function kt(i,e,t){let n=!1;if(t===0)return t;for(let r=t-1;r>=0;r--){const o=i.getValue(e,r);if(Ce(o)&&!n){if(r===0)return 0;n=!0}else{if(n&&!Ce(o))return r+1;if(n&&r===0)return 0}}return t}function Ce(i){return i&&(a.Tools.isStringNumber(i.v)||a.getCellValueType(i)===a.CellValueType.NUMBER)}const Ze=`${Ge}_MORE_FUNCTIONS_COMPONENT`,Qe={id:"formula-ui.operation.more-functions",type:a.CommandType.OPERATION,handler:async i=>(i.get(E.ISidebarService).open({header:{title:"formula.insert.tooltip"},children:{label:Ze}}),!0)},De={id:"formula-ui.operation.search-function",type:a.CommandType.OPERATION,handler:async(i,e)=>(i.get(J).search(e),!0)};var Je={exports:{}},ye={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var $t=x,qt=Symbol.for("react.element"),Bt=Symbol.for("react.fragment"),Vt=Object.prototype.hasOwnProperty,Wt=$t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ht={key:!0,ref:!0,__self:!0,__source:!0};function et(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Vt.call(e,n)&&!Ht.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:qt,type:i,key:o,ref:s,props:r,_owner:Wt.current}}ye.Fragment=Bt;ye.jsx=et;ye.jsxs=et;Je.exports=ye;var R=Je.exports;const Kt="univer-formula-error-function",Gt={formulaErrorFunction:Kt};function zt(){const[i,e]=x.useState(!1),[t,n]=x.useState({left:0,top:0}),r=k.useDependency(J),o=k.useDependency(L.ICellEditorManagerService);return x.useEffect(()=>{const s=r.help$.subscribe(c=>{const l=o.getState();if(!l)return;const{visible:u}=c;if(!u){e(u);return}const{endX:f=0,startY:g=0}=l;n({left:f,top:g}),e(u)});return()=>{s==null||s.unsubscribe()}},[]),i?R.jsx("div",{className:Gt.formulaErrorFunction,style:{left:t.left,top:t.top}}):null}var V=function(){return V=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},V.apply(this,arguments)},Yt=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},ae=x.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Yt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=x.useRef("_".concat(Qt()));return tt(t,"".concat(n),{defIds:t.defIds,idSuffix:l.current},V({ref:e,className:c},s),o)});function tt(i,e,t,n,r){return x.createElement(i.tag,V(V({key:e},Xt(i,t,r)),n),(Zt(i,t).children||[]).map(function(o,s){return tt(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Xt(i,e,t){var n=V({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Zt(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?V(V({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function Qt(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Jt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},nt=x.forwardRef(function(i,e){return x.createElement(ae,Object.assign({},i,{id:"check-mark-single",ref:e,icon:Jt}))});nt.displayName="CheckMarkSingle";const en=nt;var tn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},rt=x.forwardRef(function(i,e){return x.createElement(ae,Object.assign({},i,{id:"close-single",ref:e,icon:tn}))});rt.displayName="CloseSingle";const nn=rt;var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_891",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.51 0.5H16.51V16.5H0.51z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_891)"},children:[{tag:"path",attrs:{d:"M9.30291 5.78907C9.30291 6.22898 8.94629 6.5856 8.50637 6.5856 8.06646 6.5856 7.70984 6.22898 7.70984 5.78907 7.70984 5.34916 8.06646 4.99254 8.50637 4.99254 8.94629 4.99254 9.30291 5.34916 9.30291 5.78907zM9.1436 8.17867C9.1436 7.82674 8.8583 7.54144 8.50637 7.54144 8.15444 7.54144 7.86915 7.82674 7.86915 8.17867V12.002C7.86915 12.354 8.15444 12.6392 8.50637 12.6392 8.8583 12.6392 9.1436 12.354 9.1436 12.002V8.17867z"}},{tag:"path",attrs:{d:"M1.49689 8.49728C1.49689 4.62605 4.63514 1.48779 8.50637 1.48779C12.3776 1.48779 15.5159 4.62605 15.5159 8.49728C15.5159 12.3685 12.3776 15.5068 8.50637 15.5068C4.63514 15.5068 1.49689 12.3685 1.49689 8.49728ZM8.50637 2.76224C5.339 2.76224 2.77134 5.32991 2.77134 8.49728C2.77134 11.6646 5.339 14.2323 8.50637 14.2323C11.6737 14.2323 14.2414 11.6646 14.2414 8.49728C14.2414 5.32991 11.6737 2.76224 8.50637 2.76224Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},it=x.forwardRef(function(i,e){return x.createElement(ae,Object.assign({},i,{id:"details-single",ref:e,icon:rn}))});it.displayName="DetailsSingle";const on=it;var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=x.forwardRef(function(i,e){return x.createElement(ae,Object.assign({},i,{id:"more-single",ref:e,icon:sn}))});ot.displayName="MoreSingle";const an=ot,cn="univer-formula-help-function",ln="univer-formula-help-function-title",un="univer-formula-help-function-title-icons",dn="univer-formula-help-function-title-icon",mn="univer-formula-help-function-content",fn="univer-formula-help-function-content-inner",hn="univer-formula-help-function-content-params",gn="univer-formula-help-function-content-params-title",pn="univer-formula-help-function-content-params-detail",Sn="univer-formula-help-function-active",_n="univer-formula-help-decorator",B={formulaHelpFunction:cn,formulaHelpFunctionTitle:ln,formulaHelpFunctionTitleIcons:un,formulaHelpFunctionTitleIcon:dn,formulaHelpFunctionContent:mn,formulaHelpFunctionContentInner:fn,formulaHelpFunctionContentParams:hn,formulaHelpFunctionContentParamsTitle:gn,formulaHelpFunctionContentParamsDetail:pn,formulaHelpFunctionActive:Sn,formulaHelpDecorator:_n};function vn(){const[i,e]=x.useState(!1),[t,n]=x.useState(!0),[r,o]=x.useState(!0),[s,c]=x.useState(0),[l,u]=x.useState([0,0]),[f,g]=x.useState({left:0,top:0}),[m,p]=x.useState(null),_=k.useDependency(J),I=k.useDependency(L.ICellEditorManagerService),d=k.useDependency(a.LocaleService),v=k.useDependency(L.IFormulaEditorManagerService),S=k.useDependency(a.IContextService),C=d.t("formula.prompt.required"),T=d.t("formula.prompt.optional");x.useEffect(()=>{const M=_.help$.subscribe(b=>{const{visible:D,paramIndex:U,functionInfo:N}=b;if(!D){e(D);return}const A=S.getContextValue(a.FOCUSING_FORMULA_EDITOR)?v.getPosition():I.getRect();if(A==null)return;const{left:W,top:$,height:z}=A,ee={functionName:N.functionName,functionType:N.functionType,description:d.t(N.description),abstract:d.t(N.abstract),functionParameter:N.functionParameter.map(Y=>({name:d.t(Y.name),detail:d.t(Y.detail),example:Y.example,require:Y.require,repeat:Y.repeat}))};u([W,$+z]),c(U),p(ee),g({left:W,top:$}),e(D)});return()=>{M==null||M.unsubscribe()}},[]);function F(M){c(M)}return R.jsx(R.Fragment,{children:r?R.jsx(Q.Popup,{visible:i,offset:l,children:m?R.jsxs("div",{className:B.formulaHelpFunction,children:[R.jsxs("div",{className:B.formulaHelpFunctionTitle,children:[R.jsx(Rn,{prefix:m.functionName,value:m.functionParameter,active:s,onClick:F}),R.jsxs("div",{className:B.formulaHelpFunctionTitleIcons,children:[R.jsx("div",{className:B.formulaHelpFunctionTitleIcon,style:{transform:t?"rotateZ(-90deg)":"rotateZ(90deg)"},onClick:()=>n(!t),children:R.jsx(an,{})}),R.jsx("div",{className:B.formulaHelpFunctionTitleIcon,onClick:()=>o(!r),children:R.jsx(nn,{})})]})]}),R.jsx("div",{className:B.formulaHelpFunctionContent,style:{height:t?"unset":0,padding:t?"revert-layer":0},children:R.jsxs("div",{className:B.formulaHelpFunctionContentInner,children:[R.jsx(Ne,{title:d.t("formula.prompt.helpExample"),value:`${m.functionName}(${m.functionParameter.map(M=>M.example).join(",")})`}),R.jsx(Ne,{title:d.t("formula.prompt.helpAbstract"),value:m.description}),m&&m.functionParameter&&m.functionParameter.map((M,b)=>R.jsx(Ne,{className:s===b?B.formulaHelpFunctionActive:"",title:M.name,value:`${M.require?C:T} ${M.detail}`},b))]})})]}):R.jsx(R.Fragment,{})}):i?R.jsx("div",{className:B.formulaHelpDecorator,onClick:()=>o(!r),style:{left:f.left-24,top:f.top},children:R.jsx(on,{})}):R.jsx(R.Fragment,{})})}const Ne=i=>R.jsxs("div",{className:B.formulaHelpFunctionContentParams,children:[R.jsx("div",{className:`${B.formulaHelpFunctionContentParamsTitle} ${i.className}`,children:i.title}),R.jsx("div",{className:B.formulaHelpFunctionContentParamsDetail,children:i.value})]}),Rn=i=>{const{prefix:e,value:t,active:n,onClick:r}=i;return R.jsxs("div",{children:[R.jsxs("span",{children:[e,"("]}),t&&t.map((o,s)=>R.jsxs("span",{children:[R.jsx("span",{className:n===s?B.formulaHelpFunctionActive:"",onClick:()=>r(s),children:o.repeat?`[${o.name},...]`:o.name}),s===t.length-1?"":","]},s)),")"]})},In="univer-formula-search-function",Cn="univer-formula-search-function-item",yn="univer-formula-search-function-item-name",Mn="univer-formula-search-function-item-name-light",bn="univer-formula-search-function-item-desc",Fn="univer-formula-search-function-item-active",X={formulaSearchFunction:In,formulaSearchFunctionItem:Cn,formulaSearchFunctionItemName:yn,formulaSearchFunctionItemNameLight:Mn,formulaSearchFunctionItemDesc:bn,formulaSearchFunctionItemActive:Fn};function Nn(){const[i,e]=x.useState(!1),[t,n]=x.useState(0),[r,o]=x.useState([0,0]),[s,c]=x.useState([]),[l,u]=x.useState(""),f=k.useDependency(J),g=k.useDependency(L.ICellEditorManagerService),m=k.useDependency(L.IFormulaEditorManagerService),p=k.useDependency(a.IContextService);x.useEffect(()=>{let d=[],v=0;const S=f.search$.subscribe(F=>{const{visible:M,searchText:b,searchList:D}=F;if(!M){e(M);return}const N=p.getContextValue(a.FOCUSING_FORMULA_EDITOR)?m.getPosition():g.getRect();if(N==null)return;const{left:P,top:A,height:W}=N;u(b),c(D),d=D,o([P,A+W]),e(M),n(0),v=0}),C=f.navigate$.subscribe(F=>{const{direction:M}=F;if(M===a.Direction.UP){let b=v-1;b=b<0?d.length-1:b,n(b),v=b}else if(M===a.Direction.DOWN){let b=v+1;b=b>=d.length?0:b,n(b),v=b}}),T=f.accept$.subscribe(F=>{const M=d[v].name;f.acceptFormulaName(M)});return()=>{S==null||S.unsubscribe(),C==null||C.unsubscribe(),T==null||T.unsubscribe()}},[]);function _(d){n(d)}function I(){n(-1)}return R.jsx(Q.Popup,{visible:i,offset:r,children:R.jsx("ul",{className:X.formulaSearchFunction,children:s.map((d,v)=>R.jsxs("li",{className:t===v?`${X.formulaSearchFunctionItem} ${X.formulaSearchFunctionItemActive}`:X.formulaSearchFunctionItem,onMouseEnter:()=>_(v),onMouseLeave:I,onClick:()=>f.acceptFormulaName(d.name),children:[R.jsxs("span",{className:X.formulaSearchFunctionItemName,children:[R.jsx("span",{className:X.formulaSearchFunctionItemNameLight,children:l}),R.jsx("span",{children:d.name.slice(l.length)})]}),R.jsx("span",{className:X.formulaSearchFunctionItemDesc,children:d.desc})]},v))})})}function Tn(){return R.jsxs(R.Fragment,{children:[R.jsx(Nn,{}),R.jsx(vn,{}),R.jsx(zt,{})]})}const wn="univer-formula-more-functions",xn="univer-formula-more-functions-operation",Be={formulaMoreFunctions:wn,formulaMoreFunctionsOperation:xn};function st(i){const{prefix:e,value:t}=i;return R.jsxs("div",{children:[R.jsxs("span",{children:[e,"("]}),t&&t.map((n,r)=>R.jsxs("span",{children:[R.jsx("span",{children:n.repeat?`[${n.name},...]`:n.name}),r===t.length-1?"":","]},r)),")"]})}const En="univer-formula-function-params",On="univer-formula-function-params-title",Dn="univer-formula-function-params-detail",Te={formulaFunctionParams:En,formulaFunctionParamsTitle:On,formulaFunctionParamsDetail:Dn};function oe(i){const{className:e,value:t,title:n}=i;return R.jsxs("div",{className:Te.formulaFunctionParams,children:[R.jsx("div",{className:`${Te.formulaFunctionParamsTitle} ${e}`,children:n}),R.jsx("div",{className:Te.formulaFunctionParamsDetail,children:t})]})}const Ln="univer-formula-input-params-list",An="univer-formula-input-params-list-item-name",Pn="univer-formula-input-params-list-item-selector",ie={formulaInputParamsList:Ln,formulaInputParamsListItemName:An,formulaInputParamsListItemSelector:Pn};function Un(i){const{functionInfo:e,onChange:t}=i;if(!e)return null;const[n,r]=x.useState([]),[o,s]=x.useState(e.functionParameter),[c,l]=x.useState(-1);function u(g,m){const p=[...n];p[m]=g,r(p),t(p)}function f(g){if(g===o.length-1&&o[g].repeat){const m=[...o];m.push(o[g]),s(m)}l(g)}return R.jsxs("div",{className:ie.formulaInputParams,children:[R.jsx("div",{className:ie.formulaInputParamsList,children:o.map((g,m)=>R.jsxs("div",{children:[R.jsx("div",{className:ie.formulaInputParamsListItemName,children:g.name}),R.jsx("div",{className:ie.formulaInputParamsListItemSelector,children:R.jsx(L.RangeSelector,{onChange:p=>u(p,m),onActive:()=>f(m)})})]},m))}),R.jsx("div",{className:ie.formulaInputParamsInfo,children:R.jsx(oe,{title:c===-1?R.jsx(st,{prefix:e.functionName,value:o}):o[c].name,value:c===-1?e.description:o[c].detail})})]})}const jn=[],kn=[],$n=[],qn=[],Bn=[],Vn=[],Wn=[],Hn=[],Kn=[],Gn=[],zn=[{functionName:y.FUNCTION_NAMES_MATH.SUM,aliasFunctionName:"formula.functionList.SUM.aliasFunctionName",functionType:y.FunctionType.Math,description:"formula.functionList.SUM.description",abstract:"formula.functionList.SUM.abstract",functionParameter:[{name:"formula.functionList.SUM.functionParameter.number1.name",detail:"formula.functionList.SUM.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.SUM.functionParameter.number2.name",detail:"formula.functionList.SUM.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_MATH.SUMIF,aliasFunctionName:"formula.functionList.SUMIF.aliasFunctionName",functionType:y.FunctionType.Math,description:"formula.functionList.SUMIF.description",abstract:"formula.functionList.SUMIF.abstract",functionParameter:[{name:"formula.functionList.SUMIF.functionParameter.range.name",detail:"formula.functionList.SUMIF.functionParameter.range.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.SUMIF.functionParameter.criteria.name",detail:"formula.functionList.SUMIF.functionParameter.criteria.detail",example:">5",require:1,repeat:0},{name:"formula.functionList.SUMIF.functionParameter.sum_range.name",detail:"formula.functionList.SUMIF.functionParameter.sum_range.detail",example:"B1:B20",require:0,repeat:0}]}],Yn=[{functionName:y.FUNCTION_NAMES_STATISTICAL.AVERAGE,aliasFunctionName:"formula.functionList.AVERAGE.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.AVERAGE.description",abstract:"formula.functionList.AVERAGE.abstract",functionParameter:[{name:"formula.functionList.AVERAGE.functionParameter.number1.name",detail:"formula.functionList.AVERAGE.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.AVERAGE.functionParameter.number2.name",detail:"formula.functionList.AVERAGE.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.MAX,aliasFunctionName:"formula.functionList.MAX.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.MAX.description",abstract:"formula.functionList.MAX.abstract",functionParameter:[{name:"formula.functionList.MAX.functionParameter.number1.name",detail:"formula.functionList.MAX.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.MAX.functionParameter.number2.name",detail:"formula.functionList.MAX.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.COUNT,aliasFunctionName:"formula.functionList.COUNT.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.COUNT.description",abstract:"formula.functionList.COUNT.abstract",functionParameter:[{name:"formula.functionList.COUNT.functionParameter.value1.name",detail:"formula.functionList.COUNT.functionParameter.value1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.COUNT.functionParameter.value2.name",detail:"formula.functionList.COUNT.functionParameter.value2.detail",example:"B2:B10",require:0,repeat:1}]},{functionName:y.FUNCTION_NAMES_STATISTICAL.MIN,aliasFunctionName:"formula.functionList.MIN.aliasFunctionName",functionType:y.FunctionType.Statistical,description:"formula.functionList.MIN.description",abstract:"formula.functionList.MIN.abstract",functionParameter:[{name:"formula.functionList.MIN.functionParameter.number1.name",detail:"formula.functionList.MIN.functionParameter.number1.detail",example:"A1:A20",require:1,repeat:0},{name:"formula.functionList.MIN.functionParameter.number2.name",detail:"formula.functionList.MIN.functionParameter.number2.detail",example:"B2:B10",require:0,repeat:1}]}],Xn=[],Zn=[],Qn=[],Jn=[...Wn,...Bn,...zn,...Yn,...Gn,...qn,...Xn,...Kn,...Hn,...Vn,...$n,...kn,...Qn,...jn,...Zn];function er(i,e){return Object.keys(i).filter(t=>isNaN(Number(t))).map(t=>({label:e.t(`formula.functionType.${t.toLocaleLowerCase()}`),value:`${i[t]}`}))}function tr(i,e){let t="";return i.aliasFunctionName?(t=e.t(i.aliasFunctionName),t===i.aliasFunctionName&&(t=i.functionName)):t=i.functionName,t}var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ir=(i,e,t,n)=>{for(var r=n>1?void 0:n?rr(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&nr(e,t,r),r},Ve=(i,e)=>(t,n)=>e(t,n,i);const je=O.createIdentifier("formula-ui.description-service");let Le=class{constructor(i,e,t){this._description=i,this._functionService=e,this._localeService=t,this._initialize(),this._registerDescription()}dispose(){this._localeService.localeChanged$.complete()}getDescriptions(){return this._functionService.getDescriptions()}hasFunction(i){return this._functionService.getDescriptions().get(i.toLocaleUpperCase())!==void 0}getFunctionInfo(i){return this._functionService.getDescriptions().get(i.toLocaleUpperCase())}getSearchListByName(i){const e=[],t=this._functionService.getDescriptions();return i=i.toLocaleUpperCase(),t.forEach(n=>{const{functionName:r,abstract:o}=n;r.indexOf(i)>-1&&e.push({name:r,desc:o})}),e}getSearchListByType(i){const e=[];return this._functionService.getDescriptions().forEach(n=>{const{functionName:r,functionType:o,abstract:s}=n;(o===i||i===-1)&&e.push({name:r,desc:s})}),e}_initialize(){this._localeService.localeChanged$.subscribe(()=>{this._registerDescription()})}_registerDescription(){const i=this._localeService,t=Jn.concat(this._description||[]).map(n=>({functionName:tr(n,i),functionType:n.functionType,description:i.t(n.description),abstract:i.t(n.abstract),functionParameter:n.functionParameter.map(r=>({name:i.t(r.name),detail:i.t(r.detail),example:r.example,require:r.require,repeat:r.repeat}))}));this._functionService.registerDescriptions(...t)}};Le=ir([Ve(1,y.IFunctionService),Ve(2,O.Inject(a.LocaleService))],Le);const or="univer-formula-select-function-select",sr="univer-formula-select-function-result",ar="univer-formula-select-function-result-item",cr="univer-formula-select-function-result-item-name-light",lr="univer-formula-select-function-result-item-selected",ur="univer-formula-select-function-result-item-active",dr="univer-formula-select-function-content",H={formulaSelectFunctionSelect:or,formulaSelectFunctionResult:sr,formulaSelectFunctionResultItem:ar,formulaSelectFunctionResultItemNameLight:cr,formulaSelectFunctionResultItemSelected:lr,formulaSelectFunctionResultItemActive:ur,formulaSelectFunctionContent:dr};function mr(i){const{onChange:e}=i,t="-1",[n,r]=x.useState(""),[o,s]=x.useState([]),[c,l]=x.useState(0),[u,f]=x.useState(t),[g,m]=x.useState(0),[p,_]=x.useState(null),I=k.useDependency(je),d=k.useDependency(a.LocaleService),v=er(y.FunctionType,d);v.unshift({label:d.t("formula.moreFunctions.allFunctions"),value:t});const S=d.t("formula.prompt.required"),C=d.t("formula.prompt.optional");x.useEffect(()=>{M(t)},[]),x.useEffect(()=>{F(0)},[o]);const T=P=>{const A=new RegExp(`(${n.toLocaleUpperCase()})`);return P.split(A).filter(Boolean).map(($,z)=>$.match(A)?R.jsx("span",{className:H.formulaSelectFunctionResultItemNameLight,children:$},z):$)},F=P=>{if(o.length===0){_(null);return}m(P);const A=I.getFunctionInfo(o[P].name);if(!A){_(null);return}_(A),e(A)};function M(P){f(P);const A=I.getSearchListByType(+P);s(A)}function b(P){r(P);const A=I.getSearchListByName(P);s(A)}function D(P){if(P.stopPropagation(),P.key==="ArrowDown"){const A=c+1;l(A===o.length?0:A)}else if(P.key==="ArrowUp"){const A=c-1;l(A===-1?o.length-1:A)}else P.key==="Enter"&&F(c)}const U=P=>{l(P)},N=()=>{l(-1)};return R.jsxs("div",{children:[R.jsxs("div",{className:H.formulaSelectFunctionSelect,children:[R.jsx(Q.Select,{value:u,options:v,onChange:M}),R.jsx(Q.Input,{placeholder:d.t("formula.moreFunctions.searchFunctionPlaceholder"),onKeyDown:D,value:n,onChange:b,size:"large",allowClear:!0})]}),R.jsx("ul",{className:H.formulaSelectFunctionResult,onKeyDown:D,tabIndex:-1,children:o.map(({name:P},A)=>R.jsxs("li",{className:c===A?`${H.formulaSelectFunctionResultItem} ${H.formulaSelectFunctionResultItemActive}`:H.formulaSelectFunctionResultItem,onMouseEnter:()=>U(A),onMouseLeave:N,onClick:()=>F(A),children:[g===A&&R.jsx(en,{className:H.formulaSelectFunctionResultItemSelected}),R.jsx("span",{className:H.formulaSelectFunctionResultItemName,children:T(P)})]},A))}),p&&R.jsxs("div",{className:H.formulaSelectFunctionContent,children:[R.jsx(oe,{title:p.functionName,value:p.description}),R.jsx(oe,{title:d.t("formula.moreFunctions.syntax"),value:R.jsx(st,{prefix:p.functionName,value:p.functionParameter})}),R.jsx(oe,{title:d.t("formula.prompt.helpExample"),value:`${p.functionName}(${p.functionParameter.map(P=>P.example).join(",")})`}),p.functionParameter&&p.functionParameter.map((P,A)=>R.jsx(oe,{title:P.name,value:`${P.require?S:C} ${P.detail}`},A))]})]})}function fr(){const[i,e]=x.useState(!0),[t,n]=x.useState(!1),[r,o]=x.useState([]),[s,c]=x.useState(null),l=k.useDependency(a.LocaleService);k.useDependency(E.ISidebarService);const u=k.useDependency(se);function f(){e(!i),n(!t)}function g(){u.inputFormula(`=${s==null?void 0:s.functionName}(`)}return R.jsxs("div",{className:Be.formulaMoreFunctions,children:[i&&R.jsx(mr,{onChange:c}),t&&R.jsx(Un,{functionInfo:s,onChange:o}),R.jsxs("div",{className:Be.formulaMoreFunctionsOperation,children:[t&&R.jsx(Q.Button,{type:"primary",onClick:f,children:l.t("formula.moreFunctions.next")}),t&&R.jsx(Q.Button,{onClick:f,children:l.t("formula.moreFunctions.prev")}),i&&R.jsx(Q.Button,{type:"primary",onClick:g,children:l.t("formula.moreFunctions.confirm")})]})]})}function hr(i){return{id:Ue.id,icon:"FunctionSingle",tooltip:"formula.insert.tooltip",group:E.MenuGroup.TOOLBAR_FORMULAS_INSERT,type:E.MenuItemType.SELECTOR,positions:[E.MenuPosition.TOOLBAR_START],selections:[{label:"SUM",value:"SUM",icon:"SumSingle"},{label:"AVERAGE",value:"AVERAGE",icon:"AvgSingle"},{label:"COUNT",value:"COUNT",icon:"CntSingle"},{label:"MAX",value:"MAX",icon:"MaxSingle"},{label:"MIN",value:"MIN",icon:"MinSingle"}]}}function gr(i){return{id:Qe.id,title:"formula.insert.more",positions:Ue.id,type:E.MenuItemType.BUTTON}}function pr(i){return{id:Ye.id,type:E.MenuItemType.BUTTON,title:"formula.operation.pasteFormula",positions:[L.PASTE_SPECIAL_MENU_ID]}}const at="meta_key_ctrl_And_Shift",Me=[E.KeyCode.ARROW_DOWN,E.KeyCode.ARROW_UP,E.KeyCode.ARROW_LEFT,E.KeyCode.ARROW_RIGHT],Sr=[...Me,E.KeyCode.ENTER,E.KeyCode.TAB];function _r(){const i=[];for(const e of Sr)i.push({id:re.id,binding:e,preconditions:t=>L.whenEditorInputFormulaActivated(t),staticParameters:{eventType:q.DeviceInputEventType.Keyboard,keycode:e}});return i}function vr(){const i=[];for(const e of Me)i.push({id:re.id,binding:e|E.MetaKeys.SHIFT,preconditions:t=>L.whenEditorInputFormulaActivated(t),staticParameters:{eventType:q.DeviceInputEventType.Keyboard,keycode:e,metaKey:E.MetaKeys.SHIFT}});return i}function Rr(){const i=[];for(const e of Me)i.push({id:re.id,binding:e|E.MetaKeys.CTRL_COMMAND,preconditions:t=>L.whenEditorInputFormulaActivated(t),staticParameters:{eventType:q.DeviceInputEventType.Keyboard,keycode:e,metaKey:E.MetaKeys.CTRL_COMMAND}});return i}function Ir(){const i=[];for(const e of Me)i.push({id:re.id,binding:e|E.MetaKeys.SHIFT|E.MetaKeys.CTRL_COMMAND,preconditions:t=>L.whenEditorInputFormulaActivated(t),staticParameters:{eventType:q.DeviceInputEventType.Keyboard,keycode:e,metaKey:at}});return i}const Cr={id:Pe.id,binding:E.KeyCode.F4,preconditions:i=>L.whenEditorInputFormulaActivated(i)};var yr=Object.defineProperty,Mr=Object.getOwnPropertyDescriptor,br=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mr(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&yr(e,t,r),r},ne=(i,e)=>(t,n)=>e(t,n,i);let Se=class extends a.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._menuService=e,this._commandService=t,this._shortcutService=n,this._uiController=r,this._componentManager=o,this._initialize()}_initialize(){this._registerCommands(),this._registerMenus(),this._registerShortcuts(),this._registerComponents()}_registerMenus(){[hr,gr,pr].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_registerCommands(){[Xe,Ye,Ue,Qe,De,Oe,re,Pe].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_registerShortcuts(){[..._r(),...vr(),...Rr(),...Ir(),Cr].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_registerComponents(){this.disposeWithMe(this._uiController.registerContentComponent(()=>k.connectInjector(Tn,this._injector))),this._componentManager.register(Ze,fr)}};Se=br([a.OnLifecycle(a.LifecycleStages.Ready,Se),ne(0,O.Inject(O.Injector)),ne(1,E.IMenuService),ne(2,a.ICommandService),ne(3,E.IShortcutService),ne(4,E.IUIController),ne(5,O.Inject(E.ComponentManager))],Se);const We="formula_reference_selection_plugin_name";function we(i,e,t){const n=i.getCurrentTheme(),r=new Ke.TinyColor(e).setAlpha(.05).toString();return{id:t,strokeWidth:2,stroke:e,fill:r,widgets:{tl:!0,tc:!0,tr:!0,ml:!0,mr:!0,bl:!0,bc:!0,br:!0},widgetSize:6,widgetStrokeWidth:1,widgetStroke:n.colorWhite,hasAutoFill:!1,hasRowHeader:!1,hasColumnHeader:!1}}var Fr=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,Tr=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nr(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Fr(e,t,r),r},j=(i,e)=>(t,n)=>e(t,n,i);let _e=class extends a.Disposable{constructor(e,t,n,r,o,s,c,l,u,f,g,m,p,_,I,d,v){super();w(this,"_formulaRefColors",[]);w(this,"_previousSequenceNodes");w(this,"_previousRangesCount",0);w(this,"_previousInsertRefStringIndex");w(this,"_currentInsertRefStringIndex",-1);w(this,"_currentUnitId");w(this,"_currentSheetId");w(this,"_arrowMoveActionState",0);w(this,"_isSelectionMovingRefSelections",[]);w(this,"_stringColor","");w(this,"_numberColor","");w(this,"_insertSelections",[]);w(this,"_inputPanelState",0);this._commandService=e,this._localeService=t,this._contextService=n,this._textSelectionRenderManager=r,this._editorBridgeService=o,this._formulaPromptService=s,this._lexerTreeBuilder=c,this._renderManagerService=l,this._themeService=u,this._selectionManagerService=f,this._sheetSkeletonManagerService=g,this._currentUniverService=m,this._selectionRenderService=p,this._descriptionService=_,this._textSelectionManagerService=I,this._formulaInputService=d,this._docViewModelManagerService=v,this._initialize()}dispose(){this._formulaRefColors=[],this._resetTemp()}_resetTemp(){this._previousSequenceNodes=null,this._previousInsertRefStringIndex=null,this._currentUnitId=null,this._currentSheetId=null,this._isSelectionMovingRefSelections=[],this._previousRangesCount=0,this._currentInsertRefStringIndex=-1}_initialize(){this._initialCursorSync(),this._initAcceptFormula(),this._initialFormulaTheme(),this._initialRefSelectionUpdateEvent(),this._initialRefSelectionInsertEvent(),this._initialExitEditor(),this._initialEditorInputChange(),this._commandExecutedListener(),this._cursorStateListener(),this._syncEditorListener()}_initialFormulaTheme(){const e=this._themeService.getCurrentTheme();this._formulaRefColors=[e.loopColor1,e.loopColor2,e.loopColor3,e.loopColor4,e.loopColor5,e.loopColor6,e.loopColor7,e.loopColor8,e.loopColor9,e.loopColor10,e.loopColor11,e.loopColor12],this._numberColor=e.hyacinth700,this._stringColor=e.verdancy800}_initialCursorSync(){this.disposeWithMe(a.toDisposable(this._textSelectionRenderManager.textSelection$.subscribe(()=>{if(this._editorBridgeService.isVisible().visible===!1||this._formulaInputService.isSelectionMoving())return;const e=this._getCurrentBody(),t=(e==null?void 0:e.dataStream)||"";this._contextSwitch(t),this._changeKeepVisibleHideState(),this._switchSelectionPlugin(),!this._formulaInputService.isLockedSelectionChange()&&(this._highlightFormula(),this._changeFunctionPanelState())})))}_initialEditorInputChange(){this.disposeWithMe(a.toDisposable(this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{this._previousSequenceNodes=null,this._previousInsertRefStringIndex=null,this._selectionRenderService.enableSkipRemainLast();const t=e==null?void 0:e.event;t!=null&&([E.KeyCode.ARROW_DOWN,E.KeyCode.ARROW_UP,E.KeyCode.ARROW_LEFT,E.KeyCode.ARROW_RIGHT].includes(t.which)?this._inputPanelState=2:(this._arrowMoveActionState!==1&&(this._arrowMoveActionState=2),this._inputPanelState=1))})))}_initialExitEditor(){this.disposeWithMe(a.toDisposable(this._editorBridgeService.afterVisible$.subscribe(e=>{if(e.visible===!0){const{unitId:n,sheetId:r}=this._getCurrentUnitIdAndSheetId();this._currentUnitId==null&&(this._currentUnitId=n),this._currentSheetId==null&&(this._currentSheetId=r);return}const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)===h.NORMAL_SELECTION_PLUGIN_NAME){this._disableForceKeepVisible();return}this._selectionManagerService.clear(),this._selectionManagerService.changePlugin(h.NORMAL_SELECTION_PLUGIN_NAME),this._updateEditorModel(`\r
|
|
10
|
+
`,[]),this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._disableForceKeepVisible(),this._selectionRenderService.resetStyle(),this._resetTemp(),this._hideFunctionPanel()})))}_initialRefSelectionUpdateEvent(){const e=new a.DisposableCollection;this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if(this._formulaInputService.disableSelectionMoving(),(t==null?void 0:t.pluginName)!==We)return;this._updateRefSelectionStyle(this._isSelectionMovingRefSelections),this._selectionRenderService.getCurrentControls().forEach(r=>{r.disableHelperSelection(),e.add(a.toDisposable(r.selectionMoving$.subscribe(o=>{this._changeControlSelection(o,r)}))),e.add(a.toDisposable(r.selectionScaling$.subscribe(o=>{this._changeControlSelection(o,r)}))),e.add(a.toDisposable(r.selectionMoved$.subscribe(()=>{this._formulaInputService.disableLockedSelectionChange()}))),e.add(a.toDisposable(r.selectionScaled$.subscribe(()=>{this._formulaInputService.disableLockedSelectionChange()})))})})))}_syncEditorListener(){this.disposeWithMe(a.toDisposable(this._formulaInputService.syncToEditor$.subscribe(e=>{const{sequences:t,textSelectionOffset:n}=e;this._syncToEditor(t,n)})))}_selectionChanging(e,t=!1){if(e.length===0||!this._formulaInputService.isLockedSelectionInsert()||(this._formulaInputService.enableSelectionMoving(),this._inertControlSelection(e),t===!1))return;const n=e[e.length-1];this._inertControlSelectionReplace(n)}_initialRefSelectionInsertEvent(){this.disposeWithMe(a.toDisposable(this._selectionRenderService.selectionMoving$.subscribe(e=>{this._selectionChanging(e.map(t=>h.convertSelectionDataToRange(t)))}))),this.disposeWithMe(a.toDisposable(this._selectionRenderService.selectionMoveStart$.subscribe(e=>{this._selectionChanging(e.map(t=>h.convertSelectionDataToRange(t)),!0)})))}_initAcceptFormula(){this.disposeWithMe(a.toDisposable(this._formulaPromptService.acceptFormulaName$.subscribe(e=>{const t=this._textSelectionRenderManager.getActiveRange();if(t==null){this._hideFunctionPanel();return}const{startOffset:n}=t,r=this._formulaInputService.getSequenceNodes(),o=this._formulaInputService.getCurrentSequenceNodeIndex(n-2),s=r[o];if(s==null||typeof s=="string"){this._hideFunctionPanel();return}const c=e.length-s.token.length,l={...s};l.token=e,l.endIndex+=c,r[o]=l,r.splice(o+1,0,y.matchToken.OPEN_BRACKET);const u=e.length+1;for(let f=o+2,g=r.length;f<g;f++){const m=r[f];if(typeof m=="string")continue;const p={...m};p.startIndex+=u,p.endIndex+=u,r[f]=p}this._syncToEditor(r,l.endIndex+2)})))}_changeFunctionPanelState(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null){this._hideFunctionPanel();return}const{startOffset:t}=e,n=this._formulaInputService.getCurrentSequenceNode(t-2);if(n==null){this._hideFunctionPanel();return}if(typeof n!="string"&&n.nodeType===y.sequenceNodeType.FUNCTION){const u=n.token.toUpperCase();if(this._inputPanelState===1){const f=this._descriptionService.getSearchListByName(u);if(this._hideFunctionPanel(),f==null||f.length===0)return;this._commandService.executeCommand(De.id,{visible:!0,searchText:u,searchList:f})}else this._descriptionService.hasFunction(u)&&this._changeHelpFunctionPanelState(u,-1);return}const r=this._getCurrentBody(),o=(r==null?void 0:r.dataStream)||"",s=this._lexerTreeBuilder.getFunctionAndParameter(o,t-1);if(s==null){this._hideFunctionPanel();return}const{functionName:c,paramIndex:l}=s;this._changeHelpFunctionPanelState(c.toUpperCase(),l)}_changeHelpFunctionPanelState(e,t){const n=this._descriptionService.getFunctionInfo(e);this._hideFunctionPanel(),n!=null&&this._commandService.executeCommand(Oe.id,{visible:!0,paramIndex:t,functionInfo:n})}_hideFunctionPanel(){this._commandService.executeCommand(De.id,{visible:!1,searchText:""}),this._commandService.executeCommand(Oe.id,{visible:!1,paramIndex:-1})}_changeKeepVisibleHideState(){if(this._getContextState()===!1){this._disableForceKeepVisible();return}const e=this._getCurrentChar();if(e==null){this._disableForceKeepVisible();return}this._matchRefDrawToken(e)?(this._editorBridgeService.enableForceKeepVisible(),this._formulaInputService.enableLockedSelectionInsert(),this._selectionRenderService.enableRemainLast(),this._arrowMoveActionState!==1&&(this._arrowMoveActionState=2)):this._disableForceKeepVisible()}_matchRefDrawToken(e){return y.isFormulaLexerToken(e)&&e!==y.matchToken.CLOSE_BRACES&&e!==y.matchToken.CLOSE_BRACKET&&e!==y.matchToken.SINGLE_QUOTATION&&e!==y.matchToken.DOUBLE_QUOTATION||e===" "}_getCurrentChar(){const e=this._textSelectionRenderManager.getActiveRange();if(e==null)return;const{startOffset:t}=e,n=this._getCurrentBody();return n==null||t==null?void 0:n.dataStream[t-1]}_disableForceKeepVisible(){this._editorBridgeService.disableForceKeepVisible(),this._formulaInputService.disableLockedSelectionInsert(),this._currentInsertRefStringIndex=-1,this._selectionRenderService.disableRemainLast(),this._arrowMoveActionState===2&&(this._arrowMoveActionState=4)}_getCurrentBody(){var n;const e=this._editorBridgeService.getCurrentEditorId();if(e==null)return;const t=this._currentUniverService.getUniverDocInstance(e);return(n=t==null?void 0:t.snapshot)==null?void 0:n.body}_getFormulaAndCellEditorBody(){return[a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY].map(t=>{const n=this._currentUniverService.getUniverDocInstance(t);return n==null?void 0:n.getBody()})}_contextSwitch(e){if(a.isFormulaString(e)){this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!0);const t=this._lexerTreeBuilder.sequenceNodesBuilder(e.replace(/\r/g,"").replace(/\n/g,""))||[];this._formulaInputService.setSequenceNodes(t);const n=this._textSelectionRenderManager.getActiveRange();if(n==null)return;const{startOffset:r}=n;this._currentInsertRefStringIndex=r-1}else this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._formulaInputService.disableLockedSelectionChange(),this._formulaInputService.disableLockedSelectionInsert(),this._formulaInputService.clearSequenceNodes(),this._hideFunctionPanel()}_getContextState(){return this._contextService.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)}_switchSelectionPlugin(){if(this._getContextState()===!0){this._selectionManagerService.changePluginNoRefresh(We);const e=h.getNormalSelectionStyle(this._themeService);e.strokeDash=8,e.hasAutoFill=!1,e.hasRowHeader=!1,e.hasColumnHeader=!1,this._selectionRenderService.setStyle(e)}else this._selectionManagerService.changePluginNoRefresh(h.NORMAL_SELECTION_PLUGIN_NAME),this._selectionRenderService.resetStyle()}_highlightFormula(){if(this._getContextState()===!1)return;const e=this._formulaInputService.getSequenceNodes(),t=this._getFormulaAndCellEditorBody().filter(n=>!!n);if(this._selectionManagerService.clear(),e==null||e.length===0)t.forEach(n=>n.textRuns=[]);else{const{textRuns:n,refSelections:r}=this._buildTextRuns(e);t.forEach(o=>o.textRuns=n),this._refreshSelectionForReference(r)}this._refreshFormulaAndCellEditor()}_buildTextRuns(e){const t=[],n=[];let r=0;for(let o=0,s=e.length;o<s;o++){const c=e[o];if(typeof c=="string")continue;const{startIndex:l,endIndex:u,nodeType:f,token:g}=c;let m="";if(f===y.sequenceNodeType.REFERENCE){const p=r%this._formulaRefColors.length;m=this._formulaRefColors[p],n.push({refIndex:o,themeColor:m,token:g}),r++}else f===y.sequenceNodeType.NUMBER?m=this._numberColor:f===y.sequenceNodeType.STRING?m=this._stringColor:f===y.sequenceNodeType.ARRAY&&(m=this._stringColor);m&&m.length>0&&t.push({st:l+1,ed:u+2,ts:{cl:{rgb:m}}})}return{textRuns:t,refSelections:n}}_refreshSelectionForReference(e){var l;const{unitId:t,sheetId:n}=this._getCurrentUnitIdAndSheetId(),r=[],o=this._currentUniverService.getUniverSheetInstance(t);if((o==null?void 0:o.getSheetBySheetId(n))==null)return;let c=null;for(let u=0,f=e.length;u<f;u++){const g=e[u],{themeColor:m,token:p,refIndex:_}=g,I=a.deserializeRangeWithSheet(p),{unitId:d,sheetName:v,range:S}=I;if(d!=null&&d.length>0&&t!==d)continue;const C=this._getSheetIdByName(t,v.trim());if(v.length!==0&&C!==n)continue;const T=(l=this._insertSelections.find(F=>{const{startRow:M,startColumn:b,endRow:D,endColumn:U}=F.range;return M===S.startRow&&b===S.startColumn&&D===S.endRow&&U===S.endColumn||M===S.startRow&&b===S.startColumn&&S.startRow===S.endRow&&S.startColumn===S.endColumn}))==null?void 0:l.primary;if(T!=null){const{isMerged:F,isMergedMainCell:M,startRow:b,endRow:D,startColumn:U,endColumn:N}=T;(F||M)&&b===S.startRow&&U===S.startColumn&&S.startRow===S.endRow&&S.startColumn===S.endColumn&&(S.endRow=D,S.endColumn=N),c={range:S,primary:T,style:we(this._themeService,m,_.toString())};continue}r.push({range:S,primary:T,style:we(this._themeService,m,_.toString())})}c&&r.push(c),r.length!==0&&this._selectionManagerService.add(r)}_getSheetIdByName(e,t){var r;const n=this._currentUniverService.getUniverSheetInstance(e);return(r=n==null?void 0:n.getSheetBySheetName(y.normalizeSheetName(t)))==null?void 0:r.getSheetId()}_getSheetNameById(e,t){var o;const n=this._currentUniverService.getUniverSheetInstance(e);let r=((o=n==null?void 0:n.getSheetBySheetId(t))==null?void 0:o.getName())||"";return r.length>0&&y.includeFormulaLexerToken(r)&&(r=`'${r}'`),r}_getCurrentUnitIdAndSheetId(){const e=this._sheetSkeletonManagerService.getCurrent();if(e==null){const o=this._currentUniverService.getCurrentUniverSheetInstance(),s=o.getActiveSheet();return{unitId:o.getUnitId(),sheetId:s.getSheetId()}}const{unitId:t,sheetId:n,skeleton:r}=e;return{unitId:t,sheetId:n,skeleton:r}}_getRefString(e){const{unitId:t,sheetId:n}=this._getCurrentUnitIdAndSheetId();let r="",o="";t===this._currentUnitId?r="":r=t,n===this._currentSheetId?o="":o=this._getSheetNameById(t,n);const{range:s,primary:c}=e;let{startRow:l,endRow:u,startColumn:f,endColumn:g}=s;if(c){const{isMerged:m,isMergedMainCell:p,startRow:_,endRow:I,startColumn:d,endColumn:v}=c;(m||p)&&_===l&&d===f&&I===u&&v===g&&(l=_,f=d,u=_,g=d)}return a.serializeRangeToRefString({sheetName:o,unitId:r,range:{startRow:l,endRow:u,startColumn:f,endColumn:g}})}async _syncToEditor(e,t,n=!0){const r=y.generateStringWithSequence(e),{textRuns:o,refSelections:s}=this._buildTextRuns(e);this._isSelectionMovingRefSelections=s;const c=this._textSelectionManagerService.getLast();if(c==null)return;const{collapsed:l,style:u}=c;this._currentInsertRefStringIndex=t,await this._fitEditorSize(),n?this._commandService.executeCommand(Ie.ReplaceContentCommand.id,{unitId:this._editorBridgeService.getCurrentEditorId(),body:{dataStream:`=${r}`,textRuns:o},textRanges:[{startOffset:t+1,endOffset:t+1,collapsed:l,style:u}],segmentId:null}):(this._updateEditorModel(`=${r}\r
|
|
11
|
+
`,o),this._textSelectionManagerService.replaceTextRanges([{startOffset:t+1,endOffset:t+1,collapsed:l,style:u}]))}async _fitEditorSize(){const e=this._editorBridgeService.getCurrentEditorId();e!=null&&await this._commandService.syncExecuteCommand(L.SetEditorResizeOperation.id,{unitId:e})}_updateEditorModel(e,t){const n=this._editorBridgeService.getCurrentEditorId();if(n==null)return;const r=this._currentUniverService.getUniverDocInstance(n),o=this._docViewModelManagerService.getViewModel(n);if(o==null||r==null)return;const s=r==null?void 0:r.getSnapshot();if(s==null)return;const c={dataStream:e,textRuns:t};s.body=c,o.reset(r)}_inertControlSelectionReplace(e){this._previousSequenceNodes==null&&(this._previousSequenceNodes=this._formulaInputService.getSequenceNodes()),this._previousInsertRefStringIndex==null&&(this._previousInsertRefStringIndex=this._currentInsertRefStringIndex);const t=a.Tools.deepClone(this._previousSequenceNodes);if(t==null)return;const n=this._getRefString(e);this._formulaInputService.setSequenceNodes(t),this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex,n),this._syncToEditor(t,this._previousInsertRefStringIndex+n.length);const r=this._selectionRenderService.getSelectionDataWithStyle();this._insertSelections=[],r.forEach(o=>{const s=h.convertSelectionDataToRange(o);this._insertSelections.push(s)})}_inertControlSelection(e){const t=e[e.length-1];if((e.length===this._previousRangesCount||this._previousRangesCount===0)&&this._previousSequenceNodes!=null)this._inertControlSelectionReplace(t);else{let n=this._formulaInputService.getSequenceNodes();if(n==null)return;const r=this._getCurrentChar();if(r==null)return;this._previousInsertRefStringIndex=this._currentInsertRefStringIndex,this._matchRefDrawToken(r)||(this._formulaInputService.insertSequenceString(this._currentInsertRefStringIndex,y.matchToken.COMMA),n=this._formulaInputService.getSequenceNodes(),this._previousInsertRefStringIndex+=1),this._previousSequenceNodes=a.Tools.deepClone(n);const o=this._getRefString(t);this._formulaInputService.setSequenceNodes(n),this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex,o),this._selectionRenderService.disableSkipRemainLast()}this._arrowMoveActionState=2,this._previousRangesCount=e.length}_updateRefSelectionStyle(e){const t=this._selectionRenderService.getCurrentControls(),{unitId:n,sheetId:r}=this._getCurrentUnitIdAndSheetId();for(let o=0,s=e.length;o<s;o++){const c=e[o],{refIndex:l,themeColor:u,token:f}=c,g=a.deserializeRangeWithSheet(f),{unitId:m,sheetName:p,range:_}=g;if(m!=null&&m.length>0&&n!==m)continue;const I=this._getSheetIdByName(n,p.trim());if(I!=null&&I!==r)continue;const d=t.find(S=>{const{startRow:C,startColumn:T,endRow:F,endColumn:M}=S.getRange();return C===_.startRow&&T===_.startColumn&&F===_.endRow&&M===_.endColumn||C===_.startRow&&T===_.startColumn&&_.startRow===_.endRow&&_.startColumn===_.endColumn});if(d==null)continue;const v=we(this._themeService,u,l.toString());d.updateStyle(v)}}_changeControlSelection(e,t){var d;if(!e)return;const{unitId:n,sheetId:r,skeleton:o}=this._getCurrentUnitIdAndSheetId();this._formulaInputService.enableLockedSelectionChange();const s=(d=t.selectionStyle)==null?void 0:d.id;if(s==null||!a.Tools.isStringNumber(s))return;let{startRow:c,endRow:l,startColumn:u,endColumn:f}=e;const g=q.getCellInfoInMergeData(c,u,o==null?void 0:o.mergeData);if(g){const{isMerged:v,isMergedMainCell:S,startRow:C,endRow:T,startColumn:F,endColumn:M}=g;(v||S)&&C===c&&F===u&&T===l&&M===f&&(c=C,u=F,l=C,f=F)}const m=this._getRefString({range:{startRow:c,endRow:l,startColumn:u,endColumn:f},primary:g,style:null}),p=Number(s);this._formulaInputService.updateSequenceRef(p,m);const _=this._formulaInputService.getSequenceNodes(),I=_[p];typeof I!="string"&&(this._syncToEditor(_,I.endIndex+1),t.update(e))}_refreshFormulaAndCellEditor(){var t;const e=[a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY];for(const n of e){const r=L.getEditorObject(n,this._renderManagerService),o=r==null?void 0:r.document;o!=null&&((t=o.getSkeleton())==null||t.calculate(),o.makeDirty())}}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this.disposeWithMe(a.toDisposable(t.onPointerDownObserver.add(()=>{this._arrowMoveActionState=1,this._inputPanelState=3})))}_commandExecutedListener(){const e=[re.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:r,metaKey:o}=n;if(r===E.KeyCode.ENTER){if(this._formulaPromptService.isSearching()){this._formulaPromptService.accept(!0);return}this._editorBridgeService.changeVisible({visible:!1,eventType:q.DeviceInputEventType.Keyboard,keycode:r}),this._commandService.executeCommand(L.MoveSelectionCommand.id,{direction:a.Direction.DOWN});return}if(r===E.KeyCode.TAB){if(this._formulaPromptService.isSearching()){this._formulaPromptService.accept(!0);return}this._editorBridgeService.changeVisible({visible:!1,eventType:q.DeviceInputEventType.Keyboard,keycode:r}),this._commandService.executeCommand(L.MoveSelectionCommand.id,{direction:a.Direction.RIGHT});return}if(this._formulaPromptService.isSearching()){if(r===E.KeyCode.ARROW_DOWN){this._formulaPromptService.navigate({direction:a.Direction.DOWN});return}if(r===E.KeyCode.ARROW_UP){this._formulaPromptService.navigate({direction:a.Direction.UP});return}}if(this._arrowMoveActionState===1){this._moveInEditor(r);return}if(this._arrowMoveActionState===4){this._editorBridgeService.changeVisible({visible:!1,eventType:q.DeviceInputEventType.Keyboard,keycode:r});return}if(this._arrowMoveActionState===2&&(this._arrowMoveActionState=3),(this._selectionManagerService.getSelectionRanges()||[]).length===0){const f=this._selectionManagerService.getLastByPlugin(h.NORMAL_SELECTION_PLUGIN_NAME);if(f!=null){const g=a.Tools.deepClone(f);this._selectionManagerService.add([g])}}let c=a.Direction.DOWN;r===E.KeyCode.ARROW_DOWN?c=a.Direction.DOWN:r===E.KeyCode.ARROW_UP?c=a.Direction.UP:r===E.KeyCode.ARROW_LEFT?c=a.Direction.LEFT:r===E.KeyCode.ARROW_RIGHT&&(c=a.Direction.RIGHT),o===E.MetaKeys.CTRL_COMMAND?this._commandService.executeCommand(L.MoveSelectionCommand.id,{direction:c,jumpOver:L.JumpOver.moveGap}):o===E.MetaKeys.SHIFT?this._commandService.executeCommand(L.ExpandSelectionCommand.id,{direction:c}):o===at?this._commandService.executeCommand(L.ExpandSelectionCommand.id,{direction:c,jumpOver:L.JumpOver.moveGap}):this._commandService.executeCommand(L.MoveSelectionCommand.id,{direction:c});const l=this._selectionManagerService.getSelections()||[],u=l[l.length-1];this._inertControlSelectionReplace(u)}}))}_moveInEditor(e){if(e==null)return;let t=a.Direction.LEFT;e===E.KeyCode.ARROW_DOWN?t=a.Direction.DOWN:e===E.KeyCode.ARROW_UP?t=a.Direction.UP:e===E.KeyCode.ARROW_RIGHT&&(t=a.Direction.RIGHT),this._commandService.executeCommand(Ie.MoveCursorOperation.id,{direction:t})}_getEditorObject(){return L.getEditorObject(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};_e=Tr([a.OnLifecycle(a.LifecycleStages.Steady,_e),j(0,a.ICommandService),j(1,O.Inject(a.LocaleService)),j(2,a.IContextService),j(3,q.ITextSelectionRenderManager),j(4,O.Inject(L.IEditorBridgeService)),j(5,O.Inject(J)),j(6,O.Inject(y.LexerTreeBuilder)),j(7,q.IRenderManagerService),j(8,O.Inject(a.ThemeService)),j(9,O.Inject(h.SelectionManagerService)),j(10,O.Inject(L.SheetSkeletonManagerService)),j(11,a.IUniverInstanceService),j(12,O.Inject(L.ISelectionRenderService)),j(13,O.Inject(je)),j(14,O.Inject(Ie.TextSelectionManagerService)),j(15,se),j(16,O.Inject(Ie.DocViewModelManagerService))],_e);var wr=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,Er=(i,e,t,n)=>{for(var r=n>1?void 0:n?xr(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wr(e,t,r),r},He=(i,e)=>(t,n)=>e(t,n,i);let ve=class extends a.Disposable{constructor(e,t){super();w(this,"_waitingCommandQueue",[]);w(this,"_setTimeoutKey",-1);w(this,"_startExecutionTime",0);this._commandService=e,this._activeDirtyManagerService=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialExecuteFormulaProcessListener(),this._initialExecuteFormula()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{if(this._activeDirtyManagerService.get(e.id)){if(e.id===h.SetRangeValuesMutation.id){const n=e.params;if(t&&t.local===!0||n.trigger===h.SetStyleCommand.id)return}this._waitingCommandQueue.push(e),clearTimeout(this._setTimeoutKey),this._setTimeoutKey=setTimeout(()=>{this._commandService.executeCommand(y.SetFormulaCalculationStartMutation.id,{...this._generateDirty(this._waitingCommandQueue)},{local:!0}),this._startExecutionTime=performance.now()},100)}}))}_generateDirty(e){const t=[],n={},r={};for(const o of e){const s=this._activeDirtyManagerService.get(o.id);if(s==null)continue;const c=s.getDirtyData(o),{dirtyRanges:l,dirtyNameMap:u,dirtyUnitFeatureMap:f}=c;l!=null&&t.push(...l),u!=null&&this._mergeDirtyNameMap(n,u),f!=null&&this._mergeDirtyUnitFeatureMap(r,f)}return{dirtyRanges:t,dirtyNameMap:n,dirtyUnitFeatureMap:r}}_mergeDirtyNameMap(e,t){Object.keys(t).forEach(n=>{e[n]==null&&(e[n]={}),Object.keys(t[n]).forEach(r=>{e[n][r]=t[n][r]})})}_mergeDirtyUnitFeatureMap(e,t){Object.keys(t).forEach(n=>{e[n]==null&&(e[n]={}),Object.keys(t[n]).forEach(r=>{e[n][r]==null&&(e[n][r]={}),Object.keys(t[n][r]).forEach(o=>{e[n][r][o]=t[n][r][o]})})})}_initialExecuteFormulaProcessListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==y.SetFormulaCalculationNotificationMutation.id)return;const t=e.params;if(t.stageInfo!=null){const{totalFormulasToCalculate:n,completedFormulasCount:r,totalArrayFormulasToCalculate:o,completedArrayFormulasCount:s,stage:c}=t.stageInfo;o>0?console.log(`Stage ${c} Array formula.There are ${o} functions to be executed, ${s} complete.`):console.log(`Stage ${c} .There are ${n} functions to be executed, ${r} complete.`)}else{const n=t.functionsExecutedState;let r="";switch(n){case y.FormulaExecutedStateType.NOT_EXECUTED:r="No tasks are being executed anymore";break;case y.FormulaExecutedStateType.STOP_EXECUTION:r="The execution of the formula has been stopped";break;case y.FormulaExecutedStateType.SUCCESS:r=`Formula calculation succeeded, Total time consumed: ${performance.now()-this._startExecutionTime} ms`;break;case y.FormulaExecutedStateType.INITIAL:r="Waiting for calculation";break}console.log(`execution result${r}`)}}))}_initialExecuteFormula(){this._commandService.executeCommand(y.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{local:!0})}};ve=Er([a.OnLifecycle(a.LifecycleStages.Ready,ve),He(0,a.ICommandService),He(1,Ae)],ve);function ue(i,e,t,n,r){const{id:o}=e;if(ct(i,t,n))return i;const s=new a.ObjectMatrix(i[t][n]);switch(o){case h.MoveRangeCommand.id:Or(s,e);break;case h.MoveRowsCommand.id:Dr(s,e,r);break;case h.MoveColsCommand.id:Lr(s,e,r);break;case h.InsertRowCommand.id:Ar(s,e);break;case h.InsertColCommand.id:Pr(s,e);break;case h.InsertRangeMoveRightCommand.id:Ur(s,e);break;case h.InsertRangeMoveDownCommand.id:jr(s,e);break;case h.RemoveRowCommand.id:kr(s,e);break;case h.RemoveColCommand.id:$r(s,e);break;case h.DeleteRangeMoveUpCommand.id:qr(s,e);break;case h.DeleteRangeMoveLeftCommand.id:Br(s,e);break}return i}function Or(i,e){const{params:t}=e;if(!t)return;const{fromRange:n,toRange:r}=t,{startRow:o,endRow:s,startColumn:c,endColumn:l}=n,{startRow:u,endRow:f,startColumn:g,endColumn:m}=r,p=new a.ObjectMatrix;for(let _=o;_<=s;_++)for(let I=c;I<=l;I++){const d=i.getValue(_,I);p.setValue(_-o,I-c,d),i.setValue(_,I,null)}for(let _=u;_<=f;_++)for(let I=g;I<=m;I++){const d=p.getValue(_-u,I-g);i.setValue(_,I,d)}}function Dr(i,e,t){const{params:n}=e;if(!n)return;const{fromRow:r,toRow:o}=n,s=t==null?void 0:t.filter(f=>f.range.rangeType===a.RANGE_TYPE.ROW&&f.range.startRow<=r&&r<=f.range.endRow);if((s==null?void 0:s.length)!==1)return;const c=s[0].range,l=c.startRow,u=c.endRow-c.startRow+1;i.moveRows(l,u,o)}function Lr(i,e,t){const{params:n}=e;if(!n)return;const{fromCol:r,toCol:o}=n,s=t==null?void 0:t.filter(f=>f.range.rangeType===a.RANGE_TYPE.COLUMN&&f.range.startColumn<=r&&r<=f.range.endColumn);if((s==null?void 0:s.length)!==1)return;const c=s[0].range,l=c.startColumn,u=c.endColumn-c.startColumn+1;i.moveColumns(l,u,o)}function Ar(i,e){const{params:t}=e;if(!t)return;const{range:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,[n],r,o,a.Dimension.ROWS)}function Pr(i,e){const{params:t}=e;if(!t)return;const{range:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,[n],r,o,a.Dimension.COLUMNS)}function Ur(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,n,r,o,a.Dimension.COLUMNS)}function jr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleInsertRangeMutation(i,n,r,o,a.Dimension.ROWS)}function kr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,a.Dimension.ROWS)}function $r(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,a.Dimension.COLUMNS)}function qr(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,a.Dimension.ROWS)}function Br(i,e){const{params:t}=e;if(!t)return;const{ranges:n}=t,r=i.getLength()-1,o=i.getRange().endColumn;h.handleDeleteRangeMutation(i,n,r,o,a.Dimension.COLUMNS)}function Vr(i,e,t){if(ct(i,e,t))return i;const n=new a.ObjectMatrix(i[e][t]);return n.forValue((r,o,s)=>{const{startRow:c,startColumn:l,endRow:u,endColumn:f}=s;if(r===c&&o===l)return;const g=u-c,m=f-l,p={startRow:r,startColumn:o,endRow:r+g,endColumn:o+m};n.setValue(r,o,p)}),i}function ct(i,e,t){return i==null||i[e]==null||i[e][t]==null}var Wr=Object.defineProperty,Hr=Object.getOwnPropertyDescriptor,Kr=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hr(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Wr(e,t,r),r},Z=(i,e)=>(t,n)=>e(t,n,i);let Re=class extends a.Disposable{constructor(i,e,t,n,r,o,s){super(),this._currentUniverService=i,this._commandService=e,this._lexerTreeBuilder=t,this._formulaDataModel=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._injector=s,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>this._getUpdateFormula(i)})),this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{const{id:t,params:n}=i;if(n)switch(t){case h.SetRangeValuesMutation.id:this._handleSetRangeValuesMutation(n,e);break;case h.RemoveSheetMutation.id:this._handleRemoveSheetMutation(n);break;case h.InsertSheetMutation.id:this._handleInsertSheetMutation(n);break}}))}_handleSetRangeValuesMutation(i,e){const{worksheetId:t,workbookId:n,cellValue:r}=i;e&&e.local===!0||r==null||(this._formulaDataModel.updateFormulaData(n,t,r),this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:this._formulaDataModel.getFormulaData()},{local:!0}))}_handleRemoveSheetMutation(i){const{worksheetId:e,workbookId:t}=i,n=this._formulaDataModel.getFormulaData();delete n[t][e];const r=this._formulaDataModel.getArrayFormulaRange();delete r[t][e];const o=this._formulaDataModel.getArrayFormulaCellData();delete o[t][e],this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:n}),this._commandService.executeCommand(y.SetArrayFormulaDataMutation.id,{arrayFormulaRange:r,arrayFormulaCellData:o})}_handleInsertSheetMutation(i){const{sheet:e,workbookId:t}=i,n=this._formulaDataModel.getFormulaData(),{id:r,cellData:o}=e,s=new a.ObjectMatrix(o);y.initSheetFormulaData(n,t,r,s),this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:n})}_getUpdateFormula(i){const{id:e}=i;let t=null;switch(e){case h.MoveRangeCommand.id:t=this._handleMoveRange(i);break;case h.MoveRowsCommand.id:t=this._handleMoveRows(i);break;case h.MoveColsCommand.id:t=this._handleMoveCols(i);break;case h.InsertRowCommand.id:t=this._handleInsertRow(i);break;case h.InsertColCommand.id:t=this._handleInsertCol(i);break;case h.InsertRangeMoveRightCommand.id:t=this._handleInsertRangeMoveRight(i);break;case h.InsertRangeMoveDownCommand.id:t=this._handleInsertRangeMoveDown(i);break;case h.RemoveRowCommand.id:t=this._handleRemoveRow(i);break;case h.RemoveColCommand.id:t=this._handleRemoveCol(i);break;case h.DeleteRangeMoveUpCommand.id:t=this._handleDeleteRangeMoveUp(i);break;case h.DeleteRangeMoveLeftCommand.id:t=this._handleDeleteRangeMoveLeft(i);break;case h.SetWorksheetNameCommand.id:t=this._handleSetWorksheetName(i);break}if(t){const{unitSheetNameMap:n}=this._formulaDataModel.getCalculateData();let r=this._formulaDataModel.getFormulaData();const o=this._getFormulaReferenceMoveInfo(r,n,t),s=this._currentUniverService.getCurrentUniverSheetInstance(),c=s.getUnitId(),l=s.getActiveSheet().getSheetId(),u=this._selectionManagerService.getSelections(),f=this._formulaDataModel.getArrayFormulaRange(),g=this._formulaDataModel.getArrayFormulaCellData();let m=ue(f,i,c,l,u);m=Vr(m,c,l);const p=ue(g,i,c,l,u);this._commandService.executeCommand(y.SetArrayFormulaDataMutation.id,{arrayFormulaRange:m,arrayFormulaCellData:p},{local:!0}),r=ue(r,i,c,l,u);const _=ue(o,i,c,l,u);return this._commandService.executeCommand(y.SetFormulaDataMutation.id,{formulaData:this._formulaDataModel.getFormulaData()}),this._getUpdateFormulaMutations(r,_)}return{undos:[],redos:[]}}_handleMoveRange(i){const{params:e}=i;if(!e)return null;const{fromRange:t,toRange:n}=e;if(!t||!n)return null;const{unitId:r,sheetId:o}=this._getCurrentSheetInfo();return{type:0,from:t,to:n,unitId:r,sheetId:o}}_handleMoveRows(i){const{params:e}=i;if(!e)return null;const{fromRow:t,toRow:n}=e,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getUnitId(),s=r.getActiveSheet(),c=s.getSheetId(),l={startRow:t,startColumn:0,endRow:t,endColumn:s.getColumnCount()-1,rangeType:a.RANGE_TYPE.ROW},u={startRow:n,startColumn:0,endRow:n,endColumn:s.getColumnCount()-1,rangeType:a.RANGE_TYPE.ROW};return{type:0,from:l,to:u,unitId:o,sheetId:c}}_handleMoveCols(i){const{params:e}=i;if(!e)return null;const{fromCol:t,toCol:n}=e,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getUnitId(),s=r.getActiveSheet(),c=s.getSheetId(),l={startRow:0,startColumn:t,endRow:s.getRowCount()-1,endColumn:t,rangeType:a.RANGE_TYPE.COLUMN},u={startRow:0,startColumn:n,endRow:s.getRowCount()-1,endColumn:n,rangeType:a.RANGE_TYPE.COLUMN};return{type:0,from:l,to:u,unitId:o,sheetId:c}}_handleInsertRow(i){const{params:e}=i;if(!e)return null;const{range:t,workbookId:n,worksheetId:r}=e;return{type:1,ranges:[t],unitId:n,sheetId:r}}_handleInsertCol(i){const{params:e}=i;if(!e)return null;const{range:t,workbookId:n,worksheetId:r}=e;return{type:2,ranges:[t],unitId:n,sheetId:r}}_handleInsertRangeMoveRight(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:8,ranges:t,unitId:n,sheetId:r}}_handleInsertRangeMoveDown(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:7,ranges:t,unitId:n,sheetId:r}}_handleRemoveRow(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:3,ranges:t,unitId:n,sheetId:r}}_handleRemoveCol(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:4,ranges:t,unitId:n,sheetId:r}}_handleDeleteRangeMoveUp(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:6,ranges:t,unitId:n,sheetId:r}}_handleDeleteRangeMoveLeft(i){const{params:e}=i;if(!e)return null;const{ranges:t}=e,{unitId:n,sheetId:r}=this._getCurrentSheetInfo();return{type:5,ranges:t,unitId:n,sheetId:r}}_handleSetWorksheetName(i){const{params:e}=i;if(!e)return null;const{workbookId:t,worksheetId:n,name:r}=e,{unitId:o,sheetId:s}=this._getCurrentSheetInfo();return{type:9,unitId:t||o,sheetId:n||s,sheetName:r}}_getUpdateFormulaMutations(i,e){const t=[],n=[],r={get:this._injector.get.bind(this._injector)},o=Object.keys(e);for(const s of o){const c=e[s],l=Object.keys(c);for(const u of l){const f=new a.ObjectMatrix(i[s][u]),g=new a.ObjectMatrix(c[u]),m=new a.ObjectMatrix;g.forValue((d,v,S)=>{var F,M;const C=(S==null?void 0:S.f)||"",T=((M=(F=f.getRow(d))==null?void 0:F.get(v))==null?void 0:M.f)||"";a.isFormulaString(C)&&(a.isFormulaString(T)&&C!==T?m.setValue(d,v,{f:C}):m.setValue(d,v,{f:C,si:null}))});const p=m.getData();if(a.Tools.isEmptyObject(p))continue;const _={worksheetId:u,workbookId:s,cellValue:p};t.push({id:h.SetRangeValuesMutation.id,params:_});const I=h.SetRangeValuesUndoMutationFactory(r,_);n.push({id:h.SetRangeValuesMutation.id,params:I})}}return{redos:t,undos:n}}_getFormulaReferenceMoveInfo(i,e,t){const n=Object.keys(i),r={};for(const o of n){const s=i[o],c=Object.keys(s);r[o]==null&&(r[o]={});for(const l of c){const u=new a.ObjectMatrix(s[l]),f=new a.ObjectMatrix;u.forValue((g,m,p)=>{var M;if(!p)return!0;const{f:_,x:I,y:d,si:v}=p,S=this._lexerTreeBuilder.sequenceNodesBuilder(_);if(S==null)return!0;let C=!1;const T=[];for(let b=0,D=S.length;b<D;b++){const U=S[b];if(typeof U=="string"||U.nodeType!==y.sequenceNodeType.REFERENCE)continue;const{token:N}=U,P=a.deserializeRangeWithSheet(N),{range:A,sheetName:W,unitId:$}=P,z=$==null||$.length===0?o:$,ee=(M=e==null?void 0:e[z])==null?void 0:M[W],Y={range:A,sheetId:ee,unitId:$,sheetName:W,refOffsetX:I||0,refOffsetY:d||0};let ce=null;if(t.type===9){const{unitId:Ni,sheetId:ut,sheetName:ke}=t;if(ke==null||ee==null||ee.length===0||ut!==ee)continue;ce=a.serializeRangeToRefString({range:A,sheetName:ke,unitId:$})}else ce=this._getNewRangeByMoveParam(Y,t,o,l);ce!=null&&(S[b]={...U,token:ce},C=!0,T.push(b))}if(!C)return!0;const F=this._updateRefOffset(S,T,I,d);f.setValue(g,m,{f:`=${y.generateStringWithSequence(F)}`,x:I,y:d,si:v})}),r[o][l]=f.getData()}}return r}_getNewRangeByMoveParam(i,e,t,n){const{type:r,unitId:o,sheetId:s,ranges:c,from:l,to:u}=e,{range:f,sheetId:g,unitId:m,sheetName:p,refOffsetX:_,refOffsetY:I}=i;if(!this._checkIsSameUnitAndSheet(o,s,t,n,m,g))return;const d=a.Rectangle.moveOffset(f,_,I);let v=null;if(r===0){if(l==null||u==null)return;const S=this._checkMoveEdge(d,l),C=a.Rectangle.getIntersects(d,l);if(C==null)return;const T=h.handleMoveRange({id:h.EffectRefRangId.MoveRangeCommandId,params:{toRange:u,fromRange:l}},C),F=h.runRefRangeMutations(T,C);if(F==null)return;v=this._getMoveNewRange(S,F,l,u,d,C)}if(c!=null){if(r===1){const S=h.handleInsertRow({id:h.EffectRefRangId.InsertRowCommandId,params:{range:c[0],workbookId:"",worksheetId:"",direction:a.Direction.DOWN}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===2){const S=h.handleInsertCol({id:h.EffectRefRangId.InsertColCommandId,params:{range:c[0],workbookId:"",worksheetId:"",direction:a.Direction.RIGHT}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===3){const S=h.handleIRemoveRow({id:h.EffectRefRangId.RemoveRowCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===4){const S=h.handleIRemoveCol({id:h.EffectRefRangId.RemoveColCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===5){const S=h.handleDeleteRangeMoveLeft({id:h.EffectRefRangId.DeleteRangeMoveLeftCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===6){const S=h.handleDeleteRangeMoveUp({id:h.EffectRefRangId.DeleteRangeMoveUpCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===7){const S=h.handleInsertRangeMoveDown({id:h.EffectRefRangId.InsertRangeMoveDownCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}else if(r===8){const S=h.handleInsertRangeMoveRight({id:h.EffectRefRangId.InsertRangeMoveRightCommandId,params:{ranges:c}},d),C=h.runRefRangeMutations(S,d);if(C==null)return;v={...d,...C}}}if(v!=null)return a.serializeRangeToRefString({range:v,sheetName:p,unitId:m})}_checkIsSameUnitAndSheet(i,e,t,n,r,o){if((r==null||r.length===0)&&(o==null||o.length===0)){if(i===t&&e===n)return!0}else if((i===r||r==null||r.length===0)&&e===o)return!0;return!1}_updateRefOffset(i,e,t=0,n=0){const r=[];for(let o=0,s=i.length;o<s;o++){const c=i[o];if(typeof c=="string"||c.nodeType!==y.sequenceNodeType.REFERENCE||e.includes(o)){r.push(c);continue}const{token:l}=c,u=a.deserializeRangeWithSheet(l),{range:f,sheetName:g,unitId:m}=u,p=a.Rectangle.moveOffset(f,t,n);r.push({...c,token:a.serializeRangeToRefString({range:p,unitId:m,sheetName:g})})}return r}_checkMoveEdge(i,e){const{startRow:t,startColumn:n,endRow:r,endColumn:o}=i,{startRow:s,startColumn:c,endRow:l,endColumn:u}=e;if(t>=s&&r<=l&&n>=c&&o<=u)return 4;if(n>=c&&o<=u&&t>=s&&t<=l&&r>l)return 0;if(n>=c&&o<=u&&r>=s&&r<=l&&t<s)return 1;if(t>=s&&r<=l&&n>=c&&n<=u&&o>u)return 2;if(t>=s&&r<=l&&o>=c&&o<=u&&n<c)return 3}_getMoveNewRange(i,e,t,n,r,o){const{startRow:s,endRow:c,startColumn:l,endColumn:u}=e,{startRow:f,startColumn:g,endRow:m,endColumn:p}=t,{startRow:_,startColumn:I,endRow:d,endColumn:v}=n,{startRow:S,endRow:C,startColumn:T,endColumn:F}=o,{startRow:M,endRow:b,startColumn:D,endColumn:U}=r,N={...r};if(i===0)if(l===D&&u===U)if(s<M)N.startRow=s;else if(c<b)N.startRow=s;else if(c>=b&&_<=b)N.startRow=m+1,N.endRow=c;else return;else return;else if(i===1)if(l===D&&u===U)if(c>b)N.endRow=c;else if(s>M)N.endRow=c;else if(s<=M&&d>=M)N.endRow=f+1,N.startRow=s;else return;else return;else if(i===2)if(s===M&&c===b)if(l<D)N.startColumn=l;else if(u<U)N.startColumn=l;else if(u>=U&&I<=U)N.startColumn=p+1,N.endColumn=u;else return;else return;else if(i===3)if(s===M&&c===b)if(u>U)N.endColumn=u;else if(l>D)N.endColumn=u;else if(l<=D&&v>=D)N.endColumn=g+1,N.startColumn=l;else return;else return;else(i===4||(I<=F+1&&v>=U||I<=D&&v>=T-1)&&_<=M&&d>=b||(_<=C+1&&d>=b||_<=M&&d>=S-1)&&I<=D&&v>=U)&&(N.startRow=s,N.startColumn=l,N.endRow=c,N.endColumn=u);return N}_getInsertNewRange(){}_getCurrentSheetInfo(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getUnitId(),t=i.getActiveSheet().getSheetId();return{unitId:e,sheetId:t}}};Re=Kr([a.OnLifecycle(a.LifecycleStages.Ready,Re),Z(0,a.IUniverInstanceService),Z(1,a.ICommandService),Z(2,O.Inject(y.LexerTreeBuilder)),Z(3,O.Inject(y.FormulaDataModel)),Z(4,O.Inject(h.SheetInterceptorService)),Z(5,O.Inject(h.SelectionManagerService)),Z(6,O.Inject(O.Injector))],Re);const Gr={},zr={},Yr={},Xr={},Zr={},Qr={},Jr={},ei={},ti={},ni={},ri={SUM:{description:"You can add individual values, cell references or ranges or a mix of all three.",abstract:"Adds its arguments",functionParameter:{number1:{name:"number1",detail:"The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8."},number2:{name:"number2",detail:"This is the second number you want to add. You can specify up to 255 numbers in this way."}}},SUMIF:{description:"Sum the values in a range that meet criteria that you specify.",abstract:"Adds the cells specified by a given criteria",functionParameter:{range:{name:"range",detail:"The range of cells that you want evaluated by criteria."},criteria:{name:"criteria",detail:"The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included - a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character."},sum_range:{name:"sum_range",detail:"The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied)."}}}},ii={AVERAGE:{description:"Returns the average (arithmetic mean) of the arguments.",abstract:"Returns the average of its arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range for which you want the average."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255."}}},COUNT:{description:"Counts the number of cells that contain numbers, and counts numbers within the list of arguments.",abstract:"Counts how many numbers are in the list of arguments",functionParameter:{value1:{name:"value1",detail:"The first item, cell reference, or range within which you want to count numbers."},value2:{name:"value2",detail:"Up to 255 additional items, cell references, or ranges within which you want to count numbers."}}},MAX:{description:"Returns the largest value in a set of values.",abstract:"Returns the maximum value in a list of arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range to calculate the maximum value from."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges to calculate the maximum value from, up to a maximum of 255."}}},MIN:{description:"Returns the smallest number in a set of values.",abstract:"Returns the minimum value in a list of arguments",functionParameter:{number1:{name:"number1",detail:"The first number, cell reference, or range to calculate the minimum value from."},number2:{name:"number2",detail:"Additional numbers, cell references or ranges to calculate the minimum value from, up to a maximum of 255."}}}},oi={},si={},ai={},ci={formula:{insert:{tooltip:"Functions",sum:"SUM",average:"AVERAGE",count:"COUNT",max:"MAX",min:"MIN",more:"More Functions..."},functionList:{...Jr,...Zr,...ri,...ii,...ni,...Xr,...oi,...ti,...ei,...Qr,...Yr,...zr,...ai,...Gr,...si},prompt:{helpExample:"EXAMPLE",helpAbstract:"ABOUT",required:"Required.",optional:"Optional."},functionType:{financial:"Financial",date:"Date & Time",math:"Math & Trig",statistical:"Statistical",lookup:"Lookup & Reference",database:"Database",text:"Text",logical:"Logical",information:"Information",engineering:"Engineering",cube:"Cube",compatibility:"Compatibility",web:"Web",array:"Array",univer:"Univer"},moreFunctions:{confirm:"Confirm",prev:"Previous",next:"Next",searchFunctionPlaceholder:"Search function",allFunctions:"All Functions",syntax:"SYNTAX"},operation:{pasteFormula:"Paste Formula"}}},li={},ui={},di={},mi={},fi={},hi={},gi={},pi={},Si={},_i={},vi={SUM:{description:"将单个值、单元格引用或是区域相加,或者将三者的组合相加。",abstract:"求参数的和",functionParameter:{number1:{name:"数值1",detail:"要相加的第一个数字。 该数字可以是 4 之类的数字,B6 之类的单元格引用或 B2:B8 之类的单元格范围。"},number2:{name:"数值2",detail:"这是要相加的第二个数字。 可以按照这种方式最多指定 255 个数字。"}}},SUMIF:{description:"对范围中符合指定条件的值求和。",abstract:"按给定条件对指定单元格求和",functionParameter:{range:{name:"范围",detail:"要根据条件进行检测的范围。"},criteria:{name:"条件",detail:"以数字、表达式、单元格引用、文本或函数的形式来定义将添加哪些单元格。可包括的通配符字符 - 问号(?)以匹配任意单个字符,星号(*)以匹配任意字符序列。 如果要查找实际的问号或星号,请在该字符前键入波形符(~)。"},sum_range:{name:"求和范围",detail:"要添加的实际单元格,如果要添加在范围参数指定以外的其他单元格。 如果省略sum_range参数,Excel就会添加范围参数中指定的单元格(与应用标准的单元格相同)。"}}}},Ri={AVERAGE:{description:"返回参数的平均值(算术平均值)。",abstract:"返回参数平均值",functionParameter:{number1:{name:"数值1",detail:"要计算平均值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算平均值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}},COUNT:{description:"计算包含数字的单元格个数以及参数列表中数字的个数。",abstract:"计算参数列表中数字的个数",functionParameter:{value1:{name:"值1",detail:"要计算其中数字的个数的第一项、单元格引用或区域。"},value2:{name:"值2",detail:"要计算其中数字的个数的其他项、单元格引用或区域,最多可包含 255 个。"}}},MAX:{description:"返回一组值中的最大值。",abstract:"返回参数列表中的最大值",functionParameter:{number1:{name:"数值1",detail:"要计算最大值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算最大值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}},MIN:{description:"返回一组值中的最小值。",abstract:"返回参数列表中的最小值",functionParameter:{number1:{name:"数值1",detail:"要计算最小值的第一个数字、单元格引用或单元格区域。"},number2:{name:"数值2",detail:"要计算最小值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"}}}},Ii={},Ci={},yi={},lt={formula:{insert:{tooltip:"函数",sum:"求和",average:"平均值",count:"计数",max:"最大值",min:"最小值",more:"更多函数..."},functionList:{...gi,...fi,...vi,...Ri,..._i,...mi,...Ii,...Si,...pi,...hi,...di,...ui,...yi,...li,...Ci},prompt:{helpExample:"示例",helpAbstract:"简介",required:"必需。",optional:"可选。"},functionType:{financial:"财务",date:"日期与时间",math:"数学与三角函数",statistical:"统计",lookup:"查找与引用",database:"数据库",text:"文本",logical:"逻辑",information:"信息",engineering:"工程",cube:"多维数据集",compatibility:"兼容性",web:"Web",array:"数组",univer:"Univer"},moreFunctions:{confirm:"应用",prev:"上一步",next:"下一步",searchFunctionPlaceholder:"搜索函数",allFunctions:"全部函数",syntax:"语法"},operation:{pasteFormula:"仅粘贴公式"}}};var Mi=Object.defineProperty,bi=Object.getOwnPropertyDescriptor,Fi=(i,e,t,n)=>{for(var r=n>1?void 0:n?bi(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Mi(e,t,r),r},xe=(i,e)=>(t,n)=>e(t,n,i),Ee;exports.UniverSheetsFormulaPlugin=(Ee=class extends a.Plugin{constructor(e,t,n,r){super(Ge),this._config=e,this._injector=t,this._localeService=n,this._currentUniverService=r}initialize(){this._localeService.load({zhCN:lt}),[[J,{useClass:Pt}],[se,{useClass:Ot}],[je,{useFactory:()=>{var t;return this._injector.createInstance(Le,((t=this._config)==null?void 0:t.description)||[])}}],[Ae,{useClass:ft}],[Se],[_e],[pe],[fe],[he],[me],[ve],[Re],[ge],[de]].forEach(t=>this._injector.add(t))}onReady(){this.initialize()}},w(Ee,"type",a.PluginType.Sheet),Ee);exports.UniverSheetsFormulaPlugin=Fi([xe(1,O.Inject(O.Injector)),xe(2,O.Inject(a.LocaleService)),xe(3,a.IUniverInstanceService)],exports.UniverSheetsFormulaPlugin);exports.enUS=ci;exports.zhCN=lt;
|