stuff
Some checks are pending
Deploy Admin Panel / Deploy Admin Panel (push) Waiting to run
Deploy Admin Panel / Admin Panel Verification (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Deploy Admin Panel / Deploy Admin Panel (push) Waiting to run
Deploy Admin Panel / Admin Panel Verification (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
47cbd336d4
commit
1b055db238
1 changed files with 0 additions and 60 deletions
|
|
@ -21,66 +21,6 @@ interface CardEditorPreviewProps {
|
|||
packColor?: string
|
||||
}
|
||||
|
||||
// Helper function to format text with mnemo syntax (similar to Flutter's MnemoText)
|
||||
function formatMnemoText(text: string | null | undefined): React.ReactNode {
|
||||
if (!text) return null
|
||||
|
||||
// Replace \n with actual line breaks
|
||||
const formattedText = text.replaceAll('\\n', '\n')
|
||||
|
||||
// Find all matches of text in curly braces
|
||||
const matches = Array.from(formattedText.matchAll(/\{(.*?)\}/g))
|
||||
|
||||
if (matches.length === 0) {
|
||||
return <span>{formattedText}</span>
|
||||
}
|
||||
|
||||
const elements: React.ReactNode[] = []
|
||||
let lastIndex = 0
|
||||
|
||||
matches.forEach((match) => {
|
||||
// Add text before the match
|
||||
if (match.index !== undefined && match.index > lastIndex) {
|
||||
elements.push(
|
||||
<span key={`text-${lastIndex}`}>
|
||||
{formattedText.substring(lastIndex, match.index)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// Extract text inside braces
|
||||
let mnemoText = match[1]
|
||||
|
||||
// Check if text starts with color code #RRGGBB
|
||||
let color = '#ef4444' // Default red color (mnemoRed)
|
||||
if (mnemoText.startsWith('#') && mnemoText.length > 7) {
|
||||
const colorCode = mnemoText.substring(0, 7)
|
||||
color = colorCode
|
||||
mnemoText = mnemoText.substring(7)
|
||||
}
|
||||
|
||||
// Add highlighted text
|
||||
elements.push(
|
||||
<span key={`mnemo-${match.index}`} style={{ color }}>
|
||||
{mnemoText}
|
||||
</span>
|
||||
)
|
||||
|
||||
lastIndex = match.index! + match[0].length
|
||||
})
|
||||
|
||||
// Add remaining text
|
||||
if (lastIndex < formattedText.length) {
|
||||
elements.push(
|
||||
<span key={`text-${lastIndex}`}>
|
||||
{formattedText.substring(lastIndex)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
return <>{elements}</>
|
||||
}
|
||||
|
||||
// Helper to get image source
|
||||
function getImageSrc(image?: string): string | undefined {
|
||||
if (!image) return undefined
|
||||
|
|
|
|||
Loading…
Reference in a new issue