Can you make accessible modifier for Table (and may be other UI components)? So if I want to set some modifiers I can't do it. For example:
BasicMarkdown(
astNode = astNode,
astBlockNodeComposer = rememberAstBlockNodeComposer( // Add custom astBlockNodeComposer here
modifier = Modifier
.horizontalScroll(state = rememberScrollState())
.widthIn(min = 240.dp, max = 480.dp), // Define tables width here
)
)
@Composable
internal fun rememberAstBlockNodeComposer(
modifier: Modifier = Modifier,
): AstBlockNodeComposer = remember {
object : AstBlockNodeComposer {
override fun predicate(astBlockNodeType: AstBlockNodeType): Boolean =
astBlockNodeType is AstTableRoot
@Composable
override fun RichTextScope.Compose(
astNode: AstNode,
visitChildren: @Composable ((AstNode) -> Unit),
) {
when (astNode.type) {
is AstTableRoot -> RenderTable(node = astNode, modifier = modifier) // There is no access here to RenderTable modifier in library
else -> {}
}
}
}
}
internal fun RichTextScope.RenderTable(
node: AstNode,
modifier: Modifier = Modifier,
) {
Table(
modifier = modifier, // And this modifier isn't accessible for library's users
headerRow = {
node.filterChildrenType<AstTableHeader>()
.firstOrNull()
?.filterChildrenType<AstTableRow>()
?.firstOrNull()
?.filterChildrenType<AstTableCell>()
?.forEach { tableCell ->
cell {
MarkdownRichText(tableCell)
}
}
}
) {
node.filterChildrenType<AstTableBody>()
.firstOrNull()
?.filterChildrenType<AstTableRow>()
?.forEach { tableRow ->
row {
tableRow.filterChildrenType<AstTableCell>()
.forEach { tableCell ->
cell {
MarkdownRichText(tableCell)
}
}
}
}
}
}
So we create copy of classes from library for modifier. IMHO, it's not the best way to do it but it works.
Hello, halilozercan!
Can you make accessible modifier for Table (and may be other UI components)? So if I want to set some modifiers I can't do it. For example:
So we create copy of classes from library for modifier. IMHO, it's not the best way to do it but it works.