@trebco/treb 36.1.2 → 36.1.3

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
@@ -892,8 +892,9 @@ export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
892
892
  * Revert state one level from the undo stack.
893
893
  *
894
894
  * @public
895
+ * @returns true if undo succeeded, false if the undo stack was empty
895
896
  */
896
- Undo(): void;
897
+ Undo(): boolean;
897
898
 
898
899
  /**
899
900
  * Show the about dialog.
@@ -1131,6 +1132,12 @@ export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1131
1132
  * @param token - the token returned from `Subscribe`
1132
1133
  */
1133
1134
  Cancel(token: number): void;
1135
+
1136
+ /**
1137
+ *
1138
+ */
1139
+ ImportXLSX(// data: string, source: LoadSource): Promise<Blob | void> {
1140
+ data: ArrayBuffer, source: LoadSource, path?: string): Promise<Blob | void>;
1134
1141
  }
1135
1142
 
1136
1143
  /**
@@ -1150,6 +1157,10 @@ export interface LoadDocumentOptions {
1150
1157
  flush?: boolean;
1151
1158
  recalculate?: boolean;
1152
1159
  override_sheet?: string;
1160
+ source?: LoadSource;
1161
+
1162
+ /** opaque data for reference */
1163
+ path?: string;
1153
1164
  }
1154
1165
 
1155
1166
  /**
@@ -1611,121 +1622,6 @@ export type TableSortType = 'text' | 'numeric' | 'auto';
1611
1622
  */
1612
1623
  export declare const GetWorkerContext: () => Promise<Worker>;
1613
1624
 
1614
- /** clipboard data is a 2d array */
1615
- export type ClipboardData = ClipboardDataElement[][];
1616
-
1617
- /**
1618
- * optional paste options. we can paste formulas or values, and we
1619
- * can use the source style, target style, or just use the source
1620
- * number formats.
1621
- */
1622
- export interface PasteOptions {
1623
-
1624
- /**
1625
- * when clipboard data includes formulas, optionally paste calculated
1626
- * values instead of the original formulas. defaults to false.
1627
- */
1628
- values?: boolean;
1629
-
1630
- /**
1631
- * when pasting data from the clipboard, we can copy formatting/style
1632
- * from the original data, or we can retain the target range formatting
1633
- * and just paste data. a third option allows pasting source number
1634
- * formats but dropping other style information.
1635
- *
1636
- * defaults to "source", meaning paste source styles.
1637
- */
1638
- formatting?: 'source' | 'target' | 'number-formats';
1639
- }
1640
-
1641
- /**
1642
- * this is a structure for copy/paste data. clipboard data may include
1643
- * relative formauls and resolved styles, so it's suitable for pasting into
1644
- * other areas of the spreadsheet.
1645
- */
1646
- export interface ClipboardDataElement {
1647
-
1648
- /** calculated cell value */
1649
- calculated: CellValue;
1650
-
1651
- /** the actual cell value or formula */
1652
- value: CellValue;
1653
-
1654
- /** cell style. this may include row/column styles from the copy source */
1655
- style?: CellStyle;
1656
-
1657
- /** area. if this cell is part of an array, this is the array range */
1658
- area?: IArea;
1659
- }
1660
- export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right";
1661
-
1662
- /**
1663
- * options for the SetRange method
1664
- */
1665
- export interface SetRangeOptions {
1666
-
1667
- /** transpose rectangular array before inserting */
1668
- transpose?: boolean;
1669
-
1670
- /** recycle values (R-style) */
1671
- recycle?: boolean;
1672
-
1673
- /** apply as an array (as if you pressed ctrl+shift+enter) */
1674
- array?: boolean;
1675
-
1676
- /** spill over */
1677
- spill?: boolean;
1678
-
1679
- /**
1680
- * argument separator to use when parsing the input formula. set this
1681
- * option to call SetRange with a consistent argument separator,
1682
- * independent of current locale.
1683
- */
1684
- argument_separator?: ',' | ';';
1685
-
1686
- /**
1687
- * allow R1C1-style references; these can be either absolute
1688
- * addresses (e.g. R2C4) or relative to the cell (e.g. R[-3]C[0]).
1689
- */
1690
- r1c1?: boolean;
1691
- }
1692
- export interface ExternalEditorConfig {
1693
-
1694
- /**
1695
- * list of dependencies to highlight. we support undefined entries in
1696
- * this list so you can use the result of `EmbeddedSpreadsheet.Resolve`,
1697
- * which may return undefined.
1698
- */
1699
- dependencies: DependencyList;
1700
-
1701
- /**
1702
- * this callback will be called when the selection changes in the
1703
- * spreadsheet and this external editor is active. return an updated
1704
- * list of dependencies to highlight.
1705
- *
1706
- * NOTE: this is currently synchronous, but don't rely on that. it
1707
- * might switch to async in the future depending on how it works in
1708
- * practice.
1709
- */
1710
- update: ExternalEditorCallback;
1711
-
1712
- /**
1713
- * a list of nodes that will serve as editors. when you attach, we will do
1714
- * an initial pass of context highlighting. we highlight on text changes
1715
- * and insert references if you make a selection in the spreadsheet while
1716
- * an editor is focused.
1717
- */
1718
- nodes: HTMLElement[];
1719
-
1720
- /**
1721
- * assume that we're editing a formula. does not require leading `=`.
1722
- * defaults to `true` for historical reasons.
1723
- */
1724
- assume_formula?: boolean;
1725
- }
1726
- export type DependencyList = Array<IArea | ICellAddress | undefined>;
1727
- export type ExternalEditorCallback = (selection?: string) => DependencyList | undefined;
1728
-
1729
1625
  /**
1730
1626
  * this is the document type used by TREB. it has a lot of small variations
1731
1627
  * for historical reasons and backwards compatibility. usually it's preferable
@@ -2291,6 +2187,121 @@ export interface SerializedNamedExpression {
2291
2187
  expression: string;
2292
2188
  }
2293
2189
 
2190
+ /** clipboard data is a 2d array */
2191
+ export type ClipboardData = ClipboardDataElement[][];
2192
+
2193
+ /**
2194
+ * optional paste options. we can paste formulas or values, and we
2195
+ * can use the source style, target style, or just use the source
2196
+ * number formats.
2197
+ */
2198
+ export interface PasteOptions {
2199
+
2200
+ /**
2201
+ * when clipboard data includes formulas, optionally paste calculated
2202
+ * values instead of the original formulas. defaults to false.
2203
+ */
2204
+ values?: boolean;
2205
+
2206
+ /**
2207
+ * when pasting data from the clipboard, we can copy formatting/style
2208
+ * from the original data, or we can retain the target range formatting
2209
+ * and just paste data. a third option allows pasting source number
2210
+ * formats but dropping other style information.
2211
+ *
2212
+ * defaults to "source", meaning paste source styles.
2213
+ */
2214
+ formatting?: 'source' | 'target' | 'number-formats';
2215
+ }
2216
+
2217
+ /**
2218
+ * this is a structure for copy/paste data. clipboard data may include
2219
+ * relative formauls and resolved styles, so it's suitable for pasting into
2220
+ * other areas of the spreadsheet.
2221
+ */
2222
+ export interface ClipboardDataElement {
2223
+
2224
+ /** calculated cell value */
2225
+ calculated: CellValue;
2226
+
2227
+ /** the actual cell value or formula */
2228
+ value: CellValue;
2229
+
2230
+ /** cell style. this may include row/column styles from the copy source */
2231
+ style?: CellStyle;
2232
+
2233
+ /** area. if this cell is part of an array, this is the array range */
2234
+ area?: IArea;
2235
+ }
2236
+ export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right";
2237
+
2238
+ /**
2239
+ * options for the SetRange method
2240
+ */
2241
+ export interface SetRangeOptions {
2242
+
2243
+ /** transpose rectangular array before inserting */
2244
+ transpose?: boolean;
2245
+
2246
+ /** recycle values (R-style) */
2247
+ recycle?: boolean;
2248
+
2249
+ /** apply as an array (as if you pressed ctrl+shift+enter) */
2250
+ array?: boolean;
2251
+
2252
+ /** spill over */
2253
+ spill?: boolean;
2254
+
2255
+ /**
2256
+ * argument separator to use when parsing the input formula. set this
2257
+ * option to call SetRange with a consistent argument separator,
2258
+ * independent of current locale.
2259
+ */
2260
+ argument_separator?: ',' | ';';
2261
+
2262
+ /**
2263
+ * allow R1C1-style references; these can be either absolute
2264
+ * addresses (e.g. R2C4) or relative to the cell (e.g. R[-3]C[0]).
2265
+ */
2266
+ r1c1?: boolean;
2267
+ }
2268
+ export interface ExternalEditorConfig {
2269
+
2270
+ /**
2271
+ * list of dependencies to highlight. we support undefined entries in
2272
+ * this list so you can use the result of `EmbeddedSpreadsheet.Resolve`,
2273
+ * which may return undefined.
2274
+ */
2275
+ dependencies: DependencyList;
2276
+
2277
+ /**
2278
+ * this callback will be called when the selection changes in the
2279
+ * spreadsheet and this external editor is active. return an updated
2280
+ * list of dependencies to highlight.
2281
+ *
2282
+ * NOTE: this is currently synchronous, but don't rely on that. it
2283
+ * might switch to async in the future depending on how it works in
2284
+ * practice.
2285
+ */
2286
+ update: ExternalEditorCallback;
2287
+
2288
+ /**
2289
+ * a list of nodes that will serve as editors. when you attach, we will do
2290
+ * an initial pass of context highlighting. we highlight on text changes
2291
+ * and insert references if you make a selection in the spreadsheet while
2292
+ * an editor is focused.
2293
+ */
2294
+ nodes: HTMLElement[];
2295
+
2296
+ /**
2297
+ * assume that we're editing a formula. does not require leading `=`.
2298
+ * defaults to `true` for historical reasons.
2299
+ */
2300
+ assume_formula?: boolean;
2301
+ }
2302
+ export type DependencyList = Array<IArea | ICellAddress | undefined>;
2303
+ export type ExternalEditorCallback = (selection?: string) => DependencyList | undefined;
2304
+
2294
2305
  /**
2295
2306
  * options for exporting CSV/TSV
2296
2307
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "36.1.2",
3
+ "version": "36.1.3",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -178,8 +178,11 @@ export interface LoadDocumentOptions {
178
178
  /** @internal */
179
179
  override_selection?: GridSelection,
180
180
 
181
- /** @internal */
182
181
  source?: LoadSource,
182
+
183
+ /** opaque data for reference */
184
+ path?: string;
185
+
183
186
  }
184
187
 
185
188
  /**
@@ -3957,7 +3960,11 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3957
3960
 
3958
3961
  }
3959
3962
 
3960
- this.Publish({ type: 'load', source: options.source }); // FIXME: should not happen on undo...
3963
+ this.Publish({
3964
+ type: 'load',
3965
+ source: options.source,
3966
+ path: options.path,
3967
+ }); // FIXME: should not happen on undo...
3961
3968
  this.UpdateDocumentStyles();
3962
3969
  this.loaded = true;
3963
3970
 
@@ -4297,8 +4304,9 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4297
4304
  * Revert state one level from the undo stack.
4298
4305
  *
4299
4306
  * @public
4307
+ * @returns true if undo succeeded, false if the undo stack was empty
4300
4308
  */
4301
- public Undo(): void {
4309
+ public Undo(): boolean {
4302
4310
 
4303
4311
  // this is half of the problem, we also need to manage views when
4304
4312
  // we set undo states
@@ -4311,7 +4319,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4311
4319
 
4312
4320
  if (this.undo_pointer <= 1) {
4313
4321
  console.warn('nothing to undo');
4314
- return;
4322
+ return false;
4315
4323
  }
4316
4324
 
4317
4325
  const undo_entry = this.undo_stack[(--this.undo_pointer) - 1];
@@ -4341,6 +4349,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4341
4349
 
4342
4350
  // this.file_version--; // decrement
4343
4351
 
4352
+ return true;
4353
+
4344
4354
  }
4345
4355
 
4346
4356
 
@@ -5267,7 +5277,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5267
5277
  /**
5268
5278
  *
5269
5279
  */
5270
- protected async ImportXLSX( // data: string, source: LoadSource): Promise<Blob | void> {
5280
+ public async ImportXLSX( // data: string, source: LoadSource): Promise<Blob | void> {
5271
5281
  data: ArrayBuffer, source: LoadSource, path?: string): Promise<Blob | void> {
5272
5282
 
5273
5283
  // this is inlined to ensure the code will be tree-shaken properly