Skip to content

Commit f9e2c8b

Browse files
committed
white color within code block
1 parent cd5f068 commit f9e2c8b

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

dist/components/bubbles/BotBubble.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/bubbles/GuestBubble.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/bubbles/BotBubble.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,17 @@ 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 blocks
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+
// Always set code blocks text to white
68+
el.querySelectorAll('pre, code').forEach((element) => {
69+
(element as HTMLElement).style.color = '#FFFFFF';
70+
});
71+
6772
// Set target="_blank" for links
6873
el.querySelectorAll('a').forEach((link) => {
6974
link.target = '_blank';
@@ -267,10 +272,16 @@ export const BotBubble = (props: Props) => {
267272
const setArtifactRef = (el: HTMLSpanElement) => {
268273
if (el) {
269274
const textColor = props.textColor ?? defaultTextColor;
270-
el.querySelectorAll('a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li, code, pre').forEach((element) => {
275+
// Apply textColor to all elements except code blocks
276+
el.querySelectorAll('a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li').forEach((element) => {
271277
(element as HTMLElement).style.color = textColor;
272278
});
273279

280+
// Always set code blocks text to white
281+
el.querySelectorAll('pre, code').forEach((element) => {
282+
(element as HTMLElement).style.color = '#FFFFFF';
283+
});
284+
274285
el.querySelectorAll('a').forEach((link) => {
275286
link.target = '_blank';
276287
});

src/components/bubbles/GuestBubble.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ export const GuestBubble = (props: Props) => {
3131

3232
// Apply textColor to all links, headings, and other markdown elements
3333
const textColor = props.textColor ?? defaultTextColor;
34-
el.querySelectorAll('a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li, code, pre').forEach((element) => {
34+
el.querySelectorAll('a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li').forEach((element) => {
3535
(element as HTMLElement).style.color = textColor;
3636
});
3737

38+
// Always set code blocks text to white
39+
el.querySelectorAll('pre, code').forEach((element) => {
40+
(element as HTMLElement).style.color = '#FFFFFF';
41+
});
42+
3843
// Set target="_blank" for links
3944
el.querySelectorAll('a').forEach((link) => {
4045
link.target = '_blank';

0 commit comments

Comments
 (0)