@rowsncolumns/spreadsheet-state 29.0.0 → 29.1.1
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 +131 -7
- package/dist/cjs/api/anchored-objects.d.ts.map +1 -1
- package/dist/cjs/api/anchored-objects.js +488 -43
- package/dist/cjs/api/copy-paste.d.ts +1 -2
- package/dist/cjs/api/copy-paste.d.ts.map +1 -1
- package/dist/cjs/api/copy-paste.js +1 -3
- 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/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/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 +129 -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-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 +10 -1
- package/dist/cjs/hooks/use-on-delete-sheet.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete-sheet.js +19 -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 +3 -1
- package/dist/cjs/hooks/use-on-move-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-columns.js +14 -1
- package/dist/cjs/hooks/use-on-move-rows.d.ts +3 -1
- package/dist/cjs/hooks/use-on-move-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-rows.js +14 -1
- package/dist/cjs/hooks/use-on-move-selection.d.ts +3 -1
- package/dist/cjs/hooks/use-on-move-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-selection.js +88 -25
- package/dist/cjs/hooks/use-on-paste.d.ts +22 -1
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-paste.js +993 -776
- 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 +56 -10
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +323 -100
- 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 +7 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +8 -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 +17 -2
- 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 +17 -2
- 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 +106 -44
- 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 +16 -3
- 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 +230 -19
- 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 +149 -2
- 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 +11 -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 +11 -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 +68 -38
- 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 +10 -2
- 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 +131 -7
- package/dist/esm/api/anchored-objects.d.ts.map +1 -1
- package/dist/esm/api/anchored-objects.js +399 -15
- package/dist/esm/api/copy-paste.d.ts +1 -2
- package/dist/esm/api/copy-paste.d.ts.map +1 -1
- package/dist/esm/api/copy-paste.js +1 -3
- 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/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/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 +129 -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-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 +10 -1
- package/dist/esm/hooks/use-on-delete-sheet.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete-sheet.js +19 -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 +3 -1
- package/dist/esm/hooks/use-on-move-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-columns.js +14 -1
- package/dist/esm/hooks/use-on-move-rows.d.ts +3 -1
- package/dist/esm/hooks/use-on-move-rows.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-rows.js +14 -1
- package/dist/esm/hooks/use-on-move-selection.d.ts +3 -1
- package/dist/esm/hooks/use-on-move-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-selection.js +44 -1
- package/dist/esm/hooks/use-on-paste.d.ts +22 -1
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-paste.js +815 -672
- 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 +56 -10
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +260 -30
- 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 +7 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -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 +17 -2
- 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 +17 -2
- 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 +69 -30
- 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 +16 -3
- 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 +180 -16
- 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 +132 -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 +11 -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 +11 -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 +49 -23
- 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 +10 -2
- 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 +19 -11
|
@@ -7,6 +7,7 @@ import { isSelectionACell, useGetEffectiveValuesFromRange, } from "@rowsncolumns
|
|
|
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,9 +15,12 @@ import { findPartiallyCoveredMerge, MERGED_CELL_MOVE_ERROR } from "../api/merges
|
|
|
14
15
|
import { moveRange } from "../api/selection";
|
|
15
16
|
import { useShowError } from "../atoms/error-state.atom";
|
|
16
17
|
import { applyPasteOperation, isBlankClipboardCell, resolvePasteSpecialOptions, } from "../api/paste-special";
|
|
17
|
-
import {
|
|
18
|
-
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";
|
|
19
22
|
import { collectDataValidationTarget, extendDataValidationRanges, } from "../interface/data-validation-utils";
|
|
23
|
+
import { planHeaderCellRenames } from "../interface/change-table-column";
|
|
20
24
|
import { SheetCell } from "../sheet-cell";
|
|
21
25
|
import { extractFontFamily, generateDataFromClipboard, pickFormatting, pickFormula, pickValue, transpose, } from "./../api/copy-paste";
|
|
22
26
|
import { useCalculationQueue } from "./use-calculation-queue";
|
|
@@ -38,7 +42,7 @@ export var buildDestinationRowAssignments = function (sheetId, startRowIndex, en
|
|
|
38
42
|
return assignments;
|
|
39
43
|
};
|
|
40
44
|
export var useOnPaste = function (_a) {
|
|
41
|
-
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, 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;
|
|
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;
|
|
42
46
|
var canEditCellRange = useCanEditCellRange();
|
|
43
47
|
var showError = useShowError();
|
|
44
48
|
// Allowed values
|
|
@@ -53,6 +57,7 @@ export var useOnPaste = function (_a) {
|
|
|
53
57
|
onChangeTables: onChangeTables,
|
|
54
58
|
getSheetName: getSheetName,
|
|
55
59
|
onCommand: onCommand,
|
|
60
|
+
autoCalculatedColumns: autoCalculatedColumns,
|
|
56
61
|
});
|
|
57
62
|
var onChangeTableColumn = useOnChangeTableColumn({
|
|
58
63
|
locale: locale,
|
|
@@ -61,19 +66,20 @@ export var useOnPaste = function (_a) {
|
|
|
61
66
|
enqueueGraphOperation: enqueueGraphOperation,
|
|
62
67
|
onChangeSheetData: onChangeSheetData,
|
|
63
68
|
onChangeTables: onChangeTables,
|
|
69
|
+
onChangeCharts: onChangeCharts,
|
|
64
70
|
getDependents: getDependents,
|
|
65
71
|
onCommand: onCommand,
|
|
66
72
|
generatedNames: generatedNames,
|
|
73
|
+
tables: currentTables,
|
|
67
74
|
});
|
|
68
75
|
var redrawGrid = useRedrawGrid();
|
|
69
76
|
var getFinalRowHeight = useGetFinalRowHeight();
|
|
70
|
-
var
|
|
77
|
+
var _h = useCalculationQueue({ enqueueCalculation: enqueueCalculation }), enqueue = _h.enqueue, processQueue = _h.processQueue;
|
|
71
78
|
return useCallback(function (e, sourceSheetId, destinationSheetId, copiedSelections, activeCell, selections, finalSelections, isCutOperation) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
-
var pasteSpecial, pasteMode, pasteOperation, pasteEvent, forcePlainText, activeSheetName, from, merges, embeds, tables, columnWidths, rowHeights, selectedRowValues, rowIndex, start, end, pasteResults,
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
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) {
|
|
77
83
|
case 0:
|
|
78
84
|
pasteSpecial = resolvePasteSpecialOptions(e === null || e === void 0 ? void 0 : e.clipboardData);
|
|
79
85
|
pasteMode = pasteSpecial.paste;
|
|
@@ -89,19 +95,19 @@ export var useOnPaste = function (_a) {
|
|
|
89
95
|
for (rowIndex = from.range.startRowIndex; rowIndex <= from.range.endRowIndex; rowIndex++) {
|
|
90
96
|
start = from.range.startColumnIndex;
|
|
91
97
|
end = start + from.range.endColumnIndex - from.range.startColumnIndex + 1;
|
|
92
|
-
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 : []);
|
|
93
99
|
}
|
|
94
100
|
return [3 /*break*/, 3];
|
|
95
|
-
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)];
|
|
96
102
|
case 2:
|
|
97
|
-
pasteResults =
|
|
98
|
-
selectedRowValues = (
|
|
103
|
+
pasteResults = _f.sent();
|
|
104
|
+
selectedRowValues = (_e = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.results) !== null && _e !== void 0 ? _e : [];
|
|
99
105
|
merges = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.merges;
|
|
100
106
|
embeds = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.embeds;
|
|
101
107
|
tables = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.tables;
|
|
102
108
|
rowHeights = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.rowHeights;
|
|
103
109
|
columnWidths = pasteResults === null || pasteResults === void 0 ? void 0 : pasteResults.columnWidths;
|
|
104
|
-
|
|
110
|
+
_f.label = 3;
|
|
105
111
|
case 3:
|
|
106
112
|
// No data,
|
|
107
113
|
if (isNil(selectedRowValues)) {
|
|
@@ -119,898 +125,1105 @@ export var useOnPaste = function (_a) {
|
|
|
119
125
|
else if (pasteMode === "values") {
|
|
120
126
|
selectedRowValues = pickValue(selectedRowValues, destinationSheetId, locale);
|
|
121
127
|
}
|
|
122
|
-
saveHistory = createHistory();
|
|
123
|
-
dataValidationTargets = new Map();
|
|
124
128
|
fontFamilies = extractFontFamily(selectedRowValues);
|
|
125
129
|
if (!(fontFamilies.length && preserveFormatting)) return [3 /*break*/, 10];
|
|
126
130
|
fontFamiliesWithWeights = fontFamilies
|
|
127
131
|
.map(function (family) { return ["".concat(family, ":400"), "".concat(family, ":700")]; })
|
|
128
132
|
.flat();
|
|
129
|
-
|
|
133
|
+
_f.label = 4;
|
|
130
134
|
case 4:
|
|
131
|
-
|
|
135
|
+
_f.trys.push([4, 9, , 10]);
|
|
132
136
|
if (!onRequestFonts) return [3 /*break*/, 6];
|
|
133
137
|
return [4 /*yield*/, onRequestFonts(fontFamilies)];
|
|
134
138
|
case 5:
|
|
135
|
-
|
|
139
|
+
_f.sent();
|
|
136
140
|
return [3 /*break*/, 8];
|
|
137
141
|
case 6: return [4 /*yield*/, loadWebFont(fontFamiliesWithWeights)];
|
|
138
142
|
case 7:
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
_f.sent();
|
|
144
|
+
_f.label = 8;
|
|
141
145
|
case 8:
|
|
142
146
|
redrawGrid === null || redrawGrid === void 0 ? void 0 : redrawGrid();
|
|
143
147
|
return [3 /*break*/, 10];
|
|
144
148
|
case 9:
|
|
145
|
-
err_1 =
|
|
149
|
+
err_1 = _f.sent();
|
|
146
150
|
error("Error loading webfonts", fontFamilies, err_1);
|
|
147
151
|
return [3 /*break*/, 10];
|
|
148
152
|
case 10:
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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;
|
|
193
201
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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.
|
|
212
246
|
enqueueStructureChange === null || enqueueStructureChange === void 0 ? void 0 : enqueueStructureChange({
|
|
213
247
|
kind: "invalidate-range",
|
|
214
|
-
sheetId:
|
|
215
|
-
startRowIndex:
|
|
216
|
-
endRowIndex:
|
|
217
|
-
startColumnIndex:
|
|
218
|
-
endColumnIndex:
|
|
248
|
+
sheetId: destinationSheetId,
|
|
249
|
+
startRowIndex: to.range.startRowIndex,
|
|
250
|
+
endRowIndex: to.range.endRowIndex,
|
|
251
|
+
startColumnIndex: to.range.startColumnIndex,
|
|
252
|
+
endColumnIndex: to.range.endColumnIndex,
|
|
219
253
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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)
|
|
236
287
|
: undefined;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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";
|
|
265
334
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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;
|
|
269
354
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
+
};
|
|
286
373
|
try {
|
|
287
|
-
for (var
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
processSideEffectDependentCells({
|
|
291
|
-
draft: draft,
|
|
292
|
-
rowIndex: rowIndex,
|
|
293
|
-
columnIndex: columnIndex,
|
|
294
|
-
sheetId: sheetId,
|
|
295
|
-
destinationSheetId: destinationSheetId,
|
|
296
|
-
columnDelta: columnDelta,
|
|
297
|
-
enqueueGraphOperation: enqueueGraphOperation,
|
|
298
|
-
enqueueCalculation: enqueue,
|
|
299
|
-
getDependents: getDependents,
|
|
300
|
-
recalcCells: recalcCells,
|
|
301
|
-
rowDelta: rowDelta,
|
|
302
|
-
sourceRange: from.range,
|
|
303
|
-
movedKeys: movedKeys,
|
|
304
|
-
locale: locale,
|
|
305
|
-
rowCount: rowCount,
|
|
306
|
-
columnCount: columnCount,
|
|
307
|
-
});
|
|
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);
|
|
308
377
|
}
|
|
309
378
|
}
|
|
310
379
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
311
380
|
finally {
|
|
312
381
|
try {
|
|
313
|
-
if (
|
|
382
|
+
if (headerRenames_1_1 && !headerRenames_1_1.done && (_a = headerRenames_1.return)) _a.call(headerRenames_1);
|
|
314
383
|
}
|
|
315
384
|
finally { if (e_2) throw e_2.error; }
|
|
316
385
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
+
});
|
|
333
430
|
}
|
|
334
|
-
draft[sheetId][rowIndex].values[columnIndex] =
|
|
335
|
-
{};
|
|
336
431
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
position: position,
|
|
361
|
-
force: true,
|
|
362
|
-
});
|
|
363
|
-
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
364
|
-
}
|
|
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;
|
|
365
455
|
}
|
|
366
|
-
|
|
367
|
-
|
|
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];
|
|
368
469
|
try {
|
|
369
|
-
|
|
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
|
+
}
|
|
487
|
+
}
|
|
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; }
|
|
370
494
|
}
|
|
371
|
-
|
|
495
|
+
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
372
496
|
}
|
|
373
|
-
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
374
497
|
}
|
|
375
498
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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; }
|
|
381
505
|
}
|
|
382
|
-
finally { if (e_3) throw e_3.error; }
|
|
383
506
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (pasteSpecial.skipBlanks &&
|
|
416
|
-
isBlankClipboardCell(cellValue_2)) {
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
// Operation: combine the pasted cell with the cell it
|
|
420
|
-
// lands on. The clipboard is anchored at the FIRST tile,
|
|
421
|
-
// so a source formula is relocated to the tile it lands
|
|
422
|
-
// on first (the same `moveFormula` shift the plain paste
|
|
423
|
-
// applies below); the composed `=(dest)op(source)` is
|
|
424
|
-
// then anchored at the destination and must not be moved
|
|
425
|
-
// again (that would shift the destination fragment too).
|
|
426
|
-
if (pasteOperation) {
|
|
427
|
-
var sourceFormula = getExtendedValueFormula(getCellUserEnteredValue(cellValue_2));
|
|
428
|
-
if (!isNil(sourceFormula) &&
|
|
429
|
-
dataRowIndex === 0 &&
|
|
430
|
-
dataColumnIndex === 0 &&
|
|
431
|
-
(rowIndex !== sourceCell.rowIndex ||
|
|
432
|
-
columnIndex !== sourceCell.columnIndex)) {
|
|
433
|
-
var tileCell = new SheetCell();
|
|
434
|
-
tileCell.setLocale(locale);
|
|
435
|
-
tileCell.assign(destinationSheetId, sourceCell, cellValue_2);
|
|
436
|
-
tileCell.moveFormula(sourceCell, { rowIndex: rowIndex, columnIndex: columnIndex }, activeSheetName, { preserveAbsolutes: true });
|
|
437
|
-
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;
|
|
438
538
|
}
|
|
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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
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), {
|
|
483
618
|
rowIndex: rowIndex,
|
|
484
619
|
columnIndex: columnIndex,
|
|
485
|
-
|
|
620
|
+
sheetId: destinationSheetId,
|
|
621
|
+
});
|
|
486
622
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
type: "add",
|
|
490
|
-
position: {
|
|
623
|
+
try {
|
|
624
|
+
for (var _9 = (e_7 = void 0, __values(getDependents({
|
|
491
625
|
rowIndex: rowIndex,
|
|
492
626
|
columnIndex: columnIndex,
|
|
493
627
|
sheetId: destinationSheetId,
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
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);
|
|
502
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 = [];
|
|
503
708
|
try {
|
|
504
|
-
for (var
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
+
});
|
|
512
720
|
}
|
|
513
|
-
var position = dependent.position;
|
|
514
|
-
enqueue({
|
|
515
|
-
type: "add",
|
|
516
|
-
position: position,
|
|
517
|
-
force: true,
|
|
518
|
-
});
|
|
519
|
-
recalcCells.set(createSheetCellIdentifier(position.sheetId, position.rowIndex, position.columnIndex), position);
|
|
520
721
|
}
|
|
521
722
|
}
|
|
522
|
-
catch (
|
|
723
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
523
724
|
finally {
|
|
524
725
|
try {
|
|
525
|
-
if (
|
|
726
|
+
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
526
727
|
}
|
|
527
|
-
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); });
|
|
528
737
|
}
|
|
529
|
-
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.registerCell(sheetCell);
|
|
530
|
-
currentSheet[rowIndex].values[columnIndex] =
|
|
531
|
-
sheetCell.getCellData();
|
|
532
|
-
collectDataValidationTarget(dataValidationTargets, destinationSheetId, rowIndex, columnIndex, currentSheet[rowIndex].values[columnIndex]);
|
|
533
|
-
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.registerCellXfs(sheetCell);
|
|
534
738
|
}
|
|
535
739
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
sheetData: { patches: patches, inversePatches: inversePatches },
|
|
548
|
-
recalcCells: { undo: recalcCells, redo: recalcCells },
|
|
549
|
-
activeCell: {
|
|
550
|
-
undo: getActiveCell(),
|
|
551
|
-
redo: getActiveCell(),
|
|
552
|
-
},
|
|
553
|
-
selections: {
|
|
554
|
-
undo: undefined,
|
|
555
|
-
redo: isSelectionACell(nextSelections) ? undefined : [to],
|
|
556
|
-
},
|
|
557
|
-
});
|
|
558
|
-
extendDataValidationRanges(dataValidationTargets, onChangeDataValidations, saveHistory);
|
|
559
|
-
processQueue();
|
|
560
|
-
pastedSheetData = nextState;
|
|
561
|
-
return nextState;
|
|
562
|
-
});
|
|
563
|
-
// Save registries
|
|
564
|
-
cellXfsRegistry === null || cellXfsRegistry === void 0 ? void 0 : cellXfsRegistry.getPatches(saveHistory);
|
|
565
|
-
sharedStringRegistry === null || sharedStringRegistry === void 0 ? void 0 : sharedStringRegistry.getPatches(saveHistory);
|
|
566
|
-
// Update row or column count
|
|
567
|
-
// Change sheets
|
|
568
|
-
onChangeSheets === null || onChangeSheets === void 0 ? void 0 : onChangeSheets(function (prevSheets) {
|
|
569
|
-
var _a = __read(produceWithPatches(prevSheets, function (draft) {
|
|
570
|
-
var e_7, _a, e_8, _b, e_9, _c;
|
|
571
|
-
var _d, _e, _f, _g, _h;
|
|
572
|
-
var sheet = draft.find(function (sheet) { return sheet.sheetId === destinationSheetId; });
|
|
573
|
-
if (sheet) {
|
|
574
|
-
sheet.rowCount = Math.min(maxRowCount, Math.max((_d = sheet.rowCount) !== null && _d !== void 0 ? _d : DEFAULT_ROW_COUNT, to.range.endRowIndex));
|
|
575
|
-
sheet.columnCount = Math.min(maxColumnCount, Math.max((_e = sheet.columnCount) !== null && _e !== void 0 ? _e : DEFAULT_COLUMN_COUNT, to.range.endColumnIndex));
|
|
576
|
-
// Handle merges for cut operations
|
|
577
|
-
var mergesToAdd = merges;
|
|
578
|
-
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
579
|
-
var sourceSheet = prevSheets.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
580
|
-
if (sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.merges) {
|
|
581
|
-
// Extract merged cells from source range
|
|
582
|
-
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
|
+
};
|
|
583
751
|
try {
|
|
584
|
-
for (var
|
|
585
|
-
var merge =
|
|
586
|
-
|
|
587
|
-
if (areaIntersects(merge, from.range)) {
|
|
588
|
-
// Calculate new merge coordinates relative to destination
|
|
589
|
-
cutMerges.push({
|
|
590
|
-
startRowIndex: merge.startRowIndex + rowDelta,
|
|
591
|
-
startColumnIndex: merge.startColumnIndex + columnDelta,
|
|
592
|
-
endRowIndex: merge.endRowIndex + rowDelta,
|
|
593
|
-
endColumnIndex: merge.endColumnIndex + columnDelta,
|
|
594
|
-
});
|
|
595
|
-
}
|
|
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);
|
|
596
755
|
}
|
|
597
756
|
}
|
|
598
|
-
catch (
|
|
757
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
599
758
|
finally {
|
|
600
759
|
try {
|
|
601
|
-
if (
|
|
760
|
+
if (mergesToAdd_1_1 && !mergesToAdd_1_1.done && (_b = mergesToAdd_1.return)) _b.call(mergesToAdd_1);
|
|
602
761
|
}
|
|
603
|
-
finally { if (
|
|
604
|
-
}
|
|
605
|
-
if (cutMerges.length > 0) {
|
|
606
|
-
mergesToAdd = cutMerges;
|
|
607
|
-
}
|
|
608
|
-
// Remove merges from source sheet
|
|
609
|
-
var sourceSheetDraft = draft.find(function (s) { return s.sheetId === sourceSheetId; });
|
|
610
|
-
if (sourceSheetDraft === null || sourceSheetDraft === void 0 ? void 0 : sourceSheetDraft.merges) {
|
|
611
|
-
sourceSheetDraft.merges = sourceSheetDraft.merges.filter(function (merge) { return !areaIntersects(merge, from.range); });
|
|
762
|
+
finally { if (e_9) throw e_9.error; }
|
|
612
763
|
}
|
|
613
764
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
var exists = sheet.merges.find(function (range) {
|
|
620
|
-
return isAreasEqual(range, merge);
|
|
621
|
-
});
|
|
622
|
-
if (!exists) {
|
|
623
|
-
sheet.merges.push(merge);
|
|
765
|
+
// Row heights
|
|
766
|
+
var clipboardSizedRows = new Set();
|
|
767
|
+
if (rowHeights) {
|
|
768
|
+
if (!sheet.rowMetadata) {
|
|
769
|
+
sheet.rowMetadata = [];
|
|
624
770
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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);
|
|
630
785
|
}
|
|
631
786
|
}
|
|
632
|
-
|
|
633
|
-
|
|
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) {
|
|
634
800
|
try {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if (rowHeights) {
|
|
643
|
-
if (!sheet.rowMetadata) {
|
|
644
|
-
sheet.rowMetadata = [];
|
|
645
|
-
}
|
|
646
|
-
for (var index = 0; index < rowHeights.length; index++) {
|
|
647
|
-
var curHeight = rowHeights[index];
|
|
648
|
-
if (isNil(curHeight) || curHeight === 0) {
|
|
649
|
-
continue;
|
|
650
|
-
}
|
|
651
|
-
var rowIndex = visibleRowIndexes[index];
|
|
652
|
-
if (isNil(rowIndex)) {
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
if (!sheet.rowMetadata[rowIndex]) {
|
|
656
|
-
sheet.rowMetadata[rowIndex] = {};
|
|
657
|
-
}
|
|
658
|
-
sheet.rowMetadata[rowIndex].size = curHeight;
|
|
659
|
-
clipboardSizedRows.add(rowIndex);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
// Auto-resize rows whose pasted content needs more room
|
|
663
|
-
// (multi-line text or wrap). Mirrors use-on-change's
|
|
664
|
-
// adjustRowHeight, but batched into this immer pass so the
|
|
665
|
-
// whole paste collapses to one undo entry. Skip conditions
|
|
666
|
-
// make the common single-line-text paste do zero work.
|
|
667
|
-
// Skipped for paste-special variants since the destination
|
|
668
|
-
// cell ends up as a merge of existing + pasted data, not
|
|
669
|
-
// the raw pasted value we can read from selectedRowValues.
|
|
670
|
-
var skipAutoResize = pasteSpecial.isSpecial;
|
|
671
|
-
if (!skipAutoResize &&
|
|
672
|
-
getFinalRowHeight &&
|
|
673
|
-
selectedRowValues.length &&
|
|
674
|
-
colSpan > 0) {
|
|
675
|
-
try {
|
|
676
|
-
for (var destinationRows_3 = __values(destinationRows), destinationRows_3_1 = destinationRows_3.next(); !destinationRows_3_1.done; destinationRows_3_1 = destinationRows_3.next()) {
|
|
677
|
-
var _l = destinationRows_3_1.value, rowIndex = _l.rowIndex, dataRowIndex = _l.dataRowIndex;
|
|
678
|
-
// Clipboard-provided row heights win.
|
|
679
|
-
if (clipboardSizedRows.has(rowIndex))
|
|
680
|
-
continue;
|
|
681
|
-
var rowData = selectedRowValues[dataRowIndex];
|
|
682
|
-
if (!rowData)
|
|
683
|
-
continue;
|
|
684
|
-
// Find the cell most likely to drive row height —
|
|
685
|
-
// most lines first, then any wrap. If no cell in
|
|
686
|
-
// the row needs more than one line and no cell is
|
|
687
|
-
// wrapped, the row's existing height already fits.
|
|
688
|
-
var bestLines = 1;
|
|
689
|
-
var bestColumnIndex = void 0;
|
|
690
|
-
var bestCell = void 0;
|
|
691
|
-
var bestHasWrap = false;
|
|
692
|
-
var columnCursor = 0;
|
|
693
|
-
for (var columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++, columnCursor++) {
|
|
694
|
-
var dataColumnIndex = columnCursor % colSpan;
|
|
695
|
-
var cellValue_3 = rowData[dataColumnIndex];
|
|
696
|
-
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)
|
|
697
808
|
continue;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
var
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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
|
+
}
|
|
711
837
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
sheet.rowMetadata
|
|
729
|
-
|
|
730
|
-
|
|
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;
|
|
731
859
|
}
|
|
732
|
-
sheet.rowMetadata[rowIndex].size = height;
|
|
733
|
-
sheet.rowMetadata[rowIndex].resizedByUser = false;
|
|
734
860
|
}
|
|
735
861
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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; }
|
|
741
868
|
}
|
|
742
|
-
finally { if (e_9) throw e_9.error; }
|
|
743
869
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
sheet.columnMetadata = [];
|
|
749
|
-
}
|
|
750
|
-
for (var index = 0; index < columnWidths.length; index++) {
|
|
751
|
-
var curWidth = columnWidths[index];
|
|
752
|
-
if (isNil(curWidth) || curWidth === 0) {
|
|
753
|
-
continue;
|
|
870
|
+
// column widths
|
|
871
|
+
if (columnWidths) {
|
|
872
|
+
if (!sheet.columnMetadata) {
|
|
873
|
+
sheet.columnMetadata = [];
|
|
754
874
|
}
|
|
755
|
-
var
|
|
756
|
-
|
|
757
|
-
|
|
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];
|
|
758
886
|
}
|
|
759
|
-
sheet.columnMetadata[columnIndex].size =
|
|
760
|
-
columnWidths[index];
|
|
761
887
|
}
|
|
762
888
|
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
889
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
890
|
+
saveHistory({
|
|
891
|
+
sheets: { patches: patches, inversePatches: inversePatches },
|
|
892
|
+
});
|
|
893
|
+
return nextState;
|
|
767
894
|
});
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
if (!isSelectionACell(nextSelections)) {
|
|
776
|
-
onChangeSelections === null || onChangeSelections === void 0 ? void 0 : onChangeSelections(destinationSheetId, [to]);
|
|
777
|
-
}
|
|
778
|
-
// Update active cell
|
|
779
|
-
onChangeActiveCell(destinationSheetId, __assign({}, getActiveCell()));
|
|
780
|
-
// Stream the paste to an engine consumer. The clipboard is a bounded payload (not
|
|
781
|
-
// windowed), so paste can resolve the destination cells UI-side; we read back the
|
|
782
|
-
// user-entered values the paste actually produced — relocated formulas, paste-special
|
|
783
|
-
// merges, shared-string text — and replay them as a `change-batch` the engine recomputes
|
|
784
|
-
// from. Reading the produced state (rather than re-deriving) keeps this correct across the
|
|
785
|
-
// cut / pure-paste / paste-special branches without duplicating their logic.
|
|
786
|
-
if (onCommand && pastedSheetData) {
|
|
787
|
-
values = [];
|
|
788
|
-
for (rowIndex = to.range.startRowIndex; rowIndex <= to.range.endRowIndex; rowIndex++) {
|
|
789
|
-
row = [];
|
|
790
|
-
for (columnIndex = to.range.startColumnIndex; columnIndex <= to.range.endColumnIndex; columnIndex++) {
|
|
791
|
-
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];
|
|
792
|
-
ue = cell ? getCellUserEnteredValue(cell) : undefined;
|
|
793
|
-
// Formula text wins (e.g. "=SUM(A1:A2)"), else the literal string / number / bool.
|
|
794
|
-
// `??` (not `||`) so 0 and false survive; `null` clears the cell.
|
|
795
|
-
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);
|
|
796
|
-
}
|
|
797
|
-
values.push(row);
|
|
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]);
|
|
798
902
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
//
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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 }],
|
|
935
|
+
});
|
|
936
|
+
}
|
|
816
937
|
}
|
|
817
938
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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
|
+
}
|
|
832
953
|
}
|
|
833
954
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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; }
|
|
839
961
|
}
|
|
840
|
-
|
|
962
|
+
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
963
|
+
if (!patches.length) {
|
|
964
|
+
return prevNamedRanges;
|
|
841
965
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return prevNamedRanges;
|
|
845
|
-
}
|
|
846
|
-
saveHistory({ namedRanges: { patches: patches, inversePatches: inversePatches } });
|
|
847
|
-
return nextState;
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
// Embeds
|
|
851
|
-
if (embeds === null || embeds === void 0 ? void 0 : embeds.length) {
|
|
852
|
-
firstEmbedId_1 = embeds[0].embedId;
|
|
853
|
-
onChangeEmbeds === null || onChangeEmbeds === void 0 ? void 0 : onChangeEmbeds(function (prevEmbeds) {
|
|
854
|
-
var _a = __read(produceWithPatches(prevEmbeds, function (draft) {
|
|
855
|
-
draft.push.apply(draft, __spreadArray([], __read(embeds), false));
|
|
856
|
-
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
857
|
-
saveHistory({
|
|
858
|
-
embeds: { patches: patches, inversePatches: inversePatches },
|
|
859
|
-
selectedEmbedOrChart: { redo: firstEmbedId_1, undo: undefined },
|
|
860
|
-
});
|
|
861
|
-
return nextState;
|
|
862
|
-
});
|
|
863
|
-
// Selected first embed
|
|
864
|
-
focusEmbedOrChart(embeds[0].embedId);
|
|
865
|
-
}
|
|
866
|
-
// Tables
|
|
867
|
-
if (tables === null || tables === void 0 ? void 0 : tables.length) {
|
|
868
|
-
onChangeTables === null || onChangeTables === void 0 ? void 0 : onChangeTables(function (prevTables) {
|
|
869
|
-
var _a = __read(produceWithPatches(prevTables, function (draft) {
|
|
870
|
-
draft.push.apply(draft, __spreadArray([], __read(tables), false));
|
|
871
|
-
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
872
|
-
saveHistory({
|
|
873
|
-
tables: { patches: patches, inversePatches: inversePatches },
|
|
966
|
+
saveHistory({ namedRanges: { patches: patches, inversePatches: inversePatches } });
|
|
967
|
+
return nextState;
|
|
874
968
|
});
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
for (dataRowIndex = 0; dataRowIndex < rowSpan; dataRowIndex++) {
|
|
882
|
-
rowData = selectedRowValues[dataRowIndex];
|
|
883
|
-
if (!rowData)
|
|
884
|
-
continue;
|
|
885
|
-
for (dataColumnIndex = 0; dataColumnIndex < colSpan; dataColumnIndex++) {
|
|
886
|
-
cellValue_1 = rowData[dataColumnIndex];
|
|
887
|
-
if (cellValue_1 &&
|
|
888
|
-
typeof cellValue_1 === "object" &&
|
|
889
|
-
"citationId" in cellValue_1 &&
|
|
890
|
-
cellValue_1.citationId) {
|
|
891
|
-
citationIdMap_1.set(cellValue_1.citationId, {
|
|
892
|
-
sourceRowIndex: dataRowIndex,
|
|
893
|
-
sourceColumnIndex: dataColumnIndex,
|
|
894
|
-
});
|
|
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;
|
|
895
975
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
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; }
|
|
913
1024
|
}
|
|
914
1025
|
};
|
|
915
1026
|
try {
|
|
916
|
-
for (var
|
|
917
|
-
var
|
|
918
|
-
|
|
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);
|
|
919
1030
|
}
|
|
920
1031
|
}
|
|
921
|
-
catch (
|
|
1032
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
922
1033
|
finally {
|
|
923
1034
|
try {
|
|
924
|
-
if (
|
|
1035
|
+
if (draft_2_1 && !draft_2_1.done && (_a = draft_2.return)) _a.call(draft_2);
|
|
925
1036
|
}
|
|
926
|
-
finally { if (
|
|
1037
|
+
finally { if (e_12) throw e_12.error; }
|
|
927
1038
|
}
|
|
928
1039
|
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
929
|
-
saveHistory({
|
|
930
|
-
citations: { patches: patches, inversePatches: inversePatches },
|
|
931
|
-
});
|
|
1040
|
+
saveHistory({ tables: { patches: patches, inversePatches: inversePatches } });
|
|
932
1041
|
return nextState;
|
|
933
1042
|
});
|
|
934
1043
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
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
|
+
}
|
|
952
1073
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
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; }
|
|
958
1080
|
}
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
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
|
+
});
|
|
964
1106
|
}
|
|
965
|
-
finally { if (e_1) throw e_1.error; }
|
|
966
1107
|
}
|
|
967
|
-
|
|
968
|
-
|
|
1108
|
+
}
|
|
1109
|
+
if (citationIdMap_1.size > 0) {
|
|
1110
|
+
if (isCutOperation && from && !isNil(sourceSheetId)) {
|
|
1111
|
+
// For cut operation: Move citations to new position
|
|
969
1112
|
onChangeCitations(function (prevCitations) {
|
|
970
1113
|
var _a = __read(produceWithPatches(prevCitations, function (draft) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
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
|
+
};
|
|
983
1126
|
try {
|
|
984
|
-
for (var
|
|
985
|
-
var
|
|
986
|
-
|
|
987
|
-
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];
|
|
988
|
-
if (cellData === null || cellData === void 0 ? void 0 : cellData.citationId) {
|
|
989
|
-
var newCitationId = citationIdRemap_1.get(cellData.citationId);
|
|
990
|
-
if (newCitationId) {
|
|
991
|
-
cellData.citationId = newCitationId;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
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);
|
|
995
1130
|
}
|
|
996
1131
|
}
|
|
997
|
-
catch (
|
|
1132
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
998
1133
|
finally {
|
|
999
1134
|
try {
|
|
1000
|
-
if (
|
|
1135
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1001
1136
|
}
|
|
1002
|
-
finally { if (
|
|
1137
|
+
finally { if (e_16) throw e_16.error; }
|
|
1003
1138
|
}
|
|
1004
1139
|
}), 3), nextState = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
1005
1140
|
saveHistory({
|
|
1006
|
-
|
|
1141
|
+
citations: { patches: patches, inversePatches: inversePatches },
|
|
1007
1142
|
});
|
|
1008
1143
|
return nextState;
|
|
1009
1144
|
});
|
|
1010
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
|
+
}
|
|
1011
1224
|
}
|
|
1012
1225
|
}
|
|
1013
|
-
}
|
|
1226
|
+
});
|
|
1014
1227
|
return [2 /*return*/];
|
|
1015
1228
|
}
|
|
1016
1229
|
});
|
|
@@ -1030,6 +1243,9 @@ export var useOnPaste = function (_a) {
|
|
|
1030
1243
|
onRequestFonts,
|
|
1031
1244
|
idCreationStrategy,
|
|
1032
1245
|
createHistory,
|
|
1246
|
+
batchHistory,
|
|
1247
|
+
autoExpandTables,
|
|
1248
|
+
autoCalculatedColumns,
|
|
1033
1249
|
enqueueStructureChange,
|
|
1034
1250
|
enqueueGraphOperation,
|
|
1035
1251
|
onChangeCalculatedColumn,
|
|
@@ -1057,6 +1273,7 @@ export var useOnPaste = function (_a) {
|
|
|
1057
1273
|
onCommand,
|
|
1058
1274
|
generatedNames,
|
|
1059
1275
|
onChangeNamedRanges,
|
|
1276
|
+
onChangeCharts,
|
|
1060
1277
|
getSheetMerges,
|
|
1061
1278
|
showError,
|
|
1062
1279
|
]);
|