@epam/ai-dial-react-pdf-highlighter

中文文档
0.3.3发布于 2026/11/18Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 9951

React components for PDF viewing and highlighting, built on @epam/pdf-highlighter-kit

原始使用文档
文档目录21 节
  1. Table of Contents
  2. Highlights
  3. Documentation
  4. Quick Start
  5. Prerequisites
  6. Installation
  7. Peer Dependencies
  8. Basic Usage
  9. Exported API
  10. Components
  11. Hooks
  12. Styles
  13. Development
  14. Setup
  15. Quality Checks
  16. Storybook
  17. Usage in Projects
  18. Next.js
  19. Contributing
  20. Security
  21. License

@epam/ai-dial-react-pdf-highlighter

AI DIAL React PDF Highlighter is a React component library for PDF viewing and highlights. It builds on top of @epam/pdf-highlighter-kit and uses @epam/ai-dial-ui-kit styles and components.

Part of the AI DIAL ecosystem.

npm version License: Apache 2.0

Table of Contents

Highlights

  • React components for PDF viewing, thumbnailing, and highlights
  • Higher-level API over pdf-highlighter-kit
  • Built with TypeScript and strict typing
  • Storybook + Vitest test setup
  • Ready to publish and consume as an npm package

Documentation

You can explore components in Storybook during local development.

npm run storybook

Quick Start

Prerequisites

  • Node.js >= 22.2.0
  • npm >= 10.7.0

Installation

npm install @epam/ai-dial-react-pdf-highlighter

Peer Dependencies

TypePackagesnpmYarn
Requiredreact, react-dom, @epam/pdf-highlighter-kit, @epam/ai-dial-ui-kit, pdfjs-distnpm install react react-dom @epam/pdf-highlighter-kit @epam/ai-dial-ui-kit pdfjs-distyarn add react react-dom @epam/pdf-highlighter-kit @epam/ai-dial-ui-kit pdfjs-dist
Optional (for DocumentPreview)@tabler/icons-reactnpm install @tabler/icons-reactyarn add @tabler/icons-react

Your pdfjs-dist version should satisfy pdf-highlighter-kit requirements.

Basic Usage

import {
  DocumentPreview,
  DocumentPreviewCacheProvider,
} from '@epam/ai-dial-react-pdf-highlighter';
import '@epam/ai-dial-ui-kit/styles.css';
import '@epam/ai-dial-react-pdf-highlighter/styles.css';

function App() {
  return (
    <DocumentPreviewCacheProvider>
      <DocumentPreview
        fileUrl="https://example.com/document.pdf"
        loadFileCb={(url) => fetch(url).then((response) => response.blob())}
        highlights={[]}
      />
    </DocumentPreviewCacheProvider>
  );
}

Exported API

Components

NameDescription
PDFViewerLow-level PDF viewer component wrapping @epam/pdf-highlighter-kit. Accepts PdfViewerProps.
DocumentPreviewHigh-level document preview with built-in loading, zoom, highlight navigation, and thumbnail support. Accepts DocumentPreviewProps.
DocumentPreviewCacheProviderContext provider that enables cross-component sharing of loaded PDF blobs. Wrap your app (or subtree) with this to avoid re-fetching the same files.
PdfPreviewLoaderStandalone loading/error state overlay used internally by DocumentPreview. Accepts PdfPreviewLoaderProps.
PageThumbnailRenders a single PDF page as a thumbnail image. Accepts PageThumbnailProps.

Hooks

useDocumentPreview(options: UseDocumentPreviewOptions): UseDocumentPreviewResult

Encapsulates all logic for a document preview: file fetching (with optional cache integration), highlight-index navigation, zoom state, and thumbnail generation. Use it to build a fully custom preview UI without taking on DocumentPreview's default layout.

useDocumentPreviewCache(): DocumentPreviewCacheContext | null

Returns the document preview cache context provided by DocumentPreviewCacheProvider. Returns null when called outside the provider. Consumed internally by useDocumentPreview to avoid re-fetching files already in the cache.

Styles

Import both stylesheets in your app entry point:

import '@epam/ai-dial-ui-kit/styles.css';
import '@epam/ai-dial-react-pdf-highlighter/styles.css';

Development

Setup

git clone https://github.com/epam/ai-dial-react-pdf-highlighter.git
cd ai-dial-react-pdf-highlighter
npm install

Useful commands:

npm run dev
npm run storybook
npm run test:run
npm run test

Quality Checks

Before opening a PR, run:

npm run typecheck
npm run lint:check
npm run test:run

Or run the combined check:

npm run verify:agent-hook

Storybook

Development mode:

npm run storybook

Production build:

npm run build-storybook

Usage in Projects

Next.js

In some cases, PDF-related UI works only with dynamic imports on the client side. If you hit SSR issues, load viewer components with next/dynamic and ssr: false.

Contributing

Please read the contributing guide.

Security

If you find a vulnerability, please read our security policy.

License

Apache 2.0 © EPAM Systems

版本与发布记录

@epam/ai-dial-react-pdf-highlighter 共发布 62 个版本,首次发布于 2026/04/09;过去 12 个月发布了 62 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.3latest2026/11/18今天
0.4.0-dev.6development2026/11/18今天
0.4.0-dev.42026/11/107 天前
0.3.22026/11/107 天前
0.3.12026/11/0512 天前
0.4.0-dev.32026/11/0512 天前

其他发布通道:next → 0.2.0-rc.6,development → 0.4.0-dev.6。

关于 @epam/ai-dial-react-pdf-highlighter 的常见问题

@epam/ai-dial-react-pdf-highlighter 是什么?

React components for PDF viewing and highlighting, built on @epam/pdf-highlighter-kit

如何安装 @epam/ai-dial-react-pdf-highlighter?

在项目目录运行 npm install @epam/ai-dial-react-pdf-highlighter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.2.5)、react-dom(>=19.2.5)、pdfjs-dist(^6.2.108)、@epam/ai-dial-ui-kit(>=0.15.0-0 || >=0.16.0-0)、@epam/pdf-highlighter-kit(^0.0.23)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@epam/ai-dial-react-pdf-highlighter 支持 TypeScript 吗?

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

@epam/ai-dial-react-pdf-highlighter 支持 ESM 还是 CommonJS?

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

@epam/ai-dial-react-pdf-highlighter 需要什么版本的 Node.js?

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

@epam/ai-dial-react-pdf-highlighter 可以商用吗?

@epam/ai-dial-react-pdf-highlighter 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@epam/ai-dial-react-pdf-highlighter 的下载量有多少?

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

@epam/ai-dial-react-pdf-highlighter 还在维护吗?

最新版本 0.3.3 发布于 2026/11/18(今天);至今共发布 62 个版本,其中过去 12 个月发布了 62 个;首次发布于 2026/04/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。