Skip to content
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

Exmaple of link handling #195

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ To get if the current selection is a link, use `RichTextState.isLink`:
val isLink = richTextState.isLink
```

By default, links will be opened by your platform's `UriHandler`, if however you want to
handle the links on your own, you can override the composition local as such:

```kotlin
val myUriHandler by remember {
mutableStateOf(object : UriHandler {
override fun openUri(uri: String) {
// Handle the clicked link however you want
}
})
}
CompositionLocalProvider(LocalUriHandler provides myUriHandler) {
RichText( ... )
}
```

#### Add Code Blocks

To add code blocks, `RichTextState` provides `toggleCodeSpan` method:
Expand Down
Loading