fix(editor): Clear codemirror undo on new challenge (#17002)
clear codemirror undo stack on new challenge Closes #16960 fix(editor): Removed not required code Closes #16960 feat(editor): Updated code with coding style Closes #16960
This commit is contained in:
committed by
Stuart Taylor
parent
b5864279fa
commit
38e9cff9fa
@ -16,7 +16,7 @@ import {
|
|||||||
keySelector
|
keySelector
|
||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
|
|
||||||
import { themeSelector } from '../../../../redux';
|
import { themeSelector, challengeSelector } from '../../../../redux';
|
||||||
|
|
||||||
import { filesSelector } from '../../../../files';
|
import { filesSelector } from '../../../../files';
|
||||||
|
|
||||||
@ -39,17 +39,20 @@ const options = {
|
|||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
filesSelector,
|
filesSelector,
|
||||||
challengeMetaSelector,
|
challengeMetaSelector,
|
||||||
|
challengeSelector,
|
||||||
keySelector,
|
keySelector,
|
||||||
themeSelector,
|
themeSelector,
|
||||||
(
|
(
|
||||||
files = {},
|
files = {},
|
||||||
{ mode = 'javascript'},
|
{ mode = 'javascript' },
|
||||||
|
{ id },
|
||||||
key,
|
key,
|
||||||
theme
|
theme
|
||||||
) => ({
|
) => ({
|
||||||
content: files[key] && files[key].contents || '// Happy Coding!',
|
content: files[key] && files[key].contents || '// Happy Coding!',
|
||||||
file: files[key],
|
file: files[key],
|
||||||
fileKey: key,
|
fileKey: key,
|
||||||
|
id,
|
||||||
mode,
|
mode,
|
||||||
theme
|
theme
|
||||||
})
|
})
|
||||||
@ -65,6 +68,7 @@ const propTypes = {
|
|||||||
content: PropTypes.string,
|
content: PropTypes.string,
|
||||||
executeChallenge: PropTypes.func.isRequired,
|
executeChallenge: PropTypes.func.isRequired,
|
||||||
fileKey: PropTypes.string.isRequired,
|
fileKey: PropTypes.string.isRequired,
|
||||||
|
id: PropTypes.string,
|
||||||
mode: PropTypes.string,
|
mode: PropTypes.string,
|
||||||
theme: PropTypes.string
|
theme: PropTypes.string
|
||||||
};
|
};
|
||||||
@ -125,6 +129,7 @@ export class Editor extends PureComponent {
|
|||||||
content,
|
content,
|
||||||
executeChallenge,
|
executeChallenge,
|
||||||
fileKey,
|
fileKey,
|
||||||
|
id,
|
||||||
classicEditorUpdated,
|
classicEditorUpdated,
|
||||||
mode
|
mode
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@ -136,6 +141,7 @@ export class Editor extends PureComponent {
|
|||||||
>
|
>
|
||||||
<NoSSR onSSR={ <CodeMirrorSkeleton content={ content } /> }>
|
<NoSSR onSSR={ <CodeMirrorSkeleton content={ content } /> }>
|
||||||
<Codemirror
|
<Codemirror
|
||||||
|
key={ id }
|
||||||
onChange={ change => classicEditorUpdated(fileKey, change) }
|
onChange={ change => classicEditorUpdated(fileKey, change) }
|
||||||
options={ this.createOptions({ executeChallenge, mode, cmTheme }) }
|
options={ this.createOptions({ executeChallenge, mode, cmTheme }) }
|
||||||
ref='editor'
|
ref='editor'
|
||||||
|
Reference in New Issue
Block a user