260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
import * as React from "react";
|
||||
import { toast } from "sonner";
|
||||
import { cn } from "@kri/common/ui";
|
||||
|
||||
import type { KriEditorProps } from "./types";
|
||||
import { cn } from "./utils/cn";
|
||||
import { compressImage } from "./utils/imageCompression";
|
||||
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
||||
import { sanitizeHtmlForPreview } from "./utils/sanitizeHtml";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { cn } from "./utils/cn"; // 기존 "@/lib/utils" 제거
|
||||
import { cn } from "@kri/common/ui";
|
||||
import type { KriEditorProps } from "./types";
|
||||
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
||||
import { useTextareaInsert } from "./hooks/useTextareaInsert";
|
||||
@@ -192,4 +192,4 @@ export function KriEditorSms(props: SmsEditorProps) {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,11 +18,11 @@ import TableHeader from "@tiptap/extension-table-header";
|
||||
import TableCell from "@tiptap/extension-table-cell";
|
||||
|
||||
import { toast } from "sonner";
|
||||
import { cn } from "@kri/common/ui";
|
||||
|
||||
import type { KriEditorProps, KriEditorMode, ToolbarState } from "./types";
|
||||
import { FontSize } from "./extensions/font-size";
|
||||
import { Div } from "./extensions/div";
|
||||
import { cn } from "./utils/cn";
|
||||
import { compressImage } from "./utils/imageCompression";
|
||||
import { sanitizeHtml } from "./utils/sanitizeHtml";
|
||||
import { Toolbar } from "./toolbar/Toolbar";
|
||||
|
||||
@@ -3,7 +3,8 @@ import { Extension } from "@tiptap/core";
|
||||
declare module "@tiptap/core" {
|
||||
interface Commands<ReturnType> {
|
||||
fontSize: {
|
||||
setFontSize: (fontSize: string | null) => ReturnType;
|
||||
setFontSize: (fontSize: string) => ReturnType;
|
||||
unsetFontSize: () => ReturnType;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -17,7 +18,7 @@ export const FontSize = Extension.create({
|
||||
attributes: {
|
||||
fontSize: {
|
||||
default: null as string | null,
|
||||
parseHTML: (element) => (element as HTMLElement).style.fontSize || null,
|
||||
parseHTML: (element) => (element).style.fontSize || null,
|
||||
renderHTML: (attributes) => {
|
||||
if (!attributes.fontSize) return {};
|
||||
return { style: `font-size:${attributes.fontSize}` };
|
||||
@@ -33,11 +34,13 @@ export const FontSize = Extension.create({
|
||||
setFontSize:
|
||||
(fontSize) =>
|
||||
({ chain }) => {
|
||||
if (!fontSize) {
|
||||
return chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run();
|
||||
}
|
||||
return chain().setMark("textStyle", { fontSize }).run();
|
||||
},
|
||||
unsetFontSize:
|
||||
() =>
|
||||
({ chain }) => {
|
||||
return chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run();
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { cn } from "../utils/cn";
|
||||
import { cn } from "@kri/common/ui";
|
||||
import {
|
||||
AlignCenter,
|
||||
AlignLeft,
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export function cn(...inputs: Array<string | undefined | null | false>) {
|
||||
return inputs.filter(Boolean).join(" ");
|
||||
}
|
||||
@@ -1,15 +1,28 @@
|
||||
export function sanitizeHtml(input: string): string {
|
||||
if (!input) return "";
|
||||
"use client";
|
||||
|
||||
let s = input.replace(/<\s*script[^>]*>[\s\S]*?<\s*\/\s*script\s*>/gi, "");
|
||||
s = s.replace(/<\s*style[^>]*>[\s\S]*?<\s*\/\s*style\s*>/gi, "");
|
||||
s = s.replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, "");
|
||||
s = s.replace(/\s(href|src)\s*=\s*("|')\s*javascript:[^"']*("|')/gi, ' $1="#"');
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
return s;
|
||||
const HTML_PROFILE = {
|
||||
USE_PROFILES: {
|
||||
html: true,
|
||||
},
|
||||
} as const;
|
||||
|
||||
export function sanitizeHtml(
|
||||
input: string,
|
||||
): string {
|
||||
if (!input) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return DOMPurify.sanitize(
|
||||
input,
|
||||
HTML_PROFILE,
|
||||
);
|
||||
}
|
||||
|
||||
// 기존 코드 호환용
|
||||
export function sanitizeHtmlForPreview(input: string): string {
|
||||
export function sanitizeHtmlForPreview(
|
||||
input: string,
|
||||
): string {
|
||||
return sanitizeHtml(input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user