Import Figma Clipboard
You can import a Figma selection by parsing the clipboard HTML and loading the resulting objects.
Steps
- Copy a selection in Figma (Copy as Clipboard).
- Pass the clipboard HTML into
parseFigmaClipboardfrom@designful/figma-importer. - Load the returned objects via
editor.loadData({ objects, pages }).
Example
import { parseFigmaClipboard } from '@designful/figma-importer'
const result = parseFigmaClipboard(clipboardHtml)
if (result) {
editor.loadData({ objects: result.objects, pages: result.pages })
}
Debugging
import { decodeFigmaClipboard } from '@designful/figma-importer'
const message = decodeFigmaClipboard(clipboardHtml)
console.log(message)
Use this to inspect the raw Figma clipboard message before conversion.
Supported Elements
- Frames, groups, rectangles, ellipses, lines, stars, polygons, and text.
- Image fills are converted into
imageobjects when blob data exists. - Vector network blobs are scaled using
normalizedSizewhen available to match Figma bounds. - Auto layout settings are mapped from Figma stack properties.
- Auto layout is enabled by default; set
applyAutoLayout: falseto preserve absolute positions. - Figma components (symbols) are imported as
groupobjects withisComponent: true. - Component instances are imported as
groupobjects withisInstance: true,mainComponentId, andoverrides. - Text overrides from Figma instances are applied to the instance text objects and recorded in
overrides. - Unordered and ordered list metadata in Figma text is converted into list markers in the output text.
Limitations
- Vector nodes are imported as path shapes when
vectorNetworkBlobdata exists; otherwise they fall back to rectangles. - Image fills require blob data in the clipboard payload. When missing, image objects use a default placeholder source and emit
missing-imagewarnings. - Gradient and complex paint fills are ignored in favor of solid fallback colors.
- Component instance overrides are applied for text content, visibility, fills/strokes, size, and stack layout values when available. Other override types may be ignored.
- Component auto layout is resolved during import for instance groups; it does not automatically reflow after edits unless converted to frames.
- Text nodes preserve Figma-measured layout sizes on import so auto layout uses those sizes during the initial layout pass.
Tips
- Inspect
result.warningsto see unsupported nodes or missing asset data. - If
parseFigmaClipboardreturnsnull, ensure the input is the raw HTML clipboard payload (not plain text). - With
fitPageToContentenabled (default), top-level objects are offset so the content starts at the page padding (default0).