Skip to content

Type Editor


Type Editor / @type-editor/tables / input/handle-paste / handlePaste

Function: handlePaste()

ts
function handlePaste(view, _, slice): boolean;

Defined in: tables/src/input/handle-paste.ts:41

Handles paste events within table cells.

This function handles two scenarios:

  1. When pasting into a cell selection, it clips the pasted content to fit the selected area and inserts cells appropriately.
  2. When pasting table-like content into a single cell, it expands the table if necessary to accommodate the pasted cells.

Parameters

ParameterTypeDescription
viewPmEditorViewThe editor view.
_ClipboardEventThe clipboard event (unused, but required by the handler signature).
sliceSliceThe pasted content as a ProseMirror slice.

Returns

boolean

true if the paste was handled, false to let default handling continue.

Example

typescript
// Use in a ProseMirror plugin
new Plugin({
  props: {
    handlePaste: handlePaste,
  },
});