diff --git a/about.json b/about.json index 6754eec..cc0328b 100644 --- a/about.json +++ b/about.json @@ -3,7 +3,7 @@ "component": true, "authors": "Keegan George", "theme_version": "0.1", - "about_url": null, + "about_url": "https://meta.discourse.org/t/copy-post-component/218883", "license_url": null, "modifiers": { "svg_icons": [ diff --git a/javascripts/discourse/widgets/copy-widget.js b/javascripts/discourse/widgets/copy-widget.js index a0fb0ad..f522daa 100644 --- a/javascripts/discourse/widgets/copy-widget.js +++ b/javascripts/discourse/widgets/copy-widget.js @@ -18,8 +18,13 @@ createWidget('copy-widget', { click(attrs) { const copyButton = attrs.currentTarget.activeElement; + const rawCooked = this.attrs.attrs.cooked; const cookedText = this.attrs.attrs.cooked.replace(/
(.*)<\/p>/g, '$1\n'); - const postContents = cookedText.replace(/(<([^>]+)>)/gi, ''); + let postContents = cookedText.replace(/(<([^>]+)>)/gi, ''); + + if (settings.copy_raw_html) { + postContents = rawCooked; + } const state = copyButton.innerHTML; diff --git a/settings.yml b/settings.yml index e69de29..1228dca 100644 --- a/settings.yml +++ b/settings.yml @@ -0,0 +1,5 @@ +copy_raw_html: + type: bool + default: false + description: + "If selected the copied contents will be raw HTML instead of the stripped down plain text" \ No newline at end of file