界面:表格长文本列统一左对齐,保留名称与属性对齐

This commit is contained in:
2026-11-04 12:45:39 +08:00
parent 9f282baa95
commit 7357c309dd
13 changed files with 138 additions and 21 deletions
+4 -2
View File
@@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import { tableTextAlignment } from './tableTextAlignment';
import { sanitizeAnalysisDisplayText } from './analysisDisplayText';
import { analysisEvidenceParts } from './analysisEvidenceRefs';
@@ -132,9 +133,10 @@ export function AiMarkdown({ content, className, evidenceLabels, evidencePrefix,
index += 2;
const body: string[][] = [];
while (index < lines.length && lines[index].trim() && lines[index].includes('|')) body.push(tableCells(lines[index++]));
const alignments = headers.map((header, column) => tableTextAlignment(header, body.map(row => row[column])));
blocks.push(<div className="ai-markdown-table-wrap" key={`table-${blocks.length}`}><table>
<thead><tr>{!hasIndex && <th className="ai-markdown-index">序号</th>}{headers.map((cell, cellIndex) => <th key={cellIndex} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(cell, `th-${cellIndex}`)}</th>)}</tr></thead>
<tbody>{body.map((row, rowIndex) => <tr key={rowIndex}>{!hasIndex && <td className="ai-markdown-index">{rowIndex + 1}</td>}{headers.map((_, cellIndex) => <td key={cellIndex} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(row[cellIndex] || '', `td-${rowIndex}-${cellIndex}`)}</td>)}</tr>)}</tbody>
<thead><tr>{!hasIndex && <th className="ai-markdown-index">序号</th>}{headers.map((cell, cellIndex) => <th key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(cell, `th-${cellIndex}`)}</th>)}</tr></thead>
<tbody>{body.map((row, rowIndex) => <tr key={rowIndex}>{!hasIndex && <td className="ai-markdown-index">{rowIndex + 1}</td>}{headers.map((_, cellIndex) => <td key={cellIndex} style={{ textAlign: alignments[cellIndex] === 'left' ? 'left' : undefined }} className={hasIndex && cellIndex === 0 ? 'ai-markdown-index' : undefined}>{inline(row[cellIndex] || '', `td-${rowIndex}-${cellIndex}`)}</td>)}</tr>)}</tbody>
</table></div>);
if (tableNote) { blocks.push(note(tableNote)); tableNote = ''; }
continue;