From 7cfcbab53419719854d838dacb17f47537b6de37 Mon Sep 17 00:00:00 2001 From: Santiago Palenque Date: Mon, 19 Feb 2024 16:56:28 -0300 Subject: [PATCH] html to string in presentations report --- src/components/reports/smart-presentation-report.js | 8 +++++++- src/utils/methods.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/reports/smart-presentation-report.js b/src/components/reports/smart-presentation-report.js index 07685692d..349df68dd 100644 --- a/src/components/reports/smart-presentation-report.js +++ b/src/components/reports/smart-presentation-report.js @@ -18,7 +18,7 @@ import Select from 'react-select'; const Query = require('graphql-query-builder'); import wrapReport from './report-wrapper'; import {flattenData} from "../../actions/report-actions"; -import {parseAndFormat} from "../../utils/methods"; +import {htmlToString, parseAndFormat} from "../../utils/methods"; const fieldNames = [ @@ -139,6 +139,12 @@ class SmartPresentationReport extends React.Component { if (d.endDate) d.endDate = parseAndFormat(d.endDate, 'YYYY-MM-DDTHH:mm:ss+00:00', 'MM/DD/YYYY h:mma','UTC', currentSummit.time_zone_id); // bc legacy SilverStripe if (d.created) d.created = parseAndFormat(d.created, 'YYYY-MM-DDTHH:mm:ss+00:00', 'America/Chicago'); + + if (forExport) { + if (d.abstract) d.abstract = htmlToString(d.abstract); + if (d.socialSummary) d.socialSummary = htmlToString(d.socialSummary); + if (d.expectToLearn) d.expectToLearn = htmlToString(d.expectToLearn); + } }); let columns = [ diff --git a/src/utils/methods.js b/src/utils/methods.js index 7c53fb5ce..22f1726b1 100644 --- a/src/utils/methods.js +++ b/src/utils/methods.js @@ -357,4 +357,10 @@ export const joinCVSChunks = (chunks) => { }, ''); return `${header}\n${csv}`; +} + +export const htmlToString = (html) => { + return new DOMParser() + .parseFromString(html, "text/html") + .documentElement.textContent; } \ No newline at end of file