mirror of
https://github.com/status-im/ETHReport.git
synced 2025-01-09 13:46:03 +00:00
Comments
This commit is contained in:
parent
efdb5aeca2
commit
68c3d32618
@ -53,6 +53,12 @@ const SearchResults = (props) => {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We check if the position of the matched term is greater than the length of the trim
|
||||||
|
* Then (strpos - length) would place our matched term at the beginning of the last character
|
||||||
|
* We add a further 50 characters as an allowance for the search term to show
|
||||||
|
*/
|
||||||
|
|
||||||
if (strpos > length && strpos !== -1 && length > 50 && text.length > length) {
|
if (strpos > length && strpos !== -1 && length > 50 && text.length > length) {
|
||||||
offset = strpos - (length - 50);
|
offset = strpos - (length - 50);
|
||||||
firstEllipses = '<p>...</p>';
|
firstEllipses = '<p>...</p>';
|
||||||
@ -62,6 +68,11 @@ const SearchResults = (props) => {
|
|||||||
startOffset = getStartOffset(offsetText);
|
startOffset = getStartOffset(offsetText);
|
||||||
endOffset = getEndOffset(offsetText);
|
endOffset = getEndOffset(offsetText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We only append a p tag if we haven't found any of the tags in getStartOffset()
|
||||||
|
* or if we've found a '>' in the first position. Since this could be an opening
|
||||||
|
* or a closing tag. So we remove it and add a p tag
|
||||||
|
*/
|
||||||
const newOffsetText = startOffset !== false && startOffset !== -1 ?
|
const newOffsetText = startOffset !== false && startOffset !== -1 ?
|
||||||
text.substr(offset + startOffset, length + offset + endOffset) :
|
text.substr(offset + startOffset, length + offset + endOffset) :
|
||||||
`<p>${text.substr(offset + 0, length + offset + endOffset)}`;
|
`<p>${text.substr(offset + 0, length + offset + endOffset)}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user