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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rasamjs/clipboard

v0.3.1

Published

SVG clipboard commands for rasam drawings.

Readme

@rasamjs/clipboard

Copy, cut, paste, duplicate and delete SVG shapes in rasam drawings. The only runtime peer is @rasamjs/core (^0.3.0). Selection connects through a structural adapter; @rasamjs/selection is optional. @rasamjs/[email protected] is published.

import { SVG } from '@rasamjs/core';
import { Selection } from '@rasamjs/selection';
import { History } from '@rasamjs/history';
import { Clipboard } from '@rasamjs/clipboard';

const drawing = SVG(document.querySelector<HTMLElement>('#drawing')!);
const selection = new Selection(drawing);
const history = new History(drawing);
const clipboard = new Clipboard(drawing, selection);
clipboard.on('pasteerror', ({ error }) => console.warn('Paste rejected', error));
// Select shapes, then Ctrl/Cmd+C, X, V, D, Delete or Backspace.
clipboard.copy();
clipboard.paste();
clipboard.duplicate();

Keyboard copy/cut/paste use browser clipboard events and write both image/svg+xml and text/plain. Paste prefers SVG, then text, then the internal buffer. API calls use the buffer; copy/cut also try an optional navigator.clipboard.writeText() and ignore permission failures. Duplicate never touches the system clipboard or buffer. Focus in editable fields and handled events is ignored. With body focus, the first eligible clipboard instance handles an event; focus a drawing to address it explicitly.

Each drawing command is one undo step with history. Repeated pastes of the same content move 10 parent units right/down per paste; copy resets the step. Duplicate moves 10 units from the current selection. Set offset: 0 to paste in place. Clipboard contents and selection membership are not undo history.

Pass preparePaste: ({ nodes, source }) => { ... } to customize imported nodes before paste or duplicate commits. Naming and property changes join the insertion's undo step. The callback must be synchronous; throwing rolls back the model edit without changing selection or the next paste offset. The paste event remains a notification after commit.

Paste passes through core's passive SVG import policy, rejects external URLs by default, and remaps resource ids. Unsupported markup changes nothing. SVG document envelopes containing only viewport metadata are unwrapped into the destination scope; roots with presentation attributes or ids stay nested to preserve their meaning. Envelope dimensions are not a camera conversion. Copy keeps each shape's own geometry and transform, not its ancestors'. Defs remain alongside the pasted shapes in that scope. Nested SVG shapes inside a copied document retain their own viewport. Copy can export trusted content that the passive importer subsequently rejects (for example a foreignObject).

See API, release checks, changelog and the interactive example. Align/distribute live in selection's arrange entry.

Copy as PNG

Use copyImage(root, options) from @rasamjs/clipboard/raster for PNG with supported SVG representations, without changing selection or history. It follows core raster framing and image-origin rules; web fonts are not embedded. Call from a user gesture and handle rejected clipboard permission/rendering promises. See API.md.