Skip to content

Editor

Rich text editor module with collaborative features and media support.

Overview

Editor is a comprehensive rich text editing module built on TipTap, featuring real-time collaboration, media embedding, auto-save, and extensive formatting options.

Basic Usage

tsx
import { Editor } from '@acrobi/ui';

function DocumentEditor() {
  const [content, setContent] = useState('');

  return (
    <Editor
      content={content}
      onChange={setContent}
      tools={[
        'bold', 'italic', 'underline',
        'heading', 'list', 'link',
        'image', 'table', 'code'
      ]}
      placeholder="Start writing..."
    />
  );
}

Props

PropTypeDefaultDescription
contentstring-Editor content (HTML)
onChangefunction-Content change handler
toolsstring[]-Available editing tools
collaborationobject-Collaboration settings
autosaveobject-Auto-save configuration
mediaUploadobject-Media upload settings

Examples

Collaborative Editor

tsx
function CollaborativeEditor() {
  return (
    <Editor
      content={document.content}
      onChange={handleContentChange}
      collaboration={{
        enabled: true,
        users: collaborators,
        onUserJoin: handleUserJoin,
        onUserLeave: handleUserLeave
      }}
      autosave={{
        enabled: true,
        interval: 30000,
        onSave: handleAutosave
      }}
    />
  );
}
tsx
<Editor
  content={content}
  onChange={setContent}
  tools={[
    'bold', 'italic', 'underline', 'strike',
    'heading', 'paragraph', 'blockquote',
    'bulletList', 'orderedList', 'taskList',
    'link', 'image', 'video', 'table',
    'code', 'codeBlock', 'horizontalRule'
  ]}
  mediaUpload={{
    endpoint: '/api/upload',
    maxSize: 10 * 1024 * 1024,
    allowedTypes: ['image/*', 'video/*']
  }}
  placeholder="Write something amazing..."
/>

Released under the MIT License.