-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Summary
When using the copy action in Firefox (and other browsers that do not expose window.ClipboardItem), clicking Copy page throws a runtime error and nothing is written to the clipboard.
Steps to reproduce
- Install
starlight-contextual-menu@0.1.3in a Starlight site. - Open the site in Firefox 130 (or Safari 18).
- Click the Copy page button.
Expected behaviour
The page markdown should be copied to the clipboard.
Actual behaviour
The browser console shows:
Failed to copy Markdown: ReferenceError: ClipboardItem is not defined
at Object.action (contextual-menu.js:18:31)
Context
The injected script creates a new ClipboardItem(...) without checking whether the API exists. Firefox only supports navigator.clipboard.writeText, so the constructor reference throws. A small feature-detection guard (falling back to writeText) would fix the issue.
Suggested fix
Guard the Copy Page handler with:
if (typeof window.ClipboardItem === "undefined") {
await navigator.clipboard.writeText(markdown)
return
}Happy to help test a patch—thanks!
Metadata
Metadata
Assignees
Labels
No labels