signavio / react-mentions

@mention people in a textarea
https://react-mentions.vercel.app
Other
2.5k stars 575 forks source link

want dynamic attribute on the strong element #740

Open viking7982 opened 8 months ago

viking7982 commented 8 months ago

Hi:

In my project, I want the Mention strong elements with different styles.

Also, when I click an a Mention Strong element, I want to know which mention item i click and then I can do futher configuration on that metioned data. When I double click on the input, I can use document.elementsFromPoint to get the strong element easily but it's hard to find the id correspond to the clicked strong element.

It would be greate if I can add some dynamic attributes on the Strong element.

Like

const Mention = ({ id, display, style, className, classNames, getDynamicAttrs }) => {
  const styles = useStyles(defaultStyle, { style, className, classNames })
  const attrs = getDynamicAttrs ? getDynamicAttrs(id) : {}

  return <strong {...styles} {...attrs}>{display}</strong>
}