jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
508 stars 42 forks source link

Only set LinkResolver if the client explicitly requests to handle link clicks #48

Closed vikramatrbc closed 1 year ago

vikramatrbc commented 1 year ago

Description

Having markdown text like:

Click [here](https://something.con/)

And usage like:

MarkdownText(markdown = ...)

styles the link correctly, but does nothing when the link is clicked. Passing in onLinkClicked does trigger the callback:

MarkdownText(
    markdown = ...,
    onLinkClicked = { link -> println(...) }
)

but there's no default handling for the web url click.

Solution

Setting MarkwonConfiguration.Builder.linkResolver overrides Markwon's default behaviour - see LinkResolverDef and how it's used in MarkwonConfiguration.Builder. Proposed solution is to only configure a linkResolver if the client explicitly requests to handle link clicks i.e. when they pass in onLinkClicked.

Note: I believe this partially fixes https://github.com/jeziellago/compose-markdown/issues/46

zbencz3 commented 1 year ago

@jeziellago would you be able to take a look and see if this make sense for you? We would benefit from this change. Thanks 🙏