Skip to content

Commit db7b502

Browse files
simonwclaude
andauthored
Add copy HTML newsletter to clipboard button (#188)
> Modify blog-to-newsletter and add a “Copy HTML newsletter to clipboard” button Adds a new button next to the existing rich text copy button that copies the raw HTML source of the newsletter to the clipboard, useful for pasting into email HTML editors or other tools that need the markup directly. Co-authored-by: Claude <noreply@anthropic.com>
1 parent f07ff33 commit db7b502

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

blog-to-newsletter.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ <h1>Blog to Newsletter</h1>
339339

340340
<div class="buttons">
341341
<button class="primary-btn" id="copyRichText">Copy rich text newsletter to clipboard</button>
342+
<button class="primary-btn" id="copyHtml">Copy HTML newsletter to clipboard</button>
342343
<button class="secondary-btn" id="copyLinksOnly">Copy just the links/quotes/TILs</button>
343344
</div>
344345

@@ -1069,6 +1070,16 @@ <h2>Links sent in previous newsletters</h2>
10691070
copyRichText(newsletterHTML);
10701071
});
10711072

1073+
document.getElementById('copyHtml').addEventListener('click', async () => {
1074+
try {
1075+
await navigator.clipboard.writeText(newsletterHTML);
1076+
showStatus('HTML copied to clipboard!', 'success');
1077+
setTimeout(hideStatus, 2000);
1078+
} catch (e) {
1079+
showStatus('Failed to copy: ' + e.message, 'error');
1080+
}
1081+
});
1082+
10721083
document.getElementById('copyLinksOnly').addEventListener('click', () => {
10731084
const linksOnlyHtml = content
10741085
.filter(e => e.type !== 'entry')

0 commit comments

Comments
 (0)