Skip to content

Commit

Permalink
Make Markdown components not show I-Beams on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Feb 15, 2024
1 parent 7a159e4 commit 9802e5c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ public open class DefaultMarkdownBlockRenderer(
Text(
text = "$number${block.delimiter}",
style = styling.numberStyle,
modifier = Modifier.widthIn(min = styling.numberMinWidth),
modifier = Modifier.widthIn(min = styling.numberMinWidth)
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
textAlign = styling.numberTextAlign,
)

Expand All @@ -317,7 +318,11 @@ public open class DefaultMarkdownBlockRenderer(
) {
for (item in block.items) {
Row {
Text(text = styling.bullet.toString(), style = styling.bulletStyle)
Text(
text = styling.bullet.toString(),
style = styling.bulletStyle,
modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)

Spacer(Modifier.width(styling.bulletContentGap))

Expand Down Expand Up @@ -348,10 +353,14 @@ public open class DefaultMarkdownBlockRenderer(
isScrollable = styling.scrollsHorizontally,
Modifier.background(styling.background, styling.shape)
.border(styling.borderWidth, styling.borderColor, styling.shape)
.pointerHoverIcon(PointerIcon.Default, true)
.then(if (styling.fillWidth) Modifier.fillMaxWidth() else Modifier),
) {
Text(block.content, style = styling.textStyle, modifier = Modifier.padding(styling.padding))
Text(
text = block.content,
style = styling.textStyle,
modifier = Modifier.padding(styling.padding)
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)
}
}

Expand All @@ -361,7 +370,6 @@ public open class DefaultMarkdownBlockRenderer(
isScrollable = styling.scrollsHorizontally,
Modifier.background(styling.background, styling.shape)
.border(styling.borderWidth, styling.borderColor, styling.shape)
.pointerHoverIcon(PointerIcon.Default, true)
.then(if (styling.fillWidth) Modifier.fillMaxWidth() else Modifier),
) {
Column(Modifier.padding(styling.padding)) {
Expand All @@ -375,7 +383,11 @@ public open class DefaultMarkdownBlockRenderer(
)
}

Text(block.content, style = styling.textStyle)
Text(
text = block.content,
style = styling.textStyle,
modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)

if (block.mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Bottom) {
FencedBlockInfo(
Expand Down Expand Up @@ -407,7 +419,9 @@ public open class DefaultMarkdownBlockRenderer(
// TODO implement image rendering support (will require image loading)
Text(
"⚠️ Images are not supported yet",
Modifier.border(1.dp, Color.Red).padding(horizontal = 8.dp, vertical = 4.dp),
Modifier.border(1.dp, Color.Red)
.padding(horizontal = 8.dp, vertical = 4.dp)
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
color = Color.Red,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.unit.LayoutDirection.Ltr
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.theme.LocalContentColor
Expand Down Expand Up @@ -106,7 +108,11 @@ public class GitHubAlertBlockRenderer(
LocalContentColor provides
styling.titleTextStyle.color.takeOrElse { LocalContentColor.current },
) {
Text(block.javaClass.simpleName, style = styling.titleTextStyle)
Text(
text = block.javaClass.simpleName,
style = styling.titleTextStyle,
modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)
}
}
CompositionLocalProvider(
Expand Down

0 comments on commit 9802e5c

Please sign in to comment.