@expensify/react-native-live-markdown 0.1.140 → 0.1.142
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.
|
@@ -18,8 +18,18 @@ find_package(fbjni REQUIRED CONFIG)
|
|
|
18
18
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
19
19
|
find_package(hermes-engine REQUIRED CONFIG)
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
22
|
+
target_link_libraries(${CMAKE_PROJECT_NAME}
|
|
23
|
+
fbjni::fbjni
|
|
24
|
+
ReactAndroid::jsi
|
|
25
|
+
ReactAndroid::reactnative
|
|
26
|
+
hermes-engine::libhermes)
|
|
27
|
+
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 75)
|
|
28
|
+
target_link_libraries(${CMAKE_PROJECT_NAME}
|
|
29
|
+
fbjni::fbjni
|
|
30
|
+
ReactAndroid::jsi
|
|
31
|
+
ReactAndroid::reactnativejni
|
|
32
|
+
hermes-engine::libhermes)
|
|
33
|
+
else ()
|
|
34
|
+
message(FATAL_ERROR "react-native-live-markdown requires react-native 0.75 or newer.")
|
|
35
|
+
endif ()
|
|
@@ -36,42 +36,53 @@ target_include_directories(
|
|
|
36
36
|
|
|
37
37
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
39
|
+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
40
|
+
target_link_libraries(
|
|
41
|
+
${LIB_TARGET_NAME}
|
|
42
|
+
ReactAndroid::reactnative
|
|
43
|
+
ReactAndroid::jsi
|
|
44
|
+
fbjni::fbjni
|
|
45
|
+
)
|
|
46
|
+
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 75)
|
|
47
|
+
target_link_libraries(
|
|
48
|
+
${LIB_TARGET_NAME}
|
|
49
|
+
ReactAndroid::rrc_text
|
|
50
|
+
ReactAndroid::rrc_textinput
|
|
51
|
+
ReactAndroid::react_render_textlayoutmanager
|
|
52
|
+
ReactAndroid::react_render_imagemanager
|
|
53
|
+
ReactAndroid::reactnativejni
|
|
54
|
+
ReactAndroid::mapbufferjni
|
|
55
|
+
fabricjni
|
|
56
|
+
fbjni
|
|
57
|
+
folly_runtime
|
|
58
|
+
glog
|
|
59
|
+
jsi
|
|
60
|
+
react_codegen_rncore
|
|
61
|
+
react_debug
|
|
62
|
+
react_nativemodule_core
|
|
63
|
+
react_render_core
|
|
64
|
+
react_render_debug
|
|
65
|
+
react_render_graphics
|
|
66
|
+
react_render_mapbuffer
|
|
67
|
+
ReactAndroid::react_render_uimanager
|
|
68
|
+
ReactAndroid::react_render_scheduler
|
|
69
|
+
react_utils
|
|
70
|
+
runtimeexecutor
|
|
71
|
+
rrc_view
|
|
72
|
+
turbomodulejsijni
|
|
73
|
+
yoga
|
|
74
|
+
android
|
|
75
|
+
log
|
|
76
|
+
mapbufferjni
|
|
77
|
+
reactnativejni
|
|
78
|
+
react_render_consistency
|
|
79
|
+
react_performance_timeline
|
|
80
|
+
react_render_observers_events
|
|
81
|
+
react_featureflags
|
|
82
|
+
)
|
|
83
|
+
else ()
|
|
84
|
+
message(FATAL_ERROR "react-native-live-markdown requires react-native 0.75 or newer.")
|
|
85
|
+
endif ()
|
|
75
86
|
|
|
76
87
|
target_compile_options(
|
|
77
88
|
${LIB_TARGET_NAME}
|
|
@@ -169,6 +169,53 @@ RootShadowNode::Unshared MarkdownCommitHook::shadowTreeWillCommit(
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
// apply markdown
|
|
173
|
+
auto newString = [utils parseMarkdown:nsAttributedString
|
|
174
|
+
withAttributes:defaultNSTextAttributes];
|
|
175
|
+
|
|
176
|
+
// create a clone of the old TextInputState and update the
|
|
177
|
+
// attributed string box to point to the string with markdown
|
|
178
|
+
// applied
|
|
179
|
+
auto newStateData = std::make_shared<TextInputState>(stateData);
|
|
180
|
+
newStateData->attributedStringBox =
|
|
181
|
+
RCTAttributedStringBoxFromNSAttributedString(newString);
|
|
182
|
+
|
|
183
|
+
// clone the text input with the new state
|
|
184
|
+
return node.clone({
|
|
185
|
+
.state = std::make_shared<const ConcreteState<TextInputState>>(
|
|
186
|
+
newStateData, textInputState),
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
} else if (stateData.attributedStringBox.getMode() ==
|
|
190
|
+
AttributedStringBox::Mode::OpaquePointer) {
|
|
191
|
+
rootNode = rootNode->cloneTree(
|
|
192
|
+
nodes.textInput->getFamily(),
|
|
193
|
+
[&nodes, &textInputState, &stateData,
|
|
194
|
+
fontSizeMultiplier](const ShadowNode &node) {
|
|
195
|
+
const auto &markdownProps = *std::static_pointer_cast<
|
|
196
|
+
MarkdownTextInputDecoratorViewProps const>(
|
|
197
|
+
nodes.decorator->getProps());
|
|
198
|
+
const auto &textInputProps =
|
|
199
|
+
*std::static_pointer_cast<TextInputProps const>(
|
|
200
|
+
nodes.textInput->getProps());
|
|
201
|
+
|
|
202
|
+
const auto defaultTextAttributes =
|
|
203
|
+
textInputProps.getEffectiveTextAttributes(fontSizeMultiplier);
|
|
204
|
+
const auto defaultNSTextAttributes =
|
|
205
|
+
RCTNSTextAttributesFromTextAttributes(defaultTextAttributes);
|
|
206
|
+
|
|
207
|
+
// this can possibly be optimized
|
|
208
|
+
RCTMarkdownStyle *markdownStyle = [[RCTMarkdownStyle alloc]
|
|
209
|
+
initWithStruct:markdownProps.markdownStyle];
|
|
210
|
+
RCTMarkdownUtils *utils = [[RCTMarkdownUtils alloc] init];
|
|
211
|
+
[utils setMarkdownStyle:markdownStyle];
|
|
212
|
+
|
|
213
|
+
// convert the attibuted string stored in state to
|
|
214
|
+
// NSAttributedString
|
|
215
|
+
auto nsAttributedString =
|
|
216
|
+
RCTNSAttributedStringFromAttributedStringBox(
|
|
217
|
+
stateData.attributedStringBox);
|
|
218
|
+
|
|
172
219
|
// apply markdown
|
|
173
220
|
auto newString = [utils parseMarkdown:nsAttributedString
|
|
174
221
|
withAttributes:defaultNSTextAttributes];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expensify/react-native-live-markdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.142",
|
|
4
4
|
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|