260728_04_ENH: 에디터에 커스텀 태그 인식하도록 수정

This commit is contained in:
2026-07-28 17:08:31 +09:00
parent ac672dfc77
commit cf6e9ec909
5 changed files with 31 additions and 12 deletions

View File

@@ -2,14 +2,14 @@
import DOMPurify from "dompurify";
const HTML_PROFILE = {
USE_PROFILES: {
html: true,
},
} as const;
export type SanitizeHtmlOptions = {
tags?: string[];
attributes?: string[];
};
export function sanitizeHtml(
input: string,
options?: SanitizeHtmlOptions,
): string {
if (!input) {
return "";
@@ -17,12 +17,19 @@ export function sanitizeHtml(
return DOMPurify.sanitize(
input,
HTML_PROFILE,
{
USE_PROFILES: {
html: true,
},
ADD_TAGS: options?.tags ?? [],
ADD_ATTR: options?.attributes ?? [],
},
);
}
export function sanitizeHtmlForPreview(
input: string,
options?: SanitizeHtmlOptions,
): string {
return sanitizeHtml(input);
return sanitizeHtml(input, options);
}