// src/utils/adfToPlainText.js export function adfToPlainText(node) { if (!node || typeof node !== 'object') return ''; let text = ''; // Text node if (node.type === 'text' && node.text) { text += node.text; if (node.marks && Array.isArray(node.marks)) { node.marks.forEach(mark => { if (mark.type === 'link' && mark.attrs?.href) { text += ` (${mark.attrs.href})`; } }); } } // Recurse into content if (node.content && Array.isArray(node.content)) { node.content.forEach((child, index) => { const childText = adfToPlainText(child); if (childText) { text += childText; if (['paragraph', 'heading', 'bulletList', 'orderedList', 'listItem'].includes(child.type)) { text += '\n\n'; } else if (index < node.content.length - 1) { text += ' '; } } }); } return text.trim(); }