@@ -58,12 +58,26 @@ export const BotBubble = (props: Props) => {
5858 if ( el ) {
5959 el . innerHTML = Marked . parse ( props . message . message ) ;
6060
61- // Apply textColor to all links, headings, and other markdown elements
61+ // Apply textColor to all links, headings, and other markdown elements except code
6262 const textColor = props . textColor ?? defaultTextColor ;
63- el . querySelectorAll ( 'a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li, code, pre ' ) . forEach ( ( element ) => {
63+ el . querySelectorAll ( 'a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li' ) . forEach ( ( element ) => {
6464 ( element as HTMLElement ) . style . color = textColor ;
6565 } ) ;
6666
67+ // Code blocks (with pre) get white text
68+ el . querySelectorAll ( 'pre' ) . forEach ( ( element ) => {
69+ ( element as HTMLElement ) . style . color = '#FFFFFF' ;
70+ // Also ensure any code elements inside pre have white text
71+ element . querySelectorAll ( 'code' ) . forEach ( ( codeElement ) => {
72+ ( codeElement as HTMLElement ) . style . color = '#FFFFFF' ;
73+ } ) ;
74+ } ) ;
75+
76+ // Inline code (not in pre) gets green text
77+ el . querySelectorAll ( 'code:not(pre code)' ) . forEach ( ( element ) => {
78+ ( element as HTMLElement ) . style . color = '#4CAF50' ; // Green color
79+ } ) ;
80+
6781 // Set target="_blank" for links
6882 el . querySelectorAll ( 'a' ) . forEach ( ( link ) => {
6983 link . target = '_blank' ;
@@ -267,10 +281,25 @@ export const BotBubble = (props: Props) => {
267281 const setArtifactRef = ( el : HTMLSpanElement ) => {
268282 if ( el ) {
269283 const textColor = props . textColor ?? defaultTextColor ;
270- el . querySelectorAll ( 'a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li, code, pre' ) . forEach ( ( element ) => {
284+ // Apply textColor to all elements except code blocks
285+ el . querySelectorAll ( 'a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li' ) . forEach ( ( element ) => {
271286 ( element as HTMLElement ) . style . color = textColor ;
272287 } ) ;
273288
289+ // Code blocks (with pre) get white text
290+ el . querySelectorAll ( 'pre' ) . forEach ( ( element ) => {
291+ ( element as HTMLElement ) . style . color = '#FFFFFF' ;
292+ // Also ensure any code elements inside pre have white text
293+ element . querySelectorAll ( 'code' ) . forEach ( ( codeElement ) => {
294+ ( codeElement as HTMLElement ) . style . color = '#FFFFFF' ;
295+ } ) ;
296+ } ) ;
297+
298+ // Inline code (not in pre) gets green text
299+ el . querySelectorAll ( 'code:not(pre code)' ) . forEach ( ( element ) => {
300+ ( element as HTMLElement ) . style . color = '#4CAF50' ; // Green color
301+ } ) ;
302+
274303 el . querySelectorAll ( 'a' ) . forEach ( ( link ) => {
275304 link . target = '_blank' ;
276305 } ) ;
0 commit comments