25 lines
656 B
TypeScript
25 lines
656 B
TypeScript
import { clsx, type ClassValue } from "clsx"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function getErrorMessage(error: unknown, fallback: string) {
|
|
return error instanceof Error ? error.message : fallback;
|
|
}
|
|
|
|
export const stripHtml = (html: string) => {
|
|
return (html || "").replace(/<[^>]*>?/gm, '').trim();
|
|
};
|
|
|
|
export const copyToClipboard = async (text: string): Promise<boolean> => {
|
|
try {
|
|
await navigator.clipboard.writeText(text);
|
|
return true;
|
|
} catch (error) {
|
|
console.error("Copy error:", error);
|
|
return false;
|
|
}
|
|
};
|