Skip to content

Commit

Permalink
Highlight all by default
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhou committed May 22, 2023
1 parent 26397c7 commit 1afdfac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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));
},
Expand Down

0 comments on commit 1afdfac

Please sign in to comment.