New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to position the cursor in the output string #23
Comments
@jukben Yeah giving integer position would work, and I can see that would be easy to implement, but my idea was to have a special character in the output string, and interpolate position from it... |
Could you please give me some example? |
@jukben Sure, let me know if this needs some clarification <ReactTextareaAutocomplete
className="ant-select-auto-complete.ant-select ant-input"
loadingComponent={Loading}
minChar={0}
rows={1}
trigger={{
'#': {
dataProvider: (token) => {
if (!token || !token.length) {
return this.props.allProperties
}
return this.props.allProperties.filter(prop => {
if (prop.name.search(new RegExp(token, "i")) !== -1) {
return prop
}
return null
})
},
component: ItemComponent,
output: (item, trigger) => {
switch (item.type) {
case 'string':
return `${item.name} = ('${special_character_to_indicate_caret_position}')`
case 'number':
return `${item.name} in ('${special_character_to_indicate_caret_position}', '${maybe_have_multiple_positions}')`
case 'date':
return `${item.name} in ('${special_character_to_indicate_caret_position}', '${maybe_have_multiple_positions}')`
default:
return `${item.name} = ('${special_character_to_indicate_caret_position}')`
}
}
},
}}
/> |
@milosimr Hey, to be honest, I don't really like the idea of return {
text: `${item.name} = ('${special_character_to_indicate_caret_position}')`
caretPosition: `${item.name} = (`.length
} How do you imagine that multiple positions should work? |
@jukben That's true, that solution is simpler and much easier to implement... As for multiple positions, there could be a special character e.g. that would jump to the next position. Again I understand its harder to implement that, and solution will probably require a hack of some sorts, given the nature of textarea. |
@milosimr I personally think that jumping functionality is out of the scope of this plugin. I could go for my proposal about caretPosition, that's reasonable. Anyway, I could provide getters/setters for textarea's caret position, so you can implement it by yourself. |
@jukben Ok, getters/setters would be nice, I understand that my proposals are out of the scope of this plugin, I have some other needs for customization, once I get to that point i'll fork the project and make them. Thanks for all the help. |
Good. I opened Issue for getters/setters and this could be implemented also as we discussed. So if someone is interested, please follow my proposal for implementing this. |
I am on it 🙂 |
Cool! I can't wait to see your PR ❤️ |
Need to refactor See https://github.com/webscopeio/react-textarea-autocomplete/blob/master/src/List.jsx#L74 |
Hey guys, in the end, it looks like I just cannot find time to do this 😞 If someone can pick it up, please do. |
A customizable final position of the cursor in the outputted string
Options could be
"start" | "end" | number
(position in the final string). Default should be "end"Proposal:
Any thoughts?
The text was updated successfully, but these errors were encountered: