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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-clipboard-api

v1.0.1

Published

Clipboard copy and paste plugin for Cordova/PhoneGap that supports text, images and urls for iOS, Android.

Downloads

40

Readme

Cordova Clipboard API

npm version

Clipboard management plugin for Cordova/PhoneGap that supports images, text and urls for iOS. Android support is limited to text content only.

Installation

cordova plugin add cordova-clipboard-api

The plugin creates the object cordova.plugins.clipboard with the methods copy(options, callback), paste(callback) and clear().

Methods

Copy()

copy(options, callback)

The options object contains two properties: type and data.

  • type - One of "text", "url" or "image"
  • data - Data to be sent to clipboard

Callback will contain an object:

{
	type: "ex: text", // type value submitted to plugin
	data: "ex: Howdy Partner!", // data submitted to plugin
	error: false // false if successful. Exception text if not.
}

Copy Text (iOS/Android)

window.cordova.plugins.clipboard.copy({
	type: "text", // default, so not needed for text
	data: "Howdy Partner!"
}, (res) => {
	console.log(res);
});

Copy URL (iOS only)

window.cordova.plugins.clipboard.copy({
	type: "url",
	data: "https://yesorno.io/"
}, (res) => {
	console.log(res.type);
});

Copy Image (iOS only)

NOTE: Only tested with remote URLs so far.

let imageUrl = "https://placedog.net/500";

// get blob of image (example only, use whatever method you like!)
fetch(url)
.then((response) => {
	return response.blob();
}).then((blob) => {
	let reader = new FileReader() ;
	reader.onload = (res) => { 
		window.cordova.plugins.clipboard.copy({
			type: 'image',
			data: res.target.result
		}, (res) => {
			console.log(res);
		});
	};
	reader.readAsDataURL(blob) ;
});

Paste()

paste(callback)

Callback will contain an object:

{
	type: "ex: text", // type of data coming from clipboard
	data: "ex: Howdy Partner!", // data coming from clipboard
}

NOTE: Pasted images in iOS will always be base64-encoded string. Example: data:image/png;base64,iVBORw0KGgoAAAAN...

Paste Data from Clipboard

window.cordova.plugins.clipboard.paste((res) => {
	if(res.type == "text"){
		this.text = res.data;
	}
});

clear()

clear()

Clear Data from Clipboard

window.cordova.plugins.clipboard.clear();

Notes

Testing

  • This plugin hasn't been tested on a ton of physical devices yet. Please file an issue should you find a bug!

iOS

  • The minimum supported version of iOS is v7.0.

Android

  • Android version only supports text content.
  • The minimum supported API Level is 11. Make sure that minSdkVersion is larger or equal to 11 in AndroidManifest.xml.

Acknowledgements

This plugin began as a fork of CordovaClipboard which was inspired by ClipboardManagerPlugin (Android) and ClipboardPlugin (iOS).

This plugin adds support for urls and images (iOS only) as well as provides a more complete callback object with error handling.

License

The MIT License (MIT)

Copyright (c) 2020 Michael Wuori

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.