Documentation

CT Rich Text Editor

A configurable rich text editor component with API key authentication

Getting Started

Installation

Install the editor package using npm or yarn:

npm install ct-rich-text-editor
# or
yarn add ct-rich-text-editor

Important: Import Styles

To ensure proper styling of the editor components including tables, you must import the package's CSS:

import 'ct-rich-text-editor/style.css';

Basic Setup

Import and use the editor in your React application:

import React from 'react';
import {
  ConfigurableEditorWithAuth,
  EditorProvider,
  defaultEditorConfig
} from 'ct-rich-text-editor';
// Import required styles
import 'ct-rich-text-editor/style.css';

function App() {
  const apiKey = 'your-api-key'; // Replace with your actual API key

  // Current logged-in user for comments (optional)
  const currentUser = {
    id: 'user-123',
    name: 'John Doe',
    email: 'john@example.com',
    avatar: 'https://example.com/avatar.jpg' // optional
  };

  const handleContentChange = (html) => {
    console.log('Editor HTML content:', html);
    // Handle the HTML content (save to state, send to server, etc.)
  };

  return (
    <EditorProvider
      defaultFontFamilies={defaultEditorConfig.defaultFontFamilies}
      currentUser={currentUser}
    >
      <ConfigurableEditorWithAuth
        apiKey={apiKey}
        onChange={handleContentChange}
        initialContent="<p>Welcome to the editor!</p>"
        mentionUserList={["Alice", "Bob", "Charlie"]}
        onAuthSuccess={() => console.log('Authentication successful')}
        onAuthError={(error) => console.error('Authentication error:', error)}
      />
    </EditorProvider>
  );
}

Authentication & API Keys

Getting Your API Key

The CT Rich Text Editor requires an API key for authentication. Follow these steps to get started:

  1. Sign Up: Create an account using OTP verification or Google authentication
  2. Access Dashboard: Visit https://www.cteditor.com/user/license-key
  3. Copy Your Key: Your API key will be displayed in your dashboard
  4. Use in Your App: Pass the API key to the ConfigurableEditorWithAuth component

Free Premium Trial

Get 2 weeks of free premium access when you sign up! Experience all premium features including AI chat integration.

Try the Editor

Test the editor directly on our homepage before integrating:

Try Live Demo

Core Features

📝 Text Formatting

Basic Formatting

Bold, italic, underline, strikethrough, subscript, superscript

Text Colors

Text color and background color with color picker

Font Controls

20+ font families and font size controls

Text Alignment

Left, center, right, and justify alignment options

📋 Lists and Structure

Bulleted Lists

Custom bullet styles with proper indentation

Numbered Lists

Decimal, Alpha, Roman numbering formats

Checklist/Todo Lists

Interactive checkboxes with line-through styling

Nested Lists

Multi-level lists with proper indentation

📊 Tables

Table Operations

Insert/delete rows and columns, merge/split cells

Interactive Controls

Hover actions, cell resizing, table alignment

Header Styling

Header row styling with background colors

Responsive Tables

Tables that adapt to different screen sizes

🖼️ Media Support

Image Management

Drag-and-drop upload, resizing with 8-point handles

File Attachments

Upload and attach files with download links

Embed Previews

Rich embeds for external content and media

Link Management

Floating link editor for easy link management

🤖 AI Integration

AI Chat Plugin

Premium feature: AI-powered content assistance

Smart Autocomplete

AI-powered suggestions and content completion

Grammar Checking

Real-time grammar and style suggestions

Text Enhancement

AI-powered text improvement and rephrasing

Tone Adjustment

Change text tone: formal, casual, professional

AI Image Generation

Generate images from text descriptions

🎯 Advanced Features

Slash Commands

Quick formatting with / commands

Note Panels

Info, warning, error, success panels

Code Blocks

Syntax highlighting for code blocks

Charts

Insert and edit interactive charts

Digital Signatures

Canvas-based signature functionality

Voice Transcription

Voice input and transcription support

@Mentions

Mention users with @ symbol

Export to PDF

Export content with proper formatting

🔧 Developer Features

HTML View Toggle

Switch between rich text and HTML code view

Plugin Architecture

Extensible plugin system for custom features

Keyboard Shortcuts

Full keyboard shortcut support for all operations

Plugin System

Core Plugins

Text & Formatting

  • • FloatingTextFormatToolbarPlugin - Selection toolbar
  • • CodeHighlightPlugin - Syntax highlighting
  • • TextEnhancePlugin - AI text improvement
  • • CustomHorizontalRulePlugin - Dividers

Links & Media

  • • LinkPlugin - Link management
  • • LinkPreviewPlugin - Link preview cards
  • • FloatingLinkEditorPlugin - Link editing popup
  • • ImagePlugin - Image handling
  • • FilePlugin - File attachments
  • • EmbedPreviewPlugin - Rich embeds

Table Plugins

Table Features

  • • TablePlugin - Core table functionality
  • • TableActionMenuPlugin - Context menu
  • • TableCellResizer - Cell resizing
  • • TableHoverActionsPlugin - Hover controls
  • • TableImageAutoResizePlugin - Auto-resize images

AI and Intelligence

AI Features

  • • AIChatPlugin - AI chat assistance
  • • AutocompletePlugin - Smart suggestions
  • • GrammarCheckPlugin - Grammar checking
  • • CombinedAutocompleteGrammarPlugin - Combined AI
  • • TextEnhancePlugin - AI text enhancement
  • • FloatingEnhanceButton - Quick AI access

Statistics

  • • WordCountPlugin - Word/character count
  • • UsageTrackingPlugin - Usage analytics

Collaboration

Comments & Mentions

  • • CommentPlugin - Comment system
  • • CommentBubblePlugin - Comment bubble UI
  • • MentionsPlugin - @user mentions

Data Management

  • • LocalStoragePlugin - Data persistence
  • • HtmlSyncPlugin - HTML synchronization
  • • HtmlImportPlugin - HTML import

Productivity & Input

Quick Actions

  • • SlashCommandPlugin - / commands
  • • NotePanelPlugin - Info/warning panels
  • • SignatureCanvasPlugin - Digital signatures
  • • VoiceTranscriptPlugin - Voice to text

Input Handling

  • • DragDropPastePlugin - Drag & drop support
  • • RichTextPastePlugin - Rich paste handling
  • • MobileInputFixPlugin - Mobile keyboard fixes
  • • HtmlCodeViewPlugin - HTML view toggle

Configuration Options

Toolbar Configuration

toolbarOptions: {
  enableUndoRedo: boolean;           // Undo/Redo buttons
  enableTextFormatting: boolean;     // Bold, italic, etc.
  enableAlignment: boolean;          // Text alignment
  enableFontControls: boolean;       // Font family/size
  enableTableOptions: boolean;       // Table operations
  enableInsertMenu: boolean;        // Insert options
  enableColorPicker: boolean;        // Color controls
  enableClearOptions: boolean;       // Clear formatting
  enableEmojiPicker: boolean;        // Emoji picker
  enableLinks: boolean;             // Link insertion
  enableFormatTextMenu: boolean;     // Text formatting menu
  enableCodeFormat: boolean;         // Code formatting
  enableAIChat: boolean;             // AI chat integration
  enableTodoList: boolean;           // Checklist support
  enableHtmlViewToggle: boolean;     // HTML view
  enableNotePanels: boolean;         // Note panels
  enableAutocompleteToggle: boolean;  // Autocomplete
}

Floating Menu Configuration

floatingMenuOptions: {
  bold: boolean;
  italic: boolean;
  underline: boolean;
  uppercase: boolean;
  lowercase: boolean;
  capitalize: boolean;
  strikethrough: boolean;
  subscript: boolean;
  superscript: boolean;
  code: boolean;
  link: boolean;
  aiChat: boolean;
  comment: boolean;
  improve: boolean;
}

Autocomplete Configuration

autocompleteOptions: {
  minMatchLength: number;    // Minimum characters to trigger
  maxSuggestions: number;    // Maximum suggestions to show
}

Keyboard Shortcuts

Text Formatting

BoldCtrl/Cmd + B
ItalicCtrl/Cmd + I
UnderlineCtrl/Cmd + U
StrikethroughCtrl/Cmd + Shift + S
Insert LinkCtrl/Cmd + K

Block Formatting

Heading 1Ctrl/Cmd + Shift + 1
Heading 2Ctrl/Cmd + Shift + 2
Bullet ListCtrl/Cmd + Shift + 8
Numbered ListCtrl/Cmd + Shift + 7
ChecklistCtrl/Cmd + Shift + 9
Quote BlockCtrl/Cmd + Shift + >
Code BlockCtrl/Cmd + Shift + `

General

UndoCtrl/Cmd + Z
RedoCtrl/Cmd + Y
Select AllCtrl/Cmd + A
CopyCtrl/Cmd + C
PasteCtrl/Cmd + V
CutCtrl/Cmd + X

Text Alignment

Align LeftCtrl/Cmd + Shift + L
Align CenterCtrl/Cmd + Shift + E
Align RightCtrl/Cmd + Shift + R
JustifyCtrl/Cmd + Shift + J

API Reference

EditorProvider

Provides authentication and configuration context for the editor.

Props

PropTypeRequiredDescription
childrenReactNodeYesReact nodes to render
defaultFontFamiliesstring[]NoArray of font names
currentUserCurrentUserNoCurrent logged-in user for comments

CurrentUser Type

interface CurrentUser {
  id: string;
  name: string;
  email: string;
  avatar?: string; // optional
}

ConfigurableEditorWithAuth

The main editor component with authentication.

Props

PropTypeRequiredDescription
apiKeystringYesYour API key for authentication
initialContentstringNoInitial HTML content for the editor
onChangefunctionNoCallback when content changes (receives HTML string)
defaultFontFamiliesstring[]NoArray of font names for font selector
mentionUserListstring[]NoArray of usernames for mention functionality
onAuthSuccessfunctionNoCallback when authentication is successful
onAuthErrorfunctionNoCallback when authentication fails
customVerifyKeyfunctionNoCustom function to verify API key

Code Examples

Basic Editor with Authentication

import React from 'react';
import { ConfigurableEditorWithAuth, EditorProvider } from 'ct-rich-text-editor';
import 'ct-rich-text-editor/style.css';

function App() {
  return (
    <EditorProvider>
      <ConfigurableEditorWithAuth
        apiKey="your-api-key"
        onAuthSuccess={() => console.log('Authenticated')}
        onAuthError={(error) => console.error(error)}
      />
    </EditorProvider>
  );
}

Editor with Content Handling

import React, { useState } from 'react';
import { ConfigurableEditorWithAuth, EditorProvider } from 'ct-rich-text-editor';
import 'ct-rich-text-editor/style.css';

function App() {
  const [editorContent, setEditorContent] = useState('');

  const handleContentChange = (html) => {
    setEditorContent(html);
    console.log('Current content:', html);
  };

  const handleSave = () => {
    localStorage.setItem('saved-content', editorContent);
    console.log('Content saved!');
  };

  const loadSavedContent = () => {
    return localStorage.getItem('saved-content') || '<p>Start writing...</p>';
  };

  return (
    <div>
      <EditorProvider>
        <ConfigurableEditorWithAuth
          apiKey="your-api-key"
          initialContent={loadSavedContent()}
          onChange={handleContentChange}
          defaultFontFamilies={['Arial', 'Helvetica', 'Times New Roman']}
          mentionUserList={['@john', '@jane', '@bob']}
          onAuthSuccess={() => console.log('Ready to edit!')}
          onAuthError={(error) => console.error('Auth failed:', error)}
        />
      </EditorProvider>

      <button onClick={handleSave}>
        Save Content
      </button>

      <div>
        <h3>Current HTML Content:</h3>
        <pre>{editorContent}</pre>
      </div>
    </div>
  );
}

Custom API Key Verification

import React from 'react';
import { ConfigurableEditorWithAuth, EditorProvider } from 'ct-rich-text-editor';
import 'ct-rich-text-editor/style.css';

function App() {
  const customVerifyKey = async (apiKey) => {
    try {
      const response = await fetch('/api/verify-key', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ apiKey })
      });

      const data = await response.json();

      return {
        success: data.valid,
        message: data.message || 'API key verified'
      };
    } catch (error) {
      return {
        success: false,
        message: 'Failed to verify API key'
      };
    }
  };

  return (
    <EditorProvider>
      <ConfigurableEditorWithAuth
        apiKey="your-api-key"
        customVerifyKey={customVerifyKey}
        onChange={(html) => console.log('Content changed:', html)}
      />
    </EditorProvider>
  );
}

Support & Resources

Need Help?

Our support team is here to assist you with any questions or issues.

Contact Support

Try Before You Buy

Test the editor on our homepage to see all features in action.

View Live Demo

Get Your API Key

Sign up and get your API key from the dashboard.

Access Dashboard

Pricing

View our flexible pricing plans with 2 weeks free premium trial.

View Pricing

License

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