npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bw-ui/datatable-clipboard

v1.0.2

Published

Copy/Paste plugin for @bw-ui/datatable - Excel compatible

Readme

@bw-ui/datatable-clipboard

Copy/Paste plugin for BWDataTable with Excel compatibility.

Features

  • 📋 Copy to Clipboard - Tab-separated format (Excel/Sheets compatible)
  • 📥 Paste from Clipboard - Parse and add rows from Excel/Sheets
  • ⌨️ Keyboard Shortcuts - Ctrl+C, Ctrl+V
  • 🎯 Smart Paste - Auto-detect headers, type conversion

Installation

npm install @bw-ui/datatable-clipboard

Usage

import { BWDataTable } from '@bw-ui/datatable';
import { ClipboardPlugin } from '@bw-ui/datatable-clipboard';

const table = new BWDataTable('#table', { data }).use(ClipboardPlugin, {
  copyHeaders: true, // Include headers when copying (default: true)
  shortcuts: true, // Enable Ctrl+C/V shortcuts (default: true)
});

// Copy selected rows
table.copy();

// Copy all visible rows
table.copyAll();

// Paste from clipboard
table.paste();

Options

| Option | Type | Default | Description | | ------------- | --------- | ------- | ------------------------------ | | copyHeaders | boolean | true | Include column headers in copy | | shortcuts | boolean | true | Enable keyboard shortcuts |

Keyboard Shortcuts

| Shortcut | Action | | ------------------ | -------------------- | | Ctrl+C / Cmd+C | Copy selected rows | | Ctrl+V / Cmd+V | Paste from clipboard |

API

Methods (added to table)

// Copy selected rows to clipboard
table.copy(); // Returns: boolean
table.copy(true); // Copy only selected (default)
table.copy(false); // Copy all visible rows

// Copy all visible rows
table.copyAll(); // Returns: boolean

// Paste from clipboard
table.paste(); // Adds rows to table

Events

// After copy
table.on('clipboard:copy', ({ count, text }) => {
  console.log(`Copied ${count} rows`);
  // text contains tab-separated data
});

// After paste
table.on('clipboard:paste', ({ rows, count, text }) => {
  console.log(`Pasted ${count} rows`);
  // rows contains parsed row objects
});

Copy Format

Data is copied as tab-separated values (TSV):

Name	Email	Salary
John	[email protected]	50000
Jane	[email protected]	60000

This format is compatible with:

  • Microsoft Excel
  • Google Sheets
  • Apple Numbers
  • LibreOffice Calc
  • Any TSV-compatible application

Paste Behavior

When pasting:

  1. Header Detection - If first row matches column headers, it's skipped
  2. Type Conversion - Numbers and booleans are automatically converted
  3. ID Generation - New rows get unique IDs (pasted_<timestamp>_<index>)
  4. Append Mode - Pasted rows are added to existing data

Supported Paste Sources

  • Excel (Ctrl+C from cells)
  • Google Sheets
  • TSV/CSV text
  • Any tab-separated or newline-separated data

Example: Copy/Paste Workflow

const table = new BWDataTable('#table', { data }).use(ClipboardPlugin);

// 1. User selects rows with checkboxes
// 2. User presses Ctrl+C
// 3. Data is copied to clipboard

table.on('clipboard:copy', ({ count }) => {
  showToast(`Copied ${count} rows`);
});

// 4. User opens Excel, pastes with Ctrl+V
// 5. User makes changes in Excel
// 6. User copies from Excel, comes back to table
// 7. User presses Ctrl+V

table.on('clipboard:paste', ({ count }) => {
  showToast(`Added ${count} rows`);
  table.scrollToBottom();
});

Example: Export Button

const table = new BWDataTable('#table', { data }).use(ClipboardPlugin);

document.getElementById('copyAll').addEventListener('click', () => {
  table.copyAll();
});

document.getElementById('copySelected').addEventListener('click', () => {
  const selected = table.getSelected();
  if (selected.length === 0) {
    alert('Select some rows first');
    return;
  }
  table.copy();
});

TypeScript

import { BWDataTable } from '@bw-ui/datatable';
import {
  ClipboardPlugin,
  ClipboardPluginOptions,
} from '@bw-ui/datatable-clipboard';

const options: ClipboardPluginOptions = {
  copyHeaders: true,
  shortcuts: true,
};

const table = new BWDataTable('#table', { data }).use(ClipboardPlugin, options);

table.on('clipboard:copy', ({ count, text }) => {
  // Typed event data
});

Browser Permissions

The Clipboard API requires:

  • HTTPS or localhost
  • User interaction (click, keyboard)
  • Browser permission (usually auto-granted)

If clipboard access fails, check browser console for permission errors.

License

MIT © BW UI