import { BasePlugin } from '../base'; import PasteEvent from './pasteEvent'; export declare const PLUGIN_KEY = "copyPaste"; export declare const PLUGIN_PRIORITY = 80; /** * @description * Copy, cut, and paste data by using the `CopyPaste` plugin. * * Control the `CopyPaste` plugin programmatically through its [API methods](#methods). * * The user can access the copy-paste features through: * - The [context menu](@/guides/cell-features/clipboard/clipboard.md#context-menu). * - The [keyboard shortcuts](@/guides/cell-features/clipboard/clipboard.md#related-keyboard-shortcuts). * - The browser's menu bar. * * Read more: * - [Guides: Clipboard](@/guides/cell-features/clipboard/clipboard.md) * - [Configuration options: `copyPaste`](@/api/options.md#copypaste) * * @example * ```js * // enable the plugin with the default configuration * copyPaste: true, * * // or, enable the plugin with a custom configuration * copyPaste: { * columnsLimit: 25, * rowsLimit: 50, * pasteMode: 'shift_down', * copyColumnHeaders: true, * copyColumnGroupHeaders: true, * copyColumnHeadersOnly: true, * uiContainer: document.body, * }, * ``` * @class CopyPaste * @plugin CopyPaste */ export declare class CopyPaste extends BasePlugin { #private; /** * Returns the plugin key used to identify this plugin in Handsontable settings. */ static get PLUGIN_KEY(): string; /** * Returns the setting keys that trigger a plugin update when changed via `updateSettings`. */ static get SETTING_KEYS(): string[]; /** * Returns the priority order used to determine the order in which plugins are initialized. */ static get PLUGIN_PRIORITY(): number; /** * Returns the default settings applied when the plugin is enabled without explicit configuration. */ static get DEFAULT_SETTINGS(): { pasteMode: string; rowsLimit: number; columnsLimit: number; copyColumnHeaders: boolean; copyColumnGroupHeaders: boolean; copyColumnHeadersOnly: boolean; }; /** * The maximum number of columns than can be copied to the clipboard. * * @type {number} * @default Infinity */ columnsLimit: number; /** * The maximum number of rows than can be copied to the clipboard. * * @type {number} * @default Infinity */ rowsLimit: number; /** * When pasting: * - `'overwrite'` - overwrite the currently-selected cells * - `'shift_down'` - move currently-selected cells down * - `'shift_right'` - move currently-selected cells to the right * * @type {string} * @default 'overwrite' */ pasteMode: string; /** * The UI container for the secondary focusable element. * * @type {HTMLElement} */ uiContainer: HTMLElement; /** * Ranges of the cells coordinates, which should be used to copy/cut/paste actions. * * @private * @type {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} */ copyableRanges: Record[]; /** * Checks if the [`CopyPaste`](#copypaste) plugin is enabled. * * This method gets called by Handsontable's [`beforeInit`](@/api/hooks.md#beforeinit) hook. * If it returns `true`, the [`enablePlugin()`](#enableplugin) method gets called. * * @returns {boolean} */ isEnabled(): boolean; /** * Enables the [`CopyPaste`](#copypaste) plugin for your Handsontable instance. */ enablePlugin(): void; /** * Updates the state of the [`CopyPaste`](#copypaste) plugin. * * Gets called when [`updateSettings()`](@/api/core.md#updatesettings) * is invoked with any of the following configuration options: * - [`copyPaste`](@/api/options.md#copypaste) * - [`fragmentSelection`](@/api/options.md#fragmentselection) */ updatePlugin(): void; /** * Disables the [`CopyPaste`](#copypaste) plugin for your Handsontable instance. */ disablePlugin(): void; /** * Copies the contents of the selected cells (and/or their related column headers) to the system clipboard. * * Takes an optional parameter (`copyMode`) that defines the scope of copying: * * | `copyMode` value | Description | * | ----------------------------- | --------------------------------------------------------------- | * | `'cells-only'` (default) | Copy the selected cells | * | `'with-column-headers'` | - Copy the selected cells
- Copy the nearest column headers | * | `'with-column-group-headers'` | - Copy the selected cells
- Copy all related columns headers | * | `'column-headers-only'` | Copy the nearest column headers (without copying cells) | * * @param {string} [copyMode='cells-only'] Copy mode. */ copy(copyMode?: string): void; /** * Copies the contents of the selected cells. */ copyCellsOnly(): void; /** * Copies the contents of column headers that are nearest to the selected cells. */ copyColumnHeadersOnly(): void; /** * Copies the contents of the selected cells and all their related column headers. */ copyWithAllColumnHeaders(): void; /** * Copies the contents of the selected cells and their nearest column headers. */ copyWithColumnHeaders(): void; /** * Cuts the contents of the selected cells to the system clipboard. */ cut(): void; /** * Converts the contents of multiple ranges (`ranges`) into a single string. * * @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `endRow`, `startCol` and `endCol`. * @returns {string} A string that will be copied to the clipboard. */ getRangedCopyableData(ranges: Record[]): string; /** * Converts the contents of multiple ranges (`ranges`) into an array of arrays. * * @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`. * @param {boolean} [useSourceData=false] Whether to use the source data instead of the data. This will stringify objects as JSON. * @returns {Array[]} An array of arrays that will be copied to the clipboard. */ getRangedData(ranges: Record[], useSourceData?: boolean): unknown[][]; /** * Simulates the paste action. * * For security reasons, modern browsers don't allow reading from the system clipboard. * * @param {string} pastableText The value to paste, as a raw string. * @param {string} [pastableHtml=''] The value to paste, as HTML. */ paste(pastableText?: string, pastableHtml?: string): void; /** * Prepares copyable text from the cells selection in the invisible textarea. */ setCopyableText(): void; /** * Verifies if editor exists and is open. * * @private * @returns {boolean} */ isEditorOpened(): boolean | undefined; /** * Prepares new values to populate them into datasource. * * @private * @param {object} pasteData An object with the data to populate. * @param {object} pasteData.plainData The plain data to populate. * @param {object} pasteData.sourceData The source data to populate. * @param {object} pasteData.originalPlainData The original plain data before user modifications in beforePaste. * @returns {number[]} Range coordinates after populate data. */ populateValues({ plainData, originalPlainData, sourceData }: { plainData: unknown[][]; originalPlainData: unknown[][]; sourceData: unknown[][]; }): number[] | null[]; /** * `copy` event callback on textarea element. * * @param {Event} event ClipboardEvent. * @private */ onCopy(event: ClipboardEvent): void; /** * `cut` event callback on textarea element. * * @param {Event} event ClipboardEvent. * @private */ onCut(event: ClipboardEvent): void; /** * `paste` event callback on textarea element. * * @param {Event} event ClipboardEvent or pseudo ClipboardEvent, if paste was called manually. * @private */ onPaste(event: ClipboardEvent | PasteEvent): void; /** * Destroys the `CopyPaste` plugin instance. */ destroy(): void; }