Skip to content

DAMMAK/collaborative_editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collaborative Editor Pro - Light Mode

โœจ Collaborative Editor Pro

A premium real-time collaborative text editor inspired by Google Docs

FeaturesDemoTech StackGetting StartedArchitectureAPIContributing

React TypeScript Node.js PostgreSQL WebSocket TipTap License


๐Ÿ“– Overview

Collaborative Editor Pro is a feature-rich, real-time collaborative text editor that brings the power of Google Docs-style editing to your applications. Built with modern web technologies, it offers seamless multi-user collaboration, rich text formatting, and a beautiful, responsive interface that works flawlessly in both light and dark modes.

Whether you're building a documentation platform, a team collaboration tool, or a content management system, Collaborative Editor Pro provides all the essential features you need for professional document editing.


๐ŸŽฌ Demo

Light Mode

Editor in Light Mode

Dark Mode

Editor in Dark Mode


โœจ Features

๐ŸŽจ Rich Text Editing

Feature Description
Text Formatting Bold, italic, underline, strikethrough, and inline code
Headings 6 levels (H1-H6) with beautiful, consistent styling
Text Alignment Left, center, right, and justify options
Lists Bullet lists, numbered lists, and task lists with interactive checkboxes
Highlighting Multiple highlight colors (yellow, green, blue, pink, orange, purple)
Blockquotes Elegant quote blocks with styled left border accent
Horizontal Rules Gradient-styled dividers for content separation
Code Blocks Syntax-highlighted code with monospace font

๐Ÿ“Š Advanced Elements

Feature Description
Tables Full table support with insert, resize, add/delete rows and columns
Images Insert images via URL with hover effects and responsive sizing
Links Auto-link detection with custom styling and click-to-open functionality

๐Ÿ‘ฅ Real-Time Collaboration

Feature Description
Operational Transformation Industry-standard conflict resolution for concurrent editing
WebSocket Sync Instant updates across all connected clients with minimal latency
Connection Status Live indicator showing connection state (connected/reconnecting/offline)
Version Tracking Document version displayed in toolbar for debugging and sync verification
Presence Awareness See who else is editing the document in real-time

๐ŸŒ™ Modern UI/UX

Feature Description
Dark/Light Theme Toggle between themes with smooth CSS transitions
System Theme Detection Automatically matches your OS preference
Premium Design Glassmorphism effects, gradients, and micro-animations
Google Docs Layout Familiar page-style document presentation with margins
Responsive Layout Works seamlessly on desktop, laptop, and tablet devices
Custom Scrollbars Styled scrollbars that match the current theme
Keyboard Shortcuts Full support for common formatting shortcuts

๐Ÿ“ˆ Document Analytics

Feature Description
Word Count Real-time word counter in status bar
Character Count Track total character count
Reading Time Estimated reading time (calculated at 200 WPM)
Auto-Save Visual indicator showing save status

๐Ÿ’พ Export Options

  • Export to HTML - Clean, semantic HTML output
  • Export to Plain Text - Strip formatting for plain text use

๐Ÿ›  Tech Stack

Frontend

Technology Purpose Version
React UI Library 18.2
TypeScript Type Safety 5.3
TipTap Rich Text Editor (ProseMirror-based) 2.x
Tailwind CSS Styling Framework 3.4
Zustand State Management 5.0
Radix UI Accessible UI Components Latest
Lucide React Icon Library 0.303
Vite Build Tool 5.0

TipTap Extensions Used

@tiptap/starter-kit          # Core editing functionality
@tiptap/extension-image      # Image support
@tiptap/extension-link       # Link handling
@tiptap/extension-table      # Table editing
@tiptap/extension-table-row  # Table row management
@tiptap/extension-table-cell # Table cell management
@tiptap/extension-table-header # Table header support
@tiptap/extension-task-list  # Task list with checkboxes
@tiptap/extension-task-item  # Individual task items
@tiptap/extension-highlight  # Text highlighting
@tiptap/extension-underline  # Underline formatting
@tiptap/extension-text-align # Text alignment
@tiptap/extension-placeholder # Placeholder text
@tiptap/extension-character-count # Character counting

Backend

Technology Purpose Version
Node.js Runtime Environment 16+
Express Web Framework 4.18
WebSocket (ws) Real-time Communication 8.16
PostgreSQL Database 16
TypeScript Type Safety 5.3
tsx TypeScript Execution 4.7

Infrastructure

Technology Purpose
Docker Compose Container Orchestration
PostgreSQL Alpine Lightweight Database Image
pgAdmin 4 Database Management UI

๐Ÿ— Architecture

System Architecture

┌─────────────────────────────────────────────────────────────────┐
│                          CLIENT                                  │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                    React Application                      │    │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐      │    │
│  │  │   TipTap    │  │   Zustand   │  │    Radix    │      │    │
│  │  │   Editor    │  │   Stores    │  │     UI      │      │    │
│  │  └─────────────┘  └─────────────┘  └─────────────┘      │    │
│  │         │                │                               │    │
│  │         โ–ผ                โ–ผ                               │    │
│  │  ┌─────────────────────────────────────┐                │    │
│  │  │        Collaboration Client          │                │    │
│  │  │  - WebSocket Connection             │                │    │
│  │  │  - Operational Transformation       │                │    │
│  │  │  - Step Synchronization            │                │    │
│  │  └─────────────────────────────────────┘                │    │
│  └─────────────────────────────────────────────────────────┘    │
│                              │                                   │
└──────────────────────────────│───────────────────────────────────┘
                               │ HTTP REST + WebSocket
                               โ–ผ
┌─────────────────────────────────────────────────────────────────┐
│                          SERVER                                  │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                  Express Application                     │    │
│  │  ┌─────────────────┐  ┌─────────────────┐              │    │
│  │  │   REST Routes   │  │ WebSocket Server│              │    │
│  │  │  /api/collab/*  │  │    /ws          │              │    │
│  │  └────────┬────────┘  └────────┬────────┘              │    │
│  │           │                    │                        │    │
│  │           โ–ผ                    โ–ผ                        │    │
│  │  ┌─────────────────────────────────────┐               │    │
│  │  │            Step Service              │               │    │
│  │  │  - Document version management      │               │    │
│  │  │  - Step validation & storage        │               │    │
│  │  │  - Conflict resolution              │               │    │
│  │  └─────────────────────────────────────┘               │    │
│  │                    │                                    │    │
│  │                    โ–ผ                                    │    │
│  │  ┌─────────────────────────────────────┐               │    │
│  │  │         Persistence Service          │               │    │
│  │  │  - Document storage                 │               │    │
│  │  │  - Step history                     │               │    │
│  │  └─────────────────────────────────────┘               │    │
│  └─────────────────────────────────────────────────────────┘    │
│                              │                                   │
└──────────────────────────────│───────────────────────────────────┘
                               │
                               โ–ผ
┌─────────────────────────────────────────────────────────────────┐
│                       DATABASE                                   │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                     PostgreSQL                           │    │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐      │    │
│  │  │  documents  │  │    steps    │  │   sessions  │      │    │
│  │  └─────────────┘  └─────────────┘  └─────────────┘      │    │
│  └─────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────┘

Project Structure

collaborative_editor/
├── ๐Ÿ“ client/                          # React frontend application
│   ├── ๐Ÿ“ src/
│   │   ├── ๐Ÿ“ components/
│   │   │   ├── ๐Ÿ“ editor/              # Core editor components
│   │   │   │   ├── CollaborativeEditor.tsx      # Basic editor
│   │   │   │   ├── EnhancedCollaborativeEditor.tsx  # Full-featured editor
│   │   │   │   ├── EnhancedEditorToolbar.tsx   # Google Docs-style toolbar
│   │   │   │   ├── EnhancedEditorStatusBar.tsx # Document stats & status
│   │   │   │   ├── EditorRuler.tsx             # Horizontal ruler
│   │   │   │   ├── VerticalRuler.tsx           # Vertical ruler
│   │   │   │   ├── WordCounter.tsx             # Word count display
│   │   │   │   ├── ErrorBanner.tsx             # Error notifications
│   │   │   │   └── editor.css                  # Editor-specific styles
│   │   │   ├── ๐Ÿ“ layout/              # Layout components
│   │   │   │   └── Header.tsx
│   │   │   └── ๐Ÿ“ ui/                  # Reusable UI components
│   │   │       ├── button.tsx          # Button variants
│   │   │       ├── dialog.tsx          # Modal dialogs
│   │   │       ├── dropdown-menu.tsx   # Dropdown menus
│   │   │       ├── popover.tsx         # Popovers
│   │   │       ├── tooltip.tsx         # Tooltips
│   │   │       ├── separator.tsx       # Visual separators
│   │   │       ├── CollaboratorAvatar.tsx  # User presence indicators
│   │   │       └── ThemeToggle.tsx     # Theme switcher
│   │   ├── ๐Ÿ“ stores/                  # Zustand state management
│   │   │   ├── themeStore.ts           # Theme preferences
│   │   │   ├── documentStore.ts        # Document state
│   │   │   └── presenceStore.ts        # User presence state
│   │   ├── ๐Ÿ“ hooks/                   # Custom React hooks
│   │   │   ├── useDebounce.ts          # Debounce utility
│   │   │   └── useLocalStorage.ts      # LocalStorage persistence
│   │   ├── ๐Ÿ“ lib/                     # Utilities and services
│   │   │   ├── api.ts                  # REST API client
│   │   │   ├── websocket.ts            # WebSocket client
│   │   │   ├── collaboration.ts        # Collaboration logic
│   │   │   └── utils.ts                # Helper functions
│   │   ├── App.tsx                     # Root component
│   │   ├── main.tsx                    # Entry point
│   │   └── index.css                   # Global styles
│   ├── package.json
│   ├── vite.config.ts
│   ├── tailwind.config.js
│   └── tsconfig.json
│
├── ๐Ÿ“ server/                          # Node.js backend
│   ├── ๐Ÿ“ src/
│   │   ├── ๐Ÿ“ config/                  # Configuration
│   │   │   └── database.ts             # Database schema
│   │   ├── ๐Ÿ“ database/                # Database connection
│   │   │   └── pool.ts                 # PostgreSQL connection pool
│   │   ├── ๐Ÿ“ middleware/              # Express middleware
│   │   │   ├── errorHandler.ts         # Global error handling
│   │   │   └── validation.ts           # Request validation
│   │   ├── ๐Ÿ“ repositories/            # Data access layer
│   │   │   ├── documentRepository.ts   # Document CRUD
│   │   │   └── stepRepository.ts       # Step storage
│   │   ├── ๐Ÿ“ routes/                  # API endpoints
│   │   │   └── collaboration.ts        # Collaboration routes
│   │   ├── ๐Ÿ“ services/                # Business logic
│   │   │   ├── stepService.ts          # Step processing
│   │   │   ├── persistenceService.ts   # Data persistence
│   │   │   ├── websocketService.ts     # WebSocket management
│   │   │   └── logger.ts               # Logging utility
│   │   ├── ๐Ÿ“ scripts/                 # Database scripts
│   │   │   ├── setupDatabase.ts        # Initialize schema
│   │   │   └── resetDatabase.ts        # Reset database
│   │   ├── ๐Ÿ“ types/                   # TypeScript types
│   │   │   └── index.ts                # Shared type definitions
│   │   └── server.ts                   # Application entry point
│   ├── package.json
│   └── tsconfig.json
│
├── ๐Ÿ“ screenshots/                     # Documentation images
│   ├── editor_light_mode.png
│   ├── editor_dark_mode.png
│   └── img.png
│
├── docker-compose.yml                  # Database services
├── package.json                        # Root workspace configuration
├── .gitignore
└── README.md

๐Ÿš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Requirement Version Notes
Node.js v16+ Download
npm v7+ Comes with Node.js
Docker Latest Download
Docker Compose v2+ Download

Installation

1. Clone the Repository

git clone https://github.com/DAMMAK/collaborative_editor.git
cd collaborative_editor

2. Install Dependencies

# Install all dependencies (root, client, and server)
npm run install:all

3. Start the Database

# Start PostgreSQL and pgAdmin containers
docker-compose up -d

# Verify containers are running
docker-compose ps

4. Initialize the Database Schema

# Run database setup script
npm run db:setup --workspace=server

5. Start Development Servers

# Start both client and server concurrently
npm run dev

Access the Application

Service URL Description
Editor http://localhost:3000 Main application
API Server http://localhost:4000 REST API endpoints
WebSocket ws://localhost:4000/ws Real-time updates
pgAdmin http://localhost:5050 Database management

pgAdmin Credentials


๐ŸŽจ Theme System

The editor supports three theme modes that can be toggled via the toolbar:

Light Mode

Clean, bright interface with purple accents perfect for daytime use.

Dark Mode

Rich, dark interface with optimized contrast for reduced eye strain.

System Mode

Automatically matches your operating system's theme preference and updates dynamically.

Implementation Details:

  • Theme state is managed via Zustand with localStorage persistence
  • CSS transitions provide smooth theme switching
  • System theme changes are detected via matchMedia listener
  • Tailwind CSS dark mode uses class-based switching

โŒจ๏ธ Keyboard Shortcuts

Text Formatting

Shortcut Action
โŒ˜/Ctrl + B Bold
โŒ˜/Ctrl + I Italic
โŒ˜/Ctrl + U Underline
โŒ˜/Ctrl + Shift + S Strikethrough
โŒ˜/Ctrl + E Code

History

Shortcut Action
โŒ˜/Ctrl + Z Undo
โŒ˜/Ctrl + Shift + Z Redo
โŒ˜/Ctrl + Y Redo (alternative)

Lists

Shortcut Action
โŒ˜/Ctrl + Shift + 8 Bullet List
โŒ˜/Ctrl + Shift + 7 Numbered List

๐Ÿ”Œ API Reference

REST Endpoints

Collaboration

Method Endpoint Description Request Response
GET /api/collab/events Get steps since version ?version=n { version, steps[], doc }
POST /api/collab/events Push new steps { version, steps[], clientID } { success, version }
GET /api/collab/stats Document statistics - { version, stepCount, clientCount }
GET /api/collab/health Health check - { status: "ok" }

WebSocket Protocol

Connection URL: ws://localhost:4000/ws

Message Types

Type Direction Payload Description
CONNECTED Server → Client { message } Connection confirmation
NEW_STEPS Server → Client { version, steps[] } New steps broadcast
VERSION_UPDATE Server → Client { version } Version sync
PING Client → Server { timestamp } Keep-alive ping
PONG Server → Client { timestamp } Ping response

๐Ÿ”ง Available Scripts

Root Level

Command Description
npm run install:all Install all dependencies
npm run dev Start both client and server
npm run dev:client Start only client
npm run dev:server Start only server
npm run build Build for production
npm run clean Remove all node_modules and builds

Client

Command Description
npm run dev Development server with HMR
npm run build Production build
npm run preview Preview production build
npm run lint Run ESLint

Server

Command Description
npm run dev Development server with hot reload
npm run build Compile TypeScript
npm run start Start production server
npm run db:setup Initialize database schema
npm run db:reset Reset database (โš ๏ธ destructive)

๐Ÿณ Docker

Database Services

The project includes Docker Compose configuration for the database:

# Start PostgreSQL and pgAdmin
docker-compose up -d

# View logs
docker-compose logs -f

# View specific service logs
docker-compose logs -f postgres

# Stop services
docker-compose down

# Stop and remove volumes (โš ๏ธ deletes data)
docker-compose down -v

Environment Variables

Variable Default Description
POSTGRES_DB collaborative_editor Database name
POSTGRES_USER postgres Database user
POSTGRES_PASSWORD postgres Database password
PORT 4000 Server port
NODE_ENV development Environment mode

๐Ÿ” Security Considerations

When deploying to production, ensure you:

  1. Change default credentials - Update PostgreSQL and pgAdmin passwords
  2. Use environment variables - Never commit secrets to version control
  3. Enable HTTPS - Use TLS for all connections
  4. Configure CORS - Restrict origins to trusted domains
  5. Rate limiting - Implement rate limiting for API endpoints
  6. Input validation - Validate and sanitize all user inputs
  7. WebSocket authentication - Add authentication to WebSocket connections

๐Ÿšฆ Performance Optimization

Implemented Optimizations

  • Debounced sync - Prevents excessive API calls during rapid typing
  • Step batching - Multiple changes bundled into single requests
  • Efficient DOM updates - ProseMirror's virtual document model
  • Connection pooling - PostgreSQL connection reuse
  • WebSocket heartbeat - Dead connection detection and cleanup

Recommended for Production

  • Enable gzip compression
  • Use a CDN for static assets
  • Implement Redis for session caching
  • Add read replicas for database scaling
  • Consider horizontal scaling with load balancer

๐Ÿงช Testing

Running Tests

# Client tests (when implemented)
npm test --workspace=client

# Server tests (when implemented)
npm test --workspace=server

Manual Testing Checklist

  • Editor loads without errors
  • Text formatting works (bold, italic, etc.)
  • Tables can be created and edited
  • Theme toggle works correctly
  • WebSocket connection establishes
  • Changes sync between multiple tabs
  • Export functions produce valid output

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

Development Workflow

  1. Fork the repository

    git clone https://github.com/DAMMAK/collaborative_editor.git
  2. Create a feature branch

    git checkout -b feature/amazing-feature
  3. Make your changes

    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Commit your changes

    git commit -m 'feat: add amazing feature'

    Follow Conventional Commits format.

  5. Push to your fork

    git push origin feature/amazing-feature
  6. Open a Pull Request

Code Style

  • TypeScript - Strict mode enabled
  • ESLint - Follow project configuration
  • Prettier - Consistent formatting
  • Components - Functional with hooks

๐Ÿ—บ Roadmap

Upcoming Features

  • User Authentication - Login and user management
  • Document Management - Create, list, and organize documents
  • Comments & Suggestions - Google Docs-style commenting
  • Cursor Presence - See other users' cursors in real-time
  • Version History - View and restore previous versions
  • Export to PDF - Generate PDF documents
  • Import DOCX - Import Word documents
  • Emoji Picker - Rich emoji support
  • Mentions - @mention users in documents
  • Templates - Pre-built document templates
  • Mobile Optimization - Touch-friendly interface
  • Offline Mode - Continue editing when disconnected

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 DAMMAK

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

๐Ÿ™ Acknowledgments

This project stands on the shoulders of giants:

Project Purpose
TipTap The headless editor framework powering the rich text experience
ProseMirror The foundational toolkit for building rich text editors
Tailwind CSS The utility-first CSS framework for rapid styling
Radix UI Unstyled, accessible component primitives
Zustand Lightweight state management
Lucide Beautiful, consistent icons
Google Docs Design inspiration and UX patterns

๐Ÿ“ฌ Contact

DAMMAK - @DAMMAK

Project Link: https://github.com/DAMMAK/collaborative_editor


Built with โค๏ธ by DAMMAK

If you found this project helpful, please consider giving it a โญ!

About

Collaborative Editor Pro is a feature-rich, real-time collaborative text editor that brings the power of Google Docs-style editing to your applications. Built with modern web technologies, it offers seamless multi-user collaboration, rich text formatting, and a beautiful, responsive interface that works flawlessly in both light and dark modes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors