├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── codeql.yml ├── .gitignore ├── .travis.yml ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── bower.json ├── dist ├── copee.d.ts ├── copee.js ├── copee.mjs └── copee.umd.js ├── docs ├── CNAME ├── iife.js ├── index.html ├── mod.mjs └── script.js ├── package-lock.json ├── package.json ├── replace.sh ├── src └── copee.ts └── tsconfig.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | schedule: 9 | - cron: "36 19 * * 6" 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | language: [ javascript ] 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v3 28 | 29 | - name: Initialize CodeQL 30 | uses: github/codeql-action/init@v2 31 | with: 32 | languages: ${{ matrix.language }} 33 | queries: +security-and-quality 34 | 35 | - name: Autobuild 36 | uses: github/codeql-action/autobuild@v2 37 | 38 | - name: Perform CodeQL Analysis 39 | uses: github/codeql-action/analyze@v2 40 | with: 41 | category: "/language:${{ matrix.language }}" 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node.js 2 | node_modules 3 | debug.log 4 | 5 | # Windows image file caches 6 | Thumbs.db 7 | ehthumbs.db 8 | 9 | # Folder config file 10 | Desktop.ini 11 | 12 | # Recycle Bin used on file shares 13 | $RECYCLE.BIN/ 14 | 15 | # Windows Installer files 16 | *.cab 17 | *.msi 18 | *.msm 19 | *.msp 20 | 21 | # Windows shortcuts 22 | *.lnk 23 | 24 | # ========================= 25 | # Operating System Files 26 | # ========================= 27 | 28 | # OSX 29 | # ========================= 30 | 31 | .DS_Store 32 | .AppleDouble 33 | .LSOverride 34 | 35 | # Thumbnails 36 | ._* 37 | 38 | # Files that might appear on external disk 39 | .Spotlight-V100 40 | .Trashes 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | branches: 2 | only: 3 | - "main" 4 | 5 | git: 6 | depth: 5 7 | 8 | language: node_js 9 | 10 | node_js: 11 | - "12" 12 | 13 | script: 14 | - npm run build 15 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "./node_modules/typescript/lib", 3 | "files.exclude": { 4 | "**/.git": true, 5 | "**/.svn": true, 6 | "**/.hg": true, 7 | "**/CVS": true, 8 | "**/.DS_Store": true, 9 | "node_modules": true 10 | } 11 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Steven 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # copee 2 | 3 | [![npm](https://badgen.net/npm/v/copee)](https://www.npmjs.com/package/copee) 4 | [![size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/copee/dist/copee.umd.js)](https://cdn.jsdelivr.net/npm/copee/dist/copee.umd.js) 5 | [![install size](https://badgen.net/packagephobia/install/copee)](https://packagephobia.now.sh/result?p=copee) 6 | [![Downloads](https://badgen.net/npm/dt/copee)](https://www.npmjs.com/package/copee) 7 | [![Dependency Status](https://badgen.net/david/dep/styfle/copee)](https://david-dm.org/styfle/copee) 8 | [![devDependency Status](https://badgen.net/david/dev/styfle/copee)](https://david-dm.org/styfle/copee?type=dev) 9 | [![Build Status](https://badgen.net/travis/styfle/copee)](https://travis-ci.org/styfle/copee) 10 | 11 | Copy text from browser to clipboard...natively! Less than 1 kB! 12 | 13 | Have you ever wanted to send a string to the user's clipboard? Front-end developers have invented many hacks to get around this limitation...until now! 14 | 15 | Introducing `copee`, a micro-wrapper around the browser's native "copy text" API 🗜️ 16 | 17 | Death to Adobe Flash 💀 18 | 19 | ## Demo 20 | 21 | [Try the demo](https://copee.ceriously.com/) to see `copee` in action! 22 | 23 | You can view the page source to quickly learn how to use it. 24 | 25 | Also, read [this blog post](https://styfle.dev/blog/es6-modules-today-with-typescript) for some background. 26 | 27 | ## Browser ESM Usage 28 | 29 | ```html 30 | 40 | ``` 41 | 42 | ## Browser UMD Usage 43 | 44 | ```html 45 | 46 | 54 | ``` 55 | 56 | ## Browser Suppport 57 | 58 | - UMD (`.js`) supports IE 11+, Chrome 43+, Opera 29+, and Firefox 41+ 59 | - ESM ([.mjs](https://caniuse.com/#feat=es6-module)) supports Chrome 61+, Safari 10.1+, Edge 16+, and Firefox 60+ 60 | 61 | ## Prior Art 62 | 63 | This package was influenced by the following: 64 | 65 | - [Google Dev Blog](https://developers.google.com/web/updates/2015/04/cut-and-copy-commands) 66 | - [Mozilla Hacks](https://hacks.mozilla.org/2015/09/flash-free-clipboard-for-the-web/) 67 | - [StackOverflow](https://stackoverflow.com/a/30810322/266535) 68 | 69 | ## Authors 70 | 71 | Developed by [styfle](https://styfle.dev) 72 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "copee", 3 | "version": "0.0.1", 4 | "description": "Copy text from browser to clipboard...natively!", 5 | "main": "copee.js", 6 | "keywords": [ 7 | "copy" 8 | ], 9 | "authors": [ 10 | "styfle" 11 | ], 12 | "license": "MIT", 13 | "homepage": "http://copee.ceriously.com/", 14 | "repository": { 15 | "type": "git", 16 | "url": "git://github.com/styfle/copee.git" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /dist/copee.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copy text to the user's clipboard 3 | */ 4 | export declare function toClipboard(text: string): boolean; 5 | /** 6 | * Copy text from an input/textarea element to a user's clipboard 7 | * @param el The or