- implemneted API for notifications;
- added styles for notifications; - added email template to amendment page;
This commit is contained in:
28
src/helpers/getStrippedHtmlBodyTags.js
Normal file
28
src/helpers/getStrippedHtmlBodyTags.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import parse from 'html-react-parser';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
const getEmailTemplateForSoccorso = (content = '', fallback = '') => {
|
||||
const config = {
|
||||
FORBID_TAGS: ['html', 'body'],
|
||||
WHOLE_DOCUMENT: false,
|
||||
RETURN_DOM: false,
|
||||
RETURN_DOM_FRAGMENT: false,
|
||||
RETURN_DOM_IMPORT: false,
|
||||
FORCE_BODY: false,
|
||||
ADD_TAGS: ['*'],
|
||||
ADD_ATTR: ['*']
|
||||
};
|
||||
try {
|
||||
const wrappedHtml = `<div>${content}</div>`;
|
||||
const cleaned = DOMPurify.sanitize(wrappedHtml, config);
|
||||
|
||||
const tempDiv = document.createElement('div');
|
||||
tempDiv.innerHTML = cleaned;
|
||||
return parse(tempDiv.innerHTML);
|
||||
} catch (error) {
|
||||
console.error('DOMPurify cleaning error:', error);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export default getEmailTemplateForSoccorso;
|
||||
Reference in New Issue
Block a user