sanitizeSvg
Sanitizes an SVG string by removing dangerous elements, attributes, and URIs while preserving safe content including foreignObject (for text rendering), style elements (for fonts with data: URLs), and animation elements. Embedded SVG data URIs on <image>/<feImage> are recursively sanitized.
Returns the sanitized SVG string, or an empty string if the input was malformed (parse error) or contained no safe content after sanitization.
function sanitizeSvg(svgText: string): stringParameters
| Name | Description |
|---|---|
| |
Returns
stringPrev
renderRichTextFromHTMLNext
serializeTldrawJson