- Getting Started
- Development Environment
- Project Structure
- Development Workflow
- Code Style
- Testing
- Building
- Debugging
- Contributing
- Node.js: Version 18.0.0 or higher
- npm: Version 9.0.0 or higher
- Git: For version control
- VS Code (recommended): With recommended extensions
-
Clone the repository
git clone https://github.com/yourusername/markdown-editor.git cd markdown-editor -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open in browser Navigate to
http://localhost:5173
Recommended extensions for the best development experience:
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss",
"csstools.postcss",
"yoavbls.pretty-ts-errors",
"streetsidesoftware.code-spell-checker"
]
}Create a .env.local file for local development:
# Example environment variables (currently none required)
# VITE_API_URL=http://localhost:3000Useful browser extensions:
- React Developer Tools: Debug React components
- Redux DevTools: Monitor Zustand stores
- Lighthouse: Performance auditing
markdown-editor/
├── src/
│ ├── components/ # React components
│ │ ├── modals/ # Modal components
│ │ ├── CommandPalette/ # Command palette
│ │ ├── Editor/ # Editor components
│ │ ├── Help/ # Help documentation
│ │ ├── Layout/ # Layout components
│ │ └── Preview/ # Preview components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Library code
│ │ └── export/ # Export utilities
│ ├── stores/ # Zustand stores
│ ├── types/ # TypeScript types
│ ├── utils/ # Utility functions
│ ├── App.tsx # Root component
│ ├── main.tsx # Application entry
│ └── index.css # Global styles
├── public/ # Static assets
├── docs/ # Documentation
│ └── adr/ # Architecture decisions
├── tests/ # Test files
│ └── plans/ # Test plans
└── [config files] # Configuration
src/App.tsx- Main application component with layoutsrc/stores/editorStore.ts- Editor state managementsrc/components/Editor/MarkdownEditor.tsx- Main editorsrc/components/Preview/MarkdownPreview.tsx- Preview panesrc/hooks/useKeyboardShortcuts.ts- Keyboard handling
# Create a feature branch
git checkout -b feature/your-feature-name
# Make changes and test
npm run dev
# Run type checking
npm run typecheck
# Commit changes
git add .
git commit -m "feat: add your feature"
# Push to remote
git push origin feature/your-feature-nameWhen creating new components:
// src/components/YourComponent/YourComponent.tsx
import React from 'react'
/**
* Component description
*/
interface YourComponentProps {
/** Prop description */
prop: string
}
/**
* Component documentation
*/
export const YourComponent: React.FC<YourComponentProps> = ({ prop }) => {
return <div>{prop}</div>
}Adding new stores:
// src/stores/yourStore.ts
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
interface YourStore {
value: string
setValue: (value: string) => void
}
export const useYourStore = create<YourStore>()(
persist(
(set) => ({
value: '',
setValue: (value) => set({ value })
}),
{ name: 'your-storage' }
)
)Add to src/hooks/useKeyboardShortcuts.ts:
{
key: 'n',
ctrl: true,
handler: () => {
// Your handler
},
description: 'New action'
}- Use explicit types for function parameters
- Prefer interfaces over types for objects
- Use const assertions for literal types
- Document all exported functions and components
- Use functional components with hooks
- Memoize expensive computations
- Use proper dependency arrays in hooks
- Keep components focused and small
- Use utility classes, avoid custom CSS
- Follow mobile-first responsive design
- Use dark mode variants consistently
- Extract repeated patterns to components
- Components:
PascalCase.tsx - Utilities:
camelCase.ts - Types:
PascalCase.ts - Hooks:
useCamelCase.ts
# Type checking
npm run typecheck
# Linting (when configured)
npm run lint
# Build test
npm run buildBefore submitting changes:
- Editor functionality works
- Preview updates in real-time
- Dark mode toggles properly
- Keyboard shortcuts function
- Export features work (PDF, DOCX, MD)
- Copy features work in all formats
- No console errors
- Responsive design maintained
npm run devFeatures:
- Hot Module Replacement (HMR)
- Source maps
- Fast refresh
- Error overlay
npm run buildOutput:
- Minified bundles in
dist/ - Optimized assets
- Tree-shaken code
- Compressed output
npm run preview-
Build Errors
# Clear cache and rebuild rm -rf node_modules dist npm install npm run build -
Type Errors
# Check TypeScript errors npm run typecheck -
State Issues
- Open Redux DevTools
- Check Zustand stores
- Clear localStorage if needed
Add to your code for debugging:
if (import.meta.env.DEV) {
console.log('Debug info:', data)
}- Code follows style guidelines
- Changes are documented
- No unnecessary dependencies added
- Performance impact considered
- Accessibility maintained
- Cross-browser tested
- Update documentation
- Add JSDoc comments
- Test all features
- Update CHANGELOG.md
- Request review
Follow conventional commits:
feat: add new feature
fix: resolve bug
docs: update documentation
style: formatting changes
refactor: code restructuring
perf: performance improvements
test: add tests
chore: maintenance tasks
- Check existing issues
- Review ADRs for architecture decisions
- Consult API documentation
- Ask in discussions or create an issue