Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
fix(table): fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Conglei Shi committed Nov 13, 2019
1 parent 0cc202d commit 403dbf8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/superset-ui-plugin-chart-table/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ColumnMetadata,
GenericRow,
} from '@airbnb/lunar/lib/components/DataTable/types';
import dompurify from 'dompurify';
import { createSelector } from 'reselect';
import { TimeFormatter } from '@superset-ui/time-format';
import { NumberFormatter } from '@superset-ui/number-format';
Expand Down Expand Up @@ -50,6 +49,8 @@ const CELL_PADDING = 32;

const MAX_COLUMN_WIDTH = 300;

const htmlTagRegex = /(<([^>]+)>)/gi;

export type TableProps = Props & Readonly<typeof defaultProps>;

type InternalTableProps = TableProps & WithStylesProps;
Expand All @@ -68,19 +69,14 @@ function getCellHash(cell: Cell) {
}

function getText(value: unknown, format: TimeFormatter | NumberFormatter | undefined) {
let formattedValue = value;
if (format) {
formattedValue = format.format(value as any);
return format.format(value as any);
}
if (typeof value === 'string') {
const span = document.createElement('span');
const sanitizedString = dompurify.sanitize(formattedValue as string);
span.innerHTML = sanitizedString;

return String(span.textContent || span.innerText);
return value.replace(htmlTagRegex, '');
}

return String(formattedValue);
return String(value);
}

type columnWidthMetaDataType = {
Expand Down

0 comments on commit 403dbf8

Please sign in to comment.