@@ -23,6 +23,7 @@ import { ThemeProvider, createTheme } from '@mui/material/styles';
2323import Button from '@mui/material/Button' ;
2424import { extensionEnabled } from '../../utils/ReportUtils' ;
2525import { getCheckboxes , hasCheckboxes , updateCheckBoxes } from './TableActionsHelper' ;
26+ import DOMPurify from 'dompurify' ;
2627
2728const TABLE_HEADER_HEIGHT = 32 ;
2829const TABLE_FOOTER_HEIGHT = 62 ;
@@ -38,6 +39,15 @@ const fallbackRenderer = (value) => {
3839 return JSON . stringify ( value ) ;
3940} ;
4041
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+ }
50+
4151function renderAsButtonWrapper ( renderer ) {
4252 return function renderAsButton ( value ) {
4353 const outputValue = renderer ( value , true ) ;
@@ -50,7 +60,7 @@ function renderAsButtonWrapper(renderer) {
5060 style = { { width : '100%' , marginLeft : '5px' , marginRight : '5px' } }
5161 variant = 'contained'
5262 color = 'primary'
53- > { `${ outputValue } ` } </ Button >
63+ > { `${ htmlToPlainText ( outputValue ) } ` } </ Button >
5464 ) ;
5565 } ;
5666}
0 commit comments