How to add clickable button for code section in for Markdown on Android Compose?


I use a halilibo Composable to render Markdown text:

build.gradle:

implementation 'com.halilibo.compose-richtext:richtext-ui-material3:1.0.0-alpha02'
implementation 'com.halilibo.compose-richtext:richtext-commonmark:1.0.0-alpha02'

My composable:

MarkdownText(
  text = message.content,
  modifier = Modifier.padding(12.dp),
  textColor = Color.White,
  linkColor = Color.White,
)

I'd like to add my "Apply the code" button that would use the provided code block. Since the composable uses SpannableString behind the scene, can I preprocess the message.content to add a button and handle the button click?

0
Apr 28 at 9:07 AM
User Avatar4ntoine
#android#richtext#spannablestring#compose

No answer found for this question yet.