@@ -22,9 +22,8 @@ import { CategoryApi, GitHubApi } from '/apis';
2222import { tracerManager } from '/core' ;
2323import { actions } from '/reducers' ;
2424import { extension , refineGist } from '/common/util' ;
25- import { exts , us } from '/common/config' ;
26- import README from '/static/README.md' ;
27- import SCRATCH_PAPER from '/static/SCRATCH_PAPER.md' ;
25+ import { languages , exts , us } from '/common/config' ;
26+ import { README_MD , SCRATCH_PAPER_MD } from '/skeletons' ;
2827import styles from './stylesheet.scss' ;
2928
3029loadProgressBar ( ) ;
@@ -135,15 +134,16 @@ class App extends React.Component {
135134 fetchPromise = CategoryApi . getAlgorithm ( categoryKey , algorithmKey )
136135 . then ( ( { algorithm } ) => algorithm ) ;
137136 } else if ( gistId === 'new' ) {
137+ const language = languages . find ( language => language . ext === ext ) ;
138138 fetchPromise = Promise . resolve ( {
139139 titles : [ 'Scratch Paper' , 'Untitled' ] ,
140140 files : [ {
141141 name : 'README.md' ,
142- content : SCRATCH_PAPER ,
142+ content : SCRATCH_PAPER_MD ,
143143 contributors : undefined ,
144144 } , {
145145 name : `code.${ ext } ` ,
146- content : '' , // TODO: put import statements as default
146+ content : language ? language . skeleton : '' , // TODO: put import statements as default
147147 contributors : undefined ,
148148 } ] ,
149149 } ) ;
@@ -156,7 +156,7 @@ class App extends React.Component {
156156 . then ( algorithm => this . props . setCurrent ( categoryKey , algorithmKey , gistId , algorithm . titles , algorithm . files ) )
157157 . catch ( ( ) => this . props . setCurrent ( undefined , undefined , undefined , [ 'Algorithm Visualizer' ] , [ {
158158 name : 'README.md' ,
159- content : README ,
159+ content : README_MD ,
160160 contributors : [ us ] ,
161161 } ] ) )
162162 . finally ( ( ) => {
@@ -245,7 +245,6 @@ class App extends React.Component {
245245 < FontAwesomeIcon fixedWidth icon = { faPlus } /> ,
246246 ) ;
247247
248- // TODO: let google search within algorithm-visualizer.org
249248 return (
250249 < div className = { styles . app } >
251250 < Helmet >
@@ -268,7 +267,7 @@ class App extends React.Component {
268267 < TabContainer className = { styles . editor_tab_container } titles = { editorTitles } tabIndex = { editorTabIndex }
269268 onChangeTabIndex = { tabIndex => this . handleChangeEditorTabIndex ( tabIndex ) } >
270269 {
271- files . map ( ( file , i ) => (
270+ files . map ( ( file , i ) => ( // TODO: editor cursor should stay when moved to scratch paper
272271 < CodeEditor key = { [ ...titles , i ] . join ( '--' ) } file = { file }
273272 onDeleteFile = { file => this . handleDeleteFile ( file ) } />
274273 ) )
0 commit comments