feat: replace rich text editor with custom Tiptap implementation and add HTML formatting utilities

This commit is contained in:
2026-06-05 19:25:51 +07:00 Unverified
parent 658e683c96
commit cb288588d8
7 changed files with 69 additions and 46 deletions
+36
View File
@@ -0,0 +1,36 @@
import React from "react";
export function FormattedText({ text }: { text: string }) {
const lines = text.split('\n');
const urlRegex = /(https?:\/\/[^\s]+)/g;
return (
<>
{lines.map((line, i) => {
const parts = line.split(urlRegex);
return (
<React.Fragment key={i}>
{i > 0 && <br />}
{parts.map((part, j) => {
if (part.match(urlRegex)) {
return (
<a
key={j}
href={part}
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline underline-offset-4"
onClick={(e) => e.stopPropagation()}
>
{part}
</a>
);
}
return part;
})}
</React.Fragment>
);
})}
</>
);
}