-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathupdate.js
More file actions
19 lines (18 loc) · 778 Bytes
/
update.js
File metadata and controls
19 lines (18 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import Box from '@elementor/ui/Box';
import Typography from '@elementor/ui/Typography';
import { useMemo } from 'react';
export default function Update( { title, description } ) {
const descriptionToShow = useMemo( () => {
const parser = new DOMParser();
const doc = parser.parseFromString( description, 'text/html' );
const listItems = doc.querySelectorAll( 'li' );
const extractedContent = Array.from( listItems ).map( ( item ) => item.textContent.trim() );
return extractedContent.join( '\n' );
}, [ description ] );
return (
<Box sx={ { py: 2, px: 3 } }>
<Typography variant={ 'subtitle1' } sx={ { pb: 0.75 } }>{ title }</Typography>
<Typography variant={ 'body2' } sx={ { whiteSpace: 'pre-line' } }>{ descriptionToShow }</Typography>
</Box>
);
}