Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ export const getCellClassName = (

const columnHelper = createColumnHelper<AlertDto>();

/**
* Strips HTML tags from a string, returning plain text.
* Used to display note values (saved via a rich-text editor) as plain text
* in alert table columns.
*/
const stripHtml = (html: string): string => {
return html.replace(/<[^>]*>/g, " ").replace(/\s{2,}/g, " ").trim();
};

interface GenerateAlertTableColsArg {
additionalColsToGenerate?: string[];
isCheckboxDisplayed?: boolean;
Expand Down Expand Up @@ -344,6 +353,13 @@ export const useAlertTableCols = (
}

if (value) {
// Strip HTML tags from note values — notes are saved by a rich-text
// editor (Quill) which wraps content in HTML tags like <p>...</p>.
// Table columns should display plain text only.
const displayValue =
context.column.id === "note" && typeof value === "string"
? stripHtml(value)
: value.toString();
return (
<div
className={clsx(
Expand All @@ -353,7 +369,7 @@ export const useAlertTableCols = (
(rowStyle === "default" ? "line-clamp-1" : "line-clamp-3")
)}
>
{value.toString()}
{displayValue}
</div>
);
}
Expand Down
Loading