@fw-components/formula-editor 2.0.7-formula-editor.13 → 2.0.7-formula-editor.15

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.
@@ -118,7 +118,6 @@ let FormulaEditor = class FormulaEditor extends LitElement {
118
118
  this._recommendations = parseOutput.recommendations;
119
119
  this._formattedContent = parseOutput.formattedContent;
120
120
  this.errorString = parseOutput.errorString;
121
- // console.log("this._recommendation",parseOutput)
122
121
  /**
123
122
  * Don't modify the text stream manually if the text is being composed,
124
123
  * unless the user manually chooses to do so by selecting a suggestion.
@@ -185,6 +184,11 @@ let FormulaEditor = class FormulaEditor extends LitElement {
185
184
  this._recommendations = null;
186
185
  this.requestUpdate();
187
186
  }
187
+ handleFocus(e) {
188
+ if (!this.content.trim()) {
189
+ this._recommendations = Array.from(this.variables.keys());
190
+ }
191
+ }
188
192
  render() {
189
193
  return html `
190
194
  <style>
@@ -206,6 +210,7 @@ let FormulaEditor = class FormulaEditor extends LitElement {
206
210
  @input=${this.handleChange}
207
211
  @keydown=${this.handleKeyboardEvents}
208
212
  @blur=${this.handleFocusOut}
213
+ @focus=${this.handleFocus}
209
214
  ></div>
210
215
  ${this._recommendations
211
216
  ? html ` <suggestion-menu
@@ -177,6 +177,11 @@ export class Parser {
177
177
  previousToken = token;
178
178
  currentTokens += token;
179
179
  });
180
+ if (recommendation) {
181
+ parseOutput.newCursorPosition = Math.min(parseOutput.newCursorPosition +
182
+ recommendation.length, formula.length + recommendation.length);
183
+ formattedString = `${formattedString}<span class="wysiwygInternals">${recommendation}</span>`;
184
+ }
180
185
  // If the formula ends with a mathematical operator, or has unclosed `(`
181
186
  if (this.mathematicalOperators.has(previousToken)) {
182
187
  // parseOutput.errorString = "Unexpected ending of formula.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fw-components/formula-editor",
3
- "version": "2.0.7-formula-editor.13",
3
+ "version": "2.0.7-formula-editor.15",
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": "64b2664ee2da986636148d45c0d05bcf4c223886"
28
+ "gitHead": "c544f7013f65838c0ce25819898c444386fa5602"
29
29
  }