handsontable 0.0.0-next-3d099da-20231208 → 0.0.0-next-16c18c1-20231212
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/calculator/index.js +11 -6
- package/3rdparty/walkontable/src/calculator/index.mjs +5 -3
- package/3rdparty/walkontable/src/calculator/renderAllColumns.js +50 -0
- package/3rdparty/walkontable/src/calculator/renderAllColumns.mjs +46 -0
- package/3rdparty/walkontable/src/calculator/renderAllRows.js +50 -0
- package/3rdparty/walkontable/src/calculator/renderAllRows.mjs +46 -0
- package/3rdparty/walkontable/src/calculator/viewportColumns.js +3 -124
- package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +4 -126
- package/3rdparty/walkontable/src/calculator/viewportRows.js +3 -3
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +4 -5
- package/3rdparty/walkontable/src/cell/coords.js +2 -2
- package/3rdparty/walkontable/src/cell/coords.mjs +2 -2
- package/3rdparty/walkontable/src/cell/range.js +2 -2
- package/3rdparty/walkontable/src/cell/range.mjs +2 -2
- package/3rdparty/walkontable/src/core/_base.js +2 -14
- package/3rdparty/walkontable/src/core/_base.mjs +2 -14
- package/3rdparty/walkontable/src/core/clone.js +2 -2
- package/3rdparty/walkontable/src/core/clone.mjs +2 -2
- package/3rdparty/walkontable/src/core/core.js +0 -2
- package/3rdparty/walkontable/src/core/core.mjs +0 -2
- package/3rdparty/walkontable/src/facade/core.js +0 -9
- package/3rdparty/walkontable/src/facade/core.mjs +0 -9
- package/3rdparty/walkontable/src/filter/column.js +2 -2
- package/3rdparty/walkontable/src/filter/column.mjs +2 -2
- package/3rdparty/walkontable/src/filter/row.js +2 -2
- package/3rdparty/walkontable/src/filter/row.mjs +2 -2
- package/3rdparty/walkontable/src/index.js +3 -4
- package/3rdparty/walkontable/src/index.mjs +1 -2
- package/3rdparty/walkontable/src/overlay/_base.js +2 -2
- package/3rdparty/walkontable/src/overlay/_base.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/bottom.js +2 -2
- package/3rdparty/walkontable/src/overlay/bottom.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/top.js +2 -2
- package/3rdparty/walkontable/src/overlay/top.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.js +2 -2
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.mjs +2 -2
- package/3rdparty/walkontable/src/overlays.js +2 -5
- package/3rdparty/walkontable/src/overlays.mjs +2 -6
- package/3rdparty/walkontable/src/renderer/_base.js +2 -2
- package/3rdparty/walkontable/src/renderer/_base.mjs +2 -2
- package/3rdparty/walkontable/src/renderer/cells.js +2 -2
- package/3rdparty/walkontable/src/renderer/cells.mjs +2 -2
- package/3rdparty/walkontable/src/renderer/colGroup.js +10 -0
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +10 -0
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +2 -2
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +2 -2
- package/3rdparty/walkontable/src/renderer/rows.js +6 -5
- package/3rdparty/walkontable/src/renderer/rows.mjs +6 -5
- package/3rdparty/walkontable/src/renderer/table.js +2 -2
- package/3rdparty/walkontable/src/renderer/table.mjs +2 -2
- package/3rdparty/walkontable/src/scroll.js +2 -2
- package/3rdparty/walkontable/src/scroll.mjs +2 -2
- package/3rdparty/walkontable/src/selection/manager.js +0 -1
- package/3rdparty/walkontable/src/selection/manager.mjs +0 -1
- package/3rdparty/walkontable/src/settings.js +5 -2
- package/3rdparty/walkontable/src/settings.mjs +4 -2
- package/3rdparty/walkontable/src/table.js +2 -3
- package/3rdparty/walkontable/src/table.mjs +2 -3
- package/3rdparty/walkontable/src/utils/column.js +29 -14
- package/3rdparty/walkontable/src/utils/column.mjs +29 -14
- package/3rdparty/walkontable/src/utils/columnStretching.js +219 -0
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +215 -0
- package/3rdparty/walkontable/src/utils/nodesPool.js +2 -2
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/view.js +2 -2
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +2 -2
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +2 -2
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +2 -2
- package/3rdparty/walkontable/src/utils/row.js +2 -2
- package/3rdparty/walkontable/src/utils/row.mjs +2 -2
- package/3rdparty/walkontable/src/viewport.js +22 -17
- package/3rdparty/walkontable/src/viewport.mjs +23 -18
- package/base.js +4 -2
- package/base.mjs +2 -2
- package/core/focusCatcher/index.js +44 -6
- package/core/focusCatcher/index.mjs +44 -6
- package/core.js +0 -11
- package/core.mjs +0 -11
- package/dataMap/dataMap.js +3 -2
- package/dataMap/dataMap.mjs +2 -2
- package/dataMap/dataSource.js +2 -2
- package/dataMap/dataSource.mjs +2 -2
- package/dataMap/metaManager/lazyFactoryMap.js +2 -2
- package/dataMap/metaManager/lazyFactoryMap.mjs +2 -2
- package/dataMap/metaManager/metaLayers/cellMeta.js +2 -2
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +2 -2
- package/dataMap/metaManager/metaLayers/columnMeta.js +2 -2
- package/dataMap/metaManager/metaLayers/columnMeta.mjs +2 -2
- package/dataMap/metaManager/metaLayers/globalMeta.js +2 -2
- package/dataMap/metaManager/metaLayers/globalMeta.mjs +2 -2
- package/dataMap/metaManager/metaLayers/tableMeta.js +2 -2
- package/dataMap/metaManager/metaLayers/tableMeta.mjs +2 -2
- package/dataMap/metaManager/metaSchema.js +28 -2
- package/dataMap/metaManager/metaSchema.mjs +28 -2
- package/dataMap/metaManager/mods/dynamicCellMeta.js +2 -2
- package/dataMap/metaManager/mods/dynamicCellMeta.mjs +2 -2
- package/dataMap/metaManager/mods/extendMetaProperties.js +14 -2
- package/dataMap/metaManager/mods/extendMetaProperties.mjs +14 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +3 -3
- package/dist/handsontable.full.js +3991 -5589
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +66 -71
- package/dist/handsontable.js +3070 -4317
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +35 -39
- package/editorManager.js +5 -6
- package/editorManager.mjs +5 -6
- package/editors/autocompleteEditor/autocompleteEditor.js +2 -4
- package/editors/autocompleteEditor/autocompleteEditor.mjs +2 -4
- package/editors/baseEditor/baseEditor.js +2 -2
- package/editors/baseEditor/baseEditor.mjs +2 -2
- package/editors/dateEditor/dateEditor.d.ts +1 -1
- package/editors/dateEditor/dateEditor.js +6 -3
- package/editors/dateEditor/dateEditor.mjs +6 -3
- package/editors/handsontableEditor/handsontableEditor.js +0 -1
- package/editors/handsontableEditor/handsontableEditor.mjs +0 -1
- package/editors/textEditor/textEditor.js +2 -6
- package/editors/textEditor/textEditor.mjs +2 -6
- package/eventManager.js +2 -2
- package/eventManager.mjs +2 -2
- package/helpers/browser.js +5 -2
- package/helpers/browser.mjs +5 -2
- package/helpers/feature.js +10 -0
- package/helpers/feature.mjs +9 -0
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +3 -4
- package/pluginHooks.d.ts +6 -29
- package/pluginHooks.js +67 -125
- package/pluginHooks.mjs +64 -124
- package/plugins/autoColumnSize/autoColumnSize.js +2 -2
- package/plugins/autoColumnSize/autoColumnSize.mjs +2 -2
- package/plugins/autoRowSize/autoRowSize.js +2 -2
- package/plugins/autoRowSize/autoRowSize.mjs +2 -2
- package/plugins/autofill/autofill.js +2 -2
- package/plugins/autofill/autofill.mjs +2 -2
- package/plugins/base/base.js +2 -2
- package/plugins/base/base.mjs +2 -2
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +2 -2
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +2 -2
- package/plugins/collapsibleColumns/collapsibleColumns.js +2 -2
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +2 -2
- package/plugins/columnSorting/columnSorting.js +2 -2
- package/plugins/columnSorting/columnSorting.mjs +2 -2
- package/plugins/columnSorting/columnStatesManager.js +2 -2
- package/plugins/columnSorting/columnStatesManager.mjs +2 -2
- package/plugins/columnSummary/columnSummary.js +2 -2
- package/plugins/columnSummary/columnSummary.mjs +2 -2
- package/plugins/columnSummary/endpoints.js +2 -2
- package/plugins/columnSummary/endpoints.mjs +2 -2
- package/plugins/comments/commentEditor.js +2 -2
- package/plugins/comments/commentEditor.mjs +2 -2
- package/plugins/comments/comments.js +2 -2
- package/plugins/comments/comments.mjs +2 -2
- package/plugins/comments/displaySwitch.js +2 -2
- package/plugins/comments/displaySwitch.mjs +2 -2
- package/plugins/contextMenu/commandExecutor.js +2 -2
- package/plugins/contextMenu/commandExecutor.mjs +2 -2
- package/plugins/contextMenu/contextMenu.js +2 -2
- package/plugins/contextMenu/contextMenu.mjs +2 -2
- package/plugins/contextMenu/itemsFactory.js +2 -2
- package/plugins/contextMenu/itemsFactory.mjs +2 -2
- package/plugins/contextMenu/menu/cursor.js +2 -2
- package/plugins/contextMenu/menu/cursor.mjs +2 -2
- package/plugins/contextMenu/menu/menu.js +2 -2
- package/plugins/contextMenu/menu/menu.mjs +2 -2
- package/plugins/copyPaste/clipboardData.js +18 -0
- package/plugins/copyPaste/clipboardData.mjs +14 -0
- package/plugins/copyPaste/copyPaste.js +131 -53
- package/plugins/copyPaste/copyPaste.mjs +134 -56
- package/plugins/copyPaste/copyableRanges.js +43 -7
- package/plugins/copyPaste/copyableRanges.mjs +42 -7
- package/plugins/copyPaste/pasteEvent.mjs +1 -1
- package/plugins/customBorders/customBorders.js +2 -7
- package/plugins/customBorders/customBorders.mjs +2 -7
- package/plugins/customBorders/utils.js +0 -1
- package/plugins/customBorders/utils.mjs +0 -1
- package/plugins/dragToScroll/dragToScroll.js +2 -2
- package/plugins/dragToScroll/dragToScroll.mjs +2 -2
- package/plugins/dropdownMenu/dropdownMenu.js +2 -2
- package/plugins/dropdownMenu/dropdownMenu.mjs +2 -2
- package/plugins/exportFile/dataProvider.js +2 -2
- package/plugins/exportFile/dataProvider.mjs +2 -2
- package/plugins/exportFile/types/_base.js +2 -2
- package/plugins/exportFile/types/_base.mjs +2 -2
- package/plugins/filters/component/_base.js +2 -2
- package/plugins/filters/component/_base.mjs +2 -2
- package/plugins/filters/component/actionBar.js +2 -2
- package/plugins/filters/component/actionBar.mjs +2 -2
- package/plugins/filters/component/condition.js +2 -2
- package/plugins/filters/component/condition.mjs +2 -2
- package/plugins/filters/component/operators.js +2 -2
- package/plugins/filters/component/operators.mjs +2 -2
- package/plugins/filters/component/value.js +2 -2
- package/plugins/filters/component/value.mjs +2 -2
- package/plugins/filters/conditionCollection.js +2 -2
- package/plugins/filters/conditionCollection.mjs +2 -2
- package/plugins/filters/conditionUpdateObserver.js +2 -2
- package/plugins/filters/conditionUpdateObserver.mjs +2 -2
- package/plugins/filters/dataFilter.js +2 -2
- package/plugins/filters/dataFilter.mjs +2 -2
- package/plugins/filters/filters.js +2 -2
- package/plugins/filters/filters.mjs +2 -2
- package/plugins/filters/ui/_base.js +2 -2
- package/plugins/filters/ui/_base.mjs +2 -2
- package/plugins/filters/ui/radioInput.js +1 -1
- package/plugins/filters/ui/radioInput.mjs +1 -1
- package/plugins/formulas/formulas.js +2 -4
- package/plugins/formulas/formulas.mjs +2 -4
- package/plugins/formulas/indexSyncer/axisSyncer.js +0 -1
- package/plugins/formulas/indexSyncer/axisSyncer.mjs +0 -1
- package/plugins/manualColumnMove/ui/_base.js +2 -2
- package/plugins/manualColumnMove/ui/_base.mjs +2 -2
- package/plugins/manualColumnResize/manualColumnResize.js +0 -1
- package/plugins/manualColumnResize/manualColumnResize.mjs +0 -1
- package/plugins/manualRowMove/ui/_base.js +2 -2
- package/plugins/manualRowMove/ui/_base.mjs +2 -2
- package/plugins/mergeCells/calculations/autofill.js +2 -2
- package/plugins/mergeCells/calculations/autofill.mjs +2 -2
- package/plugins/mergeCells/calculations/selection.js +2 -2
- package/plugins/mergeCells/calculations/selection.mjs +2 -2
- package/plugins/mergeCells/cellCoords.js +2 -2
- package/plugins/mergeCells/cellCoords.mjs +2 -2
- package/plugins/mergeCells/cellsCollection.js +2 -2
- package/plugins/mergeCells/cellsCollection.mjs +2 -2
- package/plugins/mergeCells/mergeCells.js +3 -129
- package/plugins/mergeCells/mergeCells.mjs +3 -129
- package/plugins/multiColumnSorting/multiColumnSorting.js +2 -2
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -2
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +2 -2
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +2 -2
- package/plugins/nestedHeaders/nestedHeaders.js +43 -89
- package/plugins/nestedHeaders/nestedHeaders.mjs +44 -90
- package/plugins/nestedHeaders/stateManager/headersTree.js +0 -1
- package/plugins/nestedHeaders/stateManager/headersTree.mjs +0 -1
- package/plugins/nestedHeaders/utils/ghostTable.js +2 -2
- package/plugins/nestedHeaders/utils/ghostTable.mjs +2 -2
- package/plugins/nestedRows/data/dataManager.js +2 -2
- package/plugins/nestedRows/data/dataManager.mjs +2 -2
- package/plugins/nestedRows/nestedRows.js +2 -2
- package/plugins/nestedRows/nestedRows.mjs +2 -2
- package/plugins/nestedRows/ui/_base.js +2 -2
- package/plugins/nestedRows/ui/_base.mjs +2 -2
- package/plugins/nestedRows/ui/contextMenu.js +2 -2
- package/plugins/nestedRows/ui/contextMenu.mjs +2 -2
- package/plugins/nestedRows/utils/rowMoveController.js +2 -2
- package/plugins/nestedRows/utils/rowMoveController.mjs +2 -2
- package/plugins/persistentState/persistentState.js +2 -2
- package/plugins/persistentState/persistentState.mjs +2 -2
- package/plugins/persistentState/storage.js +2 -2
- package/plugins/persistentState/storage.mjs +2 -2
- package/plugins/search/search.js +2 -2
- package/plugins/search/search.mjs +2 -2
- package/plugins/touchScroll/touchScroll.js +2 -2
- package/plugins/touchScroll/touchScroll.mjs +2 -2
- package/plugins/trimRows/trimRows.js +2 -2
- package/plugins/trimRows/trimRows.mjs +2 -2
- package/plugins/undoRedo/undoRedo.js +0 -2
- package/plugins/undoRedo/undoRedo.mjs +0 -2
- package/renderers/autocompleteRenderer/autocompleteRenderer.js +0 -1
- package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +0 -1
- package/renderers/checkboxRenderer/checkboxRenderer.js +0 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +0 -2
- package/selection/highlight/highlight.js +2 -3
- package/selection/highlight/highlight.mjs +2 -3
- package/selection/highlight/visualSelection.js +2 -2
- package/selection/highlight/visualSelection.mjs +2 -2
- package/selection/index.js +1 -3
- package/selection/index.mjs +2 -2
- package/selection/range.js +2 -2
- package/selection/range.mjs +2 -2
- package/selection/selection.js +2 -2
- package/selection/selection.mjs +2 -2
- package/selection/utils.js +0 -34
- package/selection/utils.mjs +0 -33
- package/settings.d.ts +2 -1
- package/tableView.js +3 -4
- package/tableView.mjs +3 -4
- package/translations/indexMapper.js +4 -3
- package/translations/indexMapper.mjs +2 -2
- package/translations/mapCollections/aggregatedCollection.js +2 -2
- package/translations/mapCollections/aggregatedCollection.mjs +2 -2
- package/translations/mapCollections/mapCollection.js +2 -2
- package/translations/mapCollections/mapCollection.mjs +2 -2
- package/translations/maps/indexMap.js +2 -2
- package/translations/maps/indexMap.mjs +2 -2
- package/translations/maps/linkedPhysicalIndexToValueMap.js +2 -2
- package/translations/maps/linkedPhysicalIndexToValueMap.mjs +2 -2
- package/utils/dataStructures/linkedList.js +2 -2
- package/utils/dataStructures/linkedList.mjs +2 -2
- package/utils/dataStructures/tree.js +2 -2
- package/utils/dataStructures/tree.mjs +2 -2
- package/utils/ghostTable.js +2 -2
- package/utils/ghostTable.mjs +2 -2
- package/utils/interval.js +2 -2
- package/utils/interval.mjs +2 -2
- package/utils/parseTable.js +84 -538
- package/utils/parseTable.mjs +83 -534
- package/utils/samplesGenerator.js +2 -2
- package/utils/samplesGenerator.mjs +2 -2
- package/validators/timeValidator/timeValidator.js +0 -1
- package/validators/timeValidator/timeValidator.mjs +0 -1
- package/plugins/copyPaste/clipboardData/clipboardData.js +0 -588
- package/plugins/copyPaste/clipboardData/clipboardData.mjs +0 -584
- package/plugins/copyPaste/clipboardData/copyClipboardData.js +0 -69
- package/plugins/copyPaste/clipboardData/copyClipboardData.mjs +0 -65
- package/plugins/copyPaste/clipboardData/index.js +0 -9
- package/plugins/copyPaste/clipboardData/index.mjs +0 -4
- package/plugins/copyPaste/clipboardData/pasteClipboardData.js +0 -81
- package/plugins/copyPaste/clipboardData/pasteClipboardData.mjs +0 -77
package/utils/parseTable.js
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
-
exports.
|
5
|
-
exports.getDataWithHeadersByConfig = getDataWithHeadersByConfig;
|
6
|
-
exports.getHTMLByCoords = getHTMLByCoords;
|
7
|
-
exports.getHTMLFromConfig = getHTMLFromConfig;
|
4
|
+
exports._dataToHTML = _dataToHTML;
|
8
5
|
exports.htmlToGridSettings = htmlToGridSettings;
|
9
6
|
exports.instanceToHTML = instanceToHTML;
|
10
7
|
require("core-js/modules/es.array.push.js");
|
11
|
-
require("core-js/modules/es.string.replace-all.js");
|
12
8
|
var _mixed = require("./../helpers/mixed");
|
13
|
-
var _object = require("./../helpers/object");
|
14
|
-
var _number = require("../helpers/number");
|
15
9
|
const ESCAPED_HTML_CHARS = {
|
16
10
|
' ': '\x20',
|
17
11
|
'&': '&',
|
@@ -30,549 +24,102 @@ function isHTMLTable(element) {
|
|
30
24
|
return (element && element.nodeName || '') === 'TABLE';
|
31
25
|
}
|
32
26
|
|
33
|
-
/**
|
34
|
-
* Parses empty values to an empty string or leave them untouched otherwise.
|
35
|
-
*
|
36
|
-
* @private
|
37
|
-
* @param {string} cellValue Parsed cell value.
|
38
|
-
* @returns {string}
|
39
|
-
*/
|
40
|
-
function parseEmptyValues(cellValue) {
|
41
|
-
if ((0, _mixed.isEmpty)(cellValue)) {
|
42
|
-
return '';
|
43
|
-
}
|
44
|
-
return cellValue;
|
45
|
-
}
|
46
|
-
|
47
27
|
/**
|
48
28
|
* Converts Handsontable into HTMLTableElement.
|
49
29
|
*
|
50
|
-
* @param {Core}
|
51
|
-
* @returns {string} OuterHTML of the HTMLTableElement.
|
52
|
-
*/
|
53
|
-
function instanceToHTML(hotInstance) {
|
54
|
-
const startColumn = hotInstance.hasRowHeaders() ? -1 : 0;
|
55
|
-
const startRow = hotInstance.hasColHeaders() ? -1 : 0;
|
56
|
-
const rows = Array.from({
|
57
|
-
length: hotInstance.countRows() + Math.abs(startRow)
|
58
|
-
}, (_, i) => i + startRow);
|
59
|
-
const columns = Array.from({
|
60
|
-
length: hotInstance.countCols() + Math.abs(startColumn)
|
61
|
-
}, (_, i) => i + startColumn);
|
62
|
-
return getHTMLByCoords(hotInstance, {
|
63
|
-
rows,
|
64
|
-
columns
|
65
|
-
});
|
66
|
-
}
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Converts Handsontable's coordinates into HTMLTableElement.
|
70
|
-
*
|
71
|
-
* @param {Core} hotInstance The Handsontable instance.
|
72
|
-
* @param {object} config Configuration for building HTMLTableElement.
|
73
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating the table.
|
74
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating the table.
|
75
|
-
* @returns {string} OuterHTML of the HTMLTableElement.
|
76
|
-
*/
|
77
|
-
function getHTMLByCoords(hotInstance, config) {
|
78
|
-
return ['<table>',
|
79
|
-
// Needed for desktop Excel on MacOS while pasting any elements with rowspan/colspan.
|
80
|
-
'<!--StartFragment-->', ...getHeadersHTMLByCoords(hotInstance, config), ...getBodyHTMLByCoords(hotInstance, config),
|
81
|
-
// Needed for desktop Excel on MacOS while pasting any elements with rowspan/colspan.
|
82
|
-
'<!--EndFragment-->', '</table>'].join('');
|
83
|
-
}
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Converts Handsontable's coordinates into list of cell values.
|
87
|
-
*
|
88
|
-
* @param {Core} hotInstance The Handsontable instance.
|
89
|
-
* @param {object} config Configuration for building the cell value list.
|
90
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating the
|
91
|
-
* cell value list.
|
92
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating the
|
93
|
-
* cell value list.
|
94
|
-
* @returns {Array<Array<string>>} List of displayed cell values.
|
95
|
-
*/
|
96
|
-
function getDataByCoords(hotInstance, config) {
|
97
|
-
return [...getHeadersDataByCoords(hotInstance, config), ...getBodyDataByCoords(hotInstance, config)];
|
98
|
-
}
|
99
|
-
|
100
|
-
/**
|
101
|
-
* Converts config into HTMLTableElement.
|
102
|
-
*
|
103
|
-
* @param {object} config Configuration for building HTMLTableElement.
|
104
|
-
* @param {Array<number>} [config.excludedRows] List of row indexes which should be excluded when creating the table.
|
105
|
-
* @param {Array<number>} [config.excludedColumns] List of column indexes which should be excluded when creating the table.
|
106
|
-
* @param {Array<Array<string>>} [config.data] List of cell data.
|
107
|
-
* @param {Array<object>} [config.mergeCells] List of merged cells.
|
108
|
-
* @param {Array<Array<string|object>>} [config.nestedHeaders] List of headers and corresponding information about some
|
109
|
-
* nested elements.
|
110
|
-
* @param {Array<string>} [config.colHeaders] List of first level header values.
|
30
|
+
* @param {Core} instance The Handsontable instance.
|
111
31
|
* @returns {string} OuterHTML of the HTMLTableElement.
|
112
32
|
*/
|
113
|
-
function
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}
|
138
|
-
return listOfHeaders;
|
139
|
-
}, []);
|
140
|
-
}
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Get HTML for nested headers.
|
144
|
-
*
|
145
|
-
* @param {Array<Array<string|object>>} nestedHeaders List of nested headers which will be filtered.
|
146
|
-
* @param {Array<number>} excludedHeaders List of headers which should be excluded when creating the HTMLTableElement.tHead.
|
147
|
-
* @param {Array<number>} excludedColumns List of column indexes which should be excluded when creating the HTMLTableElement.tHead.
|
148
|
-
* @returns {Array<string>}
|
149
|
-
*/
|
150
|
-
function getNestedHeadersHTML(nestedHeaders, excludedHeaders, excludedColumns) {
|
151
|
-
const headersHTML = [];
|
152
|
-
getFilteredNestedHeaders(nestedHeaders, excludedHeaders, excludedColumns).forEach(listOfHeaders => {
|
153
|
-
const rowHTML = ['<tr>'];
|
154
|
-
for (let i = 0; i < listOfHeaders.length; i += 1) {
|
155
|
-
const header = listOfHeaders[i];
|
156
|
-
let headerValue = header;
|
157
|
-
let colspanAttribute = '';
|
158
|
-
if ((0, _object.isObject)(header)) {
|
159
|
-
const {
|
160
|
-
colspan,
|
161
|
-
label
|
162
|
-
} = header;
|
163
|
-
headerValue = label;
|
164
|
-
colspanAttribute = ` colspan=${colspan}`;
|
165
|
-
}
|
166
|
-
rowHTML.push(`<th${colspanAttribute}>${encodeHTMLEntities(parseEmptyValues(headerValue))}</th>`);
|
167
|
-
}
|
168
|
-
rowHTML.push('</tr>');
|
169
|
-
headersHTML.push(...rowHTML);
|
170
|
-
});
|
171
|
-
return headersHTML;
|
172
|
-
}
|
173
|
-
|
174
|
-
/**
|
175
|
-
* Get HTML for first level header.
|
176
|
-
*
|
177
|
-
* @param {Array<string>} columnHeaders List of header values which will be filtered.
|
178
|
-
* @param {Array<number>} excludedHeaders List of headers which should be excluded when creating the HTMLTableElement.tHead.
|
179
|
-
* @param {Array<number>} excludedColumns List of column indexes which should be excluded when creating the HTMLTableElement.tHead.
|
180
|
-
* @returns {*[]}
|
181
|
-
*/
|
182
|
-
function getSimpleHeadersHTML(columnHeaders, excludedHeaders, excludedColumns) {
|
183
|
-
if (excludedHeaders.includes(-1)) {
|
184
|
-
return [];
|
185
|
-
}
|
186
|
-
const filteredColumnHeaders = columnHeaders.filter((columnHeaderValue, columnIndex) => excludedColumns.includes(columnIndex) === false);
|
187
|
-
if (filteredColumnHeaders.length === 0) {
|
188
|
-
return [];
|
189
|
-
}
|
190
|
-
return ['<tr>', ...filteredColumnHeaders.map(columnHeader => `<th>${encodeHTMLEntities(parseEmptyValues(columnHeader))}</th>`), '</tr>'];
|
191
|
-
}
|
192
|
-
|
193
|
-
/**
|
194
|
-
* Get list of cells filtered by list of excluded rows and columns.
|
195
|
-
*
|
196
|
-
* @private
|
197
|
-
* @param {Array<Array<string>>} data List of cells values which will be filtered.
|
198
|
-
* @param {Array<number>} excludedRows List of row indexes which should be excluded when creating the HTMLTableElement.tHead.
|
199
|
-
* @param {Array<number>} excludedColumns List of column indexes which should be excluded when creating the HTMLTableElement.tHead.
|
200
|
-
* @returns {Array<string>} List of cell values.
|
201
|
-
*/
|
202
|
-
function getFilteredCells(data, excludedRows, excludedColumns) {
|
203
|
-
if (Array.isArray(data) === false) {
|
204
|
-
return [];
|
205
|
-
}
|
206
|
-
return data.reduce((listOfCells, rowData, rowIndex) => {
|
207
|
-
if (excludedRows.includes(rowIndex)) {
|
208
|
-
return listOfCells;
|
209
|
-
}
|
210
|
-
const filteredRowData = rowData.filter((cellData, columnIndex) => excludedColumns.includes(columnIndex) === false);
|
211
|
-
if (filteredRowData.length > 0) {
|
212
|
-
return listOfCells.concat([filteredRowData]);
|
213
|
-
}
|
214
|
-
return listOfCells;
|
215
|
-
}, []);
|
216
|
-
}
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Prepare information about merged areas to reduce complexity of calculations.
|
220
|
-
*
|
221
|
-
* @private
|
222
|
-
* @param {Array<object>} mergedCellsConfig List of merged cells.
|
223
|
-
* @returns {{mergedCellsMap: Map<any, any>, mergedArea: Set<any>}}
|
224
|
-
*/
|
225
|
-
function getMergedCellsInformation(mergedCellsConfig) {
|
226
|
-
const mergedCellsMap = new Map();
|
227
|
-
const mergedArea = new Set();
|
228
|
-
let mergedRows = 1;
|
229
|
-
let mergedColumns = 1;
|
230
|
-
mergedCellsConfig === null || mergedCellsConfig === void 0 || mergedCellsConfig.forEach(mergeArea => {
|
231
|
-
const {
|
232
|
-
row,
|
233
|
-
col,
|
234
|
-
rowspan,
|
235
|
-
colspan
|
236
|
-
} = mergeArea;
|
237
|
-
mergedCellsMap.set(`${row}x${col}`, {
|
238
|
-
rowspan,
|
239
|
-
colspan
|
240
|
-
});
|
241
|
-
if (Number.isInteger(rowspan)) {
|
242
|
-
mergedRows = rowspan;
|
243
|
-
}
|
244
|
-
if (Number.isInteger(colspan)) {
|
245
|
-
mergedColumns = colspan;
|
246
|
-
}
|
247
|
-
(0, _number.rangeEach)(row, row + mergedRows - 1, rowIndex => {
|
248
|
-
(0, _number.rangeEach)(col, col + mergedColumns - 1, columnIndex => {
|
249
|
-
// Other than start point.
|
250
|
-
if (rowIndex !== row || columnIndex !== col) {
|
251
|
-
mergedArea.add(`${rowIndex}x${columnIndex}`);
|
252
|
-
}
|
253
|
-
});
|
254
|
-
});
|
255
|
-
});
|
256
|
-
return {
|
257
|
-
mergedCellsMap,
|
258
|
-
mergedArea
|
259
|
-
};
|
260
|
-
}
|
261
|
-
|
262
|
-
/**
|
263
|
-
* Converts config with information about cells into HTMLTableElement.tBodies.
|
264
|
-
*
|
265
|
-
* @private
|
266
|
-
* @param {object} config Configuration for building HTMLTableElement.tBodies.
|
267
|
-
* @param {Array<Array<string>>} config.data List of cell data.
|
268
|
-
* @param {Array<number>} [config.excludedRows] List of row indexes which should be excluded when creating the HTMLTableElement.tBodies.
|
269
|
-
* @param {Array<number>} [config.excludedColumns] List of column indexes which should be excluded when creating the HTMLTableElement.tBodies.
|
270
|
-
* @param {Array<object>} [config.mergeCells] List of merged cells.
|
271
|
-
* @returns {Array<string>} List of HTMLElements stored as strings.
|
272
|
-
*/
|
273
|
-
function getBodyHTMLByConfig(config) {
|
274
|
-
const excludedColumns = config.excludedColumns || [];
|
275
|
-
const excludedRows = config.excludedRows || [];
|
276
|
-
const {
|
277
|
-
data,
|
278
|
-
mergeCells
|
279
|
-
} = config;
|
280
|
-
const ignoredCellRows = excludedRows.filter(rowIndex => rowIndex >= 0);
|
281
|
-
const filteredData = getFilteredCells(data, ignoredCellRows, excludedColumns);
|
282
|
-
const cells = [];
|
283
|
-
if (filteredData.length === 0) {
|
284
|
-
return [];
|
285
|
-
}
|
286
|
-
const {
|
287
|
-
mergedCellsMap,
|
288
|
-
mergedArea
|
289
|
-
} = getMergedCellsInformation(mergeCells);
|
290
|
-
filteredData.forEach((rowData, rowIndex) => {
|
291
|
-
const rowHTML = ['<tr>'];
|
292
|
-
rowData.forEach((cellData, columnIndex) => {
|
293
|
-
const attrs = [];
|
294
|
-
const checkedMergeCoordinate = `${rowIndex}x${columnIndex}`;
|
295
|
-
const mergeParent = mergedCellsMap.get(checkedMergeCoordinate);
|
296
|
-
if (mergeParent !== undefined) {
|
33
|
+
function instanceToHTML(instance) {
|
34
|
+
const hasColumnHeaders = instance.hasColHeaders();
|
35
|
+
const hasRowHeaders = instance.hasRowHeaders();
|
36
|
+
const coords = [hasColumnHeaders ? -1 : 0, hasRowHeaders ? -1 : 0, instance.countRows() - 1, instance.countCols() - 1];
|
37
|
+
const data = instance.getData(...coords);
|
38
|
+
const countRows = data.length;
|
39
|
+
const countCols = countRows > 0 ? data[0].length : 0;
|
40
|
+
const TABLE = ['<table>', '</table>'];
|
41
|
+
const THEAD = hasColumnHeaders ? ['<thead>', '</thead>'] : [];
|
42
|
+
const TBODY = ['<tbody>', '</tbody>'];
|
43
|
+
const rowModifier = hasRowHeaders ? 1 : 0;
|
44
|
+
const columnModifier = hasColumnHeaders ? 1 : 0;
|
45
|
+
for (let row = 0; row < countRows; row += 1) {
|
46
|
+
const isColumnHeadersRow = hasColumnHeaders && row === 0;
|
47
|
+
const CELLS = [];
|
48
|
+
for (let column = 0; column < countCols; column += 1) {
|
49
|
+
const isRowHeadersColumn = !isColumnHeadersRow && hasRowHeaders && column === 0;
|
50
|
+
let cell = '';
|
51
|
+
if (isColumnHeadersRow) {
|
52
|
+
cell = `<th>${instance.getColHeader(column - rowModifier)}</th>`;
|
53
|
+
} else if (isRowHeadersColumn) {
|
54
|
+
cell = `<th>${instance.getRowHeader(row - columnModifier)}</th>`;
|
55
|
+
} else {
|
56
|
+
const cellData = data[row][column];
|
297
57
|
const {
|
58
|
+
hidden,
|
298
59
|
rowspan,
|
299
60
|
colspan
|
300
|
-
} =
|
301
|
-
if (
|
302
|
-
attrs
|
303
|
-
|
304
|
-
|
305
|
-
|
61
|
+
} = instance.getCellMeta(row - columnModifier, column - rowModifier);
|
62
|
+
if (!hidden) {
|
63
|
+
const attrs = [];
|
64
|
+
if (rowspan) {
|
65
|
+
attrs.push(`rowspan="${rowspan}"`);
|
66
|
+
}
|
67
|
+
if (colspan) {
|
68
|
+
attrs.push(`colspan="${colspan}"`);
|
69
|
+
}
|
70
|
+
if ((0, _mixed.isEmpty)(cellData)) {
|
71
|
+
cell = `<td ${attrs.join(' ')}></td>`;
|
72
|
+
} else {
|
73
|
+
const value = cellData.toString().replace('<', '<').replace('>', '>').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20/gi, ' ').replace(/\t/gi, '	');
|
74
|
+
cell = `<td ${attrs.join(' ')}>${value}</td>`;
|
75
|
+
}
|
306
76
|
}
|
307
|
-
} else if (mergedArea.has(checkedMergeCoordinate)) {
|
308
|
-
return;
|
309
77
|
}
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
/**
|
319
|
-
* Converts config with information about headers into HTMLTableElement.tHead.
|
320
|
-
*
|
321
|
-
* @private
|
322
|
-
* @param {object} config Configuration for building HTMLTableElement.tHead.
|
323
|
-
* @param {Array<Array<string|object>>} [config.nestedHeaders] List of headers and corresponding information about some
|
324
|
-
* nested elements.
|
325
|
-
* @param {Array<string>} [config.colHeaders] List of first level header values.
|
326
|
-
* @param {Array<number>} [config.excludedRows] List of row indexes which should be excluded when creating the HTMLTableElement.tHead.
|
327
|
-
* @param {Array<number>} [config.excludedColumns] List of column indexes which should be excluded when creating the HTMLTableElement.tHead.
|
328
|
-
* @returns {Array<string>} List of HTMLElements stored as strings.
|
329
|
-
*/
|
330
|
-
function getHeadersHTMLByConfig(config) {
|
331
|
-
const headersHTML = [];
|
332
|
-
const excludedColumns = Array.isArray(config === null || config === void 0 ? void 0 : config.excludedColumns) ? config.excludedColumns : [];
|
333
|
-
const excludedRows = Array.isArray(config === null || config === void 0 ? void 0 : config.excludedRows) ? config.excludedRows : [];
|
334
|
-
const {
|
335
|
-
nestedHeaders,
|
336
|
-
colHeaders
|
337
|
-
} = config;
|
338
|
-
const excludedHeaders = excludedRows.filter(rowIndex => rowIndex < 0);
|
339
|
-
if (Array.isArray(nestedHeaders)) {
|
340
|
-
headersHTML.push(...getNestedHeadersHTML(nestedHeaders, excludedHeaders, excludedColumns));
|
341
|
-
} else if (Array.isArray(colHeaders)) {
|
342
|
-
headersHTML.push(...getSimpleHeadersHTML(colHeaders, excludedHeaders, excludedColumns));
|
343
|
-
}
|
344
|
-
if (headersHTML.length > 0) {
|
345
|
-
return ['<thead>', ...headersHTML, '</thead>'];
|
346
|
-
}
|
347
|
-
return [];
|
348
|
-
}
|
349
|
-
|
350
|
-
/**
|
351
|
-
* Converts config with information about cells and headers into list of values.
|
352
|
-
*
|
353
|
-
* @param {object} config Configuration for building list of values.
|
354
|
-
* @param {Array<number>} [config.excludedRows] List of row indexes which should be excluded when creating the value list.
|
355
|
-
* @param {Array<number>} [config.excludedColumns] List of column indexes which should be excluded when creating the value list.
|
356
|
-
* @param {Array<Array<string|object>>} [config.nestedHeaders] List of headers and information about some nested elements.
|
357
|
-
* @param {Array<string>} [config.colHeaders] List of first level header values.
|
358
|
-
* @returns {string[][]} List of values.
|
359
|
-
*/
|
360
|
-
function getDataWithHeadersByConfig(config) {
|
361
|
-
const dataWithHeaders = [];
|
362
|
-
const excludedColumns = Array.isArray(config === null || config === void 0 ? void 0 : config.excludedColumns) ? config.excludedColumns : [];
|
363
|
-
const excludedRows = Array.isArray(config === null || config === void 0 ? void 0 : config.excludedRows) ? config.excludedRows : [];
|
364
|
-
const {
|
365
|
-
data,
|
366
|
-
nestedHeaders,
|
367
|
-
colHeaders
|
368
|
-
} = config;
|
369
|
-
const excludedHeaders = excludedRows.filter(rowIndex => rowIndex < 0);
|
370
|
-
if (Array.isArray(nestedHeaders)) {
|
371
|
-
dataWithHeaders.push(...getFilteredNestedHeaders(nestedHeaders, excludedHeaders, excludedColumns).map(listOfHeaders => {
|
372
|
-
return listOfHeaders.reduce((headers, header) => {
|
373
|
-
if ((0, _object.isObject)(header)) {
|
374
|
-
headers.push(header.label, ...new Array(header.colspan - 1).fill(''));
|
375
|
-
} else {
|
376
|
-
headers.push(header);
|
377
|
-
}
|
378
|
-
return headers;
|
379
|
-
}, []);
|
380
|
-
}));
|
381
|
-
} else if (Array.isArray(colHeaders)) {
|
382
|
-
dataWithHeaders.push([...colHeaders.filter((columnHeaderData, columnIndex) => excludedColumns.includes(columnIndex) === false)]);
|
78
|
+
CELLS.push(cell);
|
79
|
+
}
|
80
|
+
const TR = ['<tr>', ...CELLS, '</tr>'].join('');
|
81
|
+
if (isColumnHeadersRow) {
|
82
|
+
THEAD.splice(1, 0, TR);
|
83
|
+
} else {
|
84
|
+
TBODY.splice(-1, 0, TR);
|
85
|
+
}
|
383
86
|
}
|
384
|
-
|
385
|
-
return
|
386
|
-
}
|
387
|
-
|
388
|
-
/**
|
389
|
-
* Encode text to HTML.
|
390
|
-
*
|
391
|
-
* @param {string} text Text to prepare.
|
392
|
-
* @returns {string}
|
393
|
-
*/
|
394
|
-
function encodeHTMLEntities(text) {
|
395
|
-
return `${text}`.replace(/&/g, '&').replace('<', '<').replace('>', '>').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20{2,}/gi, substring => {
|
396
|
-
// The way how Excel serializes data with at least two spaces.
|
397
|
-
return `<span style="mso-spacerun: yes">${' '.repeat(substring.length - 1)} </span>`;
|
398
|
-
}).replace(/\t/gi, '	');
|
399
|
-
}
|
400
|
-
|
401
|
-
/**
|
402
|
-
* Decode HTML to simple text.
|
403
|
-
*
|
404
|
-
* @param {string} html HTML for handling.
|
405
|
-
* @returns {string}
|
406
|
-
*/
|
407
|
-
function decodeHTMLEntities(html) {
|
408
|
-
return html.replace(regEscapedChars, match => ESCAPED_HTML_CHARS[match])
|
409
|
-
// The way how Excel serializes data with at least two spaces.
|
410
|
-
.replace(/<span style="mso-spacerun: yes">(.+?)<\/span>/, '$1').replaceAll(' ', ' ');
|
87
|
+
TABLE.splice(1, 0, THEAD.join(''), TBODY.join(''));
|
88
|
+
return TABLE.join('');
|
411
89
|
}
|
412
90
|
|
413
91
|
/**
|
414
|
-
* Converts
|
92
|
+
* Converts 2D array into HTMLTableElement.
|
415
93
|
*
|
416
|
-
* @param {
|
417
|
-
* @
|
418
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating
|
419
|
-
* the HTMLTableElement.tHead.
|
420
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating
|
421
|
-
* the HTMLTableElement.tHead.
|
422
|
-
* @returns {Array<string>} List of HTMLElements stored as strings.
|
94
|
+
* @param {Array} input Input array which will be converted to HTMLTable.
|
95
|
+
* @returns {string} OuterHTML of the HTMLTableElement.
|
423
96
|
*/
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
headers.forEach(rowIndex => {
|
435
|
-
const rowHTML = ['<tr>'];
|
436
|
-
for (let i = 0; i < columns.length; i += 1) {
|
437
|
-
const columnIndex = columns[i];
|
438
|
-
const headerCell = hotInstance.getCell(rowIndex, columnIndex);
|
439
|
-
const colspan = headerCell === null || headerCell === void 0 ? void 0 : headerCell.getAttribute('colspan');
|
440
|
-
let colspanAttribute = '';
|
441
|
-
if (colspan) {
|
442
|
-
const parsedColspan = parseInt(colspan, 10);
|
443
|
-
const colspanReduced = Math.min(parsedColspan, columns.length - i);
|
444
|
-
colspanAttribute = ` colspan=${colspanReduced}`;
|
445
|
-
i += colspanReduced - 1;
|
446
|
-
}
|
447
|
-
rowHTML.push(`<th${colspanAttribute}>${encodeHTMLEntities(parseEmptyValues(hotInstance.getColHeader(columnIndex, rowIndex)))}</th>`);
|
97
|
+
// eslint-disable-next-line no-restricted-globals
|
98
|
+
function _dataToHTML(input) {
|
99
|
+
const inputLen = input.length;
|
100
|
+
const result = ['<table>'];
|
101
|
+
for (let row = 0; row < inputLen; row += 1) {
|
102
|
+
const rowData = input[row];
|
103
|
+
const columnsLen = rowData.length;
|
104
|
+
const columnsResult = [];
|
105
|
+
if (row === 0) {
|
106
|
+
result.push('<tbody>');
|
448
107
|
}
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
}
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating the
|
461
|
-
* cell value list.
|
462
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating the
|
463
|
-
* cell value list.
|
464
|
-
* @returns {Array[]} List of displayed cell values.
|
465
|
-
*/
|
466
|
-
function getHeadersDataByCoords(hotInstance, config) {
|
467
|
-
const headersData = [];
|
468
|
-
const {
|
469
|
-
columns,
|
470
|
-
rows
|
471
|
-
} = config;
|
472
|
-
const headers = rows.filter(rowIndex => rowIndex < 0);
|
473
|
-
headers.forEach(rowIndex => {
|
474
|
-
const rowData = [];
|
475
|
-
for (let i = 0; i < columns.length; i += 1) {
|
476
|
-
const columnIndex = columns[i];
|
477
|
-
const headerCell = hotInstance.getCell(rowIndex, columnIndex);
|
478
|
-
const colspan = headerCell === null || headerCell === void 0 ? void 0 : headerCell.getAttribute('colspan');
|
479
|
-
rowData.push(hotInstance.getColHeader(columnIndex, rowIndex));
|
480
|
-
if (colspan) {
|
481
|
-
const parsedColspan = parseInt(colspan, 10);
|
482
|
-
const colspanReduced = Math.min(parsedColspan, columns.length - i);
|
483
|
-
rowData.push(...new Array(colspanReduced - 1).fill(''));
|
484
|
-
i += colspanReduced - 1;
|
485
|
-
}
|
108
|
+
for (let column = 0; column < columnsLen; column += 1) {
|
109
|
+
const cellData = rowData[column];
|
110
|
+
const parsedCellData = (0, _mixed.isEmpty)(cellData) ? '' : cellData.toString().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20{2,}/gi, substring => {
|
111
|
+
// The way how Excel serializes data with at least two spaces.
|
112
|
+
return `<span style="mso-spacerun: yes">${' '.repeat(substring.length - 1)} </span>`;
|
113
|
+
}).replace(/\t/gi, '	');
|
114
|
+
columnsResult.push(`<td>${parsedCellData}</td>`);
|
115
|
+
}
|
116
|
+
result.push('<tr>', ...columnsResult, '</tr>');
|
117
|
+
if (row + 1 === inputLen) {
|
118
|
+
result.push('</tbody>');
|
486
119
|
}
|
487
|
-
headersData.push(rowData);
|
488
|
-
});
|
489
|
-
return headersData;
|
490
|
-
}
|
491
|
-
|
492
|
-
/**
|
493
|
-
* Converts Handsontable's header coordinates into HTMLTableElement.tBodies.
|
494
|
-
*
|
495
|
-
* @param {Core} hotInstance The Handsontable instance.
|
496
|
-
* @param {object} config Configuration for building HTMLTableElement.
|
497
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating the table.
|
498
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating the table.
|
499
|
-
* @returns {Array<string>} List of HTMLElements stored as strings.
|
500
|
-
*/
|
501
|
-
function getBodyHTMLByCoords(hotInstance, config) {
|
502
|
-
const {
|
503
|
-
columns,
|
504
|
-
rows
|
505
|
-
} = config;
|
506
|
-
const bodyRows = rows.filter(rowIndex => rowIndex >= 0);
|
507
|
-
const cells = [];
|
508
|
-
if (bodyRows.length === 0 || columns.length === 0) {
|
509
|
-
return [];
|
510
120
|
}
|
511
|
-
|
512
|
-
|
513
|
-
columns.forEach((columnIndex, nthColumn) => {
|
514
|
-
if (columnIndex < 0) {
|
515
|
-
rowHTML.push(`<th>${encodeHTMLEntities(parseEmptyValues(hotInstance.getRowHeader(rowIndex)))}</th>`);
|
516
|
-
return;
|
517
|
-
}
|
518
|
-
const cellValue = hotInstance.getCopyableData(rowIndex, columnIndex);
|
519
|
-
const cellValueParsed = encodeHTMLEntities(parseEmptyValues(cellValue));
|
520
|
-
const {
|
521
|
-
hidden,
|
522
|
-
rowspan,
|
523
|
-
colspan
|
524
|
-
} = hotInstance.getCellMeta(rowIndex, columnIndex);
|
525
|
-
if (!hidden) {
|
526
|
-
const attrs = [];
|
527
|
-
if (rowspan) {
|
528
|
-
const recalculatedRowSpan = Math.min(rowspan, bodyRows.slice(nthRow).length);
|
529
|
-
if (recalculatedRowSpan > 1) {
|
530
|
-
attrs.push(` rowspan="${recalculatedRowSpan}"`);
|
531
|
-
}
|
532
|
-
}
|
533
|
-
if (colspan) {
|
534
|
-
const recalculatedColumnSpan = Math.min(colspan, columns.slice(nthColumn).length);
|
535
|
-
if (recalculatedColumnSpan > 1) {
|
536
|
-
attrs.push(` colspan="${recalculatedColumnSpan}"`);
|
537
|
-
}
|
538
|
-
}
|
539
|
-
rowHTML.push(`<td${attrs.join('')}>${cellValueParsed}</td>`);
|
540
|
-
}
|
541
|
-
});
|
542
|
-
rowHTML.push('</tr>');
|
543
|
-
cells.push(...rowHTML);
|
544
|
-
});
|
545
|
-
return ['<tbody>', ...cells, '</tbody>'];
|
546
|
-
}
|
547
|
-
|
548
|
-
/**
|
549
|
-
* Converts Handsontable's coordinates into list of values for cells not being headers.
|
550
|
-
*
|
551
|
-
* @param {Core} hotInstance The Handsontable instance.
|
552
|
-
* @param {object} config Configuration for building the cell value list.
|
553
|
-
* @param {Array<number>} config.rows List of row indexes which should be taken into account when creating the
|
554
|
-
* cell value list.
|
555
|
-
* @param {Array<number>} config.columns List of column indexes which should be taken into account when creating the
|
556
|
-
* cell value list.
|
557
|
-
* @returns {Array[]} List of displayed cell values.
|
558
|
-
*/
|
559
|
-
function getBodyDataByCoords(hotInstance, config) {
|
560
|
-
const cells = [];
|
561
|
-
const {
|
562
|
-
columns,
|
563
|
-
rows
|
564
|
-
} = config;
|
565
|
-
const bodyRows = rows.filter(rowIndex => rowIndex >= 0);
|
566
|
-
bodyRows.forEach(rowIndex => {
|
567
|
-
const rowData = [];
|
568
|
-
columns.forEach(columnIndex => {
|
569
|
-
const cellValue = hotInstance.getCopyableData(rowIndex, columnIndex);
|
570
|
-
const cellValueParsed = (0, _mixed.isEmpty)(cellValue) ? '' : cellValue;
|
571
|
-
rowData.push(cellValueParsed);
|
572
|
-
});
|
573
|
-
cells.push(rowData);
|
574
|
-
});
|
575
|
-
return cells;
|
121
|
+
result.push('</table>');
|
122
|
+
return result.join('');
|
576
123
|
}
|
577
124
|
|
578
125
|
/**
|
@@ -620,19 +167,18 @@ function htmlToGridSettings(element) {
|
|
620
167
|
}
|
621
168
|
return !isDataRow;
|
622
169
|
});
|
623
|
-
const isAnyNested = thRows.find(tr => tr.querySelector('th[colspan]') !== null) !== undefined;
|
624
170
|
thRowsLen = thRows.length;
|
625
171
|
hasColHeaders = thRowsLen > 0;
|
626
|
-
if (thRowsLen > 1
|
172
|
+
if (thRowsLen > 1) {
|
627
173
|
settingsObj.nestedHeaders = Array.from(thRows).reduce((rows, row) => {
|
628
174
|
const headersRow = Array.from(row.cells).reduce((headers, header, currentIndex) => {
|
629
175
|
if (hasRowHeaders && currentIndex === 0) {
|
630
176
|
return headers;
|
631
177
|
}
|
632
178
|
const {
|
633
|
-
colSpan: colspan
|
179
|
+
colSpan: colspan,
|
180
|
+
innerHTML
|
634
181
|
} = header;
|
635
|
-
const innerHTML = decodeHTMLEntities(header.innerHTML);
|
636
182
|
const nextHeader = colspan > 1 ? {
|
637
183
|
label: innerHTML,
|
638
184
|
colspan
|
@@ -648,7 +194,7 @@ function htmlToGridSettings(element) {
|
|
648
194
|
if (hasRowHeaders && index === 0) {
|
649
195
|
return headers;
|
650
196
|
}
|
651
|
-
headers.push(
|
197
|
+
headers.push(header.innerHTML);
|
652
198
|
return headers;
|
653
199
|
}, []);
|
654
200
|
}
|
@@ -682,7 +228,7 @@ function htmlToGridSettings(element) {
|
|
682
228
|
rowSpan: rowspan,
|
683
229
|
colSpan: colspan
|
684
230
|
} = cell;
|
685
|
-
const col = dataArr[row].findIndex(value => value ===
|
231
|
+
const col = dataArr[row].findIndex(value => value === undefined);
|
686
232
|
if (nodeName === 'TD') {
|
687
233
|
if (rowspan > 1 || colspan > 1) {
|
688
234
|
for (let rstart = row; rstart < row + rowspan; rstart++) {
|
@@ -709,7 +255,7 @@ function htmlToGridSettings(element) {
|
|
709
255
|
} else {
|
710
256
|
cellValue = innerHTML.replace(/<br(\s*|\/)>[\r\n]?/gim, '\r\n');
|
711
257
|
}
|
712
|
-
dataArr[row][col] =
|
258
|
+
dataArr[row][col] = cellValue.replace(regEscapedChars, match => ESCAPED_HTML_CHARS[match]);
|
713
259
|
} else {
|
714
260
|
rowHeaders.push(innerHTML);
|
715
261
|
}
|