tiptap
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTiptap Rich Text Editor
Tiptap 富文本编辑器
Overview
概述
Tiptap is a headless rich text editor built on ProseMirror, providing a modular extension system for React applications. It supports React 19, Tailwind v4, and SSR frameworks like Next.js. Use when building blog editors, comment systems, documentation tools, or Notion-like collaborative apps. Do NOT use with Create React App (CRA is incompatible with Tiptap v3 ESM module structure; use Vite instead).
Tiptap是基于ProseMirror构建的无头富文本编辑器,为React应用提供模块化扩展系统。它支持React 19、Tailwind v4以及Next.js等SSR框架。适用于构建博客编辑器、评论系统、文档工具或类Notion的协同应用。请勿与Create React App(CRA)配合使用(CRA与Tiptap v3的ESM模块结构不兼容,请改用Vite)。
Quick Reference
快速参考
| Pattern | API / Key Point |
|---|---|
| Create editor | |
| Render editor | |
| Prose styling | Add |
| Configure StarterKit | |
| Disable undo/redo | |
| Image upload | Set |
| Markdown support | |
| shadcn component | |
| Null guard | |
| 模式 | API / 关键点 |
|---|---|
| 创建编辑器 | |
| 渲染编辑器 | |
| 文档样式 | 为容器添加 |
| 配置StarterKit | |
| 禁用撤销/重做 | |
| 图片上传 | 设置 |
| Markdown支持 | |
| shadcn组件 | |
| 空值校验 | |
Core Dependencies
核心依赖
| Package | Purpose |
|---|---|
| React integration (React 19 supported since v2.10.0) |
| Bundled extensions: marks, nodes, and functionality |
| ProseMirror peer dependency (required, not auto-installed) |
| Prose styling for headings, lists, links |
| 包 | 用途 |
|---|---|
| React集成(v2.10.0起支持React 19) |
| 捆绑扩展:标记、节点及功能 |
| ProseMirror对等依赖(必需,不会自动安装) |
| 为标题、列表、链接提供文档样式 |
StarterKit v3 Contents
StarterKit v3 包含内容
| Category | Included |
|---|---|
| Marks | Bold, Italic, Strike, Code, Link (v3), Underline (v3) |
| Nodes | Document, Paragraph, Text, Heading, BulletList, OrderedList, ListItem, Blockquote, CodeBlock, HorizontalRule, HardBreak |
| Functionality | Undo/Redo, Dropcursor, Gapcursor, ListKeymap (v3), TrailingNode (v3) |
| 分类 | 包含内容 |
|---|---|
| 标记 | Bold、Italic、Strike、Code、Link(v3)、Underline(v3) |
| 节点 | Document、Paragraph、Text、Heading、BulletList、OrderedList、ListItem、Blockquote、CodeBlock、HorizontalRule、HardBreak |
| 功能 | Undo/Redo、Dropcursor、Gapcursor、ListKeymap(v3)、TrailingNode(v3) |
Common Additional Extensions
常用附加扩展
| Extension | Package | Use Case |
|---|---|---|
| Image | | Image support with resize |
| Color | | Text color (requires TextStyle) |
| Typography | | Smart quotes, dashes, ellipsis |
| Placeholder | | Placeholder text (requires CSS) |
| Table | | Table support (+ Row, Cell, Header) |
| TaskList | | Checkbox task lists |
| CodeBlockLowlight | | Syntax-highlighted code |
| Collaboration | | Real-time multi-user editing (Y.js) |
| Markdown | | Bidirectional markdown (open-source) |
| 扩展 | 包 | 适用场景 |
|---|---|---|
| Image | | 支持缩放的图片功能 |
| Color | | 文本颜色(需要TextStyle扩展) |
| Typography | | 智能引号、破折号、省略号 |
| Placeholder | | 占位符文本(需要CSS支持) |
| Table | | 表格支持(+行、单元格、表头) |
| TaskList | | 复选框任务列表 |
| CodeBlockLowlight | | 带语法高亮的代码块 |
| Collaboration | | 实时多用户编辑(Y.js) |
| Markdown | | 双向Markdown支持(开源) |
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
Missing | Add to |
No | Add |
| Images stored as base64 | Set |
| Using EditorProvider + useEditor together | Choose one — EditorProvider wraps useEditor internally |
| Undo/Redo enabled with Collaboration | Set |
| ProseMirror version conflicts | Add |
| Using Create React App | Switch to Vite — CRA incompatible with v3 ESM modules |
Not checking | |
Using | Config key renamed to |
Importing | Correct package is |
| 错误 | 修复方案 |
|---|---|
缺少 | 在 |
编辑器容器未添加 | 添加 |
| 图片以base64格式存储 | 设置 |
| 同时使用EditorProvider和useEditor | 二选一 — EditorProvider内部已封装useEditor |
| 协同编辑时启用了撤销/重做 | 使用Y.js时,在StarterKit中设置 |
| ProseMirror版本冲突 | 在package.json中为prosemirror-model/view/state添加 |
| 使用Create React App | 切换到Vite — CRA与v3 ESM模块不兼容 |
未检查 | |
为协同编辑设置 | v3中配置项已重命名为 |
导入 | 正确的包是 |
Delegation
相关参考
- Tailwind styling: see skill
tailwind - Form integration: see skill
tanstack-form
- Tailwind样式:参考技能文档
tailwind - 表单集成:参考技能文档
tanstack-form
References
参考链接
- Setup and Configuration
- Extensions Catalog
- Image Upload
- Patterns
- Known Issues and Errors
- Prose Styling
- 配置与设置
- 扩展目录
- 图片上传
- 设计模式
- 已知问题与错误
- 文档样式