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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user