feat: implement clipboard utility for copying text and update components to use it

This commit is contained in:
Anders Böttcher
2026-05-13 17:19:43 +02:00
parent f7c52d0b1c
commit ffbbf1b6eb
3 changed files with 41 additions and 16 deletions
+5 -4
View File
@@ -2,6 +2,7 @@
import { useEffect, useState } from "react";
import { LINKS } from "@/lib/links";
import { copyText } from "@/lib/clipboard";
export interface TerminalLinks {
dockerImage?: string;
@@ -254,10 +255,10 @@ export default function TerminalTyper({ mode = "docker-run", links = {}, casaosM
.join("\n");
}
navigator.clipboard.writeText(textToCopy).then(() => {
copyText(textToCopy).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
});
}).catch(() => {});
};
const copyCasaOs = () => {
@@ -265,10 +266,10 @@ export default function TerminalTyper({ mode = "docker-run", links = {}, casaosM
const text = CASAOS_LINES.filter(line => line.type === "output")
.map(line => line.text)
.join("\n");
navigator.clipboard.writeText(text).then(() => {
copyText(text).then(() => {
setCopiedCasaOs(true);
setTimeout(() => setCopiedCasaOs(false), 2000);
});
}).catch(() => {});
};
useEffect(() => {