@trebco/treb 27.11.1 → 27.12.0
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/dist/treb.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -565,12 +565,33 @@ export class EmbeddedSpreadsheet {
|
|
|
565
565
|
// this one should not be done for a split view, but we should still
|
|
566
566
|
// do it if the toll flag is set, and storage key is set.
|
|
567
567
|
|
|
568
|
+
// FIXME: shouldn't this gate on dirty? (...)
|
|
569
|
+
// ALSO: check if we can use a different event. see
|
|
570
|
+
//
|
|
571
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event#usage_notes
|
|
572
|
+
//
|
|
573
|
+
// and, including the alternatives:
|
|
574
|
+
//
|
|
575
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
|
|
576
|
+
//
|
|
577
|
+
|
|
568
578
|
if (this.options.local_storage && !options.model ) {
|
|
579
|
+
|
|
580
|
+
window.addEventListener('visibilitychange', event => {
|
|
581
|
+
if (document.visibilityState === 'hidden') {
|
|
582
|
+
if (this.options.local_storage && this.dirty) {
|
|
583
|
+
this.SaveLocalStorage(this.options.local_storage);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
/*
|
|
569
589
|
window.addEventListener('beforeunload', () => {
|
|
570
|
-
if (this.options.local_storage) {
|
|
590
|
+
if (this.options.local_storage && this.dirty) {
|
|
571
591
|
this.SaveLocalStorage(this.options.local_storage);
|
|
572
592
|
}
|
|
573
593
|
});
|
|
594
|
+
*/
|
|
574
595
|
}
|
|
575
596
|
|
|
576
597
|
let container: HTMLElement | undefined;
|
|
@@ -807,6 +828,7 @@ export class EmbeddedSpreadsheet {
|
|
|
807
828
|
|
|
808
829
|
case 'scale':
|
|
809
830
|
this.RebuildAllAnnotations();
|
|
831
|
+
this.events.Publish({ type: 'view-change' });
|
|
810
832
|
break;
|
|
811
833
|
|
|
812
834
|
case 'annotation':
|
|
@@ -5077,9 +5099,27 @@ export class EmbeddedSpreadsheet {
|
|
|
5077
5099
|
|
|
5078
5100
|
// console.info(json);
|
|
5079
5101
|
|
|
5102
|
+
// why are we saving this here? and should we not route
|
|
5103
|
+
// through the method? I guess the question should be, is
|
|
5104
|
+
// the visibilitychange handler not sufficient to save the
|
|
5105
|
+
// file? (...)
|
|
5106
|
+
|
|
5107
|
+
// I would prefer to just save once, on visibilitychange -> hidden.
|
|
5108
|
+
// the problem is that this method gets called on "data" events,
|
|
5109
|
+
// which should not trigger saving. we could check the flag?
|
|
5110
|
+
|
|
5111
|
+
// if this does come back, (1) use a method -- maybe split the
|
|
5112
|
+
// SaveLocalStorage method in two, and call the inner half (because
|
|
5113
|
+
// we've already serialized); and (2) gate on dirty.
|
|
5114
|
+
|
|
5115
|
+
// but for the time being we're removing it.
|
|
5116
|
+
|
|
5117
|
+
/*
|
|
5080
5118
|
if (this.options.local_storage) {
|
|
5081
5119
|
localStorage.setItem(this.options.local_storage, json);
|
|
5082
5120
|
}
|
|
5121
|
+
*/
|
|
5122
|
+
|
|
5083
5123
|
if (this.options.undo) {
|
|
5084
5124
|
this.PushUndo(json, undo_selection, false);
|
|
5085
5125
|
}
|
package/treb-embed/src/types.ts
CHANGED
|
@@ -122,6 +122,20 @@ export enum LoadType {
|
|
|
122
122
|
XLSX = 'xlsx',
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* This event is sent when the view changes -- at the moment, that only
|
|
127
|
+
* means the view scale has been changed. We might use it in the future
|
|
128
|
+
* for other things.
|
|
129
|
+
*
|
|
130
|
+
* @privateRemarks
|
|
131
|
+
* not sure if this should be combined with resize -- the only reason it's
|
|
132
|
+
* not is because resize implies some structural/layout changes that require
|
|
133
|
+
* changing the document, but scale does not. open to suggestions though.
|
|
134
|
+
*/
|
|
135
|
+
export interface ViewChangeEvent {
|
|
136
|
+
type: 'view-change';
|
|
137
|
+
}
|
|
138
|
+
|
|
125
139
|
/**
|
|
126
140
|
* This event is sent when a document is loaded, and also on undo. The
|
|
127
141
|
* source field can help determine if it was triggered by an undo operation.
|
|
@@ -90,6 +90,15 @@
|
|
|
90
90
|
white-space: nowrap;
|
|
91
91
|
position: relative;
|
|
92
92
|
// -webkit-user-modify: read-write;
|
|
93
|
+
|
|
94
|
+
// this fixes the firefox issue (firefox removing spaces), but
|
|
95
|
+
// I'm not sure if it will cause other problems. for the overlay
|
|
96
|
+
// editor we're trapping CR, so it shouldn't be a typing problem --
|
|
97
|
+
// it might be an issue on paste though. also need to check safari
|
|
98
|
+
// with pre here.
|
|
99
|
+
|
|
100
|
+
white-space: pre;
|
|
101
|
+
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
/** fix for firefox layout bug */
|
|
@@ -1113,6 +1113,35 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
|
|
|
1113
1113
|
|
|
1114
1114
|
const Consume = (element: Node, range: Range) => {
|
|
1115
1115
|
|
|
1116
|
+
// it only seems to happen in firefox, but sometimes we'll get
|
|
1117
|
+
// a non-text node that is the start container and endcontainer.
|
|
1118
|
+
//
|
|
1119
|
+
// in that case we need to interpret the endOffset as nodes, not
|
|
1120
|
+
// characters. that's what's causing the firefox issues. I guess
|
|
1121
|
+
// that applies to startoffset as well?
|
|
1122
|
+
|
|
1123
|
+
// not sure if this is bugged or what but when we hit this case,
|
|
1124
|
+
// it's always "all the text in there" regardless of the offsets.
|
|
1125
|
+
// not sure what the offsets are even referring to, since we get
|
|
1126
|
+
// offsets > the number of child nodes. is this a bug in firefox?
|
|
1127
|
+
|
|
1128
|
+
if (element === range.startContainer && element === range.endContainer && !(element instanceof Text)) {
|
|
1129
|
+
|
|
1130
|
+
/*
|
|
1131
|
+
if (range.startOffset !== 0 || range.endOffset !== 0) {
|
|
1132
|
+
console.info("warn offset", range.startOffset, range.endOffset);
|
|
1133
|
+
console.info(element);
|
|
1134
|
+
}
|
|
1135
|
+
*/
|
|
1136
|
+
|
|
1137
|
+
complete[0] = complete[1] = true;
|
|
1138
|
+
|
|
1139
|
+
result[0] += element.textContent;
|
|
1140
|
+
result[1] += element.textContent;
|
|
1141
|
+
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1116
1145
|
if (element === range.startContainer) {
|
|
1117
1146
|
result[0] += (element.textContent || '').substring(0, range.startOffset);
|
|
1118
1147
|
complete[0] = true;
|