HomeDocumentation

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

Bash/Shell
git clone https://github.com/AviOfLagos/Witch-text-editor.git
cd witch-text-editor

2. Install dependencies

npm install

3. Run the development server

npm run dev

Open 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.

FormatShortcutDescription
BoldCtrl + BMake text bold
ItalicCtrl + IMake text italic
UnderlineCtrl + UUnderline text
Strikethrough-Strike through text
Highlight-Highlight text
Inline CodeCtrl + EFormat 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

JavaScriptTypeScriptPythonJavaC++GoRustRubyPHPSQLHTMLCSSJSONYAMLBash+10 more

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 API
2async 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.

JavaScript
1function greet(name) {
2 return `Hello, ${name}!`;
3}
4
5console.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

ActionWindows/LinuxMac
BoldCtrl + BCmd + B
ItalicCtrl + ICmd + I
UnderlineCtrl + UCmd + U
Inline CodeCtrl + ECmd + E
LinkCtrl + KCmd + K
UndoCtrl + ZCmd + Z
RedoCtrl + YCmd + Shift + Z
SaveCtrl + SCmd + S
Export MarkdownCtrl + Shift + ECmd + Shift + E

API Reference

Editor Component Props

TypeScript
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

TSX
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

TypeScript
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)