File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ import { ref } from 'vue' ;
2+
3+ export type UseClipboardOptions = {
4+ source : string ;
5+ } ;
6+
7+ export function useClipboard ( { source } : UseClipboardOptions ) {
8+ const copied = ref ( false ) ;
9+
10+ const copy = async ( ) => {
11+ try {
12+ await navigator . clipboard . writeText ( source ) ;
13+ copied . value = true ;
14+ setTimeout ( ( ) => {
15+ copied . value = false ;
16+ } , 300 ) ;
17+ } catch ( err ) {
18+ console . error ( '[vue-json-pretty] Copy failed: ' , err ) ;
19+ }
20+ } ;
21+
22+ return {
23+ copy,
24+ } ;
25+ } ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ type UseErrorOptions = {
44 emitListener : boolean ;
55} ;
66
7- export default function useError ( message : string , { emitListener } : UseErrorOptions ) {
7+ export function useError ( message : string , { emitListener } : UseErrorOptions ) {
88 const emit = ( ) => {
99 throw new Error ( `[VueJsonPretty] ${ message } ` ) ;
1010 } ;
You can’t perform that action at this time.
0 commit comments