# @dimarborda/docx-editor 中文文档

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

版本：0\.19\.3
npm 元数据更新时间：2026-11-10T21:51:12.614Z
中文译文更新时间：2026-11-12T09:50:28.267Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：2.8 MB，26 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：7 个
- 首次发布：2026-10-07T16:09:11.271Z
- 最新版本发布：2026-11-10T21:51:12.437Z
- 近 30 天下载量：3417（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：32（近 12 个月 32 个）

## 中文简介

浏览器的Word (.docx) 编辑器: Rust + WebAssembly 排版引擎为画布所提供,作为框架-不可知的网页组件. 一个AI代理可以在用户继续工作时通过它的API编辑

## 安装

```sh
npm install @dimarborda/docx-editor
```

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

## README

# @dimarborda/docx编辑器

[![npm](https://img.shields.io/npm/v/@dimarborda/docx-editor?color=cb3837&label=npm)](https://www.npmjs.com/package/@dimarborda/docx-editor)

单词( E)`.docx`) 为浏览器编辑. 一个 Rust 和 Web Assembly 引擎读取了文档,将页面排出像 Word 一样,并应用了毫无损失地编辑. 它与React,Vue,Svelte,Angular或plain HTML一起工作,并在Tauri等桌面应用中工作. 它不需要服务器: 库将文档发送到任何地方 .

对于AI特工, `markers()` 列出要填入的剩余内容,并通过API进行编辑时会突出显示,而不移动用户的守护.

[演示](https://rust-web-docx.dimarborda.workers.dev/?demo) • 妇女 **GitHub 的完整文档 :** [联合国](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/en/api.md) • 妇女 [西班牙语Name](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/es/api.md)

## 安装

```bash
npm install @dimarborda/docx-editor
```

```html
<docx-toolbar for="doc"></docx-toolbar>
<docx-editor id="doc" src="/templates/contract.docx" style="height: 80vh"></docx-editor>

<script type="module">
  import '@dimarborda/docx-editor';          // registers <docx-editor> and <docx-toolbar>
  import '@dimarborda/docx-editor/style.css';
  import '@dimarborda/docx-editor/fonts';    // optional: stand-ins for Calibri, Cambria, Arial…

  const editor = await document.getElementById('doc').whenReady();
  editor.replaceVariables({ CLIENT: 'Acme Inc.', DATE: 'October 7, 2026' });
</script>
```

容器需要一个高度。 包含类型脚本。 如果你的应用程序发送 `Content-Security-Policy`,生产 `script-src` 需求 `'wasm-unsafe-eval'`。 。 。 .

## 用代码

```js
import { DocxEditor } from '@dimarborda/docx-editor';
import '@dimarborda/docx-editor/style.css';

const editor = await DocxEditor.create(document.querySelector('#editor'), { locale: 'en' });

await editor.open(file);                       // File, Blob, ArrayBuffer or Uint8Array
editor.replaceVariables({ CLIENT: 'Acme' });   // fills {{CLIENT}}, {CLIENT}…
editor.insertParagraphs(['The parties agree as follows.'], { at: 'end' });
await editor.downloadPdf('contract.pdf');      // vector PDF with selectable text
const bytes = editor.save();                   // Uint8Array of the edited .docx
```

## 特征

-   **模板和标记 :** 列表并填入 `{{KEY}}`, (中文(简体) ), `{key}` 待定 `[…]` 内容,保留格式.
-   **代理活动 :** `markActivity()` 显示代理人的工作位置.
-   **内容 :** 段落、表格、图像、文本框、逻辑部分和现有表格,来自代码.
-   **格式化 :** 样式、字体、字符格式化、对齐、间隔、缩进和列表,写作Word的方式.
-   **导出 :** 无损失 `.docx` 和带有工作链接的矢量PDF.
-   **视图 :** 仅读模式、缩放、水印和可选工具栏.

## 文档

| 指南 | 联合国 | 西班牙语Name |
| :-- | :-- | :-- |
| API: 每一种方法、选项和事件 | [api 密码](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/en/api.md) | [api 密码](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/es/api.md) |
| 指南:标记、代理、段落、表格、PDF、图像 | [指南](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/en/guides.md) | [指南](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/es/guides.md) |
| 反应, Next.js, Tauri, 字体、样式、捆绑器 | [整合](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/en/integrations.md) | [整合](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/es/integrations.md) |
| 安全和限制 | [警卫](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/en/security.md) | [警卫](https://github.com/dimarborda/rust-web-docx/blob/master/docs/docx-editor/es/security.md) |

图书馆将您的文档无处发送, 并且从未执行它们的内容 . [报告脆弱性](https://github.com/dimarborda/rust-web-docx/blob/master/SECURITY.md)。 。 。 .

## 对于 AI 编码代理

货船 [`AGENTS.md`](https://github.com/dimarborda/rust-web-docx/blob/master/packages/docx-editor/AGENTS.md):为编码代理撰写的关于API,其惯例和陷阱的紧凑指南. 让你的经纪人在使用软件包的项目中加载,请参考 `AGENTS.md` 或者说 `CLAUDE.md`数字 :

```md
@node_modules/@dimarborda/docx-editor/AGENTS.md
```

两个图书馆的概况也载于 [页:1](https://rust-web-docx.dimarborda.workers.dev/llms.txt) 满分 [llms- full.txt (英语)](https://rust-web-docx.dimarborda.workers.dev/llms-full.txt)。 。 。 .

## 许可证

麻省理工学院

## 常见问题

### @dimarborda/docx-editor 是什么？

浏览器的Word \(\.docx\) 编辑器: Rust \+ WebAssembly 排版引擎为画布所提供,作为框架-不可知的网页组件\. 一个AI代理可以在用户继续工作时通过它的API编辑

### 如何安装 @dimarborda/docx-editor？

在项目目录运行 npm install @dimarborda/docx-editor，或使用 pnpm add / yarn add / bun add。

### @dimarborda/docx-editor 支持 TypeScript 吗？

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

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

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

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

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

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

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

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

最新版本 0\.19\.3 发布于 2026/11/11（1 天前）；至今共发布 32 个版本，其中过去 12 个月发布了 32 个；首次发布于 2026/10/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

