* Tighten up post draft UI
* Revert "MM-15307 Updated to use InteractionManager (#3666)"
This reverts commit e08155c81b.
* Address PR review comments
* Update snapshot test
* Don't return null if no files
* Fix progress text and padding issues
* Fixes per Matt's review
* Make linter happy
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {TextInput, NativeEventEmitter, NativeModules} from 'react-native';
|
|
import CustomTextInput from './custom_text_input';
|
|
|
|
const {OnPasteEventManager} = NativeModules;
|
|
const OnPasteEventEmitter = new NativeEventEmitter(OnPasteEventManager);
|
|
|
|
export class PasteableTextInput extends React.PureComponent {
|
|
static propTypes = {
|
|
...TextInput.PropTypes,
|
|
onPaste: PropTypes.func,
|
|
forwardRef: PropTypes.any,
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.subscription = OnPasteEventEmitter.addListener('onPaste', this.onPaste);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
if (this.subscription) {
|
|
this.subscription.remove();
|
|
}
|
|
}
|
|
|
|
onPaste = (event) => {
|
|
const {onPaste} = this.props;
|
|
return onPaste?.(null, event);
|
|
}
|
|
|
|
render() {
|
|
const {forwardRef, ...props} = this.props;
|
|
|
|
return (
|
|
<CustomTextInput
|
|
{...props}
|
|
ref={forwardRef}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
const WrappedPasteableTextInput = (props, ref) => (
|
|
<PasteableTextInput
|
|
{...props}
|
|
forwardRef={ref}
|
|
/>
|
|
);
|
|
|
|
export default React.forwardRef(WrappedPasteableTextInput);
|