@trebco/treb 32.14.0 → 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/api-generator/api-generator-types.ts +3 -0
- package/api-generator/api-generator.ts +15 -1
- package/bun.lock +145 -99
- package/dist/chunk-43DLP2OX.mjs +11 -0
- package/dist/chunk-4CKS56PE.mjs +11 -0
- package/dist/chunk-75PARUQE.mjs +11 -0
- package/dist/chunk-7QD63AZS.mjs +24601 -0
- package/dist/chunk-A55ARVRD.mjs +11 -0
- package/dist/chunk-DESAKYW4.mjs +11 -0
- package/dist/chunk-EQ2R5W6P.mjs +24565 -0
- package/dist/chunk-IYJU2J6D.mjs +24601 -0
- package/dist/chunk-KSJFPGXT.mjs +11 -0
- package/dist/chunk-ORQFKLXM.mjs +24601 -0
- package/dist/chunk-SFDNNDHY.mjs +11 -0
- package/dist/chunk-T47DX5MI.mjs +11 -0
- package/dist/chunk-T6ILBVEX.mjs +11 -0
- package/dist/chunk-TPRCDYYG.mjs +11 -0
- package/dist/chunk-YAHNOOHO.mjs +11 -0
- package/dist/chunk-YLCFKX2G.mjs +24601 -0
- package/dist/treb-export-worker.mjs +9 -2
- package/dist/treb-spreadsheet.mjs +7 -19
- package/dist/treb.d.ts +144 -117
- package/esbuild-composite.mjs +18 -6
- package/esbuild-utils.mjs +62 -3
- package/i18n/languages/treb-i18n-da.mjs +1 -1
- package/i18n/languages/treb-i18n-de.mjs +1 -1
- package/i18n/languages/treb-i18n-es.mjs +1 -1
- package/i18n/languages/treb-i18n-fr.mjs +1 -1
- package/i18n/languages/treb-i18n-it.mjs +1 -1
- package/i18n/languages/treb-i18n-nl.mjs +1 -1
- package/i18n/languages/treb-i18n-no.mjs +1 -1
- package/i18n/languages/treb-i18n-pl.mjs +1 -1
- package/i18n/languages/treb-i18n-pt.mjs +1 -1
- package/i18n/languages/treb-i18n-sv.mjs +1 -1
- package/ooxml-types/README.md +141 -0
- package/ooxml-types/package.json +5 -0
- package/ooxml-types/src/types/drawingml/chart.ts +327 -0
- package/ooxml-types/src/types/drawingml/index.ts +63 -0
- package/ooxml-types/src/types/drawingml/spreadsheetDrawing.ts +105 -0
- package/ooxml-types/src/types/drawingml/theme.ts +104 -0
- package/ooxml-types/src/types/index.ts +3 -0
- package/ooxml-types/src/types/package/contentTypes.ts +49 -0
- package/ooxml-types/src/types/package/docProps.ts +46 -0
- package/ooxml-types/src/types/package/index.ts +17 -0
- package/ooxml-types/src/types/package/relationships.ts +37 -0
- package/ooxml-types/src/types/spreadsheetml/columns.ts +20 -0
- package/ooxml-types/src/types/spreadsheetml/comments.ts +30 -0
- package/ooxml-types/src/types/spreadsheetml/dataFeatures.ts +261 -0
- package/ooxml-types/src/types/spreadsheetml/enums.ts +175 -0
- package/ooxml-types/src/types/spreadsheetml/index.ts +186 -0
- package/ooxml-types/src/types/spreadsheetml/metadata.ts +90 -0
- package/ooxml-types/src/types/spreadsheetml/misc.ts +35 -0
- package/ooxml-types/src/types/spreadsheetml/pageLayout.ts +83 -0
- package/ooxml-types/src/types/spreadsheetml/sharedStrings.ts +33 -0
- package/ooxml-types/src/types/spreadsheetml/sheetData.ts +70 -0
- package/ooxml-types/src/types/spreadsheetml/sheetProperties.ts +86 -0
- package/ooxml-types/src/types/spreadsheetml/sheetViews.ts +51 -0
- package/ooxml-types/src/types/spreadsheetml/sparkline.ts +46 -0
- package/ooxml-types/src/types/spreadsheetml/styles.ts +274 -0
- package/ooxml-types/src/types/spreadsheetml/table.ts +106 -0
- package/ooxml-types/src/types/spreadsheetml/util.ts +15 -0
- package/ooxml-types/src/types/spreadsheetml/workbook.ts +165 -0
- package/ooxml-types/src/types/spreadsheetml/worksheet.ts +60 -0
- package/package.json +13 -11
- package/treb-base-types/src/api_types.ts +1 -1
- package/treb-base-types/src/area-utils.ts +1 -1
- package/treb-base-types/src/area.ts +1 -1
- package/treb-base-types/src/basic_types.ts +1 -1
- package/treb-base-types/src/cell.ts +1 -1
- package/treb-base-types/src/cells.ts +1 -1
- package/treb-base-types/src/color.ts +1 -1
- package/treb-base-types/src/dom-utilities.ts +1 -1
- package/treb-base-types/src/evaluate-options.ts +1 -1
- package/treb-base-types/src/font-stack.ts +1 -1
- package/treb-base-types/src/gradient.ts +1 -1
- package/treb-base-types/src/import.ts +1 -1
- package/treb-base-types/src/index-standalone.ts +1 -1
- package/treb-base-types/src/index.ts +2 -1
- package/treb-base-types/src/layout.ts +1 -1
- package/treb-base-types/src/localization.ts +1 -1
- package/treb-base-types/src/rectangle.ts +1 -1
- package/treb-base-types/src/render_text.ts +7 -1
- package/treb-base-types/src/style.ts +1 -1
- package/treb-base-types/src/table.ts +1 -1
- package/treb-base-types/src/text_part.ts +1 -1
- package/treb-base-types/src/theme.ts +1 -1
- package/treb-base-types/src/union.ts +4 -1
- package/treb-base-types/src/value-type.ts +1 -1
- package/treb-base-types/src/worker-proxy.ts +294 -0
- package/treb-base-types/style/resizable.css +1 -1
- package/treb-calculator/src/calculator.ts +133 -14
- package/treb-calculator/src/complex-math.ts +1 -1
- package/treb-calculator/src/dag/array-vertex.ts +1 -1
- package/treb-calculator/src/dag/calculation_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/graph.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +1 -1
- package/treb-calculator/src/dag/state_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/vertex.ts +1 -1
- package/treb-calculator/src/descriptors.ts +9 -1
- package/treb-calculator/src/expression-calculator.ts +1 -1
- package/treb-calculator/src/function-error.ts +1 -1
- package/treb-calculator/src/function-library.ts +1 -1
- package/treb-calculator/src/functions/base-functions.ts +8 -4
- package/treb-calculator/src/functions/beta.ts +1 -1
- package/treb-calculator/src/functions/checkbox.ts +1 -1
- package/treb-calculator/src/functions/complex-functions.ts +1 -1
- package/treb-calculator/src/functions/date-utils.ts +1 -1
- package/treb-calculator/src/functions/finance-functions.ts +2 -4
- package/treb-calculator/src/functions/fp.ts +1 -1
- package/treb-calculator/src/functions/function-utilities.ts +1 -1
- package/treb-calculator/src/functions/gamma.ts +1 -1
- package/treb-calculator/src/functions/information-functions.ts +1 -1
- package/treb-calculator/src/functions/lambda-functions.ts +4 -1
- package/treb-calculator/src/functions/matrix-functions.ts +1 -1
- package/treb-calculator/src/functions/normal.ts +1 -1
- package/treb-calculator/src/functions/regex-functions.ts +13 -4
- package/treb-calculator/src/functions/sparkline.ts +1 -1
- package/treb-calculator/src/functions/statistics-functions.ts +1 -1
- package/treb-calculator/src/functions/students-t.ts +1 -1
- package/treb-calculator/src/functions/text-functions.ts +5 -1
- package/treb-calculator/src/index.ts +1 -1
- package/treb-calculator/src/notifier-types.ts +1 -1
- package/treb-calculator/src/primitives.ts +1 -1
- package/treb-calculator/src/utilities.ts +1 -1
- package/treb-charts/src/chart-functions.ts +1 -1
- package/treb-charts/src/chart-types.ts +1 -1
- package/treb-charts/src/chart-utils.ts +1 -1
- package/treb-charts/src/chart.ts +1 -1
- package/treb-charts/src/default-chart-renderer.ts +1 -1
- package/treb-charts/src/index.ts +1 -1
- package/treb-charts/src/main.ts +1 -1
- package/treb-charts/src/quicksort.ts +1 -1
- package/treb-charts/src/rectangle.ts +1 -1
- package/treb-charts/src/renderer-type.ts +1 -1
- package/treb-charts/src/renderer.ts +1 -1
- package/treb-charts/src/util.ts +1 -1
- package/treb-charts/style/charts.scss +1 -1
- package/treb-data-model/src/annotation.ts +1 -1
- package/treb-data-model/src/conditional_format.ts +1 -1
- package/treb-data-model/src/data-validation.ts +1 -1
- package/treb-data-model/src/data_model.ts +32 -5
- package/treb-data-model/src/index.ts +1 -1
- package/treb-data-model/src/language-model.ts +1 -1
- package/treb-data-model/src/named.ts +1 -1
- package/treb-data-model/src/serialize_options.ts +1 -1
- package/treb-data-model/src/sheet.ts +1 -1
- package/treb-data-model/src/sheet_collection.ts +1 -1
- package/treb-data-model/src/sheet_selection.ts +1 -1
- package/treb-data-model/src/sheet_types.ts +1 -1
- package/treb-data-model/src/types.ts +1 -1
- package/treb-embed/src/content-types.d.ts +1 -1
- package/treb-embed/src/custom-element/global.d.ts +1 -1
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1 -1
- package/treb-embed/src/custom-element/treb-global.ts +1 -1
- package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +1 -1
- package/treb-embed/src/embedded-spreadsheet.ts +357 -154
- package/treb-embed/src/index.ts +1 -1
- package/treb-embed/src/options.ts +4 -2
- package/treb-embed/src/plugin.ts +1 -1
- package/treb-embed/src/progress-dialog.ts +1 -1
- package/treb-embed/src/selection-state.ts +1 -1
- package/treb-embed/src/spinner.ts +1 -1
- package/treb-embed/src/toolbar-message.ts +6 -1
- package/treb-embed/src/types.ts +13 -1
- package/treb-embed/style/autocomplete.scss +1 -1
- package/treb-embed/style/dark-theme.scss +1 -1
- package/treb-embed/style/defaults.scss +1 -1
- package/treb-embed/style/dialog.scss +1 -1
- package/treb-embed/style/dropdown-select.scss +1 -1
- package/treb-embed/style/font-stacks.scss +1 -1
- package/treb-embed/style/formula-bar.scss +1 -1
- package/treb-embed/style/grid.scss +1 -1
- package/treb-embed/style/layout.scss +1 -1
- package/treb-embed/style/mouse-mask.scss +1 -1
- package/treb-embed/style/note.scss +1 -1
- package/treb-embed/style/overlay-editor.scss +1 -1
- package/treb-embed/style/spinner.scss +1 -1
- package/treb-embed/style/tab-bar.scss +1 -1
- package/treb-embed/style/table.scss +1 -1
- package/treb-embed/style/theme-defaults.scss +1 -1
- package/treb-embed/style/toolbar.scss +1 -1
- package/treb-embed/style/tooltip.scss +1 -1
- package/treb-embed/style/treb-icons.scss +1 -1
- package/treb-embed/style/treb-spreadsheet-element.scss +1 -1
- package/treb-embed/style/z-index.scss +1 -1
- package/treb-export/src/address-type.ts +1 -1
- package/treb-export/src/base-template.ts +1 -1
- package/treb-export/src/column-width.ts +1 -1
- package/treb-export/src/drawing/bubble-chart-template.ts +1 -1
- package/treb-export/src/drawing/chart-template-components2.ts +1 -1
- package/treb-export/src/drawing/chart.ts +1 -1
- package/treb-export/src/drawing/column-chart-template2.ts +1 -1
- package/treb-export/src/drawing/donut-chart-template2.ts +1 -1
- package/treb-export/src/drawing/drawing.ts +1 -1
- package/treb-export/src/drawing/embedded-image.ts +1 -1
- package/treb-export/src/drawing/scatter-chart-template2.ts +1 -1
- package/treb-export/src/export.ts +10 -6
- package/treb-export/src/import-export-messages.ts +61 -0
- package/treb-export/src/import.ts +318 -301
- package/treb-export/src/index.worker.ts +85 -53
- package/treb-export/src/metadata.ts +71 -3
- package/treb-export/src/ooxml.ts +47 -0
- package/treb-export/src/relationship.ts +1 -1
- package/treb-export/src/shared-strings.ts +19 -15
- package/treb-export/src/template-2.ts +1 -1
- package/treb-export/src/unescape_xml.ts +1 -1
- package/treb-export/src/workbook-sheet.ts +11 -6
- package/treb-export/src/workbook-style.ts +137 -25
- package/treb-export/src/workbook-theme.ts +20 -4
- package/treb-export/src/workbook.ts +85 -88
- package/treb-export/src/xml-test.ts +1 -1
- package/treb-export/src/xml-utils.ts +1 -1
- package/treb-export/src/zip-wrapper.ts +1 -1
- package/treb-export/tsconfig.json +2 -1
- package/treb-format/src/format.test.ts +1 -1
- package/treb-format/src/format.ts +12 -5
- package/treb-format/src/format_cache.ts +3 -3
- package/treb-format/src/format_parser.ts +1 -1
- package/treb-format/src/index.ts +1 -1
- package/treb-format/src/number_format_section.ts +1 -1
- package/treb-format/src/value_parser.ts +1 -1
- package/treb-grid/src/editors/autocomplete.ts +1 -1
- package/treb-grid/src/editors/autocomplete_matcher.ts +1 -1
- package/treb-grid/src/editors/editor.ts +15 -6
- package/treb-grid/src/editors/external_editor.ts +33 -8
- package/treb-grid/src/editors/formula_bar.ts +12 -1
- package/treb-grid/src/editors/overlay_editor.ts +4 -1
- package/treb-grid/src/index.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +1 -1
- package/treb-grid/src/layout/grid_layout.ts +1 -1
- package/treb-grid/src/layout/mock-layout.ts +1 -1
- package/treb-grid/src/render/selection-renderer.ts +1 -1
- package/treb-grid/src/render/svg_header_overlay.ts +1 -1
- package/treb-grid/src/render/svg_selection_block.ts +1 -1
- package/treb-grid/src/render/tile_renderer.ts +36 -7
- package/treb-grid/src/types/border_constants.ts +1 -1
- package/treb-grid/src/types/clipboard_data.ts +1 -1
- package/treb-grid/src/types/clipboard_data2.ts +1 -1
- package/treb-grid/src/types/drag_mask.ts +1 -1
- package/treb-grid/src/types/external_editor_config.ts +1 -1
- package/treb-grid/src/types/grid.ts +181 -40
- package/treb-grid/src/types/grid_base.ts +7 -4
- package/treb-grid/src/types/grid_command.ts +7 -1
- package/treb-grid/src/types/grid_events.ts +2 -1
- package/treb-grid/src/types/grid_options.ts +1 -1
- package/treb-grid/src/types/scale-control.ts +1 -1
- package/treb-grid/src/types/set_range_options.ts +1 -1
- package/treb-grid/src/types/tab_bar.ts +1 -1
- package/treb-grid/src/types/tile.ts +1 -1
- package/treb-grid/src/types/update_flags.ts +1 -1
- package/treb-grid/src/util/fontmetrics.ts +1 -1
- package/treb-grid/src/util/ua.ts +1 -1
- package/treb-parser/src/csv-parser.ts +1 -1
- package/treb-parser/src/index.ts +1 -1
- package/treb-parser/src/md-parser.ts +1 -1
- package/treb-parser/src/parser-types.ts +1 -1
- package/treb-parser/src/parser.ts +1 -1
- package/treb-utils/src/event_source.ts +1 -1
- package/treb-utils/src/ievent_source.ts +1 -1
- package/treb-utils/src/index.ts +1 -1
- package/treb-utils/src/measurement.ts +1 -1
- package/treb-utils/src/scale.ts +1 -1
- package/treb-utils/src/serialize_html.ts +1 -1
- package/treb-utils/src/validate_uri.ts +1 -1
- package/tsproject.json +2 -3
- package/treb-embed/src/export-worker.ts +0 -44
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
SheetChangeEvent, GridOptions,
|
|
27
27
|
CellEvent, FunctionDescriptor,
|
|
28
28
|
ExternalEditorConfig,
|
|
29
|
+
GridSelectionEvent,
|
|
29
30
|
} from 'treb-grid';
|
|
30
31
|
|
|
31
32
|
import { DataModel, Sheet, StandardGradientsList } from 'treb-data-model';
|
|
@@ -74,6 +75,7 @@ import type {
|
|
|
74
75
|
IArea, CellValue, Point,
|
|
75
76
|
Complex, ExtendedUnion, IRectangle,
|
|
76
77
|
AddressReference, RangeReference, TableSortOptions, Table, TableTheme,
|
|
78
|
+
Theme,
|
|
77
79
|
} from 'treb-base-types';
|
|
78
80
|
|
|
79
81
|
import {
|
|
@@ -92,7 +94,7 @@ import { NumberFormatCache, ValueParser, NumberFormat, LotusDate, UnlotusDate }
|
|
|
92
94
|
import { Dialog, DialogType } from './progress-dialog';
|
|
93
95
|
import { Spinner } from './spinner';
|
|
94
96
|
import { type EmbeddedSpreadsheetOptions, DefaultOptions, type ExportOptions } from './options';
|
|
95
|
-
import { type TREBDocument, SaveFileType, LoadSource, type EmbeddedSheetEvent, type InsertTableOptions } from './types';
|
|
97
|
+
import { type TREBDocument, SaveFileType, LoadSource, type EmbeddedSheetEvent, type InsertTableOptions, type SelectionEvent } from './types';
|
|
96
98
|
|
|
97
99
|
import type { SelectionState } from './selection-state';
|
|
98
100
|
import type { BorderToolbarMessage, ToolbarMessage } from './toolbar-message';
|
|
@@ -102,6 +104,7 @@ import type { SetRangeOptions, ClipboardData, PasteOptions } from 'treb-grid';
|
|
|
102
104
|
|
|
103
105
|
import type { StateLeafVertex } from 'treb-calculator';
|
|
104
106
|
|
|
107
|
+
import * as ImportExportMessages from 'treb-export/src/import-export-messages';
|
|
105
108
|
|
|
106
109
|
// --- worker ------------------------------------------------------------------
|
|
107
110
|
|
|
@@ -109,9 +112,20 @@ import type { StateLeafVertex } from 'treb-calculator';
|
|
|
109
112
|
* import type for our worker, plus markup files
|
|
110
113
|
*/
|
|
111
114
|
import './content-types.d.ts';
|
|
115
|
+
import { CreateWorker, type WorkerProxy } from 'treb-base-types';
|
|
112
116
|
|
|
113
117
|
// --- types -------------------------------------------------------------------
|
|
114
118
|
|
|
119
|
+
/** new, intended for tui support but keeping it as generic as possible */
|
|
120
|
+
export type CustomGridFactory = (
|
|
121
|
+
options: GridOptions,
|
|
122
|
+
model: DataModel,
|
|
123
|
+
theme: Theme|undefined,
|
|
124
|
+
initialze_dom: boolean,
|
|
125
|
+
DOM: DOMContext,
|
|
126
|
+
) => Grid;
|
|
127
|
+
|
|
128
|
+
|
|
115
129
|
/**
|
|
116
130
|
* options for saving files. we add the option for JSON formatting.
|
|
117
131
|
*/
|
|
@@ -164,8 +178,11 @@ export interface LoadDocumentOptions {
|
|
|
164
178
|
/** @internal */
|
|
165
179
|
override_selection?: GridSelection,
|
|
166
180
|
|
|
167
|
-
/** @internal */
|
|
168
181
|
source?: LoadSource,
|
|
182
|
+
|
|
183
|
+
/** opaque data for reference */
|
|
184
|
+
path?: string;
|
|
185
|
+
|
|
169
186
|
}
|
|
170
187
|
|
|
171
188
|
/**
|
|
@@ -243,6 +260,18 @@ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue
|
|
|
243
260
|
*/
|
|
244
261
|
export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
245
262
|
|
|
263
|
+
/**
|
|
264
|
+
* this is temporary. we need a better way to handle this, perhaps
|
|
265
|
+
* making the factory method (createSpreadsheet) async.
|
|
266
|
+
*
|
|
267
|
+
* for now, you can test on this set of promises to see when the
|
|
268
|
+
* app is ready
|
|
269
|
+
*/
|
|
270
|
+
protected _ready_state: Promise<void>[] = [];
|
|
271
|
+
public get ready () {
|
|
272
|
+
return Promise.all(this._ready_state);
|
|
273
|
+
}
|
|
274
|
+
|
|
246
275
|
/** @internal */
|
|
247
276
|
public static treb_base_path = '';
|
|
248
277
|
|
|
@@ -463,8 +492,10 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
463
492
|
/**
|
|
464
493
|
* export worker (no longer using worker-loader).
|
|
465
494
|
* export worker is loaded on demand, not by default.
|
|
495
|
+
*
|
|
496
|
+
* FIXME: type
|
|
466
497
|
*/
|
|
467
|
-
protected export_worker?:
|
|
498
|
+
protected export_worker?: WorkerProxy<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>;
|
|
468
499
|
|
|
469
500
|
/**
|
|
470
501
|
* undo pointer points to the next insert spot. that means that when
|
|
@@ -651,7 +682,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
651
682
|
*
|
|
652
683
|
* @internal
|
|
653
684
|
*/
|
|
654
|
-
constructor(options: EmbeddedSpreadsheetOptions & { model?: EmbeddedSpreadsheet }) {
|
|
685
|
+
constructor(options: EmbeddedSpreadsheetOptions & { model?: EmbeddedSpreadsheet, custom_grid?: CustomGridFactory }) {
|
|
655
686
|
|
|
656
687
|
// we renamed this option, default to the new name
|
|
657
688
|
|
|
@@ -832,8 +863,12 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
832
863
|
|
|
833
864
|
}
|
|
834
865
|
|
|
835
|
-
//
|
|
836
|
-
//
|
|
866
|
+
// FIXME: we should start figuring out what can happen before
|
|
867
|
+
// this async init, and what has to wait. then we can split the
|
|
868
|
+
// ctor into two parts, and move stuff that has to wait to part 2
|
|
869
|
+
|
|
870
|
+
const calculator_init = this.calculator.InitResources();
|
|
871
|
+
this._ready_state.push(calculator_init);
|
|
837
872
|
|
|
838
873
|
if (container) {
|
|
839
874
|
this.DOM = DOMContext.GetInstance(container.ownerDocument);
|
|
@@ -847,12 +882,30 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
847
882
|
// it when we don't have a container? or was it built for something
|
|
848
883
|
// else? (A: it was)
|
|
849
884
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
885
|
+
if (options.custom_grid) {
|
|
886
|
+
this.grid = options.custom_grid(
|
|
887
|
+
grid_options,
|
|
888
|
+
this.model,
|
|
889
|
+
undefined,
|
|
890
|
+
!!container,
|
|
891
|
+
this.DOM);
|
|
892
|
+
|
|
893
|
+
// we're going to need to create some sort of capabilities map
|
|
894
|
+
// for custom grids. for the time being, let's subscribe to events
|
|
895
|
+
// and see what happens.
|
|
896
|
+
|
|
897
|
+
// UPDATE: do that a little later...
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
this.grid = new Grid(
|
|
903
|
+
grid_options,
|
|
904
|
+
this.model,
|
|
905
|
+
undefined,
|
|
906
|
+
!!container,
|
|
907
|
+
this.DOM);
|
|
908
|
+
}
|
|
856
909
|
|
|
857
910
|
if (this.options.headless) {
|
|
858
911
|
this.grid.headless = true; // FIXME: move into grid options
|
|
@@ -970,7 +1023,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
970
1023
|
|
|
971
1024
|
case 'selection':
|
|
972
1025
|
// console.info('selection event');
|
|
973
|
-
this.UpdateSelection(event.selection);
|
|
1026
|
+
this.UpdateSelection(event.selection, event.reason);
|
|
974
1027
|
this.UpdateSelectionStyle(event.selection);
|
|
975
1028
|
break;
|
|
976
1029
|
|
|
@@ -1133,11 +1186,204 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1133
1186
|
|
|
1134
1187
|
}
|
|
1135
1188
|
else {
|
|
1189
|
+
|
|
1190
|
+
if (options.custom_grid) {
|
|
1191
|
+
console.info("creating subscription for custom grid (TODO: capabilities)")
|
|
1192
|
+
|
|
1193
|
+
////
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
this.grid.grid_events.Subscribe((event) => {
|
|
1197
|
+
|
|
1198
|
+
// console.info({event});
|
|
1199
|
+
|
|
1200
|
+
switch (event.type) {
|
|
1201
|
+
|
|
1202
|
+
// these messages can stack, they don't have undo effect
|
|
1203
|
+
|
|
1204
|
+
case 'error':
|
|
1205
|
+
/*
|
|
1206
|
+
this.dialog?.ShowDialog({
|
|
1207
|
+
type: DialogType.error,
|
|
1208
|
+
...this.TranslateGridError(event.code),
|
|
1209
|
+
timeout: 3000,
|
|
1210
|
+
close_box: true,
|
|
1211
|
+
});
|
|
1212
|
+
*/
|
|
1213
|
+
|
|
1214
|
+
// ??
|
|
1215
|
+
|
|
1216
|
+
break;
|
|
1217
|
+
|
|
1218
|
+
case 'selection':
|
|
1219
|
+
// console.info('selection event');
|
|
1220
|
+
this.UpdateSelection(event.selection, event.reason);
|
|
1221
|
+
this.UpdateSelectionStyle(event.selection);
|
|
1222
|
+
break;
|
|
1223
|
+
|
|
1224
|
+
case 'sheet-change':
|
|
1225
|
+
this.OnSheetChange(event);
|
|
1226
|
+
this.UpdateSelectionStyle();
|
|
1227
|
+
break;
|
|
1228
|
+
|
|
1229
|
+
case 'scale':
|
|
1230
|
+
this.RebuildAllAnnotations();
|
|
1231
|
+
this.Publish({ type: 'view-change' });
|
|
1232
|
+
break;
|
|
1233
|
+
|
|
1234
|
+
case 'cell-event':
|
|
1235
|
+
this.HandleCellEvent(event);
|
|
1236
|
+
break;
|
|
1237
|
+
|
|
1238
|
+
// messages that trigger undo need some special handling,
|
|
1239
|
+
// because we don't want to stack a sequence of messages
|
|
1240
|
+
// and push multiple undo events. that applies to data,
|
|
1241
|
+
// style, structure, and (maybe?) annotations
|
|
1242
|
+
|
|
1243
|
+
// OK, temp we have a composite event for data+style
|
|
1244
|
+
|
|
1245
|
+
case 'composite':
|
|
1246
|
+
{
|
|
1247
|
+
const cached_selection = this.last_selection;
|
|
1248
|
+
if (this.calculation === CalculationOptions.automatic) {
|
|
1249
|
+
this.Recalculate(event);
|
|
1250
|
+
}
|
|
1251
|
+
this.DocumentChange(cached_selection);
|
|
1252
|
+
this.UpdateDocumentStyles();
|
|
1253
|
+
this.UpdateSelectionStyle();
|
|
1254
|
+
}
|
|
1255
|
+
break;
|
|
1256
|
+
|
|
1257
|
+
case 'data':
|
|
1258
|
+
{
|
|
1259
|
+
// because this is async (more than once), we can't expect the
|
|
1260
|
+
// selection event to happen after the PushUndo call. we need
|
|
1261
|
+
// to preserve the current selection and pass it through.
|
|
1262
|
+
|
|
1263
|
+
const cached_selection = this.last_selection;
|
|
1264
|
+
|
|
1265
|
+
// recalc is no longer async
|
|
1266
|
+
|
|
1267
|
+
if (this.calculation === CalculationOptions.automatic) {
|
|
1268
|
+
this.Recalculate(event);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
this.DocumentChange(cached_selection);
|
|
1272
|
+
|
|
1273
|
+
}
|
|
1274
|
+
break;
|
|
1275
|
+
|
|
1276
|
+
case 'style':
|
|
1277
|
+
this.DocumentChange();
|
|
1278
|
+
this.UpdateDocumentStyles();
|
|
1279
|
+
this.UpdateSelectionStyle();
|
|
1280
|
+
break;
|
|
1281
|
+
|
|
1282
|
+
case 'annotation':
|
|
1283
|
+
|
|
1284
|
+
/*
|
|
1285
|
+
// FIXME: maybe need to update vertices (on create, update, delete,
|
|
1286
|
+
// not on move or resize)
|
|
1287
|
+
|
|
1288
|
+
if (event.annotation) {
|
|
1289
|
+
const view: AnnotationViewData = event.annotation.view[this.grid.view_index] || {};
|
|
1290
|
+
|
|
1291
|
+
let update_toolbar = false;
|
|
1292
|
+
|
|
1293
|
+
if (event.event === 'select') {
|
|
1294
|
+
update_toolbar = true;
|
|
1295
|
+
}
|
|
1296
|
+
else {
|
|
1297
|
+
this.DocumentChange();
|
|
1298
|
+
switch (event.event) {
|
|
1299
|
+
case 'create':
|
|
1300
|
+
this.InflateAnnotation(event.annotation);
|
|
1301
|
+
this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
|
|
1302
|
+
this.grid.AnnotationUpdated(event.annotation);
|
|
1303
|
+
update_toolbar = (event.annotation === this.grid.selected_annotation);
|
|
1304
|
+
break;
|
|
1305
|
+
case 'delete':
|
|
1306
|
+
this.calculator.RemoveAnnotation(event.annotation); // clean up vertex
|
|
1307
|
+
break;
|
|
1308
|
+
case 'update':
|
|
1309
|
+
if (view.update_callback) {
|
|
1310
|
+
view.update_callback();
|
|
1311
|
+
this.grid.AnnotationUpdated(event.annotation);
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
console.info('annotation update event without update callback');
|
|
1315
|
+
}
|
|
1316
|
+
this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
|
|
1317
|
+
update_toolbar = (event.annotation === this.grid.selected_annotation);
|
|
1318
|
+
break;
|
|
1319
|
+
case 'resize':
|
|
1320
|
+
if (view.resize_callback) {
|
|
1321
|
+
view.resize_callback();
|
|
1322
|
+
this.grid.AnnotationUpdated(event.annotation);
|
|
1323
|
+
}
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if (update_toolbar) {
|
|
1330
|
+
this.UpdateSelectionStyleAnnotation(event.annotation);
|
|
1331
|
+
this.Publish({ type: 'annotation-selection' });
|
|
1332
|
+
break;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
console.info('annotation event without annotation');
|
|
1338
|
+
}
|
|
1339
|
+
*/
|
|
1340
|
+
break;
|
|
1341
|
+
|
|
1342
|
+
case 'structure':
|
|
1343
|
+
{
|
|
1344
|
+
// console.info("S event", event);
|
|
1345
|
+
|
|
1346
|
+
const cached_selection = this.last_selection;
|
|
1347
|
+
if (event.conditional_format) {
|
|
1348
|
+
this.calculator.UpdateConditionals();
|
|
1349
|
+
this.ApplyConditionalFormats(this.grid.active_sheet, false);
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
if (event.rebuild_required) {
|
|
1353
|
+
this.calculator.Reset();
|
|
1354
|
+
|
|
1355
|
+
// recalculate is no longer async
|
|
1356
|
+
|
|
1357
|
+
if (this.calculation === CalculationOptions.automatic) {
|
|
1358
|
+
this.Recalculate(event);
|
|
1359
|
+
}
|
|
1360
|
+
this.DocumentChange(cached_selection);
|
|
1361
|
+
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
this.DocumentChange(cached_selection);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
this.UpdateSelectionStyle();
|
|
1368
|
+
break;
|
|
1369
|
+
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
|
|
1373
|
+
////
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1136
1378
|
if (!EmbeddedSpreadsheet.one_time_warnings.headless) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1379
|
+
|
|
1380
|
+
// suppress this warning if you explicitly set headless mode
|
|
1381
|
+
|
|
1382
|
+
if (!options.headless) {
|
|
1383
|
+
EmbeddedSpreadsheet.one_time_warnings.headless = true;
|
|
1384
|
+
console.info('not initializing layout; don\'t call UI functions');
|
|
1385
|
+
}
|
|
1139
1386
|
}
|
|
1140
|
-
// this.grid.headless = true; // ensure
|
|
1141
1387
|
}
|
|
1142
1388
|
|
|
1143
1389
|
if (options.preload) {
|
|
@@ -1151,7 +1397,9 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1151
1397
|
data = JSON.parse(data);
|
|
1152
1398
|
}
|
|
1153
1399
|
if (data) {
|
|
1154
|
-
|
|
1400
|
+
calculator_init.then(() => {
|
|
1401
|
+
this.LoadDocument(data as TREBDocument, { recalculate: !!this.options.recalculate, source});
|
|
1402
|
+
});
|
|
1155
1403
|
}
|
|
1156
1404
|
else {
|
|
1157
1405
|
this.UpdateDocumentStyles();
|
|
@@ -1206,13 +1454,16 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1206
1454
|
this.spinner = new Spinner(container);
|
|
1207
1455
|
}
|
|
1208
1456
|
|
|
1457
|
+
|
|
1209
1458
|
// don't load if we are a split view
|
|
1210
1459
|
// UPDATE: don't load if we have a local_storage document. this is taking
|
|
1211
1460
|
// over the old alternate_document flow, because it doesn't make any sense
|
|
1212
1461
|
// otherwise. what would local_storage with document_name mean otherwise?
|
|
1213
1462
|
|
|
1214
1463
|
if (network_document && !options.model && !data) {
|
|
1215
|
-
|
|
1464
|
+
calculator_init.then(() => {
|
|
1465
|
+
this.LoadNetworkDocument(network_document, this.options);
|
|
1466
|
+
});
|
|
1216
1467
|
}
|
|
1217
1468
|
|
|
1218
1469
|
// create mask dialog
|
|
@@ -1286,6 +1537,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1286
1537
|
return new Calculator(model, {
|
|
1287
1538
|
complex_numbers: options.complex,
|
|
1288
1539
|
spill: options.spill,
|
|
1540
|
+
headless: options.headless,
|
|
1289
1541
|
});
|
|
1290
1542
|
}
|
|
1291
1543
|
|
|
@@ -1881,6 +2133,17 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1881
2133
|
case 'insert-scatter-plot': insert_annotation('Scatter.Plot'); break;
|
|
1882
2134
|
case 'insert-box-plot': insert_annotation('Box.Plot'); break;
|
|
1883
2135
|
|
|
2136
|
+
case 'toggle-grouping':
|
|
2137
|
+
if (this.selection_state?.style) {
|
|
2138
|
+
const format = NumberFormatCache.Get(this.selection_state.style.number_format || 'General');
|
|
2139
|
+
if (format.date_format) { break; }
|
|
2140
|
+
const clone = new NumberFormat(format.pattern);
|
|
2141
|
+
clone.ToggleGrouping();
|
|
2142
|
+
const rendered = clone.toString();
|
|
2143
|
+
updated_style.number_format = NumberFormatCache.SymbolicName(rendered) || rendered;
|
|
2144
|
+
}
|
|
2145
|
+
break;
|
|
2146
|
+
|
|
1884
2147
|
case 'increase-precision':
|
|
1885
2148
|
case 'decrease-precision':
|
|
1886
2149
|
if (this.selection_state?.style) {
|
|
@@ -1890,78 +2153,18 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
1890
2153
|
|
|
1891
2154
|
const clone = new NumberFormat(format.pattern);
|
|
1892
2155
|
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
// NOTE: this isn't really the way to identify this, we only want
|
|
1897
|
-
// to do this if the style === 'General'.
|
|
1898
|
-
|
|
1899
|
-
if (format.magic_decimal) {
|
|
1900
|
-
|
|
1901
|
-
// but what we're doing here, if there's a magic decimal, is
|
|
1902
|
-
// measuring the decimal part of the first number we find. then
|
|
1903
|
-
// we increase/decrease from that.
|
|
1904
|
-
|
|
1905
|
-
let len = 0;
|
|
1906
|
-
let rng = this.GetRange();
|
|
1907
|
-
|
|
1908
|
-
// find the first number...
|
|
1909
|
-
|
|
1910
|
-
if (!Array.isArray(rng)) {
|
|
1911
|
-
rng = [[rng]];
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
find_number:
|
|
1915
|
-
for (let i = 0; i < rng.length; i++) {
|
|
1916
|
-
for (let j = 0; j < rng[i].length; j++) {
|
|
1917
|
-
const value = rng[i][j];
|
|
1918
|
-
|
|
1919
|
-
if (typeof value !== 'undefined' && IsComplex(value)) {
|
|
1920
|
-
|
|
1921
|
-
// find the longer of the two, use that as base
|
|
1922
|
-
|
|
1923
|
-
//const f2 = NumberFormatCache.Get(this.active_selection_style.number_format || 'General', true);
|
|
1924
|
-
const f2 = NumberFormatCache.Get(this.selection_state.style.number_format || 'General', true);
|
|
1925
|
-
const real_parts = f2.BaseFormat(value.real);
|
|
1926
|
-
const imaginary_parts = f2.BaseFormat(value.imaginary);
|
|
1927
|
-
|
|
1928
|
-
if (real_parts.parts && typeof real_parts.parts[1] === 'string') {
|
|
1929
|
-
len = real_parts.parts[1].length;
|
|
1930
|
-
}
|
|
1931
|
-
if (imaginary_parts.parts && typeof imaginary_parts.parts[1] === 'string') {
|
|
1932
|
-
len = Math.max(len, imaginary_parts.parts[1].length);
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
break find_number;
|
|
1936
|
-
|
|
1937
|
-
}
|
|
1938
|
-
else if (typeof value === 'number') {
|
|
1939
|
-
const parts = format.BaseFormat(value);
|
|
1940
|
-
if (parts.parts && typeof parts.parts[1] === 'string') {
|
|
1941
|
-
len = parts.parts[1].length;
|
|
1942
|
-
}
|
|
1943
|
-
break find_number;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
if (event.command === 'increase-precision') {
|
|
1949
|
-
clone.SetDecimal(len + 1);
|
|
1950
|
-
}
|
|
1951
|
-
else {
|
|
1952
|
-
clone.SetDecimal(Math.max(0, len - 1));
|
|
1953
|
-
}
|
|
1954
|
-
|
|
2156
|
+
if (event.command === 'increase-precision' ) {
|
|
2157
|
+
clone.IncreaseDecimal();
|
|
1955
2158
|
}
|
|
1956
2159
|
else {
|
|
1957
|
-
|
|
1958
|
-
clone.IncreaseDecimal();
|
|
1959
|
-
}
|
|
1960
|
-
else {
|
|
1961
|
-
clone.DecreaseDecimal();
|
|
1962
|
-
}
|
|
2160
|
+
clone.DecreaseDecimal();
|
|
1963
2161
|
}
|
|
1964
|
-
|
|
2162
|
+
|
|
2163
|
+
// try to resolve this to a standard format, if possible
|
|
2164
|
+
|
|
2165
|
+
const rendered = clone.toString();
|
|
2166
|
+
updated_style.number_format = NumberFormatCache.SymbolicName(rendered) || rendered;
|
|
2167
|
+
|
|
1965
2168
|
}
|
|
1966
2169
|
break;
|
|
1967
2170
|
|
|
@@ -2203,7 +2406,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
2203
2406
|
// comments
|
|
2204
2407
|
|
|
2205
2408
|
try {
|
|
2206
|
-
|
|
2409
|
+
const path = `./languages/treb-i18n-${language}.mjs`;
|
|
2410
|
+
mod = await import(path);
|
|
2207
2411
|
}
|
|
2208
2412
|
catch (err) {
|
|
2209
2413
|
console.error(err);
|
|
@@ -2222,6 +2426,10 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
2222
2426
|
this.grid.Update(true);
|
|
2223
2427
|
this.UpdateAC();
|
|
2224
2428
|
|
|
2429
|
+
this.Publish({
|
|
2430
|
+
type: 'language-change',
|
|
2431
|
+
});
|
|
2432
|
+
|
|
2225
2433
|
}
|
|
2226
2434
|
|
|
2227
2435
|
/**
|
|
@@ -2870,6 +3078,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
2870
3078
|
*
|
|
2871
3079
|
* @param column - column, or columns (array), or undefined means all columns
|
|
2872
3080
|
* @param width - desired width (can be 0) or undefined means 'auto-size'
|
|
3081
|
+
* @param allow_shrinking - for auto-size, allow shrinking. defaults to true.
|
|
2873
3082
|
*
|
|
2874
3083
|
* @privateRemarks
|
|
2875
3084
|
*
|
|
@@ -2878,9 +3087,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
2878
3087
|
*
|
|
2879
3088
|
* @public
|
|
2880
3089
|
*/
|
|
2881
|
-
public SetColumnWidth(column?: number | number[], width?: number): void {
|
|
2882
|
-
|
|
2883
|
-
this.grid.SetColumnWidth(column, width);
|
|
3090
|
+
public SetColumnWidth(column?: number | number[], width?: number, allow_shrinking?: boolean): void {
|
|
3091
|
+
this.grid.SetColumnWidth(column, width, allow_shrinking);
|
|
2884
3092
|
}
|
|
2885
3093
|
|
|
2886
3094
|
/**
|
|
@@ -3084,14 +3292,16 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
3084
3292
|
return new Promise<Blob>((resolve, reject) => {
|
|
3085
3293
|
|
|
3086
3294
|
if (this.export_worker) {
|
|
3087
|
-
this.export_worker.
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3295
|
+
this.export_worker.OnMessage((event) => {
|
|
3296
|
+
if (event.data.type === 'export-complete') {
|
|
3297
|
+
resolve(event.data.blob);
|
|
3298
|
+
}
|
|
3299
|
+
});
|
|
3300
|
+
this.export_worker.OnError((event) => {
|
|
3091
3301
|
console.error('export worker error');
|
|
3092
3302
|
console.info(event);
|
|
3093
3303
|
reject(event);
|
|
3094
|
-
};
|
|
3304
|
+
});
|
|
3095
3305
|
|
|
3096
3306
|
if (!serialized) {
|
|
3097
3307
|
serialized = this.Serialize({
|
|
@@ -3109,8 +3319,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
3109
3319
|
// why do _we_ put this in, instead of the grid method?
|
|
3110
3320
|
serialized.decimal_mark = Localization.decimal_separator;
|
|
3111
3321
|
|
|
3112
|
-
this.export_worker.
|
|
3113
|
-
|
|
3322
|
+
this.export_worker.PostMessage({
|
|
3323
|
+
type: 'export',
|
|
3114
3324
|
sheet: serialized,
|
|
3115
3325
|
decorated: this.calculator.DecoratedFunctionList(),
|
|
3116
3326
|
});
|
|
@@ -3750,7 +3960,11 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
3750
3960
|
|
|
3751
3961
|
}
|
|
3752
3962
|
|
|
3753
|
-
this.Publish({
|
|
3963
|
+
this.Publish({
|
|
3964
|
+
type: 'load',
|
|
3965
|
+
source: options.source,
|
|
3966
|
+
path: options.path,
|
|
3967
|
+
}); // FIXME: should not happen on undo...
|
|
3754
3968
|
this.UpdateDocumentStyles();
|
|
3755
3969
|
this.loaded = true;
|
|
3756
3970
|
|
|
@@ -4041,7 +4255,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
4041
4255
|
|
|
4042
4256
|
this.calculator.Calculate(area);
|
|
4043
4257
|
|
|
4044
|
-
if (this.calculator.grid_expanded) {
|
|
4258
|
+
if (this.calculator.grid_expanded && !this.grid.headless) {
|
|
4045
4259
|
// console.info("GRID EXPANDED");
|
|
4046
4260
|
this.grid.UpdateLayout();
|
|
4047
4261
|
}
|
|
@@ -4090,8 +4304,9 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
4090
4304
|
* Revert state one level from the undo stack.
|
|
4091
4305
|
*
|
|
4092
4306
|
* @public
|
|
4307
|
+
* @returns true if undo succeeded, false if the undo stack was empty
|
|
4093
4308
|
*/
|
|
4094
|
-
public Undo():
|
|
4309
|
+
public Undo(): boolean {
|
|
4095
4310
|
|
|
4096
4311
|
// this is half of the problem, we also need to manage views when
|
|
4097
4312
|
// we set undo states
|
|
@@ -4104,7 +4319,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
4104
4319
|
|
|
4105
4320
|
if (this.undo_pointer <= 1) {
|
|
4106
4321
|
console.warn('nothing to undo');
|
|
4107
|
-
return;
|
|
4322
|
+
return false;
|
|
4108
4323
|
}
|
|
4109
4324
|
|
|
4110
4325
|
const undo_entry = this.undo_stack[(--this.undo_pointer) - 1];
|
|
@@ -4134,6 +4349,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
4134
4349
|
|
|
4135
4350
|
// this.file_version--; // decrement
|
|
4136
4351
|
|
|
4352
|
+
return true;
|
|
4353
|
+
|
|
4137
4354
|
}
|
|
4138
4355
|
|
|
4139
4356
|
|
|
@@ -5060,8 +5277,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5060
5277
|
/**
|
|
5061
5278
|
*
|
|
5062
5279
|
*/
|
|
5063
|
-
|
|
5064
|
-
data: ArrayBuffer, source: LoadSource): Promise<Blob | void> {
|
|
5280
|
+
public async ImportXLSX( // data: string, source: LoadSource): Promise<Blob | void> {
|
|
5281
|
+
data: ArrayBuffer, source: LoadSource, path?: string): Promise<Blob | void> {
|
|
5065
5282
|
|
|
5066
5283
|
// this is inlined to ensure the code will be tree-shaken properly
|
|
5067
5284
|
if (!process.env.XLSX_SUPPORT) {
|
|
@@ -5089,12 +5306,15 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5089
5306
|
message: 'Importing XLSX...'
|
|
5090
5307
|
});
|
|
5091
5308
|
|
|
5092
|
-
this.export_worker.
|
|
5309
|
+
this.export_worker.OnMessage((event) => {
|
|
5093
5310
|
if (event.data) {
|
|
5094
5311
|
|
|
5095
|
-
if (event.data.
|
|
5312
|
+
if (event.data.type === 'import-error') {
|
|
5096
5313
|
return reject(event.data.error || 'unknown error');
|
|
5097
5314
|
}
|
|
5315
|
+
if (event.data.type !== 'import-complete') {
|
|
5316
|
+
return reject('unknown error (invalid message)');
|
|
5317
|
+
}
|
|
5098
5318
|
|
|
5099
5319
|
if (this.parser.decimal_mark !== DecimalMarkType.Period) {
|
|
5100
5320
|
|
|
@@ -5118,15 +5338,15 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5118
5338
|
});
|
|
5119
5339
|
};
|
|
5120
5340
|
|
|
5121
|
-
for (const named of event.data.results) {
|
|
5122
|
-
named.expression = translate(named.expression);
|
|
5341
|
+
for (const named of event.data.results.named || []) {
|
|
5342
|
+
named.expression = translate(named.expression) || '';
|
|
5123
5343
|
}
|
|
5124
5344
|
|
|
5125
5345
|
for (const sheet of event.data.results.sheets || []) {
|
|
5126
5346
|
|
|
5127
5347
|
for (const cell of sheet.cells || []) {
|
|
5128
5348
|
if (cell.type === 'formula' && cell.value) {
|
|
5129
|
-
cell.value = translate(cell.value);
|
|
5349
|
+
cell.value = translate(cell.value as string);
|
|
5130
5350
|
}
|
|
5131
5351
|
}
|
|
5132
5352
|
|
|
@@ -5152,7 +5372,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5152
5372
|
// this one _is_ the grid cells
|
|
5153
5373
|
|
|
5154
5374
|
// this.calculator.AttachModel();
|
|
5155
|
-
this.Publish({ type: 'load', source, });
|
|
5375
|
+
this.Publish({ type: 'load', source, path });
|
|
5156
5376
|
this.UpdateDocumentStyles();
|
|
5157
5377
|
|
|
5158
5378
|
// add to support import charts
|
|
@@ -5171,15 +5391,18 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5171
5391
|
|
|
5172
5392
|
this.dialog?.HideDialog();
|
|
5173
5393
|
resolve();
|
|
5174
|
-
};
|
|
5175
|
-
|
|
5394
|
+
});
|
|
5395
|
+
|
|
5396
|
+
this.export_worker.OnError((event) => {
|
|
5176
5397
|
console.error('import worker error');
|
|
5177
5398
|
console.info(event);
|
|
5178
5399
|
reject(event);
|
|
5179
|
-
};
|
|
5180
|
-
this.export_worker.postMessage({
|
|
5181
|
-
command: 'import', data,
|
|
5182
5400
|
});
|
|
5401
|
+
|
|
5402
|
+
this.export_worker.PostMessage({
|
|
5403
|
+
type: 'import', data,
|
|
5404
|
+
});
|
|
5405
|
+
|
|
5183
5406
|
}
|
|
5184
5407
|
else {
|
|
5185
5408
|
reject('worker failed');
|
|
@@ -5630,21 +5853,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
5630
5853
|
}
|
|
5631
5854
|
}
|
|
5632
5855
|
|
|
5633
|
-
/*
|
|
5634
|
-
public SetHeadless(headless = true): void {
|
|
5635
|
-
if (this.grid.headless === headless) {
|
|
5636
|
-
return;
|
|
5637
|
-
}
|
|
5638
|
-
|
|
5639
|
-
this.grid.headless = headless;
|
|
5640
|
-
if (!headless) {
|
|
5641
|
-
this.grid.Update(true);
|
|
5642
|
-
this.RebuildAllAnnotations();
|
|
5643
|
-
// this.InflateAnnotations();
|
|
5644
|
-
}
|
|
5645
|
-
}
|
|
5646
|
-
*/
|
|
5647
|
-
|
|
5648
5856
|
/**
|
|
5649
5857
|
* this method should be called after changing the headless flag
|
|
5650
5858
|
*/
|
|
@@ -6119,14 +6327,19 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
6119
6327
|
* we can also use this to better manage selection in the undo system...
|
|
6120
6328
|
*
|
|
6121
6329
|
*/
|
|
6122
|
-
protected UpdateSelection(selection: GridSelection): void {
|
|
6330
|
+
protected UpdateSelection(selection: GridSelection, reason?: GridSelectionEvent['reason']): void {
|
|
6123
6331
|
|
|
6124
6332
|
// console.info("US", JSON.stringify(selection));
|
|
6125
6333
|
|
|
6126
6334
|
// cache for undo
|
|
6127
6335
|
this.last_selection = JSON.stringify(selection);
|
|
6128
6336
|
|
|
6129
|
-
|
|
6337
|
+
const event: SelectionEvent = { type: 'selection' };
|
|
6338
|
+
if (reason === 'sheet-change') {
|
|
6339
|
+
event.reason = reason;
|
|
6340
|
+
}
|
|
6341
|
+
|
|
6342
|
+
this.Publish(event);
|
|
6130
6343
|
}
|
|
6131
6344
|
|
|
6132
6345
|
/** update selection style for the toolbar, when an annotation is selected. */
|
|
@@ -6240,12 +6453,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
6240
6453
|
|
|
6241
6454
|
}
|
|
6242
6455
|
|
|
6243
|
-
/* * overloadable for subclasses * /
|
|
6244
|
-
protected InitCalculator(): CalcType {
|
|
6245
|
-
return new Calculator();
|
|
6246
|
-
}
|
|
6247
|
-
*/
|
|
6248
|
-
|
|
6249
6456
|
/**
|
|
6250
6457
|
* this function is called when the file locale (as indicated by the
|
|
6251
6458
|
* decimal separator) is different than the current active locale.
|
|
@@ -6577,21 +6784,17 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
6577
6784
|
}
|
|
6578
6785
|
|
|
6579
6786
|
/**
|
|
6580
|
-
*
|
|
6581
|
-
*
|
|
6582
|
-
*/
|
|
6583
|
-
protected async LoadWorker(): Promise<
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
};
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
catch (err) {
|
|
6592
|
-
console.error(err);
|
|
6593
|
-
throw(err);
|
|
6594
|
-
}
|
|
6787
|
+
* switching to worker proxy so we can support node
|
|
6788
|
+
* FIXME: type
|
|
6789
|
+
*/
|
|
6790
|
+
protected async LoadWorker(): Promise<WorkerProxy<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>> {
|
|
6791
|
+
const worker = CreateWorker<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>(!!this.options.in_process_workers);
|
|
6792
|
+
await worker.Init('./treb-export-worker.mjs', () => {
|
|
6793
|
+
return new Worker(new URL('./treb-export-worker.mjs', import.meta.url), {
|
|
6794
|
+
type: 'module'
|
|
6795
|
+
}) as Worker;
|
|
6796
|
+
});
|
|
6797
|
+
return worker;
|
|
6595
6798
|
}
|
|
6596
6799
|
|
|
6597
6800
|
/**
|