# @eigenpal/docx-editor-react 中文文档

规范地址：https://npmcn.com/package/%40eigenpal/docx-editor-react/

版本：1\.9\.0
npm 元数据更新时间：2026-06-29T21:04:51.082Z
中文译文更新时间：2026-11-13T09:38:23.454Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40eigenpal/docx-editor-react
原文对照：https://npmcn.com/package/%40eigenpal/docx-editor-react/?lang=original
项目主页：https://docx-editor.dev/
源码仓库：https://github.com/eigenpal/docx-editor

弃用说明：deprecated

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.4 MB，78 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：6 个
- peer 依赖：react ^18\.0\.0 \|\| ^19\.0\.0，react-dom ^18\.0\.0 \|\| ^19\.0\.0，prosemirror-view ^1\.41\.6，prosemirror-model ^1\.19\.4，prosemirror-state ^1\.4\.3，prosemirror-keymap ^1\.2\.2，prosemirror-tables ^1\.8\.5，prosemirror-history ^1\.4\.0，prosemirror-commands ^1\.5\.2，prosemirror-transform ^1\.12\.0，prosemirror-dropcursor ^1\.8\.2
- 首次发布：2026-05-19T10:09:39.676Z
- 最新版本发布：2026-06-21T15:55:16.341Z
- 近 30 天下载量：187252（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：23（近 12 个月 23 个）

## 中文简介

反应 DOCX 编辑器适配器,用于@eigenpal/docx-editor-core.

## 安装

```sh
npm install @eigenpal/docx-editor-react
```

也可以使用：`pnpm add @eigenpal/docx-editor-react`、`yarn add @eigenpal/docx-editor-react`、`bun add @eigenpal/docx-editor-react`

## README

[![DOCX Editor — .docx in, .docx out. Open source, agent ready, client-side.](https://raw.githubusercontent.com/eigenpal/docx-editor/main/.github/assets/header.png)](https://www.docx-editor.dev/)

[![npm version](https://img.shields.io/npm/v/@eigenpal/docx-editor-react.svg?style=flat-square&color=3B5BDB)](https://www.npmjs.com/package/@eigenpal/docx-editor-react) [![npm downloads](https://img.shields.io/npm/dm/@eigenpal/docx-editor-react.svg?style=flat-square&color=3B5BDB)](https://www.npmjs.com/package/@eigenpal/docx-editor-react) [![license](https://img.shields.io/badge/license-Apache_2.0-blue.svg?style=flat-square&color=3B5BDB)](https://github.com/eigenpal/docx-editor/blob/main/LICENSE) [![Demo](https://img.shields.io/badge/Live_Demo-3B5BDB?style=flat-square&logo=vercel&logoColor=white)](https://docx-editor.dev/editor) [![Documentation](https://img.shields.io/badge/Docs-3B5BDB?style=flat-square&logo=readthedocs&logoColor=white)](https://www.docx-editor.dev/docs)

# @eigenpal/docx-editor-反应

反应适配器 [docx 编辑器](https://docx-editor.dev/)WYSIWYYG (英语) `.docx` 由Cononical OOXML编辑,跟踪更改,评论,实时协作,以及AI代理桥.

## 快速启动

```bash
npm install @eigenpal/docx-editor-react
```

```tsx
import { useState } from 'react';
import { DocxEditor } from '@eigenpal/docx-editor-react';
import '@eigenpal/docx-editor-react/styles.css';

export function App() {
  const [buffer, setBuffer] = useState<ArrayBuffer | null>(null);

  return (
    <>
      <input
        type="file"
        accept=".docx"
        onChange={async (e) => setBuffer((await e.target.files?.[0]?.arrayBuffer()) ?? null)}
      />
      {buffer && <DocxEditor documentBuffer={buffer} mode="editing" />}
    </>
  );
}
```

> **下一个.js/安保部门改革:** 使用动态导入 。 编辑需要DOM.

## 从空白文档开始

为新文档跳过文件拾取器 . `createEmptyDocument` 返回新鲜 `Document` 您可以直接传递给编辑器的模型 :

```tsx
import { DocxEditor, createEmptyDocument } from '@eigenpal/docx-editor-react';
import '@eigenpal/docx-editor-react/styles.css';

const doc = createEmptyDocument();
// Or with options:
// createEmptyDocument({ initialText: 'Untitled', pageWidth: 12240 })

<DocxEditor document={doc} mode="editing" />;
```

`createDocumentWithText(text, options?)` 也是同样的想法,开头的段落已经输入。 两名助手从 `@eigenpal/docx-editor-core` 所以,你不需要 一个单独的依赖.

## 自定义文件 > 打开

默认情况下,内置 `File > Open` 和 Cmd/Ctrl+O 催化 `.docx` 文件并装入本地编辑器视图。 过 `onOpen` 来保留本地文件拾取器,但路径 `File` 通过您自己的进口管道:

```tsx
<DocxEditor
  document={doc}
  externalContent
  externalPlugins={plugins}
  onOpen={async (file) => {
    await importIntoBackend(file);
  }}
/>
```

设定 `showFileOpen={false}` 以隐藏内置的打开项目并离开 Cmd/Ctrl+ O为您自己的菜单或工具栏.

## 软件包

| 软件包 | 说明 |
| --- | --- |
| [`@eigenpal/docx-editor-react`](https://www.npmjs.com/package/@eigenpal/docx-editor-react) | ![](https://cdn.simpleicons.org/react/61DAFB)   反应适配器. 工具栏 页面编辑器 插件. |
| [`@eigenpal/docx-editor-vue`](https://www.npmjs.com/package/@eigenpal/docx-editor-vue) | ![](https://cdn.simpleicons.org/vuedotjs/4FC08D)   Vue 3适配器. 工具栏 页面编辑器 插件. |
| [`@eigenpal/docx-editor-core`](https://www.npmjs.com/package/@eigenpal/docx-editor-core) | 框架-不可知核:OOXML 解析器,序列器,布局引擎,ProseMirror schema. 取决于此, 如果您要叉出反应或 Vue 适配器 . |
| [`@eigenpal/docx-editor-i18n`](https://www.npmjs.com/package/@eigenpal/docx-editor-i18n) | 两个适配器消耗的共享地块串和类型. |
| [`@eigenpal/docx-editor-agents`](https://www.npmjs.com/package/@eigenpal/docx-editor-agents) | 代理SDK和聊天UI:框架-不可知桥,MCP服务器,AI SDK适配器,外加React UI. |

> **伪造适配器?** 取出叉子细. 取决于 `@eigenpal/docx-editor-core` 直接如此解析器,序列器, 和渲染自动修复您的建筑中的地块, 不回转每个上游变化的手.

## 强制安装

```ts
import { renderAsync } from '@eigenpal/docx-editor-react';

const editor = await renderAsync(file, document.getElementById('editor')!, { mode: 'editing' });
await editor.save();
editor.destroy();
```

## 子路径

-   `@eigenpal/docx-editor-react` —— 说 `DocxEditor`, (中文(简体) ), `renderAsync`公共类型
-   `@eigenpal/docx-editor-react/ui` – 工具栏原始人,拾取者,侧边栏,对话框
-   `@eigenpal/docx-editor-react/hooks` —— 说 `useAutoSave`, (中文(简体) ), `useTableSelection`,, , , , , , , , .
-   `@eigenpal/docx-editor-react/dialogs` - 对话框组件桶
-   `@eigenpal/docx-editor-react/plugin-api` — 插件主机和插件配置类型
-   `@eigenpal/docx-editor-react/styles` ——风格常数(`EDITOR_CSS_PATH`,z指数)

## 插件

```tsx
import { DocxEditor } from '@eigenpal/docx-editor-react';
import { PluginHost, templatePlugin } from '@eigenpal/docx-editor-react/plugin-api';

<PluginHost plugins={[templatePlugin]}>
  <DocxEditor documentBuffer={buffer} />
</PluginHost>;
```

## 组件 API

完整道具和参考文献: **[docx-editor.dev/docs/道具](https://www.docx-editor.dev/docs/props)**。 。 。 . `DocxEditor` 财务报告和审定财务报表 `DocxEditorRef` 镜像 Vue 适配器, 因此只应用已互换的导入路径 .

`@eigenpal/docx-editor-core` 以中转方式安装。 把它加进你的 `package.json` 只有您自己的代码直接导入核心 API 。 严格安装器, 如 pnpm , 已禁用相机自动安装 , 也可能需要 ProseMirror 的相机 `package.json`。 。 。 .

实例: [维特](https://github.com/eigenpal/docx-editor/tree/main/examples/vite) • 妇女 [下一个.js](https://github.com/eigenpal/docx-editor/tree/main/examples/nextjs) • 妇女 [重混合](https://github.com/eigenpal/docx-editor/tree/main/examples/remix) • 妇女 [天体](https://github.com/eigenpal/docx-editor/tree/main/examples/astro)

## 捐款

欢迎捐款。 见 [捐款额](https://github.com/eigenpal/docx-editor/blob/main/CONTRIBUTING.md) 用于设置,测试,以及一次性CLA签名.

## 商业支助

> \[TIP\] 问题还是习惯特征? 电子邮件 **[docx-编辑器@eigenpal.com](mailto:docx-editor@eigenpal.com)**。 。 。 .

## 常见问题

### @eigenpal/docx-editor-react 是什么？

反应 DOCX 编辑器适配器,用于@eigenpal/docx-editor-core\.注意：该包已被作者标记为弃用——deprecated

### 如何安装 @eigenpal/docx-editor-react？

在项目目录运行 npm install @eigenpal/docx-editor-react，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：prosemirror-view（^1\.41\.6）、prosemirror-model（^1\.19\.4）、prosemirror-state（^1\.4\.3）、prosemirror-keymap（^1\.2\.2）、prosemirror-tables（^1\.8\.5）、prosemirror-history（^1\.4\.0）、prosemirror-commands（^1\.5\.2）、prosemirror-transform（^1\.12\.0）、prosemirror-dropcursor（^1\.8\.2）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @eigenpal/docx-editor-react 支持 TypeScript 吗？

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

### @eigenpal/docx-editor-react 支持 ESM 还是 CommonJS？

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

### @eigenpal/docx-editor-react 可以商用吗？

@eigenpal/docx-editor-react 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @eigenpal/docx-editor-react 的下载量有多少？

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

### @eigenpal/docx-editor-react 还在维护吗？

最新版本 1\.9\.0 发布于 2026/06/21（4 个月前）；至今共发布 23 个版本，其中过去 12 个月发布了 23 个；首次发布于 2026/05/19。作者已将其标记为弃用，新项目建议寻找替代方案。

