mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 11:21:41 +03:00
copy paste tags handler
This commit is contained in:
parent
90a2e47363
commit
8d05b4dfe1
@ -19,13 +19,23 @@ export default class TagAreaView extends Component {
|
||||
this.state = {
|
||||
currentText: '',
|
||||
chips: props.draftChips || [' '],
|
||||
chipsCount: props.chipsCount || 7,
|
||||
chipsCount: props.chipsCount || 10,
|
||||
activeChip: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
_handleOnChange = (text, i) => {
|
||||
if (text.indexOf(' ') > 0) {
|
||||
let ssp = [];
|
||||
ssp = text.split(' ').filter(iii => iii);
|
||||
if (ssp.length > 1) {
|
||||
for (let ii = i; ii < i + ssp.length; ii++) {
|
||||
const element = ssp[ii - i];
|
||||
this._handleTagAdded(ii, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setState({ currentText: text.replace(/\s/g, '').replace(/,/g, '') });
|
||||
|
||||
if (text.indexOf(' ') > 0 && text) {
|
||||
@ -50,10 +60,17 @@ export default class TagAreaView extends Component {
|
||||
const _currentText = (currentText && currentText.trim()) || text;
|
||||
|
||||
if (_currentText && chips && chips.length < chipsCount) {
|
||||
if (i !== null && text !== null) {
|
||||
chips[i] = _currentText;
|
||||
this.setState({
|
||||
chips: [...chips],
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
chips: [...chips, _currentText],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (handleTagChanged && chips.length < chipsCount + 1) {
|
||||
handleTagChanged([...chips, _currentText]);
|
||||
|
Loading…
Reference in New Issue
Block a user