snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
This commit is contained in:
22
apps/yaak-client/lib/copy.ts
Normal file
22
apps/yaak-client/lib/copy.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { showToast } from "./toast";
|
||||
import { platform } from "@yaakapp-internal/platform";
|
||||
|
||||
export function copyToClipboard(
|
||||
text: string | null,
|
||||
{ disableToast }: { disableToast?: boolean } = {},
|
||||
) {
|
||||
if (text == null) {
|
||||
platform.clipboard.clear().catch(console.error);
|
||||
} else {
|
||||
platform.clipboard.writeText(text).catch(console.error);
|
||||
}
|
||||
|
||||
if (text !== "" && !disableToast) {
|
||||
showToast({
|
||||
id: "copied",
|
||||
color: "success",
|
||||
icon: "copy",
|
||||
message: "Copied to clipboard",
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user