react-native-enriched-markdown-scaffold 0.7.4-scaffold.1 → 0.7.4-scaffold.11
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/build.gradle +5 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +3 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +10 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +7 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +10 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +50 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +6 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +174 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnPasteEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/BlockSyntaxSentinel.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +71 -12
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +8 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputLayoutManager.kt +30 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +7 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HeadingSpan.kt +8 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +27 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathFontWeight.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +12 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +7 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +12 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +2 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlinePlaceholderSpan.kt +7 -3
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +8 -5
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathTypeface.kt +30 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +3 -1
- package/docs/API_REFERENCE.md +43 -0
- package/docs/INPUT.md +87 -0
- package/docs/LATEX_MATH.md +62 -0
- package/docs/STYLES.md +3 -0
- package/ios/EnrichedMarkdown.mm +44 -12
- package/ios/EnrichedMarkdownText.mm +47 -11
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +5 -1
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +2 -1
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +10 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +7 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +10 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +50 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +29 -0
- package/ios/input/ENRMBlockSyntaxSentinel.h +25 -0
- package/ios/input/ENRMBlockSyntaxSentinel.mm +80 -0
- package/ios/input/ENRMInputFormatter.h +4 -0
- package/ios/input/ENRMInputFormatter.mm +2 -0
- package/ios/input/ENRMInputParser.h +5 -0
- package/ios/input/ENRMInputParser.mm +79 -6
- package/ios/input/ENRMInputTextView.mm +11 -1
- package/ios/input/EnrichedMarkdownTextInput.h +5 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +88 -22
- package/ios/input/InputStylePropsUtils.h +13 -0
- package/ios/internals/MeasurementCache.h +1 -0
- package/ios/math/ENRMRaTeXBridge.swift +52 -3
- package/ios/parser/ENRMMarkdownParser.h +8 -0
- package/ios/parser/ENRMMarkdownParser.mm +11 -0
- package/ios/renderer/ENRMMathInlineRenderer.m +3 -0
- package/ios/renderer/ListItemRenderer.m +8 -5
- package/ios/styles/StyleConfig.h +6 -0
- package/ios/styles/StyleConfig.mm +36 -0
- package/ios/utils/ENRMMathFontWeight.h +18 -0
- package/ios/utils/StylePropsUtils.h +21 -0
- package/ios/views/ENRMMathContainerView.m +3 -1
- package/lib/module/EnrichedMarkdownNativeComponent.ts +3 -0
- package/lib/module/EnrichedMarkdownTextInput.js +17 -0
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +34 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +5 -2
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +5 -2
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/normalizeMarkdownTextInputStyle.js +7 -3
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
- package/lib/module/web/globalStyles.js +8 -1
- package/lib/module/web/globalStyles.js.map +1 -1
- package/lib/module/web/styles.js +3 -1
- package/lib/module/web/styles.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +3 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +26 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +28 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +3 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +1 -0
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +32 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +3 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +15 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedMarkdownNativeComponent.ts +3 -0
- package/src/EnrichedMarkdownTextInput.tsx +41 -0
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +34 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +3 -0
- package/src/index.tsx +1 -0
- package/src/normalizeMarkdownStyle.ts +6 -1
- package/src/normalizeMarkdownStyle.web.ts +6 -1
- package/src/normalizeMarkdownTextInputStyle.ts +5 -0
- package/src/types/MarkdownStyle.ts +32 -0
- package/src/types/MarkdownStyleInternal.ts +3 -0
- package/src/types/events.ts +16 -0
- package/src/web/globalStyles.ts +7 -0
- package/src/web/styles.ts +5 -1
package/android/build.gradle
CHANGED
|
@@ -67,6 +67,10 @@ android {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
testOptions {
|
|
72
|
+
unitTests.includeAndroidResources = true
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
repositories {
|
|
@@ -85,6 +89,7 @@ dependencies {
|
|
|
85
89
|
if (enableMath) {
|
|
86
90
|
implementation("io.github.erweixin:ratex-android:0.1.10")
|
|
87
91
|
}
|
|
92
|
+
testImplementation "junit:junit:4.13.2"
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
react {
|
|
@@ -44,9 +44,15 @@ public class EnrichedMarkdownTextInputManagerDelegate<T extends View, U extends
|
|
|
44
44
|
case "scrollEnabled":
|
|
45
45
|
mViewManager.setScrollEnabled(view, value == null ? false : (boolean) value);
|
|
46
46
|
break;
|
|
47
|
+
case "blockSyntax":
|
|
48
|
+
mViewManager.setBlockSyntax(view, value == null ? false : (boolean) value);
|
|
49
|
+
break;
|
|
47
50
|
case "autoCapitalize":
|
|
48
51
|
mViewManager.setAutoCapitalize(view, value == null ? null : (String) value);
|
|
49
52
|
break;
|
|
53
|
+
case "interceptPaste":
|
|
54
|
+
mViewManager.setInterceptPaste(view, value == null ? false : (boolean) value);
|
|
55
|
+
break;
|
|
50
56
|
case "multiline":
|
|
51
57
|
mViewManager.setMultiline(view, value == null ? false : (boolean) value);
|
|
52
58
|
break;
|
|
@@ -157,6 +163,9 @@ public class EnrichedMarkdownTextInputManagerDelegate<T extends View, U extends
|
|
|
157
163
|
case "copyToClipboard":
|
|
158
164
|
mViewManager.copyToClipboard(view);
|
|
159
165
|
break;
|
|
166
|
+
case "resolvePaste":
|
|
167
|
+
mViewManager.resolvePaste(view, args.getString(0), args.getString(1));
|
|
168
|
+
break;
|
|
160
169
|
case "requestMarkdown":
|
|
161
170
|
mViewManager.requestMarkdown(view, args.getInt(0));
|
|
162
171
|
break;
|
|
@@ -22,7 +22,9 @@ public interface EnrichedMarkdownTextInputManagerInterface<T extends View> exten
|
|
|
22
22
|
void setEditable(T view, boolean value);
|
|
23
23
|
void setAutoFocus(T view, boolean value);
|
|
24
24
|
void setScrollEnabled(T view, boolean value);
|
|
25
|
+
void setBlockSyntax(T view, boolean value);
|
|
25
26
|
void setAutoCapitalize(T view, @Nullable String value);
|
|
27
|
+
void setInterceptPaste(T view, boolean value);
|
|
26
28
|
void setMultiline(T view, boolean value);
|
|
27
29
|
void setCursorColor(T view, @Nullable Integer value);
|
|
28
30
|
void setSelectionColor(T view, @Nullable Integer value);
|
|
@@ -57,6 +59,7 @@ public interface EnrichedMarkdownTextInputManagerInterface<T extends View> exten
|
|
|
57
59
|
void updateMath(T view, int start, String latex, boolean displayMode);
|
|
58
60
|
void removeMath(T view, int start);
|
|
59
61
|
void copyToClipboard(T view);
|
|
62
|
+
void resolvePaste(T view, String text, String markdown);
|
|
60
63
|
void requestMarkdown(T view, int requestId);
|
|
61
64
|
void requestCaretRect(T view, int requestId);
|
|
62
65
|
}
|
package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp
CHANGED
|
@@ -247,6 +247,16 @@ payload.setProperty(runtime, "height", event.height);
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
|
|
250
|
+
void EnrichedMarkdownTextInputEventEmitter::onPaste(OnPaste event) const {
|
|
251
|
+
dispatchEvent("paste", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
252
|
+
auto payload = jsi::Object(runtime);
|
|
253
|
+
payload.setProperty(runtime, "text", event.text);
|
|
254
|
+
payload.setProperty(runtime, "markdown", event.markdown);
|
|
255
|
+
return payload;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
250
260
|
void EnrichedMarkdownTextInputEventEmitter::onStartMention(OnStartMention event) const {
|
|
251
261
|
dispatchEvent("startMention", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
252
262
|
auto payload = jsi::Object(runtime);
|
package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h
CHANGED
|
@@ -182,6 +182,11 @@ class EnrichedMarkdownTextInputEventEmitter : public ViewEventEmitter {
|
|
|
182
182
|
double height;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
+
struct OnPaste {
|
|
186
|
+
std::string text;
|
|
187
|
+
std::string markdown;
|
|
188
|
+
};
|
|
189
|
+
|
|
185
190
|
struct OnStartMention {
|
|
186
191
|
std::string indicator;
|
|
187
192
|
};
|
|
@@ -218,6 +223,8 @@ class EnrichedMarkdownTextInputEventEmitter : public ViewEventEmitter {
|
|
|
218
223
|
|
|
219
224
|
void onMathPress(OnMathPress value) const;
|
|
220
225
|
|
|
226
|
+
void onPaste(OnPaste value) const;
|
|
227
|
+
|
|
221
228
|
void onStartMention(OnStartMention value) const;
|
|
222
229
|
|
|
223
230
|
void onChangeMention(OnChangeMention value) const;
|
|
@@ -144,7 +144,9 @@ EnrichedMarkdownTextInputProps::EnrichedMarkdownTextInputProps(
|
|
|
144
144
|
editable(convertRawProp(context, rawProps, "editable", sourceProps.editable, {false})),
|
|
145
145
|
autoFocus(convertRawProp(context, rawProps, "autoFocus", sourceProps.autoFocus, {false})),
|
|
146
146
|
scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {false})),
|
|
147
|
+
blockSyntax(convertRawProp(context, rawProps, "blockSyntax", sourceProps.blockSyntax, {false})),
|
|
147
148
|
autoCapitalize(convertRawProp(context, rawProps, "autoCapitalize", sourceProps.autoCapitalize, {})),
|
|
149
|
+
interceptPaste(convertRawProp(context, rawProps, "interceptPaste", sourceProps.interceptPaste, {false})),
|
|
148
150
|
multiline(convertRawProp(context, rawProps, "multiline", sourceProps.multiline, {false})),
|
|
149
151
|
cursorColor(convertRawProp(context, rawProps, "cursorColor", sourceProps.cursorColor, {})),
|
|
150
152
|
selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})),
|
|
@@ -202,10 +204,18 @@ folly::dynamic EnrichedMarkdownTextInputProps::getDiffProps(
|
|
|
202
204
|
result["scrollEnabled"] = scrollEnabled;
|
|
203
205
|
}
|
|
204
206
|
|
|
207
|
+
if (blockSyntax != oldProps->blockSyntax) {
|
|
208
|
+
result["blockSyntax"] = blockSyntax;
|
|
209
|
+
}
|
|
210
|
+
|
|
205
211
|
if (autoCapitalize != oldProps->autoCapitalize) {
|
|
206
212
|
result["autoCapitalize"] = autoCapitalize;
|
|
207
213
|
}
|
|
208
214
|
|
|
215
|
+
if (interceptPaste != oldProps->interceptPaste) {
|
|
216
|
+
result["interceptPaste"] = interceptPaste;
|
|
217
|
+
}
|
|
218
|
+
|
|
209
219
|
if (multiline != oldProps->multiline) {
|
|
210
220
|
result["multiline"] = multiline;
|
|
211
221
|
}
|
|
@@ -1534,6 +1534,7 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
|
|
|
1534
1534
|
Float marginTop{0.0};
|
|
1535
1535
|
Float marginBottom{0.0};
|
|
1536
1536
|
std::string textAlign{};
|
|
1537
|
+
std::string fontWeight{};
|
|
1537
1538
|
|
|
1538
1539
|
|
|
1539
1540
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -1548,6 +1549,7 @@ struct EnrichedMarkdownMarkdownStyleMathStruct {
|
|
|
1548
1549
|
result["marginTop"] = marginTop;
|
|
1549
1550
|
result["marginBottom"] = marginBottom;
|
|
1550
1551
|
result["textAlign"] = textAlign;
|
|
1552
|
+
result["fontWeight"] = fontWeight;
|
|
1551
1553
|
return result;
|
|
1552
1554
|
}
|
|
1553
1555
|
#endif
|
|
@@ -1584,6 +1586,10 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
1584
1586
|
if (tmp_textAlign != map.end()) {
|
|
1585
1587
|
fromRawValue(context, tmp_textAlign->second, result.textAlign);
|
|
1586
1588
|
}
|
|
1589
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
1590
|
+
if (tmp_fontWeight != map.end()) {
|
|
1591
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
1592
|
+
}
|
|
1587
1593
|
}
|
|
1588
1594
|
|
|
1589
1595
|
static inline std::string toString(const EnrichedMarkdownMarkdownStyleMathStruct &value) {
|
|
@@ -1598,6 +1604,8 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownMarkdownStyleMathSt
|
|
|
1598
1604
|
|
|
1599
1605
|
struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
|
|
1600
1606
|
SharedColor color{};
|
|
1607
|
+
Float paddingVertical{0.0};
|
|
1608
|
+
std::string fontWeight{};
|
|
1601
1609
|
|
|
1602
1610
|
|
|
1603
1611
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -1606,6 +1614,8 @@ struct EnrichedMarkdownMarkdownStyleInlineMathStruct {
|
|
|
1606
1614
|
folly::dynamic toDynamic() const {
|
|
1607
1615
|
folly::dynamic result = folly::dynamic::object();
|
|
1608
1616
|
result["color"] = ::facebook::react::toDynamic(color);
|
|
1617
|
+
result["paddingVertical"] = paddingVertical;
|
|
1618
|
+
result["fontWeight"] = fontWeight;
|
|
1609
1619
|
return result;
|
|
1610
1620
|
}
|
|
1611
1621
|
#endif
|
|
@@ -1618,6 +1628,14 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
1618
1628
|
if (tmp_color != map.end()) {
|
|
1619
1629
|
fromRawValue(context, tmp_color->second, result.color);
|
|
1620
1630
|
}
|
|
1631
|
+
auto tmp_paddingVertical = map.find("paddingVertical");
|
|
1632
|
+
if (tmp_paddingVertical != map.end()) {
|
|
1633
|
+
fromRawValue(context, tmp_paddingVertical->second, result.paddingVertical);
|
|
1634
|
+
}
|
|
1635
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
1636
|
+
if (tmp_fontWeight != map.end()) {
|
|
1637
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
1638
|
+
}
|
|
1621
1639
|
}
|
|
1622
1640
|
|
|
1623
1641
|
static inline std::string toString(const EnrichedMarkdownMarkdownStyleInlineMathStruct &value) {
|
|
@@ -2804,6 +2822,7 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
|
|
|
2804
2822
|
Float paddingVertical{0.0};
|
|
2805
2823
|
SharedColor selectedBackgroundColor{};
|
|
2806
2824
|
SharedColor selectedBorderColor{};
|
|
2825
|
+
std::string fontWeight{};
|
|
2807
2826
|
|
|
2808
2827
|
|
|
2809
2828
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -2821,6 +2840,7 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathStruct {
|
|
|
2821
2840
|
result["paddingVertical"] = paddingVertical;
|
|
2822
2841
|
result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
|
|
2823
2842
|
result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
|
|
2843
|
+
result["fontWeight"] = fontWeight;
|
|
2824
2844
|
return result;
|
|
2825
2845
|
}
|
|
2826
2846
|
#endif
|
|
@@ -2869,6 +2889,10 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
2869
2889
|
if (tmp_selectedBorderColor != map.end()) {
|
|
2870
2890
|
fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
|
|
2871
2891
|
}
|
|
2892
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
2893
|
+
if (tmp_fontWeight != map.end()) {
|
|
2894
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
2895
|
+
}
|
|
2872
2896
|
}
|
|
2873
2897
|
|
|
2874
2898
|
static inline std::string toString(const EnrichedMarkdownTextInputMarkdownStyleMathStruct &value) {
|
|
@@ -2892,6 +2916,7 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
|
|
|
2892
2916
|
Float paddingVertical{0.0};
|
|
2893
2917
|
SharedColor selectedBackgroundColor{};
|
|
2894
2918
|
SharedColor selectedBorderColor{};
|
|
2919
|
+
std::string fontWeight{};
|
|
2895
2920
|
Float marginTop{0.0};
|
|
2896
2921
|
Float marginBottom{0.0};
|
|
2897
2922
|
std::string alignment{};
|
|
@@ -2912,6 +2937,7 @@ struct EnrichedMarkdownTextInputMarkdownStyleMathBlockStruct {
|
|
|
2912
2937
|
result["paddingVertical"] = paddingVertical;
|
|
2913
2938
|
result["selectedBackgroundColor"] = ::facebook::react::toDynamic(selectedBackgroundColor);
|
|
2914
2939
|
result["selectedBorderColor"] = ::facebook::react::toDynamic(selectedBorderColor);
|
|
2940
|
+
result["fontWeight"] = fontWeight;
|
|
2915
2941
|
result["marginTop"] = marginTop;
|
|
2916
2942
|
result["marginBottom"] = marginBottom;
|
|
2917
2943
|
result["alignment"] = alignment;
|
|
@@ -2963,6 +2989,10 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
2963
2989
|
if (tmp_selectedBorderColor != map.end()) {
|
|
2964
2990
|
fromRawValue(context, tmp_selectedBorderColor->second, result.selectedBorderColor);
|
|
2965
2991
|
}
|
|
2992
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
2993
|
+
if (tmp_fontWeight != map.end()) {
|
|
2994
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
2995
|
+
}
|
|
2966
2996
|
auto tmp_marginTop = map.find("marginTop");
|
|
2967
2997
|
if (tmp_marginTop != map.end()) {
|
|
2968
2998
|
fromRawValue(context, tmp_marginTop->second, result.marginTop);
|
|
@@ -3329,7 +3359,9 @@ class EnrichedMarkdownTextInputProps final : public ViewProps {
|
|
|
3329
3359
|
bool editable{false};
|
|
3330
3360
|
bool autoFocus{false};
|
|
3331
3361
|
bool scrollEnabled{false};
|
|
3362
|
+
bool blockSyntax{false};
|
|
3332
3363
|
std::string autoCapitalize{};
|
|
3364
|
+
bool interceptPaste{false};
|
|
3333
3365
|
bool multiline{false};
|
|
3334
3366
|
SharedColor cursorColor{};
|
|
3335
3367
|
SharedColor selectionColor{};
|
|
@@ -4872,6 +4904,7 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
|
|
|
4872
4904
|
Float marginTop{0.0};
|
|
4873
4905
|
Float marginBottom{0.0};
|
|
4874
4906
|
std::string textAlign{};
|
|
4907
|
+
std::string fontWeight{};
|
|
4875
4908
|
|
|
4876
4909
|
|
|
4877
4910
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -4886,6 +4919,7 @@ struct EnrichedMarkdownTextMarkdownStyleMathStruct {
|
|
|
4886
4919
|
result["marginTop"] = marginTop;
|
|
4887
4920
|
result["marginBottom"] = marginBottom;
|
|
4888
4921
|
result["textAlign"] = textAlign;
|
|
4922
|
+
result["fontWeight"] = fontWeight;
|
|
4889
4923
|
return result;
|
|
4890
4924
|
}
|
|
4891
4925
|
#endif
|
|
@@ -4922,6 +4956,10 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
4922
4956
|
if (tmp_textAlign != map.end()) {
|
|
4923
4957
|
fromRawValue(context, tmp_textAlign->second, result.textAlign);
|
|
4924
4958
|
}
|
|
4959
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
4960
|
+
if (tmp_fontWeight != map.end()) {
|
|
4961
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
4962
|
+
}
|
|
4925
4963
|
}
|
|
4926
4964
|
|
|
4927
4965
|
static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleMathStruct &value) {
|
|
@@ -4936,6 +4974,8 @@ static inline folly::dynamic toDynamic(const EnrichedMarkdownTextMarkdownStyleMa
|
|
|
4936
4974
|
|
|
4937
4975
|
struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
|
|
4938
4976
|
SharedColor color{};
|
|
4977
|
+
Float paddingVertical{0.0};
|
|
4978
|
+
std::string fontWeight{};
|
|
4939
4979
|
|
|
4940
4980
|
|
|
4941
4981
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -4944,6 +4984,8 @@ struct EnrichedMarkdownTextMarkdownStyleInlineMathStruct {
|
|
|
4944
4984
|
folly::dynamic toDynamic() const {
|
|
4945
4985
|
folly::dynamic result = folly::dynamic::object();
|
|
4946
4986
|
result["color"] = ::facebook::react::toDynamic(color);
|
|
4987
|
+
result["paddingVertical"] = paddingVertical;
|
|
4988
|
+
result["fontWeight"] = fontWeight;
|
|
4947
4989
|
return result;
|
|
4948
4990
|
}
|
|
4949
4991
|
#endif
|
|
@@ -4956,6 +4998,14 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
4956
4998
|
if (tmp_color != map.end()) {
|
|
4957
4999
|
fromRawValue(context, tmp_color->second, result.color);
|
|
4958
5000
|
}
|
|
5001
|
+
auto tmp_paddingVertical = map.find("paddingVertical");
|
|
5002
|
+
if (tmp_paddingVertical != map.end()) {
|
|
5003
|
+
fromRawValue(context, tmp_paddingVertical->second, result.paddingVertical);
|
|
5004
|
+
}
|
|
5005
|
+
auto tmp_fontWeight = map.find("fontWeight");
|
|
5006
|
+
if (tmp_fontWeight != map.end()) {
|
|
5007
|
+
fromRawValue(context, tmp_fontWeight->second, result.fontWeight);
|
|
5008
|
+
}
|
|
4959
5009
|
}
|
|
4960
5010
|
|
|
4961
5011
|
static inline std::string toString(const EnrichedMarkdownTextMarkdownStyleInlineMathStruct &value) {
|
|
@@ -25,6 +25,7 @@ import com.swmansion.enriched.markdown.utils.common.RenderedSegment
|
|
|
25
25
|
import com.swmansion.enriched.markdown.utils.common.StreamingMarkdownFilter
|
|
26
26
|
import com.swmansion.enriched.markdown.utils.common.TableStreamingMode
|
|
27
27
|
import com.swmansion.enriched.markdown.utils.common.getBooleanOrDefault
|
|
28
|
+
import com.swmansion.enriched.markdown.utils.common.getFloatOrDefault
|
|
28
29
|
import com.swmansion.enriched.markdown.utils.common.getMapOrNull
|
|
29
30
|
import com.swmansion.enriched.markdown.utils.common.getStringOrDefault
|
|
30
31
|
import com.swmansion.enriched.markdown.utils.common.splitASTIntoSegments
|
|
@@ -299,7 +300,6 @@ object MeasurementStore {
|
|
|
299
300
|
|
|
300
301
|
// 2. Render & Measure
|
|
301
302
|
val spannable = tryRenderMarkdown(markdown, styleMap, context, md4cFlags, allowFontScaling, maxFontSizeMultiplier)
|
|
302
|
-
spannable?.replaceMathSpansWithPlaceholders(context)
|
|
303
303
|
val textToMeasure = spannable ?: markdown
|
|
304
304
|
val (size, _) = measureWithLayout(width, textToMeasure, measurePaint, id)
|
|
305
305
|
|
|
@@ -420,7 +420,7 @@ object MeasurementStore {
|
|
|
420
420
|
|
|
421
421
|
when (segment) {
|
|
422
422
|
is RenderedSegment.Text -> {
|
|
423
|
-
segment.styledText.replaceMathSpansWithPlaceholders(context)
|
|
423
|
+
segment.styledText.replaceMathSpansWithPlaceholders(context, style.inlineMathStyle.paddingVertical)
|
|
424
424
|
|
|
425
425
|
val layout = createStaticLayout(segment.styledText, fontSize, widthPx, id)
|
|
426
426
|
totalHeightPx += layout.height
|
|
@@ -503,7 +503,9 @@ object MeasurementStore {
|
|
|
503
503
|
val ast = Parser.shared.parseMarkdown(markdown, md4cFlags) ?: return null
|
|
504
504
|
val style = StyleConfig(styleMap, context, allowFontScaling, maxFontSizeMultiplier)
|
|
505
505
|
measureRenderer.configure(style, context)
|
|
506
|
-
measureRenderer.renderDocument(ast, null)
|
|
506
|
+
measureRenderer.renderDocument(ast, null).apply {
|
|
507
|
+
replaceMathSpansWithPlaceholders(context, style.inlineMathStyle.paddingVertical)
|
|
508
|
+
}
|
|
507
509
|
} catch (e: Exception) {
|
|
508
510
|
Log.w(TAG, "Failed to render markdown for measurement, falling back to raw text", e)
|
|
509
511
|
null
|
|
@@ -517,7 +519,7 @@ object MeasurementStore {
|
|
|
517
519
|
fontScale: Float,
|
|
518
520
|
maxFontSizeMultiplier: Float,
|
|
519
521
|
): Float {
|
|
520
|
-
val fontSizeSp = styleMap
|
|
522
|
+
val fontSizeSp = styleMap.getMapOrNull("paragraph").getFloatOrDefault("fontSize", 16f)
|
|
521
523
|
val density = context.resources.displayMetrics.density
|
|
522
524
|
|
|
523
525
|
if (!allowFontScaling) {
|
|
@@ -27,6 +27,7 @@ import com.swmansion.enriched.markdown.input.events.OnInputBlurEvent
|
|
|
27
27
|
import com.swmansion.enriched.markdown.input.events.OnInputFocusEvent
|
|
28
28
|
import com.swmansion.enriched.markdown.input.events.OnLinkDetectedEvent
|
|
29
29
|
import com.swmansion.enriched.markdown.input.events.OnMathPressEvent
|
|
30
|
+
import com.swmansion.enriched.markdown.input.events.OnPasteEvent
|
|
30
31
|
import com.swmansion.enriched.markdown.input.events.OnRequestCaretRectResultEvent
|
|
31
32
|
import com.swmansion.enriched.markdown.input.events.OnRequestMarkdownResultEvent
|
|
32
33
|
import com.swmansion.enriched.markdown.input.events.OnStartMentionEvent
|
|
@@ -57,6 +58,13 @@ class EnrichedMarkdownTextInputManager :
|
|
|
57
58
|
stateWrapper: StateWrapper?,
|
|
58
59
|
): Any? {
|
|
59
60
|
view.stateWrapper = stateWrapper
|
|
61
|
+
// Fabric applies props before it hands over the state wrapper, so every layout
|
|
62
|
+
// invalidation raised during the mount transaction was dropped. Replay it now that we can
|
|
63
|
+
// actually push state — otherwise the shadow node keeps the initialMeasure() estimate,
|
|
64
|
+
// which ignores math chips, until the first keystroke.
|
|
65
|
+
if (stateWrapper != null) {
|
|
66
|
+
view.layoutManager.flushPendingInvalidation()
|
|
67
|
+
}
|
|
60
68
|
return super.updateState(view, props, stateWrapper)
|
|
61
69
|
}
|
|
62
70
|
|
|
@@ -69,6 +77,11 @@ class EnrichedMarkdownTextInputManager :
|
|
|
69
77
|
view.dismissActiveMention()
|
|
70
78
|
super.onDropViewInstance(view)
|
|
71
79
|
view.layoutManager.release()
|
|
80
|
+
// Unreachable while view recycling is off — it needs a `setupViewRecycling()` call from this
|
|
81
|
+
// constructor *and* ReactNativeFeatureFlags.enableViewRecycling(). Kept because the flush
|
|
82
|
+
// above turns a recycled view into a view that pushes state at mount: without this, it would
|
|
83
|
+
// push into the shadow node it was dropped from.
|
|
84
|
+
view.stateWrapper = null
|
|
72
85
|
}
|
|
73
86
|
|
|
74
87
|
override fun measure(
|
|
@@ -100,6 +113,7 @@ class EnrichedMarkdownTextInputManager :
|
|
|
100
113
|
OnContextMenuItemPressEvent.EVENT_NAME,
|
|
101
114
|
OnLinkDetectedEvent.EVENT_NAME,
|
|
102
115
|
OnMathPressEvent.EVENT_NAME,
|
|
116
|
+
OnPasteEvent.EVENT_NAME,
|
|
103
117
|
OnStartMentionEvent.EVENT_NAME,
|
|
104
118
|
OnChangeMentionEvent.EVENT_NAME,
|
|
105
119
|
OnEndMentionEvent.EVENT_NAME,
|
|
@@ -158,6 +172,14 @@ class EnrichedMarkdownTextInputManager :
|
|
|
158
172
|
view?.isVerticalScrollBarEnabled = value
|
|
159
173
|
}
|
|
160
174
|
|
|
175
|
+
@ReactProp(name = "blockSyntax", defaultBoolean = true)
|
|
176
|
+
override fun setBlockSyntax(
|
|
177
|
+
view: EnrichedMarkdownTextInputView?,
|
|
178
|
+
value: Boolean,
|
|
179
|
+
) {
|
|
180
|
+
view?.blockSyntax = value
|
|
181
|
+
}
|
|
182
|
+
|
|
161
183
|
@ReactProp(name = "autoCapitalize")
|
|
162
184
|
override fun setAutoCapitalize(
|
|
163
185
|
view: EnrichedMarkdownTextInputView?,
|
|
@@ -166,6 +188,14 @@ class EnrichedMarkdownTextInputManager :
|
|
|
166
188
|
view?.setAutoCapitalize(value)
|
|
167
189
|
}
|
|
168
190
|
|
|
191
|
+
@ReactProp(name = "interceptPaste", defaultBoolean = false)
|
|
192
|
+
override fun setInterceptPaste(
|
|
193
|
+
view: EnrichedMarkdownTextInputView?,
|
|
194
|
+
value: Boolean,
|
|
195
|
+
) {
|
|
196
|
+
view?.interceptPaste = value
|
|
197
|
+
}
|
|
198
|
+
|
|
169
199
|
@ReactProp(name = "multiline", defaultBoolean = true)
|
|
170
200
|
override fun setMultiline(
|
|
171
201
|
view: EnrichedMarkdownTextInputView?,
|
|
@@ -497,6 +527,14 @@ class EnrichedMarkdownTextInputManager :
|
|
|
497
527
|
view?.copyToClipboard()
|
|
498
528
|
}
|
|
499
529
|
|
|
530
|
+
override fun resolvePaste(
|
|
531
|
+
view: EnrichedMarkdownTextInputView?,
|
|
532
|
+
text: String?,
|
|
533
|
+
markdown: String?,
|
|
534
|
+
) {
|
|
535
|
+
view?.resolvePaste(text ?: "", markdown ?: "")
|
|
536
|
+
}
|
|
537
|
+
|
|
500
538
|
override fun requestMarkdown(
|
|
501
539
|
view: EnrichedMarkdownTextInputView?,
|
|
502
540
|
requestId: Int,
|