Expand dark theme coverage across client UI
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createEffect, createSignal, onMount, onCleanup } from "solid-js"
|
||||
import { renderMarkdown, onLanguagesLoaded } from "../lib/markdown"
|
||||
import { renderMarkdown, onLanguagesLoaded, initMarkdown } from "../lib/markdown"
|
||||
import type { TextPart } from "../types/message"
|
||||
|
||||
interface MarkdownProps {
|
||||
@@ -15,11 +15,16 @@ export function Markdown(props: MarkdownProps) {
|
||||
createEffect(async () => {
|
||||
const part = props.part
|
||||
const text = part.text || ""
|
||||
const dark = Boolean(props.isDark)
|
||||
const themeKey = dark ? "dark" : "light"
|
||||
|
||||
latestRequestedText = text
|
||||
|
||||
if (part.renderCache && part.renderCache.text === text) {
|
||||
setHtml(part.renderCache.html)
|
||||
await initMarkdown(dark)
|
||||
|
||||
const cache = part.renderCache
|
||||
if (cache && cache.text === text && cache.theme === themeKey) {
|
||||
setHtml(cache.html)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,12 +33,13 @@ export function Markdown(props: MarkdownProps) {
|
||||
|
||||
if (latestRequestedText === text) {
|
||||
setHtml(rendered)
|
||||
part.renderCache = { text, html: rendered }
|
||||
part.renderCache = { text, html: rendered, theme: themeKey }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to render markdown:", error)
|
||||
if (latestRequestedText === text) {
|
||||
setHtml(text)
|
||||
part.renderCache = { text, html: text, theme: themeKey }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user