react-native-enriched-markdown 0.8.0-nightly-20260811-94ea7e0ad → 1.0.0
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.
- package/README.md +9 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt +8 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt +1 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -192,14 +192,15 @@ We're actively working on expanding the capabilities of `react-native-enriched-m
|
|
|
192
192
|
|
|
193
193
|
## Compatibility Table
|
|
194
194
|
|
|
195
|
-
|
|
|
196
|
-
|
|
197
|
-
| **nightly** |
|
|
198
|
-
| **0.
|
|
199
|
-
| **0.
|
|
200
|
-
| **0.
|
|
201
|
-
| **0.
|
|
202
|
-
| **0.
|
|
195
|
+
| | 0.82 | 0.83 | 0.84 | 0.85 | 0.86 | 0.87 |
|
|
196
|
+
| ----------- | :--: | :--: | :--: | :--: | :--: | :--: |
|
|
197
|
+
| **nightly** | ⛔ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
198
|
+
| **1.0.0** | ⛔ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
199
|
+
| **0.7.0** | ⛔ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
200
|
+
| **0.6.0** | ⛔ | ✅ | ✅ | ✅ | ⛔ | ⛔ |
|
|
201
|
+
| **0.5.0** | ⛔ | ✅ | ✅ | ✅ | ⛔ | ⛔ |
|
|
202
|
+
| **0.4.x** | ✅ | ✅ | ✅ | ⛔ | ⛔ | ⛔ |
|
|
203
|
+
| **0.3.0** | ✅ | ✅ | ✅ | ⛔ | ⛔ | ⛔ |
|
|
203
204
|
|
|
204
205
|
## Contributing
|
|
205
206
|
|
|
@@ -170,6 +170,7 @@ class EnrichedMarkdown
|
|
|
170
170
|
fun setAllowFontScaling(allow: Boolean) {
|
|
171
171
|
if (allowFontScaling == allow) return
|
|
172
172
|
allowFontScaling = allow
|
|
173
|
+
MeasurementStore.updateFontScalingSettings(id, allowFontScaling, maxFontSizeMultiplier)
|
|
173
174
|
recreateStyleConfig()
|
|
174
175
|
dirtyFlags += DirtyFlag.RECREATE_SEGMENTS
|
|
175
176
|
dirtyFlags += DirtyFlag.FORCE_HEIGHT
|
|
@@ -179,6 +180,7 @@ class EnrichedMarkdown
|
|
|
179
180
|
fun setMaxFontSizeMultiplier(multiplier: Float) {
|
|
180
181
|
if (maxFontSizeMultiplier == multiplier) return
|
|
181
182
|
maxFontSizeMultiplier = multiplier
|
|
183
|
+
MeasurementStore.updateFontScalingSettings(id, allowFontScaling, maxFontSizeMultiplier)
|
|
182
184
|
recreateStyleConfig()
|
|
183
185
|
dirtyFlags += DirtyFlag.RECREATE_SEGMENTS
|
|
184
186
|
dirtyFlags += DirtyFlag.FORCE_HEIGHT
|
|
@@ -545,6 +547,7 @@ class EnrichedMarkdown
|
|
|
545
547
|
selectionMenuConfig = this@EnrichedMarkdown.selectionMenuConfig
|
|
546
548
|
accessibilityLabels = this@EnrichedMarkdown.accessibilityLabels
|
|
547
549
|
setIsSelectable(selectable)
|
|
550
|
+
markdownStyle?.paragraphStyle?.fontSize?.let { setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, it) }
|
|
548
551
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
549
552
|
breakStrategy = BreakStrategyUtils.resolveBreakStrategy(textBreakStrategy)
|
|
550
553
|
}
|
|
@@ -165,7 +165,11 @@ object MeasurementStore {
|
|
|
165
165
|
allowFontScaling: Boolean,
|
|
166
166
|
maxFontSizeMultiplier: Float,
|
|
167
167
|
) {
|
|
168
|
+
val previous = fontScalingSettings[viewId]
|
|
168
169
|
fontScalingSettings[viewId] = FontScalingSettings(allowFontScaling, maxFontSizeMultiplier)
|
|
170
|
+
if (previous != null && (previous.allowFontScaling != allowFontScaling || previous.maxFontSizeMultiplier != maxFontSizeMultiplier)) {
|
|
171
|
+
data.remove(viewId)
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
fun clearFontScalingSettings(viewId: Int) {
|
|
@@ -326,6 +330,7 @@ object MeasurementStore {
|
|
|
326
330
|
val propsHash = computePropsHash(props, allowFontScaling, fontScale, maxFontSizeMultiplier)
|
|
327
331
|
|
|
328
332
|
// 2. Render & Measure
|
|
333
|
+
measurePaint.textSize = fontSize
|
|
329
334
|
val imageRequestHeaders = parseImageRequestHeaders(props.getArrayOrNull("imageRequestHeaders"))
|
|
330
335
|
val spannable =
|
|
331
336
|
tryRenderMarkdown(markdown, styleMap, context, md4cFlags, allowFontScaling, maxFontSizeMultiplier, imageRequestHeaders)
|
|
@@ -28,6 +28,14 @@ abstract class BaseListSpan(
|
|
|
28
28
|
private var cachedText: CharSequence? = null
|
|
29
29
|
private var cachedHasDeeperSpanByPosition = mutableMapOf<Int, Boolean>()
|
|
30
30
|
|
|
31
|
+
val markerFontMetrics: Paint.FontMetrics by lazy {
|
|
32
|
+
TextPaint()
|
|
33
|
+
.apply {
|
|
34
|
+
applyBlockStyleFont(blockStyle, context)
|
|
35
|
+
textSize = blockStyle.fontSize
|
|
36
|
+
}.fontMetrics
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
protected abstract fun getMarkerWidth(): Float
|
|
32
40
|
|
|
33
41
|
override fun updateMeasureState(textPaint: TextPaint) = applyTextStyle(textPaint)
|
|
@@ -71,8 +71,7 @@ class TaskListSpan(
|
|
|
71
71
|
layout: Layout?,
|
|
72
72
|
start: Int,
|
|
73
73
|
) {
|
|
74
|
-
val
|
|
75
|
-
val capHeight = -fontMetrics.ascent * CAP_HEIGHT_RATIO
|
|
74
|
+
val capHeight = -markerFontMetrics.ascent * CAP_HEIGHT_RATIO
|
|
76
75
|
val centerY = baseline - capHeight / HALF_DIVISOR
|
|
77
76
|
// Right-align the checkbox inside the reserved marker column so it hugs
|
|
78
77
|
// the gap before the text. At the default (markerColumnWidth ==
|
|
@@ -66,8 +66,7 @@ class UnorderedListSpan(
|
|
|
66
66
|
// visually flush-left when the column width equals the bullet radius
|
|
67
67
|
// (the default).
|
|
68
68
|
val bulletX = x + (depth * marginLeft + markerColumnWidth) * dir
|
|
69
|
-
val
|
|
70
|
-
val bulletY = baseline + (fontMetrics.ascent + fontMetrics.descent) / 2f
|
|
69
|
+
val bulletY = baseline + (markerFontMetrics.ascent + markerFontMetrics.descent) / 2f
|
|
71
70
|
|
|
72
71
|
when (depth) {
|
|
73
72
|
0 -> {
|
|
@@ -35,7 +35,7 @@ data class ListStyle(
|
|
|
35
35
|
val lineHeightRaw = map.getDouble("lineHeight").toFloat()
|
|
36
36
|
val lineHeight = parser.toPixelFromSP(lineHeightRaw)
|
|
37
37
|
val bulletColor = parser.parseColor(map, "bulletColor")
|
|
38
|
-
val bulletSize = parser.
|
|
38
|
+
val bulletSize = parser.toPixelFromSP(map.getDouble("bulletSize").toFloat())
|
|
39
39
|
val markerMinWidth = parser.toPixelFromDIP(map.getDouble("markerMinWidth").toFloat().coerceAtLeast(0f))
|
|
40
40
|
val markerColor = parser.parseColor(map, "markerColor")
|
|
41
41
|
val markerFontWeight = parser.parseString(map, "markerFontWeight", "normal")
|
package/package.json
CHANGED