mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-13 10:30:05 -04:00
Create Clipboard.svelte
This commit is contained in:
parent
a699273978
commit
9fd1e49044
5 changed files with 36 additions and 20 deletions
35
src/components/Clipboard.svelte
Normal file
35
src/components/Clipboard.svelte
Normal file
|
@ -0,0 +1,35 @@
|
|||
<script>
|
||||
import { onMount, tick, createEventDispatcher } from 'svelte'
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
export let text
|
||||
|
||||
let textarea
|
||||
|
||||
async function copy() {
|
||||
textarea.select()
|
||||
document.execCommand('Copy')
|
||||
await tick()
|
||||
textarea.blur()
|
||||
dispatch('copy')
|
||||
}
|
||||
</script>
|
||||
|
||||
<slot {copy} />
|
||||
<textarea bind:this={textarea} value={text} aria-hidden="true" />
|
||||
|
||||
<style>
|
||||
textarea {
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
border: none;
|
||||
display: block;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import Clipboard from 'svelte-clipboard'
|
||||
import Clipboard from '~/components/Clipboard.svelte'
|
||||
|
||||
export let text
|
||||
let showTooltip = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue