fix: button preservation when loading card for editing - add TipTap data attrs to parseMarkdownBasics
This commit is contained in:
@@ -151,15 +151,20 @@ export function parseMarkdownBasics(text: string): string {
|
||||
|
||||
// Parse [button:style](url)Text[/button] (new syntax) - must come before images
|
||||
// Allow whitespace and newlines between parts
|
||||
// Include data-button attributes for TipTap recognition
|
||||
html = html.replace(/\[button:(\w+)\]\(([^)]+)\)([\s\S]*?)\[\/button\]/g, (match, style, url, text) => {
|
||||
const buttonClass = style === 'outline' ? 'button-outline' : 'button';
|
||||
return `<p style="text-align: center;"><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`;
|
||||
const trimmedText = text.trim();
|
||||
return `<a href="${url}" class="${buttonClass}" data-button="" data-text="${trimmedText}" data-href="${url}" data-style="${style}">${trimmedText}</a>`;
|
||||
});
|
||||
|
||||
// Parse [button url="..."] shortcodes (old syntax - backward compatibility)
|
||||
// Include data-button attributes for TipTap recognition
|
||||
html = html.replace(/\[button\s+url="([^"]+)"(?:\s+style="([^"]+)")?\]([^\[]+)\[\/button\]/g, (match, url, style, text) => {
|
||||
const buttonClass = style === 'outline' ? 'button-outline' : 'button';
|
||||
return `<p style="text-align: center;"><a href="${url}" class="${buttonClass}">${text.trim()}</a></p>`;
|
||||
const buttonStyle = style || 'solid';
|
||||
const buttonClass = buttonStyle === 'outline' ? 'button-outline' : 'button';
|
||||
const trimmedText = text.trim();
|
||||
return `<a href="${url}" class="${buttonClass}" data-button="" data-text="${trimmedText}" data-href="${url}" data-style="${buttonStyle}">${trimmedText}</a>`;
|
||||
});
|
||||
|
||||
// Images (must come before links)
|
||||
|
||||
Reference in New Issue
Block a user