react-native-enriched-markdown-scaffold 0.7.4-scaffold.5 → 0.7.4-scaffold.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,7 @@ class HeadingRenderer(
40
40
  HeadingSpan(
41
41
  level,
42
42
  config.style,
43
+ factory.styleCache,
43
44
  ),
44
45
  start,
45
46
  end,
@@ -4,11 +4,14 @@ import android.annotation.SuppressLint
4
4
  import android.graphics.Typeface
5
5
  import android.text.TextPaint
6
6
  import android.text.style.MetricAffectingSpan
7
+ import com.swmansion.enriched.markdown.renderer.SpanStyleCache
7
8
  import com.swmansion.enriched.markdown.styles.StyleConfig
9
+ import com.swmansion.enriched.markdown.utils.text.extensions.applyColorPreserving
8
10
 
9
11
  class HeadingSpan(
10
12
  val level: Int,
11
13
  styleConfig: StyleConfig,
14
+ private val styleCache: SpanStyleCache,
12
15
  ) : MetricAffectingSpan() {
13
16
  private val fontSize: Float = styleConfig.headingStyles[level]!!.fontSize
14
17
  private val color: Int = styleConfig.headingStyles[level]!!.color
@@ -16,7 +19,11 @@ class HeadingSpan(
16
19
 
17
20
  override fun updateDrawState(tp: TextPaint) {
18
21
  applyHeadingStyle(tp)
19
- tp.color = color
22
+ // Inline spans (link, code, strong/em with their own color) are attached to the range
23
+ // BEFORE this block span, and TextLine replays every CharacterStyle in insertion order,
24
+ // so an unconditional `tp.color = color` here would repaint them. Same guard used by
25
+ // BlockquoteSpan, BaseListSpan, CodeBlockSpan, StrongSpan and EmphasisSpan.
26
+ tp.applyColorPreserving(color, *styleCache.colorsToPreserve)
20
27
  }
21
28
 
22
29
  override fun updateMeasureState(tp: TextPaint) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-enriched-markdown-scaffold",
3
- "version": "0.7.4-scaffold.5",
3
+ "version": "0.7.4-scaffold.6",
4
4
  "description": "Markdown Text component for React Native",
5
5
  "main": "./lib/module/index",
6
6
  "module": "./lib/module/index",