@@ -35,6 +35,12 @@ const messages = {
35
35
'copy_to_clipboard' : '复制到剪贴板' ,
36
36
'copy_success' : '复制成功!' ,
37
37
'copy_failure' : '复制失败' ,
38
+ } ,
39
+ 'it' : {
40
+ 'copy' : 'Copiare' ,
41
+ 'copy_to_clipboard' : 'Copiato negli appunti' ,
42
+ 'copy_success' : 'Copiato!' ,
43
+ 'copy_failure' : 'Errore durante la copia' ,
38
44
}
39
45
}
40
46
@@ -49,7 +55,25 @@ if (doc_url_root == '#') {
49
55
doc_url_root = '' ;
50
56
}
51
57
52
- const path_static = `${ doc_url_root } _static/` ;
58
+ /**
59
+ * SVG files for our copy buttons
60
+ */
61
+ let iconCheck = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-check" width="44" height="44" viewBox="0 0 24 24" stroke-width="2" stroke="#22863a" fill="none" stroke-linecap="round" stroke-linejoin="round">
62
+ <title>${ messages [ locale ] [ 'copy_success' ] } </title>
63
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
64
+ <path d="M5 12l5 5l10 -10" />
65
+ </svg>`
66
+
67
+ // If the user specified their own SVG use that, otherwise use the default
68
+ let iconCopy = `` ;
69
+ if ( ! iconCopy ) {
70
+ iconCopy = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copy" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
71
+ <title>${ messages [ locale ] [ 'copy_to_clipboard' ] } </title>
72
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
73
+ <rect x="8" y="8" width="12" height="12" rx="2" />
74
+ <path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" />
75
+ </svg>`
76
+ }
53
77
54
78
/**
55
79
* Set up copy/paste for code blocks
@@ -88,9 +112,8 @@ const temporarilyChangeTooltip = (el, oldText, newText) => {
88
112
89
113
// Changes the copy button icon for two seconds, then changes it back
90
114
const temporarilyChangeIcon = ( el ) => {
91
- img = el . querySelector ( "img" ) ;
92
- img . setAttribute ( 'src' , `${ path_static } check-solid.svg` )
93
- setTimeout ( ( ) => img . setAttribute ( 'src' , `${ path_static } copy-button.svg` ) , 2000 )
115
+ el . innerHTML = iconCheck ;
116
+ setTimeout ( ( ) => { el . innerHTML = iconCopy } , 2000 )
94
117
}
95
118
96
119
const addCopyButtonToCodeCells = ( ) => {
@@ -109,7 +132,7 @@ const addCopyButtonToCodeCells = () => {
109
132
110
133
const clipboardButton = id =>
111
134
`<button class="copybtn o-tooltip--left" data-tooltip="${ messages [ locale ] [ 'copy' ] } " data-clipboard-target="#${ id } ">
112
- <img src=" ${ path_static } copy-button.svg" alt=" ${ messages [ locale ] [ 'copy_to_clipboard' ] } ">
135
+ ${ iconCopy }
113
136
</button>`
114
137
codeCell . insertAdjacentHTML ( 'afterend' , clipboardButton ( id ) )
115
138
} )
0 commit comments