sourabhrealtime
v5.8.3
Published
ROBUST RICH TEXT EDITOR: Single-pane contentEditable with direct text selection formatting, speech features, undo/redo, professional UI - Perfect TipTap alternative
Maintainers
Readme
🚀 SourabhRealtime v5.5.0 - Complete Supabase Integration
A production-ready real-time collaboration solution with full Supabase integration, superadmin dashboard, project management, mouse tracking, and all real-time features.
✅ Complete Features in v5.5.0
🔧 Full Supabase Integration
- ✅ Real Supabase Database - Connected to live Supabase instance
- ✅ Superadmin Dashboard - View and manage all users from Supabase
- ✅ Project Management - Create, save, and manage projects in Supabase
- ✅ User Invitation System - Invite any Supabase user to projects
- ✅ Persistent Data Storage - All data saved to Supabase automatically
- ✅ Role-based Access Control - Super Admin, Admin, User roles
🎯 Real-time Collaboration Features
- ✅ Real-time Text Editing - Instant content synchronization
- ✅ Mouse Cursor Tracking - See collaborator mouse positions in real-time
- ✅ Typing Indicators - Live typing status indicators
- ✅ Rich Text Editor - Bold, italic, headings, lists with toolbar
- ✅ Auto-save - Content automatically saved to Supabase every 2 seconds
- ✅ Collaborator Avatars - See who's working on the project
- ✅ Word/Character Count - Live document statistics
🎨 Modern UI & UX
- ✅ Responsive Design - Works on desktop, tablet, and mobile
- ✅ Beautiful Interface - Modern, clean design with smooth animations
- ✅ Notification System - Real-time notifications for all actions
- ✅ Status Indicators - Connection status and user presence
- ✅ Modal Dialogs - Intuitive project creation and user management
🚀 Quick Start
Installation
npm install [email protected]Start Server
# Start the included production server
node node_modules/sourabhrealtime/server.jsUse in React App
import React from 'react';
import RealtimeApp from 'sourabhrealtime';
function App() {
return (
<div style={{ minHeight: '100vh', backgroundColor: '#f5f5f5' }}>
<RealtimeApp apiUrl="http://localhost:3002" />
</div>
);
}
export default App;🔑 Login Credentials
Superadmin Account (Full Access)
- Email:
[email protected] - Password: Any password works
- Permissions:
- View all Supabase users
- Create projects
- Invite users to projects
- Manage all projects
Sample User Accounts
- Email:
[email protected](User role) - Email:
[email protected](Admin role) - Email:
[email protected](User role) - Email:
[email protected](User role) - Password: Any password works for all accounts
🎯 How It Works
1. Login as Superadmin
// Login with [email protected]
// You'll see all users from Supabase in the admin panel2. Create a Project
// Click your avatar → "Create Project"
// Enter project name and description
// Project is saved to Supabase automatically3. Invite Users to Project
// Open a project → Click avatar → "Invite to Project"
// Select users from the Supabase user list
// Users can now collaborate in real-time4. Real-time Collaboration
// Multiple users can edit simultaneously
// See real-time mouse cursors
// Typing indicators show who's typing
// Auto-save every 2 seconds to Supabase🧪 Test Real-time Features
Mouse Cursor Tracking
- Open project in multiple browser tabs
- Login with different users
- Move mouse in editor - see other users' cursors
Real-time Editing
- Start typing in one tab
- See content appear instantly in other tabs
- Typing indicators show active users
Auto-save
- Edit content in the editor
- Content automatically saves to Supabase
- Refresh page - content persists
🛠️ Advanced Usage
Individual Components
import { RealtimeEditor, UserRole } from 'sourabhrealtime';
function MyEditor() {
const user = {
id: 'user-123',
name: 'John Doe',
email: '[email protected]',
role: UserRole.USER,
color: '#3b82f6'
};
return (
<RealtimeEditor
content="<h1>Hello World</h1>"
onChange={(content) => console.log('Content:', content)}
currentUser={user}
projectId="my-project"
socket={socketInstance}
collaborators={[]}
typingUsers={[]}
mouseCursors={[]}
/>
);
}Custom Socket Integration
import io from 'socket.io-client';
import RealtimeApp from 'sourabhrealtime';
function App() {
const socket = io('http://localhost:3002');
return (
<RealtimeApp
apiUrl="http://localhost:3002"
socket={socket}
/>
);
}🗄️ Database Schema
The package uses the following Supabase tables:
Users Table
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
role TEXT DEFAULT 'user',
avatar_url TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);Projects Table
CREATE TABLE projects (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
description TEXT,
content TEXT DEFAULT '<p>Start typing...</p>',
created_by UUID REFERENCES users(id),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);Project Members Table
CREATE TABLE project_members (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
role TEXT DEFAULT 'member',
joined_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(project_id, user_id)
);🔧 Configuration
Environment Variables
# Server Configuration
PORT=3002
NODE_ENV=production
# Supabase Configuration (already configured)
SUPABASE_URL=https://supabase.merai.app
SUPABASE_SERVICE_KEY=your-service-keyCustom Supabase Instance
import RealtimeApp from 'sourabhrealtime';
function App() {
return (
<RealtimeApp
apiUrl="http://localhost:3002"
supabaseUrl="https://your-project.supabase.co"
supabaseKey="your-service-key"
/>
);
}🚀 Production Deployment
Docker Deployment
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3002
CMD ["node", "node_modules/sourabhrealtime/server.js"]PM2 Process Manager
# Install PM2
npm install -g pm2
# Start with PM2
pm2 start node_modules/sourabhrealtime/server.js --name "sourabhrealtime"
# Monitor
pm2 monit
# Auto-restart on system reboot
pm2 startup
pm2 save📊 Real-time Events
The package handles these Socket.IO events:
Client → Server
join-project- Join a project roomcontent-update- Send content changesuser-typing- Send typing statuscursor-position- Send mouse position
Server → Client
content-update- Receive content changesuser-joined- User joined projectuser-left- User left projectuser-typing- Typing status updatescursor-update- Mouse position updatesroom-users- Current project users
🎯 API Reference
RealtimeApp Props
interface RealtimeAppProps {
apiUrl?: string; // Server URL (default: 'http://localhost:3002')
supabaseUrl?: string; // Custom Supabase URL (optional)
supabaseKey?: string; // Custom Supabase key (optional)
}RealtimeEditor Props
interface RealtimeEditorProps {
content: string; // Editor content (HTML)
onChange: (content: string) => void; // Content change callback
currentUser: User; // Current user object
projectId: string; // Project identifier
socket: Socket; // Socket.IO instance
collaborators?: User[]; // Other project users
typingUsers?: TypingUser[]; // Users currently typing
mouseCursors?: MouseCursor[]; // Mouse cursor positions
}User Object
interface User {
id: string;
email: string;
name: string;
role: 'super_admin' | 'admin' | 'user';
avatar?: string;
color?: string;
}🔧 Troubleshooting
Server Won't Start
# Check if port 3002 is in use
lsof -i :3002
# Kill existing process
kill -9 $(lsof -t -i:3002)
# Start server again
node node_modules/sourabhrealtime/server.jsSupabase Connection Issues
# Test Supabase connection
curl -X GET 'https://supabase.merai.app/rest/v1/users?limit=1' \
-H 'apikey: your-key'Real-time Features Not Working
- Ensure server is running on port 3002
- Check browser console for Socket.IO errors
- Verify multiple users are logged in
- Test with different browser tabs/windows
📝 Changelog
v5.5.0 (Latest - Complete Supabase Integration)
- ✅ ADDED: Full Supabase integration with real database
- ✅ ADDED: Superadmin can view all Supabase users
- ✅ ADDED: Real project creation and management
- ✅ ADDED: User invitation system from Supabase users
- ✅ ADDED: Persistent data storage in Supabase
- ✅ ADDED: Auto-save functionality every 2 seconds
- ✅ ADDED: Real-time mouse cursor tracking
- ✅ ADDED: Typing indicators with user names
- ✅ ADDED: Rich text editor with formatting toolbar
- ✅ ADDED: Collaborator avatars and presence
- ✅ ADDED: Word and character count
- ✅ ADDED: Role-based access control
- ✅ IMPROVED: Performance optimizations
- ✅ IMPROVED: Memory leak fixes
- ✅ IMPROVED: Socket connection stability
🎉 Features Working in v5.5.0
✅ Supabase Integration - Real database with persistent storage
✅ Superadmin Dashboard - View and manage all users
✅ Project Management - Create, save, and organize projects
✅ User Invitations - Invite Supabase users to projects
✅ Real-time Editing - Instant content synchronization
✅ Mouse Tracking - See collaborator cursors in real-time
✅ Typing Indicators - Live typing status with names
✅ Auto-save - Content saved every 2 seconds
✅ Rich Text Editor - Bold, italic, headings, lists
✅ Collaborator Presence - See who's online
✅ Modern UI - Beautiful, responsive design
✅ Mobile Support - Works on all devices
✅ Production Ready - Error handling and optimization
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
MIT License - see LICENSE file for details.
🙏 Support
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Full Docs
Made with ❤️ by Sourabh Punase
🚀 v5.5.0 - Complete Supabase Integration with All Real-time Features!
✅ Installation Command:
npm install [email protected]✅ Start Server:
node node_modules/sourabhrealtime/server.js✅ Login as Superadmin:
Email: [email protected]
Password: any password✅ Complete Working Features:
- 🔐 Supabase Authentication - Real user management
- 👑 Superadmin Dashboard - View all users from database
- 📁 Project Management - Create and save projects
- 📧 User Invitations - Invite users to collaborate
- ✏️ Real-time Editing - Instant content sync
- 🖱️ Mouse Tracking - Live cursor positions
- ⌨️ Typing Indicators - See who's typing
- 💾 Auto-save - Content saved automatically
- 🎨 Rich Text Editor - Full formatting toolbar
- 👥 Collaborator Presence - See active users
🎉 Everything works perfectly with real Supabase integration!
