signavio / react-mentions

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

Added useRawValueOnCopy prop #723

Open bruno-campos opened 7 months ago

bruno-campos commented 7 months ago

Added useRawValueOnCopy prop

What did you change (functionally and technically)?

Added a new prop: useRawValueOnCopy

The default value is false and it won't change any behavior.

When that is set to true, when performing a copy/cut, instead of copying the content without tags to the clipboard, it will copy the raw content with tags. So for example, if I have the following:

Hi %{name}, how are you?

That is displayed like:

Hi Name, how are you?

The copied content in the clipboard with the prop on will be: Hi %{name}, how are you?. The default behavior is to copy Hi Name, how are you? to the clipboard.

This is a real use case need, where users might copy the text content and send to others for review, or paste into translation tools. When having the tags around the content, translation tools will ignore it and also, people reviewing or changing the content outside the app will be aware of the tags.

Any feedback is appreciated :) Thanks for the awesome repo. If this goes live, I can update the DefinitelyTyped repo as well.

changeset-bot[bot] commented 7 months ago

🦋 Changeset detected

Latest commit: 78496461be072c9fc274562deca6f36a75edc1c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------- | ----- | | react-mentions | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-mentions ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2023 2:07am
mrdjohnson commented 5 months ago

👋 I am not related to this project, was just reading some PRs and had some thoughts

Starting a variable with "use" gives off the impression of it being a hook, based on other props in this project, could we consider a name like "shouldCopyRawValue"?

This could definitely be my own shortcomings but: "rawValue" is not clear at all. I see now it's about the preInterpolated text but, was not clear to me and I had to read the code (not the docs) to understand. (Could just be me of course)

Curious: what happens if someone copies half of a name? There is a "shouldAllowSpaces" prop, if that's on, and this is on, and we have the text: "@John Doe is not here today" and I copy "Doe is not here today" ..what would the result be?

Feel free to ignore, just dropping in, good luck on the PR!