import type { HookCallback } from '../../../core/hooks/bucket'; import type { HotInstance } from '../../../core/types'; import { BaseAction } from './_base'; import type { MovableMetaEntry } from '../../../utils/movableMeta'; /** * A snapshot of the values and movable meta for a rectangular cell region. */ interface RegionSnapshot { /** * Top row of the region (visual). */ fromRow: number; /** * Left column of the region (visual). */ fromCol: number; /** * Bottom row of the region (visual). */ toRow: number; /** * Right column of the region (visual). */ toCol: number; /** * Source-format cell values (formula strings for formula cells). */ data: unknown[][]; /** * Sparse list of the cells that carried own movable meta — one entry per styled cell, not per * region cell, so the snapshot (and the `deepClone` the undo stack runs over it) stays small * for large unstyled regions. */ meta: MovableMetaEntry[]; } /** * Action that tracks move-cells (drag-to-move selection) changes. * * A single undo step covers the whole move: it restores both the source region (overwritten * with `null` on move) and the target region (overwritten with the moved data). * * @class MoveCellsAction * @private */ export declare class MoveCellsAction extends BaseAction { /** * Source-region snapshot captured before the move. */ sourceSnapshot: RegionSnapshot; /** * Target-region snapshot captured before the move (the overwritten data). */ targetSnapshot: RegionSnapshot; /** * `true` when the operation was a copy (source is kept intact). */ isCopy: boolean; /** * Initializes the action with snapshots of the source and target regions before the move. */ constructor({ sourceSnapshot, targetSnapshot, isCopy, }: { sourceSnapshot: RegionSnapshot; targetSnapshot: RegionSnapshot; isCopy: boolean; }); /** * Registers the `beforeMoveCells` hook listener that snapshots both the source and * target regions before mutation, and then pushes a new `MoveCellsAction` into the * undo stack via the `afterMoveCells` hook. * * Note: `afterMoveCells` only fires when the move was NOT vetoed. When `beforeMoveCells` * returns `false` (or any guard in `moveCellRange` rejects the move), `afterMoveCells` is * never called, so `pendingSnapshot` is simply overwritten on the next move attempt — a * stale snapshot cannot enqueue a spurious undo action. */ static startRegisteringEvents(hot: HotInstance, undoRedoPlugin: unknown): void; /** * Restores the grid to the state before the move. * * For a move (not copy): restores both the source region (which was cleared) and the * target region (which was overwritten). * * For a copy: the source was not modified, so only the target region is restored. * * After restoring data, selects the source region to reflect the pre-move state. * * @param {HotInstance} hot The Handsontable instance. * @param {HookCallback} undoneCallback The callback to be called after the action is undone. */ undo(hot: HotInstance, undoneCallback: HookCallback): void; /** * Re-applies the move after it has been undone. * * After the move re-runs, selects the target region to reflect the post-move state. * * @param {HotInstance} hot The Handsontable instance. * @param {(result?: { wasRedone?: boolean }) => void} redoneCallback The callback that settles * the redo state. */ redo(hot: HotInstance, redoneCallback: (result?: { wasRedone?: boolean; }) => void): void; } export {};