@trebco/treb 27.12.2 → 28.2.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/README.md +6 -0
- package/dist/treb-spreadsheet-light.mjs +16 -0
- package/dist/treb-spreadsheet.mjs +13 -11
- package/dist/treb.d.ts +33 -5
- package/esbuild-custom-element.mjs +3 -1
- package/package.json +8 -6
- package/treb-base-types/src/dom-utilities.ts +157 -19
- package/treb-base-types/src/import.ts +1 -0
- package/treb-base-types/src/theme.ts +5 -4
- package/treb-charts/src/renderer.ts +4 -58
- package/treb-embed/markup/layout.html +4 -0
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +131 -87
- package/treb-embed/src/embedded-spreadsheet.ts +153 -140
- package/treb-embed/src/options.ts +9 -0
- package/treb-embed/src/spinner.ts +5 -3
- package/treb-embed/src/toolbar-message.ts +5 -0
- package/treb-embed/style/layout.scss +65 -1
- package/treb-export/src/export-worker/export-worker.ts +7 -12
- package/treb-export/src/export2.ts +57 -33
- package/treb-export/src/import2.ts +61 -21
- package/treb-export/src/workbook2.ts +69 -24
- package/treb-export/src/zip-wrapper.ts +96 -0
- package/treb-grid/src/editors/autocomplete.ts +24 -13
- package/treb-grid/src/editors/editor.ts +43 -139
- package/treb-grid/src/editors/external_editor.ts +1 -1
- package/treb-grid/src/editors/formula_bar.ts +24 -24
- package/treb-grid/src/editors/overlay_editor.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +34 -25
- package/treb-grid/src/layout/grid_layout.ts +20 -20
- package/treb-grid/src/render/selection-renderer.ts +3 -3
- package/treb-grid/src/render/svg_header_overlay.ts +6 -4
- package/treb-grid/src/render/svg_selection_block.ts +10 -7
- package/treb-grid/src/types/annotation.ts +2 -2
- package/treb-grid/src/types/grid.ts +80 -81
- package/treb-grid/src/types/scale-control.ts +69 -81
- package/treb-grid/src/types/sheet.ts +3 -52
- package/treb-grid/src/types/tab_bar.ts +27 -13
- package/treb-grid/src/util/fontmetrics2.ts +24 -21
- package/treb-utils/src/event_source.ts +23 -23
- package/treb-utils/src/index.ts +2 -2
- package/treb-utils/src/measurement.ts +24 -24
- package/treb-utils/src/serialize_html.ts +25 -21
- package/treb-utils/src/dispatch.ts +0 -57
- package/treb-utils/src/resizable.ts +0 -159
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import { DOMContext } from 'treb-base-types';
|
|
23
23
|
import { NumberFormat, NumberFormatCache, ValueParser } from 'treb-format';
|
|
24
24
|
import { ValueType } from 'treb-base-types';
|
|
25
25
|
import { EventSource } from 'treb-utils';
|
|
26
26
|
|
|
27
27
|
export interface ScaleEvent {
|
|
28
28
|
type: 'scale';
|
|
29
|
-
// action: 'increase'|'decrease'|number;
|
|
30
29
|
value: number;
|
|
31
30
|
keep_focus?: boolean;
|
|
32
31
|
}
|
|
@@ -50,106 +49,98 @@ export class ScaleControl extends EventSource<ScaleEvent> {
|
|
|
50
49
|
|
|
51
50
|
this.format = NumberFormatCache.Get('0.0');
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
// const div = DOM.CreateDiv('treb-scale-control-2', container);
|
|
52
|
+
const DOM = DOMContext.GetInstance(container.ownerDocument);
|
|
55
53
|
|
|
56
|
-
this.input = DOM.Create('input', 'treb-scale-input',
|
|
57
|
-
|
|
54
|
+
this.input = DOM.Create('input', 'treb-scale-input', container, {
|
|
55
|
+
events: {
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
switch (event.key) {
|
|
62
|
-
case 'ArrowUp':
|
|
63
|
-
case 'ArrowDown':
|
|
64
|
-
event.stopPropagation();
|
|
65
|
-
event.preventDefault();
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
// is this for some x-browser issue? or did we just not
|
|
72
|
-
// know which event to use and this is old junk?
|
|
57
|
+
// is this for some x-browser issue? or did we just not
|
|
58
|
+
// know which event to use and this is old junk?
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
keypress: (event) => {
|
|
61
|
+
switch (event.key) {
|
|
62
|
+
case 'ArrowUp':
|
|
63
|
+
case 'ArrowDown':
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
console.info('mark?');
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
84
70
|
|
|
85
|
-
|
|
71
|
+
keydown: (event) => {
|
|
86
72
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
break;
|
|
73
|
+
switch (event.key) {
|
|
74
|
+
case 'Enter':
|
|
75
|
+
this.input.blur();
|
|
76
|
+
break;
|
|
92
77
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
case 'ArrowUp':
|
|
79
|
+
this.Tick(-1);
|
|
80
|
+
break;
|
|
96
81
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
case 'ArrowDown':
|
|
83
|
+
this.Tick(1);
|
|
84
|
+
break;
|
|
100
85
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
case 'Escape':
|
|
87
|
+
this.input.value = this.format.Format(this.scale) + '%';
|
|
88
|
+
this.input.blur();
|
|
89
|
+
break;
|
|
105
90
|
|
|
106
|
-
|
|
107
|
-
|
|
91
|
+
default:
|
|
92
|
+
return;
|
|
108
93
|
|
|
109
|
-
|
|
94
|
+
}
|
|
110
95
|
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
event.stopPropagation();
|
|
97
|
+
event.preventDefault();
|
|
113
98
|
|
|
114
|
-
|
|
99
|
+
},
|
|
115
100
|
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
// select text on click
|
|
102
|
+
focusin: () => this.input.select(),
|
|
118
103
|
|
|
119
|
-
|
|
104
|
+
change: () => {
|
|
120
105
|
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
// what we're doing here is a little unusual. we always treat
|
|
107
|
+
// the value as a percent, even if there's no percent sign.
|
|
123
108
|
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
// for that to work, if there is a percent sign, we need to remove
|
|
110
|
+
// it before we continue. then try to parse as a number.
|
|
126
111
|
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
let text = this.input.value;
|
|
113
|
+
text = text.replace(/%/g, '');
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
115
|
+
const value = ValueParser.TryParse(text);
|
|
116
|
+
if (value.type === ValueType.number) {
|
|
117
|
+
this.UpdateScale(Number(value.value), true);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.input.value = this.format.Format(this.scale) + '%';
|
|
121
|
+
}
|
|
137
122
|
|
|
138
|
-
|
|
123
|
+
},
|
|
139
124
|
|
|
140
|
-
|
|
141
|
-
type: 'range',
|
|
142
|
-
min: '50',
|
|
143
|
-
max: '200',
|
|
144
|
-
value: '100',
|
|
145
|
-
step: '2.5',
|
|
125
|
+
}
|
|
146
126
|
});
|
|
147
127
|
|
|
148
|
-
|
|
149
|
-
|
|
128
|
+
const popup = DOM.Div('treb-slider-container', container);
|
|
129
|
+
|
|
130
|
+
this.slider = DOM.Create('input', undefined, popup, {
|
|
131
|
+
attrs: {
|
|
132
|
+
type: 'range',
|
|
133
|
+
min: '50',
|
|
134
|
+
max: '200',
|
|
135
|
+
value: '100',
|
|
136
|
+
step: '2.5',
|
|
137
|
+
},
|
|
138
|
+
events: {
|
|
139
|
+
input: () => this.UpdateScale(Number(this.slider.value), true),
|
|
140
|
+
}
|
|
150
141
|
});
|
|
151
142
|
|
|
152
|
-
|
|
143
|
+
container.addEventListener('wheel', (event: WheelEvent) => {
|
|
153
144
|
event.stopPropagation();
|
|
154
145
|
event.preventDefault();
|
|
155
146
|
this.Tick(event.deltaY)
|
|
@@ -159,9 +150,6 @@ export class ScaleControl extends EventSource<ScaleEvent> {
|
|
|
159
150
|
|
|
160
151
|
public Tick(value: number): void {
|
|
161
152
|
|
|
162
|
-
// not sure what alternate case I am worried about here,
|
|
163
|
-
// sideways wheel? shift key?
|
|
164
|
-
|
|
165
153
|
// normalize
|
|
166
154
|
|
|
167
155
|
const scale = Math.round(this.scale / 2.5) * 2.5;
|
|
@@ -26,7 +26,7 @@ import { ValueType, Cells, Style,
|
|
|
26
26
|
type PropertyKeys,
|
|
27
27
|
type Color,
|
|
28
28
|
Area, IsFlatDataArray,
|
|
29
|
-
IsNestedRowArray, IsCellAddress,
|
|
29
|
+
IsNestedRowArray, IsCellAddress, DOMContext
|
|
30
30
|
} from 'treb-base-types';
|
|
31
31
|
import { NumberFormatCache } from 'treb-format';
|
|
32
32
|
import { Measurement, ValidateURI } from 'treb-utils';
|
|
@@ -741,14 +741,14 @@ export class Sheet {
|
|
|
741
741
|
}
|
|
742
742
|
|
|
743
743
|
|
|
744
|
-
public Activate() {
|
|
744
|
+
public Activate(DOM: DOMContext) {
|
|
745
745
|
|
|
746
746
|
// load background image, if set
|
|
747
747
|
|
|
748
748
|
if (this.background_image) {
|
|
749
749
|
const resource = ValidateURI(this.background_image);
|
|
750
750
|
if (resource) {
|
|
751
|
-
this._image =
|
|
751
|
+
this._image = DOM.Create('img');
|
|
752
752
|
this._image.src = resource;
|
|
753
753
|
}
|
|
754
754
|
|
|
@@ -1592,55 +1592,6 @@ export class Sheet {
|
|
|
1592
1592
|
|
|
1593
1593
|
}
|
|
1594
1594
|
|
|
1595
|
-
/* *
|
|
1596
|
-
* auto-sizes the column, but if the allow_shrink parameter is not set
|
|
1597
|
-
* it will only enlarge, never shrink the column.
|
|
1598
|
-
*
|
|
1599
|
-
* UPDATE: since the only caller calls with inline = true, removing
|
|
1600
|
-
* parameter, test, and extra behavior.
|
|
1601
|
-
*
|
|
1602
|
-
* UPDATE: moving to grid, for reasons of canvas...
|
|
1603
|
-
* /
|
|
1604
|
-
public AutoSizeColumn(column: number, allow_shrink = true): void {
|
|
1605
|
-
|
|
1606
|
-
if (!Sheet.measurement_canvas) {
|
|
1607
|
-
Sheet.measurement_canvas = document.createElement('canvas');
|
|
1608
|
-
}
|
|
1609
|
-
Sheet.measurement_canvas.style.font = Style.Font(this.default_style_properties);
|
|
1610
|
-
console.info("SMC", Sheet.measurement_canvas.style.font);
|
|
1611
|
-
(self as any).SMC = Sheet.measurement_canvas;
|
|
1612
|
-
|
|
1613
|
-
document
|
|
1614
|
-
|
|
1615
|
-
const context = Sheet.measurement_canvas.getContext('2d');
|
|
1616
|
-
if (!context) return;
|
|
1617
|
-
|
|
1618
|
-
let width = 12;
|
|
1619
|
-
const padding = 4 * 2; // FIXME: parameterize
|
|
1620
|
-
|
|
1621
|
-
if (!allow_shrink) width = this.GetColumnWidth(column);
|
|
1622
|
-
|
|
1623
|
-
for (let row = 0; row < this.cells.rows; row++) {
|
|
1624
|
-
const cell = this.CellData({ row, column });
|
|
1625
|
-
let text = cell.formatted || '';
|
|
1626
|
-
if (typeof text !== 'string') {
|
|
1627
|
-
text = text.map((part) => part.text).join('');
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
if (text && text.length) {
|
|
1631
|
-
context.font = Style.Font(cell.style || {});
|
|
1632
|
-
|
|
1633
|
-
console.info({text, style: Style.Font(cell.style||{}), cf: context.font});
|
|
1634
|
-
|
|
1635
|
-
width = Math.max(width, Math.ceil(context.measureText(text).width) + padding);
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
this.SetColumnWidth(column, width);
|
|
1640
|
-
|
|
1641
|
-
}
|
|
1642
|
-
*/
|
|
1643
|
-
|
|
1644
1595
|
/** returns the style properties for a given style index */
|
|
1645
1596
|
public GetStyle(index: number): CellStyle {
|
|
1646
1597
|
return this.style_map[index];
|
|
@@ -26,7 +26,7 @@ import type { BaseLayout } from '../layout/base_layout';
|
|
|
26
26
|
import { MouseDrag } from './drag_mask';
|
|
27
27
|
import type { GridOptions } from './grid_options';
|
|
28
28
|
import { type ScaleEvent, ScaleControl } from './scale-control';
|
|
29
|
-
import {
|
|
29
|
+
import { DOMContext } from 'treb-base-types';
|
|
30
30
|
|
|
31
31
|
export interface ActivateSheetEvent {
|
|
32
32
|
type: 'activate-sheet';
|
|
@@ -113,17 +113,22 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
113
113
|
this.stats_panel.innerText = ''; // clear
|
|
114
114
|
for (const entry of value) {
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
this.DOM.Create('span', 'treb-stats-label', this.stats_panel, {
|
|
117
|
+
text: entry.label
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
this.DOM.Create('span', 'treb-stats-value', this.stats_panel, {
|
|
121
|
+
text: entry.value,
|
|
122
|
+
});
|
|
118
123
|
|
|
119
|
-
const figure = DOMUtilities.Create('span', 'treb-stats-value', this.stats_panel);
|
|
120
|
-
figure.textContent = entry.value;
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
private container: HTMLElement;
|
|
126
129
|
|
|
130
|
+
private DOM: DOMContext;
|
|
131
|
+
|
|
127
132
|
constructor(
|
|
128
133
|
private layout: BaseLayout,
|
|
129
134
|
private model: DataModel,
|
|
@@ -135,6 +140,8 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
135
140
|
|
|
136
141
|
super();
|
|
137
142
|
|
|
143
|
+
this.DOM = DOMContext.GetInstance(view_node.ownerDocument);
|
|
144
|
+
|
|
138
145
|
this.container = view_node.querySelector('.treb-spreadsheet-footer') as HTMLElement;
|
|
139
146
|
if (!this.container) {
|
|
140
147
|
throw new Error('missing container for tab bar');
|
|
@@ -195,6 +202,10 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
195
202
|
clearTimeout(this.double_click_data.timeout);
|
|
196
203
|
}
|
|
197
204
|
this.double_click_data.index = index;
|
|
205
|
+
|
|
206
|
+
// I don't think the window instance matters for this,
|
|
207
|
+
// but perhaps it's worth using DOM just for consistency
|
|
208
|
+
|
|
198
209
|
this.double_click_data.timeout = window.setTimeout(() => {
|
|
199
210
|
this.double_click_data.index = undefined;
|
|
200
211
|
this.double_click_data.timeout = undefined;
|
|
@@ -242,14 +253,17 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
242
253
|
|
|
243
254
|
tab.contentEditable = 'true';
|
|
244
255
|
|
|
245
|
-
|
|
246
|
-
|
|
256
|
+
if (this.DOM.doc) {
|
|
257
|
+
|
|
258
|
+
const selection = this.DOM.GetSelection();
|
|
259
|
+
|
|
260
|
+
if (selection) {
|
|
261
|
+
selection.removeAllRanges();
|
|
262
|
+
const range = this.DOM.doc.createRange();
|
|
263
|
+
range.selectNodeContents(tab);
|
|
264
|
+
selection.addRange(range);
|
|
265
|
+
}
|
|
247
266
|
|
|
248
|
-
if (selection) {
|
|
249
|
-
selection.removeAllRanges();
|
|
250
|
-
const range = document.createRange();
|
|
251
|
-
range.selectNodeContents(tab);
|
|
252
|
-
selection.addRange(range);
|
|
253
267
|
}
|
|
254
268
|
|
|
255
269
|
tab.addEventListener('keydown', (inner_event: KeyboardEvent) => {
|
|
@@ -448,7 +462,7 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
448
462
|
if (!sheet.visible) { continue; }
|
|
449
463
|
|
|
450
464
|
const index = tabs.length;
|
|
451
|
-
const tab =
|
|
465
|
+
const tab = this.DOM.Create('li');
|
|
452
466
|
tab.setAttribute('tabindex', '0');
|
|
453
467
|
|
|
454
468
|
// tab.classList.add('tab');
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
22
|
export interface FontMetrics2 {
|
|
23
23
|
ascender: number;
|
|
24
24
|
descender: number;
|
|
@@ -63,6 +63,9 @@ export class FontMetricsFactory {
|
|
|
63
63
|
// what we're doing now is calculating -- we get the base size
|
|
64
64
|
// from theme and if we see em or % we scale manually.
|
|
65
65
|
|
|
66
|
+
// based on the above, we don't need to worry about which
|
|
67
|
+
// document we're using. but we probably should just to be consistent.
|
|
68
|
+
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
/* *
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { Yield } from './dispatch';
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// import { Yield } from './dispatch';
|
|
23
23
|
// import { IEventSource } from './ievent_source';
|
|
24
24
|
|
|
25
25
|
let subscription_token_generator = 1000;
|
|
@@ -90,7 +90,7 @@ export class EventSource<T> { // implements IEventSource<T> {
|
|
|
90
90
|
if (!this.dispatched) {
|
|
91
91
|
this.dispatched = true;
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
Promise.resolve().then(() => {
|
|
94
94
|
|
|
95
95
|
const events = this.queue.slice(0);
|
|
96
96
|
this.dispatched = false;
|
package/treb-utils/src/index.ts
CHANGED
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
export * from './dispatch';
|
|
22
|
+
// export * from './dispatch';
|
|
23
23
|
export * from './event_source';
|
|
24
24
|
export * from './ievent_source';
|
|
25
|
-
export * from './resizable';
|
|
25
|
+
// export * from './resizable';
|
|
26
26
|
export * from './measurement';
|
|
27
27
|
// export * from './color';
|
|
28
28
|
export * from './serialize_html';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
22
|
/** size, really */
|
|
23
23
|
export interface Metrics {
|
|
24
24
|
width: number;
|
|
@@ -120,7 +120,7 @@ export class Measurement {
|
|
|
120
120
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
/* *
|
|
124
124
|
* check if font is loaded, based on the theory that the alternatives
|
|
125
125
|
* will be different sizes. note that this probably doesn't test weights
|
|
126
126
|
* or italics properly, as those can be emulated without the specific face.
|
|
@@ -131,7 +131,7 @@ export class Measurement {
|
|
|
131
131
|
* @param font_face
|
|
132
132
|
* @param italic
|
|
133
133
|
* @param bold
|
|
134
|
-
|
|
134
|
+
* /
|
|
135
135
|
public static FontLoaded(font_face: string, italic = false, weight = 400): boolean {
|
|
136
136
|
const face = `${italic ? 'italic' : ''} ${weight} 20pt ${font_face}`;
|
|
137
137
|
const m1 = this.MeasureText(`${face}, sans-serif`, `check font`);
|
|
@@ -139,6 +139,7 @@ export class Measurement {
|
|
|
139
139
|
const m3 = this.MeasureText(`${face}, monospace`, `check font`);
|
|
140
140
|
return (m1.width === m2.width && m2.width === m3.width);
|
|
141
141
|
}
|
|
142
|
+
*/
|
|
142
143
|
|
|
143
144
|
/**
|
|
144
145
|
* measure width, height of text, accounting for rotation
|
|
@@ -169,6 +170,5 @@ export class Measurement {
|
|
|
169
170
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
22
|
interface StringMap {
|
|
23
23
|
[index: string]: string;
|
|
24
24
|
}
|
|
@@ -95,6 +95,10 @@ export const SerializeHTML = (node: Element) => {
|
|
|
95
95
|
|
|
96
96
|
const defaults: StringMap = {};
|
|
97
97
|
|
|
98
|
+
// regarding document, in this case we're creating an iframe
|
|
99
|
+
// specifically for isolation, and adding it to "document".
|
|
100
|
+
// there's no reason to require the context document here (I think).
|
|
101
|
+
|
|
98
102
|
const iframe = document.createElement('iframe');
|
|
99
103
|
iframe.style.width = '10px';
|
|
100
104
|
iframe.style.height = '10px';
|