0.9.1 β€’ Published 10 months ago

image-clipboard v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

image-clipboard

image-clipboard image-clipboard image-clipboard

English | δΈ­ζ–‡

πŸš€ Intro

  • get image from clipboard
  • upload image from paste event

πŸ¦„ Usage

import {useImageClipboard, usePasteUpload} from 'image-clipboard'

useImageClipboard

get image from clipboard

const {isSupported, getImage} = useImageClipboard({
    accepts: ['png', 'jpeg'],
    // success(file) {
    //     console.log(file)
    // }
})
getImage().then(async file => {
    console.log(file)
})

usePasteUpload

The paste operation will trigger the file upload event for the input element with the class .image-upload.

const {addEvent, removeEvent} = usePasteUpload({
    accepts: ['png', 'jpeg'],
    uploadClass: '.image-upload',
    // async success(file) {
    //     console.log(file)
    //     imagePaste.value = await getFileBase64(file?.[0])
    // }
})
onMounted(() => {
    addEvent()
})

onUnmounted(() => {
    removeEvent()
})

πŸ“¦ Install

pnpm

pnpm install image-clipboard --save
Demos

CDN

<script src="https://unpkg.com/image-clipboard"></script>

<script src="https://cdn.jsdelivr.net/npm/image-clipboard"></script>

It will be exposed to global as window.imageClipboard


CHANGELOG

0.9.1

10 months ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.0.1

1 year ago