@eigenpal/docx-editor-react

中文文档
1.9.0发布于 2026/06/21Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 18.7万

React DOCX editor adapter for @eigenpal/docx-editor-core.

此软件包已被标记为弃用

deprecated

原始使用文档
文档目录10 节
  1. Quick Start
  2. Start with a blank document
  3. Customize File > Open
  4. Packages
  5. Imperative mounting
  6. Subpaths
  7. Plugins
  8. Component API
  9. Contributing
  10. Commercial Support

DOCX Editor — .docx in, .docx out. Open source, agent ready, client-side.

npm version npm downloads license Demo Documentation

@eigenpal/docx-editor-react

React adapter for the docx-editor. WYSIWYG .docx editing with canonical OOXML, tracked changes, comments, real-time collaboration, and an AI agent bridge.

Quick Start

npm install @eigenpal/docx-editor-react
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" />}
    </>
  );
}

Next.js / SSR: Use dynamic import. The editor requires the DOM.

Start with a blank document

Skip the file picker for new documents. createEmptyDocument returns a fresh Document model you can pass straight to the editor:

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?) is the same idea with a starting paragraph already typed. Both helpers are re-exported from @eigenpal/docx-editor-core so you don't need a separate dependency.

Customize File > Open

By default, the built-in File > Open item and Cmd/Ctrl+O prompt for a .docx file and load it into the local editor view. Pass onOpen to keep the native file picker but route the selected File through your own import pipeline instead:

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

Set showFileOpen={false} to hide the built-in Open item and leave Cmd/Ctrl+O for your own menu or toolbar.

Packages

PackageDescription
@eigenpal/docx-editor-react   React adapter. Toolbar, paged editor, plugins.
@eigenpal/docx-editor-vue   Vue 3 adapter. Toolbar, paged editor, plugins.
@eigenpal/docx-editor-coreFramework-agnostic core: OOXML parser, serializer, layout engine, ProseMirror schema. Depend on this if you fork the React or Vue adapter.
@eigenpal/docx-editor-i18nShared locale strings and types consumed by both adapters.
@eigenpal/docx-editor-agentsAgent SDK and chat UI: framework-agnostic bridge, MCP server, AI SDK adapters, plus React UI.

Forking the adapter? Keep your fork thin. Depend on @eigenpal/docx-editor-core directly so parser, serializer, and rendering fixes land in your build automatically, without backporting each upstream change by hand.

Imperative mounting

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

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

Subpaths

  • @eigenpal/docx-editor-react — DocxEditor, renderAsync, public types
  • @eigenpal/docx-editor-react/ui — toolbar primitives, pickers, sidebars, dialogs
  • @eigenpal/docx-editor-react/hooks — useAutoSave, useTableSelection, ...
  • @eigenpal/docx-editor-react/dialogs — dialog components barrel
  • @eigenpal/docx-editor-react/plugin-api — plugin host and plugin-facing types
  • @eigenpal/docx-editor-react/styles — style constants (EDITOR_CSS_PATH, z-index)

Plugins

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

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

Component API

Full props and ref reference: docx-editor.dev/docs/props. DocxEditor and DocxEditorRef mirror the Vue adapter, so docs apply with just the import path swapped.

@eigenpal/docx-editor-core is installed transitively. Add it to your package.json only if your own code imports core APIs directly. Strict installers like pnpm with peer auto-install disabled may also need the ProseMirror peers listed in package.json.

Examples: Vite · Next.js · Remix · Astro

Contributing

Contributions welcome. See CONTRIBUTING.md for setup, tests, and the one-time CLA signature.

Commercial Support

[!TIP] Questions or custom features? Email [email protected].

版本与发布记录

@eigenpal/docx-editor-react 共发布 23 个版本,首次发布于 2026/05/19;过去 12 个月发布了 23 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.9.0latest2026/06/214 个月前
1.8.32026/06/204 个月前
1.8.22026/06/194 个月前
1.8.12026/06/194 个月前
1.8.02026/06/194 个月前
1.7.02026/06/184 个月前

关于 @eigenpal/docx-editor-react 的常见问题

@eigenpal/docx-editor-react 是什么?

React DOCX editor adapter for @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。作者已将其标记为弃用,新项目建议寻找替代方案。