@trebco/treb 31.7.0 → 31.7.4
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
|
@@ -945,6 +945,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
945
945
|
|
|
946
946
|
switch (event.type) {
|
|
947
947
|
|
|
948
|
+
// these messages can stack, they don't have undo effect
|
|
949
|
+
|
|
948
950
|
case 'error':
|
|
949
951
|
this.dialog?.ShowDialog({
|
|
950
952
|
type: DialogType.error,
|
|
@@ -965,6 +967,34 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
965
967
|
this.UpdateSelectionStyle();
|
|
966
968
|
break;
|
|
967
969
|
|
|
970
|
+
case 'scale':
|
|
971
|
+
this.RebuildAllAnnotations();
|
|
972
|
+
this.Publish({ type: 'view-change' });
|
|
973
|
+
break;
|
|
974
|
+
|
|
975
|
+
case 'cell-event':
|
|
976
|
+
this.HandleCellEvent(event);
|
|
977
|
+
break;
|
|
978
|
+
|
|
979
|
+
// messages that trigger undo need some special handling,
|
|
980
|
+
// because we don't want to stack a sequence of messages
|
|
981
|
+
// and push multiple undo events. that applies to data,
|
|
982
|
+
// style, structure, and (maybe?) annotations
|
|
983
|
+
|
|
984
|
+
// OK, temp we have a composite event for data+style
|
|
985
|
+
|
|
986
|
+
case 'composite':
|
|
987
|
+
{
|
|
988
|
+
const cached_selection = this.last_selection;
|
|
989
|
+
if (this.calculation === CalculationOptions.automatic) {
|
|
990
|
+
this.Recalculate(event);
|
|
991
|
+
}
|
|
992
|
+
this.DocumentChange(cached_selection);
|
|
993
|
+
this.UpdateDocumentStyles();
|
|
994
|
+
this.UpdateSelectionStyle();
|
|
995
|
+
}
|
|
996
|
+
break;
|
|
997
|
+
|
|
968
998
|
case 'data':
|
|
969
999
|
{
|
|
970
1000
|
// because this is async (more than once), we can't expect the
|
|
@@ -973,13 +1003,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
973
1003
|
|
|
974
1004
|
const cached_selection = this.last_selection;
|
|
975
1005
|
|
|
976
|
-
/*
|
|
977
|
-
((this.calculation === CalculationOptions.automatic) ?
|
|
978
|
-
this.Recalculate(event) : Promise.resolve()).then(() => {
|
|
979
|
-
this.DocumentChange(cached_selection);
|
|
980
|
-
});
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
1006
|
// recalc is no longer async
|
|
984
1007
|
|
|
985
1008
|
if (this.calculation === CalculationOptions.automatic) {
|
|
@@ -988,17 +1011,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
988
1011
|
|
|
989
1012
|
this.DocumentChange(cached_selection);
|
|
990
1013
|
|
|
991
|
-
/*
|
|
992
|
-
if (this.calculation === CalculationOptions.automatic) {
|
|
993
|
-
this.Recalculate(event).then(() => {
|
|
994
|
-
this.DocumentChange(cached_selection);
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
else {
|
|
998
|
-
Promise.resolve().then(() => this.DocumentChange(cached_selection));
|
|
999
|
-
}
|
|
1000
|
-
*/
|
|
1001
|
-
|
|
1002
1014
|
}
|
|
1003
1015
|
break;
|
|
1004
1016
|
|
|
@@ -1008,11 +1020,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1008
1020
|
this.UpdateSelectionStyle();
|
|
1009
1021
|
break;
|
|
1010
1022
|
|
|
1011
|
-
case 'scale':
|
|
1012
|
-
this.RebuildAllAnnotations();
|
|
1013
|
-
this.Publish({ type: 'view-change' });
|
|
1014
|
-
break;
|
|
1015
|
-
|
|
1016
1023
|
case 'annotation':
|
|
1017
1024
|
// FIXME: maybe need to update vertices (on create, update, delete,
|
|
1018
1025
|
// not on move or resize)
|
|
@@ -1083,13 +1090,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1083
1090
|
if (event.rebuild_required) {
|
|
1084
1091
|
this.calculator.Reset();
|
|
1085
1092
|
|
|
1086
|
-
/*
|
|
1087
|
-
((this.calculation === CalculationOptions.automatic) ?
|
|
1088
|
-
this.Recalculate(event) : Promise.resolve()).then(() => {
|
|
1089
|
-
this.DocumentChange(cached_selection);
|
|
1090
|
-
});
|
|
1091
|
-
*/
|
|
1092
|
-
|
|
1093
1093
|
// recalculate is no longer async
|
|
1094
1094
|
|
|
1095
1095
|
if (this.calculation === CalculationOptions.automatic) {
|
|
@@ -1105,10 +1105,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1105
1105
|
this.UpdateSelectionStyle();
|
|
1106
1106
|
break;
|
|
1107
1107
|
|
|
1108
|
-
case 'cell-event':
|
|
1109
|
-
this.HandleCellEvent(event);
|
|
1110
|
-
break;
|
|
1111
|
-
|
|
1112
1108
|
}
|
|
1113
1109
|
});
|
|
1114
1110
|
|
|
@@ -5924,6 +5920,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5924
5920
|
const selection = last_selection || this.last_selection;
|
|
5925
5921
|
|
|
5926
5922
|
// console.info('push undo', JSON.stringify(selection));
|
|
5923
|
+
// console.trace();
|
|
5927
5924
|
|
|
5928
5925
|
if (this.undo_stack[this.undo_pointer - 1]) {
|
|
5929
5926
|
this.undo_stack[this.undo_pointer - 1].selection = selection;
|
|
@@ -6479,12 +6476,15 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
6479
6476
|
*/
|
|
6480
6477
|
protected HandleKeyDown(event: KeyboardEvent): void {
|
|
6481
6478
|
|
|
6482
|
-
//
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
event.
|
|
6487
|
-
|
|
6479
|
+
// handle osx properly, but leave the old combination on osx
|
|
6480
|
+
// in case anyone is using it. we can maybe drop it in the future
|
|
6481
|
+
|
|
6482
|
+
if (event.key === 'z') {
|
|
6483
|
+
if ((UA.is_mac && event.metaKey) || event.ctrlKey) {
|
|
6484
|
+
event.stopPropagation();
|
|
6485
|
+
event.preventDefault();
|
|
6486
|
+
this.Undo();
|
|
6487
|
+
}
|
|
6488
6488
|
}
|
|
6489
6489
|
else if (event.key === 'F9' && this.options.recalculate_on_f9) {
|
|
6490
6490
|
event.stopPropagation();
|
|
@@ -51,7 +51,7 @@ import type { FunctionDescriptor} from '../editors/autocomplete_matcher';
|
|
|
51
51
|
import { AutocompleteMatcher } from '../editors/autocomplete_matcher';
|
|
52
52
|
import { NumberFormat, ValueParser } from 'treb-format';
|
|
53
53
|
|
|
54
|
-
import type { GridEvent } from './grid_events';
|
|
54
|
+
import type { DataEvent, GridEvent, StyleEvent } from './grid_events';
|
|
55
55
|
import { ErrorCode } from './grid_events';
|
|
56
56
|
import type { CommandRecord, CreateAnnotationCommand, DataValidationCommand, DuplicateSheetCommand, FreezeCommand, InsertColumnsCommand, InsertRowsCommand, RemoveAnnotationCommand, ResizeColumnsCommand, ResizeRowsCommand, SelectCommand, SetRangeCommand, ShowSheetCommand, SortTableCommand } from './grid_command';
|
|
57
57
|
import { DefaultGridOptions, type GridOptions } from './grid_options';
|
|
@@ -4525,24 +4525,47 @@ export class GridBase {
|
|
|
4525
4525
|
|
|
4526
4526
|
// consolidate events and merge areas
|
|
4527
4527
|
|
|
4528
|
+
let data_event: DataEvent|undefined;
|
|
4529
|
+
let style_event: StyleEvent|undefined;
|
|
4530
|
+
|
|
4528
4531
|
if (flags.data_area) {
|
|
4529
4532
|
if (!flags.data_area.start.sheet_id) {
|
|
4530
4533
|
flags.data_area.SetSheetID(this.active_sheet.id);
|
|
4531
4534
|
}
|
|
4532
|
-
events.push({ type: 'data', area: flags.data_area });
|
|
4535
|
+
// events.push({ type: 'data', area: flags.data_area });
|
|
4536
|
+
data_event = { type: 'data', area: flags.data_area };
|
|
4533
4537
|
}
|
|
4534
4538
|
else if (flags.data_event) {
|
|
4535
|
-
events.push({ type: 'data' });
|
|
4539
|
+
// events.push({ type: 'data' });
|
|
4540
|
+
data_event = { type: 'data' };
|
|
4536
4541
|
}
|
|
4537
4542
|
|
|
4538
4543
|
if (flags.style_area) {
|
|
4539
4544
|
if (!flags.style_area.start.sheet_id) {
|
|
4540
4545
|
flags.style_area.SetSheetID(this.active_sheet.id);
|
|
4541
4546
|
}
|
|
4542
|
-
events.push({ type: 'style', area: flags.style_area });
|
|
4547
|
+
// events.push({ type: 'style', area: flags.style_area });
|
|
4548
|
+
style_event = { type: 'style', area: flags.style_area };
|
|
4543
4549
|
}
|
|
4544
4550
|
else if (flags.style_event) {
|
|
4545
|
-
events.push({ type: 'style' });
|
|
4551
|
+
// events.push({ type: 'style' });
|
|
4552
|
+
style_event = { type: 'style' };
|
|
4553
|
+
}
|
|
4554
|
+
|
|
4555
|
+
if (data_event && style_event) {
|
|
4556
|
+
events.push({
|
|
4557
|
+
type: 'composite',
|
|
4558
|
+
data_area: data_event.area,
|
|
4559
|
+
style_area: style_event.area,
|
|
4560
|
+
});
|
|
4561
|
+
}
|
|
4562
|
+
else {
|
|
4563
|
+
if (data_event) {
|
|
4564
|
+
events.push(data_event);
|
|
4565
|
+
}
|
|
4566
|
+
if (style_event) {
|
|
4567
|
+
events.push(style_event);
|
|
4568
|
+
}
|
|
4546
4569
|
}
|
|
4547
4570
|
|
|
4548
4571
|
if (flags.structure_event) {
|
|
@@ -112,6 +112,15 @@ export interface CellEvent {
|
|
|
112
112
|
data?: HyperlinkCellEventData;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* data + style. temporary while I figure out a better solution.
|
|
117
|
+
*/
|
|
118
|
+
export interface CompositeEvent {
|
|
119
|
+
type: 'composite';
|
|
120
|
+
data_area?: Area;
|
|
121
|
+
style_area?: Area;
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
export interface DataEvent {
|
|
116
125
|
type: 'data';
|
|
117
126
|
area?: Area;
|
|
@@ -137,6 +146,7 @@ export type GridEvent
|
|
|
137
146
|
| StyleEvent
|
|
138
147
|
| FlushEvent
|
|
139
148
|
| ScaleEvent
|
|
149
|
+
| CompositeEvent
|
|
140
150
|
| GridErrorEvent
|
|
141
151
|
| StructureEvent
|
|
142
152
|
| AnnotationEvent
|