diff --git a/client/components/GecView/index.js b/client/components/GecView/index.js index 9e61ac97..e3343924 100644 --- a/client/components/GecView/index.js +++ b/client/components/GecView/index.js @@ -17,7 +17,6 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed return isError && edit.o_start === edit.o_end && edit.o_str === "" ? ( setHovered(true)} @@ -55,7 +54,6 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed ) : isError ? ( setHovered(true)} @@ -94,7 +92,7 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed )} ) : ( - + {word}{' '} ) @@ -158,6 +156,14 @@ const GrammarCheck = () => { const words = text.split(' ') const sentenceEdits = edits[index] || [] const modifiedSentence = [] + + // Loop through the sentence edits to adjust the words array with placeholders + sentenceEdits.forEach(edit => { + if (edit.o_start === edit.o_end && edit.o_str === "") { + // Insert an empty string at the insertion index + words.splice(edit.c_start, 0, ""); + } + }); let currentEditIndex = 0 let currentWordIndex = 0