Markdown is a dynamic, user-friendly Markdown editor with a split-pane interface. Users can write Markdown in one panel and instantly see the live preview in another. Built using React and Next.js, this project takes advantage of Zustand for state management, Framer Motion for animations, and Next Themes for dark mode functionality.
- Edit Markdown in the left panel and see the live-rendered output in the right panel.
- Supports GitHub Flavored Markdown through
remark-gfm
.
- Easily create, update, and delete Markdown documents with autosave functionality.
- Use the sidebar for quick access to documents and seamless switching.
- Optimized for both desktop and mobile devices.
- On mobile, toggle between the editor and preview modes to maximize space.
- Switch between light and dark themes with smooth transitions.
- Drag the divider between the editor and preview to resize panels.
- Layout preferences are saved in cookies, ensuring a consistent experience across sessions.
To install and run the project locally:
# Clone the repository
git clone https://github.com/blazeshomida/In-Browser-Markdown-Editor
# Navigate into the project directory
cd In-Browser-Markdown-Editor
# Install dependencies
npm install
# Start the development server
npm run dev
Visit http://localhost:3000
in your browser to access the editor.
Once the application is up and running:
- Write Markdown in the left pane. The right pane will automatically render the formatted content.
- Resize the Layout by dragging the divider between the panels.
- Manage Documents using the sidebar to create, delete, or switch between documents.
- Dark Mode: Toggle between light and dark modes via the sidebar switch.
- Mobile: The app adapts to smaller screens by toggling between editor and preview views.
This project is designed for modularity and ease of maintenance. Below is an overview of the main components and hooks:
- RootLayout: The main layout that wraps the app, integrating the header and theme provider.
- MainContent: The core component responsible for rendering the Markdown editor and preview, supporting the split-pane layout.
- Header: Handles document actions like saving, deleting, and renaming.
- SidebarNav: Manages navigation between documents and theme toggling.
- useDocumentStore: Manages the creation, updating, and deletion of documents.
- useMediaQuery: Provides responsive design functionality based on screen size.
- useMenuOpen: Controls the opening and closing of the sidebar.
- useMounted: Ensures that certain actions are only executed after the component is mounted, preventing SSR/CSR issues.
This is an example of how the document store creates a new document using Zustand:
createDocument: () =>
set((state) => {
const newDocument = createNewDocument();
return {
documents: [...state.documents, newDocument],
currentDocument: newDocument,
};
}),
The useMediaQuery
hook dynamically adjusts the layout based on the screen width:
const useMediaQuery = (query: string) => {
const [matches, setMatches] = useState(false);
useEffect(() => {
const media = window.matchMedia(query);
const listener = () => setMatches(media.matches);
window.addEventListener("resize", listener);
return () => window.removeEventListener("resize", listener);
}, [query]);
return matches;
};
- Enhanced Markdown Features: Add support for tables, task lists, and other advanced Markdown syntax.
- Cloud Sync: Allow users to save and sync documents across devices via the cloud.
- Custom Themes: Offer a range of customizable themes beyond light and dark mode.
Contributions are always welcome! If you'd like to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request for review.
Please open an issue for any significant changes you'd like to discuss before implementation.
Thanks to all contributors who have helped develop and improve Markdown.