@@ -20,6 +20,7 @@ import {
20
20
} from './Chat' ;
21
21
import { StylesContext } from './Styles' ;
22
22
import { FeedbackContext } from './Feedback' ;
23
+ import Clipboard from '@react-native-clipboard/clipboard' ;
23
24
24
25
type AiImageResponseProps = {
25
26
imageUrl ?: string ;
@@ -116,16 +117,17 @@ function AiTextResponse({text}: AiTextResponseProps): JSX.Element {
116
117
117
118
type AiSectionProps = PropsWithChildren < {
118
119
isLoading ?: boolean ;
120
+ copyValue ?: string ;
119
121
contentShownOnHover ?: JSX . Element ;
120
122
} > ;
121
- function AiSection ( { children, isLoading, contentShownOnHover} : AiSectionProps ) : JSX . Element {
123
+ function AiSection ( { children, isLoading, copyValue , contentShownOnHover} : AiSectionProps ) : JSX . Element {
122
124
const feedbackContext = React . useContext ( FeedbackContext ) ;
123
125
const styles = React . useContext ( StylesContext ) ;
124
126
const [ hovering , setHovering ] = React . useState ( false ) ;
125
127
126
128
const showFeedbackPopup = ( positive : boolean ) => {
127
129
if ( feedbackContext ) {
128
- feedbackContext . showFeedback ( positive ) ;
130
+ feedbackContext . showFeedback ( positive , copyValue ) ;
129
131
}
130
132
}
131
133
@@ -137,7 +139,7 @@ function AiSection({children, isLoading, contentShownOnHover}: AiSectionProps):
137
139
< View style = { { flexDirection : 'row' } } >
138
140
< Text style = { [ styles . sectionTitle , { flexGrow : 1 } ] } > AI</ Text >
139
141
{ hovering && contentShownOnHover }
140
- { hovering && < HoverButton content = "📋" tooltip = "Copy to clipboard" onPress = { ( ) => console . log ( "Copy: Not yet implemented" ) } /> }
142
+ { hovering && copyValue && < HoverButton content = "📋" tooltip = "Copy to clipboard" onPress = { ( ) => Clipboard . setString ( copyValue ) } /> }
141
143
< HoverButton content = "👍" tooltip = "Give positive feedback" onPress = { ( ) => { showFeedbackPopup ( true ) ; } } />
142
144
< HoverButton content = "👎" tooltip = "Give negative feedback" onPress = { ( ) => { showFeedbackPopup ( false ) ; } } />
143
145
</ View >
@@ -158,7 +160,7 @@ type AiSectionContentProps = {
158
160
function AiSectionContent ( { id, content} : AiSectionContentProps ) : JSX . Element {
159
161
const chatHistory = React . useContext ( ChatHistoryContext ) ;
160
162
return (
161
- < AiSection >
163
+ < AiSection copyValue = { content . text } >
162
164
{ ( ( ) => {
163
165
switch ( content . contentType ) {
164
166
case ChatContent . Error :
0 commit comments