// Capture Plan Document Exporter - Complete React Component import React, { useState, useRef } from 'react'; import { FileText, Download, Copy, Eye, EyeOff, FileDown } from 'lucide-react'; const CaptureplanExporter = () => { const [content, setContent] = useState(''); const [showPreview, setShowPreview] = useState(true); const [isProcessing, setIsProcessing] = useState(false); const printRef = useRef(null); // Parse the content into structured sections const parseContent = (text) => { const lines = text.split('\n'); const sections = []; let currentSection = null; let currentSubsection = null; let currentContent = []; lines.forEach((line) => { const trimmedLine = line.trim(); // Main section headers (numbered) const mainSectionMatch = trimmedLine.match(/^(\d+)\.\s+(.+)$/); if (mainSectionMatch) { if (currentSection) { if (currentSubsection) { currentSubsection.content = currentContent.join('\n'); currentContent = []; currentSubsection = null; } else { currentSection.content = currentContent.join('\n'); currentContent = []; } } currentSection = { number: mainSectionMatch[1], title: mainSectionMatch[2], subsections: [], content: '' }; sections.push(currentSection); return; } // Subsection headers (letters) const subSectionMatch = trimmedLine.match(/^([A-Z])\.\s+(.+)$/); if (subSectionMatch && currentSection) { if (currentSubsection) { currentSubsection.content = currentContent.join('\n'); currentContent = []; } else if (currentContent.length > 0) { currentSection.content = currentContent.join('\n'); currentContent = []; } currentSubsection = { letter: subSectionMatch[1], title: subSectionMatch[2], content: '' }; currentSection.subsections.push(currentSubsection); return; } // Arrow items (β†’) if (trimmedLine.includes('β†’')) { currentContent.push(line); return; } // Regular content if (trimmedLine) { currentContent.push(line); } }); // Handle remaining content if (currentContent.length > 0) { if (currentSubsection) { currentSubsection.content = currentContent.join('\n'); } else if (currentSection) { currentSection.content = currentContent.join('\n'); } } return sections; }; const FormattedDocument = ({ sections }) => { return (

CAPTURE PLAN

{sections.map((section, index) => (
0 && index % 3 === 0 ? 'print-break' : ''}`}>

{section.number}. {section.title}

{section.content && (
{section.content.split('\n').map((line, i) => { if (line.includes('β†’')) { const [label, value] = line.split('β†’').map(s => s.trim()); return (
{label} β†’ {value}
); } return

{line}

; })}
)} {section.subsections.map((subsection, subIndex) => (

{subsection.letter}. {subsection.title}

{subsection.content.split('\n').map((line, i) => { if (line.includes('β†’')) { const [label, value] = line.split('β†’').map(s => s.trim()); return (
{label}: {value}
); } return

{line}

; })}
))}
))}

Generated on {new Date().toLocaleDateString()}

); }; const handlePrint = () => { window.print(); }; const handleExportHTML = () => { const element = printRef.current; if (!element) return; const htmlContent = ` Capture Plan

CAPTURE PLAN

${element.innerHTML} `; const blob = new Blob([htmlContent], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'capture-plan.html'; a.click(); URL.revokeObjectURL(url); }; const handleExportMarkdown = () => { const sections = parseContent(content); let markdown = '# CAPTURE PLAN\n\n'; markdown += `*Generated on ${new Date().toLocaleDateString()}*\n\n---\n\n`; sections.forEach(section => { markdown += `## ${section.number}. ${section.title}\n\n`; if (section.content) { section.content.split('\n').forEach(line => { if (line.includes('β†’')) { const [label, value] = line.split('β†’').map(s => s.trim()); markdown += `**${label}:** ${value}\n\n`; } else if (line.trim()) { markdown += `${line}\n\n`; } }); } section.subsections.forEach(subsection => { markdown += `### ${subsection.letter}. ${subsection.title}\n\n`; subsection.content.split('\n').forEach(line => { if (line.includes('β†’')) { const [label, value] = line.split('β†’').map(s => s.trim()); markdown += `**${label}:** ${value}\n\n`; } else if (line.trim()) { markdown += `${line}\n\n`; } }); }); }); const blob = new Blob([markdown], { type: 'text/markdown' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'capture-plan.md'; a.click(); URL.revokeObjectURL(url); }; const sections = parseContent(content); return (

Capture Plan Document Exporter