mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-16 08:31:57 +02:00
23 lines
528 B
TypeScript
23 lines
528 B
TypeScript
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",
|
|
});
|
|
}
|
|
}
|