Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Clipboard API wrapper
tag: 0.0.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
History.md
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

Clipboard

Clipboard library.

Installation

$ component install component/clipboard

Example

var Clipboard = require('clipboard');

var clip = new Clipboard(window);

clip.on('paste', function(e){
  // file
  if (e.file) {
    console.log('paste file "%s"', e.file.name);
    e.file.toDataURL(function(err, url){
      var img = new Image;
      img.src = url;
      document.body.appendChild(img);
    });
    return;
  }

  if (e.html) {
    console.log('html "%s"', e.html);
  }

  if (e.plain) {
    console.log('plain "%s"', e.plain);
  }
});

clip.on('cut', function(){
  console.log('cut');
});

clip.on('copy', function(e){
  console.log('copy');
});

API

Files

Currently only a single file is exposed as e.file.

Strings

String pastes are assigned to e using their associated MIME subtype. For example a "text/plain" representation as e.plain, "text/html" as e.html etc.

Clipboard#bind()

Bind event handlers. This is done for you in the constructor.

Clipboard#unbind()

Unbind event handlers.

Links

License

MIT

Something went wrong with that request. Please try again.