mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 21:35:04 +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 = {
|
this.state = {
|
||||||
currentText: '',
|
currentText: '',
|
||||||
chips: props.draftChips || [' '],
|
chips: props.draftChips || [' '],
|
||||||
chipsCount: props.chipsCount || 7,
|
chipsCount: props.chipsCount || 10,
|
||||||
activeChip: 0,
|
activeChip: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnChange = (text, i) => {
|
_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, '') });
|
this.setState({ currentText: text.replace(/\s/g, '').replace(/,/g, '') });
|
||||||
|
|
||||||
if (text.indexOf(' ') > 0 && text) {
|
if (text.indexOf(' ') > 0 && text) {
|
||||||
@ -50,10 +60,17 @@ export default class TagAreaView extends Component {
|
|||||||
const _currentText = (currentText && currentText.trim()) || text;
|
const _currentText = (currentText && currentText.trim()) || text;
|
||||||
|
|
||||||
if (_currentText && chips && chips.length < chipsCount) {
|
if (_currentText && chips && chips.length < chipsCount) {
|
||||||
|
if (i !== null && text !== null) {
|
||||||
|
chips[i] = _currentText;
|
||||||
|
this.setState({
|
||||||
|
chips: [...chips],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
chips: [...chips, _currentText],
|
chips: [...chips, _currentText],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (handleTagChanged && chips.length < chipsCount + 1) {
|
if (handleTagChanged && chips.length < chipsCount + 1) {
|
||||||
handleTagChanged([...chips, _currentText]);
|
handleTagChanged([...chips, _currentText]);
|
||||||
|
Loading…
Reference in New Issue
Block a user