bug where we lost the rtl direction on JSX Pashto text

This commit is contained in:
lingdocs 2021-06-24 12:51:52 +04:00
parent cdea37e024
commit 23b7b5d45a
3 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "0.4.5", "version": "0.4.6",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -27,19 +27,21 @@ const Pashto = ({ opts, children: text }: {
? p ? p
: convertAfToPkSpelling(p); : convertAfToPkSpelling(p);
} }
if (typeof text.p !== "string" && typeof text.f !== "string") {
return psJSXMap(
text as T.PsJSX,
"p",
(ps: T.PsString) => convertText(ps, opts),
);
}
const style = opts.pTextSize === "normal" const style = opts.pTextSize === "normal"
? undefined ? undefined
: { fontSize: opts.pTextSize === "larger" ? "large" : "larger" }; : { fontSize: opts.pTextSize === "larger" ? "large" : "larger" };
return ( return (
<span className="p-text" dir="rtl" style={style}> <span className="p-text" dir="rtl" style={style}>
{convertText(text as T.PsString, opts)} {(typeof text.p !== "string" && typeof text.f !== "string")
?
psJSXMap(
text as T.PsJSX,
"p",
(ps: T.PsString) => convertText(ps, opts),
)
:
convertText(text as T.PsString, opts)
}
</span> </span>
); );
}; };

View File

@ -28,12 +28,10 @@ const Phonetics = ({ opts, children: text }: {
system: opts.phonetics, system: opts.phonetics,
}) })
); );
if (typeof text !== "string" && typeof text.f !== "string") {
return psJSXMap(text as T.PsJSX, "f", ({f}) => handleText(f));
}
const f = typeof text === "string" ? text : text.f as string;
return <span className="f-text"> return <span className="f-text">
{handleText(f)} {(typeof text !== "string" && typeof text.f !== "string")
? psJSXMap(text as T.PsJSX, "f", ({f}) => handleText(f))
: handleText(typeof text === "string" ? text : text.f as string)}
</span> </span>
}; };