260728_04_ENH: 에디터에 커스텀 태그 인식하도록 수정
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user