Wrap chat markdown tables to the transcript width
Tables no longer scroll sideways: columns size to content and shrink to fit, wrapping cell text; an unbreakable token breaks inside its cell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,13 +11,14 @@ import 'chat_link_spans.dart';
|
||||
import 'chat_markdown.dart';
|
||||
import 'chat_markdown_cache.dart';
|
||||
import 'chat_message_bubble.dart';
|
||||
import 'chat_table_column_width.dart';
|
||||
|
||||
/// Renders one assistant text part with native text widgets and the host's own
|
||||
/// theme roles. Links (`http`, `https`, `mailto` and `www.` hosts only) open
|
||||
/// through [onOpenLink] when given, else the [ChatLinkScope] launcher, which by
|
||||
/// default opens them outside the app. No font family, size, colour or component
|
||||
/// dimension is overridden; code keeps its exact whitespace and scrolls
|
||||
/// sideways instead of widening the transcript.
|
||||
/// sideways instead of widening the transcript, while table cells wrap.
|
||||
class ChatMarkdownView extends StatefulWidget {
|
||||
const ChatMarkdownView({super.key, required this.text, this.onOpenLink});
|
||||
|
||||
@@ -176,24 +177,22 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
),
|
||||
);
|
||||
case MarkdownTable(header: final header, rows: final rows):
|
||||
return ChatTranscriptHorizontalScrollView(
|
||||
label: 'table',
|
||||
child: Table(
|
||||
defaultColumnWidth: const IntrinsicColumnWidth(),
|
||||
border: TableBorder.all(color: _dividerColor(context)),
|
||||
children: [
|
||||
// Cells wrap to the transcript width; the table never scrolls sideways.
|
||||
return Table(
|
||||
defaultColumnWidth: ChatTableColumnWidth(header.length),
|
||||
border: TableBorder.all(color: _dividerColor(context)),
|
||||
children: [
|
||||
TableRow(
|
||||
decoration: BoxDecoration(color: _headerFill(context)),
|
||||
children: [
|
||||
for (final cell in header) _cell(context, cell, header: true),
|
||||
],
|
||||
),
|
||||
for (final row in rows)
|
||||
TableRow(
|
||||
decoration: BoxDecoration(color: _headerFill(context)),
|
||||
children: [
|
||||
for (final cell in header) _cell(context, cell, header: true),
|
||||
],
|
||||
children: [for (final cell in row) _cell(context, cell)],
|
||||
),
|
||||
for (final row in rows)
|
||||
TableRow(
|
||||
children: [for (final cell in row) _cell(context, cell)],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
case MarkdownCode(language: final language, code: final code):
|
||||
final labelStyle = _roleStyle(
|
||||
|
||||
Reference in New Issue
Block a user