Akryum / vue-mention

Mention component for Vue.js
https://vue-mention.netlify.app/
MIT License
523 stars 54 forks source link

feat: add replaceWith param to apply event #61

Closed Michaelvilleneuve closed 2 years ago

Michaelvilleneuve commented 2 years ago

This PR allows to easily retrieve the corresponding items when parsing the modified string. The very concrete use case is as follows:

@apply="addMention"

addMention (item, key, replacedWith) {
  this.mentions.push({
    user: item.data,
    replacedWith
  })
}

This way when using the string later I can work with it based on data like:

 message: "Hello @Michael how are you?"
 mentions: [
   {
     user: { id: 'xxx', firstName: 'Michael', lastName: 'Villeneuve' },
     replacedWith: '@Michael'
   }
 ]