@rowsncolumns/spreadsheet-state 28.0.76 → 29.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/anchored-objects.d.ts +122 -6
- package/dist/cjs/api/anchored-objects.d.ts.map +1 -1
- package/dist/cjs/api/anchored-objects.js +464 -43
- package/dist/cjs/api/copy-paste.d.ts +8 -2
- package/dist/cjs/api/copy-paste.d.ts.map +1 -1
- package/dist/cjs/api/copy-paste.js +4 -4
- package/dist/cjs/api/filter.d.ts +15 -1
- package/dist/cjs/api/filter.d.ts.map +1 -1
- package/dist/cjs/api/filter.js +32 -2
- package/dist/cjs/api/formula.d.ts +63 -0
- package/dist/cjs/api/formula.d.ts.map +1 -1
- package/dist/cjs/api/formula.js +278 -8
- package/dist/cjs/api/immer-utils.d.ts +11 -1
- package/dist/cjs/api/immer-utils.d.ts.map +1 -1
- package/dist/cjs/api/immer-utils.js +17 -1
- package/dist/cjs/api/insert-cut-cells.d.ts +35 -0
- package/dist/cjs/api/insert-cut-cells.d.ts.map +1 -0
- package/dist/cjs/api/insert-cut-cells.js +60 -0
- package/dist/cjs/api/merges.d.ts +8 -0
- package/dist/cjs/api/merges.d.ts.map +1 -1
- package/dist/cjs/api/merges.js +11 -0
- package/dist/cjs/api/paint-format.d.ts +22 -1
- package/dist/cjs/api/paint-format.d.ts.map +1 -1
- package/dist/cjs/api/paint-format.js +57 -1
- package/dist/cjs/api/sort.d.ts +23 -1
- package/dist/cjs/api/sort.d.ts.map +1 -1
- package/dist/cjs/api/sort.js +52 -6
- package/dist/cjs/api/structural-guards.d.ts +57 -0
- package/dist/cjs/api/structural-guards.d.ts.map +1 -1
- package/dist/cjs/api/structural-guards.js +93 -1
- package/dist/cjs/api/structural-table-refs.d.ts +58 -3
- package/dist/cjs/api/structural-table-refs.d.ts.map +1 -1
- package/dist/cjs/api/structural-table-refs.js +177 -16
- package/dist/cjs/api/subtotal.d.ts +20 -13
- package/dist/cjs/api/subtotal.d.ts.map +1 -1
- package/dist/cjs/api/subtotal.js +26 -19
- package/dist/cjs/api/table.d.ts +26 -2
- package/dist/cjs/api/table.d.ts.map +1 -1
- package/dist/cjs/api/table.js +93 -60
- package/dist/cjs/api/validation.d.ts.map +1 -1
- package/dist/cjs/api/validation.js +53 -8
- package/dist/cjs/atoms/creating-table.atom.d.ts +22 -0
- package/dist/cjs/atoms/creating-table.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/creating-table.atom.js +4 -0
- package/dist/cjs/atoms/dialog-state.atom.d.ts +8 -0
- package/dist/cjs/atoms/dialog-state.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/dialog-state.atom.js +28 -0
- package/dist/cjs/atoms/editing-slicer.atom.d.ts +9 -0
- package/dist/cjs/atoms/editing-slicer.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/editing-slicer.atom.js +6 -0
- package/dist/cjs/atoms/index.d.ts +4 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +4 -0
- package/dist/cjs/atoms/inserting-slicer.atom.d.ts +8 -0
- package/dist/cjs/atoms/inserting-slicer.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/inserting-slicer.atom.js +5 -0
- package/dist/cjs/atoms/resizing-table.atom.d.ts +8 -0
- package/dist/cjs/atoms/resizing-table.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/resizing-table.atom.js +5 -0
- package/dist/cjs/commands.d.ts +138 -2
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/embed-editor.d.ts +4 -2
- package/dist/cjs/components/editors/embed-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/embed-editor.js +38 -9
- package/dist/cjs/components/editors/slicer-editor.d.ts +15 -0
- package/dist/cjs/components/editors/slicer-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/slicer-editor.js +87 -0
- package/dist/cjs/components/editors/table-editor.d.ts +58 -2
- package/dist/cjs/components/editors/table-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/table-editor.js +261 -20
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.d.ts.map +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants.d.ts +9 -1
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +12 -0
- package/dist/cjs/generated-names.d.ts +13 -3
- package/dist/cjs/generated-names.d.ts.map +1 -1
- package/dist/cjs/generated-names.js +3 -1
- package/dist/cjs/helpers.d.ts +5 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +10 -1
- package/dist/cjs/hooks/use-on-change-batch.d.ts +19 -2
- package/dist/cjs/hooks/use-on-change-batch.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-change-batch.js +43 -35
- package/dist/cjs/hooks/use-on-change-calculated-column.d.ts +10 -1
- package/dist/cjs/hooks/use-on-change-calculated-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-change-calculated-column.js +17 -5
- package/dist/cjs/hooks/use-on-change-table-column.d.ts +6 -1
- package/dist/cjs/hooks/use-on-change-table-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-change-table-column.js +17 -5
- package/dist/cjs/hooks/use-on-change.d.ts +36 -3
- package/dist/cjs/hooks/use-on-change.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-change.js +218 -136
- package/dist/cjs/hooks/use-on-copy.d.ts +1 -1
- package/dist/cjs/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-copy.js +2 -3
- package/dist/cjs/hooks/use-on-create-custom-table-style.d.ts +17 -0
- package/dist/cjs/hooks/use-on-create-custom-table-style.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-create-custom-table-style.js +28 -0
- package/dist/cjs/hooks/use-on-create-named-range.d.ts +4 -2
- package/dist/cjs/hooks/use-on-create-named-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-create-named-range.js +11 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts +2 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.js +3 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts +2 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.js +3 -1
- package/dist/cjs/hooks/use-on-delete-column.d.ts +2 -1
- package/dist/cjs/hooks/use-on-delete-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-column.js +3 -1
- package/dist/cjs/hooks/use-on-delete-row.d.ts +2 -1
- package/dist/cjs/hooks/use-on-delete-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-row.js +3 -1
- package/dist/cjs/hooks/use-on-delete-sheet.d.ts +9 -1
- package/dist/cjs/hooks/use-on-delete-sheet.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-sheet.js +17 -1
- package/dist/cjs/hooks/use-on-delete-table-row.d.ts +4 -1
- package/dist/cjs/hooks/use-on-delete-table-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-table-row.js +19 -1
- package/dist/cjs/hooks/use-on-delete.d.ts +5 -2
- package/dist/cjs/hooks/use-on-delete.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete.js +5 -1
- package/dist/cjs/hooks/use-on-embeds.d.ts +7 -4
- package/dist/cjs/hooks/use-on-embeds.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-embeds.js +26 -24
- package/dist/cjs/hooks/use-on-fill.d.ts +17 -2
- package/dist/cjs/hooks/use-on-fill.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-fill.js +29 -15
- package/dist/cjs/hooks/use-on-filter-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-filter-table.js +209 -103
- package/dist/cjs/hooks/use-on-import-excel.d.ts +2 -1
- package/dist/cjs/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-import-excel.js +22 -19
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts +2 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.js +3 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts +2 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.js +3 -1
- package/dist/cjs/hooks/use-on-insert-column.d.ts +2 -1
- package/dist/cjs/hooks/use-on-insert-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-column.js +3 -1
- package/dist/cjs/hooks/use-on-insert-row.d.ts +2 -1
- package/dist/cjs/hooks/use-on-insert-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-row.js +3 -1
- package/dist/cjs/hooks/use-on-insert-table-row.d.ts +5 -2
- package/dist/cjs/hooks/use-on-insert-table-row.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-table-row.js +19 -1
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts +3 -2
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.js +14 -1
- package/dist/cjs/hooks/use-on-move-columns.d.ts +4 -1
- package/dist/cjs/hooks/use-on-move-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-columns.js +28 -6
- package/dist/cjs/hooks/use-on-move-rows.d.ts +18 -1
- package/dist/cjs/hooks/use-on-move-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-rows.js +44 -6
- package/dist/cjs/hooks/use-on-move-selection.d.ts +9 -2
- package/dist/cjs/hooks/use-on-move-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-selection.js +101 -25
- package/dist/cjs/hooks/use-on-paste.d.ts +33 -2
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-paste.js +1005 -740
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts +5 -2
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-remove-duplicates.js +5 -1
- package/dist/cjs/hooks/use-on-request-create-table.d.ts +13 -0
- package/dist/cjs/hooks/use-on-request-create-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-create-table.js +44 -0
- package/dist/cjs/hooks/use-on-request-insert-slicer.d.ts +7 -0
- package/dist/cjs/hooks/use-on-request-insert-slicer.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-insert-slicer.js +15 -0
- package/dist/cjs/hooks/use-on-request-resize-table.d.ts +7 -0
- package/dist/cjs/hooks/use-on-request-resize-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-resize-table.js +15 -0
- package/dist/cjs/hooks/use-on-resize-table.d.ts +5 -1
- package/dist/cjs/hooks/use-on-resize-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-resize-table.js +110 -33
- package/dist/cjs/hooks/use-on-sort-column.d.ts +28 -3
- package/dist/cjs/hooks/use-on-sort-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-column.js +136 -90
- package/dist/cjs/hooks/use-on-sort-range.d.ts +26 -3
- package/dist/cjs/hooks/use-on-sort-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-range.js +113 -67
- package/dist/cjs/hooks/use-on-sort-table.d.ts +18 -1
- package/dist/cjs/hooks/use-on-sort-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-table.js +128 -98
- package/dist/cjs/hooks/use-on-subtotal.d.ts +10 -3
- package/dist/cjs/hooks/use-on-subtotal.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-subtotal.js +13 -9
- package/dist/cjs/hooks/use-on-table.d.ts +39 -7
- package/dist/cjs/hooks/use-on-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-table.js +257 -49
- package/dist/cjs/hooks/use-on-undo-calculated-column.d.ts +23 -0
- package/dist/cjs/hooks/use-on-undo-calculated-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-undo-calculated-column.js +70 -0
- package/dist/cjs/hooks/use-on-undo-table-auto-expansion.d.ts +28 -0
- package/dist/cjs/hooks/use-on-undo-table-auto-expansion.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-undo-table-auto-expansion.js +96 -0
- package/dist/cjs/hooks/use-on-update-named-range.d.ts +4 -2
- package/dist/cjs/hooks/use-on-update-named-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-update-named-range.js +13 -1
- package/dist/cjs/hooks/use-sheet-properties.d.ts +1 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sheet-properties.js +54 -34
- package/dist/cjs/hooks/use-slicers.d.ts +2 -2
- package/dist/cjs/hooks/use-slicers.d.ts.map +1 -1
- package/dist/cjs/hooks/use-slicers.js +17 -26
- package/dist/cjs/hooks/use-sparkline-groups.d.ts +50 -0
- package/dist/cjs/hooks/use-sparkline-groups.d.ts.map +1 -0
- package/dist/cjs/hooks/use-sparkline-groups.js +192 -0
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +69 -12
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +383 -84
- package/dist/cjs/hooks/use-structured-reference.d.ts.map +1 -1
- package/dist/cjs/hooks/use-structured-reference.js +17 -0
- package/dist/cjs/hooks/use-undo-redo-actions.d.ts +2 -1
- package/dist/cjs/hooks/use-undo-redo-actions.d.ts.map +1 -1
- package/dist/cjs/hooks/use-undo-redo-actions.js +10 -2
- package/dist/cjs/hooks/use-undo-redo.d.ts +12 -0
- package/dist/cjs/hooks/use-undo-redo.d.ts.map +1 -1
- package/dist/cjs/hooks/use-undo-redo.js +169 -10
- package/dist/cjs/hooks/utils/sort-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/utils/sort-rows.js +4 -3
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/interface/apply-fill.d.ts +26 -3
- package/dist/cjs/interface/apply-fill.d.ts.map +1 -1
- package/dist/cjs/interface/apply-fill.js +207 -98
- package/dist/cjs/interface/change-batch.d.ts +1 -1
- package/dist/cjs/interface/change-batch.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch.js +112 -15
- package/dist/cjs/interface/change-calculated-column.d.ts +6 -2
- package/dist/cjs/interface/change-calculated-column.d.ts.map +1 -1
- package/dist/cjs/interface/change-calculated-column.js +87 -17
- package/dist/cjs/interface/change-table-column.d.ts +81 -7
- package/dist/cjs/interface/change-table-column.d.ts.map +1 -1
- package/dist/cjs/interface/change-table-column.js +336 -76
- package/dist/cjs/interface/create-table.d.ts +15 -3
- package/dist/cjs/interface/create-table.d.ts.map +1 -1
- package/dist/cjs/interface/create-table.js +100 -25
- package/dist/cjs/interface/delete-cells-shift-left.d.ts +1 -1
- package/dist/cjs/interface/delete-cells-shift-left.d.ts.map +1 -1
- package/dist/cjs/interface/delete-cells-shift-left.js +10 -1
- package/dist/cjs/interface/delete-cells-shift-up.d.ts +1 -1
- package/dist/cjs/interface/delete-cells-shift-up.d.ts.map +1 -1
- package/dist/cjs/interface/delete-cells-shift-up.js +10 -1
- package/dist/cjs/interface/delete-cells.d.ts +1 -1
- package/dist/cjs/interface/delete-cells.d.ts.map +1 -1
- package/dist/cjs/interface/delete-cells.js +81 -25
- package/dist/cjs/interface/delete-column.d.ts +1 -1
- package/dist/cjs/interface/delete-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-column.js +29 -22
- package/dist/cjs/interface/delete-row.d.ts +1 -1
- package/dist/cjs/interface/delete-row.d.ts.map +1 -1
- package/dist/cjs/interface/delete-row.js +244 -39
- package/dist/cjs/interface/delete-sheet.d.ts +2 -2
- package/dist/cjs/interface/delete-sheet.d.ts.map +1 -1
- package/dist/cjs/interface/delete-sheet.js +118 -1
- package/dist/cjs/interface/delete-table-column.d.ts +1 -1
- package/dist/cjs/interface/delete-table-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-table-column.js +11 -1
- package/dist/cjs/interface/delete-table-row.d.ts +1 -1
- package/dist/cjs/interface/delete-table-row.d.ts.map +1 -1
- package/dist/cjs/interface/delete-table-row.js +361 -275
- package/dist/cjs/interface/duplicate-sheet.d.ts.map +1 -1
- package/dist/cjs/interface/duplicate-sheet.js +83 -31
- package/dist/cjs/interface/embeds.d.ts +10 -1
- package/dist/cjs/interface/embeds.d.ts.map +1 -1
- package/dist/cjs/interface/embeds.js +120 -6
- package/dist/cjs/interface/insert-cells-shift-down.d.ts +1 -1
- package/dist/cjs/interface/insert-cells-shift-down.d.ts.map +1 -1
- package/dist/cjs/interface/insert-cells-shift-down.js +10 -1
- package/dist/cjs/interface/insert-cells-shift-right.d.ts +1 -1
- package/dist/cjs/interface/insert-cells-shift-right.d.ts.map +1 -1
- package/dist/cjs/interface/insert-cells-shift-right.js +10 -1
- package/dist/cjs/interface/insert-column.d.ts +2 -2
- package/dist/cjs/interface/insert-column.d.ts.map +1 -1
- package/dist/cjs/interface/insert-column.js +101 -56
- package/dist/cjs/interface/insert-row.d.ts +1 -1
- package/dist/cjs/interface/insert-row.d.ts.map +1 -1
- package/dist/cjs/interface/insert-row.js +25 -7
- package/dist/cjs/interface/insert-table-row.d.ts +2 -1
- package/dist/cjs/interface/insert-table-row.d.ts.map +1 -1
- package/dist/cjs/interface/insert-table-row.js +70 -19
- package/dist/cjs/interface/remove-duplicates.d.ts +1 -1
- package/dist/cjs/interface/remove-duplicates.d.ts.map +1 -1
- package/dist/cjs/interface/remove-duplicates.js +46 -6
- package/dist/cjs/interface/remove-table.d.ts +1 -1
- package/dist/cjs/interface/remove-table.d.ts.map +1 -1
- package/dist/cjs/interface/remove-table.js +72 -16
- package/dist/cjs/interface/slicers.d.ts +12 -1
- package/dist/cjs/interface/slicers.d.ts.map +1 -1
- package/dist/cjs/interface/slicers.js +47 -2
- package/dist/cjs/interface/spreadsheet-interface.d.ts +1 -1
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/cjs/interface/spreadsheet-interface.js +64 -1
- package/dist/cjs/interface/table-totalrow.d.ts +13 -1
- package/dist/cjs/interface/table-totalrow.d.ts.map +1 -1
- package/dist/cjs/interface/table-totalrow.js +107 -73
- package/dist/cjs/interface/table-utils.d.ts +59 -6
- package/dist/cjs/interface/table-utils.d.ts.map +1 -1
- package/dist/cjs/interface/table-utils.js +211 -15
- package/dist/cjs/interface/update-table.d.ts +16 -1
- package/dist/cjs/interface/update-table.d.ts.map +1 -1
- package/dist/cjs/interface/update-table.js +190 -44
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/test-setup.d.ts.map +1 -1
- package/dist/cjs/test-setup.js +6 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/validation-schema/table.schema.d.ts +11 -0
- package/dist/cjs/validation-schema/table.schema.d.ts.map +1 -1
- package/dist/cjs/validation-schema/table.schema.js +20 -3
- package/dist/esm/api/anchored-objects.d.ts +122 -6
- package/dist/esm/api/anchored-objects.d.ts.map +1 -1
- package/dist/esm/api/anchored-objects.js +375 -15
- package/dist/esm/api/copy-paste.d.ts +8 -2
- package/dist/esm/api/copy-paste.d.ts.map +1 -1
- package/dist/esm/api/copy-paste.js +4 -4
- package/dist/esm/api/filter.d.ts +15 -1
- package/dist/esm/api/filter.d.ts.map +1 -1
- package/dist/esm/api/filter.js +28 -0
- package/dist/esm/api/formula.d.ts +63 -0
- package/dist/esm/api/formula.d.ts.map +1 -1
- package/dist/esm/api/formula.js +235 -8
- package/dist/esm/api/immer-utils.d.ts +11 -1
- package/dist/esm/api/immer-utils.d.ts.map +1 -1
- package/dist/esm/api/immer-utils.js +16 -0
- package/dist/esm/api/insert-cut-cells.d.ts +35 -0
- package/dist/esm/api/insert-cut-cells.d.ts.map +1 -0
- package/dist/esm/api/insert-cut-cells.js +67 -0
- package/dist/esm/api/merges.d.ts +8 -0
- package/dist/esm/api/merges.d.ts.map +1 -1
- package/dist/esm/api/merges.js +9 -0
- package/dist/esm/api/paint-format.d.ts +22 -1
- package/dist/esm/api/paint-format.d.ts.map +1 -1
- package/dist/esm/api/paint-format.js +44 -1
- package/dist/esm/api/sort.d.ts +23 -1
- package/dist/esm/api/sort.d.ts.map +1 -1
- package/dist/esm/api/sort.js +45 -6
- package/dist/esm/api/structural-guards.d.ts +57 -0
- package/dist/esm/api/structural-guards.d.ts.map +1 -1
- package/dist/esm/api/structural-guards.js +85 -0
- package/dist/esm/api/structural-table-refs.d.ts +58 -3
- package/dist/esm/api/structural-table-refs.d.ts.map +1 -1
- package/dist/esm/api/structural-table-refs.js +126 -6
- package/dist/esm/api/subtotal.d.ts +20 -13
- package/dist/esm/api/subtotal.d.ts.map +1 -1
- package/dist/esm/api/subtotal.js +15 -8
- package/dist/esm/api/table.d.ts +26 -2
- package/dist/esm/api/table.d.ts.map +1 -1
- package/dist/esm/api/table.js +70 -48
- package/dist/esm/api/validation.d.ts.map +1 -1
- package/dist/esm/api/validation.js +53 -8
- package/dist/esm/atoms/creating-table.atom.d.ts +22 -0
- package/dist/esm/atoms/creating-table.atom.d.ts.map +1 -0
- package/dist/esm/atoms/creating-table.atom.js +4 -0
- package/dist/esm/atoms/dialog-state.atom.d.ts +8 -0
- package/dist/esm/atoms/dialog-state.atom.d.ts.map +1 -1
- package/dist/esm/atoms/dialog-state.atom.js +12 -0
- package/dist/esm/atoms/editing-slicer.atom.d.ts +9 -0
- package/dist/esm/atoms/editing-slicer.atom.d.ts.map +1 -0
- package/dist/esm/atoms/editing-slicer.atom.js +6 -0
- package/dist/esm/atoms/index.d.ts +4 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +4 -0
- package/dist/esm/atoms/inserting-slicer.atom.d.ts +8 -0
- package/dist/esm/atoms/inserting-slicer.atom.d.ts.map +1 -0
- package/dist/esm/atoms/inserting-slicer.atom.js +5 -0
- package/dist/esm/atoms/resizing-table.atom.d.ts +8 -0
- package/dist/esm/atoms/resizing-table.atom.d.ts.map +1 -0
- package/dist/esm/atoms/resizing-table.atom.js +5 -0
- package/dist/esm/commands.d.ts +138 -2
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/embed-editor.d.ts +4 -2
- package/dist/esm/components/editors/embed-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/embed-editor.js +40 -6
- package/dist/esm/components/editors/slicer-editor.d.ts +15 -0
- package/dist/esm/components/editors/slicer-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/slicer-editor.js +85 -0
- package/dist/esm/components/editors/table-editor.d.ts +58 -2
- package/dist/esm/components/editors/table-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/table-editor.js +243 -19
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/constants.d.ts +9 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +12 -0
- package/dist/esm/generated-names.d.ts +13 -3
- package/dist/esm/generated-names.d.ts.map +1 -1
- package/dist/esm/generated-names.js +3 -1
- package/dist/esm/helpers.d.ts +5 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +7 -1
- package/dist/esm/hooks/use-on-change-batch.d.ts +19 -2
- package/dist/esm/hooks/use-on-change-batch.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-change-batch.js +19 -3
- package/dist/esm/hooks/use-on-change-calculated-column.d.ts +10 -1
- package/dist/esm/hooks/use-on-change-calculated-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-change-calculated-column.js +17 -5
- package/dist/esm/hooks/use-on-change-table-column.d.ts +6 -1
- package/dist/esm/hooks/use-on-change-table-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-change-table-column.js +17 -5
- package/dist/esm/hooks/use-on-change.d.ts +36 -3
- package/dist/esm/hooks/use-on-change.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-change.js +214 -124
- package/dist/esm/hooks/use-on-copy.d.ts +1 -1
- package/dist/esm/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-copy.js +2 -3
- package/dist/esm/hooks/use-on-create-custom-table-style.d.ts +17 -0
- package/dist/esm/hooks/use-on-create-custom-table-style.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-create-custom-table-style.js +26 -0
- package/dist/esm/hooks/use-on-create-named-range.d.ts +4 -2
- package/dist/esm/hooks/use-on-create-named-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-create-named-range.js +11 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts +2 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-left.js +3 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts +2 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-cells-shift-up.js +3 -1
- package/dist/esm/hooks/use-on-delete-column.d.ts +2 -1
- package/dist/esm/hooks/use-on-delete-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-column.js +3 -1
- package/dist/esm/hooks/use-on-delete-row.d.ts +2 -1
- package/dist/esm/hooks/use-on-delete-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-row.js +3 -1
- package/dist/esm/hooks/use-on-delete-sheet.d.ts +9 -1
- package/dist/esm/hooks/use-on-delete-sheet.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-sheet.js +17 -1
- package/dist/esm/hooks/use-on-delete-table-row.d.ts +4 -1
- package/dist/esm/hooks/use-on-delete-table-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-table-row.js +19 -1
- package/dist/esm/hooks/use-on-delete.d.ts +5 -2
- package/dist/esm/hooks/use-on-delete.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete.js +5 -1
- package/dist/esm/hooks/use-on-embeds.d.ts +7 -4
- package/dist/esm/hooks/use-on-embeds.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-embeds.js +23 -6
- package/dist/esm/hooks/use-on-fill.d.ts +17 -2
- package/dist/esm/hooks/use-on-fill.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-fill.js +27 -1
- package/dist/esm/hooks/use-on-filter-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-filter-table.js +97 -26
- package/dist/esm/hooks/use-on-import-excel.d.ts +2 -1
- package/dist/esm/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-import-excel.js +4 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts +2 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-down.js +3 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts +2 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-cells-shift-right.js +3 -1
- package/dist/esm/hooks/use-on-insert-column.d.ts +2 -1
- package/dist/esm/hooks/use-on-insert-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-column.js +3 -1
- package/dist/esm/hooks/use-on-insert-row.d.ts +2 -1
- package/dist/esm/hooks/use-on-insert-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-row.js +3 -1
- package/dist/esm/hooks/use-on-insert-table-row.d.ts +5 -2
- package/dist/esm/hooks/use-on-insert-table-row.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-table-row.js +19 -1
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts +3 -2
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-merge-unmerge-cells.js +12 -1
- package/dist/esm/hooks/use-on-move-columns.d.ts +4 -1
- package/dist/esm/hooks/use-on-move-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-columns.js +28 -6
- package/dist/esm/hooks/use-on-move-rows.d.ts +18 -1
- package/dist/esm/hooks/use-on-move-rows.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-rows.js +44 -6
- package/dist/esm/hooks/use-on-move-selection.d.ts +9 -2
- package/dist/esm/hooks/use-on-move-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-selection.js +57 -1
- package/dist/esm/hooks/use-on-paste.d.ts +33 -2
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-paste.js +825 -643
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts +5 -2
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-remove-duplicates.js +5 -1
- package/dist/esm/hooks/use-on-request-create-table.d.ts +13 -0
- package/dist/esm/hooks/use-on-request-create-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-create-table.js +43 -0
- package/dist/esm/hooks/use-on-request-insert-slicer.d.ts +7 -0
- package/dist/esm/hooks/use-on-request-insert-slicer.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-insert-slicer.js +15 -0
- package/dist/esm/hooks/use-on-request-resize-table.d.ts +7 -0
- package/dist/esm/hooks/use-on-request-resize-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-resize-table.js +15 -0
- package/dist/esm/hooks/use-on-resize-table.d.ts +5 -1
- package/dist/esm/hooks/use-on-resize-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-resize-table.js +107 -27
- package/dist/esm/hooks/use-on-sort-column.d.ts +28 -3
- package/dist/esm/hooks/use-on-sort-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-column.js +105 -68
- package/dist/esm/hooks/use-on-sort-range.d.ts +26 -3
- package/dist/esm/hooks/use-on-sort-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-range.js +100 -64
- package/dist/esm/hooks/use-on-sort-table.d.ts +18 -1
- package/dist/esm/hooks/use-on-sort-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-table.js +107 -86
- package/dist/esm/hooks/use-on-subtotal.d.ts +10 -3
- package/dist/esm/hooks/use-on-subtotal.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-subtotal.js +7 -5
- package/dist/esm/hooks/use-on-table.d.ts +39 -7
- package/dist/esm/hooks/use-on-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-table.js +234 -26
- package/dist/esm/hooks/use-on-undo-calculated-column.d.ts +23 -0
- package/dist/esm/hooks/use-on-undo-calculated-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-undo-calculated-column.js +62 -0
- package/dist/esm/hooks/use-on-undo-table-auto-expansion.d.ts +28 -0
- package/dist/esm/hooks/use-on-undo-table-auto-expansion.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-undo-table-auto-expansion.js +75 -0
- package/dist/esm/hooks/use-on-update-named-range.d.ts +4 -2
- package/dist/esm/hooks/use-on-update-named-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-update-named-range.js +13 -1
- package/dist/esm/hooks/use-sheet-properties.d.ts +1 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/esm/hooks/use-sheet-properties.js +38 -19
- package/dist/esm/hooks/use-slicers.d.ts +2 -2
- package/dist/esm/hooks/use-slicers.d.ts.map +1 -1
- package/dist/esm/hooks/use-slicers.js +16 -8
- package/dist/esm/hooks/use-sparkline-groups.d.ts +50 -0
- package/dist/esm/hooks/use-sparkline-groups.d.ts.map +1 -0
- package/dist/esm/hooks/use-sparkline-groups.js +146 -0
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +69 -12
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +321 -14
- package/dist/esm/hooks/use-structured-reference.d.ts.map +1 -1
- package/dist/esm/hooks/use-structured-reference.js +17 -0
- package/dist/esm/hooks/use-undo-redo-actions.d.ts +2 -1
- package/dist/esm/hooks/use-undo-redo-actions.d.ts.map +1 -1
- package/dist/esm/hooks/use-undo-redo-actions.js +8 -2
- package/dist/esm/hooks/use-undo-redo.d.ts +12 -0
- package/dist/esm/hooks/use-undo-redo.d.ts.map +1 -1
- package/dist/esm/hooks/use-undo-redo.js +158 -7
- package/dist/esm/hooks/utils/sort-rows.d.ts.map +1 -1
- package/dist/esm/hooks/utils/sort-rows.js +4 -3
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -0
- package/dist/esm/interface/apply-fill.d.ts +26 -3
- package/dist/esm/interface/apply-fill.d.ts.map +1 -1
- package/dist/esm/interface/apply-fill.js +188 -88
- package/dist/esm/interface/change-batch.d.ts +1 -1
- package/dist/esm/interface/change-batch.d.ts.map +1 -1
- package/dist/esm/interface/change-batch.js +89 -8
- package/dist/esm/interface/change-calculated-column.d.ts +6 -2
- package/dist/esm/interface/change-calculated-column.d.ts.map +1 -1
- package/dist/esm/interface/change-calculated-column.js +81 -16
- package/dist/esm/interface/change-table-column.d.ts +81 -7
- package/dist/esm/interface/change-table-column.d.ts.map +1 -1
- package/dist/esm/interface/change-table-column.js +295 -67
- package/dist/esm/interface/create-table.d.ts +15 -3
- package/dist/esm/interface/create-table.d.ts.map +1 -1
- package/dist/esm/interface/create-table.js +103 -27
- package/dist/esm/interface/delete-cells-shift-left.d.ts +1 -1
- package/dist/esm/interface/delete-cells-shift-left.d.ts.map +1 -1
- package/dist/esm/interface/delete-cells-shift-left.js +10 -1
- package/dist/esm/interface/delete-cells-shift-up.d.ts +1 -1
- package/dist/esm/interface/delete-cells-shift-up.d.ts.map +1 -1
- package/dist/esm/interface/delete-cells-shift-up.js +10 -1
- package/dist/esm/interface/delete-cells.d.ts +1 -1
- package/dist/esm/interface/delete-cells.d.ts.map +1 -1
- package/dist/esm/interface/delete-cells.js +47 -14
- package/dist/esm/interface/delete-column.d.ts +1 -1
- package/dist/esm/interface/delete-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-column.js +26 -30
- package/dist/esm/interface/delete-row.d.ts +1 -1
- package/dist/esm/interface/delete-row.d.ts.map +1 -1
- package/dist/esm/interface/delete-row.js +191 -44
- package/dist/esm/interface/delete-sheet.d.ts +2 -2
- package/dist/esm/interface/delete-sheet.d.ts.map +1 -1
- package/dist/esm/interface/delete-sheet.js +113 -1
- package/dist/esm/interface/delete-table-column.d.ts +1 -1
- package/dist/esm/interface/delete-table-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-table-column.js +11 -1
- package/dist/esm/interface/delete-table-row.d.ts +1 -1
- package/dist/esm/interface/delete-table-row.d.ts.map +1 -1
- package/dist/esm/interface/delete-table-row.js +312 -232
- package/dist/esm/interface/duplicate-sheet.d.ts.map +1 -1
- package/dist/esm/interface/duplicate-sheet.js +73 -26
- package/dist/esm/interface/embeds.d.ts +10 -1
- package/dist/esm/interface/embeds.d.ts.map +1 -1
- package/dist/esm/interface/embeds.js +84 -5
- package/dist/esm/interface/insert-cells-shift-down.d.ts +1 -1
- package/dist/esm/interface/insert-cells-shift-down.d.ts.map +1 -1
- package/dist/esm/interface/insert-cells-shift-down.js +10 -1
- package/dist/esm/interface/insert-cells-shift-right.d.ts +1 -1
- package/dist/esm/interface/insert-cells-shift-right.d.ts.map +1 -1
- package/dist/esm/interface/insert-cells-shift-right.js +10 -1
- package/dist/esm/interface/insert-column.d.ts +2 -2
- package/dist/esm/interface/insert-column.d.ts.map +1 -1
- package/dist/esm/interface/insert-column.js +70 -33
- package/dist/esm/interface/insert-row.d.ts +1 -1
- package/dist/esm/interface/insert-row.d.ts.map +1 -1
- package/dist/esm/interface/insert-row.js +22 -6
- package/dist/esm/interface/insert-table-row.d.ts +2 -1
- package/dist/esm/interface/insert-table-row.d.ts.map +1 -1
- package/dist/esm/interface/insert-table-row.js +67 -12
- package/dist/esm/interface/remove-duplicates.d.ts +1 -1
- package/dist/esm/interface/remove-duplicates.d.ts.map +1 -1
- package/dist/esm/interface/remove-duplicates.js +41 -6
- package/dist/esm/interface/remove-table.d.ts +1 -1
- package/dist/esm/interface/remove-table.d.ts.map +1 -1
- package/dist/esm/interface/remove-table.js +58 -10
- package/dist/esm/interface/slicers.d.ts +12 -1
- package/dist/esm/interface/slicers.d.ts.map +1 -1
- package/dist/esm/interface/slicers.js +44 -2
- package/dist/esm/interface/spreadsheet-interface.d.ts +1 -1
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/esm/interface/spreadsheet-interface.js +73 -1
- package/dist/esm/interface/table-totalrow.d.ts +13 -1
- package/dist/esm/interface/table-totalrow.d.ts.map +1 -1
- package/dist/esm/interface/table-totalrow.js +98 -68
- package/dist/esm/interface/table-utils.d.ts +59 -6
- package/dist/esm/interface/table-utils.d.ts.map +1 -1
- package/dist/esm/interface/table-utils.js +155 -14
- package/dist/esm/interface/update-table.d.ts +16 -1
- package/dist/esm/interface/update-table.d.ts.map +1 -1
- package/dist/esm/interface/update-table.js +203 -42
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/test-setup.d.ts.map +1 -1
- package/dist/esm/test-setup.js +6 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/validation-schema/table.schema.d.ts +11 -0
- package/dist/esm/validation-schema/table.schema.d.ts.map +1 -1
- package/dist/esm/validation-schema/table.schema.js +15 -2
- package/package.json +25 -17
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator, __read, __rest, __spreadArray, __values } from "tslib";
|
|
2
2
|
import { isStaticNode } from "@rowsncolumns/dag";
|
|
3
|
-
import { areaIntersects, isAreasEqual } from "@rowsncolumns/grid";
|
|
3
|
+
import { areaInsideArea, areaIntersects, isAreasEqual } from "@rowsncolumns/grid";
|
|
4
4
|
import { selectionFromActiveCell } from "@rowsncolumns/grid";
|
|
5
5
|
import { DEFAULT_COLUMN_COUNT, DEFAULT_ROW_COUNT, findActiveTableWithinCell, loadWebFont, MAX_COLUMN_COUNT, MAX_ROW_COUNT, useFocusEmbedOrChart, useGetFinalRowHeight, useRedrawGrid, } from "@rowsncolumns/spreadsheet";
|
|
6
6
|
import { isSelectionACell, useGetEffectiveValuesFromRange, } from "@rowsncolumns/spreadsheet";
|
|
7
7
|
import { error, getCellFormattedValue, getCellUserEnteredFormat, getCellUserEnteredValue, getExtendedValueBool, getExtendedValueFormula, getExtendedValueNumber, getExtendedValueString, isNil, iterateCellsInRange, uuidString, } from "@rowsncolumns/utils";
|
|
8
8
|
import { produceWithPatches } from "immer";
|
|
9
9
|
import { useCallback } from "react";
|
|
10
|
+
import { moveChartsOnRangeMove } from "../api/anchored-objects";
|
|
10
11
|
import { processSideEffectDependentCells } from "../api/dependency";
|
|
11
12
|
import { createSheetCellIdentifier } from "../api/formula";
|
|
12
13
|
import { createSheetDraft } from "../api/immer-utils";
|
|
14
|
+
import { findPartiallyCoveredMerge, MERGED_CELL_MOVE_ERROR } from "../api/merges";
|
|
15
|
+
import { moveRange } from "../api/selection";
|
|
16
|
+
import { useShowError } from "../atoms/error-state.atom";
|
|
13
17
|
import { applyPasteOperation, isBlankClipboardCell, resolvePasteSpecialOptions, } from "../api/paste-special";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
18
|
+
import { getMoveRangeRefusal } from "../api/structural-guards";
|
|
19
|
+
import { renameHeaderCellsInFormulas } from "../api/structural-table-refs";
|
|
20
|
+
import { findAdjacentTable } from "../api/table";
|
|
21
|
+
import { getNextTableTitle } from "../helpers";
|
|
16
22
|
import { collectDataValidationTarget, extendDataValidationRanges, } from "../interface/data-validation-utils";
|
|
23
|
+
import { planHeaderCellRenames } from "../interface/change-table-column";
|
|
17
24
|
import { SheetCell } from "../sheet-cell";
|
|
18
25
|
import { extractFontFamily, generateDataFromClipboard, pickFormatting, pickFormula, pickValue, transpose, } from "./../api/copy-paste";
|
|
19
26
|
import { useCalculationQueue } from "./use-calculation-queue";
|
|
@@ -35,8 +42,9 @@ export var buildDestinationRowAssignments = function (sheetId, startRowIndex, en
|
|
|
35
42
|
return assignments;
|
|
36
43
|
};
|
|
37
44
|
export var useOnPaste = function (_a) {
|
|
38
|
-
var rowCount = _a.rowCount, columnCount = _a.columnCount, locale = _a.locale, sheetData = _a.sheetData, currentTables = _a.tables, _b = _a.maxRowCount, maxRowCount = _b === void 0 ? MAX_ROW_COUNT : _b, _c = _a.maxColumnCount, maxColumnCount = _c === void 0 ? MAX_COLUMN_COUNT : _c, isHiddenByFilterRow = _a.isHiddenByFilterRow, onRequestFonts = _a.onRequestFonts, idCreationStrategy = _a.idCreationStrategy, createHistory = _a.createHistory, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, enqueueGraphOperation = _a.enqueueGraphOperation, onChangeSheetData = _a.onChangeSheetData, onChangeSheets = _a.onChangeSheets, onChangeTables = _a.onChangeTables, onChangeEmbeds = _a.onChangeEmbeds, onChangeSelections = _a.onChangeSelections, onChangeActiveCell = _a.onChangeActiveCell, getDependents = _a.getDependents, getActiveCell = _a.getActiveCell, getUserEnteredValue = _a.getUserEnteredValue, onChangeDataValidations = _a.onChangeDataValidations, _d = _a.preserveFormatting, preserveFormatting = _d === void 0 ? true : _d, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getDataValidationById = _a.getDataValidationById, getSheetName = _a.getSheetName, onError = _a.onError, citations = _a.citations, onChangeCitations = _a.onChangeCitations, sanitizeHtml = _a.sanitizeHtml, onCommand = _a.onCommand, generatedNames = _a.generatedNames;
|
|
45
|
+
var rowCount = _a.rowCount, columnCount = _a.columnCount, locale = _a.locale, sheetData = _a.sheetData, currentTables = _a.tables, _b = _a.maxRowCount, maxRowCount = _b === void 0 ? MAX_ROW_COUNT : _b, _c = _a.maxColumnCount, maxColumnCount = _c === void 0 ? MAX_COLUMN_COUNT : _c, isHiddenByFilterRow = _a.isHiddenByFilterRow, onRequestFonts = _a.onRequestFonts, idCreationStrategy = _a.idCreationStrategy, createHistory = _a.createHistory, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, enqueueGraphOperation = _a.enqueueGraphOperation, onChangeSheetData = _a.onChangeSheetData, onChangeSheets = _a.onChangeSheets, onChangeTables = _a.onChangeTables, onChangeEmbeds = _a.onChangeEmbeds, onChangeSelections = _a.onChangeSelections, onChangeActiveCell = _a.onChangeActiveCell, getDependents = _a.getDependents, getActiveCell = _a.getActiveCell, getUserEnteredValue = _a.getUserEnteredValue, onChangeDataValidations = _a.onChangeDataValidations, onChangeNamedRanges = _a.onChangeNamedRanges, onChangeCharts = _a.onChangeCharts, getSheetMerges = _a.getSheetMerges, _d = _a.preserveFormatting, preserveFormatting = _d === void 0 ? true : _d, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getDataValidationById = _a.getDataValidationById, getSheetName = _a.getSheetName, onError = _a.onError, citations = _a.citations, onChangeCitations = _a.onChangeCitations, sanitizeHtml = _a.sanitizeHtml, onCommand = _a.onCommand, generatedNames = _a.generatedNames, _e = _a.batchHistory, batchHistory = _e === void 0 ? function (action) { return action(); } : _e, _f = _a.autoExpandTables, autoExpandTables = _f === void 0 ? true : _f, _g = _a.autoCalculatedColumns, autoCalculatedColumns = _g === void 0 ? true : _g;
|
|
39
46
|
var canEditCellRange = useCanEditCellRange();
|
|
47
|
+
var showError = useShowError();
|
|
40
48
|
// Allowed values
|
|
41
49
|
var getEffectiveValuesFromRange = useGetEffectiveValuesFromRange();
|
|
42
50
|
var focusEmbedOrChart = useFocusEmbedOrChart();
|
|
@@ -49,6 +57,7 @@ export var useOnPaste = function (_a) {
|
|
|
49
57
|
onChangeTables: onChangeTables,
|
|
50
58
|
getSheetName: getSheetName,
|
|
51
59
|
onCommand: onCommand,
|
|
60
|
+
autoCalculatedColumns: autoCalculatedColumns,
|
|
52
61
|
});
|
|
53
62
|
var onChangeTableColumn = useOnChangeTableColumn({
|
|
54
63
|
locale: locale,
|
|
@@ -57,19 +66,20 @@ export var useOnPaste = function (_a) {
|
|
|
57
66
|
enqueueGraphOperation: enqueueGraphOperation,
|
|
58
67
|
onChangeSheetData: onChangeSheetData,
|
|
59
68
|
onChangeTables: onChangeTables,
|
|
69
|
+
onChangeCharts: onChangeCharts,
|
|
60
70
|
getDependents: getDependents,
|
|
61
71
|
onCommand: onCommand,
|
|
62
72
|
generatedNames: generatedNames,
|
|
73
|
+
tables: currentTables,
|
|
63
74
|
});
|
|
64
75
|
var redrawGrid = useRedrawGrid();
|
|
65
76
|
var getFinalRowHeight = useGetFinalRowHeight();
|
|
66
|
-
var
|
|
77
|
+
var _h = useCalculationQueue({ enqueueCalculation: enqueueCalculation }), enqueue = _h.enqueue, processQueue = _h.processQueue;
|
|
67
78
|
return useCallback(function (e, sourceSheetId, destinationSheetId, copiedSelections, activeCell, selections, finalSelections, isCutOperation) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
-
var pasteSpecial, pasteMode, pasteOperation, pasteEvent, forcePlainText, activeSheetName, from, merges, embeds, tables, columnWidths, rowHeights, selectedRowValues, rowIndex, start, end, pasteResults,
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
switch (_0.label) {
|
|
79
|
+
var pasteSpecial, pasteMode, pasteOperation, pasteEvent, forcePlainText, activeSheetName, from, merges, embeds, tables, columnWidths, rowHeights, selectedRowValues, rowIndex, start, end, pasteResults, fontFamilies, fontFamiliesWithWeights, err_1;
|
|
80
|
+
var _a, _b, _c, _d, _e;
|
|
81
|
+
return __generator(this, function (_f) {
|
|
82
|
+
switch (_f.label) {
|
|
73
83
|
case 0:
|
|
74
84
|
pasteSpecial = resolvePasteSpecialOptions(e === null || e === void 0 ? void 0 : e.clipboardData);
|
|
75
85
|
pasteMode = pasteSpecial.paste;
|
|
@@ -85,19 +95,19 @@ export var useOnPaste = function (_a) {
|
|
|
85
95
|
for (rowIndex = from.range.startRowIndex; rowIndex <= from.range.endRowIndex; rowIndex++) {
|
|
86
96
|
start = from.range.startColumnIndex;
|
|
87
97
|
end = start + from.range.endColumnIndex - from.range.startColumnIndex + 1;
|
|
88
|
-
selectedRowValues.push((
|
|
98
|
+
selectedRowValues.push((_d = (_c = (_b = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[sourceSheetId]) === null || _a === void 0 ? void 0 : _a[rowIndex]) === null || _b === void 0 ? void 0 : _b.values) === null || _c === void 0 ? void 0 : _c.slice(start, end)) !== null && _d !== void 0 ? _d : []);
|
|
89
99
|
}
|
|
90
100
|
return [3 /*break*/, 3];
|
|
91
|
-
case 1: return [4 /*yield*/, generateDataFromClipboard(e, activeCell, destinationSheetId, activeSheetName, preserveFormatting, locale, idCreationStrategy, forcePlainText, sanitizeHtml
|
|
101
|
+
case 1: return [4 /*yield*/, generateDataFromClipboard(e, activeCell, destinationSheetId, activeSheetName, preserveFormatting, locale, idCreationStrategy, forcePlainText, sanitizeHtml)];
|
|
92
102
|
case 2:
|
|
93
|
-
pasteResults =
|
|
94
|
-
selectedRowValues = (
|
|
103
|
+
pasteResults = _f.sent();
|
|
104
|
+
selectedRowValues = (_e = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.results) !== null && _e !== void 0 ? _e : [];
|
|
95
105
|
merges = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.merges;
|
|
96
106
|
embeds = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.embeds;
|
|
97
107
|
tables = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.tables;
|
|
98
108
|
rowHeights = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.rowHeights;
|
|
99
109
|
columnWidths = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.columnWidths;
|
|
100
|
-
|
|
110
|
+
_f.label = 3;
|
|
101
111
|
case 3:
|
|
102
112
|
// No data,
|
|
103
113
|
if (isNil(selectedRowValues)) {
|
|
@@ -115,857 +125,1105 @@ export var useOnPaste = function (_a) {
|
|
|
115
125
|
else if (pasteMode === "values") {
|
|
116
126
|
selectedRowValues = pickValue(selectedRowValues, destinationSheetId, locale);
|
|
117
127
|
}
|
|
118
|
-
saveHistory = createHistory();
|
|
119
|
-
dataValidationTargets = new Map();
|
|
120
128
|
fontFamilies = extractFontFamily(selectedRowValues);
|
|
121
129
|
if (!(fontFamilies.length && preserveFormatting)) return [3 /*break*/, 10];
|
|
122
130
|
fontFamiliesWithWeights = fontFamilies
|
|
123
131
|
.map(function (family) { return ["".concat(family, ":400"), "".concat(family, ":700")]; })
|
|
124
132
|
.flat();
|
|
125
|
-
|
|
133
|
+
_f.label = 4;
|
|
126
134
|
case 4:
|
|
127
|
-
|
|
135
|
+
_f.trys.push([4, 9, , 10]);
|
|
128
136
|
if (!onRequestFonts) return [3 /*break*/, 6];
|
|
129
137
|
return [4 /*yield*/, onRequestFonts(fontFamilies)];
|
|
130
138
|
case 5:
|
|
131
|
-
|
|
139
|
+
_f.sent();
|
|
132
140
|
return [3 /*break*/, 8];
|
|
133
141
|
case 6: return [4 /*yield*/, loadWebFont(fontFamiliesWithWeights)];
|
|
134
142
|
case 7:
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
_f.sent();
|
|
144
|
+
_f.label = 8;
|
|
137
145
|
case 8:
|
|
138
146
|
redrawGrid === null || redrawGrid === void 0 ? void 0 : redrawGrid();
|
|
139
147
|
return [3 /*break*/, 10];
|
|
140
148
|
case 9:
|
|
141
|
-
err_1 =
|
|
149
|
+
err_1 = _f.sent();
|
|
142
150
|
error("Error loading webfonts", fontFamilies, err_1);
|
|
143
151
|
return [3 /*break*/, 10];
|
|
144
152
|
case 10:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
?
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
153
|
+
// From here on the paste is synchronous: its writes and the table growth / calculated-column
|
|
154
|
+
// fill they trigger open ONE undo entry.
|
|
155
|
+
batchHistory(function () {
|
|
156
|
+
var e_1, _a;
|
|
157
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
158
|
+
var saveHistory = createHistory();
|
|
159
|
+
var dataValidationTargets = new Map();
|
|
160
|
+
var _r = __read([
|
|
161
|
+
(_b = selectedRowValues === null || selectedRowValues === void 0 ? void 0 : selectedRowValues.length) !== null && _b !== void 0 ? _b : 0,
|
|
162
|
+
// For cut operations, use range dimensions since data may be sparse
|
|
163
|
+
isCutOperation && from
|
|
164
|
+
? from.range.endColumnIndex - from.range.startColumnIndex + 1
|
|
165
|
+
: (_d = (_c = selectedRowValues[0]) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
166
|
+
], 2), rowSpan = _r[0], colSpan = _r[1];
|
|
167
|
+
var to = (_e = selections === null || selections === void 0 ? void 0 : selections[(selections === null || selections === void 0 ? void 0 : selections.length) - 1]) !== null && _e !== void 0 ? _e : selectionFromActiveCell(activeCell)[0];
|
|
168
|
+
var rowDelta = from && to ? to.range.startRowIndex - from.range.startRowIndex : -1;
|
|
169
|
+
var columnDelta = from && to
|
|
170
|
+
? to.range.startColumnIndex - from.range.startColumnIndex
|
|
171
|
+
: -1;
|
|
172
|
+
// A cut is a move: a table the cut block covers whole travels with it (Excel; the rnc
|
|
173
|
+
// engine's `move-range` does the same), so it is neither the table the paste writes into
|
|
174
|
+
// nor one the paste grows.
|
|
175
|
+
var movedTables = isCutOperation && from && !isNil(sourceSheetId)
|
|
176
|
+
? (_f = currentTables === null || currentTables === void 0 ? void 0 : currentTables.filter(function (table) {
|
|
177
|
+
return table.sheetId === sourceSheetId &&
|
|
178
|
+
areaInsideArea(table.range, from.range);
|
|
179
|
+
})) !== null && _f !== void 0 ? _f : []
|
|
180
|
+
: [];
|
|
181
|
+
var stayingTables = movedTables.length
|
|
182
|
+
? currentTables === null || currentTables === void 0 ? void 0 : currentTables.filter(function (table) { return !movedTables.includes(table); })
|
|
183
|
+
: currentTables;
|
|
184
|
+
// When user enters a value in the last row of a
|
|
185
|
+
// table and if the entire row is empty
|
|
186
|
+
var _s = __read(autoExpandTables
|
|
187
|
+
? findAdjacentTable(destinationSheetId, activeCell, stayingTables, getUserEnteredValue)
|
|
188
|
+
: [undefined, false, false], 3), adjacentTable = _s[0], isRowExpansion = _s[1], isColumnExpansion = _s[2];
|
|
189
|
+
var currentTable = isColumnExpansion && adjacentTable
|
|
190
|
+
? adjacentTable
|
|
191
|
+
: findActiveTableWithinCell(destinationSheetId, activeCell, stayingTables);
|
|
192
|
+
// Next selections
|
|
193
|
+
var nextSelections = (finalSelections === null || finalSelections === void 0 ? void 0 : finalSelections.length) ? finalSelections : [to];
|
|
194
|
+
// Update range based on length of data
|
|
195
|
+
to.range.endRowIndex = Math.min(maxRowCount, Math.max(to.range.endRowIndex, to.range.startRowIndex + rowSpan - 1));
|
|
196
|
+
to.range.endColumnIndex = Math.min(maxColumnCount, Math.max(to.range.endColumnIndex, to.range.startColumnIndex + colSpan - 1));
|
|
197
|
+
// Check for protected range
|
|
198
|
+
if (!canEditCellRange(destinationSheetId, to.range)) {
|
|
199
|
+
console.debug("Protected range, You cannot paste on to protected cells.");
|
|
200
|
+
return;
|
|
179
201
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
// A cut is a move: Excel refuses it when the destination (or the source) covers a merged
|
|
203
|
+
// cell only partially — writing into a non-anchor cell of a merge would tear it.
|
|
204
|
+
if (isCutOperation &&
|
|
205
|
+
from &&
|
|
206
|
+
!isNil(sourceSheetId) &&
|
|
207
|
+
(findPartiallyCoveredMerge(to.range, getSheetMerges === null || getSheetMerges === void 0 ? void 0 : getSheetMerges(destinationSheetId)) ||
|
|
208
|
+
findPartiallyCoveredMerge(from.range, getSheetMerges === null || getSheetMerges === void 0 ? void 0 : getSheetMerges(sourceSheetId)))) {
|
|
209
|
+
showError({ message: MERGED_CELL_MOVE_ERROR });
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
// …and Excel never moves PART of a table, nor lands a block on another table's cells — the
|
|
213
|
+
// drag-move refusals (T-46) apply to a cut + paste too, across sheets (T-79).
|
|
214
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
215
|
+
var tableRefusal = getMoveRangeRefusal({
|
|
216
|
+
sheetId: sourceSheetId,
|
|
217
|
+
from: from.range,
|
|
218
|
+
to: to.range,
|
|
219
|
+
toSheetId: destinationSheetId,
|
|
220
|
+
tables: currentTables,
|
|
221
|
+
});
|
|
222
|
+
if (tableRefusal) {
|
|
223
|
+
showError({ title: tableRefusal.title, message: tableRefusal.message });
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Check if pasting a table would overlap with an existing table
|
|
228
|
+
if (tables === null || tables === void 0 ? void 0 : tables.length) {
|
|
229
|
+
var existingTable = currentTables === null || currentTables === void 0 ? void 0 : currentTables.find(function (table) {
|
|
230
|
+
return table.sheetId === destinationSheetId &&
|
|
231
|
+
areaIntersects(to.range, table.range);
|
|
232
|
+
});
|
|
233
|
+
if (existingTable) {
|
|
234
|
+
onError === null || onError === void 0 ? void 0 : onError("Cannot paste a table over another table. The paste range overlaps with an existing table.");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
var destinationRows = buildDestinationRowAssignments(destinationSheetId, to.range.startRowIndex, to.range.endRowIndex, rowSpan, isHiddenByFilterRow);
|
|
239
|
+
if (!destinationRows.length) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// Paste writes through `onChangeSheetData` directly, so the
|
|
243
|
+
// calculator's per-cell invalidation never fires for the
|
|
244
|
+
// destination cells. Invalidate the destination rect — and the
|
|
245
|
+
// source on cut, since those cells are cleared too.
|
|
198
246
|
enqueueStructureChange === null || enqueueStructureChange === void 0 ? void 0 : enqueueStructureChange({
|
|
199
247
|
kind: "invalidate-range",
|
|
200
|
-
sheetId:
|
|
201
|
-
startRowIndex:
|
|
202
|
-
endRowIndex:
|
|
203
|
-
startColumnIndex:
|
|
204
|
-
endColumnIndex:
|
|
248
|
+
sheetId: destinationSheetId,
|
|
249
|
+
startRowIndex: to.range.startRowIndex,
|
|
250
|
+
endRowIndex: to.range.endRowIndex,
|
|
251
|
+
startColumnIndex: to.range.startColumnIndex,
|
|
252
|
+
endColumnIndex: to.range.endColumnIndex,
|
|
205
253
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
254
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
255
|
+
enqueueStructureChange === null || enqueueStructureChange === void 0 ? void 0 : enqueueStructureChange({
|
|
256
|
+
kind: "invalidate-range",
|
|
257
|
+
sheetId: sourceSheetId,
|
|
258
|
+
startRowIndex: from.range.startRowIndex,
|
|
259
|
+
endRowIndex: from.range.endRowIndex,
|
|
260
|
+
startColumnIndex: from.range.startColumnIndex,
|
|
261
|
+
endColumnIndex: from.range.endColumnIndex,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
var visibleRowIndexes = destinationRows.map(function (_a) {
|
|
265
|
+
var rowIndex = _a.rowIndex;
|
|
266
|
+
return rowIndex;
|
|
267
|
+
});
|
|
268
|
+
// Adds new column to table and cell to sheet
|
|
269
|
+
var sharedStrings = sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.getSharedStrings();
|
|
270
|
+
var pastedCellText = function (cellValue) {
|
|
271
|
+
var formattedValue = getCellFormattedValue(cellValue);
|
|
272
|
+
var sharedStringValue = (cellValue === null || cellValue === void 0 ? void 0 : cellValue.ss) == null || !sharedStrings
|
|
273
|
+
? undefined
|
|
274
|
+
: sharedStrings.get(String(cellValue.ss));
|
|
275
|
+
return typeof formattedValue === "string"
|
|
276
|
+
? formattedValue
|
|
277
|
+
: typeof sharedStringValue === "string"
|
|
278
|
+
? sharedStringValue
|
|
279
|
+
: undefined;
|
|
280
|
+
};
|
|
281
|
+
var activeCellValue = pastedCellText((_g = selectedRowValues === null || selectedRowValues === void 0 ? void 0 : selectedRowValues[0]) === null || _g === void 0 ? void 0 : _g[0]);
|
|
282
|
+
// A block pasted right of the table names every new column from its own header cell.
|
|
283
|
+
var pastedHeaderValues = isColumnExpansion &&
|
|
284
|
+
adjacentTable &&
|
|
285
|
+
activeCell.rowIndex === adjacentTable.range.startRowIndex
|
|
286
|
+
? (_h = selectedRowValues === null || selectedRowValues === void 0 ? void 0 : selectedRowValues[0]) === null || _h === void 0 ? void 0 : _h.map(pastedCellText)
|
|
222
287
|
: undefined;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
288
|
+
// Header cells of existing tables the paste lands on take the typed-header
|
|
289
|
+
// rule (text, de-duplicated, structured references following); a cut moves
|
|
290
|
+
// cells as they are and a formats-only paste writes no values.
|
|
291
|
+
var headerRenames = !isCutOperation && pasteMode !== "formats"
|
|
292
|
+
? planHeaderCellRenames({
|
|
293
|
+
sheetId: destinationSheetId,
|
|
294
|
+
tables: stayingTables,
|
|
295
|
+
generatedNames: generatedNames,
|
|
296
|
+
cells: destinationRows.flatMap(function (_a) {
|
|
297
|
+
var rowIndex = _a.rowIndex, dataRowIndex = _a.dataRowIndex;
|
|
298
|
+
return Array.from({
|
|
299
|
+
length: to.range.endColumnIndex - to.range.startColumnIndex + 1,
|
|
300
|
+
}, function (_, cursor) {
|
|
301
|
+
var _a;
|
|
302
|
+
return ({
|
|
303
|
+
rowIndex: rowIndex,
|
|
304
|
+
columnIndex: to.range.startColumnIndex + cursor,
|
|
305
|
+
value: pastedCellText((_a = selectedRowValues[dataRowIndex]) === null || _a === void 0 ? void 0 : _a[colSpan > 0 ? cursor % colSpan : 0]),
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}),
|
|
309
|
+
})
|
|
310
|
+
: [];
|
|
311
|
+
var headerRenameAt = new Map(headerRenames.map(function (rename) { return [
|
|
312
|
+
"".concat(rename.rowIndex, ":").concat(rename.columnIndex),
|
|
313
|
+
rename,
|
|
314
|
+
]; }));
|
|
315
|
+
// We need to track this for history. Precedent cells
|
|
316
|
+
var recalcCells = new Map();
|
|
317
|
+
// Expand table if user is pasting
|
|
318
|
+
// table data
|
|
319
|
+
// Same undo history
|
|
320
|
+
if (!isNil(currentTable) && !isRowExpansion) {
|
|
321
|
+
// The overflow grows the table row by row and stops at the first row another table
|
|
322
|
+
// occupies (Excel; same rule as the adjacent-row growth in `changeTableColumn`). Cells
|
|
323
|
+
// pasted past that row stay plain cells.
|
|
324
|
+
var newEndRowIndex_1 = currentTable.range.endRowIndex;
|
|
325
|
+
var lastOverflowRowIndex = activeCell.rowIndex + rowSpan - 1 + (currentTable.totalRow ? 1 : 0);
|
|
326
|
+
var _loop_1 = function (rowIndex) {
|
|
327
|
+
var line = __assign(__assign({}, currentTable.range), { startRowIndex: rowIndex, endRowIndex: rowIndex });
|
|
328
|
+
if (stayingTables === null || stayingTables === void 0 ? void 0 : stayingTables.some(function (other) {
|
|
329
|
+
return other.id !== currentTable.id &&
|
|
330
|
+
other.sheetId === destinationSheetId &&
|
|
331
|
+
areaIntersects(other.range, line);
|
|
332
|
+
})) {
|
|
333
|
+
return "break";
|
|
251
334
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
335
|
+
newEndRowIndex_1 = rowIndex;
|
|
336
|
+
};
|
|
337
|
+
for (var rowIndex = currentTable.range.endRowIndex + 1; rowIndex <= lastOverflowRowIndex; rowIndex++) {
|
|
338
|
+
var state_1 = _loop_1(rowIndex);
|
|
339
|
+
if (state_1 === "break")
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
// Update table range
|
|
343
|
+
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTableData) {
|
|
344
|
+
var _a = __read(produceWithPatches(prevTableData, function (draft) {
|
|
345
|
+
var table = draft.find(function (table) { return (currentTable === null || currentTable === void 0 ? void 0 : currentTable.id) === table.id; });
|
|
346
|
+
if (table) {
|
|
347
|
+
table.range.endRowIndex = newEndRowIndex_1;
|
|
348
|
+
}
|
|
349
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
350
|
+
saveHistory({
|
|
351
|
+
tables: { patches: patches, inversePatches: inversePatches },
|
|
352
|
+
});
|
|
353
|
+
return nextState;
|
|
255
354
|
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
355
|
+
}
|
|
356
|
+
if (headerRenames.length) {
|
|
357
|
+
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTables) {
|
|
358
|
+
var _a = __read(produceWithPatches(prevTables, function (draft) {
|
|
359
|
+
var e_2, _a;
|
|
360
|
+
var _b;
|
|
361
|
+
var _loop_3 = function (table, dimensionIndex, newName) {
|
|
362
|
+
var current = draft.find(function (candidate) { return candidate.id === table.id; });
|
|
363
|
+
if (!current)
|
|
364
|
+
return "continue";
|
|
365
|
+
(_b = current.columns) !== null && _b !== void 0 ? _b : (current.columns = []);
|
|
366
|
+
if (current.columns[dimensionIndex]) {
|
|
367
|
+
current.columns[dimensionIndex].name = newName;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
current.columns[dimensionIndex] = { name: newName };
|
|
371
|
+
}
|
|
372
|
+
};
|
|
272
373
|
try {
|
|
273
|
-
for (var
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
processSideEffectDependentCells({
|
|
277
|
-
draft: draft,
|
|
278
|
-
rowIndex: rowIndex,
|
|
279
|
-
columnIndex: columnIndex,
|
|
280
|
-
sheetId: sheetId,
|
|
281
|
-
destinationSheetId: destinationSheetId,
|
|
282
|
-
columnDelta: columnDelta,
|
|
283
|
-
enqueueGraphOperation: enqueueGraphOperation,
|
|
284
|
-
enqueueCalculation: enqueue,
|
|
285
|
-
getDependents: getDependents,
|
|
286
|
-
recalcCells: recalcCells,
|
|
287
|
-
rowDelta: rowDelta,
|
|
288
|
-
sourceRange: from.range,
|
|
289
|
-
movedKeys: movedKeys,
|
|
290
|
-
locale: locale,
|
|
291
|
-
rowCount: rowCount,
|
|
292
|
-
columnCount: columnCount,
|
|
293
|
-
});
|
|
374
|
+
for (var headerRenames_1 = __values(headerRenames), headerRenames_1_1 = headerRenames_1.next(); !headerRenames_1_1.done; headerRenames_1_1 = headerRenames_1.next()) {
|
|
375
|
+
var _c = headerRenames_1_1.value, table = _c.table, dimensionIndex = _c.dimensionIndex, newName = _c.newName;
|
|
376
|
+
_loop_3(table, dimensionIndex, newName);
|
|
294
377
|
}
|
|
295
378
|
}
|
|
296
379
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
297
380
|
finally {
|
|
298
381
|
try {
|
|
299
|
-
if (
|
|
382
|
+
if (headerRenames_1_1 && !headerRenames_1_1.done && (_a = headerRenames_1.return)) _a.call(headerRenames_1);
|
|
300
383
|
}
|
|
301
384
|
finally { if (e_2) throw e_2.error; }
|
|
302
385
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
386
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
387
|
+
saveHistory({ tables: { patches: patches, inversePatches: inversePatches } });
|
|
388
|
+
return nextState;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
// Update sheetdata
|
|
392
|
+
// Capture the produced state so we can stream the exact written cells to an engine
|
|
393
|
+
// consumer afterwards (branch-agnostic across cut / pure-paste / paste-special).
|
|
394
|
+
var pastedSheetData;
|
|
395
|
+
if (selectedRowValues.length) {
|
|
396
|
+
onChangeSheetData === null || onChangeSheetData === void 0 ? void 0 : onChangeSheetData(function (prevSheetData) {
|
|
397
|
+
var _a = __read(produceWithPatches(prevSheetData, function (draft) {
|
|
398
|
+
var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e;
|
|
399
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
400
|
+
// For cut operation
|
|
401
|
+
var movedKeys = new Set();
|
|
402
|
+
/**
|
|
403
|
+
* If user is deleting source cells,
|
|
404
|
+
* let update its dependents and mark it as dirty
|
|
405
|
+
*/
|
|
406
|
+
if (isCutOperation && from && to && !isNil(sourceSheetId)) {
|
|
407
|
+
var sheetId = sourceSheetId;
|
|
408
|
+
try {
|
|
409
|
+
for (var _1 = __values(iterateCellsInRange(from.range)), _2 = _1.next(); !_2.done; _2 = _1.next()) {
|
|
410
|
+
var _3 = __read(_2.value, 2), rowIndex = _3[0], columnIndex = _3[1];
|
|
411
|
+
// Process dependents
|
|
412
|
+
processSideEffectDependentCells({
|
|
413
|
+
draft: draft,
|
|
414
|
+
rowIndex: rowIndex,
|
|
415
|
+
columnIndex: columnIndex,
|
|
416
|
+
sheetId: sheetId,
|
|
417
|
+
destinationSheetId: destinationSheetId,
|
|
418
|
+
columnDelta: columnDelta,
|
|
419
|
+
enqueueGraphOperation: enqueueGraphOperation,
|
|
420
|
+
enqueueCalculation: enqueue,
|
|
421
|
+
getDependents: getDependents,
|
|
422
|
+
recalcCells: recalcCells,
|
|
423
|
+
rowDelta: rowDelta,
|
|
424
|
+
sourceRange: from.range,
|
|
425
|
+
movedKeys: movedKeys,
|
|
426
|
+
locale: locale,
|
|
427
|
+
rowCount: rowCount,
|
|
428
|
+
columnCount: columnCount,
|
|
429
|
+
});
|
|
319
430
|
}
|
|
320
|
-
draft[sheetId][rowIndex].values[columnIndex] =
|
|
321
|
-
{};
|
|
322
431
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
position: position,
|
|
347
|
-
force: true,
|
|
348
|
-
});
|
|
349
|
-
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
350
|
-
}
|
|
432
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
433
|
+
finally {
|
|
434
|
+
try {
|
|
435
|
+
if (_2 && !_2.done && (_a = _1.return)) _a.call(_1);
|
|
436
|
+
}
|
|
437
|
+
finally { if (e_3) throw e_3.error; }
|
|
438
|
+
}
|
|
439
|
+
// Snapshot source after dependent/formula rewrites, before
|
|
440
|
+
// clearing it. The pre-cut clipboard snapshot still contains
|
|
441
|
+
// stale formulas, so writing that snapshot would discard the
|
|
442
|
+
// reference updates performed above.
|
|
443
|
+
var movedRowValues = [];
|
|
444
|
+
var sourceStartColumn = from.range.startColumnIndex;
|
|
445
|
+
var sourceEndColumn = from.range.endColumnIndex + 1;
|
|
446
|
+
for (var rowIndex = from.range.startRowIndex; rowIndex <= from.range.endRowIndex; rowIndex++) {
|
|
447
|
+
movedRowValues.push(((_j = (_h = (_g = (_f = draft[sheetId]) === null || _f === void 0 ? void 0 : _f[rowIndex]) === null || _g === void 0 ? void 0 : _g.values) === null || _h === void 0 ? void 0 : _h.slice(sourceStartColumn, sourceEndColumn)) !== null && _j !== void 0 ? _j : []));
|
|
448
|
+
}
|
|
449
|
+
// Delete source if required
|
|
450
|
+
// Move values
|
|
451
|
+
for (var rowIndex = from.range.startRowIndex; rowIndex <= from.range.endRowIndex; rowIndex++) {
|
|
452
|
+
for (var columnIndex = from.range.startColumnIndex; columnIndex <= from.range.endColumnIndex; columnIndex++) {
|
|
453
|
+
if (!((_l = (_k = draft[sheetId][rowIndex]) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l[columnIndex])) {
|
|
454
|
+
continue;
|
|
351
455
|
}
|
|
352
|
-
|
|
353
|
-
|
|
456
|
+
draft[sheetId][rowIndex].values[columnIndex] =
|
|
457
|
+
{};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
try {
|
|
461
|
+
for (var destinationRows_1 = __values(destinationRows), destinationRows_1_1 = destinationRows_1.next(); !destinationRows_1_1.done; destinationRows_1_1 = destinationRows_1.next()) {
|
|
462
|
+
var _4 = destinationRows_1_1.value, rowIndex = _4.rowIndex, dataRowIndex = _4.dataRowIndex;
|
|
463
|
+
var currentSheet = createSheetDraft(draft, destinationSheetId, rowIndex);
|
|
464
|
+
var columnCursor = 0;
|
|
465
|
+
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
466
|
+
var dataColumnIndex = colSpan > 0 ? columnCursor % colSpan : 0;
|
|
467
|
+
currentSheet[rowIndex].values[columnIndex] =
|
|
468
|
+
(_m = movedRowValues[dataRowIndex]) === null || _m === void 0 ? void 0 : _m[dataColumnIndex];
|
|
354
469
|
try {
|
|
355
|
-
|
|
470
|
+
for (var _5 = (e_5 = void 0, __values(getDependents({
|
|
471
|
+
rowIndex: rowIndex,
|
|
472
|
+
columnIndex: columnIndex,
|
|
473
|
+
sheetId: destinationSheetId,
|
|
474
|
+
}))), _6 = _5.next(); !_6.done; _6 = _5.next()) {
|
|
475
|
+
var dependent = _6.value;
|
|
476
|
+
if (isStaticNode(dependent)) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
var position = dependent.position;
|
|
480
|
+
enqueue({
|
|
481
|
+
type: "add",
|
|
482
|
+
position: position,
|
|
483
|
+
force: true,
|
|
484
|
+
});
|
|
485
|
+
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
486
|
+
}
|
|
356
487
|
}
|
|
357
|
-
|
|
488
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
489
|
+
finally {
|
|
490
|
+
try {
|
|
491
|
+
if (_6 && !_6.done && (_c = _5.return)) _c.call(_5);
|
|
492
|
+
}
|
|
493
|
+
finally { if (e_5) throw e_5.error; }
|
|
494
|
+
}
|
|
495
|
+
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
358
496
|
}
|
|
359
|
-
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
360
497
|
}
|
|
361
498
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
499
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
500
|
+
finally {
|
|
501
|
+
try {
|
|
502
|
+
if (destinationRows_1_1 && !destinationRows_1_1.done && (_b = destinationRows_1.return)) _b.call(destinationRows_1);
|
|
503
|
+
}
|
|
504
|
+
finally { if (e_4) throw e_4.error; }
|
|
367
505
|
}
|
|
368
|
-
finally { if (e_3) throw e_3.error; }
|
|
369
506
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (pasteSpecial.skipBlanks &&
|
|
402
|
-
isBlankClipboardCell(cellValue_2)) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
// Operation: combine the pasted cell with the cell it
|
|
406
|
-
// lands on. The clipboard is anchored at the FIRST tile,
|
|
407
|
-
// so a source formula is relocated to the tile it lands
|
|
408
|
-
// on first (the same `moveFormula` shift the plain paste
|
|
409
|
-
// applies below); the composed `=(dest)op(source)` is
|
|
410
|
-
// then anchored at the destination and must not be moved
|
|
411
|
-
// again (that would shift the destination fragment too).
|
|
412
|
-
if (pasteOperation) {
|
|
413
|
-
var sourceFormula = getExtendedValueFormula(getCellUserEnteredValue(cellValue_2));
|
|
414
|
-
if (!isNil(sourceFormula) &&
|
|
415
|
-
dataRowIndex === 0 &&
|
|
416
|
-
dataColumnIndex === 0 &&
|
|
417
|
-
(rowIndex !== sourceCell.rowIndex ||
|
|
418
|
-
columnIndex !== sourceCell.columnIndex)) {
|
|
419
|
-
var tileCell = new SheetCell();
|
|
420
|
-
tileCell.setLocale(locale);
|
|
421
|
-
tileCell.assign(destinationSheetId, sourceCell, cellValue_2);
|
|
422
|
-
tileCell.moveFormula(sourceCell, { rowIndex: rowIndex, columnIndex: columnIndex }, activeSheetName, { preserveAbsolutes: true });
|
|
423
|
-
cellValue_2 = __assign(__assign({}, cellValue_2), { ue: __assign(__assign({}, cellValue_2 === null || cellValue_2 === void 0 ? void 0 : cellValue_2.ue), { fv: tileCell.formula }) });
|
|
507
|
+
// TBD: Move totalrow for tables
|
|
508
|
+
// We are doing pure paste operation
|
|
509
|
+
if (!isCutOperation) {
|
|
510
|
+
renameHeaderCellsInFormulas({
|
|
511
|
+
draft: draft,
|
|
512
|
+
headerRenames: headerRenames,
|
|
513
|
+
enqueueCalculation: enqueue,
|
|
514
|
+
enqueueGraphOperation: enqueueGraphOperation,
|
|
515
|
+
recalcCells: recalcCells,
|
|
516
|
+
locale: locale,
|
|
517
|
+
cellXfsRegistry: cellXfsRegistry,
|
|
518
|
+
sharedStringRegistry: sharedStringRegistry,
|
|
519
|
+
});
|
|
520
|
+
var sheetCell = new SheetCell();
|
|
521
|
+
var sourceCell = {
|
|
522
|
+
rowIndex: to.range.startRowIndex,
|
|
523
|
+
columnIndex: to.range.startColumnIndex,
|
|
524
|
+
};
|
|
525
|
+
try {
|
|
526
|
+
for (var destinationRows_2 = __values(destinationRows), destinationRows_2_1 = destinationRows_2.next(); !destinationRows_2_1.done; destinationRows_2_1 = destinationRows_2.next()) {
|
|
527
|
+
var _7 = destinationRows_2_1.value, rowIndex = _7.rowIndex, dataRowIndex = _7.dataRowIndex;
|
|
528
|
+
var currentSheet = createSheetDraft(draft, destinationSheetId, rowIndex);
|
|
529
|
+
var columnCursor = 0;
|
|
530
|
+
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
531
|
+
var dataColumnIndex = colSpan > 0 ? columnCursor % colSpan : 0;
|
|
532
|
+
var cellValue = (_o = selectedRowValues[dataRowIndex]) === null || _o === void 0 ? void 0 : _o[dataColumnIndex];
|
|
533
|
+
// Skip blanks: an empty clipboard cell leaves the
|
|
534
|
+
// destination (value and format) untouched.
|
|
535
|
+
if (pasteSpecial.skipBlanks &&
|
|
536
|
+
isBlankClipboardCell(cellValue)) {
|
|
537
|
+
continue;
|
|
424
538
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
:
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
sheetCell.
|
|
539
|
+
// Operation: combine the pasted cell with the cell it
|
|
540
|
+
// lands on. The clipboard is anchored at the FIRST tile,
|
|
541
|
+
// so a source formula is relocated to the tile it lands
|
|
542
|
+
// on first (the same `moveFormula` shift the plain paste
|
|
543
|
+
// applies below); the composed `=(dest)op(source)` is
|
|
544
|
+
// then anchored at the destination and must not be moved
|
|
545
|
+
// again (that would shift the destination fragment too).
|
|
546
|
+
if (pasteOperation) {
|
|
547
|
+
var sourceFormula = getExtendedValueFormula(getCellUserEnteredValue(cellValue));
|
|
548
|
+
if (!isNil(sourceFormula) &&
|
|
549
|
+
dataRowIndex === 0 &&
|
|
550
|
+
dataColumnIndex === 0 &&
|
|
551
|
+
(rowIndex !== sourceCell.rowIndex ||
|
|
552
|
+
columnIndex !== sourceCell.columnIndex)) {
|
|
553
|
+
var tileCell = new SheetCell();
|
|
554
|
+
tileCell.setLocale(locale);
|
|
555
|
+
tileCell.assign(destinationSheetId, sourceCell, cellValue);
|
|
556
|
+
tileCell.moveFormula(sourceCell, { rowIndex: rowIndex, columnIndex: columnIndex }, activeSheetName, { preserveAbsolutes: true });
|
|
557
|
+
cellValue = __assign(__assign({}, cellValue), { ue: __assign(__assign({}, cellValue === null || cellValue === void 0 ? void 0 : cellValue.ue), { fv: tileCell.formula }) });
|
|
558
|
+
}
|
|
559
|
+
cellValue = applyPasteOperation(cellValue, (_r = (_q = (_p = prevSheetData[destinationSheetId]) === null || _p === void 0 ? void 0 : _p[rowIndex]) === null || _q === void 0 ? void 0 : _q.values) === null || _r === void 0 ? void 0 : _r[columnIndex], pasteOperation, destinationSheetId, locale);
|
|
560
|
+
}
|
|
561
|
+
if (pasteMode === "formats") {
|
|
562
|
+
var existingCellData = (_u = (_t = (_s = prevSheetData[destinationSheetId]) === null || _s === void 0 ? void 0 : _s[rowIndex]) === null || _t === void 0 ? void 0 : _t.values) === null || _u === void 0 ? void 0 : _u[columnIndex];
|
|
563
|
+
cellValue = __assign(__assign({}, existingCellData), cellValue);
|
|
564
|
+
sheetCell.extendCellData(cellValue);
|
|
565
|
+
}
|
|
566
|
+
if (pasteMode === "values" || forcePlainText) {
|
|
567
|
+
var existingCellData = (_x = (_w = (_v = prevSheetData[destinationSheetId]) === null || _v === void 0 ? void 0 : _v[rowIndex]) === null || _w === void 0 ? void 0 : _w.values) === null || _x === void 0 ? void 0 : _x[columnIndex];
|
|
568
|
+
// Remove ss from existingCellData since we're replacing the value
|
|
569
|
+
var _8 = existingCellData !== null && existingCellData !== void 0 ? existingCellData : {}, _ss = _8.ss, existingWithoutSs = __rest(_8, ["ss"]);
|
|
570
|
+
cellValue = __assign(__assign({}, existingWithoutSs), cellValue);
|
|
571
|
+
sheetCell.extendCellData(cellValue);
|
|
572
|
+
}
|
|
573
|
+
if (pasteSpecial.transpose && pasteMode === "all") {
|
|
574
|
+
sheetCell.assign(destinationSheetId, { rowIndex: rowIndex, columnIndex: columnIndex }, (_0 = (_z = (_y = prevSheetData[destinationSheetId]) === null || _y === void 0 ? void 0 : _y[rowIndex]) === null || _z === void 0 ? void 0 : _z.values) === null || _0 === void 0 ? void 0 : _0[columnIndex], {
|
|
575
|
+
locale: locale,
|
|
576
|
+
cellXfsRegistry: cellXfsRegistry,
|
|
577
|
+
getDataValidationById: getDataValidationById,
|
|
578
|
+
sharedStringRegistry: sharedStringRegistry,
|
|
579
|
+
});
|
|
580
|
+
var existingCellData = sheetCell.getUserCellData();
|
|
581
|
+
cellValue = __assign(__assign({}, existingCellData), cellValue);
|
|
582
|
+
sheetCell.extendCellData(cellValue);
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
sheetCell.assign(destinationSheetId, { rowIndex: rowIndex, columnIndex: columnIndex }, typeof cellValue === "object"
|
|
586
|
+
? cellValue
|
|
587
|
+
: undefined, {
|
|
588
|
+
getRangeValues: getEffectiveValuesFromRange,
|
|
589
|
+
locale: locale,
|
|
590
|
+
cellXfsRegistry: cellXfsRegistry,
|
|
591
|
+
getDataValidationById: getDataValidationById,
|
|
592
|
+
sharedStringRegistry: sharedStringRegistry,
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
if (pasteMode === "formats") {
|
|
596
|
+
sheetCell.refreshFormattedValue();
|
|
597
|
+
}
|
|
598
|
+
if (sheetCell.isFormula()) {
|
|
599
|
+
if (dataRowIndex === 0 &&
|
|
600
|
+
dataColumnIndex === 0 &&
|
|
601
|
+
!pasteOperation) {
|
|
602
|
+
sheetCell.moveFormula(sourceCell, {
|
|
603
|
+
rowIndex: rowIndex,
|
|
604
|
+
columnIndex: columnIndex,
|
|
605
|
+
}, activeSheetName, { preserveAbsolutes: true });
|
|
606
|
+
}
|
|
607
|
+
sheetCell.setLoading();
|
|
608
|
+
enqueue({
|
|
609
|
+
type: "add",
|
|
610
|
+
position: {
|
|
611
|
+
rowIndex: rowIndex,
|
|
612
|
+
columnIndex: columnIndex,
|
|
613
|
+
sheetId: destinationSheetId,
|
|
614
|
+
},
|
|
615
|
+
force: true,
|
|
616
|
+
});
|
|
617
|
+
recalcCells.set(createSheetCellIdentifier(destinationSheetId, rowIndex, columnIndex), {
|
|
469
618
|
rowIndex: rowIndex,
|
|
470
619
|
columnIndex: columnIndex,
|
|
471
|
-
|
|
620
|
+
sheetId: destinationSheetId,
|
|
621
|
+
});
|
|
472
622
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
type: "add",
|
|
476
|
-
position: {
|
|
623
|
+
try {
|
|
624
|
+
for (var _9 = (e_7 = void 0, __values(getDependents({
|
|
477
625
|
rowIndex: rowIndex,
|
|
478
626
|
columnIndex: columnIndex,
|
|
479
627
|
sheetId: destinationSheetId,
|
|
480
|
-
},
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
628
|
+
}))), _10 = _9.next(); !_10.done; _10 = _9.next()) {
|
|
629
|
+
var dependent = _10.value;
|
|
630
|
+
if (isStaticNode(dependent)) {
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
var position = dependent.position;
|
|
634
|
+
enqueue({
|
|
635
|
+
type: "add",
|
|
636
|
+
position: position,
|
|
637
|
+
force: true,
|
|
638
|
+
});
|
|
639
|
+
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
643
|
+
finally {
|
|
644
|
+
try {
|
|
645
|
+
if (_10 && !_10.done && (_e = _9.return)) _e.call(_9);
|
|
646
|
+
}
|
|
647
|
+
finally { if (e_7) throw e_7.error; }
|
|
648
|
+
}
|
|
649
|
+
var headerRename = headerRenameAt.get("".concat(rowIndex, ":").concat(columnIndex));
|
|
650
|
+
if (headerRename) {
|
|
651
|
+
// A table header cell holds its column name as text.
|
|
652
|
+
sheetCell.setUserEnteredValue(headerRename.newName, undefined, { disableTypeInference: true });
|
|
653
|
+
}
|
|
654
|
+
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.registerCell(sheetCell);
|
|
655
|
+
currentSheet[rowIndex].values[columnIndex] =
|
|
656
|
+
sheetCell.getCellData();
|
|
657
|
+
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
658
|
+
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.registerCellXfs(sheetCell);
|
|
488
659
|
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
663
|
+
finally {
|
|
664
|
+
try {
|
|
665
|
+
if (destinationRows_2_1 && !destinationRows_2_1.done && (_d = destinationRows_2.return)) _d.call(destinationRows_2);
|
|
666
|
+
}
|
|
667
|
+
finally { if (e_6) throw e_6.error; }
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
671
|
+
saveHistory({
|
|
672
|
+
sheetData: { patches: patches, inversePatches: inversePatches },
|
|
673
|
+
recalcCells: { undo: recalcCells, redo: recalcCells },
|
|
674
|
+
activeCell: {
|
|
675
|
+
undo: getActiveCell(),
|
|
676
|
+
redo: getActiveCell(),
|
|
677
|
+
},
|
|
678
|
+
selections: {
|
|
679
|
+
undo: undefined,
|
|
680
|
+
redo: isSelectionACell(nextSelections) ? undefined : [to],
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
extendDataValidationRanges(dataValidationTargets, onChangeDataValidations, saveHistory);
|
|
684
|
+
processQueue();
|
|
685
|
+
pastedSheetData = nextState;
|
|
686
|
+
return nextState;
|
|
687
|
+
});
|
|
688
|
+
// Save registries
|
|
689
|
+
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.getPatches(saveHistory);
|
|
690
|
+
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.getPatches(saveHistory);
|
|
691
|
+
// Update row or column count
|
|
692
|
+
// Change sheets
|
|
693
|
+
onChangeSheets === null || onChangeSheets === void 0 ? void 0 : onChangeSheets(function (prevSheets) {
|
|
694
|
+
var _a = __read(produceWithPatches(prevSheets, function (draft) {
|
|
695
|
+
var e_8, _a, e_9, _b, e_10, _c;
|
|
696
|
+
var _d, _e, _f, _g, _h;
|
|
697
|
+
var sheet = draft.find(function (sheet) { return sheet.sheetId === destinationSheetId; });
|
|
698
|
+
if (sheet) {
|
|
699
|
+
sheet.rowCount = Math.min(maxRowCount, Math.max((_d = sheet.rowCount) !== null && _d !== void 0 ? _d : DEFAULT_ROW_COUNT, to.range.endRowIndex));
|
|
700
|
+
sheet.columnCount = Math.min(maxColumnCount, Math.max((_e = sheet.columnCount) !== null && _e !== void 0 ? _e : DEFAULT_COLUMN_COUNT, to.range.endColumnIndex));
|
|
701
|
+
// Handle merges for cut operations
|
|
702
|
+
var mergesToAdd = merges;
|
|
703
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
704
|
+
var sourceSheet = prevSheets.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
705
|
+
if (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.merges) {
|
|
706
|
+
// Extract merged cells from source range
|
|
707
|
+
var cutMerges = [];
|
|
489
708
|
try {
|
|
490
|
-
for (var
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
709
|
+
for (var _j = __values(sourceSheet.merges), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
710
|
+
var merge = _k.value;
|
|
711
|
+
// Check if merge intersects with the cut range
|
|
712
|
+
if (areaIntersects(merge, from.range)) {
|
|
713
|
+
// Calculate new merge coordinates relative to destination
|
|
714
|
+
cutMerges.push({
|
|
715
|
+
startRowIndex: merge.startRowIndex + rowDelta,
|
|
716
|
+
startColumnIndex: merge.startColumnIndex + columnDelta,
|
|
717
|
+
endRowIndex: merge.endRowIndex + rowDelta,
|
|
718
|
+
endColumnIndex: merge.endColumnIndex + columnDelta,
|
|
719
|
+
});
|
|
498
720
|
}
|
|
499
|
-
var position = dependent.position;
|
|
500
|
-
enqueue({
|
|
501
|
-
type: "add",
|
|
502
|
-
position: position,
|
|
503
|
-
force: true,
|
|
504
|
-
});
|
|
505
|
-
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
506
721
|
}
|
|
507
722
|
}
|
|
508
|
-
catch (
|
|
723
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
509
724
|
finally {
|
|
510
725
|
try {
|
|
511
|
-
if (
|
|
726
|
+
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
512
727
|
}
|
|
513
|
-
finally { if (
|
|
728
|
+
finally { if (e_8) throw e_8.error; }
|
|
729
|
+
}
|
|
730
|
+
if (cutMerges.length > 0) {
|
|
731
|
+
mergesToAdd = cutMerges;
|
|
732
|
+
}
|
|
733
|
+
// Remove merges from source sheet
|
|
734
|
+
var sourceSheetDraft = draft.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
735
|
+
if (sourceSheetDraft === null || sourceSheetDraft === void 0 ? void 0 : sourceSheetDraft.merges) {
|
|
736
|
+
sourceSheetDraft.merges = sourceSheetDraft.merges.filter(function (merge) { return !areaIntersects(merge, from.range); });
|
|
514
737
|
}
|
|
515
|
-
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.registerCell(sheetCell);
|
|
516
|
-
currentSheet[rowIndex].values[columnIndex] =
|
|
517
|
-
sheetCell.getCellData();
|
|
518
|
-
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
519
|
-
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.registerCellXfs(sheetCell);
|
|
520
738
|
}
|
|
521
739
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
sheetData: { patches: patches, inversePatches: inversePatches },
|
|
534
|
-
recalcCells: { undo: recalcCells, redo: recalcCells },
|
|
535
|
-
activeCell: {
|
|
536
|
-
undo: getActiveCell(),
|
|
537
|
-
redo: getActiveCell(),
|
|
538
|
-
},
|
|
539
|
-
selections: {
|
|
540
|
-
undo: undefined,
|
|
541
|
-
redo: isSelectionACell(nextSelections) ? undefined : [to],
|
|
542
|
-
},
|
|
543
|
-
});
|
|
544
|
-
extendDataValidationRanges(dataValidationTargets, onChangeDataValidations, saveHistory);
|
|
545
|
-
processQueue();
|
|
546
|
-
pastedSheetData = nextState;
|
|
547
|
-
return nextState;
|
|
548
|
-
});
|
|
549
|
-
// Save registries
|
|
550
|
-
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.getPatches(saveHistory);
|
|
551
|
-
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.getPatches(saveHistory);
|
|
552
|
-
// Update row or column count
|
|
553
|
-
// Change sheets
|
|
554
|
-
onChangeSheets === null || onChangeSheets === void 0 ? void 0 : onChangeSheets(function (prevSheets) {
|
|
555
|
-
var _a = __read(produceWithPatches(prevSheets, function (draft) {
|
|
556
|
-
var e_7, _a, e_8, _b, e_9, _c;
|
|
557
|
-
var _d, _e, _f, _g, _h;
|
|
558
|
-
var sheet = draft.find(function (sheet) { return sheet.sheetId === destinationSheetId; });
|
|
559
|
-
if (sheet) {
|
|
560
|
-
sheet.rowCount = Math.min(maxRowCount, Math.max((_d = sheet.rowCount) !== null && _d !== void 0 ? _d : DEFAULT_ROW_COUNT, to.range.endRowIndex));
|
|
561
|
-
sheet.columnCount = Math.min(maxColumnCount, Math.max((_e = sheet.columnCount) !== null && _e !== void 0 ? _e : DEFAULT_COLUMN_COUNT, to.range.endColumnIndex));
|
|
562
|
-
// Handle merges for cut operations
|
|
563
|
-
var mergesToAdd = merges;
|
|
564
|
-
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
565
|
-
var sourceSheet = prevSheets.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
566
|
-
if (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.merges) {
|
|
567
|
-
// Extract merged cells from source range
|
|
568
|
-
var cutMerges = [];
|
|
740
|
+
// Update merges
|
|
741
|
+
if (mergesToAdd) {
|
|
742
|
+
sheet.merges = (_f = sheet.merges) !== null && _f !== void 0 ? _f : [];
|
|
743
|
+
var _loop_4 = function (merge) {
|
|
744
|
+
var exists = sheet.merges.find(function (range) {
|
|
745
|
+
return isAreasEqual(range, merge);
|
|
746
|
+
});
|
|
747
|
+
if (!exists) {
|
|
748
|
+
sheet.merges.push(merge);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
569
751
|
try {
|
|
570
|
-
for (var
|
|
571
|
-
var merge =
|
|
572
|
-
|
|
573
|
-
if (areaIntersects(merge, from.range)) {
|
|
574
|
-
// Calculate new merge coordinates relative to destination
|
|
575
|
-
cutMerges.push({
|
|
576
|
-
startRowIndex: merge.startRowIndex + rowDelta,
|
|
577
|
-
startColumnIndex: merge.startColumnIndex + columnDelta,
|
|
578
|
-
endRowIndex: merge.endRowIndex + rowDelta,
|
|
579
|
-
endColumnIndex: merge.endColumnIndex + columnDelta,
|
|
580
|
-
});
|
|
581
|
-
}
|
|
752
|
+
for (var mergesToAdd_1 = __values(mergesToAdd), mergesToAdd_1_1 = mergesToAdd_1.next(); !mergesToAdd_1_1.done; mergesToAdd_1_1 = mergesToAdd_1.next()) {
|
|
753
|
+
var merge = mergesToAdd_1_1.value;
|
|
754
|
+
_loop_4(merge);
|
|
582
755
|
}
|
|
583
756
|
}
|
|
584
|
-
catch (
|
|
757
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
585
758
|
finally {
|
|
586
759
|
try {
|
|
587
|
-
if (
|
|
760
|
+
if (mergesToAdd_1_1 && !mergesToAdd_1_1.done && (_b = mergesToAdd_1.return)) _b.call(mergesToAdd_1);
|
|
588
761
|
}
|
|
589
|
-
finally { if (
|
|
590
|
-
}
|
|
591
|
-
if (cutMerges.length > 0) {
|
|
592
|
-
mergesToAdd = cutMerges;
|
|
593
|
-
}
|
|
594
|
-
// Remove merges from source sheet
|
|
595
|
-
var sourceSheetDraft = draft.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
596
|
-
if (sourceSheetDraft === null || sourceSheetDraft === void 0 ? void 0 : sourceSheetDraft.merges) {
|
|
597
|
-
sourceSheetDraft.merges = sourceSheetDraft.merges.filter(function (merge) { return !areaIntersects(merge, from.range); });
|
|
762
|
+
finally { if (e_9) throw e_9.error; }
|
|
598
763
|
}
|
|
599
764
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var exists = sheet.merges.find(function (range) {
|
|
606
|
-
return isAreasEqual(range, merge);
|
|
607
|
-
});
|
|
608
|
-
if (!exists) {
|
|
609
|
-
sheet.merges.push(merge);
|
|
765
|
+
// Row heights
|
|
766
|
+
var clipboardSizedRows = new Set();
|
|
767
|
+
if (rowHeights) {
|
|
768
|
+
if (!sheet.rowMetadata) {
|
|
769
|
+
sheet.rowMetadata = [];
|
|
610
770
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
771
|
+
for (var index = 0; index < rowHeights.length; index++) {
|
|
772
|
+
var curHeight = rowHeights[index];
|
|
773
|
+
if (isNil(curHeight) || curHeight === 0) {
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
var rowIndex = visibleRowIndexes[index];
|
|
777
|
+
if (isNil(rowIndex)) {
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
if (!sheet.rowMetadata[rowIndex]) {
|
|
781
|
+
sheet.rowMetadata[rowIndex] = {};
|
|
782
|
+
}
|
|
783
|
+
sheet.rowMetadata[rowIndex].size = curHeight;
|
|
784
|
+
clipboardSizedRows.add(rowIndex);
|
|
616
785
|
}
|
|
617
786
|
}
|
|
618
|
-
|
|
619
|
-
|
|
787
|
+
// Auto-resize rows whose pasted content needs more room
|
|
788
|
+
// (multi-line text or wrap). Mirrors use-on-change's
|
|
789
|
+
// adjustRowHeight, but batched into this immer pass so the
|
|
790
|
+
// whole paste collapses to one undo entry. Skip conditions
|
|
791
|
+
// make the common single-line-text paste do zero work.
|
|
792
|
+
// Skipped for paste-special variants since the destination
|
|
793
|
+
// cell ends up as a merge of existing + pasted data, not
|
|
794
|
+
// the raw pasted value we can read from selectedRowValues.
|
|
795
|
+
var skipAutoResize = pasteSpecial.isSpecial;
|
|
796
|
+
if (!skipAutoResize &&
|
|
797
|
+
getFinalRowHeight &&
|
|
798
|
+
selectedRowValues.length &&
|
|
799
|
+
colSpan > 0) {
|
|
620
800
|
try {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (rowHeights) {
|
|
629
|
-
if (!sheet.rowMetadata) {
|
|
630
|
-
sheet.rowMetadata = [];
|
|
631
|
-
}
|
|
632
|
-
for (var index = 0; index < rowHeights.length; index++) {
|
|
633
|
-
var curHeight = rowHeights[index];
|
|
634
|
-
if (isNil(curHeight) || curHeight === 0) {
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
var rowIndex = visibleRowIndexes[index];
|
|
638
|
-
if (isNil(rowIndex)) {
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
if (!sheet.rowMetadata[rowIndex]) {
|
|
642
|
-
sheet.rowMetadata[rowIndex] = {};
|
|
643
|
-
}
|
|
644
|
-
sheet.rowMetadata[rowIndex].size = curHeight;
|
|
645
|
-
clipboardSizedRows.add(rowIndex);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
// Auto-resize rows whose pasted content needs more room
|
|
649
|
-
// (multi-line text or wrap). Mirrors use-on-change's
|
|
650
|
-
// adjustRowHeight, but batched into this immer pass so the
|
|
651
|
-
// whole paste collapses to one undo entry. Skip conditions
|
|
652
|
-
// make the common single-line-text paste do zero work.
|
|
653
|
-
// Skipped for paste-special variants since the destination
|
|
654
|
-
// cell ends up as a merge of existing + pasted data, not
|
|
655
|
-
// the raw pasted value we can read from selectedRowValues.
|
|
656
|
-
var skipAutoResize = pasteSpecial.isSpecial;
|
|
657
|
-
if (!skipAutoResize &&
|
|
658
|
-
getFinalRowHeight &&
|
|
659
|
-
selectedRowValues.length &&
|
|
660
|
-
colSpan > 0) {
|
|
661
|
-
try {
|
|
662
|
-
for (var destinationRows_3 = __values(destinationRows), destinationRows_3_1 = destinationRows_3.next(); !destinationRows_3_1.done; destinationRows_3_1 = destinationRows_3.next()) {
|
|
663
|
-
var _l = destinationRows_3_1.value, rowIndex = _l.rowIndex, dataRowIndex = _l.dataRowIndex;
|
|
664
|
-
// Clipboard-provided row heights win.
|
|
665
|
-
if (clipboardSizedRows.has(rowIndex))
|
|
666
|
-
continue;
|
|
667
|
-
var rowData = selectedRowValues[dataRowIndex];
|
|
668
|
-
if (!rowData)
|
|
669
|
-
continue;
|
|
670
|
-
// Find the cell most likely to drive row height —
|
|
671
|
-
// most lines first, then any wrap. If no cell in
|
|
672
|
-
// the row needs more than one line and no cell is
|
|
673
|
-
// wrapped, the row's existing height already fits.
|
|
674
|
-
var bestLines = 1;
|
|
675
|
-
var bestColumnIndex = void 0;
|
|
676
|
-
var bestCell = void 0;
|
|
677
|
-
var bestHasWrap = false;
|
|
678
|
-
var columnCursor = 0;
|
|
679
|
-
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
680
|
-
var dataColumnIndex = columnCursor % colSpan;
|
|
681
|
-
var cellValue_3 = rowData[dataColumnIndex];
|
|
682
|
-
if (!cellValue_3 || typeof cellValue_3 !== "object")
|
|
801
|
+
for (var destinationRows_3 = __values(destinationRows), destinationRows_3_1 = destinationRows_3.next(); !destinationRows_3_1.done; destinationRows_3_1 = destinationRows_3.next()) {
|
|
802
|
+
var _l = destinationRows_3_1.value, rowIndex = _l.rowIndex, dataRowIndex = _l.dataRowIndex;
|
|
803
|
+
// Clipboard-provided row heights win.
|
|
804
|
+
if (clipboardSizedRows.has(rowIndex))
|
|
805
|
+
continue;
|
|
806
|
+
var rowData = selectedRowValues[dataRowIndex];
|
|
807
|
+
if (!rowData)
|
|
683
808
|
continue;
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
var
|
|
690
|
-
var
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
809
|
+
// Find the cell most likely to drive row height —
|
|
810
|
+
// most lines first, then any wrap. If no cell in
|
|
811
|
+
// the row needs more than one line and no cell is
|
|
812
|
+
// wrapped, the row's existing height already fits.
|
|
813
|
+
var bestLines = 1;
|
|
814
|
+
var bestColumnIndex = void 0;
|
|
815
|
+
var bestCell = void 0;
|
|
816
|
+
var bestHasWrap = false;
|
|
817
|
+
var columnCursor = 0;
|
|
818
|
+
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
819
|
+
var dataColumnIndex = columnCursor % colSpan;
|
|
820
|
+
var cellValue = rowData[dataColumnIndex];
|
|
821
|
+
if (!cellValue || typeof cellValue !== "object")
|
|
822
|
+
continue;
|
|
823
|
+
var ue_1 = getCellUserEnteredValue(cellValue);
|
|
824
|
+
var text = getExtendedValueString(ue_1);
|
|
825
|
+
var lines = typeof text === "string" && text.includes("\n")
|
|
826
|
+
? text.split("\n").length
|
|
827
|
+
: 1;
|
|
828
|
+
var uf_1 = getCellUserEnteredFormat(cellValue);
|
|
829
|
+
var wrap = (uf_1 === null || uf_1 === void 0 ? void 0 : uf_1.wrapStrategy) === "wrap";
|
|
830
|
+
if (lines > bestLines ||
|
|
831
|
+
(lines === bestLines && wrap && !bestHasWrap)) {
|
|
832
|
+
bestLines = lines;
|
|
833
|
+
bestCell = cellValue;
|
|
834
|
+
bestColumnIndex = columnIndex;
|
|
835
|
+
bestHasWrap = wrap;
|
|
836
|
+
}
|
|
697
837
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
sheet.rowMetadata
|
|
715
|
-
|
|
716
|
-
|
|
838
|
+
if (!bestCell ||
|
|
839
|
+
bestColumnIndex === undefined ||
|
|
840
|
+
(bestLines === 1 && !bestHasWrap)) {
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
var ue = getCellUserEnteredValue(bestCell);
|
|
844
|
+
var overrideText = (_g = getExtendedValueString(ue)) !== null && _g !== void 0 ? _g : "";
|
|
845
|
+
var uf = getCellUserEnteredFormat(bestCell);
|
|
846
|
+
var height = getFinalRowHeight(destinationSheetId, rowIndex, bestColumnIndex, {
|
|
847
|
+
textOverride: String(overrideText),
|
|
848
|
+
textFormatOverride: uf === null || uf === void 0 ? void 0 : uf.textFormat,
|
|
849
|
+
shouldWrapOverride: bestHasWrap,
|
|
850
|
+
});
|
|
851
|
+
if (typeof height === "number" && height > 0) {
|
|
852
|
+
if (!sheet.rowMetadata)
|
|
853
|
+
sheet.rowMetadata = [];
|
|
854
|
+
if (!sheet.rowMetadata[rowIndex]) {
|
|
855
|
+
sheet.rowMetadata[rowIndex] = {};
|
|
856
|
+
}
|
|
857
|
+
sheet.rowMetadata[rowIndex].size = height;
|
|
858
|
+
sheet.rowMetadata[rowIndex].resizedByUser = false;
|
|
717
859
|
}
|
|
718
|
-
sheet.rowMetadata[rowIndex].size = height;
|
|
719
|
-
sheet.rowMetadata[rowIndex].resizedByUser = false;
|
|
720
860
|
}
|
|
721
861
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
862
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
863
|
+
finally {
|
|
864
|
+
try {
|
|
865
|
+
if (destinationRows_3_1 && !destinationRows_3_1.done && (_c = destinationRows_3.return)) _c.call(destinationRows_3);
|
|
866
|
+
}
|
|
867
|
+
finally { if (e_10) throw e_10.error; }
|
|
727
868
|
}
|
|
728
|
-
finally { if (e_9) throw e_9.error; }
|
|
729
869
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
sheet.columnMetadata = [];
|
|
735
|
-
}
|
|
736
|
-
for (var index = 0; index < columnWidths.length; index++) {
|
|
737
|
-
var curWidth = columnWidths[index];
|
|
738
|
-
if (isNil(curWidth) || curWidth === 0) {
|
|
739
|
-
continue;
|
|
870
|
+
// column widths
|
|
871
|
+
if (columnWidths) {
|
|
872
|
+
if (!sheet.columnMetadata) {
|
|
873
|
+
sheet.columnMetadata = [];
|
|
740
874
|
}
|
|
741
|
-
var
|
|
742
|
-
|
|
743
|
-
|
|
875
|
+
for (var index = 0; index < columnWidths.length; index++) {
|
|
876
|
+
var curWidth = columnWidths[index];
|
|
877
|
+
if (isNil(curWidth) || curWidth === 0) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
var columnIndex = to.range.startColumnIndex + index;
|
|
881
|
+
if (!((_h = sheet.columnMetadata) === null || _h === void 0 ? void 0 : _h[columnIndex])) {
|
|
882
|
+
sheet.columnMetadata[columnIndex] = {};
|
|
883
|
+
}
|
|
884
|
+
sheet.columnMetadata[columnIndex].size =
|
|
885
|
+
columnWidths[index];
|
|
744
886
|
}
|
|
745
|
-
sheet.columnMetadata[columnIndex].size =
|
|
746
|
-
columnWidths[index];
|
|
747
887
|
}
|
|
748
888
|
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
sheets: { patches: patches, inversePatches: inversePatches },
|
|
753
|
-
});
|
|
754
|
-
return nextState;
|
|
755
|
-
});
|
|
756
|
-
// For row expansions, add columns
|
|
757
|
-
onChangeTableColumn(destinationSheetId, activeCell, activeCellValue !== null && activeCellValue !== void 0 ? activeCellValue : undefined, adjacentTable, isRowExpansion, isColumnExpansion, to.range);
|
|
758
|
-
// Add calculated column
|
|
759
|
-
onChangeCalculatedColumn(destinationSheetId, activeCell, activeCellValue !== null && activeCellValue !== void 0 ? activeCellValue : undefined, currentTable);
|
|
760
|
-
// Update new selections
|
|
761
|
-
if (!isSelectionACell(nextSelections)) {
|
|
762
|
-
onChangeSelections === null || onChangeSelections === void 0 ? void 0 : onChangeSelections(destinationSheetId, [to]);
|
|
763
|
-
}
|
|
764
|
-
// Update active cell
|
|
765
|
-
onChangeActiveCell(destinationSheetId, __assign({}, getActiveCell()));
|
|
766
|
-
// Stream the paste to an engine consumer. The clipboard is a bounded payload (not
|
|
767
|
-
// windowed), so paste can resolve the destination cells UI-side; we read back the
|
|
768
|
-
// user-entered values the paste actually produced — relocated formulas, paste-special
|
|
769
|
-
// merges, shared-string text — and replay them as a `change-batch` the engine recomputes
|
|
770
|
-
// from. Reading the produced state (rather than re-deriving) keeps this correct across the
|
|
771
|
-
// cut / pure-paste / paste-special branches without duplicating their logic.
|
|
772
|
-
if (onCommand && pastedSheetData) {
|
|
773
|
-
values = [];
|
|
774
|
-
for (rowIndex = to.range.startRowIndex; rowIndex <= to.range.endRowIndex; rowIndex++) {
|
|
775
|
-
row = [];
|
|
776
|
-
for (columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++) {
|
|
777
|
-
cell = (_v = (_u = (_t = pastedSheetData[destinationSheetId]) === null || _t === void 0 ? void 0 : _t[rowIndex]) === null || _u === void 0 ? void 0 : _u.values) === null || _v === void 0 ? void 0 : _v[columnIndex];
|
|
778
|
-
ue = cell ? getCellUserEnteredValue(cell) : undefined;
|
|
779
|
-
// Formula text wins (e.g. "=SUM(A1:A2)"), else the literal string / number / bool.
|
|
780
|
-
// `??` (not `||`) so 0 and false survive; `null` clears the cell.
|
|
781
|
-
row.push((_z = (_y = (_x = (_w = getExtendedValueFormula(ue)) !== null && _w !== void 0 ? _w : getExtendedValueString(ue)) !== null && _x !== void 0 ? _x : getExtendedValueNumber(ue)) !== null && _y !== void 0 ? _y : getExtendedValueBool(ue)) !== null && _z !== void 0 ? _z : null);
|
|
782
|
-
}
|
|
783
|
-
values.push(row);
|
|
784
|
-
}
|
|
785
|
-
onCommand({
|
|
786
|
-
command: "change-batch",
|
|
787
|
-
sheetId: destinationSheetId,
|
|
788
|
-
ranges: to.range,
|
|
789
|
-
values: values,
|
|
790
|
-
});
|
|
791
|
-
// On cut, the source cells were cleared — mirror that so the engine drops them too.
|
|
792
|
-
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
793
|
-
onCommand({
|
|
794
|
-
command: "delete-cells",
|
|
795
|
-
sheetId: sourceSheetId,
|
|
796
|
-
activeCell: {
|
|
797
|
-
rowIndex: from.range.startRowIndex,
|
|
798
|
-
columnIndex: from.range.startColumnIndex,
|
|
799
|
-
},
|
|
800
|
-
selections: [{ range: from.range }],
|
|
889
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
890
|
+
saveHistory({
|
|
891
|
+
sheets: { patches: patches, inversePatches: inversePatches },
|
|
801
892
|
});
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
// Embeds
|
|
806
|
-
if (embeds === null || embeds === void 0 ? void 0 : embeds.length) {
|
|
807
|
-
firstEmbedId_1 = embeds[0].embedId;
|
|
808
|
-
onChangeEmbeds === null || onChangeEmbeds === void 0 ? void 0 : onChangeEmbeds(function (prevEmbeds) {
|
|
809
|
-
var _a = __read(produceWithPatches(prevEmbeds, function (draft) {
|
|
810
|
-
draft.push.apply(draft, __spreadArray([], __read(embeds), false));
|
|
811
|
-
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
812
|
-
saveHistory({
|
|
813
|
-
embeds: { patches: patches, inversePatches: inversePatches },
|
|
814
|
-
selectedEmbedOrChart: { redo: firstEmbedId_1, undo: undefined },
|
|
893
|
+
return nextState;
|
|
815
894
|
});
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
895
|
+
// For row expansions, add columns
|
|
896
|
+
onChangeTableColumn(destinationSheetId, activeCell, activeCellValue !== null && activeCellValue !== void 0 ? activeCellValue : undefined, adjacentTable, isRowExpansion, isColumnExpansion, to.range, pastedHeaderValues);
|
|
897
|
+
// Add calculated column
|
|
898
|
+
onChangeCalculatedColumn(destinationSheetId, activeCell, activeCellValue !== null && activeCellValue !== void 0 ? activeCellValue : undefined, currentTable);
|
|
899
|
+
// Update new selections
|
|
900
|
+
if (!isSelectionACell(nextSelections)) {
|
|
901
|
+
onChangeSelections === null || onChangeSelections === void 0 ? void 0 : onChangeSelections(destinationSheetId, [to]);
|
|
902
|
+
}
|
|
903
|
+
// Update active cell
|
|
904
|
+
onChangeActiveCell(destinationSheetId, __assign({}, getActiveCell()));
|
|
905
|
+
// Stream the paste to an engine consumer. The clipboard is a bounded payload (not
|
|
906
|
+
// windowed), so paste can resolve the destination cells UI-side; we read back the
|
|
907
|
+
// user-entered values the paste actually produced — relocated formulas, paste-special
|
|
908
|
+
// merges, shared-string text — and replay them as a `change-batch` the engine recomputes
|
|
909
|
+
// from. Reading the produced state (rather than re-deriving) keeps this correct across the
|
|
910
|
+
// cut / pure-paste / paste-special branches without duplicating their logic.
|
|
911
|
+
if (onCommand && pastedSheetData) {
|
|
912
|
+
var values = [];
|
|
913
|
+
for (var rowIndex = to.range.startRowIndex; rowIndex <= to.range.endRowIndex; rowIndex++) {
|
|
914
|
+
var row = [];
|
|
915
|
+
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++) {
|
|
916
|
+
var cell = (_l = (_k = (_j = pastedSheetData[destinationSheetId]) === null || _j === void 0 ? void 0 : _j[rowIndex]) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l[columnIndex];
|
|
917
|
+
var ue = cell ? getCellUserEnteredValue(cell) : undefined;
|
|
918
|
+
// Formula text wins (e.g. "=SUM(A1:A2)"), else the literal string / number / bool.
|
|
919
|
+
// `??` (not `||`) so 0 and false survive; `null` clears the cell.
|
|
920
|
+
row.push((_q = (_p = (_o = (_m = getExtendedValueFormula(ue)) !== null && _m !== void 0 ? _m : getExtendedValueString(ue)) !== null && _o !== void 0 ? _o : getExtendedValueNumber(ue)) !== null && _p !== void 0 ? _p : getExtendedValueBool(ue)) !== null && _q !== void 0 ? _q : null);
|
|
921
|
+
}
|
|
922
|
+
values.push(row);
|
|
923
|
+
}
|
|
924
|
+
onCommand(__assign(__assign({ command: "change-batch", sheetId: destinationSheetId, ranges: to.range, values: values }, (autoExpandTables ? {} : { autoExpandTables: autoExpandTables })), (autoCalculatedColumns ? {} : { autoCalculatedColumns: autoCalculatedColumns })));
|
|
925
|
+
// On cut, the source cells were cleared — mirror that so the engine drops them too.
|
|
926
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
927
|
+
onCommand({
|
|
928
|
+
command: "delete-cells",
|
|
929
|
+
sheetId: sourceSheetId,
|
|
930
|
+
activeCell: {
|
|
931
|
+
rowIndex: from.range.startRowIndex,
|
|
932
|
+
columnIndex: from.range.startColumnIndex,
|
|
933
|
+
},
|
|
934
|
+
selections: [{ range: from.range }],
|
|
849
935
|
});
|
|
850
936
|
}
|
|
851
937
|
}
|
|
852
938
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
939
|
+
// Defined names wholly inside the cut block follow it (Excel move semantics); a name the
|
|
940
|
+
// block covers only partially keeps referring to its original area.
|
|
941
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
942
|
+
onChangeNamedRanges === null || onChangeNamedRanges === void 0 ? void 0 : onChangeNamedRanges(function (prevNamedRanges) {
|
|
943
|
+
var _a = __read(produceWithPatches(prevNamedRanges, function (draft) {
|
|
944
|
+
var e_11, _a;
|
|
945
|
+
var _b;
|
|
946
|
+
try {
|
|
947
|
+
for (var draft_1 = __values(draft), draft_1_1 = draft_1.next(); !draft_1_1.done; draft_1_1 = draft_1.next()) {
|
|
948
|
+
var namedRange = draft_1_1.value;
|
|
949
|
+
if (((_b = namedRange.range) === null || _b === void 0 ? void 0 : _b.sheetId) === sourceSheetId &&
|
|
950
|
+
areaInsideArea(namedRange.range, from.range)) {
|
|
951
|
+
namedRange.range = __assign(__assign({}, moveRange(namedRange.range, from.range, to.range)), { sheetId: destinationSheetId });
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
956
|
+
finally {
|
|
957
|
+
try {
|
|
958
|
+
if (draft_1_1 && !draft_1_1.done && (_a = draft_1.return)) _a.call(draft_1);
|
|
959
|
+
}
|
|
960
|
+
finally { if (e_11) throw e_11.error; }
|
|
961
|
+
}
|
|
962
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
963
|
+
if (!patches.length) {
|
|
964
|
+
return prevNamedRanges;
|
|
965
|
+
}
|
|
966
|
+
saveHistory({ namedRanges: { patches: patches, inversePatches: inversePatches } });
|
|
967
|
+
return nextState;
|
|
968
|
+
});
|
|
969
|
+
onChangeCharts === null || onChangeCharts === void 0 ? void 0 : onChangeCharts(function (prevCharts) {
|
|
970
|
+
var _a = __read(produceWithPatches(prevCharts, function (draft) {
|
|
971
|
+
moveChartsOnRangeMove(draft, sourceSheetId, from.range, destinationSheetId, to.range);
|
|
972
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
973
|
+
if (!patches.length) {
|
|
974
|
+
return prevCharts;
|
|
975
|
+
}
|
|
976
|
+
saveHistory({ charts: { patches: patches, inversePatches: inversePatches } });
|
|
977
|
+
return nextState;
|
|
978
|
+
});
|
|
979
|
+
// The tables the cut block covers whole move with their cells (same history step): the
|
|
980
|
+
// range lands at the destination — on another sheet too — and the column-indexed filter
|
|
981
|
+
// and sort specs follow it, so the table's filters and its structured references keep
|
|
982
|
+
// resolving there.
|
|
983
|
+
if (movedTables.length) {
|
|
984
|
+
var columnDelta_1 = to.range.startColumnIndex - from.range.startColumnIndex;
|
|
985
|
+
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTables) {
|
|
986
|
+
var _a = __read(produceWithPatches(prevTables, function (draft) {
|
|
987
|
+
var e_12, _a;
|
|
988
|
+
var _b, _c;
|
|
989
|
+
var _loop_5 = function (table) {
|
|
990
|
+
var e_13, _d, e_14, _e;
|
|
991
|
+
if (!movedTables.some(function (moved) { return moved.id === table.id; })) {
|
|
992
|
+
return "continue";
|
|
993
|
+
}
|
|
994
|
+
table.sheetId = destinationSheetId;
|
|
995
|
+
var range = moveRange(table.range, from.range, to.range);
|
|
996
|
+
table.range =
|
|
997
|
+
"sheetId" in range
|
|
998
|
+
? __assign(__assign({}, range), { sheetId: destinationSheetId }) : range;
|
|
999
|
+
try {
|
|
1000
|
+
for (var _f = (e_13 = void 0, __values((_b = table.filterSpecs) !== null && _b !== void 0 ? _b : [])), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1001
|
+
var spec = _g.value;
|
|
1002
|
+
spec.columnIndex += columnDelta_1;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1006
|
+
finally {
|
|
1007
|
+
try {
|
|
1008
|
+
if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
|
|
1009
|
+
}
|
|
1010
|
+
finally { if (e_13) throw e_13.error; }
|
|
1011
|
+
}
|
|
1012
|
+
try {
|
|
1013
|
+
for (var _h = (e_14 = void 0, __values((_c = table.sortSpecs) !== null && _c !== void 0 ? _c : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
1014
|
+
var spec = _j.value;
|
|
1015
|
+
spec.dimensionIndex += columnDelta_1;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1019
|
+
finally {
|
|
1020
|
+
try {
|
|
1021
|
+
if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
|
|
1022
|
+
}
|
|
1023
|
+
finally { if (e_14) throw e_14.error; }
|
|
868
1024
|
}
|
|
869
1025
|
};
|
|
870
1026
|
try {
|
|
871
|
-
for (var
|
|
872
|
-
var
|
|
873
|
-
|
|
1027
|
+
for (var draft_2 = __values(draft), draft_2_1 = draft_2.next(); !draft_2_1.done; draft_2_1 = draft_2.next()) {
|
|
1028
|
+
var table = draft_2_1.value;
|
|
1029
|
+
_loop_5(table);
|
|
874
1030
|
}
|
|
875
1031
|
}
|
|
876
|
-
catch (
|
|
1032
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
877
1033
|
finally {
|
|
878
1034
|
try {
|
|
879
|
-
if (
|
|
1035
|
+
if (draft_2_1 && !draft_2_1.done && (_a = draft_2.return)) _a.call(draft_2);
|
|
880
1036
|
}
|
|
881
|
-
finally { if (
|
|
1037
|
+
finally { if (e_12) throw e_12.error; }
|
|
882
1038
|
}
|
|
883
1039
|
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
884
|
-
saveHistory({
|
|
885
|
-
citations: { patches: patches, inversePatches: inversePatches },
|
|
886
|
-
});
|
|
1040
|
+
saveHistory({ tables: { patches: patches, inversePatches: inversePatches } });
|
|
887
1041
|
return nextState;
|
|
888
1042
|
});
|
|
889
1043
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1044
|
+
}
|
|
1045
|
+
// Embeds
|
|
1046
|
+
if (embeds === null || embeds === void 0 ? void 0 : embeds.length) {
|
|
1047
|
+
var firstEmbedId_1 = embeds[0].embedId;
|
|
1048
|
+
onChangeEmbeds === null || onChangeEmbeds === void 0 ? void 0 : onChangeEmbeds(function (prevEmbeds) {
|
|
1049
|
+
var _a = __read(produceWithPatches(prevEmbeds, function (draft) {
|
|
1050
|
+
draft.push.apply(draft, __spreadArray([], __read(embeds), false));
|
|
1051
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
1052
|
+
saveHistory({
|
|
1053
|
+
embeds: { patches: patches, inversePatches: inversePatches },
|
|
1054
|
+
selectedEmbedOrChart: { redo: firstEmbedId_1, undo: undefined },
|
|
1055
|
+
});
|
|
1056
|
+
return nextState;
|
|
1057
|
+
});
|
|
1058
|
+
// Selected first embed
|
|
1059
|
+
focusEmbedOrChart(embeds[0].embedId);
|
|
1060
|
+
}
|
|
1061
|
+
// Tables
|
|
1062
|
+
if (tables === null || tables === void 0 ? void 0 : tables.length) {
|
|
1063
|
+
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTables) {
|
|
1064
|
+
var _a = __read(produceWithPatches(prevTables, function (draft) {
|
|
1065
|
+
var e_15, _a;
|
|
1066
|
+
try {
|
|
1067
|
+
// Excel names a pasted table like a new one — the next free `TableN` — never
|
|
1068
|
+
// `Copy of <title>`, which is not a valid table name (it has a space).
|
|
1069
|
+
for (var tables_1 = __values(tables), tables_1_1 = tables_1.next(); !tables_1_1.done; tables_1_1 = tables_1.next()) {
|
|
1070
|
+
var table = tables_1_1.value;
|
|
1071
|
+
draft.push(__assign(__assign({}, table), { title: getNextTableTitle(draft, generatedNames) }));
|
|
1072
|
+
}
|
|
907
1073
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1074
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1075
|
+
finally {
|
|
1076
|
+
try {
|
|
1077
|
+
if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
|
|
1078
|
+
}
|
|
1079
|
+
finally { if (e_15) throw e_15.error; }
|
|
913
1080
|
}
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1081
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
1082
|
+
saveHistory({
|
|
1083
|
+
tables: { patches: patches, inversePatches: inversePatches },
|
|
1084
|
+
});
|
|
1085
|
+
return nextState;
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
// Handle citations
|
|
1089
|
+
if (selectedRowValues.length && onChangeCitations) {
|
|
1090
|
+
// Collect citationIds from pasted cells
|
|
1091
|
+
var citationIdMap_1 = new Map();
|
|
1092
|
+
for (var dataRowIndex = 0; dataRowIndex < rowSpan; dataRowIndex++) {
|
|
1093
|
+
var rowData = selectedRowValues[dataRowIndex];
|
|
1094
|
+
if (!rowData)
|
|
1095
|
+
continue;
|
|
1096
|
+
for (var dataColumnIndex = 0; dataColumnIndex < colSpan; dataColumnIndex++) {
|
|
1097
|
+
var cellValue = rowData[dataColumnIndex];
|
|
1098
|
+
if (cellValue &&
|
|
1099
|
+
typeof cellValue === "object" &&
|
|
1100
|
+
"citationId" in cellValue &&
|
|
1101
|
+
cellValue.citationId) {
|
|
1102
|
+
citationIdMap_1.set(cellValue.citationId, {
|
|
1103
|
+
sourceRowIndex: dataRowIndex,
|
|
1104
|
+
sourceColumnIndex: dataColumnIndex,
|
|
1105
|
+
});
|
|
919
1106
|
}
|
|
920
|
-
finally { if (e_1) throw e_1.error; }
|
|
921
1107
|
}
|
|
922
|
-
|
|
923
|
-
|
|
1108
|
+
}
|
|
1109
|
+
if (citationIdMap_1.size > 0) {
|
|
1110
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
1111
|
+
// For cut operation: Move citations to new position
|
|
924
1112
|
onChangeCitations(function (prevCitations) {
|
|
925
1113
|
var _a = __read(produceWithPatches(prevCitations, function (draft) {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1114
|
+
var e_16, _a;
|
|
1115
|
+
var _loop_6 = function (citationId) {
|
|
1116
|
+
var citation = draft.find(function (c) { return c.id === citationId; });
|
|
1117
|
+
if (citation) {
|
|
1118
|
+
// Update citation range to new position
|
|
1119
|
+
citation.range.sheetId = destinationSheetId;
|
|
1120
|
+
citation.range.startRowIndex += rowDelta;
|
|
1121
|
+
citation.range.endRowIndex += rowDelta;
|
|
1122
|
+
citation.range.startColumnIndex += columnDelta;
|
|
1123
|
+
citation.range.endColumnIndex += columnDelta;
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
938
1126
|
try {
|
|
939
|
-
for (var
|
|
940
|
-
var
|
|
941
|
-
|
|
942
|
-
var cellData = (_d = (_c = (_b = draft[destinationSheetId]) === null || _b === void 0 ? void 0 : _b[rowIndex]) === null || _c === void 0 ? void 0 : _c.values) === null || _d === void 0 ? void 0 : _d[columnIndex];
|
|
943
|
-
if (cellData === null || cellData === void 0 ? void 0 : cellData.citationId) {
|
|
944
|
-
var newCitationId = citationIdRemap_1.get(cellData.citationId);
|
|
945
|
-
if (newCitationId) {
|
|
946
|
-
cellData.citationId = newCitationId;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
}
|
|
1127
|
+
for (var _b = __values(citationIdMap_1.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1128
|
+
var citationId = _c.value;
|
|
1129
|
+
_loop_6(citationId);
|
|
950
1130
|
}
|
|
951
1131
|
}
|
|
952
|
-
catch (
|
|
1132
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
953
1133
|
finally {
|
|
954
1134
|
try {
|
|
955
|
-
if (
|
|
1135
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
956
1136
|
}
|
|
957
|
-
finally { if (
|
|
1137
|
+
finally { if (e_16) throw e_16.error; }
|
|
958
1138
|
}
|
|
959
1139
|
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
960
1140
|
saveHistory({
|
|
961
|
-
|
|
1141
|
+
citations: { patches: patches, inversePatches: inversePatches },
|
|
962
1142
|
});
|
|
963
1143
|
return nextState;
|
|
964
1144
|
});
|
|
965
1145
|
}
|
|
1146
|
+
else if (!isCutOperation) {
|
|
1147
|
+
// For paste (copy) operation: Create new citations with new IDs
|
|
1148
|
+
var newCitations_1 = [];
|
|
1149
|
+
var citationIdRemap_1 = new Map();
|
|
1150
|
+
var _loop_2 = function (oldCitationId, sourceRowIndex, sourceColumnIndex) {
|
|
1151
|
+
var originalCitation = citations === null || citations === void 0 ? void 0 : citations.find(function (c) { return c.id === oldCitationId; });
|
|
1152
|
+
if (originalCitation) {
|
|
1153
|
+
var newId = uuidString();
|
|
1154
|
+
citationIdRemap_1.set(oldCitationId, newId);
|
|
1155
|
+
// Calculate the new range based on paste destination
|
|
1156
|
+
var newCitation = __assign(__assign({}, originalCitation), { id: newId, range: {
|
|
1157
|
+
sheetId: destinationSheetId,
|
|
1158
|
+
startRowIndex: to.range.startRowIndex + sourceRowIndex,
|
|
1159
|
+
endRowIndex: to.range.startRowIndex + sourceRowIndex,
|
|
1160
|
+
startColumnIndex: to.range.startColumnIndex + sourceColumnIndex,
|
|
1161
|
+
endColumnIndex: to.range.startColumnIndex + sourceColumnIndex,
|
|
1162
|
+
} });
|
|
1163
|
+
newCitations_1.push(newCitation);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
try {
|
|
1167
|
+
for (var _t = __values(citationIdMap_1.entries()), _u = _t.next(); !_u.done; _u = _t.next()) {
|
|
1168
|
+
var _v = __read(_u.value, 2), oldCitationId = _v[0], _w = _v[1], sourceRowIndex = _w.sourceRowIndex, sourceColumnIndex = _w.sourceColumnIndex;
|
|
1169
|
+
_loop_2(oldCitationId, sourceRowIndex, sourceColumnIndex);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1173
|
+
finally {
|
|
1174
|
+
try {
|
|
1175
|
+
if (_u && !_u.done && (_a = _t.return)) _a.call(_t);
|
|
1176
|
+
}
|
|
1177
|
+
finally { if (e_1) throw e_1.error; }
|
|
1178
|
+
}
|
|
1179
|
+
if (newCitations_1.length > 0) {
|
|
1180
|
+
// Add new citations
|
|
1181
|
+
onChangeCitations(function (prevCitations) {
|
|
1182
|
+
var _a = __read(produceWithPatches(prevCitations, function (draft) {
|
|
1183
|
+
draft.push.apply(draft, __spreadArray([], __read(newCitations_1), false));
|
|
1184
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
1185
|
+
saveHistory({
|
|
1186
|
+
citations: { patches: patches, inversePatches: inversePatches },
|
|
1187
|
+
});
|
|
1188
|
+
return nextState;
|
|
1189
|
+
});
|
|
1190
|
+
// Update cell citationIds to point to new citations
|
|
1191
|
+
onChangeSheetData === null || onChangeSheetData === void 0 ? void 0 : onChangeSheetData(function (prevSheetData) {
|
|
1192
|
+
var _a = __read(produceWithPatches(prevSheetData, function (draft) {
|
|
1193
|
+
var e_17, _a;
|
|
1194
|
+
var _b, _c, _d;
|
|
1195
|
+
try {
|
|
1196
|
+
for (var destinationRows_4 = __values(destinationRows), destinationRows_4_1 = destinationRows_4.next(); !destinationRows_4_1.done; destinationRows_4_1 = destinationRows_4.next()) {
|
|
1197
|
+
var rowIndex = destinationRows_4_1.value.rowIndex;
|
|
1198
|
+
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++) {
|
|
1199
|
+
var cellData = (_d = (_c = (_b = draft[destinationSheetId]) === null || _b === void 0 ? void 0 : _b[rowIndex]) === null || _c === void 0 ? void 0 : _c.values) === null || _d === void 0 ? void 0 : _d[columnIndex];
|
|
1200
|
+
if (cellData === null || cellData === void 0 ? void 0 : cellData.citationId) {
|
|
1201
|
+
var newCitationId = citationIdRemap_1.get(cellData.citationId);
|
|
1202
|
+
if (newCitationId) {
|
|
1203
|
+
cellData.citationId = newCitationId;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1210
|
+
finally {
|
|
1211
|
+
try {
|
|
1212
|
+
if (destinationRows_4_1 && !destinationRows_4_1.done && (_a = destinationRows_4.return)) _a.call(destinationRows_4);
|
|
1213
|
+
}
|
|
1214
|
+
finally { if (e_17) throw e_17.error; }
|
|
1215
|
+
}
|
|
1216
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
1217
|
+
saveHistory({
|
|
1218
|
+
sheetData: { patches: patches, inversePatches: inversePatches },
|
|
1219
|
+
});
|
|
1220
|
+
return nextState;
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
966
1224
|
}
|
|
967
1225
|
}
|
|
968
|
-
}
|
|
1226
|
+
});
|
|
969
1227
|
return [2 /*return*/];
|
|
970
1228
|
}
|
|
971
1229
|
});
|
|
@@ -985,6 +1243,9 @@ export var useOnPaste = function (_a) {
|
|
|
985
1243
|
onRequestFonts,
|
|
986
1244
|
idCreationStrategy,
|
|
987
1245
|
createHistory,
|
|
1246
|
+
batchHistory,
|
|
1247
|
+
autoExpandTables,
|
|
1248
|
+
autoCalculatedColumns,
|
|
988
1249
|
enqueueStructureChange,
|
|
989
1250
|
enqueueGraphOperation,
|
|
990
1251
|
onChangeCalculatedColumn,
|
|
@@ -1011,5 +1272,9 @@ export var useOnPaste = function (_a) {
|
|
|
1011
1272
|
getFinalRowHeight,
|
|
1012
1273
|
onCommand,
|
|
1013
1274
|
generatedNames,
|
|
1275
|
+
onChangeNamedRanges,
|
|
1276
|
+
onChangeCharts,
|
|
1277
|
+
getSheetMerges,
|
|
1278
|
+
showError,
|
|
1014
1279
|
]);
|
|
1015
1280
|
};
|