A full-stack rich text editor application built with React.js and Node.js, featuring real-time editing, document persistence, and export capabilities.
- Basic Formatting: Bold, italic, underline, strikethrough
- Text Alignment: Left, center, right, justify
- Lists: Ordered and unordered lists
- Media: Hyperlinks and inline images
- History: Undo/Redo functionality with 50-step history
- Placeholder: Helpful placeholder text
- Save/Load: Persist documents to MongoDB database
- Export: Download as HTML or Markdown files
- Responsive UI: Clean, modern interface that works on all devices
- Frontend: React.js 18 + TipTap Editor
- Backend: Node.js + Express.js
- Database: MongoDB with Mongoose ODM
- Styling: Custom CSS with responsive design
- Node.js (v16 or higher)
- MongoDB (local installation or MongoDB Atlas) - Optional for demo mode
- npm or yarn
-
Clone or navigate to the project directory:
cd /home/hasnat-shohag/viva-frontend/rich-text-editor -
Install Backend Dependencies:
cd backend npm install -
Install Frontend Dependencies:
cd ../frontend npm install
For a quick demo with in-memory storage:
-
Start Demo Backend:
cd backend npm run demoThe backend will start on
http://localhost:5002with in-memory storage. -
Start Frontend:
cd frontend npm startThe frontend will start on
http://localhost:3001
Backend Configuration:
-
Create environment file (optional):
cd backend cp .env.example .env -
Configure environment variables in
backend/.env:PORT=5002 MONGO_URI=mongodb://localhost:27017/richtexteditor
Option 1: Demo Mode (No Installation Required)
- Uses in-memory storage
- Data is lost when server restarts
- Perfect for testing and development
Option 2: Local MongoDB
-
Install MongoDB locally:
# Ubuntu/Debian sudo apt update sudo apt install -y mongodb-org sudo systemctl start mongod sudo systemctl enable mongod # macOS (using Homebrew) brew tap mongodb/brew brew install mongodb-community brew services start mongodb-community # Windows # Download and install from https://www.mongodb.com/try/download/community
Option 3: MongoDB Atlas (Cloud)
- Create account at MongoDB Atlas
- Create a cluster and get connection string
- Update
MONGO_URIin.envfile
# Terminal 1: Start Demo Backend
cd backend
npm run demo
# Terminal 2: Start Frontend
cd frontend
npm start# Terminal 1: Start Backend
cd backend
npm run dev
# Terminal 2: Start Frontend
cd frontend
npm start- Demo Backend:
http://localhost:5002 - Production Backend:
http://localhost:5001(or configured PORT) - Frontend:
http://localhost:3001
cd frontend
npm run buildhttp://localhost:5000
Health check endpoint
{
"message": "Rich Text Editor API is running!"
}Save document content
{
"title": "Document Title",
"content": {
/* TipTap JSON content */
},
"html": "<p>HTML content</p>",
"markdown": "# Markdown content"
}Response:
{
"id": "document_id",
"message": "Content saved successfully"
}Load document by ID
{
"_id": "document_id",
"title": "Document Title",
"content": {
/* TipTap JSON content */
},
"html": "<p>HTML content</p>",
"markdown": "# Markdown content",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}List all documents (latest 50)
[
{
"_id": "document_id",
"title": "Document Title",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]Delete document by ID
{
"message": "Document deleted successfully"
}- Open the application at
http://localhost:3000 - Enter a title for your document
- Start typing in the editor
- Use toolbar buttons for formatting
- Bold: Click B button or use Ctrl+B
- Italic: Click I button or use Ctrl+I
- Underline: Click U button or use Ctrl+U
- Strikethrough: Click S button
- Alignment: Use alignment buttons (β€ β‘ β₯ β)
- Lists: Create bullet or numbered lists
- Links: Click link button and enter URL
- Images: Click image button and enter image URL
- Save: Click "πΎ Save" button
- Load: Enter document ID and click "π Load"
- Export: Use "π Export HTML" or "π Export Markdown"
rich-text-editor/
βββ backend/
β βββ models/
β β βββ EditorContent.js # MongoDB schema
β βββ .env # Environment variables
β βββ index.js # Express server
β βββ package.json
βββ frontend/
β βββ public/
β β βββ index.html
β βββ src/
β β βββ App.js # Main React component
β β βββ App.css # Styling
β β βββ index.js # React entry point
β β βββ index.css
β βββ package.json
βββ README.md
Backend:
- Add new routes in
backend/index.js - Create new models in
backend/models/ - Update API documentation
Frontend:
- Add new components in
frontend/src/ - Extend TipTap editor with additional extensions
- Update styling in CSS files
Backend:
npm start- Start production servernpm run dev- Start development server with nodemon
Frontend:
npm start- Start development servernpm run build- Create production buildnpm test- Run tests
MongoDB Connection Error:
- Ensure MongoDB is running
- Check connection string in
.env - Verify network connectivity for Atlas
Port Already in Use:
- Change PORT in backend
.envfile - Update API_URL in frontend if needed
CORS Issues:
- Backend includes CORS middleware
- Check if frontend proxy is configured correctly
TipTap Extensions Not Working:
- Ensure all TipTap packages are installed
- Check console for JavaScript errors
Enable detailed logging by setting environment variable:
DEBUG=* npm run devcd backend
# Create Procfile
echo "web: node index.js" > Procfile
# Deploy to Heroku
heroku create your-app-name
heroku config:set MONGO_URI=your_mongodb_uri
git push heroku maincd frontend
npm run build
# Deploy build folder to your hosting serviceexpress- Web frameworkmongoose- MongoDB ODMcors- Cross-origin resource sharingbody-parser- Request body parsingdotenv- Environment variables
react- UI framework@tiptap/*- Rich text editoraxios- HTTP clientturndown- HTML to Markdown converter
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
For support, please create an issue in the repository or contact the development team.
Happy Writing! π