handsontable 16.0.1 → 16.1.0-next-91b8a0f-20250905
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/3rdparty/walkontable/src/overlays.js +12 -2
- package/3rdparty/walkontable/src/overlays.mjs +12 -2
- package/3rdparty/walkontable/src/viewport.js +2 -6
- package/3rdparty/walkontable/src/viewport.mjs +2 -6
- package/CHANGELOG.md +37 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/autocompleteType/accessors/index.js +7 -0
- package/cellTypes/autocompleteType/accessors/index.mjs +2 -0
- package/cellTypes/autocompleteType/accessors/valueGetter.js +14 -0
- package/cellTypes/autocompleteType/accessors/valueGetter.mjs +10 -0
- package/cellTypes/autocompleteType/accessors/valueSetter.js +25 -0
- package/cellTypes/autocompleteType/accessors/valueSetter.mjs +21 -0
- package/cellTypes/autocompleteType/autocompleteType.js +4 -1
- package/cellTypes/autocompleteType/autocompleteType.mjs +4 -1
- package/cellTypes/checkboxType/accessors/index.js +5 -0
- package/cellTypes/checkboxType/accessors/index.mjs +1 -0
- package/cellTypes/checkboxType/accessors/valueSetter.js +26 -0
- package/cellTypes/checkboxType/accessors/valueSetter.mjs +22 -0
- package/cellTypes/checkboxType/checkboxType.js +3 -1
- package/cellTypes/checkboxType/checkboxType.mjs +3 -1
- package/cellTypes/dropdownType/accessors/index.js +7 -0
- package/cellTypes/dropdownType/accessors/index.mjs +2 -0
- package/cellTypes/dropdownType/accessors/valueGetter.js +14 -0
- package/cellTypes/dropdownType/accessors/valueGetter.mjs +10 -0
- package/cellTypes/dropdownType/accessors/valueSetter.js +17 -0
- package/cellTypes/dropdownType/accessors/valueSetter.mjs +13 -0
- package/cellTypes/dropdownType/dropdownType.js +4 -1
- package/cellTypes/dropdownType/dropdownType.mjs +4 -1
- package/cellTypes/numericType/accessors/index.js +5 -0
- package/cellTypes/numericType/accessors/index.mjs +1 -0
- package/cellTypes/numericType/accessors/valueSetter.js +19 -0
- package/cellTypes/numericType/accessors/valueSetter.mjs +15 -0
- package/cellTypes/numericType/numericType.js +3 -1
- package/cellTypes/numericType/numericType.mjs +3 -1
- package/core/focusCatcher/index.js +37 -112
- package/core/focusCatcher/index.mjs +35 -110
- package/core/focusCatcher/utils.js +31 -0
- package/core/focusCatcher/utils.mjs +27 -0
- package/core/hooks/constants.js +242 -0
- package/core/hooks/constants.mjs +242 -0
- package/core/hooks/index.d.ts +22 -0
- package/core/viewportScroll/scrollStrategies/focusScroll.js +5 -1
- package/core/viewportScroll/scrollStrategies/focusScroll.mjs +5 -1
- package/core/viewportScroll/utils.js +1 -1
- package/core/viewportScroll/utils.mjs +1 -1
- package/core.d.ts +4 -0
- package/core.js +237 -139
- package/core.mjs +240 -142
- package/dataMap/dataMap.js +13 -3
- package/dataMap/dataMap.mjs +14 -4
- package/dataMap/dataSource.js +16 -0
- package/dataMap/dataSource.mjs +16 -0
- package/dataMap/metaManager/lazyFactoryMap.js +4 -3
- package/dataMap/metaManager/lazyFactoryMap.mjs +2 -1
- package/dataMap/metaManager/metaLayers/cellMeta.js +3 -2
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +3 -2
- package/dataMap/metaManager/metaSchema.js +289 -4
- package/dataMap/metaManager/metaSchema.mjs +289 -4
- package/dataMap/metaManager/utils.js +0 -11
- package/dataMap/metaManager/utils.mjs +0 -10
- package/dataMap/replaceData.js +1 -0
- package/dataMap/replaceData.mjs +1 -0
- package/dist/handsontable.css +281 -4
- package/dist/handsontable.full.css +281 -4
- package/dist/handsontable.full.js +7842 -2990
- package/dist/handsontable.full.min.css +4 -5
- package/dist/handsontable.full.min.js +167 -165
- package/dist/handsontable.js +9638 -4807
- package/dist/handsontable.min.css +4 -4
- package/dist/handsontable.min.js +52 -50
- package/dist/languages/all.js +231 -21
- package/dist/languages/all.min.js +1 -1
- package/dist/languages/ar-AR.js +11 -1
- package/dist/languages/ar-AR.min.js +1 -1
- package/dist/languages/cs-CZ.js +11 -1
- package/dist/languages/cs-CZ.min.js +1 -1
- package/dist/languages/de-CH.js +11 -1
- package/dist/languages/de-CH.min.js +1 -1
- package/dist/languages/de-DE.js +11 -1
- package/dist/languages/de-DE.min.js +1 -1
- package/dist/languages/en-US.js +11 -1
- package/dist/languages/en-US.min.js +1 -1
- package/dist/languages/es-MX.js +11 -1
- package/dist/languages/es-MX.min.js +1 -1
- package/dist/languages/fa-IR.js +11 -1
- package/dist/languages/fa-IR.min.js +1 -1
- package/dist/languages/fr-FR.js +11 -1
- package/dist/languages/fr-FR.min.js +1 -1
- package/dist/languages/hr-HR.js +11 -1
- package/dist/languages/hr-HR.min.js +1 -1
- package/dist/languages/it-IT.js +11 -1
- package/dist/languages/it-IT.min.js +1 -1
- package/dist/languages/ja-JP.js +11 -1
- package/dist/languages/ja-JP.min.js +1 -1
- package/dist/languages/ko-KR.js +11 -1
- package/dist/languages/ko-KR.min.js +1 -1
- package/dist/languages/lv-LV.js +11 -1
- package/dist/languages/lv-LV.min.js +1 -1
- package/dist/languages/nb-NO.js +11 -1
- package/dist/languages/nb-NO.min.js +1 -1
- package/dist/languages/nl-NL.js +11 -1
- package/dist/languages/nl-NL.min.js +1 -1
- package/dist/languages/pl-PL.js +11 -1
- package/dist/languages/pl-PL.min.js +1 -1
- package/dist/languages/pt-BR.js +11 -1
- package/dist/languages/pt-BR.min.js +1 -1
- package/dist/languages/ru-RU.js +11 -1
- package/dist/languages/ru-RU.min.js +1 -1
- package/dist/languages/sr-SP.js +11 -1
- package/dist/languages/sr-SP.min.js +1 -1
- package/dist/languages/zh-CN.js +11 -1
- package/dist/languages/zh-CN.min.js +1 -1
- package/dist/languages/zh-TW.js +11 -1
- package/dist/languages/zh-TW.min.js +1 -1
- package/editorManager.js +4 -4
- package/editorManager.mjs +4 -4
- package/editors/autocompleteEditor/autocompleteEditor.js +50 -112
- package/editors/autocompleteEditor/autocompleteEditor.mjs +51 -113
- package/editors/baseEditor/baseEditor.js +10 -6
- package/editors/baseEditor/baseEditor.mjs +10 -6
- package/editors/handsontableEditor/handsontableEditor.js +9 -9
- package/editors/handsontableEditor/handsontableEditor.mjs +9 -9
- package/editors/textEditor/textEditor.js +0 -7
- package/editors/textEditor/textEditor.mjs +0 -7
- package/focusManager.js +2 -2
- package/focusManager.mjs +2 -2
- package/helpers/a11y.js +15 -2
- package/helpers/a11y.mjs +10 -2
- package/helpers/console.js +12 -0
- package/helpers/console.mjs +11 -0
- package/helpers/dom/element.js +4 -4
- package/helpers/dom/element.mjs +4 -4
- package/helpers/mixed.js +65 -2
- package/helpers/mixed.mjs +63 -2
- package/helpers/number.js +28 -0
- package/helpers/number.mjs +26 -0
- package/helpers/object.js +35 -0
- package/helpers/object.mjs +34 -0
- package/helpers/string.js +19 -0
- package/helpers/string.mjs +18 -0
- package/helpers/templateLiteralTag.js +57 -1
- package/helpers/templateLiteralTag.mjs +56 -1
- package/i18n/constants.js +13 -1
- package/i18n/constants.mjs +13 -1
- package/i18n/languages/ar-AR.js +11 -1
- package/i18n/languages/ar-AR.mjs +11 -1
- package/i18n/languages/cs-CZ.js +11 -1
- package/i18n/languages/cs-CZ.mjs +11 -1
- package/i18n/languages/de-CH.js +11 -1
- package/i18n/languages/de-CH.mjs +11 -1
- package/i18n/languages/de-DE.js +11 -1
- package/i18n/languages/de-DE.mjs +11 -1
- package/i18n/languages/en-US.js +11 -1
- package/i18n/languages/en-US.mjs +11 -1
- package/i18n/languages/es-MX.js +11 -1
- package/i18n/languages/es-MX.mjs +11 -1
- package/i18n/languages/fa-IR.js +11 -1
- package/i18n/languages/fa-IR.mjs +11 -1
- package/i18n/languages/fr-FR.js +11 -1
- package/i18n/languages/fr-FR.mjs +11 -1
- package/i18n/languages/hr-HR.js +11 -1
- package/i18n/languages/hr-HR.mjs +11 -1
- package/i18n/languages/it-IT.js +11 -1
- package/i18n/languages/it-IT.mjs +11 -1
- package/i18n/languages/ja-JP.js +11 -1
- package/i18n/languages/ja-JP.mjs +11 -1
- package/i18n/languages/ko-KR.js +11 -1
- package/i18n/languages/ko-KR.mjs +11 -1
- package/i18n/languages/lv-LV.js +11 -1
- package/i18n/languages/lv-LV.mjs +11 -1
- package/i18n/languages/nb-NO.js +11 -1
- package/i18n/languages/nb-NO.mjs +11 -1
- package/i18n/languages/nl-NL.js +11 -1
- package/i18n/languages/nl-NL.mjs +11 -1
- package/i18n/languages/pl-PL.js +11 -1
- package/i18n/languages/pl-PL.mjs +11 -1
- package/i18n/languages/pt-BR.js +11 -1
- package/i18n/languages/pt-BR.mjs +11 -1
- package/i18n/languages/ru-RU.js +11 -1
- package/i18n/languages/ru-RU.mjs +11 -1
- package/i18n/languages/sr-SP.js +11 -1
- package/i18n/languages/sr-SP.mjs +11 -1
- package/i18n/languages/zh-CN.js +11 -1
- package/i18n/languages/zh-CN.mjs +11 -1
- package/i18n/languages/zh-TW.js +11 -1
- package/i18n/languages/zh-TW.mjs +11 -1
- package/i18n/phraseFormatters/index.js +3 -1
- package/i18n/phraseFormatters/index.mjs +3 -1
- package/i18n/registry.js +5 -6
- package/i18n/registry.mjs +5 -6
- package/index.d.ts +27 -0
- package/languages/all.js +231 -21
- package/languages/ar-AR.js +11 -1
- package/languages/ar-AR.mjs +11 -1
- package/languages/cs-CZ.js +11 -1
- package/languages/cs-CZ.mjs +11 -1
- package/languages/de-CH.js +11 -1
- package/languages/de-CH.mjs +11 -1
- package/languages/de-DE.js +11 -1
- package/languages/de-DE.mjs +11 -1
- package/languages/en-US.js +11 -1
- package/languages/en-US.mjs +11 -1
- package/languages/es-MX.js +11 -1
- package/languages/es-MX.mjs +11 -1
- package/languages/fa-IR.js +11 -1
- package/languages/fa-IR.mjs +11 -1
- package/languages/fr-FR.js +11 -1
- package/languages/fr-FR.mjs +11 -1
- package/languages/hr-HR.js +11 -1
- package/languages/hr-HR.mjs +11 -1
- package/languages/index.js +231 -21
- package/languages/it-IT.js +11 -1
- package/languages/it-IT.mjs +11 -1
- package/languages/ja-JP.js +11 -1
- package/languages/ja-JP.mjs +11 -1
- package/languages/ko-KR.js +11 -1
- package/languages/ko-KR.mjs +11 -1
- package/languages/lv-LV.js +11 -1
- package/languages/lv-LV.mjs +11 -1
- package/languages/nb-NO.js +11 -1
- package/languages/nb-NO.mjs +11 -1
- package/languages/nl-NL.js +11 -1
- package/languages/nl-NL.mjs +11 -1
- package/languages/pl-PL.js +11 -1
- package/languages/pl-PL.mjs +11 -1
- package/languages/pt-BR.js +11 -1
- package/languages/pt-BR.mjs +11 -1
- package/languages/ru-RU.js +11 -1
- package/languages/ru-RU.mjs +11 -1
- package/languages/sr-SP.js +11 -1
- package/languages/sr-SP.mjs +11 -1
- package/languages/zh-CN.js +11 -1
- package/languages/zh-CN.mjs +11 -1
- package/languages/zh-TW.js +11 -1
- package/languages/zh-TW.mjs +11 -1
- package/mixins/localHooks.js +16 -0
- package/mixins/localHooks.mjs +16 -0
- package/package.json +19 -1
- package/plugins/autoRowSize/autoRowSize.js +43 -6
- package/plugins/autoRowSize/autoRowSize.mjs +43 -6
- package/plugins/autofill/autofill.js +50 -3
- package/plugins/autofill/autofill.mjs +50 -3
- package/plugins/base/base.js +86 -15
- package/plugins/base/base.mjs +87 -16
- package/plugins/collapsibleColumns/collapsibleColumns.js +4 -4
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +4 -4
- package/plugins/columnSorting/columnSorting.js +3 -3
- package/plugins/columnSorting/columnSorting.mjs +3 -3
- package/plugins/comments/comments.js +52 -22
- package/plugins/comments/comments.mjs +52 -22
- package/plugins/comments/contextMenuItem/addEditComment.js +3 -3
- package/plugins/comments/contextMenuItem/addEditComment.mjs +3 -3
- package/plugins/comments/contextMenuItem/readOnlyComment.js +2 -2
- package/plugins/comments/contextMenuItem/readOnlyComment.mjs +2 -2
- package/plugins/comments/contextMenuItem/removeComment.js +2 -2
- package/plugins/comments/contextMenuItem/removeComment.mjs +2 -2
- package/plugins/contextMenu/contextMenu.js +4 -5
- package/plugins/contextMenu/contextMenu.mjs +4 -5
- package/plugins/contextMenu/menu/cursor.js +1 -1
- package/plugins/contextMenu/menu/cursor.mjs +1 -1
- package/plugins/contextMenu/menu/defaultShortcutsList.js +5 -5
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +5 -5
- package/plugins/contextMenu/menu/menu.js +3 -3
- package/plugins/contextMenu/menu/menu.mjs +3 -3
- package/plugins/contextMenu/menu/positioner.js +1 -1
- package/plugins/contextMenu/menu/positioner.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/alignment.js +1 -1
- package/plugins/contextMenu/predefinedItems/alignment.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/clearColumn.js +1 -1
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/columnRight.js +3 -3
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/readOnly.js +1 -1
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/removeColumn.js +1 -1
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/removeRow.js +1 -1
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copy.js +1 -1
- package/plugins/copyPaste/contextMenuItem/copy.mjs +1 -1
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/cut.js +1 -1
- package/plugins/copyPaste/contextMenuItem/cut.mjs +1 -1
- package/plugins/copyPaste/copyPaste.js +75 -40
- package/plugins/copyPaste/copyPaste.mjs +76 -41
- package/plugins/customBorders/customBorders.js +1 -1
- package/plugins/customBorders/customBorders.mjs +1 -1
- package/plugins/dialog/dialog.d.ts +23 -0
- package/plugins/dialog/dialog.js +489 -0
- package/plugins/dialog/dialog.mjs +485 -0
- package/plugins/dialog/index.d.ts +1 -0
- package/plugins/dialog/index.js +7 -0
- package/plugins/dialog/index.mjs +1 -0
- package/plugins/dialog/ui.js +264 -0
- package/plugins/dialog/ui.mjs +259 -0
- package/plugins/dropdownMenu/dropdownMenu.js +5 -4
- package/plugins/dropdownMenu/dropdownMenu.mjs +5 -4
- package/plugins/filters/filters.js +2 -2
- package/plugins/filters/filters.mjs +2 -2
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.js +3 -3
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.mjs +3 -3
- package/plugins/hiddenColumns/contextMenuItem/showColumn.js +4 -4
- package/plugins/hiddenColumns/contextMenuItem/showColumn.mjs +4 -4
- package/plugins/hiddenRows/contextMenuItem/hideRow.js +3 -3
- package/plugins/hiddenRows/contextMenuItem/hideRow.mjs +3 -3
- package/plugins/hiddenRows/contextMenuItem/showRow.js +4 -4
- package/plugins/hiddenRows/contextMenuItem/showRow.mjs +4 -4
- package/plugins/index.d.ts +9 -0
- package/plugins/index.js +9 -0
- package/plugins/index.mjs +7 -1
- package/plugins/loading/content.js +36 -0
- package/plugins/loading/content.mjs +31 -0
- package/plugins/loading/index.d.ts +1 -0
- package/plugins/loading/index.js +7 -0
- package/plugins/loading/index.mjs +1 -0
- package/plugins/loading/loading.d.ts +19 -0
- package/plugins/loading/loading.js +290 -0
- package/plugins/loading/loading.mjs +285 -0
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +1 -1
- package/plugins/manualColumnMove/manualColumnMove.js +3 -3
- package/plugins/manualColumnMove/manualColumnMove.mjs +3 -3
- package/plugins/manualColumnResize/manualColumnResize.js +3 -3
- package/plugins/manualColumnResize/manualColumnResize.mjs +3 -3
- package/plugins/manualRowMove/manualRowMove.js +4 -4
- package/plugins/manualRowMove/manualRowMove.mjs +4 -4
- package/plugins/manualRowResize/manualRowResize.js +5 -2
- package/plugins/manualRowResize/manualRowResize.mjs +5 -2
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +15 -15
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +15 -15
- package/plugins/mergeCells/focusOrder.js +75 -39
- package/plugins/mergeCells/focusOrder.mjs +75 -39
- package/plugins/mergeCells/mergeCells.js +26 -19
- package/plugins/mergeCells/mergeCells.mjs +26 -19
- package/plugins/mergeCells/renderer.js +14 -8
- package/plugins/mergeCells/renderer.mjs +14 -8
- package/plugins/multiColumnSorting/multiColumnSorting.js +3 -3
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +3 -3
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +3 -3
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +3 -3
- package/plugins/nestedHeaders/nestedHeaders.js +47 -41
- package/plugins/nestedHeaders/nestedHeaders.mjs +47 -41
- package/plugins/nestedRows/nestedRows.js +3 -3
- package/plugins/nestedRows/nestedRows.mjs +3 -3
- package/plugins/nestedRows/ui/collapsing.js +1 -2
- package/plugins/nestedRows/ui/collapsing.mjs +1 -2
- package/plugins/nestedRows/ui/contextMenu.js +4 -4
- package/plugins/nestedRows/ui/contextMenu.mjs +4 -4
- package/plugins/nestedRows/ui/headers.js +4 -1
- package/plugins/nestedRows/ui/headers.mjs +4 -1
- package/plugins/pagination/focusController.js +27 -0
- package/plugins/pagination/focusController.mjs +23 -0
- package/plugins/pagination/index.d.ts +1 -0
- package/plugins/pagination/index.js +7 -0
- package/plugins/pagination/index.mjs +1 -0
- package/plugins/pagination/pagination.d.ts +52 -0
- package/plugins/pagination/pagination.js +1034 -0
- package/plugins/pagination/pagination.mjs +1030 -0
- package/plugins/pagination/strategies/autoPageSize.js +96 -0
- package/plugins/pagination/strategies/autoPageSize.mjs +92 -0
- package/plugins/pagination/strategies/fixedPageSize.js +88 -0
- package/plugins/pagination/strategies/fixedPageSize.mjs +84 -0
- package/plugins/pagination/strategies/index.js +22 -0
- package/plugins/pagination/strategies/index.mjs +18 -0
- package/plugins/pagination/ui.js +449 -0
- package/plugins/pagination/ui.mjs +443 -0
- package/plugins/pagination/utils.js +28 -0
- package/plugins/pagination/utils.mjs +24 -0
- package/plugins/stretchColumns/calculator.js +4 -0
- package/plugins/stretchColumns/calculator.mjs +4 -0
- package/plugins/stretchColumns/stretchColumns.js +1 -1
- package/plugins/stretchColumns/stretchColumns.mjs +1 -1
- package/plugins/undoRedo/actions/dataChange.js +17 -15
- package/plugins/undoRedo/actions/dataChange.mjs +17 -15
- package/renderers/checkboxRenderer/checkboxRenderer.js +3 -3
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +3 -3
- package/selection/range.js +11 -0
- package/selection/range.mjs +11 -0
- package/selection/selection.js +163 -124
- package/selection/selection.mjs +163 -124
- package/selection/transformation/_base.js +448 -0
- package/selection/transformation/_base.mjs +443 -0
- package/selection/transformation/extender.js +55 -0
- package/selection/transformation/extender.mjs +51 -0
- package/selection/transformation/focus.js +77 -0
- package/selection/transformation/focus.mjs +73 -0
- package/selection/transformation/index.js +7 -0
- package/selection/transformation/index.mjs +2 -0
- package/selection/utils.js +2 -1
- package/selection/utils.mjs +2 -1
- package/settings.d.ts +10 -1
- package/shortcutContexts/commands/editor/fastOpen.js +1 -1
- package/shortcutContexts/commands/editor/fastOpen.mjs +1 -1
- package/shortcutContexts/commands/editor/open.js +10 -4
- package/shortcutContexts/commands/editor/open.mjs +10 -4
- package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +2 -2
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +2 -2
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +2 -2
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +5 -2
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -2
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/scrollToFocusedCell.js +1 -1
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +1 -1
- package/shortcutContexts/grid.js +3 -3
- package/shortcutContexts/grid.mjs +3 -3
- package/shortcuts/context.js +4 -1
- package/shortcuts/context.mjs +4 -1
- package/shortcuts/manager.js +17 -3
- package/shortcuts/manager.mjs +17 -3
- package/styles/handsontable.css +288 -22
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-classic.css +828 -0
- package/styles/ht-theme-classic.min.css +30 -0
- package/styles/ht-theme-horizon.css +122 -26
- package/styles/ht-theme-horizon.min.css +3 -3
- package/styles/ht-theme-main.css +124 -28
- package/styles/ht-theme-main.min.css +3 -3
- package/tableView.js +61 -25
- package/tableView.mjs +61 -25
- package/utils/a11yAnnouncer.js +70 -0
- package/utils/a11yAnnouncer.mjs +64 -0
- package/{core/focusCatcher → utils}/focusDetector.js +30 -12
- package/{core/focusCatcher → utils}/focusDetector.mjs +30 -12
- package/utils/samplesGenerator.js +17 -1
- package/utils/samplesGenerator.mjs +17 -1
- package/utils/stylesHandler.js +23 -8
- package/utils/stylesHandler.mjs +23 -8
- package/utils/valueAccessors.js +45 -0
- package/utils/valueAccessors.mjs +40 -0
- package/validators/autocompleteValidator/autocompleteValidator.js +2 -1
- package/validators/autocompleteValidator/autocompleteValidator.mjs +2 -1
- package/selection/transformation.js +0 -335
- package/selection/transformation.mjs +0 -331
@@ -8,8 +8,8 @@ export default function copyWithColumnHeadersItem(copyPastePlugin) {
|
|
8
8
|
return {
|
9
9
|
key: 'copy_with_column_headers',
|
10
10
|
name() {
|
11
|
-
const
|
12
|
-
const nounForm =
|
11
|
+
const activeSelectedRange = this.getSelectedRangeActive();
|
12
|
+
const nounForm = activeSelectedRange ? clamp(activeSelectedRange.getWidth() - 1, 0, 1) : 0;
|
13
13
|
return this.getTranslatedPhrase(CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_HEADERS, nounForm);
|
14
14
|
},
|
15
15
|
callback() {
|
@@ -19,7 +19,7 @@ export default function copyWithColumnHeadersItem(copyPastePlugin) {
|
|
19
19
|
if (!this.hasColHeaders()) {
|
20
20
|
return true;
|
21
21
|
}
|
22
|
-
const range = this.
|
22
|
+
const range = this.getSelectedRangeActive();
|
23
23
|
if (!range) {
|
24
24
|
return true;
|
25
25
|
}
|
@@ -16,7 +16,7 @@ export default function cutItem(copyPastePlugin) {
|
|
16
16
|
if (this.countRows() === 0 || this.countCols() === 0) {
|
17
17
|
return true;
|
18
18
|
}
|
19
|
-
const range = this.
|
19
|
+
const range = this.getSelectedRangeActive();
|
20
20
|
if (!range) {
|
21
21
|
return true;
|
22
22
|
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
5
|
require("core-js/modules/es.array.push.js");
|
6
|
+
require("core-js/modules/es.json.stringify.js");
|
6
7
|
require("core-js/modules/esnext.iterator.constructor.js");
|
7
8
|
require("core-js/modules/esnext.iterator.filter.js");
|
8
9
|
require("core-js/modules/esnext.iterator.map.js");
|
@@ -11,6 +12,7 @@ var _hooks = require("../../core/hooks");
|
|
11
12
|
var _SheetClip = require("../../3rdparty/SheetClip");
|
12
13
|
var _array = require("../../helpers/array");
|
13
14
|
var _string = require("../../helpers/string");
|
15
|
+
var _object = require("../../helpers/object");
|
14
16
|
var _element = require("../../helpers/dom/element");
|
15
17
|
var _browser = require("../../helpers/browser");
|
16
18
|
var _copy = _interopRequireDefault(require("./contextMenuItem/copy"));
|
@@ -42,6 +44,7 @@ _hooks.Hooks.getSingleton().register('afterCopy');
|
|
42
44
|
const PLUGIN_KEY = exports.PLUGIN_KEY = 'copyPaste';
|
43
45
|
const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 80;
|
44
46
|
const SETTING_KEYS = ['fragmentSelection'];
|
47
|
+
const SOURCE_DATA_HTML_MIME_TYPE = 'application/ht-source-data-json-html';
|
45
48
|
const META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
|
46
49
|
|
47
50
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
@@ -377,9 +380,11 @@ class CopyPaste extends _base.BasePlugin {
|
|
377
380
|
* Converts the contents of multiple ranges (`ranges`) into an array of arrays.
|
378
381
|
*
|
379
382
|
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
383
|
+
* @param {boolean} [useSourceData=false] Whether to use the source data instead of the data. This will stringify objects as JSON.
|
380
384
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
381
385
|
*/
|
382
386
|
getRangedData(ranges) {
|
387
|
+
let useSourceData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
383
388
|
const data = [];
|
384
389
|
const {
|
385
390
|
rows,
|
@@ -394,7 +399,11 @@ class CopyPaste extends _base.BasePlugin {
|
|
394
399
|
// `row` as the second argument acts here as the `headerLevel` argument
|
395
400
|
rowSet.push(this.hot.getColHeader(column, row));
|
396
401
|
} else {
|
397
|
-
|
402
|
+
let copyableCellData = useSourceData ? this.hot.getCopyableSourceData(row, column) : this.hot.getCopyableData(row, column);
|
403
|
+
if (useSourceData && (0, _object.isObject)(copyableCellData)) {
|
404
|
+
copyableCellData = JSON.stringify(copyableCellData);
|
405
|
+
}
|
406
|
+
rowSet.push(copyableCellData);
|
398
407
|
}
|
399
408
|
});
|
400
409
|
data.push(rowSet);
|
@@ -430,7 +439,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
430
439
|
* Prepares copyable text from the cells selection in the invisible textarea.
|
431
440
|
*/
|
432
441
|
setCopyableText() {
|
433
|
-
const selectionRange = this.hot.
|
442
|
+
const selectionRange = this.hot.getSelectedRangeActive();
|
434
443
|
if (!selectionRange) {
|
435
444
|
return;
|
436
445
|
}
|
@@ -492,13 +501,14 @@ class CopyPaste extends _base.BasePlugin {
|
|
492
501
|
*
|
493
502
|
* @private
|
494
503
|
* @param {Array} inputArray An array of the data to populate.
|
504
|
+
* @param {Array} sourceInputArray An array of the source data to populate.
|
495
505
|
* @param {Array} [selection] The selection which indicates from what position the data will be populated.
|
496
506
|
* @returns {Array} Range coordinates after populate data.
|
497
507
|
*/
|
498
|
-
populateValues(inputArray) {
|
499
|
-
let selection = arguments.length >
|
508
|
+
populateValues(inputArray, sourceInputArray) {
|
509
|
+
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.hot.getSelectedRangeActive();
|
500
510
|
if (!inputArray.length) {
|
501
|
-
return;
|
511
|
+
return [null, null, null, null];
|
502
512
|
}
|
503
513
|
const populatedRowsLength = inputArray.length;
|
504
514
|
const populatedColumnsLength = inputArray[0].length;
|
@@ -534,18 +544,28 @@ class CopyPaste extends _base.BasePlugin {
|
|
534
544
|
const newRow = [];
|
535
545
|
const insertedRow = newRows.length % populatedRowsLength;
|
536
546
|
while (newRow.length < populatedColumnsLength || visualColumnForPopulatedData <= endColumnFromSelection) {
|
547
|
+
var _sourceInputArray$ins;
|
537
548
|
const {
|
538
549
|
skipColumnOnPaste,
|
539
550
|
visualCol
|
540
|
-
} = this.hot.getCellMeta(
|
551
|
+
} = this.hot.getCellMeta(visualRow, visualColumnForPopulatedData);
|
552
|
+
const sourceDataAtTarget = this.hot.getSourceDataAtCell(visualRow, visualColumnForPopulatedData);
|
553
|
+
const insertedColumn = newRow.length % populatedColumnsLength;
|
541
554
|
visualColumnForPopulatedData = visualCol + 1;
|
542
555
|
if (skipColumnOnPaste === true) {
|
543
556
|
/* eslint-disable no-continue */
|
544
557
|
continue;
|
545
558
|
}
|
546
559
|
lastVisualColumn = visualCol;
|
547
|
-
const
|
548
|
-
|
560
|
+
const sourceCellValue = sourceInputArray === null || sourceInputArray === void 0 || (_sourceInputArray$ins = sourceInputArray[insertedRow]) === null || _sourceInputArray$ins === void 0 ? void 0 : _sourceInputArray$ins[insertedColumn];
|
561
|
+
let cellValue = inputArray[insertedRow][insertedColumn];
|
562
|
+
if (sourceInputArray && (0, _string.isJSON)(sourceCellValue)) {
|
563
|
+
const parsedCellValue = JSON.parse(sourceCellValue);
|
564
|
+
if ((0, _object.isObject)(sourceDataAtTarget) || sourceDataAtTarget === null) {
|
565
|
+
cellValue = parsedCellValue;
|
566
|
+
}
|
567
|
+
}
|
568
|
+
newRow.push(cellValue);
|
549
569
|
}
|
550
570
|
newRows.push(newRow);
|
551
571
|
}
|
@@ -574,19 +594,13 @@ class CopyPaste extends _base.BasePlugin {
|
|
574
594
|
event.preventDefault();
|
575
595
|
this.setCopyableText();
|
576
596
|
_classPrivateFieldSet(_isTriggeredByCopy, this, false);
|
577
|
-
const
|
597
|
+
const rangedData = this.getRangedData(this.copyableRanges);
|
598
|
+
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
578
599
|
const copiedHeadersCount = _assertClassBrand(_CopyPaste_brand, this, _countCopiedHeaders).call(this, this.copyableRanges);
|
579
|
-
const allowCopying = !!this.hot.runHooks('beforeCopy',
|
600
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges, copiedHeadersCount);
|
580
601
|
if (allowCopying) {
|
581
|
-
|
582
|
-
|
583
|
-
const textHTML = (0, _parseTable._dataToHTML)(data, this.hot.rootDocument);
|
584
|
-
event.clipboardData.setData('text/plain', textPlain);
|
585
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
586
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
587
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
588
|
-
}
|
589
|
-
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
602
|
+
_assertClassBrand(_CopyPaste_brand, this, _setClipboardData).call(this, event, rangedData, rangedSourceData);
|
603
|
+
this.hot.runHooks('afterCopy', rangedData, this.copyableRanges, copiedHeadersCount);
|
590
604
|
}
|
591
605
|
_classPrivateFieldSet(_copyMode, this, 'cells-only');
|
592
606
|
}
|
@@ -608,16 +622,10 @@ class CopyPaste extends _base.BasePlugin {
|
|
608
622
|
this.setCopyableText();
|
609
623
|
_classPrivateFieldSet(_isTriggeredByCut, this, false);
|
610
624
|
const rangedData = this.getRangedData(this.copyableRanges);
|
625
|
+
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
611
626
|
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
612
627
|
if (allowCuttingOut) {
|
613
|
-
|
614
|
-
if (event && event.clipboardData) {
|
615
|
-
const textHTML = (0, _parseTable._dataToHTML)(rangedData, this.hot.rootDocument);
|
616
|
-
event.clipboardData.setData('text/plain', textPlain);
|
617
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
618
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
619
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
620
|
-
}
|
628
|
+
_assertClassBrand(_CopyPaste_brand, this, _setClipboardData).call(this, event, rangedData, rangedSourceData);
|
621
629
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
622
630
|
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
623
631
|
}
|
@@ -638,7 +646,13 @@ class CopyPaste extends _base.BasePlugin {
|
|
638
646
|
}
|
639
647
|
event.preventDefault();
|
640
648
|
let pastedData;
|
649
|
+
let pastedSourceData;
|
641
650
|
if (event && typeof event.clipboardData !== 'undefined') {
|
651
|
+
const sourceDataHTML = event.clipboardData.getData(SOURCE_DATA_HTML_MIME_TYPE);
|
652
|
+
if (sourceDataHTML) {
|
653
|
+
const parsedSourceConfig = (0, _parseTable.htmlToGridSettings)(sourceDataHTML, this.hot.rootDocument);
|
654
|
+
pastedSourceData = parsedSourceConfig.data;
|
655
|
+
}
|
642
656
|
const textHTML = (0, _string.sanitize)(event.clipboardData.getData('text/html'), {
|
643
657
|
ADD_TAGS: ['meta'],
|
644
658
|
ADD_ATTR: ['content'],
|
@@ -662,15 +676,19 @@ class CopyPaste extends _base.BasePlugin {
|
|
662
676
|
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
663
677
|
return;
|
664
678
|
}
|
665
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
666
|
-
|
679
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData, pastedSourceData);
|
680
|
+
if (startRow !== null && startColumn !== null) {
|
681
|
+
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
682
|
+
}
|
667
683
|
this.hot.runHooks('afterPaste', pastedData, this.copyableRanges);
|
668
684
|
}
|
669
685
|
|
670
686
|
/**
|
671
|
-
*
|
687
|
+
* Sets the clipboard data.
|
672
688
|
*
|
673
|
-
* @param {
|
689
|
+
* @param {ClipboardEvent} event The Clipboard event.
|
690
|
+
* @param {Array} rangedData Ranged data to set to the clipboard.
|
691
|
+
* @param {Array} rangedSourceData Ranged source data to set to the clipboard.
|
674
692
|
*/
|
675
693
|
|
676
694
|
/**
|
@@ -684,12 +702,12 @@ exports.CopyPaste = CopyPaste;
|
|
684
702
|
function _ensureClipboardEventsGetTriggered(eventName) {
|
685
703
|
// Without this workaround Safari (tested on Safari@16.5.2) does not trigger the 'copy' event.
|
686
704
|
if ((0, _browser.isSafari)()) {
|
687
|
-
const
|
688
|
-
if (
|
705
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
706
|
+
if (activeSelectedRange) {
|
689
707
|
const {
|
690
708
|
row: highlightRow,
|
691
709
|
col: highlightColumn
|
692
|
-
} =
|
710
|
+
} = activeSelectedRange.highlight;
|
693
711
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
694
712
|
if (currentlySelectedCell) {
|
695
713
|
(0, _element.runWithSelectedContendEditableElement)(currentlySelectedCell, () => {
|
@@ -726,12 +744,12 @@ function _countCopiedHeaders(ranges) {
|
|
726
744
|
}
|
727
745
|
function _addContentEditableToHighlightedCell() {
|
728
746
|
if (this.hot.isListening()) {
|
729
|
-
const
|
730
|
-
if (
|
747
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
748
|
+
if (activeSelectedRange) {
|
731
749
|
const {
|
732
750
|
row: highlightRow,
|
733
751
|
col: highlightColumn
|
734
|
-
} =
|
752
|
+
} = activeSelectedRange.highlight;
|
735
753
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
736
754
|
if (currentlySelectedCell) {
|
737
755
|
(0, _element.makeElementContentEditableAndSelectItsContent)(currentlySelectedCell);
|
@@ -745,12 +763,12 @@ function _addContentEditableToHighlightedCell() {
|
|
745
763
|
function _removeContentEditableFromHighlightedCell() {
|
746
764
|
// If the instance is not listening, the workaround is not needed.
|
747
765
|
if (this.hot.isListening()) {
|
748
|
-
const
|
749
|
-
if (
|
766
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
767
|
+
if (activeSelectedRange) {
|
750
768
|
const {
|
751
769
|
row: highlightRow,
|
752
770
|
col: highlightColumn
|
753
|
-
} =
|
771
|
+
} = activeSelectedRange.highlight;
|
754
772
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
755
773
|
if (currentlySelectedCell !== null && currentlySelectedCell !== void 0 && currentlySelectedCell.hasAttribute('contenteditable')) {
|
756
774
|
(0, _element.removeContentEditableFromElementAndDeselect)(currentlySelectedCell);
|
@@ -758,6 +776,23 @@ function _removeContentEditableFromHighlightedCell() {
|
|
758
776
|
}
|
759
777
|
}
|
760
778
|
}
|
779
|
+
function _setClipboardData(event, rangedData, rangedSourceData) {
|
780
|
+
const textPlain = (0, _SheetClip.stringify)(rangedData);
|
781
|
+
if (event && event.clipboardData) {
|
782
|
+
const textHTML = (0, _parseTable._dataToHTML)(rangedData);
|
783
|
+
const textSourceDataHTML = (0, _parseTable._dataToHTML)(rangedSourceData);
|
784
|
+
event.clipboardData.setData('text/plain', textPlain);
|
785
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
786
|
+
event.clipboardData.setData(SOURCE_DATA_HTML_MIME_TYPE, [META_HEAD, textSourceDataHTML].join(''));
|
787
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
788
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
789
|
+
}
|
790
|
+
}
|
791
|
+
/**
|
792
|
+
* Add copy and cut options to the Context Menu.
|
793
|
+
*
|
794
|
+
* @param {object} options Contains default added options of the Context Menu.
|
795
|
+
*/
|
761
796
|
function _onAfterContextMenuDefaultOptions(options) {
|
762
797
|
options.items.push({
|
763
798
|
name: '---------'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
2
|
import "core-js/modules/es.array.push.js";
|
3
|
+
import "core-js/modules/es.json.stringify.js";
|
3
4
|
import "core-js/modules/esnext.iterator.constructor.js";
|
4
5
|
import "core-js/modules/esnext.iterator.filter.js";
|
5
6
|
import "core-js/modules/esnext.iterator.map.js";
|
@@ -16,7 +17,8 @@ import { BasePlugin } from "../base/index.mjs";
|
|
16
17
|
import { Hooks } from "../../core/hooks/index.mjs";
|
17
18
|
import { stringify, parse } from "../../3rdparty/SheetClip/index.mjs";
|
18
19
|
import { arrayEach } from "../../helpers/array.mjs";
|
19
|
-
import { sanitize } from "../../helpers/string.mjs";
|
20
|
+
import { sanitize, isJSON } from "../../helpers/string.mjs";
|
21
|
+
import { isObject } from "../../helpers/object.mjs";
|
20
22
|
import { removeContentEditableFromElementAndDeselect, runWithSelectedContendEditableElement, makeElementContentEditableAndSelectItsContent, isHTMLElement, isInternalElement } from "../../helpers/dom/element.mjs";
|
21
23
|
import { isSafari } from "../../helpers/browser.mjs";
|
22
24
|
import copyItem from "./contextMenuItem/copy.mjs";
|
@@ -38,6 +40,7 @@ Hooks.getSingleton().register('afterCopy');
|
|
38
40
|
export const PLUGIN_KEY = 'copyPaste';
|
39
41
|
export const PLUGIN_PRIORITY = 80;
|
40
42
|
const SETTING_KEYS = ['fragmentSelection'];
|
43
|
+
const SOURCE_DATA_HTML_MIME_TYPE = 'application/ht-source-data-json-html';
|
41
44
|
const META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
|
42
45
|
|
43
46
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
@@ -373,9 +376,11 @@ export class CopyPaste extends BasePlugin {
|
|
373
376
|
* Converts the contents of multiple ranges (`ranges`) into an array of arrays.
|
374
377
|
*
|
375
378
|
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
379
|
+
* @param {boolean} [useSourceData=false] Whether to use the source data instead of the data. This will stringify objects as JSON.
|
376
380
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
377
381
|
*/
|
378
382
|
getRangedData(ranges) {
|
383
|
+
let useSourceData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
379
384
|
const data = [];
|
380
385
|
const {
|
381
386
|
rows,
|
@@ -390,7 +395,11 @@ export class CopyPaste extends BasePlugin {
|
|
390
395
|
// `row` as the second argument acts here as the `headerLevel` argument
|
391
396
|
rowSet.push(this.hot.getColHeader(column, row));
|
392
397
|
} else {
|
393
|
-
|
398
|
+
let copyableCellData = useSourceData ? this.hot.getCopyableSourceData(row, column) : this.hot.getCopyableData(row, column);
|
399
|
+
if (useSourceData && isObject(copyableCellData)) {
|
400
|
+
copyableCellData = JSON.stringify(copyableCellData);
|
401
|
+
}
|
402
|
+
rowSet.push(copyableCellData);
|
394
403
|
}
|
395
404
|
});
|
396
405
|
data.push(rowSet);
|
@@ -426,7 +435,7 @@ export class CopyPaste extends BasePlugin {
|
|
426
435
|
* Prepares copyable text from the cells selection in the invisible textarea.
|
427
436
|
*/
|
428
437
|
setCopyableText() {
|
429
|
-
const selectionRange = this.hot.
|
438
|
+
const selectionRange = this.hot.getSelectedRangeActive();
|
430
439
|
if (!selectionRange) {
|
431
440
|
return;
|
432
441
|
}
|
@@ -488,13 +497,14 @@ export class CopyPaste extends BasePlugin {
|
|
488
497
|
*
|
489
498
|
* @private
|
490
499
|
* @param {Array} inputArray An array of the data to populate.
|
500
|
+
* @param {Array} sourceInputArray An array of the source data to populate.
|
491
501
|
* @param {Array} [selection] The selection which indicates from what position the data will be populated.
|
492
502
|
* @returns {Array} Range coordinates after populate data.
|
493
503
|
*/
|
494
|
-
populateValues(inputArray) {
|
495
|
-
let selection = arguments.length >
|
504
|
+
populateValues(inputArray, sourceInputArray) {
|
505
|
+
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.hot.getSelectedRangeActive();
|
496
506
|
if (!inputArray.length) {
|
497
|
-
return;
|
507
|
+
return [null, null, null, null];
|
498
508
|
}
|
499
509
|
const populatedRowsLength = inputArray.length;
|
500
510
|
const populatedColumnsLength = inputArray[0].length;
|
@@ -530,18 +540,28 @@ export class CopyPaste extends BasePlugin {
|
|
530
540
|
const newRow = [];
|
531
541
|
const insertedRow = newRows.length % populatedRowsLength;
|
532
542
|
while (newRow.length < populatedColumnsLength || visualColumnForPopulatedData <= endColumnFromSelection) {
|
543
|
+
var _sourceInputArray$ins;
|
533
544
|
const {
|
534
545
|
skipColumnOnPaste,
|
535
546
|
visualCol
|
536
|
-
} = this.hot.getCellMeta(
|
547
|
+
} = this.hot.getCellMeta(visualRow, visualColumnForPopulatedData);
|
548
|
+
const sourceDataAtTarget = this.hot.getSourceDataAtCell(visualRow, visualColumnForPopulatedData);
|
549
|
+
const insertedColumn = newRow.length % populatedColumnsLength;
|
537
550
|
visualColumnForPopulatedData = visualCol + 1;
|
538
551
|
if (skipColumnOnPaste === true) {
|
539
552
|
/* eslint-disable no-continue */
|
540
553
|
continue;
|
541
554
|
}
|
542
555
|
lastVisualColumn = visualCol;
|
543
|
-
const
|
544
|
-
|
556
|
+
const sourceCellValue = sourceInputArray === null || sourceInputArray === void 0 || (_sourceInputArray$ins = sourceInputArray[insertedRow]) === null || _sourceInputArray$ins === void 0 ? void 0 : _sourceInputArray$ins[insertedColumn];
|
557
|
+
let cellValue = inputArray[insertedRow][insertedColumn];
|
558
|
+
if (sourceInputArray && isJSON(sourceCellValue)) {
|
559
|
+
const parsedCellValue = JSON.parse(sourceCellValue);
|
560
|
+
if (isObject(sourceDataAtTarget) || sourceDataAtTarget === null) {
|
561
|
+
cellValue = parsedCellValue;
|
562
|
+
}
|
563
|
+
}
|
564
|
+
newRow.push(cellValue);
|
545
565
|
}
|
546
566
|
newRows.push(newRow);
|
547
567
|
}
|
@@ -570,19 +590,13 @@ export class CopyPaste extends BasePlugin {
|
|
570
590
|
event.preventDefault();
|
571
591
|
this.setCopyableText();
|
572
592
|
_classPrivateFieldSet(_isTriggeredByCopy, this, false);
|
573
|
-
const
|
593
|
+
const rangedData = this.getRangedData(this.copyableRanges);
|
594
|
+
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
574
595
|
const copiedHeadersCount = _assertClassBrand(_CopyPaste_brand, this, _countCopiedHeaders).call(this, this.copyableRanges);
|
575
|
-
const allowCopying = !!this.hot.runHooks('beforeCopy',
|
596
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges, copiedHeadersCount);
|
576
597
|
if (allowCopying) {
|
577
|
-
|
578
|
-
|
579
|
-
const textHTML = _dataToHTML(data, this.hot.rootDocument);
|
580
|
-
event.clipboardData.setData('text/plain', textPlain);
|
581
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
582
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
583
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
584
|
-
}
|
585
|
-
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
598
|
+
_assertClassBrand(_CopyPaste_brand, this, _setClipboardData).call(this, event, rangedData, rangedSourceData);
|
599
|
+
this.hot.runHooks('afterCopy', rangedData, this.copyableRanges, copiedHeadersCount);
|
586
600
|
}
|
587
601
|
_classPrivateFieldSet(_copyMode, this, 'cells-only');
|
588
602
|
}
|
@@ -604,16 +618,10 @@ export class CopyPaste extends BasePlugin {
|
|
604
618
|
this.setCopyableText();
|
605
619
|
_classPrivateFieldSet(_isTriggeredByCut, this, false);
|
606
620
|
const rangedData = this.getRangedData(this.copyableRanges);
|
621
|
+
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
607
622
|
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
608
623
|
if (allowCuttingOut) {
|
609
|
-
|
610
|
-
if (event && event.clipboardData) {
|
611
|
-
const textHTML = _dataToHTML(rangedData, this.hot.rootDocument);
|
612
|
-
event.clipboardData.setData('text/plain', textPlain);
|
613
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
614
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
615
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
616
|
-
}
|
624
|
+
_assertClassBrand(_CopyPaste_brand, this, _setClipboardData).call(this, event, rangedData, rangedSourceData);
|
617
625
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
618
626
|
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
619
627
|
}
|
@@ -634,7 +642,13 @@ export class CopyPaste extends BasePlugin {
|
|
634
642
|
}
|
635
643
|
event.preventDefault();
|
636
644
|
let pastedData;
|
645
|
+
let pastedSourceData;
|
637
646
|
if (event && typeof event.clipboardData !== 'undefined') {
|
647
|
+
const sourceDataHTML = event.clipboardData.getData(SOURCE_DATA_HTML_MIME_TYPE);
|
648
|
+
if (sourceDataHTML) {
|
649
|
+
const parsedSourceConfig = htmlToGridSettings(sourceDataHTML, this.hot.rootDocument);
|
650
|
+
pastedSourceData = parsedSourceConfig.data;
|
651
|
+
}
|
638
652
|
const textHTML = sanitize(event.clipboardData.getData('text/html'), {
|
639
653
|
ADD_TAGS: ['meta'],
|
640
654
|
ADD_ATTR: ['content'],
|
@@ -658,15 +672,19 @@ export class CopyPaste extends BasePlugin {
|
|
658
672
|
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
659
673
|
return;
|
660
674
|
}
|
661
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
662
|
-
|
675
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData, pastedSourceData);
|
676
|
+
if (startRow !== null && startColumn !== null) {
|
677
|
+
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
678
|
+
}
|
663
679
|
this.hot.runHooks('afterPaste', pastedData, this.copyableRanges);
|
664
680
|
}
|
665
681
|
|
666
682
|
/**
|
667
|
-
*
|
683
|
+
* Sets the clipboard data.
|
668
684
|
*
|
669
|
-
* @param {
|
685
|
+
* @param {ClipboardEvent} event The Clipboard event.
|
686
|
+
* @param {Array} rangedData Ranged data to set to the clipboard.
|
687
|
+
* @param {Array} rangedSourceData Ranged source data to set to the clipboard.
|
670
688
|
*/
|
671
689
|
|
672
690
|
/**
|
@@ -679,12 +697,12 @@ export class CopyPaste extends BasePlugin {
|
|
679
697
|
function _ensureClipboardEventsGetTriggered(eventName) {
|
680
698
|
// Without this workaround Safari (tested on Safari@16.5.2) does not trigger the 'copy' event.
|
681
699
|
if (isSafari()) {
|
682
|
-
const
|
683
|
-
if (
|
700
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
701
|
+
if (activeSelectedRange) {
|
684
702
|
const {
|
685
703
|
row: highlightRow,
|
686
704
|
col: highlightColumn
|
687
|
-
} =
|
705
|
+
} = activeSelectedRange.highlight;
|
688
706
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
689
707
|
if (currentlySelectedCell) {
|
690
708
|
runWithSelectedContendEditableElement(currentlySelectedCell, () => {
|
@@ -721,12 +739,12 @@ function _countCopiedHeaders(ranges) {
|
|
721
739
|
}
|
722
740
|
function _addContentEditableToHighlightedCell() {
|
723
741
|
if (this.hot.isListening()) {
|
724
|
-
const
|
725
|
-
if (
|
742
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
743
|
+
if (activeSelectedRange) {
|
726
744
|
const {
|
727
745
|
row: highlightRow,
|
728
746
|
col: highlightColumn
|
729
|
-
} =
|
747
|
+
} = activeSelectedRange.highlight;
|
730
748
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
731
749
|
if (currentlySelectedCell) {
|
732
750
|
makeElementContentEditableAndSelectItsContent(currentlySelectedCell);
|
@@ -740,12 +758,12 @@ function _addContentEditableToHighlightedCell() {
|
|
740
758
|
function _removeContentEditableFromHighlightedCell() {
|
741
759
|
// If the instance is not listening, the workaround is not needed.
|
742
760
|
if (this.hot.isListening()) {
|
743
|
-
const
|
744
|
-
if (
|
761
|
+
const activeSelectedRange = this.hot.getSelectedRangeActive();
|
762
|
+
if (activeSelectedRange) {
|
745
763
|
const {
|
746
764
|
row: highlightRow,
|
747
765
|
col: highlightColumn
|
748
|
-
} =
|
766
|
+
} = activeSelectedRange.highlight;
|
749
767
|
const currentlySelectedCell = this.hot.getCell(highlightRow, highlightColumn, true);
|
750
768
|
if (currentlySelectedCell !== null && currentlySelectedCell !== void 0 && currentlySelectedCell.hasAttribute('contenteditable')) {
|
751
769
|
removeContentEditableFromElementAndDeselect(currentlySelectedCell);
|
@@ -753,6 +771,23 @@ function _removeContentEditableFromHighlightedCell() {
|
|
753
771
|
}
|
754
772
|
}
|
755
773
|
}
|
774
|
+
function _setClipboardData(event, rangedData, rangedSourceData) {
|
775
|
+
const textPlain = stringify(rangedData);
|
776
|
+
if (event && event.clipboardData) {
|
777
|
+
const textHTML = _dataToHTML(rangedData);
|
778
|
+
const textSourceDataHTML = _dataToHTML(rangedSourceData);
|
779
|
+
event.clipboardData.setData('text/plain', textPlain);
|
780
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
781
|
+
event.clipboardData.setData(SOURCE_DATA_HTML_MIME_TYPE, [META_HEAD, textSourceDataHTML].join(''));
|
782
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
783
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
784
|
+
}
|
785
|
+
}
|
786
|
+
/**
|
787
|
+
* Add copy and cut options to the Context Menu.
|
788
|
+
*
|
789
|
+
* @param {object} options Contains default added options of the Context Menu.
|
790
|
+
*/
|
756
791
|
function _onAfterContextMenuDefaultOptions(options) {
|
757
792
|
options.items.push({
|
758
793
|
name: '---------'
|
@@ -721,7 +721,7 @@ function _onAfterContextMenuDefaultOptions(defaultOptions) {
|
|
721
721
|
return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS);
|
722
722
|
},
|
723
723
|
disabled() {
|
724
|
-
const range = this.
|
724
|
+
const range = this.getSelectedRangeActive();
|
725
725
|
if (!range) {
|
726
726
|
return true;
|
727
727
|
}
|
@@ -716,7 +716,7 @@ function _onAfterContextMenuDefaultOptions(defaultOptions) {
|
|
716
716
|
return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS);
|
717
717
|
},
|
718
718
|
disabled() {
|
719
|
-
const range = this.
|
719
|
+
const range = this.getSelectedRangeActive();
|
720
720
|
if (!range) {
|
721
721
|
return true;
|
722
722
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import Core from '../../core';
|
2
|
+
import { BasePlugin } from '../base';
|
3
|
+
|
4
|
+
export interface DialogConfig {
|
5
|
+
content?: string | HTMLElement;
|
6
|
+
customClassName?: string;
|
7
|
+
background?: 'solid' | 'semi-transparent';
|
8
|
+
contentBackground?: boolean;
|
9
|
+
animation?: boolean;
|
10
|
+
closable?: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
export type Settings = boolean | DialogConfig;
|
14
|
+
|
15
|
+
export class Dialog extends BasePlugin {
|
16
|
+
|
17
|
+
constructor(hotInstance: Core);
|
18
|
+
isVisible(): boolean;
|
19
|
+
show(config?: DialogConfig): void;
|
20
|
+
hide(): void;
|
21
|
+
update(config: DialogConfig): void;
|
22
|
+
focus(): void;
|
23
|
+
}
|