From bf7d949489a682268de36170b4503b755ad4efa4 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Wed, 11 Sep 2024 15:48:07 +0200 Subject: [PATCH 1/8] Disable building example app from source on Android (#478) --- example/android/settings.gradle | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/example/android/settings.gradle b/example/android/settings.gradle index a4b10f0e..66a7a71a 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -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")) +// } +// } From d4270798deb4791e377f9c1a897b5147ca124952 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Wed, 11 Sep 2024 13:49:43 +0000 Subject: [PATCH 2/8] Bump version to 0.1.136 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2d88e32..090d0d0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.135", + "version": "0.1.136", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From 8a4472a24b0ccb276bf836958e6977dfe263133e Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Wed, 11 Sep 2024 17:05:14 +0200 Subject: [PATCH 3/8] Add missing C++ namespaces (#480) --- .../MarkdownShadowFamilyRegistry.cpp | 6 ++++++ .../RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.h | 6 ++++++ .../MarkdownTextInputDecoratorShadowNode.cpp | 2 ++ .../MarkdownTextInputDecoratorShadowNode.h | 2 ++ example/ios/Podfile.lock | 10 +++++----- ios/MarkdownCommitHook.h | 2 ++ ios/MarkdownCommitHook.mm | 2 ++ ios/RCTLiveMarkdownModule.mm | 7 ++++--- ios/RCTTextInputComponentView+Markdown.mm | 2 ++ 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.cpp b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.cpp index 1a0f4a74..de564b32 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.cpp +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.cpp @@ -2,6 +2,9 @@ #include "MarkdownShadowFamilyRegistry.h" +namespace expensify { +namespace livemarkdown { + std::set MarkdownShadowFamilyRegistry::familiesToUpdate_; std::set MarkdownShadowFamilyRegistry::forcedUpdates_; @@ -55,4 +58,7 @@ bool MarkdownShadowFamilyRegistry::shouldForceUpdate(facebook::react::Tag tag) { return false; } +} // namespace livemarkdown +} // namespace expensify + #endif diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.h b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.h index f76c87d8..4e9431b5 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.h +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownShadowFamilyRegistry.h @@ -6,6 +6,9 @@ #include #include +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 @@ -32,4 +35,7 @@ class MarkdownShadowFamilyRegistry { static std::mutex mutex_; }; +} // namespace livemarkdown +} // namespace expensify + #endif diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp index 9240e9eb..ae56126d 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp @@ -5,6 +5,8 @@ #include "MarkdownShadowFamilyRegistry.h" #include "MarkdownTextInputDecoratorShadowNode.h" +using namespace expensify::livemarkdown; + namespace facebook { namespace react { diff --git a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h index 597752cb..3392d557 100644 --- a/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h +++ b/cpp/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.h @@ -8,6 +8,8 @@ #include #include +using namespace expensify::livemarkdown; + namespace facebook { namespace react { diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index aab42016..a8b209b1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1497,7 +1497,7 @@ PODS: - React-logger (= 0.75.2) - React-perflogger (= 0.75.2) - React-utils (= 0.75.2) - - RNLiveMarkdown (0.1.128): + - RNLiveMarkdown (0.1.135): - DoubleConversion - glog - hermes-engine @@ -1517,9 +1517,9 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/common (= 0.1.128) + - RNLiveMarkdown/common (= 0.1.135) - Yoga - - RNLiveMarkdown/common (0.1.128): + - RNLiveMarkdown/common (0.1.135): - DoubleConversion - glog - hermes-engine @@ -1805,10 +1805,10 @@ SPEC CHECKSUMS: React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb ReactCodegen: 60973d382704c793c605b9be0fc7f31cb279442f ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b - RNLiveMarkdown: 44cc9af8742cfd5355733d29fa54e64e4edf0f0d + RNLiveMarkdown: 77f3338039cf98111a753256849b90567a41fc53 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae PODFILE CHECKSUM: 9b81b0f7bfba9e6fb4fa10efe8319f7860794e08 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/ios/MarkdownCommitHook.h b/ios/MarkdownCommitHook.h index 92f0acaf..ac6cc45e 100644 --- a/ios/MarkdownCommitHook.h +++ b/ios/MarkdownCommitHook.h @@ -11,6 +11,7 @@ using namespace facebook::react; +namespace expensify { namespace livemarkdown { struct MarkdownTextInputDecoratorPair { @@ -38,5 +39,6 @@ class MarkdownCommitHook : public UIManagerCommitHook { }; } // namespace livemarkdown +} // namespace expensify #endif // RCT_NEW_ARCH_ENABLED diff --git a/ios/MarkdownCommitHook.mm b/ios/MarkdownCommitHook.mm index 53f3ddd3..6524cac9 100644 --- a/ios/MarkdownCommitHook.mm +++ b/ios/MarkdownCommitHook.mm @@ -11,6 +11,7 @@ using namespace facebook::react; +namespace expensify { namespace livemarkdown { MarkdownCommitHook::MarkdownCommitHook( @@ -192,5 +193,6 @@ } } // namespace livemarkdown +} // namespace expensify #endif // RCT_NEW_ARCH_ENABLED diff --git a/ios/RCTLiveMarkdownModule.mm b/ios/RCTLiveMarkdownModule.mm index 24bbcb84..53e91785 100644 --- a/ios/RCTLiveMarkdownModule.mm +++ b/ios/RCTLiveMarkdownModule.mm @@ -7,13 +7,15 @@ #import "MarkdownShadowFamilyRegistry.h" #import "RCTLiveMarkdownModule.h" +using namespace expensify::livemarkdown; + // A turbomodule used to register the commit hook // I think this is the easiest way to access the UIManager, which we need to // actually register the hook @implementation RCTLiveMarkdownModule { BOOL installed_; - std::shared_ptr commitHook_; + std::shared_ptr commitHook_; __weak RCTSurfacePresenter *surfacePresenter_; } @@ -23,8 +25,7 @@ - (NSNumber *)install { if (!installed_ && surfacePresenter_ != nil) { RCTScheduler *scheduler = [surfacePresenter_ scheduler]; - commitHook_ = - std::make_shared(scheduler.uiManager); + commitHook_ = std::make_shared(scheduler.uiManager); installed_ = YES; } return @1; diff --git a/ios/RCTTextInputComponentView+Markdown.mm b/ios/RCTTextInputComponentView+Markdown.mm index 3161e00d..5ce1e63e 100644 --- a/ios/RCTTextInputComponentView+Markdown.mm +++ b/ios/RCTTextInputComponentView+Markdown.mm @@ -8,6 +8,8 @@ #import "MarkdownShadowFamilyRegistry.h" +using namespace expensify::livemarkdown; + @implementation RCTTextInputComponentView (Markdown) - (void)setMarkdownUtils:(RCTMarkdownUtils *)markdownUtils { From fadfc7ed98362b06d5a27f9867b3bc748d2f6938 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Wed, 11 Sep 2024 15:06:49 +0000 Subject: [PATCH 4/8] Bump version to 0.1.137 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 090d0d0b..7eb8bf9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.136", + "version": "0.1.137", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From c5f7e61b553da275f380d425dac11fec0fe0f9db Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Wed, 11 Sep 2024 19:34:34 +0200 Subject: [PATCH 5/8] Add missing `NS_ASSUME_NONNULL` macro (#479) --- example/ios/Podfile.lock | 8 ++++---- ios/RCTLiveMarkdownModule.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a8b209b1..cc793edc 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1497,7 +1497,7 @@ PODS: - React-logger (= 0.75.2) - React-perflogger (= 0.75.2) - React-utils (= 0.75.2) - - RNLiveMarkdown (0.1.135): + - RNLiveMarkdown (0.1.137): - DoubleConversion - glog - hermes-engine @@ -1517,9 +1517,9 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/common (= 0.1.135) + - RNLiveMarkdown/common (= 0.1.137) - Yoga - - RNLiveMarkdown/common (0.1.135): + - RNLiveMarkdown/common (0.1.137): - DoubleConversion - glog - hermes-engine @@ -1805,7 +1805,7 @@ SPEC CHECKSUMS: React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb ReactCodegen: 60973d382704c793c605b9be0fc7f31cb279442f ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b - RNLiveMarkdown: 77f3338039cf98111a753256849b90567a41fc53 + RNLiveMarkdown: b2d706acf1bbd968b8dab0be0dc69f130a14db6d SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae diff --git a/ios/RCTLiveMarkdownModule.h b/ios/RCTLiveMarkdownModule.h index ceee8fef..6494594d 100644 --- a/ios/RCTLiveMarkdownModule.h +++ b/ios/RCTLiveMarkdownModule.h @@ -4,9 +4,13 @@ #import #import +NS_ASSUME_NONNULL_BEGIN + // Without inheriting after RCTEventEmitter we don't get access to bridge @interface RCTLiveMarkdownModule : RCTEventEmitter @end +NS_ASSUME_NONNULL_END + #endif // RCT_NEW_ARCH_ENABLED From b91644bfdc95992d800928589ff4ed861239b81c Mon Sep 17 00:00:00 2001 From: OSBotify Date: Wed, 11 Sep 2024 17:36:10 +0000 Subject: [PATCH 6/8] Bump version to 0.1.138 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7eb8bf9b..5cfb53ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.137", + "version": "0.1.138", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index", From 6d52e57b524a48a99d50bea93d2dc67c43c82105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= <39538890+Skalakid@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:02:54 -0700 Subject: [PATCH 7/8] Fix single line input (#482) --- src/MarkdownTextInput.web.tsx | 8 ++++---- src/web/MarkdownTextInput.css | 18 ++++++++++-------- src/web/utils/blockUtils.ts | 1 - 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index acad2515..0b5ff64a 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -149,7 +149,7 @@ const MarkdownTextInput = React.forwardRef( if (text === null) { return {text: divRef.current.value, cursorPosition: null}; } - const parsedText = updateInputStructure(target, text, cursorPosition, customMarkdownStyles, !multiline, shouldForceDOMUpdate); + const parsedText = updateInputStructure(target, text, cursorPosition, customMarkdownStyles, false, shouldForceDOMUpdate); divRef.current.value = parsedText.text; if (history.current && shouldAddToHistory) { @@ -158,7 +158,7 @@ const MarkdownTextInput = React.forwardRef( return parsedText; }, - [multiline], + [], ); const processedMarkdownStyle = useMemo(() => { @@ -176,10 +176,11 @@ const MarkdownTextInput = React.forwardRef( flattenedStyle && { caretColor: (flattenedStyle as TextStyle).color || 'black', }, + {whiteSpace: multiline ? 'pre-wrap' : 'nowrap'}, disabled && styles.disabledInputStyles, parseToReactDOMStyle(flattenedStyle), ]) as CSSProperties, - [flattenedStyle, disabled], + [flattenedStyle, multiline, disabled], ); const undo = useCallback( @@ -683,7 +684,6 @@ const styles = StyleSheet.create({ fontFamily: 'sans-serif', // @ts-expect-error it works on web boxSizing: 'border-box', - whiteSpace: 'pre-wrap', overflowY: 'auto', overflowX: 'auto', overflowWrap: 'break-word', diff --git a/src/web/MarkdownTextInput.css b/src/web/MarkdownTextInput.css index 4fc0171d..941bf67c 100644 --- a/src/web/MarkdownTextInput.css +++ b/src/web/MarkdownTextInput.css @@ -1,6 +1,13 @@ -.react-native-live-markdown-input-singleline { - white-space: nowrap; - overflow: auto; +.react-native-live-markdown-input-multiline { + white-space: pre-wrap; +} + +.react-native-live-markdown-input-singleline p { + display: inline-block; +} + +.react-native-live-markdown-input-multiline p { + display: block; } .react-native-live-markdown-input-singleline::-webkit-scrollbar { @@ -11,11 +18,6 @@ display: none; } -.react-native-live-markdown-input-singleline * { - display: inline; - white-space: nowrap; -} - .react-native-live-markdown-input-singleline:empty::before, .react-native-live-markdown-input-multiline:empty::before { pointer-events: none; diff --git a/src/web/utils/blockUtils.ts b/src/web/utils/blockUtils.ts index 887ef4e1..73b72066 100644 --- a/src/web/utils/blockUtils.ts +++ b/src/web/utils/blockUtils.ts @@ -6,7 +6,6 @@ function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownSty switch (type) { case 'line': Object.assign(node.style, { - display: 'block', margin: '0', padding: '0', }); From 286eab790b0ec080e97d877e31524c6697fcb685 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Thu, 12 Sep 2024 06:04:29 +0000 Subject: [PATCH 8/8] Bump version to 0.1.139 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5cfb53ba..abcbb104 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expensify/react-native-live-markdown", - "version": "0.1.138", + "version": "0.1.139", "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.", "main": "lib/commonjs/index", "module": "lib/module/index",