@trebco/treb 27.7.6 → 27.11.1
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-spreadsheet.mjs +14 -14
- package/dist/treb.d.ts +28 -26
- package/notes/conditional-fomratring.md +29 -0
- package/package.json +1 -1
- package/treb-base-types/src/area.ts +181 -0
- package/{treb-grid/src/util/dom_utilities.ts → treb-base-types/src/dom-utilities.ts} +29 -20
- package/treb-base-types/src/evaluate-options.ts +21 -0
- package/treb-base-types/src/gradient.ts +97 -0
- package/treb-base-types/src/import.ts +2 -1
- package/treb-base-types/src/index.ts +3 -0
- package/treb-base-types/src/theme.ts +3 -5
- package/treb-calculator/src/calculator.ts +190 -28
- package/treb-calculator/src/dag/calculation_leaf_vertex.ts +97 -0
- package/treb-calculator/src/dag/graph.ts +10 -22
- package/treb-calculator/src/dag/{leaf_vertex.ts → state_leaf_vertex.ts} +3 -3
- package/treb-calculator/src/descriptors.ts +10 -3
- package/treb-calculator/src/expression-calculator.ts +1 -1
- package/treb-calculator/src/function-library.ts +25 -22
- package/treb-calculator/src/functions/base-functions.ts +166 -5
- package/treb-calculator/src/index.ts +6 -6
- package/treb-calculator/src/notifier-types.ts +1 -1
- package/treb-calculator/src/utilities.ts +2 -2
- package/treb-charts/src/util.ts +2 -2
- package/treb-embed/src/custom-element/global.d.ts +3 -1
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +13 -19
- package/treb-embed/src/embedded-spreadsheet.ts +378 -132
- package/treb-embed/src/spinner.ts +3 -3
- package/treb-embed/style/layout.scss +1 -1
- package/treb-export/src/drawing2/chart2.ts +11 -2
- package/treb-export/src/export-worker/export-worker.ts +0 -13
- package/treb-export/src/export2.ts +197 -2
- package/treb-export/src/import2.ts +169 -4
- package/treb-export/src/workbook-style2.ts +59 -10
- package/treb-export/src/workbook2.ts +10 -1
- package/treb-grid/src/editors/autocomplete.ts +28 -24
- package/treb-grid/src/editors/editor.ts +3 -4
- package/treb-grid/src/editors/formula_bar.ts +1 -1
- package/treb-grid/src/index.ts +2 -1
- package/treb-grid/src/layout/base_layout.ts +34 -31
- package/treb-grid/src/layout/grid_layout.ts +17 -28
- package/treb-grid/src/render/selection-renderer.ts +2 -3
- package/treb-grid/src/render/svg_header_overlay.ts +4 -11
- package/treb-grid/src/render/svg_selection_block.ts +27 -34
- package/treb-grid/src/render/tile_renderer.ts +8 -6
- package/treb-grid/src/types/conditional_format.ts +168 -0
- package/treb-grid/src/types/grid.ts +37 -47
- package/treb-grid/src/types/grid_base.ts +188 -33
- package/treb-grid/src/types/scale-control.ts +2 -2
- package/treb-grid/src/types/sheet.ts +332 -28
- package/treb-grid/src/types/sheet_types.ts +4 -0
- package/treb-grid/src/types/tab_bar.ts +4 -8
- package/treb-utils/src/index.ts +0 -1
- package/treb-utils/src/resizable.ts +26 -27
- package/treb-utils/src/template.ts +0 -70
- /package/{README-shadow-DOM.md → notes/shadow-DOM.md} +0 -0
|
@@ -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 { DOMUtilities } from '
|
|
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 { DOMUtilities } from 'treb-base-types';
|
|
23
23
|
import type { Theme, Rectangle } from 'treb-base-types';
|
|
24
24
|
import type { AutocompleteExecResult, DescriptorType } from './autocomplete_matcher';
|
|
25
25
|
|
|
@@ -76,7 +76,7 @@ export class Autocomplete {
|
|
|
76
76
|
|
|
77
77
|
// this.scope = 'AC' + Math.round(Math.random() * Math.pow(10, 10)).toString(16);
|
|
78
78
|
|
|
79
|
-
this.completion_list = DOMUtilities.
|
|
79
|
+
this.completion_list = DOMUtilities.Div(
|
|
80
80
|
'treb-cell-editor-ac-list treb-autocomplete',
|
|
81
81
|
options.container || document.body,
|
|
82
82
|
); // this.scope);
|
|
@@ -87,7 +87,7 @@ export class Autocomplete {
|
|
|
87
87
|
|
|
88
88
|
this.completion_list.addEventListener('mousemove', (event) => this.ListMouseMove(event));
|
|
89
89
|
|
|
90
|
-
this.tooltip = DOMUtilities.
|
|
90
|
+
this.tooltip = DOMUtilities.Div('treb-cell-editor-ac-tooltip treb-autocomplete-tooltip',
|
|
91
91
|
options.container || document.body,
|
|
92
92
|
); // this.scope);
|
|
93
93
|
|
|
@@ -173,6 +173,10 @@ export class Autocomplete {
|
|
|
173
173
|
this.active_element = undefined;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
public SetBlock(): void {
|
|
177
|
+
this.block = true;
|
|
178
|
+
}
|
|
179
|
+
|
|
176
180
|
public ResetBlock(): void {
|
|
177
181
|
this.block = false;
|
|
178
182
|
}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
import { Area, type IArea, type ICellAddress, IsCellAddress, Localization, type Theme, Rectangle, type Cell } from 'treb-base-types';
|
|
37
|
+
import { Area, type IArea, type ICellAddress, IsCellAddress, Localization, type Theme, Rectangle, type Cell, DOMUtilities } from 'treb-base-types';
|
|
38
38
|
import type { ExpressionUnit, ParseResult, UnitAddress, UnitRange } from 'treb-parser';
|
|
39
39
|
import { Parser, QuotedSheetNameRegex } from 'treb-parser';
|
|
40
40
|
import type { DataModel, ViewModel } from '../types/data_model';
|
|
@@ -291,7 +291,6 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
|
|
|
291
291
|
super();
|
|
292
292
|
|
|
293
293
|
this.parser = model.parser;
|
|
294
|
-
// this.measurement_node = document.createElement('div');
|
|
295
294
|
|
|
296
295
|
}
|
|
297
296
|
|
|
@@ -866,13 +865,13 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
|
|
|
866
865
|
|
|
867
866
|
if (type !== 'text') {
|
|
868
867
|
|
|
869
|
-
const span =
|
|
868
|
+
const span = DOMUtilities.Create('span', type);
|
|
870
869
|
|
|
871
870
|
if (reference) {
|
|
872
871
|
span.dataset.reference = reference;
|
|
873
872
|
}
|
|
874
873
|
|
|
875
|
-
span.className = type;
|
|
874
|
+
// span.className = type;
|
|
876
875
|
span.appendChild(text_node);
|
|
877
876
|
fragment.appendChild(span);
|
|
878
877
|
|
|
@@ -25,7 +25,7 @@ import { Parser } from 'treb-parser';
|
|
|
25
25
|
import type { DataModel, ViewModel } from '../types/data_model';
|
|
26
26
|
import type { GridOptions } from '../types/grid_options';
|
|
27
27
|
import { Autocomplete } from './autocomplete';
|
|
28
|
-
import { DOMUtilities } from '
|
|
28
|
+
import { DOMUtilities } from 'treb-base-types';
|
|
29
29
|
|
|
30
30
|
// --- from formula_bar ---
|
|
31
31
|
|
package/treb-grid/src/index.ts
CHANGED
|
@@ -39,4 +39,5 @@ export type { FunctionDescriptor, ArgumentDescriptor } from './editors/autocompl
|
|
|
39
39
|
export { UA } from './util/ua';
|
|
40
40
|
export type { SetRangeOptions } from './types/set_range_options';
|
|
41
41
|
export type { AnnotationData, AnnotationType } from './types/annotation';
|
|
42
|
-
export type { ExternalEditorConfig, DependencyList, ExternalEditorCallback } from './types/external_editor_config';
|
|
42
|
+
export type { ExternalEditorConfig, DependencyList, ExternalEditorCallback } from './types/external_editor_config';
|
|
43
|
+
export * from './types/conditional_format';
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { DOMUtilities } from '
|
|
22
|
+
import { DOMUtilities } from 'treb-base-types';
|
|
23
23
|
import type { DataModel, ViewModel } from '../types/data_model';
|
|
24
24
|
|
|
25
25
|
import type { Tile } from '../types/tile';
|
|
26
|
-
import type { Theme, Point, Extent, Size, Position, ICellAddress, Table } from 'treb-base-types';
|
|
26
|
+
import type { Theme, Point, Extent, Size, Position, ICellAddress, Table, IArea } from 'treb-base-types';
|
|
27
27
|
import { Style, Area, Rectangle, ThemeColor } from 'treb-base-types';
|
|
28
28
|
|
|
29
29
|
import { MouseDrag } from '../types/drag_mask';
|
|
@@ -46,8 +46,6 @@ import type { Annotation } from '../types/annotation';
|
|
|
46
46
|
|
|
47
47
|
export { Area as TileRange } from 'treb-base-types';
|
|
48
48
|
|
|
49
|
-
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
50
|
-
|
|
51
49
|
export interface TooltipOptions {
|
|
52
50
|
up?: true;
|
|
53
51
|
left?: true;
|
|
@@ -203,19 +201,16 @@ export abstract class BaseLayout {
|
|
|
203
201
|
// contexts; the mask will be under the next sheet. so either
|
|
204
202
|
// global in body, or instance local.
|
|
205
203
|
|
|
206
|
-
this.mask =
|
|
207
|
-
|
|
208
|
-
this.tooltip = // document.querySelector('.treb-tooltip'); // ||
|
|
209
|
-
DOMUtilities.CreateDiv('treb-tooltip');
|
|
204
|
+
this.mask = DOMUtilities.Div('treb-mouse-mask');
|
|
205
|
+
this.tooltip = DOMUtilities.Div('treb-tooltip');
|
|
210
206
|
|
|
211
207
|
// this.error_highlight = DOMUtilities.CreateDiv('treb-error-highlight');
|
|
212
208
|
|
|
213
|
-
this.dropdown_caret =
|
|
214
|
-
this.dropdown_caret.setAttribute('class', 'treb-dropdown-caret');
|
|
209
|
+
this.dropdown_caret = DOMUtilities.SVG('svg', 'treb-dropdown-caret');
|
|
215
210
|
this.dropdown_caret.setAttribute('viewBox', '0 0 24 24');
|
|
216
211
|
this.dropdown_caret.tabIndex = -1;
|
|
217
212
|
|
|
218
|
-
const caret =
|
|
213
|
+
const caret =DOMUtilities.SVG('path');
|
|
219
214
|
caret.setAttribute('d', 'M5,7 L12,17 L19,7');
|
|
220
215
|
this.dropdown_caret.appendChild(caret);
|
|
221
216
|
|
|
@@ -252,7 +247,7 @@ export abstract class BaseLayout {
|
|
|
252
247
|
});
|
|
253
248
|
*/
|
|
254
249
|
|
|
255
|
-
this.dropdown_list = DOMUtilities.
|
|
250
|
+
this.dropdown_list = DOMUtilities.Div('treb-dropdown-list');
|
|
256
251
|
this.dropdown_list.setAttribute('tabindex', '-1'); // focusable
|
|
257
252
|
|
|
258
253
|
// this.dropdown_caret.addEventListener('keydown', (event) => {
|
|
@@ -351,11 +346,11 @@ export abstract class BaseLayout {
|
|
|
351
346
|
this.dropdown_selected = target as HTMLElement;
|
|
352
347
|
});
|
|
353
348
|
|
|
354
|
-
this.mock_selection = DOMUtilities.
|
|
349
|
+
this.mock_selection = DOMUtilities.Div('mock-selection-node');
|
|
355
350
|
this.mock_selection.innerHTML = ' ';
|
|
356
351
|
|
|
357
|
-
this.note_node = DOMUtilities.
|
|
358
|
-
this.title_node = DOMUtilities.
|
|
352
|
+
this.note_node = DOMUtilities.Div('treb-note');
|
|
353
|
+
this.title_node = DOMUtilities.Div('treb-hover-title');
|
|
359
354
|
|
|
360
355
|
this.sort_button = DOMUtilities.Create(
|
|
361
356
|
'button',
|
|
@@ -1199,7 +1194,7 @@ export abstract class BaseLayout {
|
|
|
1199
1194
|
parent: HTMLElement,
|
|
1200
1195
|
mark_dirty = true): Tile {
|
|
1201
1196
|
|
|
1202
|
-
const tile =
|
|
1197
|
+
const tile = DOMUtilities.Create('canvas') as Tile;
|
|
1203
1198
|
tile.setAttribute('class', classes);
|
|
1204
1199
|
tile.logical_size = size;
|
|
1205
1200
|
tile.width = size.width * this.dpr;
|
|
@@ -1408,7 +1403,7 @@ export abstract class BaseLayout {
|
|
|
1408
1403
|
|
|
1409
1404
|
this.dropdown_list.textContent = '';
|
|
1410
1405
|
for (const value of list) {
|
|
1411
|
-
const entry = DOMUtilities.
|
|
1406
|
+
const entry = DOMUtilities.Div(undefined, this.dropdown_list);
|
|
1412
1407
|
if (current === value) {
|
|
1413
1408
|
this.dropdown_selected = entry;
|
|
1414
1409
|
entry.classList.add('selected');
|
|
@@ -2160,25 +2155,33 @@ export abstract class BaseLayout {
|
|
|
2160
2155
|
}
|
|
2161
2156
|
}
|
|
2162
2157
|
|
|
2163
|
-
public DirtyArea(
|
|
2158
|
+
public DirtyArea(areas: IArea|IArea[]): void {
|
|
2164
2159
|
|
|
2165
2160
|
if (!this.initialized) return;
|
|
2166
2161
|
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
if (area.start.column !== Infinity) {
|
|
2171
|
-
start.column = end.column = this.TileIndexForColumn(area.start.column);
|
|
2172
|
-
if (area.end.column !== area.start.column) end.column = this.TileIndexForColumn(area.end.column);
|
|
2162
|
+
if (!Array.isArray(areas)) {
|
|
2163
|
+
areas = [areas];
|
|
2173
2164
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2165
|
+
|
|
2166
|
+
for (const area of areas) {
|
|
2167
|
+
|
|
2168
|
+
const start = { row: 0, column: 0 };
|
|
2169
|
+
const end = { row: this.grid_tiles[0].length - 1, column: this.grid_tiles.length - 1 };
|
|
2170
|
+
|
|
2171
|
+
if (area.start.column !== Infinity) {
|
|
2172
|
+
start.column = end.column = this.TileIndexForColumn(area.start.column);
|
|
2173
|
+
if (area.end.column !== area.start.column) end.column = this.TileIndexForColumn(area.end.column);
|
|
2174
|
+
}
|
|
2175
|
+
if (area.start.row !== Infinity) {
|
|
2176
|
+
start.row = end.row = this.TileIndexForRow(area.start.row);
|
|
2177
|
+
if (area.end.row !== area.start.row) end.row = this.TileIndexForRow(area.end.row);
|
|
2181
2178
|
}
|
|
2179
|
+
for (let column = start.column; column <= end.column; column++) {
|
|
2180
|
+
for (let row = start.row; row <= end.row; row++) {
|
|
2181
|
+
this.grid_tiles[column][row].dirty = true;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2182
2185
|
}
|
|
2183
2186
|
|
|
2184
2187
|
}
|
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
|
|
22
22
|
import { BaseLayout } from './base_layout';
|
|
23
23
|
import type { Tile } from '../types/tile';
|
|
24
|
-
import { DOMUtilities } from '
|
|
24
|
+
import { DOMUtilities } from 'treb-base-types';
|
|
25
25
|
import type { DataModel, ViewModel } from '../types/data_model';
|
|
26
26
|
|
|
27
|
-
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* we used to have two layouts, this one and a legacy layout for IE11.
|
|
@@ -42,47 +41,37 @@ export class GridLayout extends BaseLayout {
|
|
|
42
41
|
// mask needs to get attached to a container, when it's
|
|
43
42
|
// available
|
|
44
43
|
|
|
45
|
-
this.column_header = DOMUtilities.
|
|
46
|
-
this.row_header = DOMUtilities.
|
|
44
|
+
this.column_header = DOMUtilities.Div('treb-top-header');
|
|
45
|
+
this.row_header = DOMUtilities.Div('treb-left-header');
|
|
47
46
|
|
|
48
|
-
this.corner = DOMUtilities.
|
|
49
|
-
this.corner_canvas =
|
|
47
|
+
this.corner = DOMUtilities.Div('treb-corner');
|
|
48
|
+
this.corner_canvas = DOMUtilities.Create('canvas');
|
|
50
49
|
this.corner.appendChild(this.corner_canvas);
|
|
51
50
|
|
|
52
|
-
this.contents = DOMUtilities.
|
|
51
|
+
this.contents = DOMUtilities.Div('treb-contents');
|
|
53
52
|
this.buffer_canvas = DOMUtilities.Create('canvas', 'treb-buffer-canvas', this.contents);
|
|
54
53
|
|
|
55
54
|
// selection node attached to contents
|
|
56
|
-
this.grid_selection =
|
|
57
|
-
this.grid_selection.classList.add('treb-grid-selection');
|
|
58
|
-
this.contents.appendChild(this.grid_selection);
|
|
55
|
+
this.grid_selection = DOMUtilities.SVG('svg', 'treb-grid-selection', this.contents);
|
|
59
56
|
|
|
60
57
|
// selection node for frozen rows
|
|
61
|
-
this.row_header_selection =
|
|
62
|
-
this.
|
|
63
|
-
this.row_header_selection.classList.add('frozen-selection-rows');
|
|
64
|
-
this.column_header.appendChild(this.row_header_selection);
|
|
65
|
-
this.row_header_annotations = DOMUtilities.CreateDiv('frozen-annotation-container frozen-annotation-container-rows', this.column_header);
|
|
58
|
+
this.row_header_selection = DOMUtilities.SVG('svg', ['frozen-selection', 'frozen-selection-rows'], this.column_header);
|
|
59
|
+
this.row_header_annotations = DOMUtilities.Div('frozen-annotation-container frozen-annotation-container-rows', this.column_header);
|
|
66
60
|
|
|
67
61
|
// ...columns
|
|
68
|
-
this.column_header_selection =
|
|
69
|
-
this.
|
|
70
|
-
this.column_header_selection.classList.add('frozen-selection-columns');
|
|
71
|
-
this.row_header.appendChild(this.column_header_selection);
|
|
72
|
-
this.column_header_annotations = DOMUtilities.CreateDiv('frozen-annotation-container frozen-annotation-container-columns', this.row_header);
|
|
62
|
+
this.column_header_selection = DOMUtilities.SVG('svg', ['frozen-selection', 'frozen-selection-columns'], this.row_header);
|
|
63
|
+
this.column_header_annotations = DOMUtilities.Div('frozen-annotation-container frozen-annotation-container-columns', this.row_header);
|
|
73
64
|
|
|
74
65
|
// ...corner
|
|
75
|
-
this.corner_selection =
|
|
76
|
-
this.
|
|
77
|
-
this.corner.appendChild(this.corner_selection);
|
|
78
|
-
this.corner_annotations = DOMUtilities.CreateDiv('frozen-annotation-container frozen-annotation-container-corner', this.corner);
|
|
66
|
+
this.corner_selection = DOMUtilities.SVG('svg', 'frozen-selection', this.corner);
|
|
67
|
+
this.corner_annotations = DOMUtilities.Div('frozen-annotation-container frozen-annotation-container-corner', this.corner);
|
|
79
68
|
|
|
80
69
|
|
|
81
|
-
this.annotation_container = DOMUtilities.
|
|
70
|
+
this.annotation_container = DOMUtilities.Div('treb-annotation-container');
|
|
82
71
|
|
|
83
|
-
this.grid_cover = DOMUtilities.
|
|
84
|
-
this.column_header_cover = DOMUtilities.
|
|
85
|
-
this.row_header_cover = DOMUtilities.
|
|
72
|
+
this.grid_cover = DOMUtilities.Div('tile-cover grid-cover');
|
|
73
|
+
this.column_header_cover = DOMUtilities.Div('tile-cover column-header-cover');
|
|
74
|
+
this.row_header_cover = DOMUtilities.Div('tile-cover row-header-cover');
|
|
86
75
|
|
|
87
76
|
}
|
|
88
77
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { Theme, ICellAddress } from 'treb-base-types';
|
|
23
|
-
import { Rectangle } from 'treb-base-types';
|
|
23
|
+
import { DOMUtilities, Rectangle } from 'treb-base-types';
|
|
24
24
|
import type { BaseLayout } from '../layout/base_layout';
|
|
25
25
|
import type { SelectionOffset } from './svg_selection_block';
|
|
26
26
|
import { SVGSelectionBlock } from './svg_selection_block';
|
|
@@ -302,8 +302,7 @@ export class SelectionRenderer {
|
|
|
302
302
|
|
|
303
303
|
let group: SVGElement = node.querySelector('.alternate-selections') as SVGElement;
|
|
304
304
|
if (!group) {
|
|
305
|
-
group =
|
|
306
|
-
group.setAttribute('class', 'alternate-selections');
|
|
305
|
+
group = DOMUtilities.SVG('g', 'alternate-selections');
|
|
307
306
|
node.appendChild(group);
|
|
308
307
|
}
|
|
309
308
|
group?.appendChild(selection_block.g);
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type
|
|
23
|
-
|
|
24
|
-
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
22
|
+
import { DOMUtilities, type Theme } from 'treb-base-types';
|
|
25
23
|
|
|
26
24
|
export enum Orientation {
|
|
27
25
|
Horizontal,
|
|
@@ -39,14 +37,9 @@ export class HeaderOverlay {
|
|
|
39
37
|
private container: SVGElement,
|
|
40
38
|
private orientation: Orientation) {
|
|
41
39
|
|
|
42
|
-
this.g =
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
this.overlay = document.createElementNS(SVGNS, 'rect');
|
|
46
|
-
this.overlay.setAttribute('class', 'treb-overlay');
|
|
47
|
-
|
|
48
|
-
this.highlight = document.createElementNS(SVGNS, 'rect');
|
|
49
|
-
this.highlight.setAttribute('class', 'treb-highlight');
|
|
40
|
+
this.g = DOMUtilities.SVG('g', 'treb-header-overlay');
|
|
41
|
+
this.overlay = DOMUtilities.SVG('rect', 'treb-overlay');
|
|
42
|
+
this.highlight = DOMUtilities.SVG('rect', 'treb-highlight');
|
|
50
43
|
|
|
51
44
|
this.g.style.display = 'none';
|
|
52
45
|
this.g.appendChild(this.highlight);
|
|
@@ -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 type
|
|
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 { type Theme, type Rectangle, DOMUtilities } from 'treb-base-types';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* the original selections -- a canvas overlaid over the tile canvases --
|
|
@@ -30,8 +30,6 @@ import type { Theme, Rectangle } from 'treb-base-types';
|
|
|
30
30
|
* attributes.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
34
|
-
|
|
35
33
|
export interface SelectionOffset {
|
|
36
34
|
x: number;
|
|
37
35
|
y: number;
|
|
@@ -48,11 +46,10 @@ export class SVGSelectionBlock {
|
|
|
48
46
|
private theme: Theme,
|
|
49
47
|
private offset: SelectionOffset = {x: 0, y: 0}) {
|
|
50
48
|
|
|
51
|
-
this.g =
|
|
49
|
+
this.g = DOMUtilities.SVG('g');
|
|
52
50
|
this.g.setAttribute('transform', `translate(${offset.x}, ${offset.y})`);
|
|
53
51
|
|
|
54
|
-
this.outline =
|
|
55
|
-
this.outline.setAttribute('class', 'outline');
|
|
52
|
+
this.outline = DOMUtilities.SVG('rect', 'outline');
|
|
56
53
|
|
|
57
54
|
if (primary) {
|
|
58
55
|
|
|
@@ -61,11 +58,8 @@ export class SVGSelectionBlock {
|
|
|
61
58
|
// primary selections have a separate fill, plus the nub. separate
|
|
62
59
|
// fill because the "target" is unfilled.
|
|
63
60
|
|
|
64
|
-
this.fill =
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
this.nub = document.createElementNS(SVGNS, 'rect');
|
|
68
|
-
this.nub.setAttribute('class', 'nub');
|
|
61
|
+
this.fill = DOMUtilities.SVG('path', 'fill');
|
|
62
|
+
this.nub = DOMUtilities.SVG('rect', 'nub');
|
|
69
63
|
|
|
70
64
|
this.g.appendChild(this.fill);
|
|
71
65
|
this.g.appendChild(this.outline);
|
|
@@ -81,8 +75,7 @@ export class SVGSelectionBlock {
|
|
|
81
75
|
// and use currentColor, but we can't set opacity separately so we
|
|
82
76
|
// need another node. which is a waste, but ergonomics ftw!
|
|
83
77
|
|
|
84
|
-
this.fill =
|
|
85
|
-
this.fill.setAttribute('class', 'fill');
|
|
78
|
+
this.fill = DOMUtilities.SVG('rect', 'fill');
|
|
86
79
|
|
|
87
80
|
// this.SetThemeColor(0);
|
|
88
81
|
// if (theme.additional_selection_line_dash_array) {
|
|
@@ -99,10 +99,7 @@ export class TileRenderer {
|
|
|
99
99
|
protected view: ViewModel,
|
|
100
100
|
protected options: GridOptions, ) {
|
|
101
101
|
|
|
102
|
-
// this.buffer_canvas = document.createElement('canvas');
|
|
103
|
-
|
|
104
102
|
this.buffer_canvas = layout.buffer_canvas;
|
|
105
|
-
|
|
106
103
|
this.buffer_canvas.width = this.buffer_canvas_size.width;
|
|
107
104
|
this.buffer_canvas.height = this.buffer_canvas_size.height;
|
|
108
105
|
|
|
@@ -239,7 +236,7 @@ export class TileRenderer {
|
|
|
239
236
|
*/
|
|
240
237
|
public OverflowDirty(full_tile = false): void {
|
|
241
238
|
|
|
242
|
-
const mutated = [];
|
|
239
|
+
const mutated: OverflowRecord[] = [];
|
|
243
240
|
|
|
244
241
|
for (const overflow of this.overflow_areas) {
|
|
245
242
|
const row = overflow.area.start.row;
|
|
@@ -912,6 +909,8 @@ export class TileRenderer {
|
|
|
912
909
|
line_width = test;
|
|
913
910
|
words.shift();
|
|
914
911
|
|
|
912
|
+
max_width = Math.max(max_width, line_width);
|
|
913
|
+
|
|
915
914
|
}
|
|
916
915
|
|
|
917
916
|
// trim the last word, then insert a row (we're relying on the
|
|
@@ -920,6 +919,8 @@ export class TileRenderer {
|
|
|
920
919
|
last.text = last.text.trim();
|
|
921
920
|
last.width = last.trimmed;
|
|
922
921
|
|
|
922
|
+
max_width = Math.max(max_width, last.width);
|
|
923
|
+
|
|
923
924
|
strings.push(line2.map((metric) => {
|
|
924
925
|
return {
|
|
925
926
|
...metric.part,
|
|
@@ -928,11 +929,11 @@ export class TileRenderer {
|
|
|
928
929
|
text: metric.text,
|
|
929
930
|
};
|
|
930
931
|
}));
|
|
931
|
-
|
|
932
|
+
|
|
932
933
|
}
|
|
933
934
|
|
|
934
935
|
}
|
|
935
|
-
|
|
936
|
+
|
|
936
937
|
}
|
|
937
938
|
else {
|
|
938
939
|
|
|
@@ -1341,6 +1342,7 @@ export class TileRenderer {
|
|
|
1341
1342
|
else {
|
|
1342
1343
|
|
|
1343
1344
|
const fill = ThemeColor2(this.theme, style.fill);
|
|
1345
|
+
|
|
1344
1346
|
if (fill) {
|
|
1345
1347
|
context.fillStyle = fill;
|
|
1346
1348
|
context.fillRect(0, 0, width - 1, height - 1);
|