Implement proper Markdown link styling (#455)

We weren't using the TextLinkStyles provided by the LinkAnnotation API,
and as a result, our links weren't stateful. We were also not properly
setting a disabled colour — now we do.

Also changed, we force the Markdown text to not be focusable, even if it
is clickable, since we don't want it to get focused. Now only links are
focused while tabbing through Markdown.

This also removes some testing harness left around from #425, and that
we don't need anymore.

Note: links should have a border around them when they are focused, but
that's not possible with the Compose APIs. What we do instead is show
a subtle background color,
taken from the ActionButtons' hover and pressed states, for our focused
and pressed states, respectively.
GitOrigin-RevId: 8cd3eee5791dbdb5f4f96f4e569e1f28923d1619
This commit is contained in:
Sebastiano Poggi
2024-07-18 10:51:52 +02:00
committed by intellij-monorepo-bot
parent 453467b456
commit d5d59269db
13 changed files with 123 additions and 69 deletions

View File

@@ -509,12 +509,17 @@ public final class org/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer
public final class org/jetbrains/jewel/markdown/rendering/InlinesStyling {
public static final field $stable I
public static final field Companion Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;
public fun <init> (Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)V
public fun <init> (Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)V
public fun equals (Ljava/lang/Object;)Z
public final fun getEmphasis ()Landroidx/compose/ui/text/SpanStyle;
public final fun getInlineCode ()Landroidx/compose/ui/text/SpanStyle;
public final fun getInlineHtml ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLink ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLinkDisabled ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLinkFocused ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLinkHovered ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLinkPressed ()Landroidx/compose/ui/text/SpanStyle;
public final fun getLinkVisited ()Landroidx/compose/ui/text/SpanStyle;
public final fun getRenderInlineHtml ()Z
public final fun getStrongEmphasis ()Landroidx/compose/ui/text/SpanStyle;
public final fun getTextStyle ()Landroidx/compose/ui/text/TextStyle;

View File

@@ -87,7 +87,7 @@ public fun Markdown(
}
} else {
Column(
modifier.semantics { rawMarkdown = markdown },
modifier = modifier.semantics { rawMarkdown = markdown },
verticalArrangement = Arrangement.spacedBy(markdownStyling.blockVerticalSpacing),
) {
for (block in markdownBlocks) {

View File

@@ -6,6 +6,7 @@ import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.AnnotatedString.Builder
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import org.commonmark.renderer.text.TextContentRenderer
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
@@ -40,6 +41,15 @@ public open class DefaultInlineMarkdownRenderer(
enabled: Boolean,
onUrlClicked: ((String) -> Unit)? = null,
) {
// TODO move to InlineMarkdown to avoid recomputing after #416 is done
val linkStyling =
TextLinkStyles(
styling.link,
styling.linkFocused,
styling.linkHovered,
styling.linkPressed,
)
for (child in inlineMarkdown) {
when (child) {
is InlineMarkdown.Text -> append(child.nativeNode.literal)
@@ -62,18 +72,21 @@ public open class DefaultInlineMarkdownRenderer(
}
is InlineMarkdown.Link -> {
withStyles(styling.link.withEnabled(enabled), child) {
val index =
if (enabled) {
val destination = it.nativeNode.destination
val destination = child.nativeNode.destination
val link =
LinkAnnotation.Clickable(
tag = destination,
linkInteractionListener = { _ -> onUrlClicked?.invoke(destination) },
styles = linkStyling,
)
pushLink(link)
} else {
pushStyle(styling.linkDisabled)
}
appendInlineMarkdownFrom(it.children, styling, enabled)
}
appendInlineMarkdownFrom(child.children, styling, enabled)
pop(index)
}
is InlineMarkdown.Code -> {

View File

@@ -34,6 +34,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
@@ -141,11 +142,13 @@ public open class DefaultMarkdownBlockRenderer(
Text(
modifier =
Modifier.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onTextClick,
),
Modifier
.focusProperties { canFocus = false }
.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onTextClick,
),
text = renderedContent,
style = mergedStyle,
)
@@ -212,6 +215,7 @@ public open class DefaultMarkdownBlockRenderer(
Text(
text = renderedContent,
style = mergedStyle,
modifier = Modifier.focusProperties { canFocus = false },
)
if (underlineWidth > 0.dp && underlineColor.isSpecified) {
@@ -295,6 +299,7 @@ public open class DefaultMarkdownBlockRenderer(
color = styling.numberStyle.color.takeOrElse { LocalContentColor.current },
modifier =
Modifier
.focusProperties { canFocus = false }
.widthIn(min = styling.numberMinWidth)
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
textAlign = styling.numberTextAlign,
@@ -333,7 +338,9 @@ public open class DefaultMarkdownBlockRenderer(
text = styling.bullet.toString(),
style = styling.bulletStyle,
color = styling.bulletStyle.color.takeOrElse { LocalContentColor.current },
modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
modifier =
Modifier.focusProperties { canFocus = false }
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)
Spacer(Modifier.width(styling.bulletContentGap))
@@ -384,7 +391,7 @@ public open class DefaultMarkdownBlockRenderer(
style = styling.editorTextStyle,
color = styling.editorTextStyle.color.takeOrElse { LocalContentColor.current },
modifier =
Modifier
Modifier.focusProperties { canFocus = false }
.padding(styling.padding)
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)
@@ -418,7 +425,9 @@ public open class DefaultMarkdownBlockRenderer(
text = block.content,
style = styling.editorTextStyle,
color = styling.editorTextStyle.color.takeOrElse { LocalContentColor.current },
modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
modifier =
Modifier.focusProperties { canFocus = false }
.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true),
)
if (block.mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Bottom) {
@@ -447,6 +456,7 @@ public open class DefaultMarkdownBlockRenderer(
text = infoText,
style = textStyle,
color = textStyle.color.takeOrElse { LocalContentColor.current },
modifier = Modifier.focusProperties { canFocus = false },
)
}
}

View File

@@ -269,6 +269,11 @@ public class InlinesStyling(
public val textStyle: TextStyle,
public val inlineCode: SpanStyle,
public val link: SpanStyle,
public val linkDisabled: SpanStyle,
public val linkFocused: SpanStyle,
public val linkHovered: SpanStyle,
public val linkPressed: SpanStyle,
public val linkVisited: SpanStyle,
public val emphasis: SpanStyle,
public val strongEmphasis: SpanStyle,
public val inlineHtml: SpanStyle,

View File

@@ -8,12 +8,12 @@ public final class org/jetbrains/jewel/intui/markdown/bridge/BridgeProvideMarkdo
}
public final class org/jetbrains/jewel/intui/markdown/bridge/styling/BridgeMarkdownStylingKt {
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;
public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph$Companion;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;
public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;

View File

@@ -371,19 +371,37 @@ public fun InlinesStyling.Companion.create(
color = JBUI.CurrentTheme.Link.Foreground.ENABLED.toComposeColor(),
textDecoration = TextDecoration.Underline,
).toSpanStyle(),
linkDisabled: SpanStyle = link.copy(color = JBUI.CurrentTheme.Link.Foreground.DISABLED.toComposeColor()),
linkHovered: SpanStyle = link.copy(color = JBUI.CurrentTheme.Link.Foreground.HOVERED.toComposeColor()),
linkFocused: SpanStyle =
link.copy(
color = JBUI.CurrentTheme.Link.Foreground.ENABLED.toComposeColor(),
background = JBUI.CurrentTheme.ActionButton.hoverBackground().toComposeColor(),
),
linkPressed: SpanStyle =
link.copy(
color = JBUI.CurrentTheme.Link.Foreground.PRESSED.toComposeColor(),
background = JBUI.CurrentTheme.ActionButton.pressedBackground().toComposeColor(),
),
linkVisited: SpanStyle = link.copy(color = JBUI.CurrentTheme.Link.Foreground.VISITED.toComposeColor()),
emphasis: SpanStyle = textStyle.copy(fontStyle = FontStyle.Italic).toSpanStyle(),
strongEmphasis: SpanStyle = textStyle.copy(fontWeight = FontWeight.Bold).toSpanStyle(),
inlineHtml: SpanStyle = textStyle.toSpanStyle(),
renderInlineHtml: Boolean = false,
): InlinesStyling =
InlinesStyling(
textStyle,
inlineCode,
link,
emphasis,
strongEmphasis,
inlineHtml,
renderInlineHtml,
textStyle = textStyle,
inlineCode = inlineCode,
link = link,
linkDisabled = linkDisabled,
linkHovered = linkHovered,
linkFocused = linkFocused,
linkPressed = linkPressed,
linkVisited = linkVisited,
emphasis = emphasis,
strongEmphasis = strongEmphasis,
inlineHtml = inlineHtml,
renderInlineHtml = renderInlineHtml,
)
private val defaultTextStyle

View File

@@ -11,12 +11,12 @@ public final class org/jetbrains/jewel/intui/markdown/standalone/IntUiProvideMar
}
public final class org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMarkdownStylingKt {
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;
public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph$Companion;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;
public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;
@@ -51,12 +51,12 @@ public final class org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMa
public static synthetic fun dark-pI2OzKA$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote$Companion;Landroidx/compose/foundation/layout/PaddingValues;FJLandroidx/compose/ui/graphics/PathEffect;IJILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;
public static final fun default-1Fc8zlc (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Image$Companion;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/ui/graphics/Shape;JFJ)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Image;
public static synthetic fun default-1Fc8zlc$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Image$Companion;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/ui/graphics/Shape;JFJILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Image;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Z)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;
public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph$Companion;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;
public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling$Companion;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;Landroidx/compose/ui/text/SpanStyle;ZILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;
public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H1;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H2;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H3;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H4;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H5;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$H6;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;
public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Companion;Landroidx/compose/ui/text/TextStyle;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;

View File

@@ -19,6 +19,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme
import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme
import org.jetbrains.jewel.intui.standalone.theme.createDefaultTextStyle
import org.jetbrains.jewel.intui.standalone.theme.createEditorTextStyle
import org.jetbrains.jewel.markdown.rendering.InlinesStyling
@@ -648,20 +650,33 @@ public fun InlinesStyling.Companion.light(
.copy(fontSize = textStyle.fontSize * .85, background = inlineCodeBackgroundColorLight)
.toSpanStyle(),
link: SpanStyle =
textStyle.copy(color = Color(0xFF0969DA), textDecoration = TextDecoration.Underline).toSpanStyle(),
textStyle.copy(
color = IntUiLightTheme.colors.blue(2),
textDecoration = TextDecoration.Underline,
).toSpanStyle(),
linkDisabled: SpanStyle = link.copy(color = IntUiLightTheme.colors.grey(8)),
linkHovered: SpanStyle = link,
linkFocused: SpanStyle = link.copy(background = Color(0x12000000)),
linkPressed: SpanStyle = link.copy(background = Color(0x1D000000)),
linkVisited: SpanStyle = link,
emphasis: SpanStyle = textStyle.copy(fontStyle = FontStyle.Italic).toSpanStyle(),
strongEmphasis: SpanStyle = textStyle.copy(fontWeight = FontWeight.Bold).toSpanStyle(),
inlineHtml: SpanStyle = textStyle.toSpanStyle(),
renderInlineHtml: Boolean = false,
): InlinesStyling =
InlinesStyling(
textStyle,
inlineCode,
link,
emphasis,
strongEmphasis,
inlineHtml,
renderInlineHtml,
textStyle = textStyle,
inlineCode = inlineCode,
link = link,
linkDisabled = linkDisabled,
linkFocused = linkFocused,
linkHovered = linkHovered,
linkPressed = linkPressed,
linkVisited = linkVisited,
emphasis = emphasis,
strongEmphasis = strongEmphasis,
inlineHtml = inlineHtml,
renderInlineHtml = renderInlineHtml,
)
public fun InlinesStyling.Companion.dark(
@@ -671,22 +686,33 @@ public fun InlinesStyling.Companion.dark(
.copy(fontSize = textStyle.fontSize * .85, background = inlineCodeBackgroundColorDark)
.toSpanStyle(),
link: SpanStyle =
textStyle
.copy(color = Color(0xFF2F81F7), textDecoration = TextDecoration.Underline)
.toSpanStyle(),
textStyle.copy(
color = IntUiDarkTheme.colors.blue(9),
textDecoration = TextDecoration.Underline,
).toSpanStyle(),
linkDisabled: SpanStyle = link.copy(color = IntUiDarkTheme.colors.grey(8)),
linkHovered: SpanStyle = link,
linkFocused: SpanStyle = link.copy(background = Color(0x16FFFFFF)),
linkPressed: SpanStyle = link.copy(background = Color(0x26FFFFFF)),
linkVisited: SpanStyle = link,
emphasis: SpanStyle = textStyle.copy(fontStyle = FontStyle.Italic).toSpanStyle(),
strongEmphasis: SpanStyle = textStyle.copy(fontWeight = FontWeight.Bold).toSpanStyle(),
inlineHtml: SpanStyle = textStyle.toSpanStyle(),
renderInlineHtml: Boolean = false,
): InlinesStyling =
InlinesStyling(
textStyle,
inlineCode,
link,
emphasis,
strongEmphasis,
inlineHtml,
renderInlineHtml,
textStyle = textStyle,
inlineCode = inlineCode,
link = link,
linkDisabled = linkDisabled,
linkFocused = linkFocused,
linkHovered = linkHovered,
linkPressed = linkPressed,
linkVisited = linkVisited,
emphasis = emphasis,
strongEmphasis = strongEmphasis,
inlineHtml = inlineHtml,
renderInlineHtml = renderInlineHtml,
)
private val blockBackgroundColorLight = Color(0xFFF6F8FA)

View File

@@ -24,11 +24,9 @@ import org.jetbrains.jewel.ui.component.Divider
fun MarkdownDemo() {
Row(Modifier.trackActivation().fillMaxSize().background(JewelTheme.globalColors.panelBackground)) {
var currentMarkdown by remember { mutableStateOf(JewelReadme) }
var linksAreEnabled by remember { mutableStateOf(true) }
MarkdownEditor(
currentMarkdown = currentMarkdown,
onMarkdownChange = { currentMarkdown = it },
onLinksEnabledChange = { linksAreEnabled = it },
modifier = Modifier.fillMaxHeight().weight(1f),
)
@@ -37,7 +35,6 @@ fun MarkdownDemo() {
MarkdownPreview(
modifier = Modifier.fillMaxHeight().weight(1f),
rawMarkdown = currentMarkdown,
linksAreEnabled = linksAreEnabled,
)
}
}

View File

@@ -120,7 +120,7 @@ include the `int-ui` module, which is always released from the main branch.
Releases of Jewel are always cut from a tag on the main branch; the HEAD of each `releases/xxx` branch is then tagged
as `[mainTag]-xxx`, and used to publish the artifacts for that major IJP version.
> ![IMPORTANT]
> [!IMPORTANT]
> We only support the latest build of IJP for each major IJP version. If the latest 233 version is 2023.3.3, for
> example, we will only guarantee that Jewel works on that. Versions 2023.3.02023.3.2 might or might not work.

View File

@@ -24,7 +24,6 @@ import com.darkrockstudios.libraries.mpfilepicker.JvmFile
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.StandaloneSampleIcons
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.Checkbox
import org.jetbrains.jewel.ui.component.Divider
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.OutlinedButton
@@ -36,14 +35,12 @@ import org.jetbrains.jewel.ui.component.TextArea
internal fun MarkdownEditor(
currentMarkdown: String,
onMarkdownChange: (String) -> Unit,
onLinksEnabledChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier) {
ControlsRow(
modifier = Modifier.fillMaxWidth().background(JewelTheme.globalColors.panelBackground).padding(8.dp),
onMarkdownChange = onMarkdownChange,
onLinksEnabledChange = onLinksEnabledChange,
)
Divider(orientation = Orientation.Horizontal)
Editor(
@@ -58,7 +55,6 @@ internal fun MarkdownEditor(
private fun ControlsRow(
modifier: Modifier = Modifier,
onMarkdownChange: (String) -> Unit,
onLinksEnabledChange: (Boolean) -> Unit,
) {
Row(
modifier.horizontalScroll(rememberScrollState()),
@@ -125,20 +121,6 @@ private fun ControlsRow(
}
}
}
var linksAreEnabled by remember { mutableStateOf(true) }
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Text("Links enabled")
Checkbox(
checked = linksAreEnabled,
onCheckedChange = {
linksAreEnabled = it
onLinksEnabledChange(it)
},
)
}
}
}

View File

@@ -45,7 +45,6 @@ import java.net.URI
internal fun MarkdownPreview(
modifier: Modifier = Modifier,
rawMarkdown: String,
linksAreEnabled: Boolean,
) {
val isDark = JewelTheme.isDark
@@ -99,7 +98,6 @@ internal fun MarkdownPreview(
contentPadding = PaddingValues(16.dp),
state = lazyListState,
selectable = true,
enabled = linksAreEnabled,
onUrlClick = { url -> Desktop.getDesktop().browse(URI.create(url)) },
)