From e5f01ab889b8b2d0d58718f4d6f25b64c8cc8856 Mon Sep 17 00:00:00 2001 From: "C. Fuhrman" Date: Fri, 14 Feb 2025 21:28:08 -0500 Subject: [PATCH] Correct bug in how questions are split Allow for multiple blank lines at start of editor without an error --- client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx b/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx index 453d5c9..f2c2d69 100644 --- a/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx +++ b/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx @@ -118,7 +118,11 @@ const QuizForm: React.FC = () => { setValue(value); } - const linesArray = value.split(/(?<=^|[^\\]}.*)[\n]+/); + // split value when there is at least one blank line + const linesArray = value.split(/\n{2,}/); + + // if the first item in linesArray is blank, remove it + if (linesArray[0] === '') linesArray.shift(); if (linesArray[linesArray.length - 1] === '') linesArray.pop();