Skip to content

Commit

Permalink
Support UrlAnnotation and LinkAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanstern authored and saket committed Aug 11, 2024
1 parent 2a79eb3 commit 7c2b3d8
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.buildAnnotatedString
import me.saket.extendedspans.internal.fastFold
Expand Down Expand Up @@ -47,6 +48,16 @@ class ExtendedSpans(
text.getTtsAnnotations(start = 0, end = text.length).fastForEach {
addTtsAnnotation(it.item, it.start, it.end)
}
@Suppress("DEPRECATION")
text.getUrlAnnotations(start = 0, end = text.length).fastForEach {
addUrlAnnotation(it.item, it.start, it.end)
}
text.getLinkAnnotations(start = 0, end = text.length).fastForEach { range ->
when (val item = range.item) {
is LinkAnnotation.Url -> addLink(item, range.start, range.end)
is LinkAnnotation.Clickable -> addLink(item, range.start, range.end)
}
}
}
}

Expand Down

0 comments on commit 7c2b3d8

Please sign in to comment.