Skip to content

Use unsanitized HTML in demo clipboard read#3355

Merged
JiuqingSong merged 2 commits into
masterfrom
use-unsanitized-clipboard-read
May 29, 2026
Merged

Use unsanitized HTML in demo clipboard read#3355
JiuqingSong merged 2 commits into
masterfrom
use-unsanitized-clipboard-read

Conversation

@JiuqingSong
Copy link
Copy Markdown
Collaborator

Summary

  • Pass { unsanitized: ['text/html'] } to navigator.clipboard.read() in the demo Paste button and the PastePane API playground so the browser does not sanitize the HTML before we receive it.
  • Add a local ClipboardWithUnsanitized interface as a typing shim, since the unsanitized option is not yet present in the standard TypeScript Clipboard typings.

Test plan

  • Open the demo and use the Paste button to paste rich HTML; confirm the clipboard read still succeeds and the pasted content reflects the unsanitized HTML.
  • Open the API Playground → Paste pane, click "Extract clipboard programmatically", and verify the displayed clipboard data uses the unsanitized HTML payload.
  • yarn eslint, yarn test:fast, yarn b pass.

🤖 Generated with Claude Code

Pass `unsanitized: ['text/html']` to `navigator.clipboard.read()` in the
demo Paste button and PastePane so the read HTML is not sanitized by the
browser. A local `ClipboardWithUnsanitized` interface is added since the
option is not yet in the standard TypeScript Clipboard typings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-05-29 17:20 UTC

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the demo clipboard-reading flows to request unsanitized text/html from navigator.clipboard.read() so the demo receives the original HTML payload (instead of browser-sanitized HTML), adding a local typing shim to satisfy current TypeScript DOM typings.

Changes:

  • Pass { unsanitized: ['text/html'] } to navigator.clipboard.read() in the demo Paste button and API Playground Paste pane.
  • Add a local ClipboardWithUnsanitized interface to type the experimental unsanitized option.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
demo/scripts/controlsV2/sidePane/apiPlayground/paste/PastePane.tsx Adds a local clipboard typing shim and requests unsanitized HTML when extracting clipboard data in the Paste pane.
demo/scripts/controlsV2/demoButtons/pasteButton.ts Adds the same typing shim and requests unsanitized HTML for the ribbon Paste button’s programmatic clipboard read.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +20
interface ClipboardWithUnsanitized {
read(options?: { unsanitized?: string[] }): Promise<ClipboardItems>;
}
Comment on lines +5 to +7
interface ClipboardWithUnsanitized {
read(options?: { unsanitized?: string[] }): Promise<ClipboardItems>;
}
if (clipboard && clipboard.read) {
try {
const clipboardItems = await clipboard.read();
const clipboardItems = await clipboard.read({ unsanitized: ['text/html'] });
if (clipboard && clipboard.read) {
try {
const clipboardItems = await clipboard.read();
const clipboardItems = await clipboard.read({ unsanitized: ['text/html'] });
@JiuqingSong JiuqingSong merged commit 1b17aad into master May 29, 2026
8 checks passed
@JiuqingSong JiuqingSong deleted the use-unsanitized-clipboard-read branch May 29, 2026 17:20
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.

3 participants