@trebco/treb 30.6.0 → 30.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "30.6.0",
3
+ "version": "30.6.2",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -567,7 +567,7 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
567
567
  * that's fine, but it needs a new name.
568
568
  *
569
569
  */
570
- protected UpdateColors(force_event = false) {
570
+ protected UpdateColors(force_event = false, toll_update = false) {
571
571
 
572
572
  // const view = this.active_editor?.node.ownerDocument.defaultView as (Window & typeof globalThis);
573
573
 
@@ -623,8 +623,10 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
623
623
 
624
624
  this.composite_dependencies = list;
625
625
 
626
- this.Publish({ type: 'update', dependencies: this.composite_dependencies });
627
-
626
+ if (!toll_update) {
627
+ this.Publish({ type: 'update', dependencies: this.composite_dependencies });
628
+ }
629
+
628
630
  }
629
631
 
630
632
  /**
@@ -57,6 +57,8 @@ export type FormulaBar2Event
57
57
  export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
58
58
 
59
59
 
60
+ public committed = false;
61
+
60
62
  /** is the _editor_ currently focused */
61
63
  // tslint:disable-next-line:variable-name
62
64
  public focused_ = false;
@@ -219,7 +221,7 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
219
221
  this.active_editor.node.spellcheck = false; // change the default back
220
222
 
221
223
  this.RegisterListener(descriptor, 'focusin', () => {
222
-
224
+
223
225
  // this.editor_node.addEventListener('focusin', () => {
224
226
 
225
227
  // can't happen
@@ -239,7 +241,9 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
239
241
  this.autocomplete?.ResetBlock();
240
242
 
241
243
  this.UpdateText(this.active_editor);
242
- this.UpdateColors();
244
+ this.UpdateColors(undefined, true); // toll update event -- we will send in order, below
245
+
246
+ this.committed = false;
243
247
 
244
248
  this.Publish([
245
249
  { type: 'start-editing', editor: 'formula-bar' },
@@ -256,11 +260,32 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
256
260
  console.info('focusout, but selecting...');
257
261
  }
258
262
 
259
- // console.info('focus out');
260
-
261
263
  this.autocomplete?.Hide();
264
+
265
+ const text = (this.active_editor ?
266
+ this.GetTextContent(this.active_editor.node).join('') : '').trim();
267
+
268
+ if (this.committed) {
269
+ this.Publish([
270
+ { type: 'stop-editing' },
271
+ ]);
272
+ }
273
+ else {
274
+ this.committed = true;
275
+ this.Publish({
276
+ type: 'commit',
277
+ value: text,
278
+ });
279
+ }
280
+
262
281
  this.Publish([
263
282
  { type: 'stop-editing' },
283
+ /*
284
+ {
285
+ type: 'commit',
286
+ value: text,
287
+ }
288
+ */
264
289
  ]);
265
290
 
266
291
  this.focused_ = false;
@@ -441,6 +466,7 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
441
466
  const text = (this.active_editor ?
442
467
  this.GetTextContent(this.active_editor.node).join('') : '').trim();
443
468
 
469
+ this.committed = true;
444
470
  this.Publish({
445
471
  type: 'commit',
446
472
  // selection: this.selection,
@@ -193,6 +193,9 @@ export class Grid extends GridBase {
193
193
  /** if we are editing, what is the cell? */
194
194
  private editing_cell: ICellAddress = { row: -1, column: -1, sheet_id: 0 };
195
195
 
196
+ /** */
197
+ private editing_selection: GridSelection|undefined;
198
+
196
199
  /** */
197
200
  private selected_annotation?: Annotation;
198
201
 
@@ -2859,6 +2862,7 @@ export class Grid extends GridBase {
2859
2862
 
2860
2863
  this.editing_state = EditingState.FormulaBar;
2861
2864
  this.editing_cell = { ...this.primary_selection.target };
2865
+ this.editing_selection = { ...this.primary_selection };
2862
2866
  break;
2863
2867
 
2864
2868
  case 'discard':
@@ -2924,7 +2928,15 @@ export class Grid extends GridBase {
2924
2928
 
2925
2929
  if (this.container) this.Focus();
2926
2930
 
2927
- this.SetInferredType(this.primary_selection, event.value, event.array);
2931
+ if (event.event) {
2932
+ this.SetInferredType(this.primary_selection, event.value, event.array);
2933
+ }
2934
+ else {
2935
+ if (this.editing_selection) {
2936
+ this.SetInferredType(this.editing_selection, event.value, event.array);
2937
+ }
2938
+ }
2939
+
2928
2940
  this.ClearAdditionalSelections();
2929
2941
  this.ClearSelection(this.active_selection);
2930
2942