feat(client): handle jsx in multi-file editor
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
1a985f95f5
commit
10d2559fee
@ -127,6 +127,10 @@ class Editor extends Component {
|
|||||||
indexhtml: {
|
indexhtml: {
|
||||||
model: null,
|
model: null,
|
||||||
state: null
|
state: null
|
||||||
|
},
|
||||||
|
indexjsx: {
|
||||||
|
model: null,
|
||||||
|
state: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -281,6 +285,8 @@ class Editor extends Component {
|
|||||||
this.data.indexcss.state = currentState;
|
this.data.indexcss.state = currentState;
|
||||||
} else if (currentModel === this.data.indexhtml.model) {
|
} else if (currentModel === this.data.indexhtml.model) {
|
||||||
this.data.indexhtml.state = currentState;
|
this.data.indexhtml.state = currentState;
|
||||||
|
} else if (currentModel === this.data.indexjsx.model) {
|
||||||
|
this.data.indexjsx.state = currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.setModel(this.data[fileKey].model);
|
editor.setModel(this.data[fileKey].model);
|
||||||
@ -310,6 +316,14 @@ class Editor extends Component {
|
|||||||
<Suspense fallback={<Loader timeout={600} />}>
|
<Suspense fallback={<Loader timeout={600} />}>
|
||||||
<span className='notranslate'>
|
<span className='notranslate'>
|
||||||
<div className='monaco-editor-tabs'>
|
<div className='monaco-editor-tabs'>
|
||||||
|
{challengeFiles['indexjsx'] && (
|
||||||
|
<div
|
||||||
|
className='monaco-editor-tab'
|
||||||
|
onClick={() => this.changeTab('indexjsx')}
|
||||||
|
>
|
||||||
|
script.jsx
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{challengeFiles['indexhtml'] && (
|
{challengeFiles['indexhtml'] && (
|
||||||
<div
|
<div
|
||||||
className='monaco-editor-tab'
|
className='monaco-editor-tab'
|
||||||
|
@ -34,5 +34,17 @@ export const challengeFiles = {
|
|||||||
path: 'index.js',
|
path: 'index.js',
|
||||||
seed: 'some js',
|
seed: 'some js',
|
||||||
tail: ''
|
tail: ''
|
||||||
|
},
|
||||||
|
indexjsx: {
|
||||||
|
contents: 'some jsx',
|
||||||
|
error: null,
|
||||||
|
ext: 'jsx',
|
||||||
|
head: '',
|
||||||
|
history: ['index.jsx'],
|
||||||
|
key: 'indexjsx',
|
||||||
|
name: 'index',
|
||||||
|
path: 'index.jsx',
|
||||||
|
seed: 'some jsx',
|
||||||
|
tail: ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,8 @@ export function sortFiles(challengeFiles) {
|
|||||||
xs.sort((a, b) => {
|
xs.sort((a, b) => {
|
||||||
if (a.ext === 'html') return -1;
|
if (a.ext === 'html') return -1;
|
||||||
if (b.ext === 'html') return 1;
|
if (b.ext === 'html') return 1;
|
||||||
|
if (a.ext === 'jsx') return -1;
|
||||||
|
if (b.ext === 'jsx') return 1;
|
||||||
if (a.ext === 'js') return -1;
|
if (a.ext === 'js') return -1;
|
||||||
if (b.ext === 'js') return 1;
|
if (b.ext === 'js') return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -19,8 +19,9 @@ describe('sort-files', () => {
|
|||||||
it('should sort the objects into html, js, css order', () => {
|
it('should sort the objects into html, js, css order', () => {
|
||||||
const sorted = sortFiles(challengeFiles);
|
const sorted = sortFiles(challengeFiles);
|
||||||
const sortedKeys = sorted.map(({ key }) => key);
|
const sortedKeys = sorted.map(({ key }) => key);
|
||||||
const expected = ['indexhtml', 'indexjs', 'indexcss'];
|
const expected = ['indexhtml', 'indexjsx', 'indexjs', 'indexcss'];
|
||||||
expect(sortedKeys).toStrictEqual(expected);
|
expect(sortedKeys).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user