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

This commit is contained in:
Dmitry 2025-12-17 05:03:33 +03:00
parent 47cbd336d4
commit 1b055db238

View file

@ -21,66 +21,6 @@ interface CardEditorPreviewProps {
packColor?: string 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 // Helper to get image source
function getImageSrc(image?: string): string | undefined { function getImageSrc(image?: string): string | undefined {
if (!image) return undefined if (!image) return undefined