@@ -35,6 +35,12 @@ const messages = {
3535 'copy_to_clipboard' : '复制到剪贴板' ,
3636 'copy_success' : '复制成功!' ,
3737 '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' ,
3844 }
3945}
4046
@@ -49,7 +55,25 @@ if (doc_url_root == '#') {
4955 doc_url_root = '' ;
5056}
5157
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+ }
5377
5478/**
5579 * Set up copy/paste for code blocks
@@ -88,9 +112,8 @@ const temporarilyChangeTooltip = (el, oldText, newText) => {
88112
89113// Changes the copy button icon for two seconds, then changes it back
90114const 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 )
94117}
95118
96119const addCopyButtonToCodeCells = ( ) => {
@@ -109,7 +132,7 @@ const addCopyButtonToCodeCells = () => {
109132
110133 const clipboardButton = id =>
111134 `<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 }
113136 </button>`
114137 codeCell . insertAdjacentHTML ( 'afterend' , clipboardButton ( id ) )
115138 } )
0 commit comments