-
Notifications
You must be signed in to change notification settings - Fork 43
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
Load markdown images with Coil3 #327
base: main
Are you sure you want to change the base?
Conversation
markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
Outdated
Show resolved
Hide resolved
markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
Outdated
Show resolved
Hide resolved
98c42bc
to
806f009
Compare
57f2c0a
to
38797b6
Compare
38797b6
to
78a3bc9
Compare
/** | ||
* This method sets up an image loader with a memory cache but disables the disk cache. Disabling the disk cache is | ||
* necessary because Coil crashes when attempting to use the file system cache with IDEA platform. | ||
* | ||
* Otherwise Coil3 will throw java.lang.NoSuchMethodError: kotlinx.coroutines.CoroutineDispatcher.limitedParallelism | ||
*/ |
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.
Have you filed a Coil bug for this? Or is there a workaround, like moving the init to the bridge and standalone modules, handling things differently in each case? For what you write, disk caching should work fine in standalone as-is, and may require a different approach for the bridge, where we provide a custom implementation that works in IJP.
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.
My thought is that this issue is specific to our way of loading dependencies in ide-plugin(or kotlin versions). I think we can add a todo here to delete this invocation once we move Jewel to the platform, since this will likely streamline all dependencies.
This workaround is not needed for standalone mode.
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.
This workaround is not needed for standalone mode.
So it should only be done in the bridge version, and indeed we need an issue to track checking this again when we move to the IJP
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.
Markdown
is invoked directly from the example code. Do you know how to add it to the bridge only?
Additionally, if we change IDE vs Standalone behaviour, it would be much more difficult to figure out if something is wrong in one but works fine in another.
markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
Outdated
Show resolved
Hide resolved
.../core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt
Outdated
Show resolved
Hide resolved
.../core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt
Outdated
Show resolved
Hide resolved
.../core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt
Outdated
Show resolved
Hide resolved
model = | ||
ImageRequest.Builder(LocalPlatformContext.current).data(image.source).size(Size.ORIGINAL).build(), | ||
contentDescription = image.title, | ||
// TODO: figure out what to use instead of *.sp |
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.
Why are you not using dp?
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.
InlineTextContent
only accepts size in as a TextUnit
which is either em
or sp
. I'll change logic to use more advanced conversion.
I polished this logic a bit and added a comment, but I haven't figured out how to make Coil scale up images to the size of placeholder.
78a3bc9
to
f076393
Compare
) | ||
} | ||
) { | ||
AsyncImage( |
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.
BTW you need to make sure Ktor is initialised correctly (e.g., in the IDE it needs to respect the IDE proxy settings).
As a starting point, you can do something like this: https://gist.github.com/rock3r/6f633cb0e5b73625cc6ec0570896ff85
Of course this needs more work than just copy pasting it, but it should point you in the right direction
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.
as we discussed offline, it would be easier to do after the intellij-community
move
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.
Be warned you'll have to recreate the branch and PR on the IJ repo. You'll also need to manage both Gradle and JPS builds in parallel
@obask for inline images, you can probably take inspiration from https://github.com/halilozercan/compose-richtext/blob/main/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/string/InlineContent.kt |
It supports every image as inline
f076393
to
46f29ca
Compare
I think it does the same |
And I fixed images scaling, BTW. It shows them the same way as other markdown editors. |
No description provided.