260803_01_ENH: 에디터에 QR 코드 삽입 추가
This commit is contained in:
@@ -26,6 +26,7 @@ import { FontSize } from "./extensions/font-size";
|
||||
import { Div } from "./extensions/div";
|
||||
import { compressImage } from "./utils/imageCompression";
|
||||
import { sanitizeHtml } from "./utils/sanitizeHtml";
|
||||
import { applyLinkPreviewClass, KRI_EDITOR_LINK_CLASS } from "./utils/linkPreview";
|
||||
import { Toolbar } from "./toolbar/Toolbar";
|
||||
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
||||
import { useTextareaInsert } from "./hooks/useTextareaInsert";
|
||||
@@ -87,6 +88,9 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
allowBase64 = false,
|
||||
sanitizeHtml: sanitizeHtmlOpt = true,
|
||||
toolbar = {},
|
||||
editorExtensions = [],
|
||||
allowedCustomHtml,
|
||||
transformPreviewHtml,
|
||||
} = props;
|
||||
|
||||
const showHtmlToggle = mode === "both";
|
||||
@@ -154,7 +158,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
openOnClick: false,
|
||||
linkOnPaste: true,
|
||||
HTMLAttributes: {
|
||||
class: "cursor-pointer text-blue-600 underline underline-offset-2",
|
||||
class: KRI_EDITOR_LINK_CLASS,
|
||||
...LINK_HTML_ATTRS,
|
||||
},
|
||||
}),
|
||||
@@ -179,6 +183,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
},
|
||||
}),
|
||||
Placeholder.configure({ placeholder }),
|
||||
...editorExtensions,
|
||||
],
|
||||
|
||||
content: value || "<p></p>",
|
||||
@@ -436,12 +441,12 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
}
|
||||
|
||||
const raw = htmlDraftRef.current;
|
||||
const safe = sanitizeHtmlOpt ? sanitizeHtml(raw) : raw;
|
||||
const safe = sanitizeHtmlOpt ? sanitizeHtml(raw, allowedCustomHtml) : raw;
|
||||
|
||||
editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } });
|
||||
flushChange(editor.getHTML());
|
||||
setView("wysiwyg");
|
||||
}, [editor, flushChange, sanitizeHtmlOpt]);
|
||||
}, [allowedCustomHtml, editor, flushChange, sanitizeHtmlOpt]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
@@ -558,8 +563,10 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
}, [command, editor, props.onCommandReady]);
|
||||
|
||||
const previewHtml = useMemo(() => {
|
||||
return sanitizeHtmlOpt ? sanitizeHtml(previewSource) : previewSource;
|
||||
}, [previewSource, sanitizeHtmlOpt]);
|
||||
const sanitized = sanitizeHtmlOpt ? sanitizeHtml(previewSource, allowedCustomHtml) : previewSource;
|
||||
const withLinkStyle = applyLinkPreviewClass(sanitized);
|
||||
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
|
||||
}, [allowedCustomHtml, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
|
||||
|
||||
if (!editor) {
|
||||
return (
|
||||
@@ -630,7 +637,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
<div className={cn("border-t p-3", previewClassName)}>
|
||||
<div className="mb-2 text-sm font-semibold">미리보기</div>
|
||||
<div className="rounded-md border bg-muted/30 p-3">
|
||||
<div dangerouslySetInnerHTML={{ __html: previewHtml }} />
|
||||
<div className="kri-editor-preview" dangerouslySetInnerHTML={{ __html: previewHtml }} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user