@@ -3,6 +3,23 @@ import { useParams, useNavigate } from 'react-router-dom';
33import { getAgent , updateAgent , deleteAgent , getAgentConfig } from '../api/client.js' ;
44import { useI18n } from '../i18n/index.js' ;
55
6+ function copyText ( text : string ) {
7+ if ( navigator . clipboard ?. writeText ) {
8+ navigator . clipboard . writeText ( text ) . catch ( ( ) => fallbackCopy ( text ) ) ;
9+ } else {
10+ fallbackCopy ( text ) ;
11+ }
12+ }
13+ function fallbackCopy ( text : string ) {
14+ const ta = document . createElement ( 'textarea' ) ;
15+ ta . value = text ;
16+ ta . style . cssText = 'position:fixed;left:-9999px' ;
17+ document . body . appendChild ( ta ) ;
18+ ta . select ( ) ;
19+ document . execCommand ( 'copy' ) ;
20+ document . body . removeChild ( ta ) ;
21+ }
22+
623// βββ Provider & Model Presets (shared with Settings) βββββββββββββββββββββββββ
724
825interface ProviderPreset {
@@ -85,7 +102,7 @@ function CodeSnippet({ title, code }: { title: string; code: string }) {
85102 const { t } = useI18n ( ) ;
86103
87104 const handleCopy = ( ) => {
88- navigator . clipboard . writeText ( code ) ;
105+ copyText ( code ) ;
89106 setCopied ( true ) ;
90107 setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
91108 } ;
@@ -118,7 +135,7 @@ function StepBlock({ step, title, description, code, children, isLast }: {
118135
119136 const handleCopy = ( ) => {
120137 if ( ! code ) return ;
121- navigator . clipboard . writeText ( code ) ;
138+ copyText ( code ) ;
122139 setCopied ( true ) ;
123140 setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
124141 } ;
0 commit comments