@@ -198,49 +198,31 @@ class PreviewFrame extends React.Component {
198198 this . resolveScripts ( sketchDoc , resolvedFiles ) ;
199199 this . resolveStyles ( sketchDoc , resolvedFiles ) ;
200200
201- let scriptsToInject = [
201+ const scriptsToInject = [
202202 '/loop-protect.min.js' ,
203203 '/hijackConsole.js'
204204 ] ;
205- if (
206- this . props . isAccessibleOutputPlaying ||
207- ( ( this . props . textOutput || this . props . gridOutput || this . props . soundOutput ) && this . props . isPlaying ) ) {
208- let interceptorScripts = [ ] ;
209- interceptorScripts = [
210- '/p5-interceptor/registry.js' ,
211- '/p5-interceptor/loadData.js' ,
212- '/p5-interceptor/interceptorHelperFunctions.js' ,
213- '/p5-interceptor/baseInterceptor.js' ,
214- '/p5-interceptor/entities/entity.min.js' ,
215- '/p5-interceptor/ntc.min.js'
216- ] ;
217- if ( ! this . props . textOutput && ! this . props . gridOutput && ! this . props . soundOutput ) {
218- this . props . setTextOutput ( true ) ;
219- }
220- if ( this . props . textOutput ) {
221- let textInterceptorScripts = [ ] ;
222- textInterceptorScripts = [
223- '/p5-interceptor/textInterceptor/interceptorFunctions.js' ,
224- '/p5-interceptor/textInterceptor/interceptorP5.js'
225- ] ;
226- interceptorScripts = interceptorScripts . concat ( textInterceptorScripts ) ;
227- }
228- if ( this . props . gridOutput ) {
229- let gridInterceptorScripts = [ ] ;
230- gridInterceptorScripts = [
231- '/p5-interceptor/gridInterceptor/interceptorFunctions.js' ,
232- '/p5-interceptor/gridInterceptor/interceptorP5.js'
233- ] ;
234- interceptorScripts = interceptorScripts . concat ( gridInterceptorScripts ) ;
235- }
236- if ( this . props . soundOutput ) {
237- let soundInterceptorScripts = [ ] ;
238- soundInterceptorScripts = [
239- '/p5-interceptor/soundInterceptor/interceptorP5.js'
240- ] ;
241- interceptorScripts = interceptorScripts . concat ( soundInterceptorScripts ) ;
242- }
243- scriptsToInject = scriptsToInject . concat ( interceptorScripts ) ;
205+ const accessiblelib = sketchDoc . createElement ( 'script' ) ;
206+ accessiblelib . setAttribute ( 'src' , 'https://cdn.rawgit.com/MathuraMG/p5-accessibility/e856365c/dist/p5-accessibility.js' ) ;
207+ if ( this . props . textOutput ) {
208+ sketchDoc . getElementById ( 'accessibility-library' ) . appendChild ( accessiblelib ) ;
209+ const textSection = sketchDoc . createElement ( 'section' ) ;
210+ textSection . setAttribute ( 'id' , 'textOutput-content' ) ;
211+ sketchDoc . getElementById ( 'accessible-outputs' ) . appendChild ( textSection ) ;
212+ this . iframeElement . focus ( ) ;
213+ }
214+ if ( this . props . gridOutput ) {
215+ sketchDoc . getElementById ( 'accessibility-library' ) . appendChild ( accessiblelib ) ;
216+ const gridSection = sketchDoc . createElement ( 'section' ) ;
217+ gridSection . setAttribute ( 'id' , 'gridOutput-content' ) ;
218+ sketchDoc . getElementById ( 'accessible-outputs' ) . appendChild ( gridSection ) ;
219+ this . iframeElement . focus ( ) ;
220+ }
221+ if ( this . props . soundOutput ) {
222+ sketchDoc . getElementById ( 'accessibility-library' ) . appendChild ( accessiblelib ) ;
223+ const soundSection = sketchDoc . createElement ( 'section' ) ;
224+ soundSection . setAttribute ( 'id' , 'soundOutput-content' ) ;
225+ sketchDoc . getElementById ( 'accessible-outputs' ) . appendChild ( soundSection ) ;
244226 }
245227
246228 scriptsToInject . forEach ( ( scriptToInject ) => {
@@ -419,7 +401,7 @@ PreviewFrame.propTypes = {
419401 textOutput : PropTypes . bool . isRequired ,
420402 gridOutput : PropTypes . bool . isRequired ,
421403 soundOutput : PropTypes . bool . isRequired ,
422- setTextOutput : PropTypes . func . isRequired ,
404+ // setTextOutput: PropTypes.func.isRequired,
423405 htmlFile : PropTypes . shape ( {
424406 content : PropTypes . string . isRequired
425407 } ) . isRequired ,
0 commit comments