# :page\_facing\_up: Copy Post Component

**URL:** https://meta.discourse.org/t/copy-post-component/218883
**Category:** Theme component
**Tags:** official, copy-post
**Created:** [February 20, 2022, 3:51pm UTC](https://meta.discourse.org/t/copy-post-component/218883 "2022-02-20T15:51:40Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [February 20, 2022, 3:51pm UTC](https://meta.discourse.org/t/copy-post-component/218883/1 "2022-02-20T15:51:40Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Copy post** shows a button in the post control of each post which copies the entire contents of the post to the user’s clipboard. |
| :eyeglasses: | **Preview** | [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/keegan/discourse-copy-post) |
| :hammer_and_wrench: | **Repository Link** | [https://github.com/discourse/discourse-copy-post](https://github.com/discourse/discourse-copy-post) |
| :open_book: | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

> [@](#):
>
> :discourse: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. :+1:
> 
> [:question:&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=copy-post "Ask for support on configuring and using copy post component") [:bug:&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=copy-post "A bug report means something is broken, preventing normal/typical use of the theme component") [:eyes:&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=copy-post "Discussion about the user interface of Copy post, and how features are presented (including language and UI elements)") [:bulb:&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=copy-post "Discussion about how existing Copy post features can be improved or enhanced, and how proposed new features could work")

### Settings

| Name | Description |
| --- | --- |
| `copy_type` | Select the type of copied text you would like saved to the clipboard (Markdown or HTML). |
| `copy_button_allowed_groups` | Select the groups that are allowed to use the copy button. By default, all users in the Trust Level 1 group will see it. |

| Translation | Default |
| --- | --- |
| title | Copy the contents of this post |

### Screenshots

![The image shows a discussion thread on a forum with various responses discussing the most inspirational movie they have ever seen, including comments on Trees and Albania. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/4/d/1/4d14b983e39dcb49ea322b15d8deaa99c560ae41.gif)

  

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @keegan 2025-01-13T20:29:03Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [February 20, 2022, 11:50pm UTC](https://meta.discourse.org/t/copy-post-component/218883/3 "2022-02-20T23:50:35Z")

</div>

What happens to formatting and media?

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [February 21, 2022, 7:12pm UTC](https://meta.discourse.org/t/copy-post-component/218883/4 "2022-02-21T19:12:06Z")

</div>

@Zup

May need to make some improvements in this area but currently:

- media is not copied
- formatting will be gone (i.e. plain text only) however, line breaks from `<p>` tags will be present.

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [February 21, 2022, 8:03pm UTC](https://meta.discourse.org/t/copy-post-component/218883/5 "2022-02-21T20:03:47Z")

</div>

Hope this can be updated to include media and formatting when pasted in Discourse.

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [February 21, 2022, 8:27pm UTC](https://meta.discourse.org/t/copy-post-component/218883/7 "2022-02-21T20:27:17Z")

</div>

@Zup

Yes, definitely something I’ll be looking to improve in the future.

However, in the meantime, I’ve added a setting to copy the raw HTML content instead. If you set this to true, the copy button will copy the raw HTML of the post instead of the plain text. This way you should have the formatting and media.

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [February 21, 2022, 8:31pm UTC](https://meta.discourse.org/t/copy-post-component/218883/8 "2022-02-21T20:31:35Z")

</div>

Super! :clap:

Maybe a second button, _Duplicate_, (in the moderator gear icon area?) to automatically copy the entire contents of the post into a new topic with "DUPLICATE: " appended to the beginning of the title?

Anyway, very handy as is, thanks!

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 21, 2022, 9:46pm UTC](https://meta.discourse.org/t/copy-post-component/218883/9 "2022-02-21T21:46:59Z")

</div>

Maybe make the button do a request to `/raw/topic_id/post_number` so you can copy the real post content? This way it will act like the very useful Reddit Enhancement Suite “Source” button.

---

<div class="post-metadata">

### Author: ![md-misko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/md-misko/32/126315_2.png) [@md-misko](https://meta.discourse.org/u/md-misko)
#### Post date: [February 22, 2022, 5:48am UTC](https://meta.discourse.org/t/copy-post-component/218883/10 "2022-02-22T05:48:54Z")

</div>

> [@Falco](#):
>
> Maybe make the button do a request to `/raw/topic_id/post_number` so you can copy the real post content?

Similar component already exists: [Raw Post Button](https://meta.discourse.org/t/raw-post-button/152542/1).

Adding a copy button to the modal of that component would combine both approaches, what do you think @keegan @Johani?

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [February 26, 2022, 4:54pm UTC](https://meta.discourse.org/t/copy-post-component/218883/11 "2022-02-26T16:54:39Z")

</div>

@md-misko Yup I think that’s a great idea. Since I created a widget for the copy button, I believe it can be quite simply copied over to be used in the modal.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [February 27, 2022, 6:53am UTC](https://meta.discourse.org/t/copy-post-component/218883/12 "2022-02-27T06:53:38Z")

</div>

Is there any trick to show the button to logged in users only?

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [March 1, 2022, 1:48pm UTC](https://meta.discourse.org/t/copy-post-component/218883/13 "2022-03-01T13:48:44Z")

</div>

@Jagster

There is now! :smiley: I’ve added a setting to apply a minimum trust level to show the widget. Configuring it to `0` will make it so only logged in users can see the button.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [March 1, 2022, 2:02pm UTC](https://meta.discourse.org/t/copy-post-component/218883/14 "2022-03-01T14:02:34Z")

</div>

Why can’t we put two thumbs up when it is earned :wink:

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [March 1, 2022, 5:59pm UTC](https://meta.discourse.org/t/copy-post-component/218883/15 "2022-03-01T17:59:43Z")

</div>

:+1: :+1:

> [@Jagster](#):
>
> Why can’t we put two thumbs up when it is earned

Now @keegan has them. :smiley:

---

<div class="post-metadata">

### Author: ![geoff777](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/geoff777/32/202388_2.png) [@geoff777](https://meta.discourse.org/u/geoff777)
#### Post date: [March 25, 2022, 1:49pm UTC](https://meta.discourse.org/t/copy-post-component/218883/16 "2022-03-25T13:49:12Z")

</div>

This wasn’t working on a new install.  
The min\_trust\_level wasn’t selectable in Admin.  
edit: component was functioning but wasn’t displaying correctly in Admin

I forked the repo and got it working but I set min\_trust\_level as an integer  
So (5) = ‘disabled’ (0-4) as expected. So a small rewrite.

I haven’t done a PR … as it’s a simplification .. perhaps someone else can confirm the component isn’t working?

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [May 2, 2022, 5:47pm UTC](https://meta.discourse.org/t/copy-post-component/218883/17 "2022-05-02T17:47:55Z")

</div>

Hey @geoff777 I’ve tested this on a new install and it seems to be working correctly for me.  
Also if I do apply those changes, the issue with using setting the min\_trust\_level as an integer in the settings.yml file is that the 0 value isn’t appearing in the dropdown.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [May 2, 2022, 6:33pm UTC](https://meta.discourse.org/t/copy-post-component/218883/18 "2022-05-02T18:33:52Z")

</div>

Any of values, except disabled, isn’t appearing in the box when selected. AFAIK any of values is in use, though.

 ![kuva](https://global.discourse-cdn.com/meta/original/4X/4/4/0/440c98d97fd2282c3ec73cf147cc21c48f0520c2.png)

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [May 2, 2022, 6:50pm UTC](https://meta.discourse.org/t/copy-post-component/218883/19 "2022-05-02T18:50:22Z")

</div>

> [@geoff777](#):
>
> I set min\_trust\_level as an integer

Ah sorry, my mistake, I thought you meant you changed the strings in the enum to integers, but you meant you used the integer type instead. Yes, that seems like a better approach. I’ve [updated the theme component](https://github.com/keegangeorge/discourse-copy-post/commit/6205c369f5ce7eb3b5def3871f1b4fc94530d064) to support that. Hopefully this should fix any of the issues.

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [August 21, 2024, 10:52am UTC](https://meta.discourse.org/t/copy-post-component/218883/20 "2024-08-21T10:52:35Z")

</div>

This is a great TC! In our use case we want our authors to copy full posts and paste them into an external editor of a course website. It would be great if you could copy the whole post including media in HTML or just rich text format.

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [January 14, 2025, 3:48pm UTC](https://meta.discourse.org/t/copy-post-component/218883/21 "2025-01-14T15:48:41Z")

</div>

Just a heads up to those who were previously using this. I’ve now moved this from being my personal project to now being an #official #Customization > Theme component :tada:. With that, I’ve done a few changes to modernize the component so it works correctly on the latest Discourse version.

I’ve also updated the settings. Instead of a trust level only setting, you can now select _any_ groups you want to be allowed to use the copy button. Additionally, I’ve allowed for a `copy_type` setting so you can choose whether the copied text is the post’s HTML markup or the raw Markdown.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [January 14, 2025, 4:47pm UTC](https://meta.discourse.org/t/copy-post-component/218883/22 "2025-01-14T16:47:35Z")

</div>

> [@keegan](#):
>
> Instead of a trust level only setting, you can now select _any_ groups you want to be allowed to use the copy button

I think it doesn’t work when you select “everyone” in the dropdown. At least I couldn’t find the button until I selected another group. (I know that problem also affects other plugins and components)

[Next page](https://meta.discourse.org/t/copy-post-component/218883.md?page=2)
