How to make copy&paste of full mentions possible?

AI-generated summary

In a support discussion titled ‘How to make copy&paste of full mentions possible?’, thoka reports an issue where full-name mentions (via the plugin Discourse Show Fullname in Mentions) cannot be copied and pasted into new posts. The rendered mentions store the full name in a data-full-name attribute, but the pasted text only retains the username (e.g., @toka), not the full name (e.g., @Thomas Kalka). NateDhaliwal and tobiaseigen request clarification and examples. tobiaseigen suggests using Discourse’s built-in text selection popup for copying, which may preserve mentions correctly. Falco notes the topic involves an unofficial plugin, implying limited official support. The core issue is ensuring full-name mentions are preserved during copy-paste operations, requiring either plugin customization or a workaround.

I’m looking for a solution for

Is there a way how plugins / components could decide which code is pasted via copy & paste?

Could you elaborate a bit more? I don’t think I’m fully understanding. As I get it, full name mentions display on copy & paste, but username mentions are normal ones in posts? Or the fact that copy and pasting fullname mentions doesn’t transfer over?

Hallo Thomas! :waving_hand: Can you share an example to illustrate what you mean? You can write in German if you prefer and your post will be auto-translated for us.

We use Discourse Show Fullname in Mentions. Consequently, mentions from rendered posts cannot be copied and pasted into new posts.
Replaced usernames are stored inside the rendered content as a data attribute:

<a class="mention mention-fullname discourse-show-name-mentions" data-full-name="Thomas Kalka" href="/u/toka" data-original-mention="@toka">@Thomas Kalka</a>

I would like to discover a method to ensure that the appropriate mention, in this case @toka, is captured when copying from the rendered text (cooked content) during post creation.

What options exist to customize the algorithm that constructs Markdown content from HTML, specifically for this scenario, such that a[data-original-fullname] is inserted for a.mention-fullname?

Are you copying the discourse way, using the popup that appears when you select some text in a post? I believe that works as you would expect but have not tested it lately.

Edit: oh, wait. Just reading this more carefully. This is not an official theme component so to get support for that component, you want to reply in that topic. I think what you are describing may be a bug.

Given this is a discussion about an unofficial theme component, let’s keep it on that topic.