From e1ccea1d08b99b073439818b29d34a6746257c14 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Tue, 17 Dec 2024 21:52:21 +0100 Subject: [PATCH 1/9] Fix build with `USE_FRAMEWORKS=static` (#589) --- RNLiveMarkdown.podspec | 11 ++++++++++- example/ios/Podfile.lock | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RNLiveMarkdown.podspec b/RNLiveMarkdown.podspec index de9baafc1..34e9fd00c 100644 --- a/RNLiveMarkdown.podspec +++ b/RNLiveMarkdown.podspec @@ -4,6 +4,10 @@ react_native_node_modules_dir = ENV['REACT_NATIVE_NODE_MODULES_DIR'] || File.joi react_native_json = JSON.parse(File.read(File.join(react_native_node_modules_dir, 'react-native/package.json'))) react_native_minor_version = react_native_json['version'].split('.')[1].to_i +pods_root = Pod::Config.instance.project_pods_root +react_native_reanimated_node_modules_dir = ENV['REACT_NATIVE_REANIMATED_NODE_MODULES_DIR'] || File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-reanimated/package.json')"`) +react_native_reanimated_node_modules_dir_from_pods_root = Pathname.new(react_native_reanimated_node_modules_dir).relative_path_from(pods_root).to_s + package = JSON.parse(File.read(File.join(__dir__, "package.json"))) folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' @@ -23,7 +27,11 @@ Pod::Spec.new do |s| s.dependency "RNReanimated/worklets" s.xcconfig = { - "OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}" + "OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}", + "HEADER_SEARCH_PATHS" => [ + "\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/apple\"", + "\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/Common/cpp\"", + ].join(' '), } install_modules_dependencies(s) @@ -33,6 +41,7 @@ Pod::Spec.new do |s| "react/renderer/textlayoutmanager/platform/ios", "react/renderer/components/textinput/platform/ios", ]) + add_dependency(s, "React-rendererconsistency") end if ENV['RCT_NEW_ARCH_ENABLED'] == '1' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7aed26be2..5a43e11a4 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1497,7 +1497,7 @@ PODS: - React-logger (= 0.75.3) - React-perflogger (= 0.75.3) - React-utils (= 0.75.3) - - RNLiveMarkdown (0.1.205): + - RNLiveMarkdown (0.1.208): - DoubleConversion - glog - hermes-engine @@ -1517,10 +1517,10 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/newarch (= 0.1.205) + - RNLiveMarkdown/newarch (= 0.1.208) - RNReanimated/worklets - Yoga - - RNLiveMarkdown/newarch (0.1.205): + - RNLiveMarkdown/newarch (0.1.208): - DoubleConversion - glog - hermes-engine @@ -1897,7 +1897,7 @@ SPEC CHECKSUMS: React-utils: f2afa6acd905ca2ce7bb8ffb4a22f7f8a12534e8 ReactCodegen: e35c23cdd36922f6d2990c6c1f1b022ade7ad74d ReactCommon: 289214026502e6a93484f4a46bcc0efa4f3f2864 - RNLiveMarkdown: bf0f16b1e8c3320d600a5931d270e19afef9fa92 + RNLiveMarkdown: 1ee098c3a830c3133c23fc163b0aff29398a293e RNReanimated: 75df06d3a81fc147b83056ae469512f573365b1d SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 1354c027ab07c7736f99a3bef16172d6f1b12b47 From 31f36be8731cb5b71c020b2017a04957981e4b37 Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:53:14 +0000 Subject: [PATCH 2/9] Update package-lock.json version to 0.1.209 --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8340261a4..d3d61e4d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.208", + "version": "0.1.209", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@expensify/react-native-live-markdown", - "version": "0.1.208", + "version": "0.1.209", "hasInstallScript": true, "license": "MIT", "workspaces": [ From bc6ef7608e1ea7ba288e645a71bb3f4f060657d6 Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:53:15 +0000 Subject: [PATCH 3/9] Update package.json version to 0.1.209 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index daed2b239..46b0402eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.208", + "version": "0.1.209", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From 8b1789a13e2cbb48ec7b0abe9efc7bc9f2dc57dc Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <56457735+ikevin127@users.noreply.github.com> Date: Wed, 18 Dec 2024 04:44:41 -0800 Subject: [PATCH 4/9] FIX: Android - Live markdown style not applied consistently (#590) --- .../expensify/livemarkdown/MarkdownTextInputDecoratorView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/expensify/livemarkdown/MarkdownTextInputDecoratorView.java b/android/src/main/java/com/expensify/livemarkdown/MarkdownTextInputDecoratorView.java index 6bd1a68fe..b7ab2aa03 100644 --- a/android/src/main/java/com/expensify/livemarkdown/MarkdownTextInputDecoratorView.java +++ b/android/src/main/java/com/expensify/livemarkdown/MarkdownTextInputDecoratorView.java @@ -61,6 +61,7 @@ protected void onAttachedToWindow() { mReactEditText = (ReactEditText) previousSibling; mTextWatcher = new MarkdownTextWatcher(mMarkdownUtils); mReactEditText.addTextChangedListener(mTextWatcher); + applyNewStyles(); } } From b8c6ff393582569c66bd4ec925d21849da3aa103 Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:45:37 +0000 Subject: [PATCH 5/9] Update package-lock.json version to 0.1.210 --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d3d61e4d8..f313c8276 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.209", + "version": "0.1.210", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@expensify/react-native-live-markdown", - "version": "0.1.209", + "version": "0.1.210", "hasInstallScript": true, "license": "MIT", "workspaces": [ From f165434a62852973f1e46b6271a49c8928d73cbe Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:45:38 +0000 Subject: [PATCH 6/9] Update package.json version to 0.1.210 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46b0402eb..17a124aef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.209", + "version": "0.1.210", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From a068201769058888e9d87cbd453101bf4d3afe03 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Sat, 21 Dec 2024 20:19:06 +0100 Subject: [PATCH 7/9] Fix blockquote line height on iOS (#587) --- apple/MarkdownFormatter.mm | 24 ++++++++++++++++-------- example/ios/Podfile.lock | 8 ++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/apple/MarkdownFormatter.mm b/apple/MarkdownFormatter.mm index b84200c97..fdb4116f6 100644 --- a/apple/MarkdownFormatter.mm +++ b/apple/MarkdownFormatter.mm @@ -24,10 +24,15 @@ - (nonnull NSAttributedString *)format:(nonnull NSString *)text type:std::string([markdownRange.type UTF8String]) range:markdownRange.range depth:markdownRange.depth - markdownStyle:markdownStyle]; + markdownStyle:markdownStyle + defaultTextAttributes:defaultTextAttributes]; } - RCTApplyBaselineOffset(attributedString); + [attributedString.string enumerateSubstringsInRange:NSMakeRange(0, attributedString.length) + options:NSStringEnumerationByLines | NSStringEnumerationSubstringNotRequired + usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { + RCTApplyBaselineOffset(attributedString, enclosingRange); + }]; [attributedString endEditing]; @@ -38,7 +43,9 @@ - (void)applyRangeToAttributedString:(NSMutableAttributedString *)attributedStri type:(const std::string)type range:(const NSRange)range depth:(const int)depth - markdownStyle:(nonnull RCTMarkdownStyle *)markdownStyle { + markdownStyle:(nonnull RCTMarkdownStyle *)markdownStyle + defaultTextAttributes:(nonnull NSDictionary *)defaultTextAttributes +{ if (type == "bold" || type == "italic" || type == "code" || type == "pre" || type == "h1" || type == "emoji") { UIFont *font = [attributedString attribute:NSFontAttributeName atIndex:range.location effectiveRange:NULL]; if (type == "bold") { @@ -99,7 +106,8 @@ - (void)applyRangeToAttributedString:(NSMutableAttributedString *)attributedStri [attributedString addAttribute:NSForegroundColorAttributeName value:markdownStyle.linkColor range:range]; } else if (type == "blockquote") { CGFloat indent = (markdownStyle.blockquoteMarginLeft + markdownStyle.blockquoteBorderWidth + markdownStyle.blockquotePaddingLeft) * depth; - NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; + NSParagraphStyle *defaultParagraphStyle = defaultTextAttributes[NSParagraphStyleAttributeName]; + NSMutableParagraphStyle *paragraphStyle = defaultParagraphStyle != nil ? [defaultParagraphStyle mutableCopy] : [NSMutableParagraphStyle new]; paragraphStyle.firstLineHeadIndent = indent; paragraphStyle.headIndent = indent; [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range]; @@ -112,12 +120,12 @@ - (void)applyRangeToAttributedString:(NSMutableAttributedString *)attributedStri } } -static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) +static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText, NSRange attributedTextRange) { __block CGFloat maximumLineHeight = 0; [attributedText enumerateAttribute:NSParagraphStyleAttributeName - inRange:NSMakeRange(0, attributedText.length) + inRange:attributedTextRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSParagraphStyle *paragraphStyle, __unused NSRange range, __unused BOOL *stop) { if (!paragraphStyle) { @@ -135,7 +143,7 @@ static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) __block CGFloat maximumFontLineHeight = 0; [attributedText enumerateAttribute:NSFontAttributeName - inRange:NSMakeRange(0, attributedText.length) + inRange:attributedTextRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(UIFont *font, NSRange range, __unused BOOL *stop) { if (!font) { @@ -152,7 +160,7 @@ static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) CGFloat baseLineOffset = (maximumLineHeight - maximumFontLineHeight) / 2.0; [attributedText addAttribute:NSBaselineOffsetAttributeName value:@(baseLineOffset) - range:NSMakeRange(0, attributedText.length)]; + range:attributedTextRange]; } @end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 5a43e11a4..a8d14f2a2 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1497,7 +1497,7 @@ PODS: - React-logger (= 0.75.3) - React-perflogger (= 0.75.3) - React-utils (= 0.75.3) - - RNLiveMarkdown (0.1.208): + - RNLiveMarkdown (0.1.210): - DoubleConversion - glog - hermes-engine @@ -1517,10 +1517,10 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/newarch (= 0.1.208) + - RNLiveMarkdown/newarch (= 0.1.210) - RNReanimated/worklets - Yoga - - RNLiveMarkdown/newarch (0.1.208): + - RNLiveMarkdown/newarch (0.1.210): - DoubleConversion - glog - hermes-engine @@ -1897,7 +1897,7 @@ SPEC CHECKSUMS: React-utils: f2afa6acd905ca2ce7bb8ffb4a22f7f8a12534e8 ReactCodegen: e35c23cdd36922f6d2990c6c1f1b022ade7ad74d ReactCommon: 289214026502e6a93484f4a46bcc0efa4f3f2864 - RNLiveMarkdown: 1ee098c3a830c3133c23fc163b0aff29398a293e + RNLiveMarkdown: 687bc45ffb3b4af261f414fea169f10eae5ac261 RNReanimated: 75df06d3a81fc147b83056ae469512f573365b1d SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 1354c027ab07c7736f99a3bef16172d6f1b12b47 From 8fbfa803deb69f5adbe518b1b975982712832f60 Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:19:55 +0000 Subject: [PATCH 8/9] Update package-lock.json version to 0.1.211 --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f313c8276..dee2f10c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.210", + "version": "0.1.211", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@expensify/react-native-live-markdown", - "version": "0.1.210", + "version": "0.1.211", "hasInstallScript": true, "license": "MIT", "workspaces": [ From 6447ea9ec54830f1d55c1eac0e9274ce93a4c769 Mon Sep 17 00:00:00 2001 From: "os-botify[bot]" <140437396+os-botify[bot]@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:19:56 +0000 Subject: [PATCH 9/9] Update package.json version to 0.1.211 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17a124aef..9e554fc2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.210", + "version": "0.1.211", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index",