@appflowyinc/editor

中文文档
0.1.13发布于 2025/07/01MITTypeScriptESM + CJS近 30 天下载 9314

AppFlowy Web Editor

原始使用文档
文档目录16 节
  1. ✨ Features
  2. 📦 Installation
  3. 🚀 Quick Start
  4. 🎨 Custom Toolbar
  5. 📚 Apply Data
  6. 💡 Theme Switching
  7. 🌍 Multi-language Usage
  8. Supported Languages
  9. 📖 API
  10. Editor Props
  11. EditorProvider Props
  12. EditorData
  13. NodeType
  14. Hooks
  15. 🔨 Development
  16. 📄 License

AppFlowy Web Editor

A modern editor library with support for rich text, markdown, and code editing.

✨ Features

  • 🌓 Day/Night mode switching
  • 🌍 Multi-language support
  • 📱 Responsive design
  • 💪 TypeScript support
  • 📝 Rich text, markdown, and code editing
  • 📦 Easy to integrate
  • 🎉 And more!

📦 Installation

To install the AppFlowy Web Editor, run the following command:

npm install @appflowyinc/editor

# or

yarn add @appflowyinc/editor

# or

pnpm add @appflowyinc/editor

Note: This package requires these peer dependencies to be installed:

"peerDependencies": {
    "i18next": "^22.4.10",
    "i18next-resources-to-backend": "^1.2.1",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-i18next": "^14.1.0",
    "slate": "^0.112.0",
    "slate-history": "^0.110.3",
    "slate-react": "^0.112.0"
}

🚀 Quick Start

To use the AppFlowy Web Editor, import the Editor and EditorProvider components from the package and wrap your app

Note: Using the editor requires the EditorProvider component. Therefore, each Editor component needs to be wrapped by the corresponding EditorProvider


import { Editor, EditorProvider } from '@appflowyinc/editor';

const App = () => {
  return <EditorProvider>
    <Editor/>
  </EditorProvider>
};

export default App;

🎨 Custom Toolbar

The AppFlowy Web Editor provides a toolbar with various options for editing content. You can customize the toolbar by passing the ToolbarComponent prop to the Editor component.

import { Editor, EditorProvider, FixedToolbar } from '@appflowyinc/editor';

const App = () => {
  return <EditorProvider>
    <Editor ToolbarComponent={FixedToolbar}/>
  </EditorProvider>;
};

export default App;

📚 Apply Data

You can get editor from the useEditor hook and apply data to the editor.

import { Editor, EditorProvider, useEditor, NodeType } from '@appflowyinc/editor';

const App = () => {
  const editor = useEditor();

  useEffect(() => {
    editor.applyData({
      type: NodeType.Paragraph,
      delta: [
        {
          insert: 'Hello, World!',
        },
      ],
      children: []
    });

    // or apply markdown
    editor.applyMarkdown('# Hello, World!');
  }, []);

  return
  <Editor/>;
};

const Main = () => {
  return <EditorProvider>
    <App/>
  </EditorProvider>;
};

export default App;

💡 Theme Switching

The AppFlowy Web Editor supports theme switching between light and dark modes. You can customize the themes by passing the theme prop to the Editor component.

import { Editor, EditorProvider } from '@appflowyinc/editor';

const App = () => {
  return <EditorProvider>
    <Editor theme={'dark'}/>
  </EditorProvider>;
};

export default App;

🌍 Multi-language Usage

The AppFlowy Web Editor supports multiple languages. You can customize the language by passing the language prop to the Editor component.


import { Editor, EditorProvider } from '@appflowyinc/editor';
// Optionally, you can import the language resources from the package
import zh from '@appflowyinc/editor/locales/zh-CN.json';

import hostI18n from 'i18next';

const App = () => {
  return <I18nextProvider i18n={hostI18n}>
    <EditorProvider>
      <Editor locale={{
        // The language code.
        lang: 'zh-CN',
        // Optionally, you can pass the language resources or let it use the default resources
        resources: zh,
      }}/>
    </EditorProvider>
  </I18nextProvider>;
};

export default App;

Supported Languages

  • English(en)
  • Arabic(ar-SA)
  • Catalan(ca-ES)
  • Central Kurdish(ckb-KU)
  • Czech(cs-CZ)
  • German(de-DE)
  • Spanish(es-VE)
  • Basque(eu-ES)
  • Persian(fa)
  • French(fr-CA)
  • French(fr-FR)
  • Hebrew(he)
  • Hungarian(hu-HU)
  • Indonesian(id-ID)
  • Italian(it-IT)
  • Japanese(ja-JP)
  • Korean(ko-KR)
  • Polish(pl-PL)
  • Brazilian Portuguese(pt-BR)
  • Portuguese(pt-PT)
  • Russian(ru-RU)
  • Swedish(sv-SE)
  • Thai(th-TH)
  • Turkish(tr-TR)
  • Ukrainian(uk-UA)
  • Vietnamese(vi)
  • Vietnamese(vi-VN)
  • Simplified Chinese(zh-CN)
  • Traditional Chinese(zh-TW)

📖 API

Editor Props

PropTypeDefaultDescription
theme'light' | 'dark''light'Editor theme
locale{ lang: string; resources?: Record<string, string> }-Editor language configuration
readOnlybooleanfalseWhether the editor is read-only
onChange(data: EditorData) => void-Callback when editor content changes
initialValueEditorData-Initial editor content
modalZIndexnumber50Editor modal z-index
ToolbarComponentFC-Custom toolbar component

EditorProvider Props

PropTypeDefaultDescription
childrenReactNode-The children components

EditorData

type EditorData = {
  type: NodeType;
  data: Record<string, any>;
  delta: DeltaOperation[];
  children: EditorData[];
};

NodeType


enum NodeType {
  Paragraph = 'paragraph',
  Heading = 'heading',
  NestedBlock = 'nested-block',
  Todo = 'todo_list',
  NumberedList = 'numbered_list',
  BulletedList = 'bulleted_list',
  Quote = 'quote',
}

Hooks

useEditor

Returns the editor instance with methods to control the editor.

const editor = useEditor();
MethodDescription
applyDataApply data to the editor
applyMarkdownApply markdown to the editor

🔨 Development

Guide

Development Mode


# Install dependencies

pnpm i

# Start development server

pnpm run dev

# Build library

pnpm run build

To run the demo locally:

pnpm install
pnpm run dev

Open http://localhost:5173/ with your browser to see the result. img.png

Switch between light and dark mode by clicking the theme switcher in the top right corner. img_1.png

📄 License

MIT License


[]: # (END) README.md


版本与发布记录

@appflowyinc/editor 共发布 54 个版本,首次发布于 2024/12/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.13latest2025/07/011.4 年前
0.1.122025/07/011.4 年前
0.1.112025/07/011.4 年前
0.1.102025/03/281.6 年前
0.1.92025/03/271.6 年前
0.1.82025/03/261.6 年前

关于 @appflowyinc/editor 的常见问题

@appflowyinc/editor 是什么?

AppFlowy Web Editor

如何安装 @appflowyinc/editor?

在项目目录运行 npm install @appflowyinc/editor,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:i18next(^22.4.10)、i18next-resources-to-backend(^1.2.1)、react(^18.3.1)、react-dom(^18.3.1)、react-i18next(^14.1.0)、slate(^0.112.0)、slate-history(^0.110.3)、slate-react(^0.112.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@appflowyinc/editor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@appflowyinc/editor 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@appflowyinc/editor 可以商用吗?

@appflowyinc/editor 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appflowyinc/editor 的下载量有多少?

根据 npm 官方下载统计,@appflowyinc/editor 在 2026/10/07 – 2026/11/05 这 30 天内被下载 9,314 次,日均约 310 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appflowyinc/editor 还在维护吗?

最新版本 0.1.13 发布于 2025/07/01(1.4 年前);至今共发布 54 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/12/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。