# @docling/docling-components 中文文档

规范地址：https://npmcn.com/package/%40docling/docling-components/

版本：0\.0\.11
npm 元数据更新时间：2026-10-06T07:40:26.062Z
中文译文更新时间：2026-11-13T05:09:35.382Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40docling/docling-components
原文对照：https://npmcn.com/package/%40docling/docling-components/?lang=original
项目主页：https://github.com/docling-project/docling-ts/tree/main/docling-components
源码仓库：https://github.com/docling-project/docling-ts

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

- 包体积（解压后）：201 kB，6 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：3 个
- 首次发布：2025-02-04T15:57:12.314Z
- 最新版本发布：2026-10-06T07:40:25.740Z
- 近 30 天下载量：2241（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 2 个）

## 中文简介

显示 Docling 输出的 Web 组件 .

## 安装

```sh
npm install @docling/docling-components
```

也可以使用：`pnpm add @docling/docling-components`、`yarn add @docling/docling-components`、`bun add @docling/docling-components`

## README

# 调制组件

用于显示Docling输出的Web组件,它简化了文档处理,解析了多种格式——包括高级PDF理解. 此软件包需要 JSON 输出转换为 [调试](https://docling.io/)。从 [互动实例](https://docling-project.github.io/docling-ts/examples)。 。 。 .

## 安装软件包

如果客户端或单页应用程序被捆绑在前面:

```sh
npm i @docling/docling-components
```

下一步, 导入应用程序根上的软件包以安装组件 :

```ts
import '@docling/docling-components';
```

如果一个静态或服务器侧实现的网站; 将软件包添加到页面 HTML 中 . 要么下载该软件包并将其作为其他网站的一部分,要么使用国家预防机制的CDN镜像:

```html
<html>
  <head>
    ...

    <script
      type="module"
      src="https://unpkg.com/@docling/docling-components/dist/index.es.js"
    />
  </head>

  ...
</html>
```

## 文件组件

### 标记-img

此组件通过显示在转换 JSON 中嵌入的完整页面渲染(用于特定的输入文档格式),在被转换的文档上下文中显示被转换的文档. 每个文档项目在页面上方显示为边框.

#### 专有用途

类似 `<img>` 您可以将组件指向 Docling JSON 文件.

```html
<docling-img src="conversion.json"></docling-img>
```

或按程序加载文档 :

```html
<script type="module">
  const cmp = document.getElementById('cmp');

  const fetched = await fetch('conversion.json');
  const doc = await fetched.json();
  cmp.src = doc;
</script>
...
<docling-img id="cmp" pagenumbers></docling-img>
```

#### 项目过滤和突出显示

根据已转换文档中的引用路径将已标记的文档项目缩小:

```html
<docling-img src="conversion.json" items="#/pictures/3"></docling-img>
```

选择整个项目类别 `items="#/pictures"`,完整页与 `items="#/pages/2"`,与 `items="#/pictures, #/tables"`。 。 。 .

或在方案上选择特定项目:

```html
<script type="module">
  const cmp = document.getElementById('cmp');
  const fetched = await fetch('conversion.json');
  const doc = await fetched.json();
  cmp.src = doc;

  // Select the first three tables.
  cmp.items = doc.tables.slice(0, 3);
</script>
...
<docling-img id="cmp" pagenumbers></docling-img>
```

要强调项目选择, 您可以将未选取的内容压入页面背景并/或剪切出页面, 无需选择任何项目 :

```html
<docling-img
  src="conversion.json"
  items="#/pictures"
  trim="pages"
  backdrop
></docling-img>
```

#### 工具提示

当你在页面上徘徊时,会弹出一个工具提示。 如果有匹配的网络组件, 此工具提示会显示项目解析的内容和说明 :

```html
<docling-img src="conversion.json">
  <docling-tooltip></docling-tooltip>
</docling-img>
```

#### 重叠

将内容和说明直接解析到项目上方(可能包含这些项目).

```html
<docling-img src="conversion.json">
  <docling-overlay></docling-overlay>
</docling-img>
```

### 登记表

此组件将转换后的文档显示为已解析的文档项目表,包含项目内容的列和已解析文档的图像(如果有的话).

#### 专有用途

```html
<docling-table src="conversion.json"></docling-table>
```

您可以选择带有 `items` 属性,如描述 `docling-img` 组件。 选择项目将从视图中剪切所有未选中的项目 .

#### 配置列

选择要显示的列和顺序 :

```html
<docling-table src="conversion.json">
  <docling-column>
    <docling-item-text></docling-item-text>
    <docling-item-table></docling-item-table>
  </docling-column>
  <docling-column>
    <docling-item-provenance></docling-item-provenance>
  </docling-column>
</docling-table>
```

您也可以使用它来显示单个文档项目的剪接图像 :

```html
<docling-table src="conversion.json" items="#/tables/2">
  <docling-column>
    <docling-item-provenance></docling-item-provenance>
  </docling-column>
</docling-table>
```

## 项目构成部分

大多数类型的文档项目都有一个预先包装的组件,用于可视化:

| 标记 | 项目标签 |
| --- | --- |
| `<docling-item-text>` | 复选框( s)  
复选框( u)  
脚注  
页脚  
页面标题  
段 次 页 次  
文本  
参考文献 |
| `<docling-item-table>` | 图表 |

您可以直接使用这些标签, 其元素有: `<docling-tooltip>` 指定将使用哪些组件,包括可选参数。 例如,只显示表格组件的工具提示:

```
<docling-tooltip>
  <docling-item-table></docling-item-table>
</docling-tooltip>
```

您可以通过从 : `DoclingItemElement` 学习时间 `/src/item/ItemElement.ts` 并且以教诲示人 `@customDoclingItemElement('docling-my-first-item-component')` 使其既注册为自定义网络元素,又注册为渲染文档项目的默认组件.

## 注释组件

某些类型的文档项目注释有一个预先包装的组件,用于可视化:

| 标记 | 项目标签 | 注释类型 |
| --- | --- | --- |
| `<docling-picture-classification>` | 图表  
图片 | 分类 |
| `<docling-picture-description>` | 图表  
图片 | 说明 |

您可以直接使用这些标签, 其元素有: `<docling-tooltip>` 指定将使用哪些组件。 例如,如果有的话,用其分类来覆盖图片:

```
<docling-overlay>
  <docling-picture-classification></docling-picture-classification>
</docling-overlay>
```

通过从 `DoclingAnnotationElement` 学习时间 `/src/annotation/AnnotationElement.ts` 并且以教诲示人 `@customDoclingAnnotationElement('docling-my-first-annotation-component')` 使其既注册为自定义网络元素,又注册为提供文档说明的默认组件.

## 常见问题

### @docling/docling-components 是什么？

显示 Docling 输出的 Web 组件 \.

### 如何安装 @docling/docling-components？

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

### @docling/docling-components 支持 TypeScript 吗？

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

### @docling/docling-components 支持 ESM 还是 CommonJS？

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

### @docling/docling-components 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @docling/docling-components 可以商用吗？

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

### @docling/docling-components 的下载量有多少？

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

### @docling/docling-components 还在维护吗？

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

