sourabhrealtime
Version:
ROBUST RICH TEXT EDITOR: Single-pane contentEditable with direct text selection formatting, speech features, undo/redo, professional UI - Perfect TipTap alternative
71 lines (62 loc) • 1.59 kB
TypeScript
import { ReactNode } from 'react';
export interface User {
id: string;
name: string;
color?: string;
[key: string]: any;
}
export interface CursorPosition {
x?: number;
y?: number;
relativeX?: number;
relativeY?: number;
textPosition?: number;
selectionEnd?: number;
timestamp?: number;
[key: string]: any;
}
export interface Cursor {
id: string;
position: CursorPosition;
user: User;
timestamp: number;
}
export interface CollaborativeEditorProps {
roomId: string;
userId: string;
userName: string;
userColor?: string;
initialContent?: string;
onContentChange?: (content: string) => void;
wsUrl?: string;
height?: number | string;
width?: number | string;
showCollaborators?: boolean;
showStatus?: boolean;
debug?: boolean;
}
export interface UseRealtimeCursorsOptions {
roomId: string;
userId: string;
userName: string;
userColor?: string;
wsUrl?: string;
debug?: boolean;
}
export interface UseRealtimeCursorsResult {
cursors: Record<string, Cursor>;
collaborators: User[];
typingStatus: Record<string, {
isTyping: boolean;
user: User;
timestamp: number;
}>;
connected: boolean;
updateCursor: (position: CursorPosition) => void;
updateTypingStatus: (isTyping: boolean) => void;
registerUser: (user: User) => void;
unregisterUser: (userId: string) => void;
}
export declare function useRealtimeCursors(options: UseRealtimeCursorsOptions): UseRealtimeCursorsResult;
export declare const CollaborativeEditor: React.FC<CollaborativeEditorProps>;
export default CollaborativeEditor;