Drag and Drop API Reference
kittl.dragAndDrop — drag images from your extension into the Kittl canvas.
Scope: exempt — always allowed (uses design:state:write internally)
startDragImageEvent(input)
Call inside a dragstart handler. Sets up the native drag preview and attaches a dragend listener that completes the drop.
| Property | Type | Required | Description |
|---|---|---|---|
event | DragEvent | Yes | The native dragstart event |
img | HTMLImageElement | Yes | The image element being dragged |
persistImage | boolean | No | If true, fetches the src, uploads it via kittl.upload, and replaces the inserted object with the uploaded asset |
Returns: void
dropImage(input)
Inserts an image at specific coordinates without a native drag gesture.
| Property | Type | Required | Description |
|---|---|---|---|
x | number | Yes | Drop X coordinate (iframe client space) |
y | number | Yes | Drop Y coordinate (iframe client space) |
src | string | Yes | Image source URL |
imgWidth | number | No | Rendered width for sizing the placed image |
imgHeight | number | No | Rendered height for sizing the placed image |
grabOffsetX | number | No | Horizontal grab offset (cursor position within the image) |
grabOffsetY | number | No | Vertical grab offset (cursor position within the image) |
persistImage | boolean | No | If true, fetches and uploads the image for permanent storage |
Returns: Promise<string | null> — the ID of the inserted object, or null if the drop failed.