The Copy Post theme component, now an official Discourse project maintained by keegan, adds a button to post controls that copies content to the clipboard. Originally, the component copied plain text, stripping formatting and media, but keegan added a setting to copy raw HTML to preserve structure and media, addressing user Zupās feedback. The component is configurable via copy_type (Markdown or HTML) and copy_button_allowed_groups, allowing admins to restrict usage to specific groups or trust levels.
Discussions included feature requests for a āDuplicateā post function Zup and integration with raw post viewing Falco, which keegan noted could be combined with existing components. Technical issues were reported by geoff777 and Jagster regarding the min_trust_level setting not displaying correctly in the admin panel; keegan resolved this by switching the setting type to integer. Another issue where the button failed to appear for āeveryoneā was fixed by keegan after Moin reported it.
An error occurring for anonymous users was identified by Arkshine and fixed via PR #14. Ethsim2 conducted deep investigation into clipboard failures on iOS Safari, noting that while the UI indicated success, the clipboard content was sometimes not updated due to race conditions. Ethsim2 subsequently submitted PR #39 to ensure the success indicator only appears after the clipboard write operation completes.
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.
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?
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.
@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.
There is now! 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.
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?
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.
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 to support that. Hopefully this should fix any of the issues.
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.
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 officialCustomization > Theme component. 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.
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)