react-native-enriched-markdown-scaffold 0.6.0-scaffold.6 → 0.6.0-scaffold.8

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.
Files changed (63) hide show
  1. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +0 -36
  2. package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +0 -1
  3. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +0 -3
  4. package/android/src/main/java/com/swmansion/enriched/markdown/spans/MathModels.kt +0 -1
  5. package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +1 -3
  6. package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +1 -3
  7. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +0 -14
  8. package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +0 -1
  9. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -2
  10. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +1 -3
  11. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +1 -2
  12. package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +1 -8
  13. package/ios/attachments/ENRMMathInlineAttachment+macOS.m +1 -5
  14. package/ios/attachments/ENRMMathInlineAttachment.h +0 -3
  15. package/ios/attachments/ENRMMathInlineAttachment.m +1 -2
  16. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +0 -36
  17. package/ios/input/ENRMInputFormatter.h +0 -6
  18. package/ios/input/ENRMInputFormatter.mm +0 -2
  19. package/ios/input/EnrichedMarkdownTextInput.mm +13 -3
  20. package/ios/input/InputStylePropsUtils.h +0 -8
  21. package/ios/math/ENRMRaTeXBridge.swift +2 -16
  22. package/ios/renderer/ENRMMathInlineRenderer.m +0 -1
  23. package/ios/styles/StyleConfig.h +0 -4
  24. package/ios/styles/StyleConfig.mm +0 -24
  25. package/ios/utils/StylePropsUtils.h +0 -10
  26. package/ios/views/ENRMMathContainerView.m +1 -2
  27. package/lib/module/EnrichedMarkdownNativeComponent.ts +0 -2
  28. package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
  29. package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +0 -1
  30. package/lib/module/EnrichedMarkdownTextNativeComponent.ts +0 -2
  31. package/lib/module/normalizeMarkdownStyle.js +2 -4
  32. package/lib/module/normalizeMarkdownStyle.js.map +1 -1
  33. package/lib/module/normalizeMarkdownStyle.web.js +2 -4
  34. package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
  35. package/lib/module/normalizeMarkdownTextInputStyle.js +3 -10
  36. package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
  37. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +0 -2
  38. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
  39. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +0 -12
  40. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
  41. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +0 -1
  42. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
  43. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +0 -2
  44. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
  45. package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
  46. package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
  47. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +0 -2
  48. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
  49. package/lib/typescript/src/types/MarkdownStyle.d.ts +0 -14
  50. package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
  51. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +0 -3
  52. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/EnrichedMarkdownNativeComponent.ts +0 -2
  55. package/src/EnrichedMarkdownTextInput.tsx +0 -12
  56. package/src/EnrichedMarkdownTextInputNativeComponent.ts +0 -1
  57. package/src/EnrichedMarkdownTextNativeComponent.ts +0 -2
  58. package/src/normalizeMarkdownStyle.ts +1 -6
  59. package/src/normalizeMarkdownStyle.web.ts +1 -6
  60. package/src/normalizeMarkdownTextInputStyle.ts +0 -14
  61. package/src/types/MarkdownStyle.ts +0 -14
  62. package/src/types/MarkdownStyleInternal.ts +0 -4
  63. package/android/src/math/java/com/swmansion/enriched/markdown/utils/math/LatexWeightWrapper.kt +0 -23
@@ -1534,7 +1534,6 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
1534
1534
  Float marginTop{0.0};
1535
1535
  Float marginBottom{0.0};
1536
1536
  std::string textAlign{};
1537
- std::string fontWeight{};
1538
1537
 
1539
1538
 
1540
1539
  #ifdef RN_SERIALIZABLE_STATE
@@ -1549,7 +1548,6 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
1549
1548
  result["marginTop"] = marginTop;
1550
1549
  result["marginBottom"] = marginBottom;
1551
1550
  result["textAlign"] = textAlign;
1552
- result["fontWeight"] = fontWeight;
1553
1551
  return result;
1554
1552
  }
1555
1553
  #endif
@@ -1586,10 +1584,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
1586
1584
  if (tmp_textAlign != map.end()) {
1587
1585
  fromRawValue(context, tmp_textAlign->second, result.textAlign);
1588
1586
  }
1589
- auto tmp_fontWeight = map.find("fontWeight");
1590
- if (tmp_fontWeight != map.end()) {
1591
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
1592
- }
1593
1587
  }
1594
1588
 
1595
1589
  static inline std::string toString(const EnrichedMarkdownMarkdownStyleMathStruct &value) {
@@ -1604,7 +1598,6 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleMathSt
1604
1598
 
1605
1599
  struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
1606
1600
  SharedColor color{};
1607
- std::string fontWeight{};
1608
1601
 
1609
1602
 
1610
1603
  #ifdef RN_SERIALIZABLE_STATE
@@ -1613,7 +1606,6 @@ struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
1613
1606
  folly::dynamic toDynamic() const {
1614
1607
  folly::dynamic result = folly::dynamic::object();
1615
1608
  result["color"] = ::facebook::react::toDynamic(color);
1616
- result["fontWeight"] = fontWeight;
1617
1609
  return result;
1618
1610
  }
1619
1611
  #endif
@@ -1626,10 +1618,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
1626
1618
  if (tmp_color != map.end()) {
1627
1619
  fromRawValue(context, tmp_color->second, result.color);
1628
1620
  }
1629
- auto tmp_fontWeight = map.find("fontWeight");
1630
- if (tmp_fontWeight != map.end()) {
1631
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
1632
- }
1633
1621
  }
1634
1622
 
1635
1623
  static inline std::string toString(const EnrichedMarkdownMarkdownStyleInlineMathStruct &value) {
@@ -2521,7 +2509,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
2521
2509
  Float paddingVertical{0.0};
2522
2510
  SharedColor selectedBackgroundColor{};
2523
2511
  SharedColor selectedBorderColor{};
2524
- std::string fontWeight{};
2525
2512
 
2526
2513
 
2527
2514
  #ifdef RN_SERIALIZABLE_STATE
@@ -2539,7 +2526,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
2539
2526
  result["paddingVertical"] = paddingVertical;
2540
2527
  result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
2541
2528
  result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
2542
- result["fontWeight"] = fontWeight;
2543
2529
  return result;
2544
2530
  }
2545
2531
  #endif
@@ -2588,10 +2574,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
2588
2574
  if (tmp_selectedBorderColor != map.end()) {
2589
2575
  fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
2590
2576
  }
2591
- auto tmp_fontWeight = map.find("fontWeight");
2592
- if (tmp_fontWeight != map.end()) {
2593
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
2594
- }
2595
2577
  }
2596
2578
 
2597
2579
  static inline std::string toString(const EnrichedMarkdownTextInputMarkdownStyleMathStruct &value) {
@@ -2615,7 +2597,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
2615
2597
  Float paddingVertical{0.0};
2616
2598
  SharedColor selectedBackgroundColor{};
2617
2599
  SharedColor selectedBorderColor{};
2618
- std::string fontWeight{};
2619
2600
  Float marginTop{0.0};
2620
2601
  Float marginBottom{0.0};
2621
2602
  std::string alignment{};
@@ -2636,7 +2617,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
2636
2617
  result["paddingVertical"] = paddingVertical;
2637
2618
  result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
2638
2619
  result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
2639
- result["fontWeight"] = fontWeight;
2640
2620
  result["marginTop"] = marginTop;
2641
2621
  result["marginBottom"] = marginBottom;
2642
2622
  result["alignment"] = alignment;
@@ -2688,10 +2668,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
2688
2668
  if (tmp_selectedBorderColor != map.end()) {
2689
2669
  fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
2690
2670
  }
2691
- auto tmp_fontWeight = map.find("fontWeight");
2692
- if (tmp_fontWeight != map.end()) {
2693
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
2694
- }
2695
2671
  auto tmp_marginTop = map.find("marginTop");
2696
2672
  if (tmp_marginTop != map.end()) {
2697
2673
  fromRawValue(context, tmp_marginTop->second, result.marginTop);
@@ -4447,7 +4423,6 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
4447
4423
  Float marginTop{0.0};
4448
4424
  Float marginBottom{0.0};
4449
4425
  std::string textAlign{};
4450
- std::string fontWeight{};
4451
4426
 
4452
4427
 
4453
4428
  #ifdef RN_SERIALIZABLE_STATE
@@ -4462,7 +4437,6 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
4462
4437
  result["marginTop"] = marginTop;
4463
4438
  result["marginBottom"] = marginBottom;
4464
4439
  result["textAlign"] = textAlign;
4465
- result["fontWeight"] = fontWeight;
4466
4440
  return result;
4467
4441
  }
4468
4442
  #endif
@@ -4499,10 +4473,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
4499
4473
  if (tmp_textAlign != map.end()) {
4500
4474
  fromRawValue(context, tmp_textAlign->second, result.textAlign);
4501
4475
  }
4502
- auto tmp_fontWeight = map.find("fontWeight");
4503
- if (tmp_fontWeight != map.end()) {
4504
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
4505
- }
4506
4476
  }
4507
4477
 
4508
4478
  static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleMathStruct &value) {
@@ -4517,7 +4487,6 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleMa
4517
4487
 
4518
4488
  struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
4519
4489
  SharedColor color{};
4520
- std::string fontWeight{};
4521
4490
 
4522
4491
 
4523
4492
  #ifdef RN_SERIALIZABLE_STATE
@@ -4526,7 +4495,6 @@ struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
4526
4495
  folly::dynamic toDynamic() const {
4527
4496
  folly::dynamic result = folly::dynamic::object();
4528
4497
  result["color"] = ::facebook::react::toDynamic(color);
4529
- result["fontWeight"] = fontWeight;
4530
4498
  return result;
4531
4499
  }
4532
4500
  #endif
@@ -4539,10 +4507,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
4539
4507
  if (tmp_color != map.end()) {
4540
4508
  fromRawValue(context, tmp_color->second, result.color);
4541
4509
  }
4542
- auto tmp_fontWeight = map.find("fontWeight");
4543
- if (tmp_fontWeight != map.end()) {
4544
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
4545
- }
4546
4510
  }
4547
4511
 
4548
4512
  static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleInlineMathStruct &value) {
@@ -396,7 +396,6 @@ object MeasurementStore {
396
396
  fontSize = style.mathStyle.fontSize,
397
397
  latex = segment.latex,
398
398
  mode = MathRenderMode.Display,
399
- fontWeight = style.mathStyle.fontWeight,
400
399
  ),
401
400
  )
402
401
  }
@@ -13,7 +13,6 @@ open class MathChipStyle(
13
13
  val paddingVertical: Float,
14
14
  val selectedBackgroundColor: Int?,
15
15
  val selectedBorderColor: Int?,
16
- val fontWeight: String,
17
16
  ) {
18
17
  open fun isBlock(): Boolean = false
19
18
  }
@@ -29,7 +28,6 @@ class MathBlockStyle(
29
28
  paddingVertical: Float,
30
29
  selectedBackgroundColor: Int?,
31
30
  selectedBorderColor: Int?,
32
- fontWeight: String,
33
31
  val marginTop: Float,
34
32
  val marginBottom: Float,
35
33
  val alignment: Layout.Alignment,
@@ -44,7 +42,6 @@ class MathBlockStyle(
44
42
  paddingVertical,
45
43
  selectedBackgroundColor,
46
44
  selectedBorderColor,
47
- fontWeight,
48
45
  ) {
49
46
  override fun isBlock(): Boolean = true
50
47
  }
@@ -9,7 +9,6 @@ data class MathMeasureRequest(
9
9
  val fontSize: Float,
10
10
  val latex: String,
11
11
  val mode: MathRenderMode = MathRenderMode.Text,
12
- val fontWeight: String = "normal",
13
12
  )
14
13
 
15
14
  data class MathMetrics(
@@ -4,7 +4,6 @@ import com.facebook.react.bridge.ReadableMap
4
4
 
5
5
  data class InlineMathStyle(
6
6
  val color: Int,
7
- val fontWeight: String,
8
7
  ) {
9
8
  companion object {
10
9
  fun fromReadableMap(
@@ -12,8 +11,7 @@ data class InlineMathStyle(
12
11
  parser: StyleParser,
13
12
  ): InlineMathStyle {
14
13
  val color = parser.parseColor(map, "color")
15
- val fontWeight = parser.parseString(map, "fontWeight", "normal")
16
- return InlineMathStyle(color, fontWeight)
14
+ return InlineMathStyle(color)
17
15
  }
18
16
  }
19
17
  }
@@ -10,7 +10,6 @@ data class MathStyle(
10
10
  val marginTop: Float,
11
11
  val marginBottom: Float,
12
12
  val textAlign: String,
13
- val fontWeight: String,
14
13
  ) {
15
14
  companion object {
16
15
  fun fromReadableMap(
@@ -24,8 +23,7 @@ data class MathStyle(
24
23
  val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
25
24
  val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
26
25
  val textAlign = parser.parseString(map, "textAlign", "center")
27
- val fontWeight = parser.parseString(map, "fontWeight", "normal")
28
- return MathStyle(fontSize, color, backgroundColor, padding, marginTop, marginBottom, textAlign, fontWeight)
26
+ return MathStyle(fontSize, color, backgroundColor, padding, marginTop, marginBottom, textAlign)
29
27
  }
30
28
  }
31
29
  }
@@ -76,7 +76,6 @@ object MarkdownStyleParser {
76
76
  if (mathMap?.hasKey("selectedBackgroundColor") == true) mathMap.getInt("selectedBackgroundColor") else null
77
77
  val selectedBorderColor =
78
78
  if (mathMap?.hasKey("selectedBorderColor") == true) mathMap.getInt("selectedBorderColor") else null
79
- val fontWeight = parseFontWeight(mathMap)
80
79
 
81
80
  return MathChipStyle(
82
81
  color = color,
@@ -89,7 +88,6 @@ object MarkdownStyleParser {
89
88
  paddingVertical = paddingVertical,
90
89
  selectedBackgroundColor = nullIfTransparent(selectedBackgroundColor),
91
90
  selectedBorderColor = nullIfTransparent(selectedBorderColor),
92
- fontWeight = fontWeight,
93
91
  )
94
92
  }
95
93
 
@@ -160,12 +158,6 @@ object MarkdownStyleParser {
160
158
  "right" -> Layout.Alignment.ALIGN_OPPOSITE
161
159
  else -> Layout.Alignment.ALIGN_CENTER
162
160
  }
163
- val fontWeight =
164
- if (mathBlockMap?.hasKey("fontWeight") == true) {
165
- normalizeFontWeight(mathBlockMap.getString("fontWeight"))
166
- } else {
167
- inlineFallback.fontWeight
168
- }
169
161
 
170
162
  return MathBlockStyle(
171
163
  color = color,
@@ -178,18 +170,12 @@ object MarkdownStyleParser {
178
170
  paddingVertical = paddingVertical,
179
171
  selectedBackgroundColor = nullIfTransparent(selectedBackgroundColor),
180
172
  selectedBorderColor = nullIfTransparent(selectedBorderColor),
181
- fontWeight = fontWeight,
182
173
  marginTop = marginTop,
183
174
  marginBottom = marginBottom,
184
175
  alignment = alignment,
185
176
  )
186
177
  }
187
178
 
188
- private fun parseFontWeight(map: ReadableMap?): String =
189
- if (map?.hasKey("fontWeight") == true) normalizeFontWeight(map.getString("fontWeight")) else "normal"
190
-
191
- private fun normalizeFontWeight(raw: String?): String = if (raw == "bold") "bold" else "normal"
192
-
193
179
  private fun nullIfTransparent(color: Int?): Int? {
194
180
  if (color == null) return null
195
181
  if (Color.alpha(color) == 0) return null
@@ -35,7 +35,6 @@ class MathInlineRenderer(
35
35
  latex = latex,
36
36
  fontSize = blockStyle.fontSize,
37
37
  textColor = config.style.inlineMathStyle.color,
38
- fontWeight = config.style.inlineMathStyle.fontWeight,
39
38
  )
40
39
 
41
40
  builder.setSpan(span, start, end, SPAN_FLAGS_EXCLUSIVE_EXCLUSIVE)
@@ -8,7 +8,6 @@ import android.text.Layout
8
8
  import android.text.style.ReplacementSpan
9
9
  import com.swmansion.enriched.markdown.input.model.MathBlockStyle
10
10
  import com.swmansion.enriched.markdown.input.model.MathChipStyle
11
- import com.swmansion.enriched.markdown.utils.math.LatexWeightWrapper
12
11
  import io.ratex.RaTeXEngine
13
12
  import io.ratex.RaTeXFontLoader
14
13
  import io.ratex.RaTeXRenderer
@@ -63,7 +62,7 @@ class MathChipSpan(
63
62
  try {
64
63
  val displayList =
65
64
  RaTeXEngine.parseBlocking(
66
- LatexWeightWrapper.wrap(latex, style.fontWeight),
65
+ latex,
67
66
  displayMode = displayMode,
68
67
  color = style.color,
69
68
  )
@@ -5,7 +5,6 @@ import android.graphics.Bitmap
5
5
  import android.graphics.Canvas
6
6
  import android.graphics.Paint
7
7
  import android.text.style.ReplacementSpan
8
- import com.swmansion.enriched.markdown.utils.math.LatexWeightWrapper
9
8
  import io.ratex.RaTeXEngine
10
9
  import io.ratex.RaTeXFontLoader
11
10
  import io.ratex.RaTeXRenderer
@@ -16,7 +15,6 @@ class MathInlineSpan(
16
15
  internal val latex: String,
17
16
  internal val fontSize: Float,
18
17
  private val textColor: Int,
19
- private val fontWeight: String = "normal",
20
18
  ) : ReplacementSpan() {
21
19
  private var cachedBitmap: Bitmap? = null
22
20
  private var cachedWidth = 0
@@ -29,7 +27,7 @@ class MathInlineSpan(
29
27
  if (renderFailed) return
30
28
 
31
29
  try {
32
- val displayList = RaTeXEngine.parseBlocking(LatexWeightWrapper.wrap(latex, fontWeight), displayMode = false, color = textColor)
30
+ val displayList = RaTeXEngine.parseBlocking(latex, displayMode = false, color = textColor)
33
31
  val renderer = RaTeXRenderer(displayList, fontSize) { RaTeXFontLoader.getTypeface(it) }
34
32
 
35
33
  cachedWidth = renderer.widthPx.toInt().coerceAtLeast(1)
@@ -2,7 +2,6 @@ package com.swmansion.enriched.markdown.spans
2
2
 
3
3
  import android.content.Context
4
4
  import android.util.Log
5
- import com.swmansion.enriched.markdown.utils.math.LatexWeightWrapper
6
5
  import io.ratex.RaTeXEngine
7
6
  import io.ratex.RaTeXFontLoader
8
7
  import io.ratex.RaTeXRenderer
@@ -28,7 +27,7 @@ object MathMeasureHelper {
28
27
  ): MathMetrics {
29
28
  val displayList =
30
29
  RaTeXEngine.parseBlocking(
31
- LatexWeightWrapper.wrap(request.latex, request.fontWeight),
30
+ request.latex,
32
31
  displayMode = request.mode == MathRenderMode.Display,
33
32
  )
34
33
 
@@ -16,7 +16,6 @@ import com.swmansion.enriched.markdown.spans.MathMeasureRequest
16
16
  import com.swmansion.enriched.markdown.spans.MathRenderMode
17
17
  import com.swmansion.enriched.markdown.styles.MathStyle
18
18
  import com.swmansion.enriched.markdown.styles.StyleConfig
19
- import com.swmansion.enriched.markdown.utils.math.LatexWeightWrapper
20
19
  import io.ratex.RaTeXEngine
21
20
  import io.ratex.RaTeXFontLoader
22
21
  import io.ratex.RaTeXRenderer
@@ -83,12 +82,7 @@ class MathContainerView(
83
82
  fun applyLatex(latex: String) {
84
83
  cachedLatex = latex
85
84
  try {
86
- val displayList =
87
- RaTeXEngine.parseBlocking(
88
- LatexWeightWrapper.wrap(latex, mathStyle.fontWeight),
89
- displayMode = true,
90
- color = mathStyle.color,
91
- )
85
+ val displayList = RaTeXEngine.parseBlocking(latex, displayMode = true, color = mathStyle.color)
92
86
  mathView.renderer = RaTeXRenderer(displayList, mathStyle.fontSize) { RaTeXFontLoader.getTypeface(it) }
93
87
  } catch (e: Exception) {
94
88
  Log.e(TAG, "Failed to render LaTeX", e)
@@ -144,7 +138,6 @@ class MathContainerView(
144
138
  fontSize = mathStyle.fontSize,
145
139
  latex = latex,
146
140
  mode = MathRenderMode.Display,
147
- fontWeight = mathStyle.fontWeight,
148
141
  )
149
142
  val metrics = MathMeasureHelper.measure(context, listOf(request)).first()
150
143
  return ceil(metrics.ascent + metrics.descent).toInt() + (mathStyle.padding * 2)
@@ -25,11 +25,7 @@
25
25
  - (void)renderForMacOS
26
26
  {
27
27
  RCTUIColor *color = self.mathTextColor ?: [RCTUIColor blackColor];
28
- ENRMRaTeXRenderResult *result = [ENRMRaTeXBridge parse:self.latex
29
- displayMode:NO
30
- fontSize:self.fontSize
31
- color:color
32
- fontWeight:self.fontWeight];
28
+ ENRMRaTeXRenderResult *result = [ENRMRaTeXBridge parse:self.latex displayMode:NO fontSize:self.fontSize color:color];
33
29
  if (!result)
34
30
  return;
35
31
 
@@ -8,9 +8,6 @@ NS_ASSUME_NONNULL_BEGIN
8
8
  @property (nonatomic, strong) NSString *latex;
9
9
  @property (nonatomic, assign) CGFloat fontSize;
10
10
  @property (nonatomic, strong, nullable) RCTUIColor *mathTextColor;
11
- /// `@"bold"` to render with KaTeX bold variant. `nil`/`@"normal"` keeps the
12
- /// default (regular) glyph. Render-time only — never written back to `latex`.
13
- @property (nonatomic, copy, nullable) NSString *fontWeight;
14
11
 
15
12
  /// YES if block math (`$$...$$`), NO for inline (`$...$`).
16
13
  @property (nonatomic, assign) BOOL displayMode;
@@ -21,8 +21,7 @@
21
21
  ENRMRaTeXRenderResult *result = [ENRMRaTeXBridge parse:self.latex
22
22
  displayMode:self.displayMode
23
23
  fontSize:self.fontSize
24
- color:color
25
- fontWeight:self.fontWeight];
24
+ color:color];
26
25
  if (!result)
27
26
  return;
28
27
 
@@ -1534,7 +1534,6 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
1534
1534
  Float marginTop{0.0};
1535
1535
  Float marginBottom{0.0};
1536
1536
  std::string textAlign{};
1537
- std::string fontWeight{};
1538
1537
 
1539
1538
 
1540
1539
  #ifdef RN_SERIALIZABLE_STATE
@@ -1549,7 +1548,6 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
1549
1548
  result["marginTop"] = marginTop;
1550
1549
  result["marginBottom"] = marginBottom;
1551
1550
  result["textAlign"] = textAlign;
1552
- result["fontWeight"] = fontWeight;
1553
1551
  return result;
1554
1552
  }
1555
1553
  #endif
@@ -1586,10 +1584,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
1586
1584
  if (tmp_textAlign != map.end()) {
1587
1585
  fromRawValue(context, tmp_textAlign->second, result.textAlign);
1588
1586
  }
1589
- auto tmp_fontWeight = map.find("fontWeight");
1590
- if (tmp_fontWeight != map.end()) {
1591
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
1592
- }
1593
1587
  }
1594
1588
 
1595
1589
  static inline std::string toString(const EnrichedMarkdownMarkdownStyleMathStruct &value) {
@@ -1604,7 +1598,6 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleMathSt
1604
1598
 
1605
1599
  struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
1606
1600
  SharedColor color{};
1607
- std::string fontWeight{};
1608
1601
 
1609
1602
 
1610
1603
  #ifdef RN_SERIALIZABLE_STATE
@@ -1613,7 +1606,6 @@ struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
1613
1606
  folly::dynamic toDynamic() const {
1614
1607
  folly::dynamic result = folly::dynamic::object();
1615
1608
  result["color"] = ::facebook::react::toDynamic(color);
1616
- result["fontWeight"] = fontWeight;
1617
1609
  return result;
1618
1610
  }
1619
1611
  #endif
@@ -1626,10 +1618,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
1626
1618
  if (tmp_color != map.end()) {
1627
1619
  fromRawValue(context, tmp_color->second, result.color);
1628
1620
  }
1629
- auto tmp_fontWeight = map.find("fontWeight");
1630
- if (tmp_fontWeight != map.end()) {
1631
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
1632
- }
1633
1621
  }
1634
1622
 
1635
1623
  static inline std::string toString(const EnrichedMarkdownMarkdownStyleInlineMathStruct &value) {
@@ -2521,7 +2509,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
2521
2509
  Float paddingVertical{0.0};
2522
2510
  SharedColor selectedBackgroundColor{};
2523
2511
  SharedColor selectedBorderColor{};
2524
- std::string fontWeight{};
2525
2512
 
2526
2513
 
2527
2514
  #ifdef RN_SERIALIZABLE_STATE
@@ -2539,7 +2526,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
2539
2526
  result["paddingVertical"] = paddingVertical;
2540
2527
  result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
2541
2528
  result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
2542
- result["fontWeight"] = fontWeight;
2543
2529
  return result;
2544
2530
  }
2545
2531
  #endif
@@ -2588,10 +2574,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
2588
2574
  if (tmp_selectedBorderColor != map.end()) {
2589
2575
  fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
2590
2576
  }
2591
- auto tmp_fontWeight = map.find("fontWeight");
2592
- if (tmp_fontWeight != map.end()) {
2593
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
2594
- }
2595
2577
  }
2596
2578
 
2597
2579
  static inline std::string toString(const EnrichedMarkdownTextInputMarkdownStyleMathStruct &value) {
@@ -2615,7 +2597,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
2615
2597
  Float paddingVertical{0.0};
2616
2598
  SharedColor selectedBackgroundColor{};
2617
2599
  SharedColor selectedBorderColor{};
2618
- std::string fontWeight{};
2619
2600
  Float marginTop{0.0};
2620
2601
  Float marginBottom{0.0};
2621
2602
  std::string alignment{};
@@ -2636,7 +2617,6 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
2636
2617
  result["paddingVertical"] = paddingVertical;
2637
2618
  result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
2638
2619
  result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
2639
- result["fontWeight"] = fontWeight;
2640
2620
  result["marginTop"] = marginTop;
2641
2621
  result["marginBottom"] = marginBottom;
2642
2622
  result["alignment"] = alignment;
@@ -2688,10 +2668,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
2688
2668
  if (tmp_selectedBorderColor != map.end()) {
2689
2669
  fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
2690
2670
  }
2691
- auto tmp_fontWeight = map.find("fontWeight");
2692
- if (tmp_fontWeight != map.end()) {
2693
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
2694
- }
2695
2671
  auto tmp_marginTop = map.find("marginTop");
2696
2672
  if (tmp_marginTop != map.end()) {
2697
2673
  fromRawValue(context, tmp_marginTop->second, result.marginTop);
@@ -4447,7 +4423,6 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
4447
4423
  Float marginTop{0.0};
4448
4424
  Float marginBottom{0.0};
4449
4425
  std::string textAlign{};
4450
- std::string fontWeight{};
4451
4426
 
4452
4427
 
4453
4428
  #ifdef RN_SERIALIZABLE_STATE
@@ -4462,7 +4437,6 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
4462
4437
  result["marginTop"] = marginTop;
4463
4438
  result["marginBottom"] = marginBottom;
4464
4439
  result["textAlign"] = textAlign;
4465
- result["fontWeight"] = fontWeight;
4466
4440
  return result;
4467
4441
  }
4468
4442
  #endif
@@ -4499,10 +4473,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
4499
4473
  if (tmp_textAlign != map.end()) {
4500
4474
  fromRawValue(context, tmp_textAlign->second, result.textAlign);
4501
4475
  }
4502
- auto tmp_fontWeight = map.find("fontWeight");
4503
- if (tmp_fontWeight != map.end()) {
4504
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
4505
- }
4506
4476
  }
4507
4477
 
4508
4478
  static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleMathStruct &value) {
@@ -4517,7 +4487,6 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleMa
4517
4487
 
4518
4488
  struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
4519
4489
  SharedColor color{};
4520
- std::string fontWeight{};
4521
4490
 
4522
4491
 
4523
4492
  #ifdef RN_SERIALIZABLE_STATE
@@ -4526,7 +4495,6 @@ struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
4526
4495
  folly::dynamic toDynamic() const {
4527
4496
  folly::dynamic result = folly::dynamic::object();
4528
4497
  result["color"] = ::facebook::react::toDynamic(color);
4529
- result["fontWeight"] = fontWeight;
4530
4498
  return result;
4531
4499
  }
4532
4500
  #endif
@@ -4539,10 +4507,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
4539
4507
  if (tmp_color != map.end()) {
4540
4508
  fromRawValue(context, tmp_color->second, result.color);
4541
4509
  }
4542
- auto tmp_fontWeight = map.find("fontWeight");
4543
- if (tmp_fontWeight != map.end()) {
4544
- fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
4545
- }
4546
4510
  }
4547
4511
 
4548
4512
  static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleInlineMathStruct &value) {
@@ -50,9 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
50
50
  @property (nonatomic, assign) CGFloat mathPaddingVertical;
51
51
  @property (nonatomic, strong, nullable) RCTUIColor *mathSelectedBackgroundColor;
52
52
  @property (nonatomic, strong, nullable) RCTUIColor *mathSelectedBorderColor;
53
- /// `@"bold"` to render inline math with KaTeX bold variant.
54
- /// `nil`/`@"normal"` = default regular weight.
55
- @property (nonatomic, copy, nullable) NSString *mathFontWeight;
56
53
 
57
54
  /// Math block (`$$...$$`)
58
55
  @property (nonatomic, strong, nullable) RCTUIColor *mathBlockColor;
@@ -68,9 +65,6 @@ NS_ASSUME_NONNULL_BEGIN
68
65
  @property (nonatomic, assign) CGFloat mathBlockMarginTop;
69
66
  @property (nonatomic, assign) CGFloat mathBlockMarginBottom;
70
67
  @property (nonatomic, assign) NSTextAlignment mathBlockAlignment;
71
- /// `@"bold"` to render block math with KaTeX bold variant.
72
- /// `nil`/`@"normal"` = default regular weight.
73
- @property (nonatomic, copy, nullable) NSString *mathBlockFontWeight;
74
68
 
75
69
  - (UIFont *)fontForTraits:(UIFontDescriptorSymbolicTraits)traits;
76
70
  - (void)invalidateFontCache;
@@ -56,7 +56,6 @@
56
56
  copy.mathPaddingVertical = _mathPaddingVertical;
57
57
  copy.mathSelectedBackgroundColor = _mathSelectedBackgroundColor;
58
58
  copy.mathSelectedBorderColor = _mathSelectedBorderColor;
59
- copy.mathFontWeight = _mathFontWeight;
60
59
  copy.mathBlockColor = _mathBlockColor;
61
60
  copy.mathBlockFontSize = _mathBlockFontSize;
62
61
  copy.mathBlockBackgroundColor = _mathBlockBackgroundColor;
@@ -70,7 +69,6 @@
70
69
  copy.mathBlockMarginTop = _mathBlockMarginTop;
71
70
  copy.mathBlockMarginBottom = _mathBlockMarginBottom;
72
71
  copy.mathBlockAlignment = _mathBlockAlignment;
73
- copy.mathBlockFontWeight = _mathBlockFontWeight;
74
72
  return copy;
75
73
  }
76
74
 
@@ -41,7 +41,8 @@
41
41
  using namespace facebook::react;
42
42
 
43
43
  #if !TARGET_OS_OSX
44
- @interface EnrichedMarkdownTextInput () <RCTEnrichedMarkdownTextInputViewProtocol, UITextViewDelegate>
44
+ @interface EnrichedMarkdownTextInput () <RCTEnrichedMarkdownTextInputViewProtocol, UITextViewDelegate,
45
+ UIGestureRecognizerDelegate>
45
46
  #else
46
47
  @interface EnrichedMarkdownTextInput () <RCTEnrichedMarkdownTextInputViewProtocol, RCTBackedTextInputDelegate>
47
48
  #endif
@@ -222,6 +223,9 @@ using namespace facebook::react;
222
223
  UITapGestureRecognizer *mathTap = [[UITapGestureRecognizer alloc] initWithTarget:self
223
224
  action:@selector(handleTapForMathChip:)];
224
225
  mathTap.cancelsTouchesInView = NO;
226
+ mathTap.delaysTouchesBegan = NO;
227
+ mathTap.delaysTouchesEnded = NO;
228
+ mathTap.delegate = self;
225
229
  [_textView addGestureRecognizer:mathTap];
226
230
  #endif
227
231
  }
@@ -592,6 +596,14 @@ using namespace facebook::react;
592
596
  [_textView mouseDown:event];
593
597
  }
594
598
 
599
+ #else // iOS
600
+
601
+ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
602
+ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
603
+ {
604
+ return YES;
605
+ }
606
+
595
607
  #endif
596
608
 
597
609
  #if !TARGET_OS_OSX
@@ -683,7 +695,6 @@ using namespace facebook::react;
683
695
  att.blockAlignment = _formatterStyle.mathBlockAlignment;
684
696
  att.selectedBackgroundColor = _formatterStyle.mathBlockSelectedBackgroundColor;
685
697
  att.selectedBorderColor = _formatterStyle.mathBlockSelectedBorderColor;
686
- att.fontWeight = _formatterStyle.mathBlockFontWeight;
687
698
  } else {
688
699
  att.fontSize = _formatterStyle.mathFontSize > 0 ? _formatterStyle.mathFontSize : 16.0;
689
700
  att.mathTextColor = _formatterStyle.mathColor ?: _formatterStyle.baseTextColor;
@@ -698,7 +709,6 @@ using namespace facebook::react;
698
709
  att.blockAlignment = NSTextAlignmentNatural;
699
710
  att.selectedBackgroundColor = _formatterStyle.mathSelectedBackgroundColor;
700
711
  att.selectedBorderColor = _formatterStyle.mathSelectedBorderColor;
701
- att.fontWeight = _formatterStyle.mathFontWeight;
702
712
  }
703
713
  }
704
714