Clipboard.read() never returns `html` and Clipboard.copy({ html }) drops HTML on Windows
Description
On Windows, the Clipboard API ignores the HTML representation in both directions:
Clipboard.read()returnstextbuthtmlis alwaysundefined, even when the system clipboard holds anHTML Format(CF_HTML) entry.Clipboard.copy({ text, html })writes only the text. The resulting clipboard has noHTML Formatentry, so other apps can only paste plain text.
The docs describe ReadContent.html and Content.html with no platform restriction, and the manifest now accepts "platforms": ["macOS", "Windows"]. I couldn't find a changelog entry or known issue that mentions this limitation.
Extensions that depend on rich text fail silently. Markdown Converter (extensions/markdown-converter), for example, shows a success HUD on every run but never receives HTML to convert, and its HTML output never reaches the clipboard.
I reproduced this with the latest Raycast for Windows and the latest API:
- Windows 11 Pro 10.0.26200
- Raycast for Windows 2.4.0.0 (MSIX)
@raycast/api2.4.1. Also reproduced with 1.104.x.@raycast/apiis external in the bundle (require("@raycast/api")), so this looks like an app-side implementation gap.- Source app: Chrome 153.0.8010.50
Steps To Reproduce
A. Read
-
Create a
no-viewcommand:import { Clipboard, showHUD } from "@raycast/api"; export default async function Command() { const { text, html } = await Clipboard.read(); await showHUD(`text=${text?.length ?? "none"} html=${html?.length ?? "none"}`); } -
In Chrome, select some formatted content on a web page (for example, part of https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) and press Ctrl+C.
-
Confirm that Windows has HTML on the clipboard. In Windows PowerShell 5.1, run:
(Get-Clipboard -TextFormatType Html -Raw).Length→1088616, starting withVersion:0.9 StartHTML:... SourceURL:... -
Run the command.
B. Write
-
Create a
no-viewcommand:import { Clipboard, showHUD } from "@raycast/api"; export default async function Command() { await Clipboard.copy({ text: "hello", html: "<b>hello</b>" }); await showHUD("copied"); } -
Run the command.
-
In Windows PowerShell 5.1, run:
(Get-Clipboard -TextFormatType Html -Raw).Length
Current Behaviour
- Read: HUD shows
text=22128 html=none. At the same moment,Get-Clipboard -TextFormatType Htmlreturns 1,088,616 characters. Every run gave the same result. - The same happens when Raycast itself put the HTML there: after I restored a rich entry from Clipboard History (the clipboard then held
HTML Formatandapplication/raycast-clipboard-metadata),Clipboard.read()still returned nohtml. - Write: HUD shows
copied.Get-Clipboard -Rawreturnshello, butGet-Clipboard -TextFormatType Htmlreturns length 0. In an earlier run with a larger payload,System.Windows.Forms.Clipboard.GetFormats()listedSystem.String, UnicodeText, Text, application/raycast-clipboard-metadata, Locale, OEMText. Raycast handles the write (its metadata format is present) but never addsHTML Format. - Neither call throws, so extensions can't detect the failure.
Expected Behaviour
As documented:
Clipboard.read()returns the clipboard HTML inhtmlwhen anHTML Formatentry is present. Ideally it returns the fragment or document with the CF_HTML header (Version:,StartHTML:, …) removed, which would match macOSpublic.html.Clipboard.copy({ html })writes a valid CF_HTMLHTML Formatentry next to the text, so rich text pastes correctly into other apps.
If HTML isn't supported on Windows yet, please document it in the Clipboard API reference so extensions can declare platforms accurately.
Additional context
The only way I found to work around this from an extension is to spawn powershell.exe and read HTML Format through System.Windows.Forms.Clipboard. That adds about 2 s per run. It also fails in PowerShell Constrained Language Mode, which is common on managed corporate machines: Add-Type is blocked with CannotDefineNewType. It can't stand in for a fix in Raycast.
I believe I can reproduce this on Mac OS as well.
I believe I can reproduce this on Mac OS as well.
I think the MacOS version is tracked here: https://github.com/raycast/extensions/issues/31421
Root cause appears to be with the Raycast API, so it's possible the bug could be cross platform.
Retested on Raycast for Windows 2.7.3.0 (v2.5, v2.6 and v2.7 have shipped since the status: fixed in next release label): Clipboard.read() still returns html as undefined for content copied from Chrome, while the Windows clipboard holds an HTML Format entry at the same moment.
Is the fix expected to cover the read direction too? #30013 only described Clipboard.copy({ html, text }) dropping the html flavor, so I want to make sure reading isn't tracked separately.