|
|
@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import { isRtl } from '../rtl'; |
|
|
|
import { isRtl } from '../rtl'; |
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'; |
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'; |
|
|
|
|
|
|
|
import Textarea from 'react-textarea-autosize'; |
|
|
|
|
|
|
|
|
|
|
|
const textAtCursorMatchesToken = (str, caretPosition) => { |
|
|
|
const textAtCursorMatchesToken = (str, caretPosition) => { |
|
|
|
let word; |
|
|
|
let word; |
|
|
@ -69,10 +70,6 @@ class AutosuggestTextarea extends ImmutablePureComponent { |
|
|
|
this.props.onSuggestionsClearRequested(); |
|
|
|
this.props.onSuggestionsClearRequested(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// auto-resize textarea
|
|
|
|
|
|
|
|
e.target.style.height = 'auto'; |
|
|
|
|
|
|
|
e.target.style.height = `${e.target.scrollHeight}px`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.props.onChange(e); |
|
|
|
this.props.onChange(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -160,10 +157,6 @@ class AutosuggestTextarea extends ImmutablePureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reset () { |
|
|
|
|
|
|
|
this.textarea.style.height = 'auto'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props; |
|
|
|
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props; |
|
|
|
const { suggestionsHidden, selectedSuggestion } = this.state; |
|
|
|
const { suggestionsHidden, selectedSuggestion } = this.state; |
|
|
@ -175,8 +168,8 @@ class AutosuggestTextarea extends ImmutablePureComponent { |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className='autosuggest-textarea'> |
|
|
|
<div className='autosuggest-textarea'> |
|
|
|
<textarea |
|
|
|
<Textarea |
|
|
|
ref={this.setTextarea} |
|
|
|
inputRef={this.setTextarea} |
|
|
|
className='autosuggest-textarea__textarea' |
|
|
|
className='autosuggest-textarea__textarea' |
|
|
|
disabled={disabled} |
|
|
|
disabled={disabled} |
|
|
|
placeholder={placeholder} |
|
|
|
placeholder={placeholder} |
|
|
|