Skip to content

Support video and native context-menu media paste in Markdown - #341552

Merged
Henning Dieterichs (hediet) merged 5 commits into
mainfrom
hediet/markdown-media-paste
Oct 15, 2026
Merged

Henning Dieterichs (hediet) merged 5 commits into
mainfrom
hediet/markdown-media-paste

Conversation

@hediet

@hediet Henning Dieterichs (hediet) commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Accept video/audio as well as image clipboard files; preserve native names, MIME types, and bytes through existing file/snippet infrastructure.
  • Consume native context-menu clipboard payloads without rereading the clipboard and report unsupported file-only formats explicitly.
  • Fix the webview host-menu focus race: restore the last connected focused input synchronously before native clipboard commands, without overriding an already focused input. Update the shell CSP hash.

Companion clipboard strategy: https://github.com/microsoft/vscode-packages/pull/363. Media support compiles against published editor types; complete context-menu behavior requires that package change to be published and adopted. Local file-linked development dependencies are deliberately excluded from this PR.

Validation

  • 10 focused Markdown media-paste extension tests and three native-media classification tests passed.
  • Three targeted webview shell tests passed, covering native command focus, disconnected/existing inputs, and CSP consistency.
  • Renderer type-check, extension compilation, webview bundle build, and targeted ESLint passed.
  • Actual Code OSS automated with dbgjs/CDP: keyboard image/video paste and actual context-menu Paste clicks insert correct image/video markup. The native command receives the editable Clipboard target rather than BODY; the proxy is cleaned up after insertion. Keyboard-pasted PNG/WebM SHA256 hashes match fixtures exactly.
  • Native clipboard payloads are controlled fixtures because terminal Win32 clipboard access is denied (error 5); physical OS clipboard file seeding remains unverified.

The first CI run's full ESLint process was killed with exit 137. Targeted lint passed; the focus follow-up starts a fresh CI run.

Accept image, video, and audio payloads through existing file/snippet infrastructure, consume native clipboard data directly, and report unsupported file-only formats explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The locked dependency cannot deliver context-menu payloads, tests are not wired into CI, and large media transfers are unbounded.

3 open findings
What changed in this PR

Extends Markdown custom-editor clipboard paste from images to image, video, and audio media while preserving native metadata and bytes.

Changes:

  • Adds native clipboard media classification.
  • Reuses existing media file creation and embed generation.
  • Adds host and classifier tests for supported and invalid media.
File Description
src/​test/​markdownEditorImagePaste.test.ts Tests video/audio creation and validation.
src/​preview/​markdownEditorImagePaste.ts Accepts media MIME types and updates messages.
scripts/​clipboardMedia.test.mts Tests native clipboard classification.
markdown-editor-src/​imagePasteController.ts Processes native and async clipboard media.
markdown-editor-src/​clipboardMedia.ts Classifies supported native media files.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Remember the last focused content element and restore it synchronously when a host menu action targets the webview body, preserving existing focused inputs and ignoring disconnected elements. Update the webview shell CSP hash and add regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
roblourens previously approved these changes Oct 14, 2026
Request clipboard bytes sequentially through file handles, keep each base64 response bounded to 256 KiB of file data, and release renderer handles after each paste. Run native clipboard and transfer regressions in PR CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 5ea3f380 Current: 37a16017

Changed (1)

sessions/chatCompositeBar/OverflowingTabs/Light
Before After
before after

Pin @vscode/markdown-editor 0.0.2-127, published from 3966f6f0, so clean checkouts receive the native clipboard callback and context-menu focus handling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hediet
Henning Dieterichs (hediet) merged commit 9dac660 into main Oct 15, 2026
36 checks passed
@hediet
Henning Dieterichs (hediet) deleted the hediet/markdown-media-paste branch October 15, 2026 15:46
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 15, 2026
Eric Dallo (ericdallo) added a commit to editor-code-assistant/eca-webview that referenced this pull request Oct 22, 2026
VS Code 1.143 refocuses a webview's last focused element before running
clipboard commands whenever <body> is active (microsoft/vscode#341552).
Selecting message text leaves focus on <body> and the last focused
element is usually the prompt textarea, so Cmd/Ctrl+C and context-menu
Copy moved focus there, wiping the selection and copying nothing.

Make the messages scroller click-focusable (tabIndex -1, kept out of the
Tab order) so selecting text focuses it instead and VS Code leaves the
selection alone. It stays on the scroller itself since a focusable
ancestor would break arrow/Page-key scrolling.

Reported upstream as microsoft/vscode#343489.

🤖 Generated with [ECA](https://eca.dev) (nubank-anthropic/opus-5.5 - max)

Co-Authored-By: eca-agent <git@eca.dev>
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.

5 participants