@@ -1516,39 +1516,11 @@ function EmailDetail({ auth }: { auth: AuthState }) {
15161516
15171517 { /* Download .md */ }
15181518 < div className = "mt-4 pt-4 border-t border-gray-800 flex gap-2" >
1519- < button
1520- onClick = { ( ) => {
1521- const md = `# ${ email . subject || 'Email' } \n\n**From:** ${ email . from_addr } \n**To:** ${ email . to_addr } \n**Date:** ${ new Date ( email . created_at * 1000 ) . toISOString ( ) } \n\n---\n\n${ bodyText } ` ;
1522- // Try download, fallback to showing raw text
1523- try {
1524- const blob = new Blob ( [ md ] , { type : 'text/markdown' } ) ;
1525- const url = URL . createObjectURL ( blob ) ;
1526- const a = document . createElement ( 'a' ) ;
1527- a . href = url ;
1528- a . download = `${ ( email . subject || 'email' ) . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, '-' ) . slice ( 0 , 50 ) } .md` ;
1529- document . body . appendChild ( a ) ;
1530- a . click ( ) ;
1531- document . body . removeChild ( a ) ;
1532- setTimeout ( ( ) => URL . revokeObjectURL ( url ) , 1000 ) ;
1533- } catch {
1534- prompt ( 'Copy the markdown below:' , md ) ;
1535- }
1536- } }
1537- className = "text-gray-500 hover:text-gray-300 text-xs flex items-center gap-1 transition"
1538- >
1539- 📄 Download .md
1540- </ button >
1541- < button
1542- onClick = { ( ) => {
1543- navigator . clipboard . writeText ( bodyText ) . then (
1544- ( ) => alert ( 'Copied!' ) ,
1545- ( ) => prompt ( 'Copy the text below:' , bodyText ) ,
1546- ) ;
1547- } }
1548- className = "text-gray-500 hover:text-gray-300 text-xs flex items-center gap-1 transition"
1549- >
1550- 📋 Copy text
1551- </ button >
1519+ < CopyButton
1520+ label = "📋 Copy Markdown"
1521+ text = { `# ${ email . subject || 'Email' } \n\n**From:** ${ email . from_addr } \n**To:** ${ email . to_addr } \n**Date:** ${ new Date ( email . created_at * 1000 ) . toISOString ( ) } \n\n---\n\n${ bodyText } ` }
1522+ />
1523+ < CopyButton label = "📄 Copy Plain Text" text = { bodyText } />
15521524 </ div >
15531525 </ div >
15541526 </ div >
0 commit comments