mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-09 15:07:10 +02:00
feat: fix rtl
This commit is contained in:
@@ -12,24 +12,23 @@ function hasRTLCharacters(text: string): boolean {
|
||||
|
||||
export function Text({ node }: TextNodeProps) {
|
||||
const text = node.value;
|
||||
|
||||
|
||||
// If no newlines, render as inline span
|
||||
if (!text.includes("\n")) {
|
||||
const isRTL = hasRTLCharacters(text);
|
||||
return <span dir={isRTL ? "rtl" : "auto"}>{text || "\u00A0"}</span>;
|
||||
}
|
||||
|
||||
// If has newlines, use spans with <br> tags
|
||||
|
||||
// If has newlines, use divs for proper RTL per line
|
||||
const lines = text.split("\n");
|
||||
return (
|
||||
<>
|
||||
{lines.map((line, idx) => {
|
||||
const isRTL = hasRTLCharacters(line);
|
||||
return (
|
||||
<span key={idx}>
|
||||
<span dir={isRTL ? "rtl" : "auto"}>{line || "\u00A0"}</span>
|
||||
{idx < lines.length - 1 && <br />}
|
||||
</span>
|
||||
<div key={idx} dir={isRTL ? "rtl" : "auto"}>
|
||||
{line || "\u00A0"}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user