@SuhasK Try writing something like <foo>test</foo>
in a field and notice the foo
tag is removed when you re-open the editor.
This appears to be the default behavior of the dompurify package. I tested with this change, which should fix the issue according to the docs, but it didn’t work for me:
diff --git a/ts/lib/domlib/sanitize.ts b/ts/lib/domlib/sanitize.ts
index d6ae4f049..9b3469292 100644
--- a/ts/lib/domlib/sanitize.ts
+++ b/ts/lib/domlib/sanitize.ts
@@ -6,5 +6,12 @@ import DOMPurify from "dompurify";
export function sanitize(html: string): string {
// We need to treat the text as a document fragment, or a style tag
// at the start of input will be discarded.
- return DOMPurify.sanitize(html, { FORCE_BODY: true });
+ return DOMPurify.sanitize(html, {
+ FORCE_BODY: true,
+ CUSTOM_ELEMENT_HANDLING: {
+ tagNameCheck: () => true,
+ attributeNameCheck: () => true,
+ allowCustomizedBuiltInElements: true,
+ },
+ });
}