Skip to content

Image not getting added in Compose #609

@vish-n-u

Description

@vish-n-u

I read the image support has been added in this package, I am using this version of the package :- com.mohamedrejeb.richeditor:richeditor-compose:1.0.0-rc10

Everything else is displayed as expected just the image is not showing I am not seeing any error in Logcat either

Image

@composable
fun ShowEditedScreen(text: String) {

val state = rememberRichTextState()

LaunchedEffect(Unit) {

    val htmlContent = """
        <h1>Welcome to My Article</h1>
        <p>This is a paragraph of text. Below is an image that should be displayed:</p>
        <img src="https://via.placeholder.com/400x200.png?text=Sample+Image" alt="A placeholder image" style="width:100%; max-width:400px; height:auto;">
        <p>Another paragraph following the image. You can also include local images if they are served via a local web server or a content provider that returns a URL.</p>
        <img src="https://via.placeholder.com/400x200.png?text=Test+Image" alt="Placeholder image">
        <p>End of content.</p>
    """.trimIndent()

    state.setHtml(htmlContent)
}

val titleSize = MaterialTheme.typography.displaySmall.fontSize
val subtitleSize = MaterialTheme.typography.titleLarge.fontSize

// Track selection changes to update controls
val selectionTracker = state.selection

RichText(
    modifier = Modifier
        .fillMaxWidth()
        .background(Color.Transparent),
    state = state,
)

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions