@trebco/treb 28.2.3 → 28.3.5
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-light.mjs +8 -8
- package/dist/treb-spreadsheet.mjs +10 -10
- package/dist/treb.d.ts +11 -5
- package/package.json +1 -1
- package/treb-embed/markup/toolbar.html +8 -8
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +3 -3
- package/treb-embed/src/custom-element/treb-global.ts +2 -2
- package/treb-embed/src/embedded-spreadsheet.ts +17 -4
- package/treb-grid/package.json +1 -1
- package/treb-grid/src/types/grid.ts +19 -2
package/dist/treb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! API v28.
|
|
1
|
+
/*! API v28.3. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* add our tag to the map
|
|
@@ -26,7 +26,7 @@ export declare class TREBGlobal {
|
|
|
26
26
|
/**
|
|
27
27
|
* create a spreadsheet instance
|
|
28
28
|
*/
|
|
29
|
-
CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet
|
|
29
|
+
CreateSpreadsheet<USER_DATA_TYPE = unknown>(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet<USER_DATA_TYPE>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/** single instance of factory class */
|
|
@@ -276,7 +276,7 @@ export interface ICellAddress {
|
|
|
276
276
|
/**
|
|
277
277
|
* embedded spreadsheet
|
|
278
278
|
*/
|
|
279
|
-
export declare class EmbeddedSpreadsheet {
|
|
279
|
+
export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
280
280
|
|
|
281
281
|
/** document name (metadata) */
|
|
282
282
|
get document_name(): string | undefined;
|
|
@@ -285,10 +285,10 @@ export declare class EmbeddedSpreadsheet {
|
|
|
285
285
|
set document_name(name: string | undefined);
|
|
286
286
|
|
|
287
287
|
/** opaque user data (metadata) */
|
|
288
|
-
get user_data():
|
|
288
|
+
get user_data(): USER_DATA_TYPE | undefined;
|
|
289
289
|
|
|
290
290
|
/** opaque user data (metadata) */
|
|
291
|
-
set user_data(data:
|
|
291
|
+
set user_data(data: USER_DATA_TYPE);
|
|
292
292
|
|
|
293
293
|
/** current grid scale */
|
|
294
294
|
get scale(): number;
|
|
@@ -333,6 +333,12 @@ export declare class EmbeddedSpreadsheet {
|
|
|
333
333
|
*/
|
|
334
334
|
get dirty(): boolean;
|
|
335
335
|
|
|
336
|
+
/**
|
|
337
|
+
* explicitly set or clear the dirty flag. it's intended for use by clients
|
|
338
|
+
* that have their own save routine.
|
|
339
|
+
*/
|
|
340
|
+
set dirty(value: boolean);
|
|
341
|
+
|
|
336
342
|
/**
|
|
337
343
|
* returns the names of all sheets in the current document
|
|
338
344
|
*/
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<div composite narrow>
|
|
15
15
|
<button data-command="justify-left" data-target="justify" title="Left-align text"></button>
|
|
16
16
|
<div class="treb-menu">
|
|
17
|
-
<button dropdown></button>
|
|
17
|
+
<button dropdown title="Text justify options"></button>
|
|
18
18
|
<div class="treb-icon-buttons" data-replace="justify">
|
|
19
19
|
<button data-command="justify-left" title="Left-align text"></button>
|
|
20
20
|
<button data-command="justify-center" title="Center-align text"></button>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<div composite narrow>
|
|
27
27
|
<button data-command="align-top" data-target="align" title="Align to top"></button>
|
|
28
28
|
<div class="treb-menu">
|
|
29
|
-
<button dropdown></button>
|
|
29
|
+
<button dropdown title="Text align options"></button>
|
|
30
30
|
<div class="treb-icon-buttons" data-replace="align">
|
|
31
31
|
<button data-command="align-top" title="Align to top"></button>
|
|
32
32
|
<button data-command="align-middle" title="Align to middle"></button>
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
<div composite>
|
|
69
69
|
<button data-command="fill-color" data-color-bar="fill" data-color="{}" title="Fill color"></button>
|
|
70
70
|
<div class="treb-menu treb-color-menu" data-color-command="fill-color" data-replace-color="fill" data-default-color-text="No fill">
|
|
71
|
-
<button dropdown></button>
|
|
71
|
+
<button dropdown title="Color options"></button>
|
|
72
72
|
<div class="treb-color-chooser">
|
|
73
73
|
<div class="treb-caption">Theme colors</div>
|
|
74
74
|
<div class="treb-swatches"></div>
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
<div composite>
|
|
91
91
|
<button data-command="text-color" data-color-bar="text" data-color="{}" title="Text color"></button>
|
|
92
92
|
<div class="treb-menu treb-color-menu" data-color-command="text-color" data-replace-color="text" data-default-color-text="Default text color">
|
|
93
|
-
<button dropdown></button>
|
|
93
|
+
<button dropdown title="Color options"></button>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
|
|
97
97
|
<div composite>
|
|
98
98
|
<button data-command="border-bottom" data-target="border" title="Bottom border"></button>
|
|
99
99
|
<div class="treb-menu">
|
|
100
|
-
<button dropdown></button>
|
|
100
|
+
<button dropdown title="Border options"></button>
|
|
101
101
|
<div class="treb-icon-buttons" data-replace="border">
|
|
102
102
|
<button data-command="border-top" title="Top border"></button>
|
|
103
103
|
<button data-command="border-left" title="Left border"></button>
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
<div composite font-scale>
|
|
119
119
|
<input class="treb-font-scale" title="Font scale">
|
|
120
120
|
<div class="treb-menu">
|
|
121
|
-
<button dropdown></button>
|
|
121
|
+
<button dropdown title="Font scale options"></button>
|
|
122
122
|
<div>
|
|
123
123
|
<button data-command="font-scale" data-scale="0.8">0.80</button>
|
|
124
124
|
<button data-command="font-scale" data-scale="0.9">0.90</button>
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
<div composite>
|
|
148
148
|
<input class="treb-number-format" title="Number format">
|
|
149
149
|
<div class="treb-menu">
|
|
150
|
-
<button dropdown></button>
|
|
150
|
+
<button dropdown title="Number formats"></button>
|
|
151
151
|
<div class="treb-number-format-menu"></div>
|
|
152
152
|
</div>
|
|
153
153
|
</div>
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
<div composite chart-menu>
|
|
161
161
|
<button data-command="insert-column-chart" data-target="annotation" title="Insert column chart"></button>
|
|
162
162
|
<div class="treb-menu">
|
|
163
|
-
<button dropdown></button>
|
|
163
|
+
<button dropdown title="Chart options"></button>
|
|
164
164
|
<div class="treb-icon-buttons" data-replace="annotation">
|
|
165
165
|
<button data-command="insert-column-chart" title="Insert column chart"></button>
|
|
166
166
|
<button data-command="insert-donut-chart" title="Insert donut chart"></button>
|
|
@@ -14,13 +14,13 @@ import type { ToolbarMessage } from '../toolbar-message';
|
|
|
14
14
|
import { DOMContext } from 'treb-base-types';
|
|
15
15
|
|
|
16
16
|
/** @internal */
|
|
17
|
-
export class SpreadsheetConstructor {
|
|
17
|
+
export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
|
|
18
18
|
|
|
19
19
|
/** container, if any */
|
|
20
20
|
public root?: HTMLElement;
|
|
21
21
|
|
|
22
22
|
/** spreadsheet instance */
|
|
23
|
-
public sheet?: EmbeddedSpreadsheet
|
|
23
|
+
public sheet?: EmbeddedSpreadsheet<USER_DATA_TYPE>;
|
|
24
24
|
|
|
25
25
|
/** current border color. will be applied to new borders. */
|
|
26
26
|
protected border_color?: Color;
|
|
@@ -278,7 +278,7 @@ export class SpreadsheetConstructor {
|
|
|
278
278
|
|
|
279
279
|
// set a local variable so we don't have to keep testing the member
|
|
280
280
|
|
|
281
|
-
this.sheet = new EmbeddedSpreadsheet(options);
|
|
281
|
+
this.sheet = new EmbeddedSpreadsheet<USER_DATA_TYPE>(options);
|
|
282
282
|
|
|
283
283
|
if (this.root) {
|
|
284
284
|
this.CreateLayout(this.sheet, this.root);
|
|
@@ -27,9 +27,9 @@ export class TREBGlobal {
|
|
|
27
27
|
/**
|
|
28
28
|
* create a spreadsheet instance
|
|
29
29
|
*/
|
|
30
|
-
public CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet {
|
|
30
|
+
public CreateSpreadsheet<USER_DATA_TYPE = unknown>(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet<USER_DATA_TYPE> {
|
|
31
31
|
const container = options.container;
|
|
32
|
-
const instance = new SpreadsheetConstructor(container);
|
|
32
|
+
const instance = new SpreadsheetConstructor<USER_DATA_TYPE>(container);
|
|
33
33
|
instance.AttachElement(options);
|
|
34
34
|
if (!instance.sheet) {
|
|
35
35
|
throw new Error('construction failed');
|
|
@@ -221,7 +221,7 @@ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue
|
|
|
221
221
|
/**
|
|
222
222
|
* embedded spreadsheet
|
|
223
223
|
*/
|
|
224
|
-
export class EmbeddedSpreadsheet {
|
|
224
|
+
export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
225
225
|
|
|
226
226
|
/** @internal */
|
|
227
227
|
public static treb_base_path = '';
|
|
@@ -475,12 +475,12 @@ export class EmbeddedSpreadsheet {
|
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
/** opaque user data (metadata) */
|
|
478
|
-
public get user_data():
|
|
478
|
+
public get user_data(): USER_DATA_TYPE|undefined {
|
|
479
479
|
return this.grid.model.user_data;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
/** opaque user data (metadata) */
|
|
483
|
-
public set user_data(data:
|
|
483
|
+
public set user_data(data: USER_DATA_TYPE) {
|
|
484
484
|
this.grid.model.user_data = data;
|
|
485
485
|
this.DocumentChange();
|
|
486
486
|
}
|
|
@@ -574,6 +574,19 @@ export class EmbeddedSpreadsheet {
|
|
|
574
574
|
return this.file_version !== this.last_save_version;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
+
/**
|
|
578
|
+
* explicitly set or clear the dirty flag. it's intended for use by clients
|
|
579
|
+
* that have their own save routine.
|
|
580
|
+
*/
|
|
581
|
+
public set dirty(value: boolean) {
|
|
582
|
+
if (value) {
|
|
583
|
+
this.file_version++;
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
this.last_save_version = this.file_version;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
577
590
|
/**
|
|
578
591
|
* returns the names of all sheets in the current document
|
|
579
592
|
*/
|
|
@@ -1172,7 +1185,7 @@ export class EmbeddedSpreadsheet {
|
|
|
1172
1185
|
* create the correct type
|
|
1173
1186
|
*/
|
|
1174
1187
|
protected CreateView(): EmbeddedSpreadsheet {
|
|
1175
|
-
const child = new EmbeddedSpreadsheet({
|
|
1188
|
+
const child = new EmbeddedSpreadsheet<USER_DATA_TYPE>({
|
|
1176
1189
|
...this.options,
|
|
1177
1190
|
global_name: undefined, // don't overwrite
|
|
1178
1191
|
model: this,
|
package/treb-grid/package.json
CHANGED
|
@@ -652,7 +652,7 @@ export class Grid extends GridBase {
|
|
|
652
652
|
const resize_target = this.DOM.Div('annotation-resize-target', node);
|
|
653
653
|
|
|
654
654
|
node.addEventListener('keydown', (event) => {
|
|
655
|
-
|
|
655
|
+
|
|
656
656
|
const rect = annotation.scaled_rect;
|
|
657
657
|
if (!rect) {
|
|
658
658
|
console.info('missing scaled rect!');
|
|
@@ -714,6 +714,13 @@ export class Grid extends GridBase {
|
|
|
714
714
|
this.Focus();
|
|
715
715
|
break;
|
|
716
716
|
|
|
717
|
+
case 'Backspace':
|
|
718
|
+
if (event.metaKey && UA.is_mac) {
|
|
719
|
+
this.Focus();
|
|
720
|
+
this.RemoveAnnotation(annotation);
|
|
721
|
+
}
|
|
722
|
+
break;
|
|
723
|
+
|
|
717
724
|
case 'Delete':
|
|
718
725
|
case 'Del':
|
|
719
726
|
this.Focus();
|
|
@@ -4468,6 +4475,8 @@ export class Grid extends GridBase {
|
|
|
4468
4475
|
|
|
4469
4476
|
// handle some specific control-key combinations
|
|
4470
4477
|
|
|
4478
|
+
console.info("K", event);
|
|
4479
|
+
|
|
4471
4480
|
if (event.ctrlKey || (UA.is_mac && event.metaKey)) {
|
|
4472
4481
|
|
|
4473
4482
|
// handle ctrl+shift+arrow AND ctrl+arrow (we used to just handle
|
|
@@ -4494,6 +4503,14 @@ export class Grid extends GridBase {
|
|
|
4494
4503
|
delta.columns++;
|
|
4495
4504
|
break;
|
|
4496
4505
|
|
|
4506
|
+
case 'Backspace':
|
|
4507
|
+
if (event.metaKey && UA.is_mac) {
|
|
4508
|
+
if (!selection.empty) {
|
|
4509
|
+
this.DeleteSelection(selection);
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
break;
|
|
4513
|
+
|
|
4497
4514
|
case 'Delete':
|
|
4498
4515
|
case 'Del':
|
|
4499
4516
|
// if (event.shiftKey) // ctrl+shift+delete seems to be "delete history" in all browsers...
|
|
@@ -5062,7 +5079,7 @@ export class Grid extends GridBase {
|
|
|
5062
5079
|
if (found_number_format) {
|
|
5063
5080
|
|
|
5064
5081
|
const style: CellStyle = {
|
|
5065
|
-
number_format: found_number_format,
|
|
5082
|
+
number_format: NumberFormatCache.SymbolicName(found_number_format) || found_number_format,
|
|
5066
5083
|
};
|
|
5067
5084
|
|
|
5068
5085
|
commands.push({
|