A configurable rich text editor component with API key authentication
Install the editor package using npm or yarn:
npm install ct-rich-text-editor# oryarn add ct-rich-text-editorTo ensure proper styling of the editor components including tables, you must import the package's CSS:
import 'ct-rich-text-editor/style.css';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>
);
}The CT Rich Text Editor requires an API key for authentication. Follow these steps to get started:
Get 2 weeks of free premium access when you sign up! Experience all premium features including AI chat integration.
Bold, italic, underline, strikethrough, subscript, superscript
Text color and background color with color picker
20+ font families and font size controls
Left, center, right, and justify alignment options
Custom bullet styles with proper indentation
Decimal, Alpha, Roman numbering formats
Interactive checkboxes with line-through styling
Multi-level lists with proper indentation
Insert/delete rows and columns, merge/split cells
Hover actions, cell resizing, table alignment
Header row styling with background colors
Tables that adapt to different screen sizes
Drag-and-drop upload, resizing with 8-point handles
Upload and attach files with download links
Rich embeds for external content and media
Floating link editor for easy link management
Premium feature: AI-powered content assistance
AI-powered suggestions and content completion
Real-time grammar and style suggestions
AI-powered text improvement and rephrasing
Change text tone: formal, casual, professional
Generate images from text descriptions
Quick formatting with / commands
Info, warning, error, success panels
Syntax highlighting for code blocks
Insert and edit interactive charts
Canvas-based signature functionality
Voice input and transcription support
Mention users with @ symbol
Export content with proper formatting
Switch between rich text and HTML code view
Extensible plugin system for custom features
Full keyboard shortcut support for all operations
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
}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;
}autocompleteOptions: {
minMatchLength: number; // Minimum characters to trigger
maxSuggestions: number; // Maximum suggestions to show
}Ctrl/Cmd + BCtrl/Cmd + ICtrl/Cmd + UCtrl/Cmd + Shift + SCtrl/Cmd + KCtrl/Cmd + Shift + 1Ctrl/Cmd + Shift + 2Ctrl/Cmd + Shift + 8Ctrl/Cmd + Shift + 7Ctrl/Cmd + Shift + 9Ctrl/Cmd + Shift + >Ctrl/Cmd + Shift + `Ctrl/Cmd + ZCtrl/Cmd + YCtrl/Cmd + ACtrl/Cmd + CCtrl/Cmd + VCtrl/Cmd + XCtrl/Cmd + Shift + LCtrl/Cmd + Shift + ECtrl/Cmd + Shift + RCtrl/Cmd + Shift + JProvides authentication and configuration context for the editor.
| Prop | Type | Required | Description |
|---|---|---|---|
| children | ReactNode | Yes | React nodes to render |
| defaultFontFamilies | string[] | No | Array of font names |
| currentUser | CurrentUser | No | Current logged-in user for comments |
interface CurrentUser {
id: string;
name: string;
email: string;
avatar?: string; // optional
}The main editor component with authentication.
| Prop | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Yes | Your API key for authentication |
| initialContent | string | No | Initial HTML content for the editor |
| onChange | function | No | Callback when content changes (receives HTML string) |
| defaultFontFamilies | string[] | No | Array of font names for font selector |
| mentionUserList | string[] | No | Array of usernames for mention functionality |
| onAuthSuccess | function | No | Callback when authentication is successful |
| onAuthError | function | No | Callback when authentication fails |
| customVerifyKey | function | No | Custom function to verify API key |
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>
);
}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>
);
}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>
);
}This project is licensed under the MIT License - see the LICENSE file for details.