chore: refactor cursor blink, debugging

This commit is contained in:
Danny Avila 2023-03-15 16:38:01 -04:00
parent 84b104e65f
commit 8c6340aed0
3 changed files with 121 additions and 78 deletions

View file

@ -46,8 +46,9 @@ const inLineWrap = (parts) => {
});
};
export default function TextWrapper({ text }) {
export default function TextWrapper({ text, generateCursor }) {
let embedTest = false;
let result = null;
// to match unenclosed code blocks
if (text.match(/```/g)?.length === 1) {
@ -137,13 +138,23 @@ export default function TextWrapper({ text }) {
}
});
return <>{codeParts}</>; // return the wrapped text
// return <>{codeParts}</>; // return the wrapped text
result = <>{codeParts}</>;
} else if (text.match(markupRegex)) {
// map over the parts and wrap any text between tildes with <code> tags
const parts = text.split(markupRegex);
const codeParts = inLineWrap(parts);
return <Markdown options={mdOptions}>{codeParts}</Markdown>; // return the wrapped text
// return <>{codeParts}</>; // return the wrapped text
result = <>{codeParts}</>;
} else {
return <Markdown options={mdOptions}>{text}</Markdown>;
// return <Markdown options={mdOptions}>{text}</Markdown>;
result = <Markdown options={mdOptions}>{text}</Markdown>;
}
return (
<>
{result}
{(<>{generateCursor()}</>)}
</>
);
}