Skip to content

Commit

Permalink
fix: support multiline phrase highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
James Duffy committed Jan 29, 2021
1 parent bfd2ae0 commit 3d7281c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/components/Warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ export const calculatePosition = (coords) => {

export default function Warning(props) {
const { parentNode, rangeToHighlight } = props.value;
const warningStyle = highlightStyles(parentNode, rangeToHighlight);
const warningStyles = highlightStyles(parentNode, rangeToHighlight);
const coords = calculateCoords(parentNode, rangeToHighlight);
const position = calculatePosition(coords);
const positions = calculatePosition(coords);

return (
<div className="jns-warning">
<WarningHighlight
styles={warningStyle}
parent={parentNode}
keyword={props.value.keyword}
message={props.value.message}
position={position}
/>
</div>
);
const highlights = warningStyles.map((style, index) => (
<WarningHighlight
key={positions[index]}
styles={style}
parent={parentNode}
keyword={props.value.keyword}
message={props.value.message}
position={positions[index]}
/>
));
return <div className="jns-warning">{highlights}</div>;
}

0 comments on commit 3d7281c

Please sign in to comment.