Skip to content

Commit

Permalink
Merge branch 'main' into @tomekzaw/worklets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Sep 13, 2024
2 parents b744c05 + c964d91 commit 5aeb9dc
Show file tree
Hide file tree
Showing 38 changed files with 741 additions and 224 deletions.
6 changes: 3 additions & 3 deletions RNLiveMarkdown.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Pod::Spec.new do |s|

install_modules_dependencies(s)

if ENV['USE_FRAMEWORKS'] && ENV['RCT_NEW_ARCH_ENABLED']
add_dependency(s, "React-Fabric", :additional_framework_paths => [
if ENV['USE_FRAMEWORKS'] != nil && ENV['RCT_NEW_ARCH_ENABLED'] == '1'
add_dependency(s, "React-FabricComponents", :additional_framework_paths => [
"react/renderer/textlayoutmanager/platform/ios",
"react/renderer/components/textinput/iostextinput",
"react/renderer/components/textinput/platform/ios",
])
end

Expand Down
2 changes: 1 addition & 1 deletion WebExample/__tests__/styles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe('markdown content styling', () => {

test('blockquote', async ({page, browserName}) => {
const blockquoteStyle =
'border-color: gray; border-width: 6px; margin-left: 6px; padding-left: 6px; border-left-style: solid; display: inline-block; max-width: 100%; box-sizing: border-box;';
'border-color: gray; border-width: 6px; margin-left: 6px; padding-left: 6px; border-left-style: solid; display: inline-block; max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere;';

// Firefox border properties are serialized slightly differently
const browserStyle = browserName === 'firefox' ? blockquoteStyle.replace('border-left-style: solid', 'border-left: 6px solid gray') : blockquoteStyle;
Expand Down
26 changes: 26 additions & 0 deletions android/src/main/assets/react-native-live-markdown-parser.js

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions android/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(react-native-reanimated REQUIRED CONFIG)

target_link_libraries(${CMAKE_PROJECT_NAME}
fbjni::fbjni
react-native-reanimated::worklets
ReactAndroid::jsi
ReactAndroid::reactnativejni
ReactAndroid::runtimeexecutor
ReactAndroid::react_nativemodule_core)
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
target_link_libraries(${CMAKE_PROJECT_NAME}
fbjni::fbjni
ReactAndroid::jsi
ReactAndroid::reactnative
react-native-reanimated::worklets
hermes-engine::libhermes)
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 75)
target_link_libraries(${CMAKE_PROJECT_NAME}
fbjni::fbjni
ReactAndroid::jsi
ReactAndroid::reactnativejni
react-native-reanimated::worklets
hermes-engine::libhermes)
else ()
message(FATAL_ERROR "react-native-live-markdown requires react-native 0.75 or newer.")
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
public class MarkdownTextWatcher implements TextWatcher {
private final MarkdownUtils mMarkdownUtils;

private boolean mShouldSkip = false;

public MarkdownTextWatcher(@NonNull MarkdownUtils markdownUtils) {
mMarkdownUtils = markdownUtils;
}
Expand All @@ -22,17 +20,13 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (mShouldSkip) {
return;
}
if (s instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) s);
mShouldSkip = true;
}

}

@Override
public void afterTextChanged(Editable editable) {
mShouldSkip = false;
if (editable instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) editable);
}
}
}
83 changes: 47 additions & 36 deletions android/src/main/new_arch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,53 @@ target_include_directories(

find_package(ReactAndroid REQUIRED CONFIG)

target_link_libraries(
${LIB_TARGET_NAME}
ReactAndroid::rrc_text
ReactAndroid::rrc_textinput
ReactAndroid::react_render_textlayoutmanager
ReactAndroid::react_render_imagemanager
ReactAndroid::reactnativejni
ReactAndroid::mapbufferjni
fabricjni
fbjni
folly_runtime
glog
jsi
react_codegen_rncore
react_debug
react_nativemodule_core
react_render_core
react_render_debug
react_render_graphics
react_render_mapbuffer
ReactAndroid::react_render_uimanager
ReactAndroid::react_render_scheduler
react_utils
runtimeexecutor
rrc_view
turbomodulejsijni
yoga
android
log
mapbufferjni
reactnativejni
react_render_consistency
react_performance_timeline
react_render_observers_events
react_featureflags
)
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
target_link_libraries(
${LIB_TARGET_NAME}
ReactAndroid::reactnative
ReactAndroid::jsi
fbjni::fbjni
)
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 75)
target_link_libraries(
${LIB_TARGET_NAME}
ReactAndroid::rrc_text
ReactAndroid::rrc_textinput
ReactAndroid::react_render_textlayoutmanager
ReactAndroid::react_render_imagemanager
ReactAndroid::reactnativejni
ReactAndroid::mapbufferjni
fabricjni
fbjni
folly_runtime
glog
jsi
react_codegen_rncore
react_debug
react_nativemodule_core
react_render_core
react_render_debug
react_render_graphics
react_render_mapbuffer
ReactAndroid::react_render_uimanager
ReactAndroid::react_render_scheduler
react_utils
runtimeexecutor
rrc_view
turbomodulejsijni
yoga
android
log
mapbufferjni
reactnativejni
react_render_consistency
react_performance_timeline
react_render_observers_events
react_featureflags
)
else ()
message(FATAL_ERROR "react-native-live-markdown requires react-native 0.75 or newer.")
endif ()

target_compile_options(
${LIB_TARGET_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "MarkdownShadowFamilyRegistry.h"

namespace expensify {
namespace livemarkdown {

std::set<facebook::react::ShadowNodeFamily::Shared>
MarkdownShadowFamilyRegistry::familiesToUpdate_;
std::set<facebook::react::Tag> MarkdownShadowFamilyRegistry::forcedUpdates_;
Expand Down Expand Up @@ -55,4 +58,7 @@ bool MarkdownShadowFamilyRegistry::shouldForceUpdate(facebook::react::Tag tag) {
return false;
}

} // namespace livemarkdown
} // namespace expensify

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <mutex>
#include <set>

namespace expensify {
namespace livemarkdown {

// A registry to store pointers to the ShadowNodeFamilies of markdown
// decorators. The only place we can _legally_ access the family of shadow node
// is in the constructor and we need it inside commit hook. To achieve it, we
Expand All @@ -32,4 +35,7 @@ class MarkdownShadowFamilyRegistry {
static std::mutex mutex_;
};

} // namespace livemarkdown
} // namespace expensify

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "MarkdownShadowFamilyRegistry.h"
#include "MarkdownTextInputDecoratorShadowNode.h"

using namespace expensify::livemarkdown;

namespace facebook {
namespace react {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <react/renderer/components/RNLiveMarkdownSpec/Props.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>

using namespace expensify::livemarkdown;

namespace facebook {
namespace react {

Expand Down
16 changes: 8 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autoli
rootProject.name = 'LiveMarkdownExample'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../node_modules/react-native') {
dependencySubstitution {
substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
}
}
// includeBuild('../node_modules/react-native') {
// dependencySubstitution {
// substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
// substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
// substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
// substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
// }
// }
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ PODS:
- React-logger (= 0.75.2)
- React-perflogger (= 0.75.2)
- React-utils (= 0.75.2)
- RNLiveMarkdown (0.1.132):
- RNLiveMarkdown (0.1.145):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1517,10 +1517,10 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNLiveMarkdown/common (= 0.1.132)
- RNLiveMarkdown/common (= 0.1.145)
- RNReanimated/worklets
- Yoga
- RNLiveMarkdown/common (0.1.132):
- RNLiveMarkdown/common (0.1.145):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1875,7 +1875,7 @@ SPEC CHECKSUMS:
React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb
ReactCodegen: 60973d382704c793c605b9be0fc7f31cb279442f
ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b
RNLiveMarkdown: dec90bce136a6f3a682e8bb92667bcf79c9f118c
RNLiveMarkdown: 4b0919b7d1faf7704206b5d8d2985b6c7f317673
RNReanimated: 070deccceef093bec96ac3f87ef8c7f361caf754
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "react-native start"
},
"dependencies": {
"expensify-common": "2.0.76",
"expensify-common": "2.0.85",
"react": "18.3.1",
"react-native": "0.75.2",
"react-native-reanimated": "3.15.0"
Expand Down
Loading

0 comments on commit 5aeb9dc

Please sign in to comment.