Skip to content

Commit

Permalink
Merge pull request #230 from MohamedRejeb/1.x
Browse files Browse the repository at this point in the history
Update links docs
  • Loading branch information
MohamedRejeb authored Mar 31, 2024
2 parents e226fc1 + 2ad75a7 commit 3e2acb7
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions docs/links.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add links

To add links, `RichTextState` provides `addLink` method:
- To add links, `RichTextState` provides `addLink` method:

```kotlin
// Add link after selection.
Expand All @@ -10,13 +10,52 @@ richTextState.addLink(
)
```

To get if the current selection is a link, use `RichTextState.isLink`:
- To add link to the selected text, `RichTextState` provides `addLinkToSelection` method:

```kotlin
// Add link to selected text.
richTextState.addLinkToSelection(
url = "https://kotlinlang.org/"
)
```

- To update link URL, `RichTextState` provides `updateLink` method:

```kotlin
// Update selected link URL.
richTextState.updateLink(
url = "https://kotlinlang.org/"
)
```

- To remove links, `RichTextState` provides `removeLink` method:

```kotlin
// Remove link from selected text.
richTextState.removeLink()
```

- To get if the current selection is a link, use `RichTextState.isLink`:

```kotlin
// Get if the current selection is a link.
val isLink = richTextState.isLink
```

- To get the current link text, use `RichTextState.selectedLinkText`:

```kotlin
// Get the current link text.
val linkText = richTextState.selectedLinkText
```

- To get the current link URL, use `RichTextState.selectedLinkUrl`:

```kotlin
// Get the current link URL.
val linkUrl = richTextState.selectedLinkUrl
```

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:

Expand Down

0 comments on commit 3e2acb7

Please sign in to comment.