A standalone React application that runs entirely in the browser with no backend dependencies. All markdown processing, rendering, and file exports happen client-side for maximum privacy and performance.
- React 18.3.1: UI framework with hooks and concurrent features
- TypeScript 5.2.2: Type safety and enhanced developer experience
- Vite 5.0.10: Lightning-fast build tool and dev server
- Tailwind CSS v4.0.0-beta.4: Utility-first CSS with dark mode support
- Lucide React 0.462.0: Modern, tree-shakeable icon library
- React Resizable Panels 2.1.7: Flexible split-pane implementation
- Marked.js 14.1.2: Fast markdown parser with GFM support
- Highlight.js 11.10.0: Syntax highlighting for 180+ languages
- KaTeX 0.16.11: High-quality math equation rendering
- DOMPurify 3.2.2: XSS sanitization for safe HTML rendering
- jsPDF 2.5.2: Client-side PDF generation
- html2canvas 1.4.1: HTML to canvas conversion for PDF
- docx 9.0.2: Microsoft Word document generation
- file-saver 2.0.5: Cross-browser file downloading
- Zustand 5.0.2: Lightweight state management with persistence
- Local Storage: Auto-save and preference persistence
- ESLint: Code quality enforcement
- Prettier: Consistent code formatting
- TypeScript: Compile-time type checking
markdown-editor/
├── src/
│ ├── components/
│ │ ├── modals/ # Centralized modal components
│ │ │ ├── CopyModal.tsx
│ │ │ ├── ExportModal.tsx
│ │ │ └── Modal.tsx
│ │ ├── CommandPalette/
│ │ │ └── CommandPalette.tsx
│ │ ├── Editor/
│ │ │ └── MarkdownEditor.tsx
│ │ ├── Help/
│ │ │ └── HelpDocumentation.tsx
│ │ ├── Layout/
│ │ │ ├── AppLayout.tsx
│ │ │ └── Header.tsx
│ │ └── Preview/
│ │ └── MarkdownPreview.tsx
│ ├── hooks/
│ │ ├── useKeyboardShortcuts.ts
│ │ └── useSyncScroll.ts
│ ├── lib/
│ │ └── export/
│ │ ├── exportDocx.ts
│ │ ├── exportMarkdown.ts
│ │ └── exportPDF.ts
│ ├── stores/
│ │ ├── editorStore.ts
│ │ ├── modalStore.ts
│ │ └── themeStore.ts
│ ├── types/
│ │ └── index.ts
│ ├── utils/
│ │ └── copyUtils.ts
│ ├── App.tsx
│ ├── index.css
│ └── main.tsx
├── docs/ # Comprehensive documentation
├── tests/
│ └── plans/ # Test plans and QA documentation
├── public/
├── package.json
├── tsconfig.json
├── vite.config.ts
├── tailwind.config.js
└── README.md
The editor uses a native <textarea> element enhanced with:
- Real-time Updates: Immediate state synchronization
- Auto-save: Debounced persistence to localStorage
- Keyboard Shortcuts: Bold (Ctrl+B), Italic (Ctrl+I), Link (Ctrl+L)
- Focus Management: Proper focus handling for shortcuts
- Resizable: Via react-resizable-panels
interface EditorState {
content: string
lastSaved: Date | null
isAutoSaveEnabled: boolean
setContent: (content: string) => void
setLastSaved: (date: Date) => void
toggleAutoSave: () => void
}Real-time markdown rendering with:
- Marked.js Pipeline: Markdown → HTML with custom renderer
- Syntax Highlighting: Highlight.js integration
- Math Support: KaTeX for LaTeX equations
- Safe Rendering: DOMPurify sanitization
- Synchronized Scrolling: Bidirectional sync with editor
Features supported:
- GitHub Flavored Markdown
- Tables with styling
- Task lists
- Code blocks with language detection
- Blockquotes
- Nested lists
- LaTeX math expressions
// Implementation approach:
- Create temporary container with print-optimized styles
- Render markdown to HTML with syntax highlighting
- Use html2canvas to capture rendered content
- Generate PDF with jsPDF
- Handle pagination for long documents
- Clean up temporary elements// Implementation approach:
- Parse markdown using marked.lexer
- Convert tokens to Word document structure
- Apply appropriate styles for each element
- Support tables, lists, code blocks, and formatting
- Generate binary DOCX file
- Trigger download via file-saverThree copy formats with modern Clipboard API:
// Markdown: Raw markdown text
await navigator.clipboard.writeText(markdown)
// HTML: Rich text for document pasting
await navigator.clipboard.write([
new ClipboardItem({ 'text/html': htmlBlob })
])
// Plain Text: Formatted with preserved structure
const formattedText = getPlainTextWithFormatting(element)
await navigator.clipboard.writeText(formattedText)// Editor Store (Persistent)
interface EditorStore {
content: string
lastSaved: Date | null
isAutoSaveEnabled: boolean
// ... methods
}
// Modal Store (Session)
interface ModalStore {
isExportOpen: boolean
isCopyOpen: boolean
isHelpOpen: boolean
isCommandPaletteOpen: boolean
// ... methods
}
// Theme Store (Persistent)
interface ThemeStore {
isDarkMode: boolean
toggleDarkMode: () => void
}Context-aware shortcuts with:
- Global Shortcuts: Work everywhere (Save, Export, etc.)
- Editor Shortcuts: Only when editor is focused
- Conflict Resolution: Proper handling of browser shortcuts
- Command Palette: Searchable interface for all commands
- Debounced Preview: 300ms delay for smooth typing
- Memoized Components: React.memo for expensive renders
- Lazy Modal Loading: Modals render only when opened
- Efficient Scroll Sync: RAF-based synchronization
- Optimized Builds: Tree-shaking and minification
- Client-side Only: No data leaves the browser
- XSS Prevention: DOMPurify sanitization
- Content Security: No external resource loading
- Safe Export: Generated files contain no active content
- Local Storage: Data stored only in user's browser
Tested and supported:
- Chrome/Edge 90+ ✓
- Firefox 88+ ✓
- Safari 14+ ✓
- Opera 76+ ✓
- Mobile browsers (limited functionality)
git clone <repository>
cd markdown-editor
npm install
npm run dev{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit",
"clean": "rm -rf dist node_modules"
}
}- Dist Size: ~3.5MB (includes all libraries)
- Initial Load: <2s on 3G
- Static Files: Ready for CDN deployment
- No Server Required: Pure client-side application
The built application is a collection of static files that can be hosted anywhere:
- GitHub Pages: Free hosting for public repos
- Netlify/Vercel: Automatic deployments from Git
- AWS S3 + CloudFront: Scalable CDN distribution
- Nginx/Apache: Traditional web server hosting
- Docker: Container with nginx for consistent deployment
Based on the original specification, potential additions:
- File Upload: Drag-and-drop markdown file import
- URL Import: Fetch markdown from remote URLs
- Mermaid Diagrams: Flowchart and diagram support
- Custom Themes: User-defined preview themes
- Plugin System: Extensible markdown processing
- Mobile App: React Native implementation
- PWA Features: Offline support and installation