extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Clipboard.read() never returns `html` and Clipboard.copy({ html }) drops HTML on Windows

Open cwouyang opened this issue 2 months ago • 3 comments

Description

On Windows, the Clipboard API ignores the HTML representation in both directions:

  • Clipboard.read() returns text but html is always undefined, even when the system clipboard holds an HTML Format (CF_HTML) entry.
  • Clipboard.copy({ text, html }) writes only the text. The resulting clipboard has no HTML Format entry, 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/api 2.4.1. Also reproduced with 1.104.x. @raycast/api is 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

  1. Create a no-view command:

    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"}`);
    }
    
  2. 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.

  3. Confirm that Windows has HTML on the clipboard. In Windows PowerShell 5.1, run: (Get-Clipboard -TextFormatType Html -Raw).Length → 1088616, starting with Version:0.9 StartHTML:... SourceURL:...

  4. Run the command.

B. Write

  1. Create a no-view command:

    import { Clipboard, showHUD } from "@raycast/api";
    
    export default async function Command() {
      await Clipboard.copy({ text: "hello", html: "<b>hello</b>" });
      await showHUD("copied");
    }
    
  2. Run the command.

  3. 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 Html returns 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 Format and application/raycast-clipboard-metadata), Clipboard.read() still returned no html.
  • Write: HUD shows copied. Get-Clipboard -Raw returns hello, but Get-Clipboard -TextFormatType Html returns length 0. In an earlier run with a larger payload, System.Windows.Forms.Clipboard.GetFormats() listed System.String, UnicodeText, Text, application/raycast-clipboard-metadata, Locale, OEMText. Raycast handles the write (its metadata format is present) but never adds HTML Format.
  • Neither call throws, so extensions can't detect the failure.

Expected Behaviour

As documented:

  • Clipboard.read() returns the clipboard HTML in html when an HTML Format entry is present. Ideally it returns the fragment or document with the CF_HTML header (Version:, StartHTML:, …) removed, which would match macOS public.html.
  • Clipboard.copy({ html }) writes a valid CF_HTML HTML Format entry 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.

cwouyang avatar Sep 21 '26 10:09 cwouyang

I believe I can reproduce this on Mac OS as well.

adamesque avatar Sep 25 '26 21:09 adamesque

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.

dfrancour avatar Sep 26 '26 21:09 dfrancour

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.

cwouyang avatar Oct 10 '26 13:10 cwouyang