From 1afdfac9d4d8f3969b713fe5349b2990cc2ef083 Mon Sep 17 00:00:00 2001 From: yuanzhou Date: Mon, 22 May 2023 12:44:00 -0400 Subject: [PATCH] Highlight all by default --- src/components/Document.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Document.js b/src/components/Document.js index 5f538b8..234a86e 100644 --- a/src/components/Document.js +++ b/src/components/Document.js @@ -40,7 +40,8 @@ function Document(props) { } } - const [checkedVariables, setCheckedVariables] = useState(new Array(variableNamesArr.length).fill(false)); + // By default, all the variable checkboxes are selected to highlight the text mentions + const [checkedVariables, setCheckedVariables] = useState(new Array(variableNamesArr.length).fill(true)); // Reset the state variables on each new file selection function resetAllStates() { @@ -51,7 +52,7 @@ function Document(props) { setDocPreview(''); setNlpResult({}); setError(''); - setCheckedVariables(new Array(variableNamesArr.length).fill(false)); + setCheckedVariables(new Array(variableNamesArr.length).fill(true)); } // Reset the state variables on each click of the Summarize button @@ -61,7 +62,7 @@ function Document(props) { setDocPreview(docText); setNlpResult({}); setError(''); - setCheckedVariables(new Array(variableNamesArr.length).fill(false)); + setCheckedVariables(new Array(variableNamesArr.length).fill(true)); } // const with curly brackets is object destructuring assignment from ES6 specifications @@ -140,6 +141,11 @@ function Document(props) { // `data` is an object here setNlpResult(res.data); + // Trigger multihighlighting + // Without this line, the text preview won't highlight any text mentions + // even though resetSummaryStates() was called earlier + setCheckedVariables(new Array(variableNamesArr.length).fill(true)); + // console.log("======Pretty print======"); // console.log(JSON.stringify(res.data, null, 2)); },