Clipboard
Copy, cut, and paste move the current selection through an in-editor buffer. The engine exposes them as verbs; the corresponding actions (actionCopy, actionCut, actionPaste) wire them to standard hotkeys.
Copy, cut, pasteโ
import { Editor } from "@oh-just-another/state";
editor.copySelected(); // buffer the selection
editor.cutSelected(); // copy + delete in one step
editor.paste(); // paste under the cursor
paste(targetWorld?) accepts an optional world-space drop target. When omitted, the engine pastes under the last observed pointer position so a fresh paste lands beneath the cursor instead of overlapping the originals.
const world = editor.screenToWorld({ x: clientX, y: clientY });
editor.paste(world);
Style clipboardโ
Separate from element copy/paste, the engine keeps a lightweight per-editor style buffer โ capture a shape's visual style (fill, stroke, dash, โฆ) and stamp it onto the current selection.
editor.copySelectionStyle();
editor.pasteSelectionStyle();
const ready = editor.hasStyleClipboard; // true once a style is buffered
This is an in-editor buffer, not the OS clipboard. Cross-tab paste is the host's responsibility โ wire it through the clipboard actions or your own keyboard handler.
Hotkeysโ
The built-in clipboard actions are bundled as clipboardActions and dispatched by bindEditorHotkeys.
import { bindEditorHotkeys } from "@oh-just-another/editor";
const unbind = bindEditorHotkeys(editor);