File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,16 @@ class PreviewFrame extends React.Component {
340
340
} else {
341
341
script . setAttribute ( 'data-tag' , `${ startTag } ${ resolvedFile . name } ` ) ;
342
342
script . removeAttribute ( 'src' ) ;
343
- script . innerHTML = resolvedFile . content ; // eslint-disable-line
343
+ let content = resolvedFile . content ;
344
+ if ( resolvedFile . name === 'sketch.js' ) {
345
+ if ( ! / f u n c t i o n \s + s e t u p \s * \( \s * \) / . test ( content ) ) {
346
+ if ( ! / c r e a t e C a n v a s \s * \( [ ^ ) ] * \) / . test ( content ) ) {
347
+ content = `createCanvas(400, 400);${ content } ` ;
348
+ }
349
+ content = `function setup(){${ content } }` ;
350
+ }
351
+ }
352
+ script . innerHTML = content ; // eslint-disable-line
344
353
}
345
354
}
346
355
} else if ( ! ( script . getAttribute ( 'src' ) && script . getAttribute ( 'src' ) . match ( EXTERNAL_LINK_REGEX ) ) !== null ) {
Original file line number Diff line number Diff line change 1
1
import objectID from 'bson-objectid' ;
2
2
import * as ActionTypes from '../../../constants' ;
3
3
4
- const defaultSketch = `function setup() {
5
- createCanvas(400, 400);
6
- }
7
-
8
- function draw() {
9
- background(220);
10
- }` ;
4
+ const defaultSketch = '' ;
11
5
12
6
const defaultHTML =
13
7
`<!DOCTYPE html>
You can’t perform that action at this time.
0 commit comments