diff --git a/jsx/DataTable.d.ts b/jsx/DataTable.d.ts index 53caa9c563..cd82715775 100644 --- a/jsx/DataTable.d.ts +++ b/jsx/DataTable.d.ts @@ -5,7 +5,7 @@ type TableRow = (string|null)[] type Field = { show: boolean - label: string + label: string | ReactNode } type hideOptions = { diff --git a/modules/dataquery/jsx/getdictionarydescription.tsx b/modules/dataquery/jsx/getdictionarydescription.tsx index c403f27721..7c97ae3979 100644 --- a/modules/dataquery/jsx/getdictionarydescription.tsx +++ b/modules/dataquery/jsx/getdictionarydescription.tsx @@ -1,5 +1,17 @@ import {FullDictionary} from './types'; +/** + * Parses string to remove HTML tags and return raw text + * + * @param {string} html - input string + * @returns {string} - parsed string + */ +function stripHTML(html: string): string { + if (!html) return ''; + const doc = new DOMParser().parseFromString(html, 'text/html'); + return doc.body.textContent || html.replace(/<\/?[a-zA-Z][^>]*>?/gm, ''); +} + /** * Get the dictionary for a given term * @@ -23,7 +35,8 @@ function getDictionaryDescription( return fieldname; } - return dict[module][category][fieldname].description; + const desc = dict[module][category][fieldname].description; + return stripHTML(desc); } export default getDictionaryDescription; diff --git a/modules/dataquery/jsx/viewdata.tsx b/modules/dataquery/jsx/viewdata.tsx index ac1d1ba856..9858a53d12 100644 --- a/modules/dataquery/jsx/viewdata.tsx +++ b/modules/dataquery/jsx/viewdata.tsx @@ -384,7 +384,10 @@ function ViewData(props: { rowNumLabel={t('Row Number')} fields={organizedData.headers.map( (val: string) => { - return {show: true, label: val}; + return { + show: true, + label:
{val}
, + }; }) } data={organizedData.data} @@ -436,7 +439,21 @@ function ViewData(props: { } /> :
); - return
+ return
+