fix formatting and lint errors

This commit is contained in:
Amruth Pillai
2025-01-30 17:57:14 +01:00
parent b21f1648c4
commit 92995d9c2b
5 changed files with 263 additions and 199 deletions

View File

@ -58,20 +58,83 @@ export const parseLayoutLocator = (payload: SortablePayload | null): LayoutLocat
};
export const sanitize = (html: string, options?: sanitizeHtml.IOptions) => {
const allowedTags = (options?.allowedTags ?? []) as string[];
return sanitizeHtml(html, {
...options,
allowedTags: [
...(options?.allowedTags ?? []),
// default tags (https://www.npmjs.com/package/sanitize-html#default-options)
"address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4",
"h5", "h6", "hgroup", "main", "nav", "section", "blockquote", "dd", "div",
"dl", "dt", "figcaption", "figure", "hr", "li", "main", "ol", "p", "pre",
"ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn",
"em", "i", "kbd", "mark", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp",
"small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "caption",
"col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr",
// images
...allowedTags,
"a",
"abbr",
"address",
"article",
"aside",
"b",
"bdi",
"bdo",
"blockquote",
"br",
"caption",
"cite",
"code",
"col",
"colgroup",
"data",
"dd",
"dfn",
"div",
"dl",
"dt",
"em",
"figcaption",
"figure",
"footer",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hgroup",
"hr",
"i",
"img",
"kbd",
"li",
"main",
"main",
"mark",
"nav",
"ol",
"p",
"pre",
"q",
"rb",
"rp",
"rt",
"rtc",
"ruby",
"s",
"samp",
"section",
"small",
"span",
"strong",
"sub",
"sup",
"table",
"tbody",
"td",
"tfoot",
"th",
"thead",
"time",
"tr",
"u",
"ul",
"var",
"wbr",
],
allowedAttributes: {
...options?.allowedAttributes,