react-mentions icon indicating copy to clipboard operation
react-mentions copied to clipboard

Added a render prop to Mention component for custom rendering the display value

Open nikhil2kumar opened this issue 3 years ago β€’ 10 comments

This PR includes the addition of the render method to the Mention component.

The method has display parameters and expects to return a react component to render the mention display value.

This would come in handy if there's a need to pass our own component instead of relying on the default functionality.

<Tooltip title="customTitleGoesHere"> <strong className="myClassName">{display}</strong> </Tooltip>

nikhil2kumar avatar Jun 14 '21 13:06 nikhil2kumar

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

πŸ” Inspect: https://vercel.com/signavio/react-mentions/ApJRr7Y36K1aDsgrdEYuXew9ASM6
βœ… Preview: https://react-mentions-git-fork-nikhil2kumar-customment-4691fc-signavio.vercel.app

vercel[bot] avatar Jun 14 '21 13:06 vercel[bot]

Codecov Report

Merging #502 (c69b779) into master (a2c8856) will decrease coverage by 0.08%. The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
- Coverage   78.84%   78.76%   -0.09%     
==========================================
  Files          32       32              
  Lines         695      697       +2     
  Branches      108      109       +1     
==========================================
+ Hits          548      549       +1     
- Misses        146      147       +1     
  Partials        1        1              
Impacted Files Coverage Ξ”
src/Mention.js 75.00% <66.66%> (-5.00%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update a2c8856...c69b779. Read the comment docs.

codecov-commenter avatar Jun 14 '21 14:06 codecov-commenter

This would be a much needed addition for my needs as well!

dargue3 avatar Nov 02 '21 04:11 dargue3

πŸ‘

This PR would give us the ability to apply different styles to different Mention types and add Tooltips. Note Slack's UI ...

image

mikeg0 avatar May 18 '22 03:05 mikeg0

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated
react-mentions βœ… Ready (Inspect) Visit Preview Jun 15, 2022 at 5:27PM (UTC)

vercel[bot] avatar Jun 15 '22 17:06 vercel[bot]

I would love this as well.

jsheffers avatar Jul 14 '22 15:07 jsheffers

was this merged yet? i also want this as well

haniequach25 avatar Sep 16 '22 05:09 haniequach25

Any update?

icrocket avatar Sep 09 '23 09:09 icrocket

Really need support for this, can we get this merged please?

matt-d-rat avatar Nov 20 '23 06:11 matt-d-rat

Since internally this library uses only Mention props, we can create our own Mention component that just follows the same API, so to make it work I did:

const Mention = ({
  id,
  render,
  display,
}) => {
  if (render) {
    return render({ children: display, label: display, value: id });
  }
  return <strong {...props}>{display}</strong>;
};

Mention.defaultProps = {
  onAdd: () => null,
  markup: "@[__display__](__id__)",
  trigger: "@",
  onRemove: () => null,
  isLoading: false,
  displayTransform: (id?: string | number, display?: string) => display || id,
  renderSuggestion: null,
  appendSpaceOnAdd: false,
};

And then I just use this Mention instead of the library one

hyanmandian avatar Mar 29 '24 16:03 hyanmandian