Class: CopyPaste

CopyPaste

This plugin enables the copy/paste functionality in the Handsontable. The functionality works for API, Context Menu,
using keyboard shortcuts and menu bar from the browser.
Possible values:

  • true (to enable default options),
  • false (to disable completely)

or an object with values:

See the copy/paste demo for examples.

Example
// Enables the plugin with default values
copyPaste: true,
// Enables the plugin with custom values
copyPaste: {
  columnsLimit: 25,
  rowsLimit: 50,
  pasteMode: 'shift_down',
},

Members

columnsLimitNumber

Maximum number of columns than can be copied to clipboard using CTRL + C.

Default Value: 1000

pasteModeString

Defines paste (CTRL + V) behavior.

  • Default value "overwrite" will paste clipboard value over current selection.
  • When set to "shift_down", clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  • When set to "shift_right", clipboard data will be pasted in place of current selection, while all selected cells are moved right.
Default Value: 'overwrite'

rowsLimitNumber

Maximum number of rows than can be copied to clipboard using CTRL + C.

Default Value: 1000

Methods

copy()

Copies the selected cell into the clipboard.

cut()

Cuts the selected cell into the clipboard.

destroy()

Destroys the plugin instance.

disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getRangedCopyableData(ranges){String}

Creates copyable text releated to range objects.

Parameters:
Name Type Description
ranges Array.<Object>

Array of objects with properties startRow, endRow, startCol and endCol.

Returns: {String} Returns string which will be copied into clipboard.

getRangedData(ranges){Array.<Array>}

Creates copyable text releated to range objects.

Parameters:
Name Type Description
ranges Array.<Object>

Array of objects with properties startRow, startCol, endRow and endCol.

Returns: {Array.<Array>} Returns array of arrays which will be copied into clipboard.

isEnabled(){Boolean}

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true than the CopyPaste#enablePlugin method is called.

Returns: {Boolean}

paste(value)

Simulates the paste action.

Parameters:
Name Type Description
value String optional

Value to paste.

setCopyableText()

Prepares copyable text from the cells selection in the invisible textarea.

updatePlugin()

Updates the plugin state. This method is executed when Core#updateSettings is invoked.