Socket
Socket
Sign inDemoInstall

copy-image-clipboard

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

## 2.0.1 - 2021-09-09
**Fixes**
- Improve documentation readability
## 2.0.0 - 2021-09-06

@@ -7,0 +13,0 @@

2

dist/index.browser.js

@@ -1,2 +0,2 @@

/* copy-image-clipboard 2.0.0 - Licensed MIT @ Luan Eduardo da Costa */
/* copy-image-clipboard 2.0.1 - Licensed MIT @ Luan Eduardo da Costa */
var CopyImageClipboard=function(n){"use strict";function t(n,t,o,e){return new(o||(o=Promise))((function(i,r){function c(n){try{a(e.next(n))}catch(n){r(n)}}function u(n){try{a(e.throw(n))}catch(n){r(n)}}function a(n){var t;n.done?i(n.value):(t=n.value,t instanceof o?t:new o((function(n){n(t)}))).then(c,u)}a((e=e.apply(n,t||[])).next())}))}function o(n){return t(this,void 0,void 0,(function*(){const t=yield fetch(`${n}`);return yield t.blob()}))}function e(n){return n.type.includes("jpeg")}function i(n){return n.type.includes("png")}function r(n){return t(this,void 0,void 0,(function*(){return new Promise((function(t,o){const e=document.createElement("img");e.crossOrigin="anonymous",e.src=n,e.onload=function(n){const o=n.target;t(o)},e.onabort=o,e.onerror=o}))}))}function c(n){return t(this,void 0,void 0,(function*(){return new Promise((function(t,o){const e=document.createElement("canvas"),i=e.getContext("2d");if(i){const{width:r,height:c}=n;e.width=r,e.height=c,i.drawImage(n,0,0,r,c),e.toBlob((function(n){n?t(n):o("Cannot get blob from image element")}),"image/png",1)}}))}))}function u(n){return t(this,void 0,void 0,(function*(){const t=URL.createObjectURL(n),o=yield r(t);return yield c(o)}))}function a(n){return t(this,void 0,void 0,(function*(){const t={[n.type]:n},o=new ClipboardItem(t);yield navigator.clipboard.write([o])}))}return n.canCopyImagesToClipboard=function(){var n;const t="undefined"!=typeof fetch,o="undefined"!=typeof ClipboardItem,e=!!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.write);return t&&o&&e},n.convertBlobToPng=u,n.copyBlobToClipboard=a,n.copyImageToClipboard=function(n){return t(this,void 0,void 0,(function*(){const t=yield o(n);if(e(t)){const n=yield u(t);return yield a(n),t}if(i(t))return yield a(t),t;throw new Error("Cannot copy this type of image to clipboard")}))},n.createImageElement=r,n.getBlobFromImageElement=c,n.getBlobFromImageSource=o,n.isJpegBlob=e,n.isPngBlob=i,n.requestClipboardWritePermission=function(){var n;return t(this,void 0,void 0,(function*(){if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.permissions)||void 0===n?void 0:n.query))return!1;const{state:t}=yield navigator.permissions.query({name:"clipboard-write"});return"granted"===t}))},Object.defineProperty(n,"__esModule",{value:!0}),n}({});
{
"name": "copy-image-clipboard",
"version": "2.0.0",
"version": "2.0.1",
"main": "dist/index.js",

@@ -28,3 +28,3 @@ "module": "dist/index.js",

"dev": "rollup --config -w",
"build": "yarn clean:dist && tsc && rollup --config --",
"build": "yarn clean:dist && tsc && rollup --config && exit 0",
"prepublishOnly": "yarn build",

@@ -40,3 +40,3 @@ "prepare": "husky install",

"*.{js,jsx,ts,tsx}": "jest --watchAll=false --findRelatedTests",
"src/index.ts": [
"{src/index.ts,package.json}": [
"yarn build",

@@ -43,0 +43,0 @@ "git add dist"

@@ -71,3 +71,3 @@ <h1 style="text-align: center">

**jsDelivr**
jsDelivr

@@ -137,3 +137,3 @@ ```javascript

Use this function to check synchronously in runtime if can copy images to clipboard. It checks if can use the Fetch API and the Clipboard API.
Use this function to synchronously check at runtime whether you can copy images to the clipboard. It checks if it can use the Fetch API and the Clipboard API.

@@ -152,3 +152,3 @@ ```javascript

- The permission to write data on the clipboard is granted automatically to pages when they are in the active tab, so generally you don't need to use this function.
- Permission to write data to the clipboard is automatically granted to pages when they are in the active tab, so generally you don't need to use this function.
- If the browser has not implemented the Permissions API yet, this function will return `false`. Check the browser compatibility here: [Permissions API Browser Compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API#browser_compatibility).

@@ -166,7 +166,7 @@

- React + TypeScript - [See in your browser](https://github.com/LuanEdCosta/copy-image-clipboard/tree/master/demo)
- React + TypeScript | [View Code](https://github.com/LuanEdCosta/copy-image-clipboard/tree/master/demo) - [View in Your Browser](https://luanedcosta.github.io/copy-image-clipboard/)
## :globe_with_meridians: Compatibility
This project uses the asynchronous Clipboard API and Fetch API. Most browsers already support these two APIs natively, but for the old ones such as Internet Explorer this library doesn't work and there is nothing you can do about it.
This project uses the asynchronous Clipboard API and Fetch API. Most browsers already support natively these two APIs, but for the old ones like Internet Explorer this library doesn't work and there's nothing you can do about it.

@@ -186,11 +186,11 @@ Use the links below to see the browser compatibility:

**For now you can copy only JPG and PNG images**
### For now you can copy only JPG and PNG images
Other image types are not supported. If you try to copy other type an error will be thrown.
**This library only works in pages with HTTPS**
### This library only works in pages with HTTPS
This limitation was defined by the browsers due to security risks involved when dealing with the user's clipboard.
**You can only copy an image in the user's active tab/document**
### You can only copy an image in the user's active tab/document

@@ -207,3 +207,3 @@ If the user is navigating in another tab and the copy function is called, an error will be thrown.

- [Create an issue](https://github.com/LuanEdCosta/copy-image-clipboard/issues) to suggest an improvement or to describe a bug.
- Read the [Contribution Guide](CONTRIBUTING.md) to see how to contribute with code.
- Read the [Contribution Guide](https://github.com/LuanEdCosta/copy-image-clipboard/blob/master/CONTRIBUTING.md) to see how to contribute with code.

@@ -210,0 +210,0 @@ ## :blue_book: License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc