@fw-components/formula-editor 2.0.7-formula-editor.8 → 2.0.7-formula-editor.9
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.
|
@@ -28,6 +28,7 @@ export class Parser {
|
|
|
28
28
|
let currentPosition = 0;
|
|
29
29
|
// Previous 'token' (not a space or a new line) that we just encountered.
|
|
30
30
|
let previousToken = "";
|
|
31
|
+
let currentTokens = "";
|
|
31
32
|
// The object that we return as the output of the parsing result.
|
|
32
33
|
let parseOutput = {
|
|
33
34
|
recommendations: null,
|
|
@@ -107,7 +108,7 @@ export class Parser {
|
|
|
107
108
|
!isNumber &&
|
|
108
109
|
token != "(" &&
|
|
109
110
|
!((token == "-" || token == "+") &&
|
|
110
|
-
(this.mathematicalOperators.has(previousToken)))) {
|
|
111
|
+
(!currentTokens.trim() || this.mathematicalOperators.has(previousToken)))) {
|
|
111
112
|
parseOutput.errorString = `Expected variable/number at position ${currentPosition}`;
|
|
112
113
|
tokenClassName += " error";
|
|
113
114
|
expectation = Expectation.UNDEFINED;
|
|
@@ -174,6 +175,7 @@ export class Parser {
|
|
|
174
175
|
formattedString = `${formattedString}<span class="wysiwygInternals ${tokenClassName}">${token}</span>`;
|
|
175
176
|
currentPosition += token.length;
|
|
176
177
|
previousToken = token;
|
|
178
|
+
currentTokens += token;
|
|
177
179
|
});
|
|
178
180
|
// If the formula ends with a mathematical operator, or has unclosed `(`
|
|
179
181
|
if (this.mathematicalOperators.has(previousToken)) {
|
|
@@ -200,9 +202,10 @@ export class Parser {
|
|
|
200
202
|
let previousToken = "";
|
|
201
203
|
let carriedToken = null;
|
|
202
204
|
const parsedTokens = [];
|
|
205
|
+
let currentTokens = "";
|
|
203
206
|
for (const token of tokens) {
|
|
204
207
|
if ((token == "+" || token == "-") &&
|
|
205
|
-
(this.mathematicalOperators.has(previousToken))) {
|
|
208
|
+
(!currentTokens.trim() || this.mathematicalOperators.has(previousToken))) {
|
|
206
209
|
carriedToken = token;
|
|
207
210
|
}
|
|
208
211
|
else if (carriedToken) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fw-components/formula-editor",
|
|
3
|
-
"version": "2.0.7-formula-editor.
|
|
3
|
+
"version": "2.0.7-formula-editor.9",
|
|
4
4
|
"description": "A WYSIWYG type formula editor",
|
|
5
5
|
"main": "dist/formula-editor/src/formula-builder.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@types/big.js": "^6.1.6",
|
|
26
26
|
"es-dev-server": "^2.1.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "8ec9bb1e89c289c5334db8f99d1a359c731a4375"
|
|
29
29
|
}
|