diff --git a/markdown/core/api/core.api b/markdown/core/api/core.api index d3a68a137..4f2bf74a6 100644 --- a/markdown/core/api/core.api +++ b/markdown/core/api/core.api @@ -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 (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 (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; diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/Markdown.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/Markdown.kt index 1fe15f369..d7288c40f 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/Markdown.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/Markdown.kt @@ -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) { diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer.kt index 26dfc56e5..2ed53289c 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer.kt @@ -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 -> { diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt index 4f0ea7757..10a657c67 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt @@ -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 }, ) } } diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownStyling.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownStyling.kt index 34cb39114..7ff64e74d 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownStyling.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownStyling.kt @@ -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, diff --git a/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api b/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api index 8c60a2415..f3ab48643 100644 --- a/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api +++ b/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api @@ -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; diff --git a/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/bridge/styling/BridgeMarkdownStyling.kt b/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/bridge/styling/BridgeMarkdownStyling.kt index b4e6c87e4..bf4a01996 100644 --- a/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/bridge/styling/BridgeMarkdownStyling.kt +++ b/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/bridge/styling/BridgeMarkdownStyling.kt @@ -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 diff --git a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api index a9383401b..6fdf4dcc1 100644 --- a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api +++ b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api @@ -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; diff --git a/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMarkdownStyling.kt b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMarkdownStyling.kt index c2f65096d..60db3f9aa 100644 --- a/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMarkdownStyling.kt +++ b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/standalone/styling/IntUiMarkdownStyling.kt @@ -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) diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/MarkdownView.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/MarkdownView.kt index fdd282da6..cd7a0b3cb 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/MarkdownView.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/MarkdownView.kt @@ -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, ) } } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/JewelReadme.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/JewelReadme.kt index ca83ee13f..e14adde22 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/JewelReadme.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/JewelReadme.kt @@ -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.0–2023.3.2 might or might not work. diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownEditor.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownEditor.kt index 9e5b7059d..08b3cd56b 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownEditor.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownEditor.kt @@ -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) - }, - ) - } } } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt index 072c29f53..8d8e7c567 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt @@ -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)) }, )