diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h index faa1bb6a..13756877 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h @@ -2,8 +2,8 @@ #include "MarkdownContainerMeasurementManager.h" #include "MarkdownContainerShadowNode.h" -#include "MarkdownInputMeasurementManager.h" -#include "MarkdownInputShadowNode.h" +#include "MarkdownTextInputMeasurementManager.h" +#include "MarkdownTextInputShadowNode.h" #include "MarkdownTextMeasurementManager.h" #include "MarkdownTextShadowNode.h" @@ -44,20 +44,21 @@ class EnrichedMarkdownTextComponentDescriptor final : public ConcreteComponentDe const std::shared_ptr measurementsManager_; }; -class EnrichedMarkdownTextInputComponentDescriptor final : public ConcreteComponentDescriptor { +class EnrichedMarkdownTextInputComponentDescriptor final + : public ConcreteComponentDescriptor { public: EnrichedMarkdownTextInputComponentDescriptor(const ComponentDescriptorParameters ¶meters) : ConcreteComponentDescriptor(parameters), - measurementsManager_(std::make_shared(contextContainer_)) {} + measurementsManager_(std::make_shared(contextContainer_)) {} void adopt(ShadowNode &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - auto &inputShadowNode = static_cast(shadowNode); + auto &inputShadowNode = static_cast(shadowNode); inputShadowNode.setMeasurementsManager(measurementsManager_); } private: - const std::shared_ptr measurementsManager_; + const std::shared_ptr measurementsManager_; }; void EnrichedMarkdownTextSpec_registerComponentDescriptorsFromCodegen( diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.cpp b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.cpp deleted file mode 100644 index 3a32df33..00000000 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "MarkdownInputState.h" - -namespace facebook::react { - -int MarkdownInputState::getForceHeightRecalculationCounter() const { - return forceHeightRecalculationCounter_; -} - -} // namespace facebook::react diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.cpp b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.cpp similarity index 84% rename from android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.cpp rename to android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.cpp index 760e0e0c..29026f7a 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.cpp +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.cpp @@ -1,4 +1,4 @@ -#include "MarkdownInputMeasurementManager.h" +#include "MarkdownTextInputMeasurementManager.h" #include "conversions.h" #include @@ -9,9 +9,9 @@ using namespace facebook::jni; namespace facebook::react { -Size MarkdownInputMeasurementManager::measure(SurfaceId surfaceId, int viewTag, - const EnrichedMarkdownTextInputProps &props, - LayoutConstraints layoutConstraints) const { +Size MarkdownTextInputMeasurementManager::measure(SurfaceId surfaceId, int viewTag, + const EnrichedMarkdownTextInputProps &props, + LayoutConstraints layoutConstraints) const { const jni::global_ref &fabricUIManager = contextContainer_->at>("FabricUIManager"); static const auto measure = diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.h b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.h similarity index 78% rename from android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.h rename to android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.h index 117b949e..5eadd0bb 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputMeasurementManager.h +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.h @@ -6,9 +6,9 @@ namespace facebook::react { -class MarkdownInputMeasurementManager { +class MarkdownTextInputMeasurementManager { public: - MarkdownInputMeasurementManager(const std::shared_ptr &contextContainer) + MarkdownTextInputMeasurementManager(const std::shared_ptr &contextContainer) : contextContainer_(contextContainer) {} Size measure(SurfaceId surfaceId, int viewTag, const EnrichedMarkdownTextInputProps &props, diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.cpp b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.cpp similarity index 50% rename from android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.cpp rename to android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.cpp index c00291b6..ac18fda9 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.cpp +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.cpp @@ -1,18 +1,18 @@ -#include "MarkdownInputShadowNode.h" +#include "MarkdownTextInputShadowNode.h" #include namespace facebook::react { -extern const char MarkdownInputComponentName[] = "EnrichedMarkdownTextInput"; +extern const char MarkdownTextInputComponentName[] = "EnrichedMarkdownTextInput"; -void MarkdownInputShadowNode::setMeasurementsManager( - const std::shared_ptr &measurementsManager) { +void MarkdownTextInputShadowNode::setMeasurementsManager( + const std::shared_ptr &measurementsManager) { ensureUnsealed(); measurementsManager_ = measurementsManager; } -void MarkdownInputShadowNode::dirtyLayoutIfNeeded() { +void MarkdownTextInputShadowNode::dirtyLayoutIfNeeded() { const auto state = this->getStateData(); const auto counter = state.getForceHeightRecalculationCounter(); @@ -22,8 +22,8 @@ void MarkdownInputShadowNode::dirtyLayoutIfNeeded() { } } -Size MarkdownInputShadowNode::measureContent(const LayoutContext &layoutContext, - const LayoutConstraints &layoutConstraints) const { +Size MarkdownTextInputShadowNode::measureContent(const LayoutContext &layoutContext, + const LayoutConstraints &layoutConstraints) const { return measurementsManager_->measure(getSurfaceId(), getTag(), getConcreteProps(), layoutConstraints); } diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.h b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.h similarity index 60% rename from android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.h rename to android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.h index 9068a317..22cabef6 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputShadowNode.h +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.h @@ -1,7 +1,7 @@ #pragma once -#include "MarkdownInputMeasurementManager.h" -#include "MarkdownInputState.h" +#include "MarkdownTextInputMeasurementManager.h" +#include "MarkdownTextInputState.h" #include #include @@ -9,15 +9,15 @@ namespace facebook::react { -JSI_EXPORT extern const char MarkdownInputComponentName[]; +JSI_EXPORT extern const char MarkdownTextInputComponentName[]; -class MarkdownInputShadowNode final - : public ConcreteViewShadowNode { +class MarkdownTextInputShadowNode final + : public ConcreteViewShadowNode { public: using ConcreteViewShadowNode::ConcreteViewShadowNode; - MarkdownInputShadowNode(ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment) + MarkdownTextInputShadowNode(ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment) : ConcreteViewShadowNode(sourceShadowNode, fragment) { dirtyLayoutIfNeeded(); } @@ -29,7 +29,7 @@ class MarkdownInputShadowNode final return traits; } - void setMeasurementsManager(const std::shared_ptr &measurementsManager); + void setMeasurementsManager(const std::shared_ptr &measurementsManager); void dirtyLayoutIfNeeded(); @@ -37,7 +37,7 @@ class MarkdownInputShadowNode final private: int forceHeightRecalculationCounter_{0}; - std::shared_ptr measurementsManager_; + std::shared_ptr measurementsManager_; }; } // namespace facebook::react diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.cpp b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.cpp new file mode 100644 index 00000000..fdbd2292 --- /dev/null +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.cpp @@ -0,0 +1,9 @@ +#include "MarkdownTextInputState.h" + +namespace facebook::react { + +int MarkdownTextInputState::getForceHeightRecalculationCounter() const { + return forceHeightRecalculationCounter_; +} + +} // namespace facebook::react diff --git a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.h b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.h similarity index 66% rename from android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.h rename to android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.h index ad5d2403..537e9622 100644 --- a/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownInputState.h +++ b/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.h @@ -4,11 +4,11 @@ namespace facebook::react { -class MarkdownInputState { +class MarkdownTextInputState { public: - MarkdownInputState() : forceHeightRecalculationCounter_(0) {} + MarkdownTextInputState() : forceHeightRecalculationCounter_(0) {} - MarkdownInputState(MarkdownInputState const &previousState, folly::dynamic data) + MarkdownTextInputState(MarkdownTextInputState const &previousState, folly::dynamic data) : forceHeightRecalculationCounter_((int)data["forceHeightRecalculationCounter"].getInt()) {} folly::dynamic getDynamic() const { diff --git a/ios/input/ENRMInputTextView.h b/ios/input/ENRMInputTextView.h index faef86f9..1c4f40ff 100644 --- a/ios/input/ENRMInputTextView.h +++ b/ios/input/ENRMInputTextView.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ENRMInputTextView : ENRMPlatformTextView -@property (nonatomic, weak, nullable) EnrichedMarkdownTextInput *markdownInput; +@property (nonatomic, weak, nullable) EnrichedMarkdownTextInput *markdownTextInput; @end NS_ASSUME_NONNULL_END diff --git a/ios/input/ENRMInputTextView.mm b/ios/input/ENRMInputTextView.mm index c4131749..187cf5b4 100644 --- a/ios/input/ENRMInputTextView.mm +++ b/ios/input/ENRMInputTextView.mm @@ -20,7 +20,7 @@ - (void)copy:(id)sender } NSString *plainText = [self.text substringWithRange:selection]; - NSString *markdown = [self.markdownInput markdownForSelectedRange]; + NSString *markdown = [self.markdownTextInput markdownForSelectedRange]; UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSMutableDictionary *items = [NSMutableDictionary dictionary]; @@ -49,8 +49,8 @@ - (void)paste:(id)sender markdown = [[NSString alloc] initWithData:markdownValue encoding:NSUTF8StringEncoding]; } - if (markdown.length > 0 && self.markdownInput != nil) { - [self.markdownInput pasteMarkdown:markdown]; + if (markdown.length > 0 && self.markdownTextInput != nil) { + [self.markdownTextInput pasteMarkdown:markdown]; return; } @@ -74,8 +74,8 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender - (void)layoutSubviews { [super layoutSubviews]; - if (self.markdownInput != nil) { - [self.markdownInput scheduleRelayoutIfNeeded]; + if (self.markdownTextInput != nil) { + [self.markdownTextInput scheduleRelayoutIfNeeded]; } } @@ -93,7 +93,7 @@ - (void)copy:(id)sender } NSString *plainText = [self.string substringWithRange:selection]; - NSString *markdown = [self.markdownInput markdownForSelectedRange]; + NSString *markdown = [self.markdownTextInput markdownForSelectedRange]; NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; [pasteboard clearContents]; @@ -121,8 +121,8 @@ - (void)paste:(id)sender NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; NSString *markdown = [pasteboard stringForType:kENRMMarkdownPasteboardType]; - if (markdown.length > 0 && self.markdownInput != nil) { - [self.markdownInput pasteMarkdown:markdown]; + if (markdown.length > 0 && self.markdownTextInput != nil) { + [self.markdownTextInput pasteMarkdown:markdown]; return; } @@ -158,8 +158,8 @@ - (void)mouseDown:(NSEvent *)event - (NSMenu *)menuForEvent:(NSEvent *)event { NSMenu *menu = [super menuForEvent:event]; - if (self.markdownInput != nil) { - return [self.markdownInput enrichedMenuForEvent:event defaultMenu:menu textView:self]; + if (self.markdownTextInput != nil) { + return [self.markdownTextInput enrichedMenuForEvent:event defaultMenu:menu textView:self]; } return menu; } @@ -167,8 +167,8 @@ - (NSMenu *)menuForEvent:(NSEvent *)event - (void)layout { [super layout]; - if (self.markdownInput != nil) { - [self.markdownInput scheduleRelayoutIfNeeded]; + if (self.markdownTextInput != nil) { + [self.markdownTextInput scheduleRelayoutIfNeeded]; } } diff --git a/ios/input/EnrichedMarkdownTextInput.mm b/ios/input/EnrichedMarkdownTextInput.mm index 016d341e..96969e8a 100644 --- a/ios/input/EnrichedMarkdownTextInput.mm +++ b/ios/input/EnrichedMarkdownTextInput.mm @@ -146,9 +146,9 @@ - (void)setupTextView #else ENRMInputTextView *inputTextView = [[ENRMInputTextView alloc] initWithFrame:CGRectZero]; #endif - inputTextView.markdownInput = self; + inputTextView.markdownTextInput = self; _textView = inputTextView; - ENRMConfigureMarkdownInputTextView(_textView); + ENRMConfigureMarkdownTextInputTextView(_textView); #if !TARGET_OS_OSX _textView.adjustsFontForContentSizeCategory = YES; _textView.delegate = self; diff --git a/ios/utils/ENRMUIKit.h b/ios/utils/ENRMUIKit.h index 37a7f927..477e5fed 100644 --- a/ios/utils/ENRMUIKit.h +++ b/ios/utils/ENRMUIKit.h @@ -176,7 +176,7 @@ static inline void ENRMSetDefaultTypingAttributes(ENRMPlatformTextView *textView /// Applies shared configuration to a text view used for markdown input editing. /// Handles platform differences: scroll indicators, text container insets, /// drawsBackground (macOS). Sets editable=YES, scrollEnabled=YES. -static inline void ENRMConfigureMarkdownInputTextView(ENRMPlatformTextView *textView) +static inline void ENRMConfigureMarkdownTextInputTextView(ENRMPlatformTextView *textView) { textView.font = [UIFont systemFontOfSize:16.0]; textView.backgroundColor = [RCTUIColor clearColor];