mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
36 lines
806 B
TypeScript
36 lines
806 B
TypeScript
import React from 'react';
|
|
|
|
export type TemplateCustomMessageBodyProps = {
|
|
text?: string;
|
|
};
|
|
|
|
export const TemplateCustomMessageBody = ({ text }: TemplateCustomMessageBodyProps) => {
|
|
if (!text) {
|
|
return null;
|
|
}
|
|
|
|
const normalized = text
|
|
.trim()
|
|
.replace(/\r\n?/g, '\n')
|
|
.replace(/\n\s*\n+/g, '\n\n')
|
|
.replace(/\n{2,}/g, '\n\n');
|
|
|
|
const paragraphs = normalized.split('\n\n');
|
|
|
|
return paragraphs.map((paragraph, i) => (
|
|
<p
|
|
key={`p-${i}`}
|
|
className="whitespace-pre-line break-words font-sans text-base text-slate-400"
|
|
>
|
|
{paragraph.split('\n').map((line, j) => (
|
|
<React.Fragment key={`line-${i}-${j}`}>
|
|
{j > 0 && <br />}
|
|
{line}
|
|
</React.Fragment>
|
|
))}
|
|
</p>
|
|
));
|
|
};
|
|
|
|
export default TemplateCustomMessageBody;
|