From 38d65f95b48d27ceac142f7800a73ef096cdd35b Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 4 Oct 2021 15:48:57 +0200 Subject: [PATCH] refactor(editor): improve naming and comments (#43662) Co-authored-by: Shaun Hamilton Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com> --- .../src/templates/Challenges/classic/editor.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 3eac788982..ff1933c913 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -292,8 +292,8 @@ const Editor = (props: EditorProps): JSX.Element => { editorRef.current = editor; data.editor = editor; - if (isProject()) { - initializeProjectFeatures(); + if (isProjectStep()) { + initializeProjectStepFeatures(); addContentChangeListener(); showEditableRegion(editor); } @@ -646,7 +646,7 @@ const Editor = (props: EditorProps): JSX.Element => { } }; - function initializeProjectFeatures() { + function initializeProjectStepFeatures() { const editor = data.editor; if (editor) { initializeRegions(getEditableRegionFromRedux()); @@ -654,7 +654,9 @@ const Editor = (props: EditorProps): JSX.Element => { } } - function isProject() { + // Currently, only practice project parts have editable region markers + // This function is used to enable multiple editor tabs, jaws, etc. + function isProjectStep() { const editableRegionBoundaries = getEditableRegionFromRedux(); return editableRegionBoundaries.length === 2; } @@ -957,14 +959,14 @@ const Editor = (props: EditorProps): JSX.Element => { const { editor } = data; const hasChangedContents = updateEditorValues(); - if (hasChangedContents && isProject()) { - initializeProjectFeatures(); + if (hasChangedContents && isProjectStep()) { + initializeProjectStepFeatures(); updateDescriptionZone(); updateOutputZone(); } editor?.focus(); - if (isProject() && editor) { + if (isProjectStep() && editor) { showEditableRegion(editor); } // eslint-disable-next-line react-hooks/exhaustive-deps