@@ -32,10 +32,28 @@ function main() {
32
32
divider . className = 'Navigation__NavMenuDivider'
33
33
container . appendChild ( divider )
34
34
35
+ const copyHtml = `${ iconCopy } Copy`
36
+ const copiedHtml = `${ iconCopy } Copied`
35
37
const copyButton = < HTMLAnchorElement > firstItem . cloneNode ( true )
36
38
copyButton . removeAttribute ( 'href' )
37
- copyButton . innerHTML = `${ iconCopy } Copy`
38
- copyButton . addEventListener ( 'click' , ( ) => copyToText ( ) )
39
+ copyButton . innerHTML = copyHtml
40
+ copyButton . addEventListener ( 'click' , ( ) => {
41
+ const items = getConversation ( )
42
+ if ( items . length === 0 ) {
43
+ // eslint-disable-next-line no-alert
44
+ alert ( 'No conversation found. Please send a message first.' )
45
+ return
46
+ }
47
+
48
+ const text = conversationToText ( items )
49
+ copyToClipboard ( text )
50
+
51
+ copyButton . innerHTML = copiedHtml
52
+ setTimeout ( ( ) => {
53
+ copyButton . innerHTML = copyHtml
54
+ copyButton . classList . remove ( 'copied' )
55
+ } , 3000 )
56
+ } )
39
57
container . appendChild ( copyButton )
40
58
41
59
const htmlButton = < HTMLAnchorElement > firstItem . cloneNode ( true )
@@ -46,18 +64,6 @@ function main() {
46
64
} )
47
65
}
48
66
49
- function copyToText ( ) {
50
- const items = getConversation ( )
51
- if ( items . length === 0 ) {
52
- // eslint-disable-next-line no-alert
53
- alert ( 'No conversation found. Please send a message first.' )
54
- return
55
- }
56
-
57
- const text = conversationToText ( items )
58
- copyToClipboard ( text )
59
- }
60
-
61
67
function exportToHtml ( ) {
62
68
const items = getConversation ( )
63
69
if ( items . length === 0 ) {
0 commit comments