-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[JEWEL-941] Reducing space used by images on markdown image error #3285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
429a579 to
2c618eb
Compare
|
@faogustavo can you confirm the space under the title in the "after" screenshot is purely bottom padding of the title? I haven't looked at the code yet but it seems to me like we should not emit anything at all in the case where there is a paragraph that only contains an image that failed |
There is also an extra space from the empty line above and below the failed image. I'll check if I can "hide" that too |
|
Yeah, that's what I meant. Thanks :) |
2c618eb to
d8bb5db
Compare
I've pushed a second commit to this branch so we can discuss the solution. I'm kinda not that sure this is good enough, but I'm not able to think on other alternatives. Let me know your thoughts and I can squash the commits later |
rock3r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a legit implementation, I think you can squash
39fd0c2 to
608480f
Compare
608480f to
1f60a64
Compare
|
Ready to merge |
- When the line contains only images, replaced the Text component with FlowRow - Using a flow row we can skip the Paragraph component that was taking extra space
1f60a64 to
63bc89f
Compare
| inlineContent = images, | ||
| style = mergedStyle, | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Spacing lost when paragraph has only failed images
When a paragraph contains only images that all fail to load, RenderImages returns early without applying the modifier, causing spacing to be lost in LazyMarkdown. The modifier contains padding for block spacing, but when images.isEmpty() triggers the early return in RenderImages, this padding is never applied. This causes the spacing between blocks to collapse when a paragraph with only failed images is present in a LazyMarkdown context.
| val onlyImages = remember(block) { block.inlineContent.all { it is InlineMarkdown.Image } } | ||
| val images = renderedImages(block) | ||
|
|
||
| if (onlyImages && images.isEmpty()) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Spacing lost when heading has only failed images
When a heading contains only images that all fail to load, the function returns early without applying the modifier, causing spacing to be lost in LazyMarkdown. The modifier contains padding for block spacing, but the early return at line 281 prevents the Column from being created, so the modifier is never applied. This causes incorrect spacing between blocks in a LazyMarkdown context.
| } | ||
|
|
||
| return map | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Duplicate images not rendered in image-only blocks
When a paragraph or heading contains only images and multiple images share the same source URL, only one image is rendered instead of all of them. The renderedImages function uses a map keyed by image.source, so duplicate sources overwrite each other. When RenderImages iterates through this map, it only renders one image per unique source. For example,   would render only one image instead of two. This differs from the text path where duplicate images are rendered correctly.
Evidences
Release notes
Bug fixes
Note
Renders image-only paragraphs/headings without Text using a FlowRow, hides images that fail to load via a nullable image extension, and adjusts LazyMarkdown spacing with per-item padding.
RenderImages(aFlowRow), skippingText; headings early-return when images are absent.renderedImages: now maintains a mutable map and supports nullable images from extensions; removes entries on error.RenderImageshelper to lay out inline images using placeholder sizes.ImageRendererExtension.renderImageContentreturn type is nowInlineTextContent?to allow suppressing failed images.nullon load error; tracks loading/error state; preserves original-size placeholders on success.LazyMarkdown: switch toitemsIndexedand apply top/bottom padding per item instead of listverticalArrangement.Written by Cursor Bugbot for commit 63bc89f. This will update automatically on new commits. Configure here.