import "@johnlindquist/kit";
const history = await getClipboardHistory();
let { value, type } = await arg("What to paste?", () => {
return history.map(({ value, type, timestamp, maybeSecret }) => {
const multilinePreview = value.includes("\n")
? `<div class="font-mono text-xs">${value
.split("\n")
.map((line) => `<p>${line}</p>`)
.join("")}<div>`
: null;
const preview = type === "image" ? `<img src="${value}" alt="${value}">` : multilinePreview;
return {
type,
name: maybeSecret ? value.slice(0, 2).padEnd(10, "*") : value,
value: {
value,
type,
},
description: timestamp,
preview,
};
});
});
if (type === "text") {
await setSelectedText(value);
}
if (type === "image") {
await copyPathAsImage(value);
await keystroke("command v");
}