replace paste-input with RN patch
This commit is contained in:
@@ -90,7 +90,6 @@
|
|||||||
"@haileyok/bluesky-video": "0.3.2",
|
"@haileyok/bluesky-video": "0.3.2",
|
||||||
"@ipld/dag-cbor": "^9.2.0",
|
"@ipld/dag-cbor": "^9.2.0",
|
||||||
"@lingui/react": "^4.14.1",
|
"@lingui/react": "^4.14.1",
|
||||||
"@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.7.1",
|
"@mozzius/expo-dynamic-app-icon": "^1.7.1",
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,21 +6,17 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {
|
import {
|
||||||
type NativeSyntheticEvent,
|
|
||||||
Text as RNText,
|
Text as RNText,
|
||||||
type TextInputSelectionChangeEventData,
|
TextInput as RNTextInput,
|
||||||
|
type TextInputPasteEvent,
|
||||||
|
type TextInputSelectionChangeEvent,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
|
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
|
||||||
import PasteInput, {
|
|
||||||
type PastedFile,
|
|
||||||
type PasteInputRef, // @ts-expect-error no types when installing from github
|
|
||||||
} 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 {isAndroid, isNative} from '#/platform/detection'
|
import {isAndroid, isNative} from '#/platform/detection'
|
||||||
@@ -46,11 +42,10 @@ export function TextInput({
|
|||||||
setRichText,
|
setRichText,
|
||||||
onPhotoPasted,
|
onPhotoPasted,
|
||||||
onNewLink,
|
onNewLink,
|
||||||
onError,
|
|
||||||
...props
|
...props
|
||||||
}: TextInputProps) {
|
}: TextInputProps) {
|
||||||
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('')
|
||||||
@@ -127,23 +122,20 @@ export function TextInput({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onPaste = useCallback(
|
const onPaste = useCallback(
|
||||||
async (err: string | undefined, files: PastedFile[]) => {
|
async (evt: TextInputPasteEvent) => {
|
||||||
if (err) {
|
const files = evt.nativeEvent.items
|
||||||
return onError(cleanError(err))
|
const uris = files.map(f => f.data)
|
||||||
}
|
|
||||||
|
|
||||||
const uris = files.map(f => f.uri)
|
|
||||||
const uri = uris.find(isUriImage)
|
const uri = uris.find(isUriImage)
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
onPhotoPasted(uri)
|
onPhotoPasted(uri)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[onError, onPhotoPasted],
|
[onPhotoPasted],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onSelectionChange = useCallback(
|
const onSelectionChange = useCallback(
|
||||||
(evt: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
|
(evt: TextInputSelectionChangeEvent) => {
|
||||||
// NOTE we track the input selection using a ref to avoid excessive renders -prf
|
// NOTE we track the input selection using a ref to avoid excessive renders -prf
|
||||||
textInputSelection.current = evt.nativeEvent.selection
|
textInputSelection.current = evt.nativeEvent.selection
|
||||||
},
|
},
|
||||||
@@ -215,7 +207,7 @@ 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
|
<RNTextInput
|
||||||
testID="composerTextInput"
|
testID="composerTextInput"
|
||||||
ref={textInput}
|
ref={textInput}
|
||||||
onChangeText={onChangeText}
|
onChangeText={onChangeText}
|
||||||
@@ -249,7 +241,7 @@ export function TextInput({
|
|||||||
props.style,
|
props.style,
|
||||||
]}>
|
]}>
|
||||||
{textDecorated}
|
{textDecorated}
|
||||||
</PasteInput>
|
</RNTextInput>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
prefix={autocompletePrefix}
|
prefix={autocompletePrefix}
|
||||||
onSelect={onSelectAutocompleteItem}
|
onSelect={onSelectAutocompleteItem}
|
||||||
|
|||||||
@@ -5458,12 +5458,6 @@
|
|||||||
"@babel/runtime" "^7.20.13"
|
"@babel/runtime" "^7.20.13"
|
||||||
"@lingui/core" "4.14.1"
|
"@lingui/core" "4.14.1"
|
||||||
|
|
||||||
"@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"
|
||||||
@@ -18127,11 +18121,6 @@ semver-compare@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
|
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
|
||||||
integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==
|
integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==
|
||||||
|
|
||||||
semver@7.6.3, semver@^7.1.3, semver@^7.6.3:
|
|
||||||
version "7.6.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
|
|
||||||
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
|
|
||||||
|
|
||||||
semver@^5.5.0, semver@^5.6.0:
|
semver@^5.5.0, semver@^5.6.0:
|
||||||
version "5.7.2"
|
version "5.7.2"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
||||||
@@ -18142,6 +18131,11 @@ semver@^6.0.0, semver@^6.3.0, semver@^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, semver@^7.6.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.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~7.5.4:
|
semver@^7.3.5, semver@^7.3.7, 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