260908_01_ENH: 이메일 템플릿에서 <area>, <map> 태그 사용 시 반투명 영역으로 가시화

This commit is contained in:
2026-09-08 07:47:32 +09:00
parent 0fbec01f73
commit 7bfb1ca987
5 changed files with 188 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ import { applyLinkPreviewClass, KRI_EDITOR_LINK_CLASS } from "./utils/linkPrevie
import { Toolbar } from "./toolbar/Toolbar";
import { useDebouncedChange } from "./hooks/useDebouncedChange";
import { useTextareaInsert } from "./hooks/useTextareaInsert";
import { useImageMapOverlay } from "./hooks/useImageMapOverlay";
type ViewMode = "wysiwyg" | "html";
@@ -114,6 +115,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
const { scheduleChange, flushChange, optimisticHtmlRef } = useDebouncedChange(onChange, debounceMs);
const fileRef = useRef<HTMLInputElement | null>(null);
const previewContainerRef = useRef<HTMLDivElement | null>(null);
const htmlTextareaRef = useRef<HTMLTextAreaElement | null>(null);
const htmlTi = useTextareaInsert(htmlTextareaRef);
const { insertText: insertTextareaText } = htmlTi;
@@ -653,6 +655,8 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
}, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
const imageMapOverlayBoxes = useImageMapOverlay(previewContainerRef, previewHtml);
const wysiwygCompatibility = useMemo(
() => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)),
[editor, getCompatibility, previewSource, view],
@@ -736,8 +740,19 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
{showPreview && (
<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 ref={previewContainerRef} className="relative rounded-md border bg-muted/30 p-3">
<div dangerouslySetInnerHTML={{ __html: previewHtml }} />
{imageMapOverlayBoxes.length > 0 && (
<div className="pointer-events-none absolute inset-0" aria-hidden="true">
{imageMapOverlayBoxes.map((box) => (
<div
key={box.key}
className="absolute border-2 border-sky-500 bg-sky-500/30"
style={box.style}
/>
))}
</div>
)}
</div>
</div>
)}