File tree Expand file tree Collapse file tree 1 file changed +1
-27
lines changed
src/components/CopyCodeButton Expand file tree Collapse file tree 1 file changed +1
-27
lines changed Original file line number Diff line number Diff line change 1
- import React , { useState } from 'react ' ;
1
+ import { useState } from 'preact/hooks ' ;
2
2
import CircleButton from "../CircleButton" ;
3
3
4
4
interface CopyCodeButtonProps {
@@ -12,32 +12,6 @@ export const CopyCodeButton = ({ textToCopy }: CopyCodeButtonProps) => {
12
12
console . log ( 'Copy button clicked' ) ;
13
13
console . log ( 'Text to copy:' , textToCopy ) ;
14
14
15
- if ( ! navigator . clipboard ) {
16
- console . log ( 'Clipboard API not available, using fallback' ) ;
17
- // Fallback for older browsers
18
- const textArea = document . createElement ( "textarea" ) ;
19
- textArea . value = textToCopy ;
20
- textArea . style . position = "fixed" ;
21
- document . body . appendChild ( textArea ) ;
22
- textArea . focus ( ) ;
23
- textArea . select ( ) ;
24
-
25
- try {
26
- const result = document . execCommand ( 'copy' ) ;
27
- console . log ( 'Fallback copy result:' , result ) ;
28
- setIsCopied ( true ) ;
29
- setTimeout ( ( ) => {
30
- setIsCopied ( false ) ;
31
- console . log ( 'Copy state reset' ) ;
32
- } , 2000 ) ;
33
- } catch ( err ) {
34
- console . error ( 'Fallback copy failed:' , err ) ;
35
- }
36
-
37
- document . body . removeChild ( textArea ) ;
38
- return ;
39
- }
40
-
41
15
try {
42
16
console . log ( 'Using Clipboard API' ) ;
43
17
await navigator . clipboard . writeText ( textToCopy ) ;
You can’t perform that action at this time.
0 commit comments