feat: add Figma clipboard paste with WASM rendering#15
Merged
trmquang93 merged 4 commits intomainfrom Mar 23, 2026
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@grida/refig(Skia WASM)Drawd.jsxby extracting hooks (useFigmaPaste,useCollabSync,useDerivedCanvasState,useInteractionCallbacks,useFileActions,useInstructionGeneration,useDataModels,useStickyNotes,useScreenGroups) to reduce orchestrator complexityparseFigmaClipboard.jsutility with unit tests for detecting, extracting, and rendering Figma clipboard dataTest plan
npm testto verify parseFigmaClipboard unit tests passnpm run lintandnpx vite buildto verify no regressions