Object Clipboard Operations

Overview

Use copyObjects to copy specific objects to the internal clipboard. Use pasteObjects to create new objects, optionally applying a custom offset. Use duplicateObjects to clone objects without touching the clipboard.

API

copyObjects

editor.copyObjects([rect.id, circle.id])

pasteObjects

const pastedIds = editor.pasteObjects()
const offsetIds = editor.pasteObjects({ x: 30, y: -15 })

duplicateObjects

const duplicateIds = editor.duplicateObjects([rect.id])

Behavior

  • Missing IDs are ignored.
  • pasteObjects returns an empty array when the clipboard is empty.
  • When an offset is provided, it is applied to pasted objects.
  • When no offset is provided, non-frame objects use the default diagonal offset.
  • Duplicates are selected after creation to match in-editor duplication behavior.

Example

const rect = editor.addShape('rect', {
  x: 40,
  y: 30,
  width: 120,
  height: 80,
  fill: '#222222',
})

editor.copyObjects([rect.id])
const pasted = editor.pasteObjects({ x: 20, y: 10 })

const duplicates = editor.duplicateObjects([rect.id])