feat: enhance markdown image handling with customizable builder

- Introduced an `imageBuilderOverride` parameter in the `ConduitMarkdown` class to allow customization of how markdown images are rendered.
- Updated the `StreamingMarkdownWidget` to accept the new `imageBuilderOverride` parameter, enabling enhanced image handling in streaming contexts.
- Implemented an `imageBuilderOverride` in the `_AssistantMessageWidgetState` to utilize `EnhancedImageAttachment`, providing caching, authentication headers, and fullscreen viewing for markdown images.
- Refactored the `_ImageBuilder` class to support the new image building logic, improving flexibility and maintainability of image rendering in markdown content.
This commit is contained in:
cogwheel0
2025-10-10 16:12:31 +05:30
parent e73c5ee93a
commit 570fa26011
3 changed files with 28 additions and 6 deletions

View File

@@ -771,6 +771,16 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
content: processedContent,
isStreaming: widget.isStreaming,
onTapLink: (url, _) => _launchUri(url),
imageBuilderOverride: (uri, title, alt) {
// Route markdown images through the enhanced image widget so they
// get caching, auth headers, fullscreen viewer, and sharing.
return EnhancedImageAttachment(
attachmentId: uri.toString(),
isMarkdownFormat: true,
constraints: const BoxConstraints(maxWidth: 500, maxHeight: 400),
disableAnimation: widget.isStreaming,
);
},
);
final responseBuilder = ref.watch(assistantResponseBuilderProvider);