@fw-components/formula-editor 2.0.7-formula-editor.7 → 2.0.7-formula-editor.8
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.
|
@@ -30,7 +30,7 @@ let FormulaEditor = class FormulaEditor extends LitElement {
|
|
|
30
30
|
this.currentCursorRect = undefined;
|
|
31
31
|
this.lastInputType = "undef";
|
|
32
32
|
this.content = "";
|
|
33
|
-
this.placeholder = "";
|
|
33
|
+
this.placeholder = "Type your formula...";
|
|
34
34
|
this.variables = new Map();
|
|
35
35
|
this.minSuggestionLen = 2;
|
|
36
36
|
this.errorString = null;
|
|
@@ -170,6 +170,13 @@ let FormulaEditor = class FormulaEditor extends LitElement {
|
|
|
170
170
|
this._recommendations = null;
|
|
171
171
|
this.requestUpdate();
|
|
172
172
|
}
|
|
173
|
+
async updated(_changedProperties) {
|
|
174
|
+
if (_changedProperties.has("content")) {
|
|
175
|
+
if (!this.content.trim()) {
|
|
176
|
+
this._recommendations = Array.from(this.variables.keys());
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
173
180
|
render() {
|
|
174
181
|
return html `
|
|
175
182
|
<style>
|
|
@@ -36,6 +36,18 @@ export class Parser {
|
|
|
36
36
|
newCursorPosition: prevCurPos ?? -1,
|
|
37
37
|
errorString: null,
|
|
38
38
|
};
|
|
39
|
+
if (!formula.trim()) {
|
|
40
|
+
if (recommendation) {
|
|
41
|
+
formattedString = `<span class="wysiwygInternals">${recommendation}</span>`;
|
|
42
|
+
currentPosition += recommendation.length;
|
|
43
|
+
const parser = new DOMParser();
|
|
44
|
+
const doc = parser.parseFromString(formattedString, "text/html");
|
|
45
|
+
parseOutput.formattedContent = doc.querySelector("body");
|
|
46
|
+
parseOutput.formattedString = formattedString;
|
|
47
|
+
parseOutput.newCursorPosition = recommendation.length;
|
|
48
|
+
return parseOutput;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
39
51
|
tokens.forEach((token) => {
|
|
40
52
|
// It is a number is either it's in the defined variables, or
|
|
41
53
|
// it's a valid number literal.
|
|
@@ -95,7 +107,7 @@ export class Parser {
|
|
|
95
107
|
!isNumber &&
|
|
96
108
|
token != "(" &&
|
|
97
109
|
!((token == "-" || token == "+") &&
|
|
98
|
-
(this.mathematicalOperators.has(previousToken)
|
|
110
|
+
(this.mathematicalOperators.has(previousToken)))) {
|
|
99
111
|
parseOutput.errorString = `Expected variable/number at position ${currentPosition}`;
|
|
100
112
|
tokenClassName += " error";
|
|
101
113
|
expectation = Expectation.UNDEFINED;
|
|
@@ -190,9 +202,7 @@ export class Parser {
|
|
|
190
202
|
const parsedTokens = [];
|
|
191
203
|
for (const token of tokens) {
|
|
192
204
|
if ((token == "+" || token == "-") &&
|
|
193
|
-
(this.mathematicalOperators.has(previousToken)
|
|
194
|
-
previousToken === "" ||
|
|
195
|
-
previousToken === "(")) {
|
|
205
|
+
(this.mathematicalOperators.has(previousToken))) {
|
|
196
206
|
carriedToken = token;
|
|
197
207
|
}
|
|
198
208
|
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.8",
|
|
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": "ca9e8ea86309bdbc9755d3e51fdf00821a00b9b7"
|
|
29
29
|
}
|