mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 18:06:39 +02:00
Fix for images are mixed with text in a single paragraph
nevent1qqs04pmdf8guxpyhjuvpeg72ccwuzje7vhlm09szxl2d8x28cse5fzgpz9mhxue69uhkummnw3ezuamfdejj7q3qwl89d7yazg500lehg08p45dj2jzhhyqg2erj067458e3wd30djnsxpqqqqqqzmdjgxd
This commit is contained in:
@@ -360,6 +360,8 @@ private fun renderParagraphWithFlowRow(
|
|||||||
|
|
||||||
// Check if this paragraph contains only images (ignoring whitespace)
|
// Check if this paragraph contains only images (ignoring whitespace)
|
||||||
val isImageOnlyParagraph = isImageOnlyParagraph(paragraph)
|
val isImageOnlyParagraph = isImageOnlyParagraph(paragraph)
|
||||||
|
// Check if this paragraph contains multiple images (mixed with text is ok)
|
||||||
|
val hasMultipleImages = hasMultipleImages(paragraph)
|
||||||
|
|
||||||
if (isImageOnlyParagraph && paragraph.words.isNotEmpty()) {
|
if (isImageOnlyParagraph && paragraph.words.isNotEmpty()) {
|
||||||
// Collect consecutive image-only paragraphs for gallery
|
// Collect consecutive image-only paragraphs for gallery
|
||||||
@@ -378,6 +380,13 @@ private fun renderParagraphWithFlowRow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return endIndex // Return next index to process
|
return endIndex // Return next index to process
|
||||||
|
} else if (hasMultipleImages && paragraph.words.isNotEmpty()) {
|
||||||
|
// Mixed paragraph with multiple images - use RenderWordsWithImageGallery for smart grouping
|
||||||
|
RenderWordsWithImageGallery(
|
||||||
|
paragraph.words.toImmutableList(),
|
||||||
|
context,
|
||||||
|
)
|
||||||
|
return paragraphIndex + 1 // Return next index to process
|
||||||
} else {
|
} else {
|
||||||
// Non-image paragraph - render normally with FlowRow
|
// Non-image paragraph - render normally with FlowRow
|
||||||
RenderSingleParagraphWithFlowRow(paragraph, paragraph.words.toImmutableList(), spaceWidth, context)
|
RenderSingleParagraphWithFlowRow(paragraph, paragraph.words.toImmutableList(), spaceWidth, context)
|
||||||
@@ -427,6 +436,15 @@ private fun isImageOnlyParagraph(paragraph: ParagraphState): Boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hasMultipleImages(paragraph: ParagraphState): Boolean {
|
||||||
|
// Count the number of image segments in the paragraph
|
||||||
|
val imageCount =
|
||||||
|
paragraph.words.count { word ->
|
||||||
|
word is ImageSegment || word is Base64Segment
|
||||||
|
}
|
||||||
|
return imageCount > 1
|
||||||
|
}
|
||||||
|
|
||||||
private fun collectConsecutiveImageParagraphs(
|
private fun collectConsecutiveImageParagraphs(
|
||||||
paragraphs: ImmutableList<ParagraphState>,
|
paragraphs: ImmutableList<ParagraphState>,
|
||||||
startIndex: Int,
|
startIndex: Int,
|
||||||
|
Reference in New Issue
Block a user