@univerjs/sheets-formula 0.1.0-beta.5 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +8 -8
- package/lib/es/index.js +1789 -1870
- package/lib/index.css +1 -1
- package/lib/types/controllers/prompt.controller.d.ts +15 -15
- package/lib/types/services/prompt.service.d.ts +61 -1
- package/lib/umd/index.js +6 -6
- package/package.json +20 -20
- package/lib/types/controllers/formula-input.controller.d.ts +0 -41
- package/lib/types/services/formula-input.service.d.ts +0 -106
- package/lib/types/views/prompt/error-function/error-function.d.ts +0 -17
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-formula-
|
|
1
|
+
.univer-formula-help-function{user-select:none;box-sizing:border-box;width:250px;margin:0;line-height:20px;list-style:none;background-color:rgb(var(--bg-color-secondary));border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-lg);outline:none;box-shadow:var(--box-shadow-base)}.univer-formula-help-function-title{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;padding:var(--padding-base) var(--padding-lg);font-size:var(--font-size-xxs);font-weight:500;color:rgb(var(--text-color));overflow-wrap:anywhere;border-bottom:1px solid rgb(var(--border-color))}.univer-formula-help-function-title-icons{display:flex}.univer-formula-help-function-title-icon{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;margin-left:var(--margin-xs);padding:0;font-size:var(--font-size-xs);color:rgb(var(--text-color-secondary));background-color:transparent;border:none;border-radius:var(--border-radius-base);outline:none;transition:background-color .2s}.univer-formula-help-function-title-icon:hover{background-color:rgb(var(--bg-color-hover))}.univer-formula-help-function-content{overflow-y:auto;box-sizing:border-box;max-height:350px;padding:0 var(--padding-lg) var(--padding-base) var(--padding-lg)}.univer-formula-help-function-content-inner{margin-top:var(--margin-sm)}.univer-formula-help-function-content-params{margin:var(--margin-xs) 0}.univer-formula-help-function-content-params-title{margin-bottom:var(--margin-xs);font-size:var(--font-size-xs);font-weight:500;color:rgb(var(--text-color))}.univer-formula-help-function-content-params-detail{font-size:var(--font-size-xxs);font-weight:400;white-space:pre-wrap;color:rgb(var(--text-color-secondary))}.univer-formula-help-function-active{color:rgb(var(--primary-color))}.univer-formula-help-decorator{cursor:pointer;position:fixed;z-index:10;display:flex;align-items:center;justify-content:center;padding:var(--padding-xs)}.univer-formula-search-function{overflow-y:auto;box-sizing:border-box;width:250px;max-height:400px;margin:0;padding:var(--padding-sm);line-height:20px;list-style:none;background-color:rgb(var(--bg-color-secondary));border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-lg);outline:none;box-shadow:var(--box-shadow-base)}.univer-formula-search-function-item{cursor:pointer;box-sizing:border-box;padding:var(--padding-xs) var(--padding-sm);color:rgb(var(--text-color));border-radius:var(--border-radius-base);transition:background .2s}.univer-formula-search-function-item-name{font-size:var(--font-size-xxs)}.univer-formula-search-function-item-name-light{color:rgb(var(--error-color))}.univer-formula-search-function-item-desc{display:block;font-size:var(--font-size-xxs);color:rgb(var(--grey-500))}.univer-formula-search-function-item-active{background-color:rgb(var(--bg-color-hover))}.univer-formula-more-functions{display:flex;flex-direction:column;justify-content:space-between;height:100%;line-height:20px}.univer-formula-more-functions-operation{display:flex;justify-content:flex-end}.univer-formula-more-functions-operation>button{margin:0 0 var(--margin-lg) var(--margin-base)}.univer-formula-function-params{margin-bottom:var(--margin-xs);font-size:var(--font-size-xxs)}.univer-formula-function-params-title{font-weight:500;color:rgb(var(--text-color-secondary))}.univer-formula-function-params-detail{font-weight:400;color:rgb(var(--text-color))}.univer-formula-input-params-list{overflow-y:auto;height:364px}.univer-formula-input-params-list-item-name{font-size:var(--font-size-sm)}.univer-formula-input-params-list-item-selector{margin:var(--margin-xxs) 0 var(--margin-xs) 0}.univer-formula-select-function-select{display:flex;gap:10%;align-items:center;justify-content:space-between}.univer-formula-select-function-result{user-select:none;overflow-y:auto;box-sizing:border-box;width:100%;height:364px;margin:0;margin-top:var(--margin-xs);padding:var(--padding-base);list-style:none;border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-base);outline:none}.univer-formula-select-function-result-item{cursor:pointer;position:relative;box-sizing:border-box;padding:var(--padding-xs) 28px;font-size:var(--font-size-xs);color:rgb(var(--text-color));border-radius:var(--border-radius-base);transition:background .2s}.univer-formula-select-function-result-item>span{display:block}.univer-formula-select-function-result-item-name-light{color:rgb(var(--error-color))}.univer-formula-select-function-result-item-selected{position:absolute;top:50%;left:6px;transform:translateY(-50%);display:inline-flex;font-size:var(--font-size-lg);color:rgb(var(--success-color))}.univer-formula-select-function-result-item-active{background-color:rgb(var(--bg-color-hover))}.univer-formula-select-function-content{overflow-y:auto;max-height:307px;margin:var(--margin-xs) 0}
|
|
@@ -20,9 +20,8 @@ import { IRenderManagerService, ITextSelectionRenderManager } from '@univerjs/en
|
|
|
20
20
|
import { SelectionManagerService } from '@univerjs/sheets';
|
|
21
21
|
import type { EditorBridgeService } from '@univerjs/sheets-ui';
|
|
22
22
|
import { ISelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
23
|
-
import { IContextMenuService } from '@univerjs/ui';
|
|
23
|
+
import { IContextMenuService, IEditorService } from '@univerjs/ui';
|
|
24
24
|
import { IDescriptionService } from '../services/description.service';
|
|
25
|
-
import { IFormulaInputService } from '../services/formula-input.service';
|
|
26
25
|
import { IFormulaPromptService } from '../services/prompt.service';
|
|
27
26
|
export declare class PromptController extends Disposable {
|
|
28
27
|
private readonly _commandService;
|
|
@@ -39,23 +38,24 @@ export declare class PromptController extends Disposable {
|
|
|
39
38
|
private readonly _selectionRenderService;
|
|
40
39
|
private readonly _descriptionService;
|
|
41
40
|
private readonly _textSelectionManagerService;
|
|
42
|
-
private readonly _formulaInputService;
|
|
43
41
|
private readonly _docViewModelManagerService;
|
|
44
42
|
private readonly _contextMenuService;
|
|
43
|
+
private readonly _editorService;
|
|
45
44
|
private _formulaRefColors;
|
|
46
45
|
private _previousSequenceNodes;
|
|
47
46
|
private _previousRangesCount;
|
|
48
47
|
private _previousInsertRefStringIndex;
|
|
49
48
|
private _currentInsertRefStringIndex;
|
|
50
|
-
private _currentUnitId;
|
|
51
|
-
private _currentSheetId;
|
|
52
49
|
private _arrowMoveActionState;
|
|
53
50
|
private _isSelectionMovingRefSelections;
|
|
54
51
|
private _stringColor;
|
|
55
52
|
private _numberColor;
|
|
56
53
|
private _insertSelections;
|
|
57
54
|
private _inputPanelState;
|
|
58
|
-
|
|
55
|
+
private _userCursorMove;
|
|
56
|
+
private _previousEditorUnitId;
|
|
57
|
+
private _executeBlurSetTimeout;
|
|
58
|
+
constructor(_commandService: ICommandService, _contextService: IContextService, _textSelectionRenderManager: ITextSelectionRenderManager, _editorBridgeService: EditorBridgeService, _formulaPromptService: IFormulaPromptService, _lexerTreeBuilder: LexerTreeBuilder, _renderManagerService: IRenderManagerService, _themeService: ThemeService, _selectionManagerService: SelectionManagerService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _currentUniverService: IUniverInstanceService, _selectionRenderService: ISelectionRenderService, _descriptionService: IDescriptionService, _textSelectionManagerService: TextSelectionManagerService, _docViewModelManagerService: DocViewModelManagerService, _contextMenuService: IContextMenuService, _editorService: IEditorService);
|
|
59
59
|
dispose(): void;
|
|
60
60
|
private _resetTemp;
|
|
61
61
|
private _initialize;
|
|
@@ -63,8 +63,9 @@ export declare class PromptController extends Disposable {
|
|
|
63
63
|
private _initialCursorSync;
|
|
64
64
|
private _initialEditorInputChange;
|
|
65
65
|
private _initialExitEditor;
|
|
66
|
+
private _initialChangeEditor;
|
|
67
|
+
private _changeEditor;
|
|
66
68
|
private _initialRefSelectionUpdateEvent;
|
|
67
|
-
private _syncEditorListener;
|
|
68
69
|
private _selectionChanging;
|
|
69
70
|
private _initialRefSelectionInsertEvent;
|
|
70
71
|
private _initAcceptFormula;
|
|
@@ -80,7 +81,6 @@ export declare class PromptController extends Disposable {
|
|
|
80
81
|
/**
|
|
81
82
|
* Determine whether the character is a token keyword for the formula engine.
|
|
82
83
|
* @param char
|
|
83
|
-
* @returns
|
|
84
84
|
*/
|
|
85
85
|
private _matchRefDrawToken;
|
|
86
86
|
/**
|
|
@@ -95,12 +95,12 @@ export declare class PromptController extends Disposable {
|
|
|
95
95
|
private _disableForceKeepVisible;
|
|
96
96
|
private _getCurrentBody;
|
|
97
97
|
private _getFormulaAndCellEditorBody;
|
|
98
|
+
private _editorModelUnitIds;
|
|
98
99
|
/**
|
|
99
100
|
* Detect whether the user's input content is a formula. If it is a formula,
|
|
100
101
|
* serialize the current input content into a sequenceNode;
|
|
101
102
|
* otherwise, close the formula panel.
|
|
102
103
|
* @param currentInputValue The text content entered by the user in the editor.
|
|
103
|
-
* @returns
|
|
104
104
|
*/
|
|
105
105
|
private _contextSwitch;
|
|
106
106
|
private _getContextState;
|
|
@@ -116,14 +116,12 @@ export declare class PromptController extends Disposable {
|
|
|
116
116
|
* :
|
|
117
117
|
* #
|
|
118
118
|
* Generate styles for formula text, highlighting references, text, numbers, and arrays.
|
|
119
|
-
* @returns
|
|
120
119
|
*/
|
|
121
120
|
private _buildTextRuns;
|
|
122
121
|
private _exceedCurrentRange;
|
|
123
122
|
/**
|
|
124
123
|
* Draw the referenced selection text based on the style and token.
|
|
125
124
|
* @param refSelections
|
|
126
|
-
* @returns
|
|
127
125
|
*/
|
|
128
126
|
private _refreshSelectionForReference;
|
|
129
127
|
private _getSheetIdByName;
|
|
@@ -131,15 +129,13 @@ export declare class PromptController extends Disposable {
|
|
|
131
129
|
private _getCurrentUnitIdAndSheetId;
|
|
132
130
|
/**
|
|
133
131
|
* Convert the selection range to a ref string for the formula engine, such as A1:B1
|
|
134
|
-
* @param
|
|
135
|
-
* @returns
|
|
132
|
+
* @param currentSelection
|
|
136
133
|
*/
|
|
137
134
|
private _getRefString;
|
|
138
135
|
/**
|
|
139
136
|
* Restore the sequenceNode generated by the lexer to the text in the editor, and set the cursor position.
|
|
140
137
|
* @param sequenceNodes
|
|
141
138
|
* @param textSelectionOffset
|
|
142
|
-
* @returns
|
|
143
139
|
*/
|
|
144
140
|
private _syncToEditor;
|
|
145
141
|
private _fitEditorSize;
|
|
@@ -147,7 +143,6 @@ export declare class PromptController extends Disposable {
|
|
|
147
143
|
* Update the editor's model value to facilitate formula updates.
|
|
148
144
|
* @param dataStream
|
|
149
145
|
* @param textRuns
|
|
150
|
-
* @returns
|
|
151
146
|
*/
|
|
152
147
|
private _updateEditorModel;
|
|
153
148
|
private _inertControlSelectionReplace;
|
|
@@ -159,5 +154,10 @@ export declare class PromptController extends Disposable {
|
|
|
159
154
|
private _cursorStateListener;
|
|
160
155
|
private _commandExecutedListener;
|
|
161
156
|
private _moveInEditor;
|
|
157
|
+
private _userMouseListener;
|
|
158
|
+
private _inputFormulaListener;
|
|
159
|
+
private _changeRefString;
|
|
160
|
+
private _changeRangeRef;
|
|
161
|
+
private _changeSingleRef;
|
|
162
162
|
private _getEditorObject;
|
|
163
163
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Direction } from '@univerjs/core';
|
|
17
|
-
import type
|
|
17
|
+
import { type IFunctionInfo, type ISequenceNode } from '@univerjs/engine-formula';
|
|
18
18
|
import type { IDisposable } from '@wendellhu/redi';
|
|
19
19
|
import type { Observable } from 'rxjs';
|
|
20
20
|
import type { ISearchItem } from './description.service';
|
|
@@ -93,6 +93,24 @@ export interface IFormulaPromptService {
|
|
|
93
93
|
isSearching(): boolean;
|
|
94
94
|
isHelping(): boolean;
|
|
95
95
|
dispose(): void;
|
|
96
|
+
getSequenceNodes(): Array<string | ISequenceNode>;
|
|
97
|
+
setSequenceNodes(nodes: Array<string | ISequenceNode>): void;
|
|
98
|
+
clearSequenceNodes(): void;
|
|
99
|
+
getCurrentSequenceNodeIndex(strIndex: number): number;
|
|
100
|
+
getCurrentSequenceNodeByIndex(nodeIndex: number): string | ISequenceNode;
|
|
101
|
+
getCurrentSequenceNode(strIndex: number): string | ISequenceNode;
|
|
102
|
+
updateSequenceRef(nodeIndex: number, refString: string): void;
|
|
103
|
+
insertSequenceRef(index: number, refString: string): void;
|
|
104
|
+
insertSequenceString(index: number, content: string): void;
|
|
105
|
+
enableSelectionMoving(): void;
|
|
106
|
+
disableSelectionMoving(): void;
|
|
107
|
+
isSelectionMoving(): boolean;
|
|
108
|
+
enableLockedSelectionChange(): void;
|
|
109
|
+
disableLockedSelectionChange(): void;
|
|
110
|
+
isLockedSelectionChange(): boolean;
|
|
111
|
+
enableLockedSelectionInsert(): void;
|
|
112
|
+
disableLockedSelectionInsert(): void;
|
|
113
|
+
isLockedSelectionInsert(): boolean;
|
|
96
114
|
}
|
|
97
115
|
export declare const IFormulaPromptService: import("@wendellhu/redi").IdentifierDecorator<FormulaPromptService>;
|
|
98
116
|
export declare class FormulaPromptService implements IFormulaPromptService, IDisposable {
|
|
@@ -109,6 +127,10 @@ export declare class FormulaPromptService implements IFormulaPromptService, IDis
|
|
|
109
127
|
private _searching;
|
|
110
128
|
private _helping;
|
|
111
129
|
private _isInsertRefString;
|
|
130
|
+
private _sequenceNodes;
|
|
131
|
+
private _isSelectionMoving;
|
|
132
|
+
private _isLockedOnSelectionChangeRefString;
|
|
133
|
+
private _isLockedOnSelectionInsertRefString;
|
|
112
134
|
dispose(): void;
|
|
113
135
|
search(param: ISearchFunctionOperationParams): void;
|
|
114
136
|
isSearching(): boolean;
|
|
@@ -117,4 +139,42 @@ export declare class FormulaPromptService implements IFormulaPromptService, IDis
|
|
|
117
139
|
navigate(param: INavigateParam): void;
|
|
118
140
|
accept(param: boolean): void;
|
|
119
141
|
acceptFormulaName(param: string): void;
|
|
142
|
+
getSequenceNodes(): (string | ISequenceNode)[];
|
|
143
|
+
setSequenceNodes(nodes: Array<string | ISequenceNode>): void;
|
|
144
|
+
clearSequenceNodes(): void;
|
|
145
|
+
getCurrentSequenceNode(strIndex: number): string | ISequenceNode;
|
|
146
|
+
getCurrentSequenceNodeByIndex(nodeIndex: number): string | ISequenceNode;
|
|
147
|
+
/**
|
|
148
|
+
* Query the text coordinates in the sequenceNodes and determine the actual insertion index.
|
|
149
|
+
* @param strIndex
|
|
150
|
+
*/
|
|
151
|
+
getCurrentSequenceNodeIndex(strIndex: number): number;
|
|
152
|
+
/**
|
|
153
|
+
* Synchronize the reference text based on the changes of the selection.
|
|
154
|
+
* @param nodeIndex
|
|
155
|
+
* @param refString
|
|
156
|
+
*/
|
|
157
|
+
updateSequenceRef(nodeIndex: number, refString: string): void;
|
|
158
|
+
/**
|
|
159
|
+
* When the cursor is on the right side of a formula token,
|
|
160
|
+
* you can add reference text to the formula by drawing a selection.
|
|
161
|
+
* @param index
|
|
162
|
+
* @param refString
|
|
163
|
+
*/
|
|
164
|
+
insertSequenceRef(index: number, refString: string): void;
|
|
165
|
+
/**
|
|
166
|
+
* Insert a string at the cursor position in the text corresponding to the sequenceNodes.
|
|
167
|
+
* @param index
|
|
168
|
+
* @param content
|
|
169
|
+
*/
|
|
170
|
+
insertSequenceString(index: number, content: string): void;
|
|
171
|
+
enableSelectionMoving(): void;
|
|
172
|
+
disableSelectionMoving(): void;
|
|
173
|
+
isSelectionMoving(): boolean;
|
|
174
|
+
enableLockedSelectionChange(): void;
|
|
175
|
+
disableLockedSelectionChange(): void;
|
|
176
|
+
isLockedSelectionChange(): boolean;
|
|
177
|
+
enableLockedSelectionInsert(): void;
|
|
178
|
+
disableLockedSelectionInsert(): void;
|
|
179
|
+
isLockedSelectionInsert(): boolean;
|
|
120
180
|
}
|