react-native-enriched-markdown 0.4.0 → 0.4.1
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/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +1 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +55 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +3 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +1 -1
- package/app.plugin.js +1 -0
- package/cpp/parser/MD4CParser.cpp +34 -7
- package/ios/EnrichedMarkdown.mm +85 -19
- package/ios/EnrichedMarkdownText.mm +74 -15
- package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/Props.h +55 -0
- package/ios/internals/EnrichedMarkdownShadowNode.mm +16 -2
- package/ios/internals/EnrichedMarkdownTextShadowNode.mm +16 -2
- package/ios/utils/StylePropsUtils.h +6 -3
- package/lib/module/plugin/withAndroidMath.js +23 -0
- package/lib/module/plugin/withAndroidMath.js.map +1 -0
- package/lib/module/plugin/withIosMath.js +26 -0
- package/lib/module/plugin/withIosMath.js.map +1 -0
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js +16 -0
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js.map +1 -0
- package/lib/typescript/src/plugin/withAndroidMath.d.ts +5 -0
- package/lib/typescript/src/plugin/withAndroidMath.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withIosMath.d.ts +5 -0
- package/lib/typescript/src/plugin/withIosMath.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts +6 -0
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts.map +1 -0
- package/package.json +28 -13
- package/src/plugin/withAndroidMath.ts +26 -0
- package/src/plugin/withIosMath.ts +37 -0
- package/src/plugin/withReactNativeEnrichedMarkdown.ts +17 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ComponentDescriptors.cpp +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ComponentDescriptors.h +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/EventEmitters.cpp +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/EventEmitters.h +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/Props.cpp +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/RCTComponentViewHelpers.h +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ShadowNodes.cpp +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ShadowNodes.h +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/States.cpp +0 -0
- /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/States.h +0 -0
package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java
CHANGED
|
@@ -16,6 +16,7 @@ import com.facebook.react.uimanager.BaseViewManager;
|
|
|
16
16
|
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
17
17
|
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
18
18
|
|
|
19
|
+
@SuppressWarnings("deprecation")
|
|
19
20
|
public class EnrichedMarkdownManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EnrichedMarkdownManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
20
21
|
public EnrichedMarkdownManagerDelegate(U viewManager) {
|
|
21
22
|
super(viewManager);
|
|
@@ -16,6 +16,7 @@ import com.facebook.react.uimanager.BaseViewManager;
|
|
|
16
16
|
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
17
17
|
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
18
18
|
|
|
19
|
+
@SuppressWarnings("deprecation")
|
|
19
20
|
public class EnrichedMarkdownTextManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EnrichedMarkdownTextManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
20
21
|
public EnrichedMarkdownTextManagerDelegate(U viewManager) {
|
|
21
22
|
super(viewManager);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <react/renderer/components/view/ViewProps.h>
|
|
13
13
|
#include <react/renderer/core/PropsParserContext.h>
|
|
14
14
|
#include <react/renderer/core/propsConversions.h>
|
|
15
|
+
#include <react/renderer/debug/DebugStringConvertible.h>
|
|
15
16
|
#include <react/renderer/graphics/Color.h>
|
|
16
17
|
|
|
17
18
|
namespace facebook::react {
|
|
@@ -26,6 +27,7 @@ struct EnrichedMarkdownMarkdownStyleParagraphStruct {
|
|
|
26
27
|
Float lineHeight{0.0};
|
|
27
28
|
std::string textAlign{};
|
|
28
29
|
|
|
30
|
+
|
|
29
31
|
#ifdef RN_SERIALIZABLE_STATE
|
|
30
32
|
bool operator==(const EnrichedMarkdownMarkdownStyleParagraphStruct&) const = default;
|
|
31
33
|
|
|
@@ -101,6 +103,7 @@ struct EnrichedMarkdownMarkdownStyleH1Struct {
|
|
|
101
103
|
Float lineHeight{0.0};
|
|
102
104
|
std::string textAlign{};
|
|
103
105
|
|
|
106
|
+
|
|
104
107
|
#ifdef RN_SERIALIZABLE_STATE
|
|
105
108
|
bool operator==(const EnrichedMarkdownMarkdownStyleH1Struct&) const = default;
|
|
106
109
|
|
|
@@ -176,6 +179,7 @@ struct EnrichedMarkdownMarkdownStyleH2Struct {
|
|
|
176
179
|
Float lineHeight{0.0};
|
|
177
180
|
std::string textAlign{};
|
|
178
181
|
|
|
182
|
+
|
|
179
183
|
#ifdef RN_SERIALIZABLE_STATE
|
|
180
184
|
bool operator==(const EnrichedMarkdownMarkdownStyleH2Struct&) const = default;
|
|
181
185
|
|
|
@@ -251,6 +255,7 @@ struct EnrichedMarkdownMarkdownStyleH3Struct {
|
|
|
251
255
|
Float lineHeight{0.0};
|
|
252
256
|
std::string textAlign{};
|
|
253
257
|
|
|
258
|
+
|
|
254
259
|
#ifdef RN_SERIALIZABLE_STATE
|
|
255
260
|
bool operator==(const EnrichedMarkdownMarkdownStyleH3Struct&) const = default;
|
|
256
261
|
|
|
@@ -326,6 +331,7 @@ struct EnrichedMarkdownMarkdownStyleH4Struct {
|
|
|
326
331
|
Float lineHeight{0.0};
|
|
327
332
|
std::string textAlign{};
|
|
328
333
|
|
|
334
|
+
|
|
329
335
|
#ifdef RN_SERIALIZABLE_STATE
|
|
330
336
|
bool operator==(const EnrichedMarkdownMarkdownStyleH4Struct&) const = default;
|
|
331
337
|
|
|
@@ -401,6 +407,7 @@ struct EnrichedMarkdownMarkdownStyleH5Struct {
|
|
|
401
407
|
Float lineHeight{0.0};
|
|
402
408
|
std::string textAlign{};
|
|
403
409
|
|
|
410
|
+
|
|
404
411
|
#ifdef RN_SERIALIZABLE_STATE
|
|
405
412
|
bool operator==(const EnrichedMarkdownMarkdownStyleH5Struct&) const = default;
|
|
406
413
|
|
|
@@ -476,6 +483,7 @@ struct EnrichedMarkdownMarkdownStyleH6Struct {
|
|
|
476
483
|
Float lineHeight{0.0};
|
|
477
484
|
std::string textAlign{};
|
|
478
485
|
|
|
486
|
+
|
|
479
487
|
#ifdef RN_SERIALIZABLE_STATE
|
|
480
488
|
bool operator==(const EnrichedMarkdownMarkdownStyleH6Struct&) const = default;
|
|
481
489
|
|
|
@@ -554,6 +562,7 @@ struct EnrichedMarkdownMarkdownStyleBlockquoteStruct {
|
|
|
554
562
|
Float gapWidth{0.0};
|
|
555
563
|
SharedColor backgroundColor{};
|
|
556
564
|
|
|
565
|
+
|
|
557
566
|
#ifdef RN_SERIALIZABLE_STATE
|
|
558
567
|
bool operator==(const EnrichedMarkdownMarkdownStyleBlockquoteStruct&) const = default;
|
|
559
568
|
|
|
@@ -649,6 +658,7 @@ struct EnrichedMarkdownMarkdownStyleListStruct {
|
|
|
649
658
|
Float gapWidth{0.0};
|
|
650
659
|
Float marginLeft{0.0};
|
|
651
660
|
|
|
661
|
+
|
|
652
662
|
#ifdef RN_SERIALIZABLE_STATE
|
|
653
663
|
bool operator==(const EnrichedMarkdownMarkdownStyleListStruct&) const = default;
|
|
654
664
|
|
|
@@ -753,6 +763,7 @@ struct EnrichedMarkdownMarkdownStyleCodeBlockStruct {
|
|
|
753
763
|
Float borderWidth{0.0};
|
|
754
764
|
Float padding{0.0};
|
|
755
765
|
|
|
766
|
+
|
|
756
767
|
#ifdef RN_SERIALIZABLE_STATE
|
|
757
768
|
bool operator==(const EnrichedMarkdownMarkdownStyleCodeBlockStruct&) const = default;
|
|
758
769
|
|
|
@@ -843,6 +854,7 @@ struct EnrichedMarkdownMarkdownStyleLinkStruct {
|
|
|
843
854
|
SharedColor color{};
|
|
844
855
|
bool underline{false};
|
|
845
856
|
|
|
857
|
+
|
|
846
858
|
#ifdef RN_SERIALIZABLE_STATE
|
|
847
859
|
bool operator==(const EnrichedMarkdownMarkdownStyleLinkStruct&) const = default;
|
|
848
860
|
|
|
@@ -888,6 +900,7 @@ struct EnrichedMarkdownMarkdownStyleStrongStruct {
|
|
|
888
900
|
std::string fontWeight{};
|
|
889
901
|
SharedColor color{};
|
|
890
902
|
|
|
903
|
+
|
|
891
904
|
#ifdef RN_SERIALIZABLE_STATE
|
|
892
905
|
bool operator==(const EnrichedMarkdownMarkdownStyleStrongStruct&) const = default;
|
|
893
906
|
|
|
@@ -933,6 +946,7 @@ struct EnrichedMarkdownMarkdownStyleEmStruct {
|
|
|
933
946
|
std::string fontStyle{};
|
|
934
947
|
SharedColor color{};
|
|
935
948
|
|
|
949
|
+
|
|
936
950
|
#ifdef RN_SERIALIZABLE_STATE
|
|
937
951
|
bool operator==(const EnrichedMarkdownMarkdownStyleEmStruct&) const = default;
|
|
938
952
|
|
|
@@ -976,6 +990,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleEmStru
|
|
|
976
990
|
struct EnrichedMarkdownMarkdownStyleStrikethroughStruct {
|
|
977
991
|
SharedColor color{};
|
|
978
992
|
|
|
993
|
+
|
|
979
994
|
#ifdef RN_SERIALIZABLE_STATE
|
|
980
995
|
bool operator==(const EnrichedMarkdownMarkdownStyleStrikethroughStruct&) const = default;
|
|
981
996
|
|
|
@@ -1009,6 +1024,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleStrike
|
|
|
1009
1024
|
struct EnrichedMarkdownMarkdownStyleUnderlineStruct {
|
|
1010
1025
|
SharedColor color{};
|
|
1011
1026
|
|
|
1027
|
+
|
|
1012
1028
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1013
1029
|
bool operator==(const EnrichedMarkdownMarkdownStyleUnderlineStruct&) const = default;
|
|
1014
1030
|
|
|
@@ -1046,6 +1062,7 @@ struct EnrichedMarkdownMarkdownStyleCodeStruct {
|
|
|
1046
1062
|
SharedColor backgroundColor{};
|
|
1047
1063
|
SharedColor borderColor{};
|
|
1048
1064
|
|
|
1065
|
+
|
|
1049
1066
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1050
1067
|
bool operator==(const EnrichedMarkdownMarkdownStyleCodeStruct&) const = default;
|
|
1051
1068
|
|
|
@@ -1102,6 +1119,7 @@ struct EnrichedMarkdownMarkdownStyleImageStruct {
|
|
|
1102
1119
|
Float marginTop{0.0};
|
|
1103
1120
|
Float marginBottom{0.0};
|
|
1104
1121
|
|
|
1122
|
+
|
|
1105
1123
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1106
1124
|
bool operator==(const EnrichedMarkdownMarkdownStyleImageStruct&) const = default;
|
|
1107
1125
|
|
|
@@ -1150,6 +1168,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleImageS
|
|
|
1150
1168
|
struct EnrichedMarkdownMarkdownStyleInlineImageStruct {
|
|
1151
1169
|
Float size{0.0};
|
|
1152
1170
|
|
|
1171
|
+
|
|
1153
1172
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1154
1173
|
bool operator==(const EnrichedMarkdownMarkdownStyleInlineImageStruct&) const = default;
|
|
1155
1174
|
|
|
@@ -1186,6 +1205,7 @@ struct EnrichedMarkdownMarkdownStyleThematicBreakStruct {
|
|
|
1186
1205
|
Float marginTop{0.0};
|
|
1187
1206
|
Float marginBottom{0.0};
|
|
1188
1207
|
|
|
1208
|
+
|
|
1189
1209
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1190
1210
|
bool operator==(const EnrichedMarkdownMarkdownStyleThematicBreakStruct&) const = default;
|
|
1191
1211
|
|
|
@@ -1250,6 +1270,7 @@ struct EnrichedMarkdownMarkdownStyleTableStruct {
|
|
|
1250
1270
|
Float cellPaddingHorizontal{0.0};
|
|
1251
1271
|
Float cellPaddingVertical{0.0};
|
|
1252
1272
|
|
|
1273
|
+
|
|
1253
1274
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1254
1275
|
bool operator==(const EnrichedMarkdownMarkdownStyleTableStruct&) const = default;
|
|
1255
1276
|
|
|
@@ -1369,6 +1390,7 @@ struct EnrichedMarkdownMarkdownStyleTaskListStruct {
|
|
|
1369
1390
|
SharedColor checkedTextColor{};
|
|
1370
1391
|
bool checkedStrikethrough{false};
|
|
1371
1392
|
|
|
1393
|
+
|
|
1372
1394
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1373
1395
|
bool operator==(const EnrichedMarkdownMarkdownStyleTaskListStruct&) const = default;
|
|
1374
1396
|
|
|
@@ -1438,6 +1460,7 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
|
|
|
1438
1460
|
Float marginBottom{0.0};
|
|
1439
1461
|
std::string textAlign{};
|
|
1440
1462
|
|
|
1463
|
+
|
|
1441
1464
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1442
1465
|
bool operator==(const EnrichedMarkdownMarkdownStyleMathStruct&) const = default;
|
|
1443
1466
|
|
|
@@ -1501,6 +1524,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleMathSt
|
|
|
1501
1524
|
struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
|
|
1502
1525
|
SharedColor color{};
|
|
1503
1526
|
|
|
1527
|
+
|
|
1504
1528
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1505
1529
|
bool operator==(const EnrichedMarkdownMarkdownStyleInlineMathStruct&) const = default;
|
|
1506
1530
|
|
|
@@ -1556,6 +1580,7 @@ struct EnrichedMarkdownMarkdownStyleStruct {
|
|
|
1556
1580
|
EnrichedMarkdownMarkdownStyleMathStruct math{};
|
|
1557
1581
|
EnrichedMarkdownMarkdownStyleInlineMathStruct inlineMath{};
|
|
1558
1582
|
|
|
1583
|
+
|
|
1559
1584
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1560
1585
|
bool operator==(const EnrichedMarkdownMarkdownStyleStruct&) const = default;
|
|
1561
1586
|
|
|
@@ -1700,6 +1725,7 @@ struct EnrichedMarkdownMd4cFlagsStruct {
|
|
|
1700
1725
|
bool underline{false};
|
|
1701
1726
|
bool latexMath{false};
|
|
1702
1727
|
|
|
1728
|
+
|
|
1703
1729
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1704
1730
|
bool operator==(const EnrichedMarkdownMd4cFlagsStruct&) const = default;
|
|
1705
1731
|
|
|
@@ -1756,6 +1782,8 @@ class EnrichedMarkdownProps final : public ViewProps {
|
|
|
1756
1782
|
|
|
1757
1783
|
folly::dynamic getDiffProps(const Props* prevProps) const override;
|
|
1758
1784
|
#endif
|
|
1785
|
+
|
|
1786
|
+
|
|
1759
1787
|
};
|
|
1760
1788
|
|
|
1761
1789
|
struct EnrichedMarkdownTextMarkdownStyleParagraphStruct {
|
|
@@ -1768,6 +1796,7 @@ struct EnrichedMarkdownTextMarkdownStyleParagraphStruct {
|
|
|
1768
1796
|
Float lineHeight{0.0};
|
|
1769
1797
|
std::string textAlign{};
|
|
1770
1798
|
|
|
1799
|
+
|
|
1771
1800
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1772
1801
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleParagraphStruct&) const = default;
|
|
1773
1802
|
|
|
@@ -1843,6 +1872,7 @@ struct EnrichedMarkdownTextMarkdownStyleH1Struct {
|
|
|
1843
1872
|
Float lineHeight{0.0};
|
|
1844
1873
|
std::string textAlign{};
|
|
1845
1874
|
|
|
1875
|
+
|
|
1846
1876
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1847
1877
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH1Struct&) const = default;
|
|
1848
1878
|
|
|
@@ -1918,6 +1948,7 @@ struct EnrichedMarkdownTextMarkdownStyleH2Struct {
|
|
|
1918
1948
|
Float lineHeight{0.0};
|
|
1919
1949
|
std::string textAlign{};
|
|
1920
1950
|
|
|
1951
|
+
|
|
1921
1952
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1922
1953
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH2Struct&) const = default;
|
|
1923
1954
|
|
|
@@ -1993,6 +2024,7 @@ struct EnrichedMarkdownTextMarkdownStyleH3Struct {
|
|
|
1993
2024
|
Float lineHeight{0.0};
|
|
1994
2025
|
std::string textAlign{};
|
|
1995
2026
|
|
|
2027
|
+
|
|
1996
2028
|
#ifdef RN_SERIALIZABLE_STATE
|
|
1997
2029
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH3Struct&) const = default;
|
|
1998
2030
|
|
|
@@ -2068,6 +2100,7 @@ struct EnrichedMarkdownTextMarkdownStyleH4Struct {
|
|
|
2068
2100
|
Float lineHeight{0.0};
|
|
2069
2101
|
std::string textAlign{};
|
|
2070
2102
|
|
|
2103
|
+
|
|
2071
2104
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2072
2105
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH4Struct&) const = default;
|
|
2073
2106
|
|
|
@@ -2143,6 +2176,7 @@ struct EnrichedMarkdownTextMarkdownStyleH5Struct {
|
|
|
2143
2176
|
Float lineHeight{0.0};
|
|
2144
2177
|
std::string textAlign{};
|
|
2145
2178
|
|
|
2179
|
+
|
|
2146
2180
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2147
2181
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH5Struct&) const = default;
|
|
2148
2182
|
|
|
@@ -2218,6 +2252,7 @@ struct EnrichedMarkdownTextMarkdownStyleH6Struct {
|
|
|
2218
2252
|
Float lineHeight{0.0};
|
|
2219
2253
|
std::string textAlign{};
|
|
2220
2254
|
|
|
2255
|
+
|
|
2221
2256
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2222
2257
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleH6Struct&) const = default;
|
|
2223
2258
|
|
|
@@ -2296,6 +2331,7 @@ struct EnrichedMarkdownTextMarkdownStyleBlockquoteStruct {
|
|
|
2296
2331
|
Float gapWidth{0.0};
|
|
2297
2332
|
SharedColor backgroundColor{};
|
|
2298
2333
|
|
|
2334
|
+
|
|
2299
2335
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2300
2336
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleBlockquoteStruct&) const = default;
|
|
2301
2337
|
|
|
@@ -2391,6 +2427,7 @@ struct EnrichedMarkdownTextMarkdownStyleListStruct {
|
|
|
2391
2427
|
Float gapWidth{0.0};
|
|
2392
2428
|
Float marginLeft{0.0};
|
|
2393
2429
|
|
|
2430
|
+
|
|
2394
2431
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2395
2432
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleListStruct&) const = default;
|
|
2396
2433
|
|
|
@@ -2495,6 +2532,7 @@ struct EnrichedMarkdownTextMarkdownStyleCodeBlockStruct {
|
|
|
2495
2532
|
Float borderWidth{0.0};
|
|
2496
2533
|
Float padding{0.0};
|
|
2497
2534
|
|
|
2535
|
+
|
|
2498
2536
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2499
2537
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleCodeBlockStruct&) const = default;
|
|
2500
2538
|
|
|
@@ -2585,6 +2623,7 @@ struct EnrichedMarkdownTextMarkdownStyleLinkStruct {
|
|
|
2585
2623
|
SharedColor color{};
|
|
2586
2624
|
bool underline{false};
|
|
2587
2625
|
|
|
2626
|
+
|
|
2588
2627
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2589
2628
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleLinkStruct&) const = default;
|
|
2590
2629
|
|
|
@@ -2630,6 +2669,7 @@ struct EnrichedMarkdownTextMarkdownStyleStrongStruct {
|
|
|
2630
2669
|
std::string fontWeight{};
|
|
2631
2670
|
SharedColor color{};
|
|
2632
2671
|
|
|
2672
|
+
|
|
2633
2673
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2634
2674
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleStrongStruct&) const = default;
|
|
2635
2675
|
|
|
@@ -2675,6 +2715,7 @@ struct EnrichedMarkdownTextMarkdownStyleEmStruct {
|
|
|
2675
2715
|
std::string fontStyle{};
|
|
2676
2716
|
SharedColor color{};
|
|
2677
2717
|
|
|
2718
|
+
|
|
2678
2719
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2679
2720
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleEmStruct&) const = default;
|
|
2680
2721
|
|
|
@@ -2718,6 +2759,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleEm
|
|
|
2718
2759
|
struct EnrichedMarkdownTextMarkdownStyleStrikethroughStruct {
|
|
2719
2760
|
SharedColor color{};
|
|
2720
2761
|
|
|
2762
|
+
|
|
2721
2763
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2722
2764
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleStrikethroughStruct&) const = default;
|
|
2723
2765
|
|
|
@@ -2751,6 +2793,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleSt
|
|
|
2751
2793
|
struct EnrichedMarkdownTextMarkdownStyleUnderlineStruct {
|
|
2752
2794
|
SharedColor color{};
|
|
2753
2795
|
|
|
2796
|
+
|
|
2754
2797
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2755
2798
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleUnderlineStruct&) const = default;
|
|
2756
2799
|
|
|
@@ -2788,6 +2831,7 @@ struct EnrichedMarkdownTextMarkdownStyleCodeStruct {
|
|
|
2788
2831
|
SharedColor backgroundColor{};
|
|
2789
2832
|
SharedColor borderColor{};
|
|
2790
2833
|
|
|
2834
|
+
|
|
2791
2835
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2792
2836
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleCodeStruct&) const = default;
|
|
2793
2837
|
|
|
@@ -2844,6 +2888,7 @@ struct EnrichedMarkdownTextMarkdownStyleImageStruct {
|
|
|
2844
2888
|
Float marginTop{0.0};
|
|
2845
2889
|
Float marginBottom{0.0};
|
|
2846
2890
|
|
|
2891
|
+
|
|
2847
2892
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2848
2893
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleImageStruct&) const = default;
|
|
2849
2894
|
|
|
@@ -2892,6 +2937,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleIm
|
|
|
2892
2937
|
struct EnrichedMarkdownTextMarkdownStyleInlineImageStruct {
|
|
2893
2938
|
Float size{0.0};
|
|
2894
2939
|
|
|
2940
|
+
|
|
2895
2941
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2896
2942
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleInlineImageStruct&) const = default;
|
|
2897
2943
|
|
|
@@ -2928,6 +2974,7 @@ struct EnrichedMarkdownTextMarkdownStyleThematicBreakStruct {
|
|
|
2928
2974
|
Float marginTop{0.0};
|
|
2929
2975
|
Float marginBottom{0.0};
|
|
2930
2976
|
|
|
2977
|
+
|
|
2931
2978
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2932
2979
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleThematicBreakStruct&) const = default;
|
|
2933
2980
|
|
|
@@ -2992,6 +3039,7 @@ struct EnrichedMarkdownTextMarkdownStyleTableStruct {
|
|
|
2992
3039
|
Float cellPaddingHorizontal{0.0};
|
|
2993
3040
|
Float cellPaddingVertical{0.0};
|
|
2994
3041
|
|
|
3042
|
+
|
|
2995
3043
|
#ifdef RN_SERIALIZABLE_STATE
|
|
2996
3044
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleTableStruct&) const = default;
|
|
2997
3045
|
|
|
@@ -3111,6 +3159,7 @@ struct EnrichedMarkdownTextMarkdownStyleTaskListStruct {
|
|
|
3111
3159
|
SharedColor checkedTextColor{};
|
|
3112
3160
|
bool checkedStrikethrough{false};
|
|
3113
3161
|
|
|
3162
|
+
|
|
3114
3163
|
#ifdef RN_SERIALIZABLE_STATE
|
|
3115
3164
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleTaskListStruct&) const = default;
|
|
3116
3165
|
|
|
@@ -3180,6 +3229,7 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
|
|
|
3180
3229
|
Float marginBottom{0.0};
|
|
3181
3230
|
std::string textAlign{};
|
|
3182
3231
|
|
|
3232
|
+
|
|
3183
3233
|
#ifdef RN_SERIALIZABLE_STATE
|
|
3184
3234
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleMathStruct&) const = default;
|
|
3185
3235
|
|
|
@@ -3243,6 +3293,7 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleMa
|
|
|
3243
3293
|
struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
|
|
3244
3294
|
SharedColor color{};
|
|
3245
3295
|
|
|
3296
|
+
|
|
3246
3297
|
#ifdef RN_SERIALIZABLE_STATE
|
|
3247
3298
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleInlineMathStruct&) const = default;
|
|
3248
3299
|
|
|
@@ -3298,6 +3349,7 @@ struct EnrichedMarkdownTextMarkdownStyleStruct {
|
|
|
3298
3349
|
EnrichedMarkdownTextMarkdownStyleMathStruct math{};
|
|
3299
3350
|
EnrichedMarkdownTextMarkdownStyleInlineMathStruct inlineMath{};
|
|
3300
3351
|
|
|
3352
|
+
|
|
3301
3353
|
#ifdef RN_SERIALIZABLE_STATE
|
|
3302
3354
|
bool operator==(const EnrichedMarkdownTextMarkdownStyleStruct&) const = default;
|
|
3303
3355
|
|
|
@@ -3442,6 +3494,7 @@ struct EnrichedMarkdownTextMd4cFlagsStruct {
|
|
|
3442
3494
|
bool underline{false};
|
|
3443
3495
|
bool latexMath{false};
|
|
3444
3496
|
|
|
3497
|
+
|
|
3445
3498
|
#ifdef RN_SERIALIZABLE_STATE
|
|
3446
3499
|
bool operator==(const EnrichedMarkdownTextMd4cFlagsStruct&) const = default;
|
|
3447
3500
|
|
|
@@ -3498,6 +3551,8 @@ class EnrichedMarkdownTextProps final : public ViewProps {
|
|
|
3498
3551
|
|
|
3499
3552
|
folly::dynamic getDiffProps(const Props* prevProps) const override;
|
|
3500
3553
|
#endif
|
|
3554
|
+
|
|
3555
|
+
|
|
3501
3556
|
};
|
|
3502
3557
|
|
|
3503
3558
|
} // namespace facebook::react
|
|
@@ -278,7 +278,7 @@ class EnrichedMarkdown
|
|
|
278
278
|
segment: RenderSegment.Math,
|
|
279
279
|
style: StyleConfig,
|
|
280
280
|
): android.view.View {
|
|
281
|
-
if (!FeatureFlags.
|
|
281
|
+
if (!FeatureFlags.IS_MATH_ENABLED) return android.view.View(context)
|
|
282
282
|
return try {
|
|
283
283
|
val mathContainerClass = Class.forName("com.swmansion.enriched.markdown.views.MathContainerView")
|
|
284
284
|
val view =
|
|
@@ -86,7 +86,7 @@ class EnrichedMarkdownManager :
|
|
|
86
86
|
val md4cFlags =
|
|
87
87
|
Md4cFlags(
|
|
88
88
|
underline = flags?.getBoolean("underline") ?: false,
|
|
89
|
-
latexMath = FeatureFlags.
|
|
89
|
+
latexMath = FeatureFlags.IS_MATH_ENABLED && (flags?.getBoolean("latexMath") ?: true),
|
|
90
90
|
)
|
|
91
91
|
view?.setMd4cFlags(md4cFlags)
|
|
92
92
|
}
|
package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt
CHANGED
|
@@ -106,7 +106,7 @@ class EnrichedMarkdownTextManager :
|
|
|
106
106
|
val md4cFlags =
|
|
107
107
|
Md4cFlags(
|
|
108
108
|
underline = flags?.getBoolean("underline") ?: false,
|
|
109
|
-
latexMath = FeatureFlags.
|
|
109
|
+
latexMath = FeatureFlags.IS_MATH_ENABLED && (flags?.getBoolean("latexMath") ?: true),
|
|
110
110
|
)
|
|
111
111
|
view?.setMd4cFlags(md4cFlags)
|
|
112
112
|
}
|
|
@@ -242,7 +242,7 @@ object MeasurementStore {
|
|
|
242
242
|
val md4cFlags =
|
|
243
243
|
Md4cFlags(
|
|
244
244
|
underline = props.getMapOrNull("md4cFlags").getBooleanOrDefault("underline", false),
|
|
245
|
-
latexMath = FeatureFlags.
|
|
245
|
+
latexMath = FeatureFlags.IS_MATH_ENABLED && props.getMapOrNull("md4cFlags").getBooleanOrDefault("latexMath", true),
|
|
246
246
|
)
|
|
247
247
|
|
|
248
248
|
val fontSize = getInitialFontSize(styleMap, context, allowFontScaling, fontScale, maxFontSizeMultiplier)
|
|
@@ -308,7 +308,7 @@ object MeasurementStore {
|
|
|
308
308
|
val md4cFlags =
|
|
309
309
|
Md4cFlags(
|
|
310
310
|
underline = props.getMapOrNull("md4cFlags").getBooleanOrDefault("underline", false),
|
|
311
|
-
latexMath = FeatureFlags.
|
|
311
|
+
latexMath = FeatureFlags.IS_MATH_ENABLED && props.getMapOrNull("md4cFlags").getBooleanOrDefault("latexMath", true),
|
|
312
312
|
)
|
|
313
313
|
val allowTrailingMargin = props.getBooleanOrDefault("allowTrailingMargin", false)
|
|
314
314
|
val propsHash = computePropsHash(props, allowFontScaling, fontScale, maxFontSizeMultiplier)
|
|
@@ -590,7 +590,7 @@ object MeasurementStore {
|
|
|
590
590
|
context: Context,
|
|
591
591
|
requests: List<MathMeasureRequest>,
|
|
592
592
|
): List<MathMetrics> {
|
|
593
|
-
if (!FeatureFlags.
|
|
593
|
+
if (!FeatureFlags.IS_MATH_ENABLED || requests.isEmpty()) {
|
|
594
594
|
return requests.map { estimateMathFallback(it) }
|
|
595
595
|
}
|
|
596
596
|
return try {
|
|
@@ -5,7 +5,7 @@ import com.swmansion.enriched.markdown.utils.common.FeatureFlags
|
|
|
5
5
|
|
|
6
6
|
data class Md4cFlags(
|
|
7
7
|
val underline: Boolean = false,
|
|
8
|
-
val latexMath: Boolean = FeatureFlags.
|
|
8
|
+
val latexMath: Boolean = FeatureFlags.IS_MATH_ENABLED,
|
|
9
9
|
) {
|
|
10
10
|
companion object {
|
|
11
11
|
val DEFAULT = Md4cFlags()
|
|
@@ -86,7 +86,7 @@ class RendererFactory(
|
|
|
86
86
|
put(MarkdownASTNode.NodeType.Image, ImageRenderer())
|
|
87
87
|
put(MarkdownASTNode.NodeType.LineBreak, lineBreakRenderer)
|
|
88
88
|
put(MarkdownASTNode.NodeType.ThematicBreak, ThematicBreakRenderer(config))
|
|
89
|
-
if (FeatureFlags.
|
|
89
|
+
if (FeatureFlags.IS_MATH_ENABLED) {
|
|
90
90
|
try {
|
|
91
91
|
val mathInlineRendererClass = Class.forName("com.swmansion.enriched.markdown.renderer.MathInlineRenderer")
|
|
92
92
|
val constructor = mathInlineRendererClass.getConstructor(RendererConfig::class.java, Context::class.java)
|
|
@@ -16,7 +16,7 @@ fun SpannableStringBuilder.isInlineImage(): Boolean {
|
|
|
16
16
|
|
|
17
17
|
/** Swaps MathInlineSpans for MathInlinePlaceholderSpans safe for background-thread measurement. */
|
|
18
18
|
fun SpannableString.replaceMathSpansWithPlaceholders(context: Context) {
|
|
19
|
-
if (!FeatureFlags.
|
|
19
|
+
if (!FeatureFlags.IS_MATH_ENABLED) return
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
22
|
val spanClass = Class.forName("com.swmansion.enriched.markdown.spans.MathInlineSpan")
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/module/plugin/withReactNativeEnrichedMarkdown');
|
|
@@ -395,16 +395,43 @@ std::shared_ptr<MarkdownASTNode> MD4CParser::parse(const std::string &markdown,
|
|
|
395
395
|
|
|
396
396
|
impl_->flushText();
|
|
397
397
|
|
|
398
|
-
// md4c
|
|
399
|
-
//
|
|
398
|
+
// md4c wraps certain block-level constructs as inline spans inside a Paragraph.
|
|
399
|
+
// When they appear on consecutive lines without a blank separator, md4c merges
|
|
400
|
+
// them into a single Paragraph with LineBreak / whitespace Text nodes between them.
|
|
401
|
+
// Detect and unwrap these, promoting each block node to a top-level sibling.
|
|
402
|
+
// Example: consecutive $$...$$ (LatexMathDisplay) on adjacent lines.
|
|
400
403
|
if (impl_->root) {
|
|
404
|
+
auto shouldPromote = [](const MarkdownASTNode &n) { return n.type == NodeType::LatexMathDisplay; };
|
|
405
|
+
auto isSeparator = [](const MarkdownASTNode &n) {
|
|
406
|
+
return n.type == NodeType::LineBreak ||
|
|
407
|
+
(n.type == NodeType::Text && n.content.find_first_not_of(" \t\n\r") == std::string::npos);
|
|
408
|
+
};
|
|
409
|
+
|
|
401
410
|
auto &children = impl_->root->children;
|
|
402
|
-
for (size_t i = 0; i < children.size();
|
|
403
|
-
auto &
|
|
404
|
-
if (
|
|
405
|
-
|
|
406
|
-
|
|
411
|
+
for (size_t i = 0; i < children.size();) {
|
|
412
|
+
auto ¶ = children[i];
|
|
413
|
+
if (para->type != NodeType::Paragraph || para->children.empty()) {
|
|
414
|
+
++i;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
std::vector<std::shared_ptr<MarkdownASTNode>> promoted;
|
|
419
|
+
for (auto &pc : para->children) {
|
|
420
|
+
if (shouldPromote(*pc))
|
|
421
|
+
promoted.push_back(pc);
|
|
422
|
+
else if (!isSeparator(*pc)) {
|
|
423
|
+
promoted.clear();
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (promoted.empty()) {
|
|
429
|
+
++i;
|
|
430
|
+
continue;
|
|
407
431
|
}
|
|
432
|
+
auto pos = children.erase(children.begin() + static_cast<ptrdiff_t>(i));
|
|
433
|
+
children.insert(pos, promoted.begin(), promoted.end());
|
|
434
|
+
i += promoted.size();
|
|
408
435
|
}
|
|
409
436
|
}
|
|
410
437
|
|