Browse Source

chore: remove cruft

Ryan Chandler 4 years ago
parent
commit
9c60d7bb3f
4 changed files with 3 additions and 124 deletions
  1. 0 17
      examples/ie11.html
  2. 3 3
      package.json
  3. 0 37
      rollup.ie11.config.js
  4. 0 67
      src/index.ie11.js

+ 0 - 17
examples/ie11.html

@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<head>
-    <title>Alpine Clipboard IE11</title>
-    <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.js" defer></script>
-</head>
-<body>
-    <div x-data="{ input: '' }">
-        <input x-model="input">
-        <button type="button" @click="$clipboard(input)">Copy to Clipboard</button>
-    </div>
-
-    <div x-data="{}">
-        <button type="button" @click="$clipboard(() => 'Testing')">Copy 'Testing' to Clipboard</button>
-    </div>
-
-    <script src="../dist/alpine-clipboard.ie11.js"></script>
-</body>

+ 3 - 3
package.json

@@ -1,15 +1,15 @@
 {
     "name": "@ryangjchandler/alpine-clipboard",
     "description": "Simply copy to the users clipboard in your Alpine.js components.",
-    "version": "1.0.0",
+    "version": "2.0.0",
     "license": "MIT",
     "author": "Ryan Chandler <support@ryangjchandler.co.uk>",
     "repository": {
         "type": "git",
         "url": "https://github.com/ryangjchandler/alpine-clipboard"
     },
-    "main": "dist/alpine-clipboard.ie11.js",
-    "module": "src/index.js",
+
+    "main": "src/index.js",
     "scripts": {
         "build": "rollup -c && rollup -c rollup.ie11.config.js",
         "watch": "rollup -c -w"

+ 0 - 37
rollup.ie11.config.js

@@ -1,37 +0,0 @@
-import babel from 'rollup-plugin-babel'
-import filesize from 'rollup-plugin-filesize'
-import resolve from 'rollup-plugin-node-resolve'
-
-export default {
-    input: 'src/index.ie11.js',
-    output: [
-        {
-            name: 'AlpineClipboard',
-            file: 'dist/alpine-clipboard.ie11.js',
-            format: 'umd',
-            sourcemap: true,
-        }
-    ],
-    plugins: [
-        resolve(),
-        filesize(),
-        babel({
-            exclude: 'node_modules/**',
-            babelrc: false,
-            presets: [
-                [
-                    '@babel/preset-env',
-                    {
-                        targets: {
-                            node: 'current',
-                            edge: '18',
-                            ie: '11',
-                            ios: '11.3',
-                            safari: '13'
-                        }
-                    }
-                ]
-            ]
-        })
-    ]
-}

+ 0 - 67
src/index.ie11.js

@@ -1,67 +0,0 @@
-const AlpineClipboard = {
-    start() {
-        if (!window.Alpine) {
-            throw new Error('Alpine is required for `alpine-clipboard` to work.')
-        }
-
-        Alpine.addMagicProperty('clipboard', () => {
-            return function (target) {
-                let value = target
-
-                if (typeof value === 'function') {
-                    value = value()
-                } else if (typeof value !== 'string') {
-                    try {
-                        value = JSON.stringify(value)
-                    } catch (e) {
-                        console.warn(e)
-                    }
-                }
-
-                const container = document.createElement('textarea')
-
-                container.value = value
-                container.setAttribute('readonly', '')
-                container.style.cssText = 'position:fixed;pointer-events:none;z-index:-9999;opacity:0;'
-
-                document.body.appendChild(container)
-
-                if (navigator.userAgent && navigator.userAgent.match(/ipad|ipod|iphone/i)) {
-                    container.contentEditable = true
-                    container.readOnly = true
-
-                    const range = document.createRange()
-
-                    range.selectNodeContents(container)
-
-                    const selection = window.getSelection()
-
-                    selection.removeAllRanges()
-                    selection.addRange(range)
-
-                    container.setSelectionRange(0, 999999)
-                } else {
-                    container.select()
-                }
-
-                try {
-                    document.execCommand('copy')
-                } catch (e) {
-                    console.warn(err)
-                }
-
-                document.body.removeChild(container)
-            }
-        })
-    }
-}
-
-const alpine = window.deferLoadingAlpine || ((callback) => callback())
-
-window.deferLoadingAlpine = function (callback) {
-    AlpineClipboard.start()
-
-    alpine(callback)
-}
-
-export default AlpineClipboard