tribute
tribute copied to clipboard
Is it possible to execute a function when a @mention is removed?
Is there a way to call a function when a @mention string is being removed from the text input by the user?
Reason: Iām building an array with IDs of users to notify as soon as they are @mentioned - however, when you remove someone afterwards, Iād need to update the array and removing the affected ID again.
Thanks for any hints
There currently isn't a way to do this. I would like to add several more events to the library and this is a good candidate. I'll put this on the roadmap.
Cool, looking forward to it! š
So long I'm taking server-side care of possible duplicates due to the same @mentions...
@mrsweaters badly needed that one. looking forward. šš
I have a workaround which could be tweaked later as a core solution (as reference I'm using vue-tribute).
Basically I use an array to store all current mentions that gets populated from the tribute-replaced event (only storing value). Whenever the text input changes I run a check and loop through all the mentions to see if they are still in the input.
If they are not then I remove them from the array, so that the array should always be a reference point for currently mentioned users.
Here is the vue code (my input is called comment because it's used in a comment system).
watch: {
msg: function(comment) {
// Polyfill for tribute-removed event
this.mentions.map( (mention, i) => {
if (!comment.includes(`@${mention}`)) {
this.$delete(this.mentions, i);
}
});
}
}
@Truemedia, wouldn't it be more performant to perform that check on submit?
Waking up an old thread - did this ever go anywhere?
Would be a great feature to have