@@ -202,25 +202,27 @@ function playpen_text(playpen) {
202
202
} ) ;
203
203
} ) ;
204
204
205
- Array . from ( document . querySelectorAll ( 'pre code' ) ) . forEach ( function ( block ) {
206
- var pre_block = block . parentNode ;
207
- if ( ! pre_block . classList . contains ( 'playpen' ) ) {
208
- var buttons = pre_block . querySelector ( ".buttons" ) ;
209
- if ( ! buttons ) {
210
- buttons = document . createElement ( 'div' ) ;
211
- buttons . className = 'buttons' ;
212
- pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
213
- }
205
+ if ( window . playpen_copyable ) {
206
+ Array . from ( document . querySelectorAll ( 'pre code' ) ) . forEach ( function ( block ) {
207
+ var pre_block = block . parentNode ;
208
+ if ( ! pre_block . classList . contains ( 'playpen' ) ) {
209
+ var buttons = pre_block . querySelector ( ".buttons" ) ;
210
+ if ( ! buttons ) {
211
+ buttons = document . createElement ( 'div' ) ;
212
+ buttons . className = 'buttons' ;
213
+ pre_block . insertBefore ( buttons , pre_block . firstChild ) ;
214
+ }
214
215
215
- var clipButton = document . createElement ( 'button' ) ;
216
- clipButton . className = 'fa fa-copy clip-button' ;
217
- clipButton . title = 'Copy to clipboard' ;
218
- clipButton . setAttribute ( 'aria-label' , clipButton . title ) ;
219
- clipButton . innerHTML = '<i class=\"tooltiptext\"></i>' ;
216
+ var clipButton = document . createElement ( 'button' ) ;
217
+ clipButton . className = 'fa fa-copy clip-button' ;
218
+ clipButton . title = 'Copy to clipboard' ;
219
+ clipButton . setAttribute ( 'aria-label' , clipButton . title ) ;
220
+ clipButton . innerHTML = '<i class=\"tooltiptext\"></i>' ;
220
221
221
- buttons . insertBefore ( clipButton , buttons . firstChild ) ;
222
- }
223
- } ) ;
222
+ buttons . insertBefore ( clipButton , buttons . firstChild ) ;
223
+ }
224
+ } ) ;
225
+ }
224
226
225
227
// Process playpen code blocks
226
228
Array . from ( document . querySelectorAll ( ".playpen" ) ) . forEach ( function ( pre_block ) {
@@ -238,19 +240,21 @@ function playpen_text(playpen) {
238
240
runCodeButton . title = 'Run this code' ;
239
241
runCodeButton . setAttribute ( 'aria-label' , runCodeButton . title ) ;
240
242
241
- var copyCodeClipboardButton = document . createElement ( 'button' ) ;
242
- copyCodeClipboardButton . className = 'fa fa-copy clip-button' ;
243
- copyCodeClipboardButton . innerHTML = '<i class="tooltiptext"></i>' ;
244
- copyCodeClipboardButton . title = 'Copy to clipboard' ;
245
- copyCodeClipboardButton . setAttribute ( 'aria-label' , copyCodeClipboardButton . title ) ;
246
-
247
243
buttons . insertBefore ( runCodeButton , buttons . firstChild ) ;
248
- buttons . insertBefore ( copyCodeClipboardButton , buttons . firstChild ) ;
249
-
250
244
runCodeButton . addEventListener ( 'click' , function ( e ) {
251
245
run_rust_code ( pre_block ) ;
252
246
} ) ;
253
247
248
+ if ( window . playpen_copyable ) {
249
+ var copyCodeClipboardButton = document . createElement ( 'button' ) ;
250
+ copyCodeClipboardButton . className = 'fa fa-copy clip-button' ;
251
+ copyCodeClipboardButton . innerHTML = '<i class="tooltiptext"></i>' ;
252
+ copyCodeClipboardButton . title = 'Copy to clipboard' ;
253
+ copyCodeClipboardButton . setAttribute ( 'aria-label' , copyCodeClipboardButton . title ) ;
254
+
255
+ buttons . insertBefore ( copyCodeClipboardButton , buttons . firstChild ) ;
256
+ }
257
+
254
258
let code_block = pre_block . querySelector ( "code" ) ;
255
259
if ( window . ace && code_block . classList . contains ( "editable" ) ) {
256
260
var undoChangesButton = document . createElement ( 'button' ) ;
0 commit comments