fix: remove hardcoded center alignment from button preview

parseCardsForPreview was forcing text-align: center on all buttons
regardless of user alignment choice. Removed the hardcoded style
so buttons follow natural document flow alignment.
This commit is contained in:
Dwindi Ramadhana
2026-01-01 23:49:33 +07:00
parent 1ce99e2bb6
commit 8959af8270

View File

@@ -98,13 +98,13 @@ export function markdownToHtml(markdown: string): string {
// Parse [button:style](url)Text[/button] (new syntax) // Parse [button:style](url)Text[/button] (new syntax)
html = html.replace(/\[button:(\w+)\]\(([^)]+)\)([^\[]+)\[\/button\]/g, (match, style, url, text) => { html = html.replace(/\[button:(\w+)\]\(([^)]+)\)([^\[]+)\[\/button\]/g, (match, style, url, text) => {
const buttonClass = style === 'outline' ? 'button-outline' : 'button'; const buttonClass = style === 'outline' ? 'button-outline' : 'button';
return `<p style="text-align: center;"><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`; return `<p><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`;
}); });
// Parse [button url="..."] shortcodes (old syntax - backward compatibility) // Parse [button url="..."] shortcodes (old syntax - backward compatibility)
html = html.replace(/\[button\s+url="([^"]+)"(?:\s+style="([^"]+)")?\]([^\[]+)\[\/button\]/g, (match, url, style, text) => { html = html.replace(/\[button\s+url="([^"]+)"(?:\s+style="([^"]+)")?\]([^\[]+)\[\/button\]/g, (match, url, style, text) => {
const buttonClass = style === 'outline' ? 'button-outline' : 'button'; const buttonClass = style === 'outline' ? 'button-outline' : 'button';
return `<p style="text-align: center;"><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`; return `<p><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`;
}); });
// Parse remaining markdown // Parse remaining markdown