feat: Add expandable collapsible component for improved content display
- Introduced `ExpandableCollapsible` component to manage the visibility of lengthy content, allowing users to toggle between expanded and collapsed views. - Updated `renderTestOutput` to utilize the new component for displaying test results, JSON outputs, and object representations, enhancing user experience by reducing clutter. - Enhanced `Markdown` component to support fenced code blocks, improving the rendering of code snippets with language labels and better styling. These changes improve the readability and organization of content within the application, providing users with a more interactive and manageable interface.
This commit is contained in:
1 parent
4b6e1bed11
commit
08c9cccdcc
2 files changed
+165
-52
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// Lightweight Markdown renderer – handles the subset used by the AI:
|
||||
// ## Headings, **bold**, bullet lists, numbered lists, line breaks
|
||||
// ## Headings, **bold**, bullet lists, numbered lists, fenced ``` code ```, line breaks
|
||||
|
||||
export default function Markdown({ text }) {
|
||||
if (!text) return null
|
||||
@@ -7,6 +7,19 @@ export default function Markdown({ text }) {
|
||||
const lines = text.split('\n')
|
||||
const elements = []
|
||||
let i = 0
|
||||
let blockId = 0
|
||||
|
||||
const codeBlockStyle = {
|
||||
margin: '10px 0',
|
||||
padding: 12,
|
||||
background: 'var(--surface2)',
|
||||
borderRadius: 8,
|
||||
border: '1px solid var(--border)',
|
||||
overflow: 'auto',
|
||||
fontSize: 12,
|
||||
lineHeight: 1.5,
|
||||
fontFamily: 'ui-monospace, Consolas, monospace'
|
||||
}
|
||||
|
||||
const parseLine = (line) => {
|
||||
// Parse inline **bold** and *italic*
|
||||
@@ -39,6 +52,44 @@ export default function Markdown({ text }) {
|
||||
while (i < lines.length) {
|
||||
const line = lines[i]
|
||||
|
||||
// Fenced code block: ``` or ```lang
|
||||
const trimmedStart = line.trimStart()
|
||||
if (trimmedStart.startsWith('```')) {
|
||||
const lang = trimmedStart.slice(3).trim() || null
|
||||
i++
|
||||
const codeLines = []
|
||||
while (i < lines.length) {
|
||||
if (lines[i].trim().startsWith('```')) {
|
||||
i++
|
||||
break
|
||||
}
|
||||
codeLines.push(lines[i])
|
||||
i++
|
||||
}
|
||||
const code = codeLines.join('\n')
|
||||
elements.push(
|
||||
<div key={`code-${blockId++}`} style={{ margin: '10px 0' }}>
|
||||
{lang && (
|
||||
<div
|
||||
style={{
|
||||
fontSize: 10,
|
||||
color: 'var(--text3)',
|
||||
marginBottom: 6,
|
||||
fontFamily: 'ui-monospace, monospace',
|
||||
letterSpacing: 0.02
|
||||
}}
|
||||
>
|
||||
{lang}
|
||||
</div>
|
||||
)}
|
||||
<pre style={codeBlockStyle}>
|
||||
<code style={{ color: 'var(--text1)', whiteSpace: 'pre', display: 'block' }}>{code}</code>
|
||||
</pre>
|
||||
</div>
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip empty lines (add spacing)
|
||||
if (line.trim() === '') {
|
||||
elements.push(<div key={i} style={{ height: 8 }} />)
|
||||
|
||||
Reference in new issue
Block a user