Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Fix/token annotator whitespace and reset (#892)
Browse files Browse the repository at this point in the history
* Fix token annotator whitespace and allowing answer unselecting

* Removed duplicate setData() call
  • Loading branch information
maxbartolo authored Feb 24, 2022
1 parent cdfa0d3 commit ab17e4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions frontends/web/src/common/Annotation/AnnotationComponent.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@
text-transform: uppercase;
color: #005798;
}

.token-annotator > span {
/* Fix for react-text-annote token annotator added whitespace around tokens */
margin-right: -4px;
white-space: pre-wrap;
letter-spacing: 0.2px;
line-height: 1.8;
}

.token-annotator > mark {
margin-right: 2px;
}
11 changes: 8 additions & 3 deletions frontends/web/src/common/Annotation/AnnotationComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,20 @@ const ContextStringSelection = ({
{configObj.reference_name}:
</h6>
<TokenAnnotator
className="mb-1 p-3 light-gray-bg"
tokens={data[configObj.reference_name].split(/\b/)}
className="mb-1 p-3 light-gray-bg token-annotator"
tokens={data[configObj.reference_name].split(
/\b|(?<=[\s\(\)])|(?=[\s\(\)])/
)}
value={selectionInfo}
onChange={(value) => {
if (value.length > 0) {
setSelectionInfo([value[value.length - 1]]);
data[name] = value[value.length - 1].tokens.join("");
setData(data);
} else {
setSelectionInfo([]);
data[name] = "";
}
setData(data);
}}
getSpan={(span) => ({
...span,
Expand Down

0 comments on commit ab17e4a

Please sign in to comment.