Files
buzz/desktop/src/shared/lib/clipboard.ts
Taylor Ho c48006fc3e fix(profile): consolidate agent profile runtime metadata (#1451)
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub14vtk7pvazqrq9639qu7e560wnqtl0d53ca4gjuvq6jzf3k2el23qqlwa7f <ab176f059d100602ea25073d9a69ee9817f7b691c76a897180d48498d959faa2@sprout-oss.stage.blox.sqprod.co>
2026-07-02 10:13:15 -07:00

21 lines
513 B
TypeScript

import { toast } from "sonner";
/**
* Copy plain text to the clipboard with a success toast, surfacing
* `writeText` rejections (permissions, unfocused document) as an error
* toast instead of an unhandled rejection.
*/
export function copyTextToClipboard(
text: string,
successMessage = "Copied to clipboard",
) {
void navigator.clipboard
.writeText(text)
.then(() => {
toast.success(successMessage);
})
.catch(() => {
toast.error("Failed to copy to clipboard");
});
}