Witch Text Editor Documentation
A powerful, extensible rich text editor built with Tiptap and React. Learn how to integrate it into your project.
Getting Started
Witch Text Editor is a feature-rich, split-panel editor with real-time preview, designed for blog posts, documentation, and content creation. It includes advanced features like image cropping, code syntax highlighting, and markdown export.
Code Blocks
Syntax highlighting with 25+ languages
Image Editor
Crop, resize, and upload multiple images
Markdown Export
Export your content as clean markdown
Installation
1. Clone the repository
git clone https://github.com/AviOfLagos/Witch-text-editor.git
cd witch-text-editor2. Install dependencies
npm install3. Run the development server
npm run devOpen http://localhost:3000 in your browser to see the editor.
Features
Rich Text Formatting
Bold, italic, underline, strikethrough, highlight, and more
Code Blocks with Syntax Highlighting
Language selector with 25+ programming languages and one-click copy
Advanced Image Editor
Upload, crop, resize with aspect ratio lock, multi-image support
Resizable Tables
Create and manipulate tables with add/delete rows and columns
Embed Support
YouTube, Vimeo, Twitter, Spotify, CodePen, and generic iframes
Lists and Checklists
Bullet lists, numbered lists, and interactive task lists
Text Formatting
The editor supports a wide range of text formatting options accessible via the toolbar or keyboard shortcuts.
| Format | Shortcut | Description |
|---|---|---|
| Bold | Ctrl + B | Make text bold |
| Italic | Ctrl + I | Make text italic |
| Underline | Ctrl + U | Underline text |
| - | Strike through text | |
| Highlight | - | Highlight text |
Inline Code | Ctrl + E | Format as inline code |
Code Blocks
Code blocks feature syntax highlighting with support for 25+ programming languages. Each block includes a language selector dropdown and a copy button. Multi-language code blocks allow users to switch between different language implementations.
Supported Languages
Multi-Language Code Blocks
Display the same functionality in multiple languages with tabbed navigation. Users can switch between languages and copy the code for their preferred language.
API Usage Example
1// Fetch data from API2async function fetchData() {3 const response = await fetch('/api/data');4 const data = await response.json();5 return data;6}Single Language Block
For single-language examples, the tabs are hidden automatically.
1function greet(name) {2 return `Hello, ${name}!`;3}45console.log(greet('World'));Usage
Click the code block button in the toolbar or use the keyboard shortcut. Select your language from the dropdown in the top-left of the code block.
Images
The image editor provides powerful tools for managing images in your content.
Features
- Upload from computer - Select one or multiple images at once
- URL import - Add images from any public URL
- Cropping - Drag to select crop area with resize handles
- Resizing - Adjust dimensions with optional aspect ratio lock
- Alt text - Add accessibility descriptions
- Cloud upload simulation - Images are processed for cloud storage URLs
Tables
Create and manipulate tables with the table dropdown menu.
Table Operations
- Insert a 3x3 table with header row
- Add columns before or after the current column
- Add rows before or after the current row
- Delete columns, rows, or the entire table
- Resize columns by dragging the edges
Embeds
Embed content from various platforms directly into your editor.
Supported Platforms
YouTube
Paste any YouTube video URL
Vimeo
Embed Vimeo videos
Twitter / X
Embed tweets
Spotify
Embed tracks, albums, playlists
CodePen
Embed CodePen projects
Generic iFrame
Any embeddable URL
Keyboard Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Bold | Ctrl + B | Cmd + B |
| Italic | Ctrl + I | Cmd + I |
| Underline | Ctrl + U | Cmd + U |
| Inline Code | Ctrl + E | Cmd + E |
| Link | Ctrl + K | Cmd + K |
| Undo | Ctrl + Z | Cmd + Z |
| Redo | Ctrl + Y | Cmd + Shift + Z |
| Save | Ctrl + S | Cmd + S |
| Export Markdown | Ctrl + Shift + E | Cmd + Shift + E |
API Reference
Editor Component Props
interface EditorProps {
content: string // HTML content to display
onChange: (content: string) => void // Called when content changes
onUpdate?: () => void // Called on any editor update
}Basic Usage
import { Editor } from '@/components/editor'
import { Preview } from '@/components/preview'
export default function MyEditor() {
const [content, setContent] = useState('<p>Hello World</p>')
return (
<div className="flex">
<Editor content={content} onChange={setContent} />
<Preview content={content} />
</div>
)
}Markdown Export
import { htmlToMarkdown, downloadMarkdown, copyToClipboard } from '@/lib/markdown'
// Convert HTML to Markdown
const markdown = htmlToMarkdown(content)
// Download as .md file
downloadMarkdown(markdown, 'my-post.md')
// Copy to clipboard
await copyToClipboard(markdown)