1.2.6 • Published 9 months ago

copy-share v1.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

CopyShare Logo


CopyShare is a lightweight JavaScript library that provides easy and versatile clipboard operations. It allows you to copy text, code, images, video URLs, and links to the clipboard, with built-in error handling and history management.

Contributor Covenant Version License

Features

  • Copy Text: Safely copy plain text to the clipboard.

  • Copy Code: Copy code snippets with syntax sanitization.

  • Copy Image: Copy images directly to the clipboard or as URLs.

  • Copy Video URL: Copy video URLs to the clipboard.

  • Copy Link: Copy HTML links to the clipboard.

  • History Management: Track copied items and clear history.

Installation

To install CopyShare, use npm:

npm install copy-share

Quick Start

To quickly start using CopyShare in your web project:

  1. Add this script tag to your HTML:
<script type="module">
   import { copyText } from 'https://cdn.jsdelivr.net/npm/copy-share/copyShare.min.js';

   // Get the button element
   const btn = document.querySelector('#btn');

   // Add click event listener to the button
   btn.addEventListener('click', () => {
       // Get the text from the input element
       const text = document.querySelector('#text').value;
       // Copy the text to clipboard using copyText function
       copyText(text);
   });
</script>

Usage

Option 1: Import the Entire Library:

You can import the entire library and use the methods via the copyShare object:

import copyShare from 'copy-share';

copyShare.copyText('Hello, Adam!');

Option 2: Use Named Imports:

Alternatively, you can import specific methods directly:

import { copyText, copyCode } from 'copy-share';

copyText('Hello, Adam!');

copyCode('console.log("Hello, world!");', 'javascript');

Documentation

1.2.6

9 months ago

1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago