Patch: Fix too-long code in comment previews via appropriate truncation (#19540)
* Fix too-long code in comment previews * Update app/javascript/articles/components/CommentListItem.jsx --------- Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
This commit is contained in:
parent
56414481ba
commit
2fe2c6c6bb
1 changed files with 3 additions and 2 deletions
|
|
@ -20,12 +20,13 @@ function contentAwareComments(comment) {
|
|||
nodes.forEach((node) => {
|
||||
if (
|
||||
node.outerHTML &&
|
||||
node.tagName === 'P' &&
|
||||
(node.tagName === 'P' || node.className.includes('highlight')) &&
|
||||
nodesSelected < 2 &&
|
||||
node.outerHTML.length > 250
|
||||
&& !node.outerHTML.includes('article-body-image-wrapper')
|
||||
) {
|
||||
text = `${text} ${node.outerHTML.substring(0, 230)} ...`;
|
||||
node.innerHTML = `${node.innerHTML.substring(0, 230)}...`;
|
||||
text = `${text} ${node.outerHTML}`;
|
||||
nodesSelected = 2;
|
||||
} else if (node.outerHTML && nodesSelected < 2) {
|
||||
text = text + node.outerHTML;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue