From db4b94f5adbfc2c68dc91ff200112ba316af6b38 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 30 Mar 2020 17:41:34 +0200 Subject: [PATCH] refactor: refer directly to editor when possible --- .../templates/Challenges/classic/Editor.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/client/src/templates/Challenges/classic/Editor.js b/client/src/templates/Challenges/classic/Editor.js index c4d7509c82..eb4204b4fb 100644 --- a/client/src/templates/Challenges/classic/Editor.js +++ b/client/src/templates/Challenges/classic/Editor.js @@ -128,15 +128,15 @@ class Editor extends Component { editorDidMount = (editor, monaco) => { this._editor = editor; - this._editor.updateOptions({ + editor.updateOptions({ accessibilitySupport: this.props.inAccessibilityMode ? 'on' : 'auto' }); // Users who are using screen readers should not have to move focus from // the editor to the description every time they open a challenge. if (this.props.canFocus && !this.props.inAccessibilityMode) { - this._editor.focus(); + editor.focus(); } else this.focusOnHotkeys(); - this._editor.addAction({ + editor.addAction({ id: 'execute-challenge', label: 'Run tests', keybindings: [ @@ -145,7 +145,7 @@ class Editor extends Component { ], run: this.props.executeChallenge }); - this._editor.addAction({ + editor.addAction({ id: 'leave-editor', label: 'Leave editor', keybindings: [monaco.KeyCode.Escape], @@ -154,7 +154,7 @@ class Editor extends Component { this.props.setEditorFocusability(false); } }); - this._editor.addAction({ + editor.addAction({ id: 'save-editor-content', label: 'Save editor content to localStorage', keybindings: [ @@ -162,7 +162,7 @@ class Editor extends Component { ], run: this.props.saveEditorContent }); - this._editor.addAction({ + editor.addAction({ id: 'toggle-accessibility', label: 'Toggle Accessibility Mode', keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F1], @@ -171,16 +171,14 @@ class Editor extends Component { // The store needs to be updated first, as onDidChangeConfiguration is // called before updateOptions returns this.props.setAccessibilityMode(!currentAccessibility); - this._editor.updateOptions({ + editor.updateOptions({ accessibilitySupport: currentAccessibility ? 'auto' : 'on' }); } }); - this._editor.onDidFocusEditorWidget(() => - this.props.setEditorFocusability(true) - ); + editor.onDidFocusEditorWidget(() => this.props.setEditorFocusability(true)); // This is to persist changes caused by the accessibility tooltip. - this._editor.onDidChangeConfiguration(event => { + editor.onDidChangeConfiguration(event => { if ( event.hasChanged(monaco.editor.EditorOption.accessibilitySupport) && editor.getRawOptions().accessibilitySupport === 'on' &&