fritx / vue-at

At.js for Vue.
https://fritx.github.io/vue-at/
MIT License
529 stars 114 forks source link

ability to pull out RAW values. #68

Open anlek opened 6 years ago

anlek commented 6 years ago

I have a situation where I want to be about to have text input that looks like this:

I believe @andrew likes cars more then toys, while @jill33 wants toys over cars.

but I want the raw output to look something like this:

[
  'I believe ', 
  {id: 1, firstName: 'Andrew', username: 'andrew' }, 
  ' likes cars more then toys, whille ', 
  {id: 3, firstName: 'Jill', username: 'jill33'}, 
  ' wants toys over cars.'
]

This way, I can submit the raw output to a database and can always re-render the users based on their ID. This way if Andrew renames himself to Draw, I can make this changes to the old content.

Thoughts on that posibility?

fritx commented 6 years ago

@anlek vue-at doesn't do that thing for us 😆 - it's just a decorator/helper on textareas. it'd be better we have our own functions to transform before/after the text-rendering, as you said above?

anlek commented 6 years ago

Hello @fritx, I agree the rendering should be done outside the vue-at but the text array generated could be done with vue-at as it is based on the text entered via the helper.

fritx commented 6 years ago

There is no "text array", vue-at just helps us type and @people in the editor If I'm missing anything xD I'm a bit long away from the library, my bad

anlek commented 6 years ago

No worries, I thought I'd ask just to see if it was possible. Right now I'm parsing the HTML content form the contentedtiable area in the backend into the array format mentioned above. It would be lovely if the Vue-at could do that for me in the feature.

mankowitz commented 6 years ago

as long as the text following the @ sign is unique, the way you're doing it sounds optimal. Another solution is to have a post-processing command that maintains a shadow input field. I made a pull request for a processItem function a few months ago, and that might be a good place to insert the json that you are talking about.

fritx commented 6 years ago

Did you mean PR https://github.com/fritx/vue-at/pull/47 ? I would try to have a look again and merge it soon. @mankowitz


There are still problems in that PR, and also I can't get the point relative to this issue 😓