This page covers a next version of Handsontable, and is not published yet.

This page covers a non-latest version of Handsontable.

# CopyPaste

# Description

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',
  uiContainer: document.body,
},

# Options

# copyPaste

Source code (opens new window)

copyPaste.copyPaste : object | boolean

Disables or enables the copy/paste functionality.

Default: true Example

// disable copy and paste
copyPaste: false,

// enable copy and paste with custom configuration
copyPaste: {
  columnsLimit: 25,
  rowsLimit: 50,
  pasteMode: 'shift_down',
  uiContainer: document.body,
},

# Members

# columnsLimit

Source code (opens new window)

copyPaste.columnsLimit : number

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

Default: 1000

# pasteMode

Source code (opens new window)

copyPaste.pasteMode : string

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: "overwrite"

# rowsLimit

Source code (opens new window)

copyPaste.rowsLimit : number

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

Default: 1000

# uiContainer

Source code (opens new window)

copyPaste.uiContainer : HTMLElement

UI container for the secondary focusable element.

# Methods

# copy

Source code (opens new window)

copyPaste.copy()

Copies the selected cell into the clipboard.

# cut

Source code (opens new window)

copyPaste.cut()

Cuts the selected cell into the clipboard.

# destroy

Source code (opens new window)

copyPaste.destroy()

Destroys the plugin instance.

# disablePlugin

Source code (opens new window)

copyPaste.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

# enablePlugin

Source code (opens new window)

copyPaste.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

# getRangedCopyableData

Source code (opens new window)

copyPaste.getRangedCopyableData(ranges) ⇒ string

Creates copyable text releated to range objects.

Param 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

Source code (opens new window)

copyPaste.getRangedData(ranges) ⇒ Array<Array>

Creates copyable text releated to range objects.

Param 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

Source code (opens new window)

copyPaste.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.

# paste

Source code (opens new window)

copyPaste.paste(pastableText, [pastableHtml])

Simulates the paste action.

Param Type Default Description
pastableText string Value as raw string to paste.
[pastableHtml] string "" optional Value as HTML to paste.

# setCopyableText

Source code (opens new window)

copyPaste.setCopyableText()

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

# updatePlugin

Source code (opens new window)

copyPaste.updatePlugin()

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

Last Updated: Apr 12, 2024