260803_02_ENH: kri editor에서 preview에서도 줄바꿈 보여지게 수정

This commit is contained in:
2026-08-04 16:21:12 +09:00
parent 66ad2ac26e
commit 57b27eb50c
4 changed files with 28 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
const EMPTY_PARAGRAPH_PATTERN = /<p((?:\s+[^>]*)?)>\s*<\/p>/gi;
/**
* TipTap이 빈 줄을 <p></p>로 직렬화하면 이메일 클라이언트에서 margin collapse로 사라진다.
* 눈에 보이지 않는 콘텐츠(&nbsp;)를 채워 실제 발송 HTML에서도 빈 줄이 유지되게 한다.
*/
export function preserveEmptyParagraphs(html: string): string {
return html.replace(EMPTY_PARAGRAPH_PATTERN, (_match, attrs: string) => `<p${attrs}>&nbsp;</p>`);
}