Skip to content

Commit 6bdbf93

Browse files
authored
Merge pull request #176 from mikepenz/develop
dev -> main
2 parents 669f4d2 + fc329c1 commit 6bdbf93

File tree

7 files changed

+25
-24
lines changed

7 files changed

+25
-24
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ allprojects {
2121
google()
2222
maven { setUrl("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
2323
maven { setUrl("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental") }
24-
maven("https://oss.sonatype.org/content/repositories/snapshots")
2524
}
2625
}
2726

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maven stuff
22
GROUP=com.mikepenz
3-
VERSION_NAME=0.22.0
4-
VERSION_CODE=2200
3+
VERSION_NAME=0.23.0
4+
VERSION_CODE=2300
55

66
POM_URL=https://github.com/mikepenz/multiplatform-markdown-renderer
77

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ compose = "1.6.8"
99
compose-plugin = "1.6.11"
1010
kotlin = "2.0.0"
1111
dokka = "1.9.20"
12-
coil = "3.0.0-SNAPSHOT"
12+
coil = "3.0.0-alpha07"
1313
coil2 = "2.6.0"
1414
aboutlib = "11.2.1"
1515
markdown = "0.7.3"

multiplatform-markdown-renderer-coil3/src/commonMain/kotlin/com/mikepenz/markdown/coil3/Coil3ImageTransformerImpl.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.mikepenz.markdown.coil3
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.runtime.LaunchedEffect
5+
import androidx.compose.runtime.collectAsState
56
import androidx.compose.runtime.getValue
67
import androidx.compose.runtime.mutableStateOf
78
import androidx.compose.runtime.remember
@@ -30,10 +31,10 @@ object Coil3ImageTransformerImpl : ImageTransformer {
3031
@Composable
3132
override fun intrinsicSize(painter: Painter): Size {
3233
var size by remember(painter) { mutableStateOf(painter.intrinsicSize) }
33-
3434
if (painter is AsyncImagePainter) {
35-
LaunchedEffect(painter.state) {
36-
painter.state.painter?.let {
35+
val painterState = painter.state.collectAsState()
36+
LaunchedEffect(painterState) {
37+
painterState.value.painter?.let {
3738
size = it.intrinsicSize
3839
}
3940
}

multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/compose/elements/MarkdownText.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import com.mikepenz.markdown.compose.elements.material.MarkdownBasicText
2727
import com.mikepenz.markdown.compose.extendedspans.ExtendedSpans
2828
import com.mikepenz.markdown.compose.extendedspans.drawBehind
2929
import com.mikepenz.markdown.model.rememberMarkdownImageState
30-
import com.mikepenz.markdown.utils.TAG_IMAGE_URL
31-
import com.mikepenz.markdown.utils.TAG_URL
30+
import com.mikepenz.markdown.utils.MARKDOWN_TAG_IMAGE_URL
31+
import com.mikepenz.markdown.utils.MARKDOWN_TAG_URL
3232

3333

3434
@Composable
@@ -86,12 +86,12 @@ fun MarkdownText(
8686
val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
8787
val imageState = rememberMarkdownImageState()
8888

89-
val hasUrl = content.getStringAnnotations(TAG_URL, 0, content.length).any()
89+
val hasUrl = content.getStringAnnotations(MARKDOWN_TAG_URL, 0, content.length).any()
9090
val textModifier = if (hasUrl) modifier.pointerInput(Unit) {
9191
detectTapGestures { pos ->
9292
layoutResult.value?.let { layoutResult ->
9393
val position = layoutResult.getOffsetForPosition(pos)
94-
content.getStringAnnotations(TAG_URL, position, position).reversed().firstOrNull()
94+
content.getStringAnnotations(MARKDOWN_TAG_URL, position, position).reversed().firstOrNull()
9595
?.let {
9696
val foundReference = referenceLinkHandler.find(it.item)
9797
try {
@@ -115,7 +115,7 @@ fun MarkdownText(
115115
.animateContentSize(),
116116
style = style,
117117
color = LocalMarkdownColors.current.text,
118-
inlineContent = mapOf(TAG_IMAGE_URL to InlineTextContent(
118+
inlineContent = mapOf(MARKDOWN_TAG_IMAGE_URL to InlineTextContent(
119119
Placeholder(
120120
width = imageState.imageSize.width.sp,
121121
height = imageState.imageSize.height.sp,

multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/utils/AnnotatedStringKtx.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import com.mikepenz.markdown.compose.LocalMarkdownAnnotator
1212
import com.mikepenz.markdown.compose.LocalMarkdownColors
1313
import org.intellij.markdown.MarkdownElementTypes
1414
import org.intellij.markdown.MarkdownTokenTypes
15-
import org.intellij.markdown.MarkdownTokenTypes.Companion.TEXT
1615
import org.intellij.markdown.ast.ASTNode
1716
import org.intellij.markdown.ast.findChildOfType
1817
import org.intellij.markdown.ast.getTextInNode
@@ -26,10 +25,13 @@ internal fun AnnotatedString.Builder.appendMarkdownLink(content: String, node: A
2625
append(node.getTextInNode(content).toString())
2726
return
2827
}
29-
val destination = node.findChildOfType(MarkdownElementTypes.LINK_DESTINATION)?.getTextInNode(content)?.toString()
30-
val linkLabel = node.findChildOfType(MarkdownElementTypes.LINK_LABEL)?.getTextInNode(content)?.toString()
28+
val destination = node.findChildOfType(MarkdownElementTypes.LINK_DESTINATION)
29+
?.getTextInNode(content)
30+
?.toString()
31+
val linkLabel = node.findChildOfType(MarkdownElementTypes.LINK_LABEL)
32+
?.getTextInNode(content)?.toString()
3133
val annotation = destination ?: linkLabel
32-
if (annotation != null) pushStringAnnotation(TAG_URL, annotation)
34+
if (annotation != null) pushStringAnnotation(MARKDOWN_TAG_URL, annotation)
3335
pushStyle(
3436
SpanStyle(
3537
color = LocalMarkdownColors.current.linkText,
@@ -48,7 +50,7 @@ internal fun AnnotatedString.Builder.appendAutoLink(content: String, node: ASTNo
4850
it.type.name == MarkdownElementTypes.AUTOLINK.name
4951
} ?: node
5052
val destination = targetNode.getTextInNode(content).toString()
51-
pushStringAnnotation(TAG_URL, (destination))
53+
pushStringAnnotation(MARKDOWN_TAG_URL, (destination))
5254
pushStyle(
5355
SpanStyle(
5456
color = LocalMarkdownColors.current.linkText,
@@ -95,10 +97,9 @@ fun AnnotatedString.Builder.buildMarkdownAnnotatedString(content: String, childr
9597
MarkdownElementTypes.PARAGRAPH -> buildMarkdownAnnotatedString(content, child)
9698
MarkdownElementTypes.IMAGE -> child.findChildOfTypeRecursive(
9799
MarkdownElementTypes.LINK_DESTINATION
98-
)
99-
?.let {
100-
appendInlineContent(TAG_IMAGE_URL, it.getTextInNode(content).toString())
101-
}
100+
)?.let {
101+
appendInlineContent(MARKDOWN_TAG_IMAGE_URL, it.getTextInNode(content).toString())
102+
}
102103

103104
MarkdownElementTypes.EMPH -> {
104105
pushStyle(SpanStyle(fontStyle = FontStyle.Italic))
@@ -136,7 +137,7 @@ fun AnnotatedString.Builder.buildMarkdownAnnotatedString(content: String, childr
136137
MarkdownElementTypes.INLINE_LINK -> appendMarkdownLink(content, child)
137138
MarkdownElementTypes.SHORT_REFERENCE_LINK -> appendMarkdownLink(content, child)
138139
MarkdownElementTypes.FULL_REFERENCE_LINK -> appendMarkdownLink(content, child)
139-
TEXT -> append(child.getTextInNode(content).toString())
140+
MarkdownTokenTypes.TEXT -> append(child.getTextInNode(content).toString())
140141
GFMTokenTypes.GFM_AUTOLINK -> if (child.parent == MarkdownElementTypes.LINK_TEXT) {
141142
append(child.getTextInNode(content).toString())
142143
} else appendAutoLink(content, child)

multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/utils/Extensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import org.intellij.markdown.ast.ASTNode
66
/**
77
* Tag used to indicate an url for inline content. Required for click handling.
88
*/
9-
internal const val TAG_URL = "MARKDOWN_URL"
9+
const val MARKDOWN_TAG_URL = "MARKDOWN_URL"
1010

1111
/**
1212
* Tag used to indicate an image url for inline content. Required for rendering.
1313
*/
14-
internal const val TAG_IMAGE_URL = "MARKDOWN_IMAGE_URL"
14+
const val MARKDOWN_TAG_IMAGE_URL = "MARKDOWN_IMAGE_URL"
1515

1616
/**
1717
* Find a child node recursive

0 commit comments

Comments
 (0)