clipboard-pro
v1.0.0
Published
A modern Clipboard Utility Library for copying text, images, and HTML with history tracking and toast notifications.
Maintainers
Readme
clipboard-pro
A modern Clipboard Utility Library for copying text, images, and HTML with history tracking and toast notifications.
Features
- 📋 Copy text, images, and HTML to clipboard
- 📝 Clipboard history tracking (last 5 items)
- 🔔 Toast notifications for feedback
- 🔄 Fallback support for older browsers
- 📱 TypeScript support
- ⚛️ React hooks included
Installation
npm install clipboard-proUsage
import { copyText, copyImage, copyHTML, useClipboardHistory } from 'clipboard-pro';
// Copy text
await copyText('Hello, World!');
// Copy image
await copyImage('https://example.com/image.jpg');
// Copy HTML
await copyHTML('<h1>Hello</h1><p>This is HTML content</p>');
// Use clipboard history in React components
function MyComponent() {
const { history, copyFromHistory, clearHistory } = useClipboardHistory();
return (
<div>
{history.map(item => (
<div key={item.id}>
{item.content}
<button onClick={() => copyFromHistory(item.id)}>Copy</button>
</div>
))}
</div>
);
}API Reference
Functions
copyText(text: string, showFeedback?: boolean): Promise<boolean>copyImage(imageUrl: string, showFeedback?: boolean): Promise<boolean>copyHTML(htmlString: string, showFeedback?: boolean): Promise<boolean>
Hooks
useClipboardHistory(): { history: ClipboardHistoryItem[], copyFromHistory: (id: string) => Promise<boolean>, clearHistory: () => void }
License
MIT
