refactor(editor): improve naming and comments (#43662)
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f5de80dc4f
commit
38d65f95b4
@ -292,8 +292,8 @@ const Editor = (props: EditorProps): JSX.Element => {
|
|||||||
editorRef.current = editor;
|
editorRef.current = editor;
|
||||||
data.editor = editor;
|
data.editor = editor;
|
||||||
|
|
||||||
if (isProject()) {
|
if (isProjectStep()) {
|
||||||
initializeProjectFeatures();
|
initializeProjectStepFeatures();
|
||||||
addContentChangeListener();
|
addContentChangeListener();
|
||||||
showEditableRegion(editor);
|
showEditableRegion(editor);
|
||||||
}
|
}
|
||||||
@ -646,7 +646,7 @@ const Editor = (props: EditorProps): JSX.Element => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function initializeProjectFeatures() {
|
function initializeProjectStepFeatures() {
|
||||||
const editor = data.editor;
|
const editor = data.editor;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
initializeRegions(getEditableRegionFromRedux());
|
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();
|
const editableRegionBoundaries = getEditableRegionFromRedux();
|
||||||
return editableRegionBoundaries.length === 2;
|
return editableRegionBoundaries.length === 2;
|
||||||
}
|
}
|
||||||
@ -957,14 +959,14 @@ const Editor = (props: EditorProps): JSX.Element => {
|
|||||||
const { editor } = data;
|
const { editor } = data;
|
||||||
|
|
||||||
const hasChangedContents = updateEditorValues();
|
const hasChangedContents = updateEditorValues();
|
||||||
if (hasChangedContents && isProject()) {
|
if (hasChangedContents && isProjectStep()) {
|
||||||
initializeProjectFeatures();
|
initializeProjectStepFeatures();
|
||||||
updateDescriptionZone();
|
updateDescriptionZone();
|
||||||
updateOutputZone();
|
updateOutputZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
editor?.focus();
|
editor?.focus();
|
||||||
if (isProject() && editor) {
|
if (isProjectStep() && editor) {
|
||||||
showEditableRegion(editor);
|
showEditableRegion(editor);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
Reference in New Issue
Block a user