Replace react-native-paste-input with expo-paste-input (#10158)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
+1
-1
@@ -109,7 +109,6 @@
|
|||||||
"@ipld/dag-cbor": "^9.2.0",
|
"@ipld/dag-cbor": "^9.2.0",
|
||||||
"@lingui/core": "^5.9.2",
|
"@lingui/core": "^5.9.2",
|
||||||
"@lingui/react": "^5.9.2",
|
"@lingui/react": "^5.9.2",
|
||||||
"@mattermost/react-native-paste-input": "mattermost/react-native-paste-input",
|
|
||||||
"@miblanchard/react-native-slider": "^2.6.0",
|
"@miblanchard/react-native-slider": "^2.6.0",
|
||||||
"@mozzius/expo-dynamic-app-icon": "^1.8.0",
|
"@mozzius/expo-dynamic-app-icon": "^1.8.0",
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
@@ -167,6 +166,7 @@
|
|||||||
"expo-location": "~19.0.8",
|
"expo-location": "~19.0.8",
|
||||||
"expo-media-library": "~18.2.1",
|
"expo-media-library": "~18.2.1",
|
||||||
"expo-notifications": "~0.32.16",
|
"expo-notifications": "~0.32.16",
|
||||||
|
"expo-paste-input": "^0.1.10",
|
||||||
"expo-privacy-sensitive": "^0.1.0",
|
"expo-privacy-sensitive": "^0.1.0",
|
||||||
"expo-screen-orientation": "~9.0.8",
|
"expo-screen-orientation": "~9.0.8",
|
||||||
"expo-sharing": "~14.0.8",
|
"expo-sharing": "~14.0.8",
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt b/node_modules/@mattermost/react-native-paste-input/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt
|
|
||||||
index 4ed2307..ede1181 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt
|
|
||||||
@@ -54,7 +54,7 @@ class PasteTextInputManager(context: ReactApplicationContext) : ReactTextInputMa
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
|
|
||||||
- val map = super.getExportedCustomBubblingEventTypeConstants()!!
|
|
||||||
+ val map = super.getExportedCustomBubblingEventTypeConstants().toMutableMap()
|
|
||||||
map["onPaste"] = MapBuilder.of(
|
|
||||||
"phasedRegistrationNames",
|
|
||||||
MapBuilder.of("bubbled", "onPaste")
|
|
||||||
@@ -1,264 +0,0 @@
|
|||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
|
|
||||||
index e916023..5049c33 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
|
|
||||||
@@ -4,6 +4,7 @@
|
|
||||||
//
|
|
||||||
// Created by Elias Nahum on 04-11-20.
|
|
||||||
// Copyright © 2020 Facebook. All rights reserved.
|
|
||||||
+// Updated to remove parent’s default text view
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "PasteInputView.h"
|
|
||||||
@@ -12,49 +13,78 @@
|
|
||||||
|
|
||||||
@implementation PasteInputView
|
|
||||||
{
|
|
||||||
- PasteInputTextView *_backedTextInputView;
|
|
||||||
+ // We'll store the custom text view in this ivar
|
|
||||||
+ PasteInputTextView *_customBackedTextView;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
||||||
{
|
|
||||||
+ // Must call the super’s designated initializer
|
|
||||||
if (self = [super initWithBridge:bridge]) {
|
|
||||||
- _backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds];
|
|
||||||
- _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
||||||
- _backedTextInputView.textInputDelegate = self;
|
|
||||||
+ // 1. The parent (RCTMultilineTextInputView) has already created
|
|
||||||
+ // its own _backedTextInputView = [RCTUITextView new] in super init.
|
|
||||||
+ // We can remove that subview:
|
|
||||||
|
|
||||||
- [self addSubview:_backedTextInputView];
|
|
||||||
- }
|
|
||||||
+ id<RCTBackedTextInputViewProtocol> parentInputView = super.backedTextInputView;
|
|
||||||
+ if ([parentInputView isKindOfClass:[UIView class]]) {
|
|
||||||
+ UIView *parentSubview = (UIView *)parentInputView;
|
|
||||||
+ if (parentSubview.superview == self) {
|
|
||||||
+ [parentSubview removeFromSuperview];
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
+ // 2. Now create our custom PasteInputTextView
|
|
||||||
+ _customBackedTextView = [[PasteInputTextView alloc] initWithFrame:self.bounds];
|
|
||||||
+ _customBackedTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
||||||
+ _customBackedTextView.textInputDelegate = self;
|
|
||||||
+
|
|
||||||
+ // Optional: disable inline predictions for iOS 17+
|
|
||||||
+ if (@available(iOS 17.0, *)) {
|
|
||||||
+ _customBackedTextView.inlinePredictionType = UITextInlinePredictionTypeNo;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // 3. Add your custom text view as the only subview
|
|
||||||
+ [self addSubview:_customBackedTextView];
|
|
||||||
+ }
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Override the parent's accessor so that anywhere in RN that calls
|
|
||||||
+ * `self.backedTextInputView` will get the custom PasteInputTextView.
|
|
||||||
+ */
|
|
||||||
- (id<RCTBackedTextInputViewProtocol>)backedTextInputView
|
|
||||||
{
|
|
||||||
- return _backedTextInputView;
|
|
||||||
+ return _customBackedTextView;
|
|
||||||
}
|
|
||||||
|
|
||||||
-- (void)setDisableCopyPaste:(BOOL)disableCopyPaste {
|
|
||||||
- _backedTextInputView.disableCopyPaste = disableCopyPaste;
|
|
||||||
+#pragma mark - Setters for React Props
|
|
||||||
+
|
|
||||||
+- (void)setDisableCopyPaste:(BOOL)disableCopyPaste
|
|
||||||
+{
|
|
||||||
+ _customBackedTextView.disableCopyPaste = disableCopyPaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
-- (void)setOnPaste:(RCTDirectEventBlock)onPaste {
|
|
||||||
- _backedTextInputView.onPaste = onPaste;
|
|
||||||
+- (void)setOnPaste:(RCTDirectEventBlock)onPaste
|
|
||||||
+{
|
|
||||||
+ _customBackedTextView.onPaste = onPaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
-- (void)setSmartPunctuation:(NSString *)smartPunctuation {
|
|
||||||
- if ([smartPunctuation isEqualToString:@"enable"]) {
|
|
||||||
- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeYes];
|
|
||||||
- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeYes];
|
|
||||||
- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes];
|
|
||||||
- } else if ([smartPunctuation isEqualToString:@"disable"]) {
|
|
||||||
- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeNo];
|
|
||||||
- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeNo];
|
|
||||||
- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo];
|
|
||||||
- } else {
|
|
||||||
- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeDefault];
|
|
||||||
- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeDefault];
|
|
||||||
- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault];
|
|
||||||
- }
|
|
||||||
+- (void)setSmartPunctuation:(NSString *)smartPunctuation
|
|
||||||
+{
|
|
||||||
+ if ([smartPunctuation isEqualToString:@"enable"]) {
|
|
||||||
+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeYes];
|
|
||||||
+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeYes];
|
|
||||||
+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes];
|
|
||||||
+ } else if ([smartPunctuation isEqualToString:@"disable"]) {
|
|
||||||
+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeNo];
|
|
||||||
+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeNo];
|
|
||||||
+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo];
|
|
||||||
+ } else {
|
|
||||||
+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeDefault];
|
|
||||||
+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeDefault];
|
|
||||||
+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault];
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - UIScrollViewDelegate
|
|
||||||
@@ -62,7 +92,6 @@ - (void)setSmartPunctuation:(NSString *)smartPunctuation {
|
|
||||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
|
||||||
{
|
|
||||||
RCTDirectEventBlock onScroll = self.onScroll;
|
|
||||||
-
|
|
||||||
if (onScroll) {
|
|
||||||
CGPoint contentOffset = scrollView.contentOffset;
|
|
||||||
CGSize contentSize = scrollView.contentSize;
|
|
||||||
@@ -71,22 +100,22 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
|
||||||
|
|
||||||
onScroll(@{
|
|
||||||
@"contentOffset": @{
|
|
||||||
- @"x": @(contentOffset.x),
|
|
||||||
- @"y": @(contentOffset.y)
|
|
||||||
+ @"x": @(contentOffset.x),
|
|
||||||
+ @"y": @(contentOffset.y)
|
|
||||||
},
|
|
||||||
@"contentInset": @{
|
|
||||||
- @"top": @(contentInset.top),
|
|
||||||
- @"left": @(contentInset.left),
|
|
||||||
- @"bottom": @(contentInset.bottom),
|
|
||||||
- @"right": @(contentInset.right)
|
|
||||||
+ @"top": @(contentInset.top),
|
|
||||||
+ @"left": @(contentInset.left),
|
|
||||||
+ @"bottom": @(contentInset.bottom),
|
|
||||||
+ @"right": @(contentInset.right)
|
|
||||||
},
|
|
||||||
@"contentSize": @{
|
|
||||||
- @"width": @(contentSize.width),
|
|
||||||
- @"height": @(contentSize.height)
|
|
||||||
+ @"width": @(contentSize.width),
|
|
||||||
+ @"height": @(contentSize.height)
|
|
||||||
},
|
|
||||||
@"layoutMeasurement": @{
|
|
||||||
- @"width": @(size.width),
|
|
||||||
- @"height": @(size.height)
|
|
||||||
+ @"width": @(size.width),
|
|
||||||
+ @"height": @(size.height)
|
|
||||||
},
|
|
||||||
@"zoomScale": @(scrollView.zoomScale ?: 1),
|
|
||||||
});
|
|
||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm
|
|
||||||
index dd50053..2ed7017 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm
|
|
||||||
@@ -122,8 +122,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
|
|
||||||
const auto &newTextInputProps = static_cast<const PasteTextInputProps &>(*props);
|
|
||||||
|
|
||||||
// Traits:
|
|
||||||
- if (newTextInputProps.traits.multiline != oldTextInputProps.traits.multiline) {
|
|
||||||
- [self _setMultiline:newTextInputProps.traits.multiline];
|
|
||||||
+ if (newTextInputProps.multiline != oldTextInputProps.multiline) {
|
|
||||||
+ [self _setMultiline:newTextInputProps.multiline];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) {
|
|
||||||
@@ -421,7 +421,7 @@ - (void)textInputDidChangeSelection
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto &props = static_cast<const PasteTextInputProps &>(*_props);
|
|
||||||
- if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
|
|
||||||
+ if (props.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
|
|
||||||
[self textInputDidChange];
|
|
||||||
_ignoreNextTextInputCall = YES;
|
|
||||||
}
|
|
||||||
@@ -708,11 +708,11 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe
|
|
||||||
- (SubmitBehavior)getSubmitBehavior
|
|
||||||
{
|
|
||||||
const auto &props = static_cast<const PasteTextInputProps &>(*_props);
|
|
||||||
- const SubmitBehavior submitBehaviorDefaultable = props.traits.submitBehavior;
|
|
||||||
+ const SubmitBehavior submitBehaviorDefaultable = props.submitBehavior;
|
|
||||||
|
|
||||||
// We should always have a non-default `submitBehavior`, but in case we don't, set it based on multiline.
|
|
||||||
if (submitBehaviorDefaultable == SubmitBehavior::Default) {
|
|
||||||
- return props.traits.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit;
|
|
||||||
+ return props.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return submitBehaviorDefaultable;
|
|
||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp
|
|
||||||
index 29e094f..7ef519a 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp
|
|
||||||
@@ -22,8 +22,7 @@ PasteTextInputProps::PasteTextInputProps(
|
|
||||||
const PropsParserContext &context,
|
|
||||||
const PasteTextInputProps &sourceProps,
|
|
||||||
const RawProps& rawProps)
|
|
||||||
- : ViewProps(context, sourceProps, rawProps),
|
|
||||||
- BaseTextProps(context, sourceProps, rawProps),
|
|
||||||
+ : BaseTextInputProps(context, sourceProps, rawProps),
|
|
||||||
traits(convertRawProp(context, rawProps, sourceProps.traits, {})),
|
|
||||||
smartPunctuation(convertRawProp(context, rawProps, "smartPunctuation", sourceProps.smartPunctuation, {})),
|
|
||||||
disableCopyPaste(convertRawProp(context, rawProps, "disableCopyPaste", sourceProps.disableCopyPaste, {false})),
|
|
||||||
@@ -133,7 +132,7 @@ TextAttributes PasteTextInputProps::getEffectiveTextAttributes(Float fontSizeMul
|
|
||||||
ParagraphAttributes PasteTextInputProps::getEffectiveParagraphAttributes() const {
|
|
||||||
auto result = paragraphAttributes;
|
|
||||||
|
|
||||||
- if (!traits.multiline) {
|
|
||||||
+ if (!multiline) {
|
|
||||||
result.maximumNumberOfLines = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h
|
|
||||||
index 723d00c..31cfe66 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h
|
|
||||||
@@ -15,6 +15,7 @@
|
|
||||||
#include <react/renderer/components/iostextinput/conversions.h>
|
|
||||||
#include <react/renderer/components/iostextinput/primitives.h>
|
|
||||||
#include <react/renderer/components/text/BaseTextProps.h>
|
|
||||||
+#include <react/renderer/components/textinput/BaseTextInputProps.h>
|
|
||||||
#include <react/renderer/components/view/ViewProps.h>
|
|
||||||
#include <react/renderer/core/Props.h>
|
|
||||||
#include <react/renderer/core/PropsParserContext.h>
|
|
||||||
@@ -25,7 +26,7 @@
|
|
||||||
|
|
||||||
namespace facebook::react {
|
|
||||||
|
|
||||||
-class PasteTextInputProps final : public ViewProps, public BaseTextProps {
|
|
||||||
+class PasteTextInputProps final : public BaseTextInputProps {
|
|
||||||
public:
|
|
||||||
PasteTextInputProps() = default;
|
|
||||||
PasteTextInputProps(const PropsParserContext& context, const PasteTextInputProps& sourceProps, const RawProps& rawProps);
|
|
||||||
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp
|
|
||||||
index 31e07e3..7f0ebfb 100644
|
|
||||||
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp
|
|
||||||
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp
|
|
||||||
@@ -91,20 +91,11 @@ void PasteTextInputShadowNode::updateStateIfNeeded(
|
|
||||||
const auto& state = getStateData();
|
|
||||||
|
|
||||||
react_native_assert(textLayoutManager_);
|
|
||||||
- react_native_assert(
|
|
||||||
- (!state.layoutManager || state.layoutManager == textLayoutManager_) &&
|
|
||||||
- "`StateData` refers to a different `TextLayoutManager`");
|
|
||||||
-
|
|
||||||
- if (state.reactTreeAttributedString == reactTreeAttributedString &&
|
|
||||||
- state.layoutManager == textLayoutManager_) {
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
|
|
||||||
auto newState = TextInputState{};
|
|
||||||
newState.attributedStringBox = AttributedStringBox{reactTreeAttributedString};
|
|
||||||
newState.paragraphAttributes = getConcreteProps().paragraphAttributes;
|
|
||||||
newState.reactTreeAttributedString = reactTreeAttributedString;
|
|
||||||
- newState.layoutManager = textLayoutManager_;
|
|
||||||
newState.mostRecentEventCount = getConcreteProps().mostRecentEventCount;
|
|
||||||
setStateData(std::move(newState));
|
|
||||||
}
|
|
||||||
@@ -8,21 +8,17 @@ import {
|
|||||||
import {
|
import {
|
||||||
type NativeSyntheticEvent,
|
type NativeSyntheticEvent,
|
||||||
Text as RNText,
|
Text as RNText,
|
||||||
|
TextInput as RNTextInput,
|
||||||
type TextInputSelectionChangeEventData,
|
type TextInputSelectionChangeEventData,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {type PasteEventPayload, TextInputWrapper} from 'expo-paste-input'
|
||||||
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
|
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
|
||||||
import PasteInput, {
|
import {useLingui} from '@lingui/react/macro'
|
||||||
type PastedFile,
|
|
||||||
type PasteInputRef,
|
|
||||||
// @ts-expect-error no types when installing from github
|
|
||||||
// eslint-disable-next-line import-x/no-unresolved
|
|
||||||
} from '@mattermost/react-native-paste-input'
|
|
||||||
|
|
||||||
import {POST_IMG_MAX} from '#/lib/constants'
|
import {POST_IMG_MAX} from '#/lib/constants'
|
||||||
import {downloadAndResize} from '#/lib/media/manip'
|
import {downloadAndResize} from '#/lib/media/manip'
|
||||||
import {isUriImage} from '#/lib/media/util'
|
import {isUriImage} from '#/lib/media/util'
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
|
||||||
import {getMentionAt, insertMentionAt} from '#/lib/strings/mention-manip'
|
import {getMentionAt, insertMentionAt} from '#/lib/strings/mention-manip'
|
||||||
import {useTheme} from '#/lib/ThemeContext'
|
import {useTheme} from '#/lib/ThemeContext'
|
||||||
import {
|
import {
|
||||||
@@ -51,8 +47,9 @@ export function TextInput({
|
|||||||
onError,
|
onError,
|
||||||
...props
|
...props
|
||||||
}: TextInputProps) {
|
}: TextInputProps) {
|
||||||
|
const {t: l} = useLingui()
|
||||||
const {theme: t, fonts} = useAlf()
|
const {theme: t, fonts} = useAlf()
|
||||||
const textInput = useRef<PasteInputRef>(null)
|
const textInput = useRef<RNTextInput>(null)
|
||||||
const textInputSelection = useRef<Selection>({start: 0, end: 0})
|
const textInputSelection = useRef<Selection>({start: 0, end: 0})
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const [autocompletePrefix, setAutocompletePrefix] = useState('')
|
const [autocompletePrefix, setAutocompletePrefix] = useState('')
|
||||||
@@ -129,19 +126,21 @@ export function TextInput({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onPaste = useCallback(
|
const onPaste = useCallback(
|
||||||
async (err: string | undefined, files: PastedFile[]) => {
|
(payload: PasteEventPayload) => {
|
||||||
if (err) {
|
if (payload.type === 'unsupported') {
|
||||||
return onError(cleanError(err))
|
onError(l`Unsupported clipboard content`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const uris = files.map(f => f.uri)
|
if (payload.type === 'images') {
|
||||||
const uri = uris.find(isUriImage)
|
for (const uri of payload.uris) {
|
||||||
|
if (isUriImage(uri)) {
|
||||||
if (uri) {
|
onPhotoPasted(uri)
|
||||||
onPhotoPasted(uri)
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[onError, onPhotoPasted],
|
[l, onError, onPhotoPasted],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onSelectionChange = useCallback(
|
const onSelectionChange = useCallback(
|
||||||
@@ -217,41 +216,42 @@ export function TextInput({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_1, a.pl_md, hasRightPadding && a.pr_4xl]}>
|
<View style={[a.flex_1, a.pl_md, hasRightPadding && a.pr_4xl]}>
|
||||||
<PasteInput
|
<TextInputWrapper onPaste={onPaste}>
|
||||||
testID="composerTextInput"
|
<RNTextInput
|
||||||
ref={textInput}
|
testID="composerTextInput"
|
||||||
onChangeText={onChangeText}
|
ref={textInput}
|
||||||
onPaste={onPaste}
|
onChangeText={onChangeText}
|
||||||
onSelectionChange={onSelectionChange}
|
onSelectionChange={onSelectionChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
placeholderTextColor={t.atoms.text_contrast_low.color}
|
placeholderTextColor={t.atoms.text_contrast_low.color}
|
||||||
keyboardAppearance={theme.colorScheme}
|
keyboardAppearance={theme.colorScheme}
|
||||||
autoFocus={props.autoFocus !== undefined ? props.autoFocus : true}
|
autoFocus={props.autoFocus !== undefined ? props.autoFocus : true}
|
||||||
allowFontScaling
|
allowFontScaling
|
||||||
multiline
|
multiline
|
||||||
scrollEnabled={false}
|
scrollEnabled={false}
|
||||||
numberOfLines={2}
|
numberOfLines={2}
|
||||||
// Note: should be the default value, but as of v1.104
|
// Note: should be the default value, but as of v1.104
|
||||||
// it switched to "none" on Android
|
// it switched to "none" on Android
|
||||||
autoCapitalize="sentences"
|
autoCapitalize="sentences"
|
||||||
{...props}
|
{...props}
|
||||||
style={[
|
style={[
|
||||||
inputTextStyle,
|
inputTextStyle,
|
||||||
a.w_full,
|
a.w_full,
|
||||||
!autocompletePrefix && a.h_full,
|
!autocompletePrefix && a.h_full,
|
||||||
{
|
{
|
||||||
textAlignVertical: 'top',
|
textAlignVertical: 'top',
|
||||||
minHeight: 60,
|
minHeight: 60,
|
||||||
includeFontPadding: false,
|
includeFontPadding: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: 'transparent',
|
borderColor: 'transparent',
|
||||||
},
|
},
|
||||||
props.style,
|
props.style,
|
||||||
]}>
|
]}>
|
||||||
{textDecorated}
|
{textDecorated}
|
||||||
</PasteInput>
|
</RNTextInput>
|
||||||
|
</TextInputWrapper>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
prefix={autocompletePrefix}
|
prefix={autocompletePrefix}
|
||||||
onSelect={onSelectAutocompleteItem}
|
onSelect={onSelectAutocompleteItem}
|
||||||
|
|||||||
@@ -3894,12 +3894,6 @@
|
|||||||
"@babel/runtime" "^7.20.13"
|
"@babel/runtime" "^7.20.13"
|
||||||
"@lingui/core" "5.9.2"
|
"@lingui/core" "5.9.2"
|
||||||
|
|
||||||
"@mattermost/react-native-paste-input@mattermost/react-native-paste-input":
|
|
||||||
version "0.8.1"
|
|
||||||
resolved "https://codeload.github.com/mattermost/react-native-paste-input/tar.gz/f260447edc645a817ab1ba7b46d8341d84dba8e9"
|
|
||||||
dependencies:
|
|
||||||
semver "7.6.3"
|
|
||||||
|
|
||||||
"@messageformat/parser@^5.0.0":
|
"@messageformat/parser@^5.0.0":
|
||||||
version "5.1.0"
|
version "5.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@messageformat/parser/-/parser-5.1.0.tgz#05e4851c782d633ad735791dd0a68ee65d2a7201"
|
resolved "https://registry.yarnpkg.com/@messageformat/parser/-/parser-5.1.0.tgz#05e4851c782d633ad735791dd0a68ee65d2a7201"
|
||||||
@@ -9086,6 +9080,11 @@ expo-notifications@~0.32.16:
|
|||||||
expo-application "~7.0.8"
|
expo-application "~7.0.8"
|
||||||
expo-constants "~18.0.13"
|
expo-constants "~18.0.13"
|
||||||
|
|
||||||
|
expo-paste-input@^0.1.10:
|
||||||
|
version "0.1.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/expo-paste-input/-/expo-paste-input-0.1.10.tgz#7df0a07ae6ecd381004624dbe88762997d962780"
|
||||||
|
integrity sha512-TkAauK1eIq7+vk2SA39trmDO6dLfFLQL+09KIVZh//3XWs8gHC5ezH3vjfjr7xj9xi67amyeiDCErP5caTDIKg==
|
||||||
|
|
||||||
expo-privacy-sensitive@^0.1.0:
|
expo-privacy-sensitive@^0.1.0:
|
||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/expo-privacy-sensitive/-/expo-privacy-sensitive-0.1.0.tgz#2177d7a3cb8ed352df94c5806d012dfb7b48bc84"
|
resolved "https://registry.yarnpkg.com/expo-privacy-sensitive/-/expo-privacy-sensitive-0.1.0.tgz#2177d7a3cb8ed352df94c5806d012dfb7b48bc84"
|
||||||
@@ -14648,16 +14647,16 @@ selfsigned@^2.1.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
node-forge "^1"
|
node-forge "^1"
|
||||||
|
|
||||||
semver@7.6.3, semver@^7.1.3:
|
|
||||||
version "7.6.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
|
|
||||||
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
|
|
||||||
|
|
||||||
semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
|
semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
|
||||||
version "6.3.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
||||||
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
||||||
|
|
||||||
|
semver@^7.1.3:
|
||||||
|
version "7.6.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
|
||||||
|
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
|
||||||
|
|
||||||
semver@^7.3.5, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~7.5.4:
|
semver@^7.3.5, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~7.5.4:
|
||||||
version "7.5.4"
|
version "7.5.4"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
|
||||||
|
|||||||
Reference in New Issue
Block a user