Skip to content

Commit 9c4475e

Browse files
Merge pull request #864 from LiamEdwardsLamarche/fix/htmlRenderRollback
html render rollback due to too many bugs
2 parents ace909f + 62cf070 commit 9c4475e

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/chart/graph/component/GraphEntityInspectionTable.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ShowMoreText from 'react-show-more-text';
33
import { Checkbox, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
44
import { TextLink } from '@neo4j-ndl/react';
5-
import DOMPurify from 'dompurify';
5+
// import DOMPurify from 'dompurify';
66

77
export const formatProperty = (property) => {
88
const str = property?.toString() || '';
@@ -13,8 +13,7 @@ export const formatProperty = (property) => {
1313
</TextLink>
1414
);
1515
}
16-
const cleanValue = DOMPurify.sanitize(str);
17-
return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
16+
return str;
1817
};
1918

2019
/**
@@ -91,7 +90,7 @@ export const GraphEntityInspectionTable = ({
9190
{key}
9291
</TableCell>
9392
<TableCell align={'left'} style={{ color: tableTextColor }}>
94-
<ShowMoreText lines={2}>{formatProperty(entity?.properties[key])}</ShowMoreText>
93+
<ShowMoreText lines={2}>{formatProperty(entity?.properties[key])}</ShowMoreText>
9594
</TableCell>
9695
{checklistEnabled ? (
9796
<TableCell align={'center'}>

src/chart/table/TableChart.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ const fallbackRenderer = (value) => {
3838
return JSON.stringify(value);
3939
};
4040

41-
function htmlToPlainText(html): string {
42-
// Create a temporary div element to hold the sanitized HTML content
43-
const tempElement = document.createElement('div');
44-
// Set the HTML content directly as innerHTML of the temporary element
45-
tempElement.innerHTML = html.props.dangerouslySetInnerHTML.__html;
46-
// Extract plain text using textContent
47-
return tempElement.textContent ?? '';
48-
}
49-
5041
function renderAsButtonWrapper(renderer) {
5142
return function renderAsButton(value) {
5243
const outputValue = renderer(value, true);
@@ -59,7 +50,7 @@ function renderAsButtonWrapper(renderer) {
5950
style={{ width: '100%', marginLeft: '5px', marginRight: '5px' }}
6051
variant='contained'
6152
color='primary'
62-
>{`${htmlToPlainText(outputValue)}`}</Button>
53+
>{outputValue}</Button>
6354
);
6455
};
6556
}

src/report/ReportRecordProcessing.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
valueIsPath,
1111
valueIsRelationship,
1212
} from '../chart/ChartUtils';
13-
import DOMPurify from 'dompurify';
13+
// import DOMPurify from 'dompurify';
1414

1515
/**
1616
* Collects all node labels and node properties in a set of Neo4j records.
@@ -267,8 +267,7 @@ function RenderString(value) {
267267
</TextLink>
268268
);
269269
}
270-
const cleanValue = DOMPurify.sanitize(str);
271-
return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
270+
return str;
272271
}
273272

274273
function RenderLink(value, disabled = false) {

0 commit comments

Comments
 (0)