Skip to content

Commit ae7e3e5

Browse files
html render rollback due to too many bugs
1 parent 6e54e0d commit ae7e3e5

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/chart/graph/component/GraphEntityInspectionTable.tsx

Lines changed: 8 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,11 @@ export const formatProperty = (property) => {
1313
</TextLink>
1414
);
1515
}
16-
const cleanValue = DOMPurify.sanitize(str);
17-
return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
16+
return property;
17+
18+
// html render rollback
19+
// const cleanValue = DOMPurify.sanitize(str);
20+
// return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
1821
};
1922

2023
/**
@@ -91,7 +94,8 @@ export const GraphEntityInspectionTable = ({
9194
{key}
9295
</TableCell>
9396
<TableCell align={'left'} style={{ color: tableTextColor }}>
94-
<ShowMoreText lines={2}>{formatProperty(entity?.properties[key])}</ShowMoreText>
97+
<ShowMoreText lines={2}>{formatProperty(entity && entity.properties[key].toString())}</ShowMoreText>
98+
{/* <ShowMoreText lines={2}>{formatProperty(entity?.properties[key])}</ShowMoreText> */}
9599
</TableCell>
96100
{checklistEnabled ? (
97101
<TableCell align={'center'}>

src/chart/table/TableChart.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ 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-
}
41+
// html Render Rollback
42+
// function htmlToPlainText(html): string {
43+
// // Create a temporary div element to hold the sanitized HTML content
44+
// const tempElement = document.createElement('div');
45+
// // Set the HTML content directly as innerHTML of the temporary element
46+
// tempElement.innerHTML = html.props.dangerouslySetInnerHTML.__html;
47+
// // Extract plain text using textContent
48+
// return tempElement.textContent ?? '';
49+
// }
4950

5051
function renderAsButtonWrapper(renderer) {
5152
return function renderAsButton(value) {
@@ -59,7 +60,7 @@ function renderAsButtonWrapper(renderer) {
5960
style={{ width: '100%', marginLeft: '5px', marginRight: '5px' }}
6061
variant='contained'
6162
color='primary'
62-
>{`${htmlToPlainText(outputValue)}`}</Button>
63+
>{outputValue}</Button>
6364
);
6465
};
6566
}

src/report/ReportRecordProcessing.tsx

Lines changed: 5 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,10 @@ function RenderString(value) {
267267
</TextLink>
268268
);
269269
}
270-
const cleanValue = DOMPurify.sanitize(str);
271-
return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
270+
return str;
271+
// html render rollback
272+
// const cleanValue = DOMPurify.sanitize(str);
273+
// return <div dangerouslySetInnerHTML={{ __html: cleanValue }} />;
272274
}
273275

274276
function RenderLink(value, disabled = false) {

0 commit comments

Comments
 (0)