1

Does the current version of the Angular-Slickgrid support the DomSanitization? If yes please help me to do it.

Requirement: From the API call I get the rich text as data, which has HTML elements in it. I need to display the rich text into the grid as is to have the formatting (e.g. bold, underline).

Here is the sample data that comes from the API:

name: \<strong>\<underline>John K Paul\</underline>\</strong>

Here is a similar ask from another person. How can I resolve "safeHtml pipe not working" in Angular 8

Kit
  • 20,354
  • 4
  • 60
  • 103

1 Answers1

0

I had already replied to the same question you asked in GitHub Discussion, below is the same answer to your question.

Angular-Slickgrid (Slickgrid-Universal) uses DOMPurify internally, that is what you should use in a Custom Formatter, for example you can see it implemented in this TreeFormatter for example.

import * as DOMPurify_ from 'dompurify';
const DOMPurify = DOMPurify_; // patch to fix rollup to work
// ...
const sanitizedOutputValue = DOMPurify.sanitize(outputValue);
return sanitizedOutputValue;

It is recommended to use Custom Formatter instead of Angular Pipe (which would require asyncPostRenderer and are much slower (hence why it's not recommended, better stick with Custom Formatter).

ghiscoding
  • 12,308
  • 6
  • 69
  • 112