Skip to content

feat: add Figma clipboard paste with WASM rendering#15

Merged
trmquang93 merged 4 commits intomainfrom
feat/figma-clipboard-paste
Mar 23, 2026
Merged

feat: add Figma clipboard paste with WASM rendering#15
trmquang93 merged 4 commits intomainfrom
feat/figma-clipboard-paste

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Add Figma clipboard paste support: copy a frame in Figma, Cmd/Ctrl+V to paste it as a named screen rendered via @grida/refig (Skia WASM)
  • Resolve shared Figma library components before WASM rendering to avoid missing symbols
  • Refactor Drawd.jsx by extracting hooks (useFigmaPaste, useCollabSync, useDerivedCanvasState, useInteractionCallbacks, useFileActions, useInstructionGeneration, useDataModels, useStickyNotes, useScreenGroups) to reduce orchestrator complexity
  • Add parseFigmaClipboard.js utility with unit tests for detecting, extracting, and rendering Figma clipboard data

Test plan

  • Copy a frame in Figma and paste into the editor canvas -- verify it renders as a named screen
  • Paste a frame that uses shared library components -- verify they resolve correctly
  • Verify existing canvas interactions (pan, zoom, drag, hotspots, connections) still work after the hook extraction refactor
  • Run npm test to verify parseFigmaClipboard unit tests pass
  • Run npm run lint and npx vite build to verify no regressions

Support pasting Figma frames directly onto the canvas (Cmd/Ctrl+V).
Frames are parsed from clipboard binary data, rendered via @grida/refig
WASM renderer, and added as named screens.

- Add parseFigmaClipboard.js with detection, extraction, and rendering
- Integrate Figma paste handler in Drawd.jsx with loading overlay and
  error toast
- Add npm overrides to upgrade @grida/canvas-wasm to 0.90.0-canary.10
  under @grida/refig for rendering fixes (gradient direction, image
  fills, missing elements)
- Pass actual frame dimensions to renderer to avoid viewport mismatch
- Add dev-only diagnostic logging for frame count and dimensions
- Fix vite.config.js WASM middleware to handle nested node_modules path
- Add Node.js stubs for browser build compatibility
- Add figmaSource metadata field to screens and backfill in importFlow
- Update user guide with Figma paste documentation
Break down the 727-line Drawd.jsx into focused hooks:
- useFileActions: file open/save/new operations
- useCollabSync: collaboration wiring and remote state sync
- useInteractionCallbacks: cross-concern callbacks (connect, drag, hotspot)
- useDerivedCanvasState: pure derived canvas values (preview lines, ghost rect)

Drawd.jsx is now 542 lines, serving purely as a hook orchestrator and renderer.
Add missing useCallback dependencies (setFeatureBrief, setTaskLink,
setTechStack, setHotspotModal, etc.) that became required when state
setters moved from same-component scope to hook parameters.

Move collab disconnect effect back to Drawd.jsx to satisfy
React Compiler's set-state-in-effect rule.
Shared/library component instances from Figma clipboard were rendering
as empty frames because their definitions live in derivedSymbolData on
INSTANCE nodeChanges, not in the top-level nodeChanges array that
@grida/refig processes.

Intercept factory.node during kiwi parsing to capture derivedSymbolData,
then convert derived NodeChanges to REST-like nodes, rebuild parent-child
trees, and patch INSTANCE nodes in _figFile before rendering. Gracefully
degrades to empty instances on failure.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flow-forge Ready Ready Preview, Comment Mar 23, 2026 3:31pm

@trmquang93 trmquang93 merged commit 1884cc3 into main Mar 23, 2026
3 checks passed
@github-actions github-actions bot deleted the feat/figma-clipboard-paste branch March 23, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant