Feat/vscode support#9
Conversation
|
Thanks for the thorough investigation — the VS Code replay dedup and I wonder if we can simplify the approach though. Instead of an overlay editor with show/hide toggling, what if we just mount the Excalidraw editor inline when fullscreen isn't available? So instead of SVG preview + Edit button + overlay CSS, it's just: no fullscreen → editor is the view. One code path, no Also please rebase on latest Would you be open to trying that simpler approach? Happy to create a PR myself as well if that's easier. |
When the host doesn't report fullscreen in availableDisplayModes, mount the Excalidraw editor directly as the primary view instead of SVG-only preview. One code path, no overlay or mode toggling. Changes: - Detect canFullscreen from host context availableDisplayModes - Size inline editor via containerDimensions.maxHeight (fallback 500px) - Deduplicate ontoolinput/ontoolresult replays (VS Code scroll behavior) - Show toolbar only when fullscreen is available - Rename .fullscreen-btn to .toolbar-btn, add flex layout to .toolbar
dbd0dfa to
0a07944
Compare
|
Someone is attempting to deploy a commit to the Excalidraw Team on Vercel. A member of the Team first needs to authorize it. |
|
Always displaying the inline-editing mode kind of works, but has the drawdown that you can't scroll in the vs code chat very good, because you will scroll inside the excalidraw editor instead (scroll in scroll). Allowing to enter and exit the editing mode fixed this. But i can't get the contianer to stay at a 4/3 aspect ratio while resizing the vs code chat without keeping the svg in the backgound for measurement. Feel free to give it a try yourself. |
feat: VS Code host support
Add support for MCP App hosts that don't offer fullscreen mode (VS Code, etc.), while keeping full Excalidraw editing capabilities through an inline editor.
Problem
The Excalidraw MCP App was built exclusively for Claude Desktop's fullscreen mode. In VS Code's Copilot Chat, which only supports
inlinedisplay mode:ontoolinput/ontoolresultevents, causing unnecessary re-rendersBefore / After
excalidraw-mcp-vscode-issues.mp4
fixed.mp4
Changes
Inline editing mode (
src/mcp-app.tsx,src/global.css)When fullscreen is unavailable, an Edit button replaces the Fullscreen button. Clicking it opens an Excalidraw editor overlaid on top of the SVG preview — same editing experience, no fullscreen required.
visibility: hidden) so VS Code can measure iframe content height correctly[Export] [Fullscreen], VS Code gets[Export] [Edit]Replay deduplication (
src/mcp-app.tsx)VS Code replays
ontoolinput+ontoolresultwhenever a widget scrolls into view. Without dedup, this caused re-renders and flicker. Fixed by:ontoolresultif checkpoint hasn't changedHost detection & defaults (
src/mcp-app.tsx)canFullscreendefaults tofalse(wastrue), preventing the fullscreen button from flashing on hosts that don't support itonhostcontextchangedreadsavailableDisplayModesto setcanFullscreen, with anelsefallback tofalsetoolCallIdis present — no more"default"fallback that caused cross-chat diagram sharingExport without fullscreen (
src/mcp-app.tsx)Extracted
exportElements()as a standalone function usingserializeAsJSONdirectly, so Export works without needing the Excalidraw imperative API (which requires the editor to be mounted).Technical notes
ontoolinputpartialevents. The streaming draw-on animation only works in Claude Desktop. This is a host limitation, not fixable from the widget side.useCallbackfortoggleInlineEdit,toggleFullscreen) are placed before early returns to avoid hooks-order violations that caused black-box rendering.