TarekRaafat / autoComplete.js

Simple autocomplete pure vanilla Javascript library.
https://tarekraafat.github.io/autoComplete.js
Apache License 2.0
3.93k stars 236 forks source link

Replace only a portion of the input #405

Closed jclark-dot-org closed 1 year ago

jclark-dot-org commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to use autocomplete in a textarea to implement a simple formula language (think, something like excel formulas). I believe I can use a custom query to extract just the relevant bit of the input string and a data.src function to tailor the response to the current context, but as far as I can tell, autocomplete always replace the entire input with the selected match.

Thoroughly Describe the solution you'd like I'd like to be able to configure what portion of the target textarea is replaced with a selected match.

Please provide a few use cases for this feature This would be useful in any use case where autocomplete is being used in a larger input context, such as formula entry, code entry, etc. As I'm working with a custom DSL, there's no language-specific parser already available.

Please Describe alternatives you've considered As I'm just evaluating options, I've only read the docs and played with the codepen so far.

jclark-dot-org commented 1 year ago

Somehow the first time through the codepen I completely missed the selection event handler which is updating the input; I can see now exactly how to do what i need to do. Closing, and thanks!