@embedpdf/plugin-redaction

中文文档
3.2.0发布于 2026/11/12Apache-2.0TypeScriptESM + CJS近 30 天下载 129万

文档范围编辑:破坏性应用阶段大于编辑注释标记——待排队查看,附带估计,以及doc.redact. 应用包装。 标记本身在注释机上.

中文使用文档
文档目录4 节
  1. 设置
  2. 标记
  3. 待决队列
  4. 应用

@embedpdf/plugin-redaction (英语)

编辑 EmbedPDF —— 标记删除内容, 审查待处理 标记,然后永久销毁内容.

编辑是 两阶段 工作流程(ISO 32000-2):

  1. 标记 是无损的 并且住在注解飞机上 A 类 编辑标记是真实的 redact 注释:它使、选择、, 同步, 并像其他注释一样删除, 没有被删除 还没有。 您不需要这个插件来标记 —— redact 工具舰 @embedpdf/plugin-annotation ——但它为代码添加了标记动词.
  2. 应用 具有破坏性, 并且是这个插件所包裹的内容 : 在每一个标记区域下永久删除,配置 覆盖( 填充 + 标签) 的位置被涂上, 所消耗的标记 加上与该区域相交叉的任何注释,将删除. 那边 无法消除.

信入分界. 在分层/分层文档上,应用重写 当前图层的字节。 不可移动的基准文档保存原始 内容——编辑的内容只有在留下的内容中才能真正恢复 系统(一层下载/导出,或本地文档保存于 (适用)。 任何"永久删除"的UI都相应表示.

设置

import { annotationPlugin } from '@embedpdf/react/annotation';
import { redactionPlugin } from '@embedpdf/react/redaction';

const plugins = [
  // ...stage, interaction, selection...
  annotationPlugin(), // required: owns the marks
  redactionPlugin(), // the destructive apply + pending queue view
];

要求数 plugin-annotation与 plugin-selection 财务报告和审定财务报表 plugin-interaction 当前( 通常的查看器设置) , 标记工具 财务报告和审定财务报表 markSelection() 也点起; markMatches() 需求 plugin-search。 。 。 .

redactionPlugin({ overlay }) 设定每个标记上的涂料, 不论以何种方式产生 redact 工具,选定文本或代码 : overlay.fill 是应用程序上所绘的颜色(默认为黑色)和 overlay.text 样式标签(color,默认为白色; fontFamily, (中文(简体) ), 默认 Helvetica ; fontSize,则默认 0 符合区域。 这个 设置成为编辑工具的默认值,并且 redaction.updateSettings() 更改它们,以表示从那时起的标记.

标记

这个 redact 工具是一个 编 成 工具:使用它,拖动到 文本标记所选文本(每行四行,如亮点),以及 在其它任何地方拖曳都标志着一个长方形区域. 一种工具,两种模式.

import { useInteraction, useInteractionState } from '@embedpdf/react/interaction';
import { useRedaction } from '@embedpdf/react/redaction';

const redaction = useRedaction();
const interaction = useInteraction();
const { activeToolId } = useInteractionState();

interaction.activateTool('redact'); // arm the redact tool
activeToolId === 'redact';

// Mark the current text selection without switching tools
// (context-menu "Mark for Redaction"):
const { marks } = await redaction.markSelection();

// Or mark from code (page space; a page is a ref or an index):
const { mark } = await redaction.markArea(page, { x: 72, y: 72, width: 200, height: 40 });
await redaction.markPage(0);
await redaction.markMatches({ text: 'Confidential' }); // every search hit: { marks }

canMark() 是注释创建权威:标记是普通的 注释,所以任何能够注释的人都可以提出编辑建议.

标记带有其外观: color (标记大纲), interiorColor (填写在申请上)和可选标签(/OverlayText(中文(简体) ) 样式由 fontFamily编号 :fontSize编号 :fontColor编号 :textAlign 与 repeat 横跨整个区域 样式道具流经 普通注释样式面板; 标签文本本身 :

const { mark } = await redaction.updateLabel(ref, { overlayText: 'REDACTED', repeat: true });

canUnmark(ref) 财务报告和审定财务报表 canUpdateLabel(ref) 每个标记的回答,作为 注释本身的删除和更新检查.

待决队列

等待的标记是 非插件状态 - 他们是一个活的景色过 注释平面( n)subtype === 'redact') (中文(简体) ). 删除标记只是 删除注释.

redaction.listPending(); // RedactionMark[] — ref, page, pageIndex, kind: 'area' | 'text', bounds, overlayText, repeat
redaction.listPending({ page }); // one page's marks
redaction.getPending(ref); // one mark, or null
redaction.getPendingCount();
redaction.estimateCollateral(); // { count, refs }: a client-side estimate of the
// other annotations the pending marks would destroy — show
// this in your confirm dialog before applying

await redaction.unmark([ref]); // remove marks; refs that are not marks are skipped, refused ones fail
await redaction.clearPending(); // remove every mark

redaction.onPendingChanged(({ pages }) => {
  /* marks were created, changed or removed on these pages */
});

应用

// Everything in the document, including marks on pages this client never loaded:
const result = await redaction.applyAll();
// Or specific marks:        await redaction.apply([ref1, ref2]);
// Or the marks on pages:    await redaction.applyPages([page]);

result.removedAnnotationCount; // authoritative collateral count
result.results; // per-page applied/unchanged/failed/skipped

redaction.onApplied(({ result, origin }) => {
  /* toast, audit, ... */
});

apply 在引擎确认后解决。 一次运行一次, 按照呼叫顺序 受影响的页面重新编辑( 内容范围无效) 及其注解列表自动加载——包括当 合作者 适用于共享文档。 在一个文件上 缺少 doc.redact (或 doc.pages.modify 财务报告和审定财务报表 doc.annotate.modify,哪个 也适用主张), canApply() 是虚假的,而且 apply 拒绝方式 permission-denied;没有引擎编辑服务,它拒绝使用 unsupported。 。 。 .

redaction.canApply(); // engine service present and every apply capability granted
redaction.isApplying(); // in-flight state for spinners
redaction.getLastResult(); // the last confirmed apply, from this session or another

在反应中, useRedaction() 这是能力, useRedactionState() 读取 { pendingCount, applying, lastResult }, (中文(简体) ), usePendingRedactions(filter?) 实值 反应性待决名单, useRedactionSettings() 设置,以及 useRedactionEvent((redaction) => redaction.onApplied, handler) 订阅 使用寿命——全部来自 @embedpdf/react/redaction。 。 。 .

版本与发布记录

@embedpdf/plugin-redaction 共发布 96 个版本,首次发布于 2025/08/13;过去 12 个月发布了 64 个版本。

版本发布日期距今
3.2.0latest2026/11/121 天前
3.1.02026/11/094 天前
3.0.02026/11/076 天前
3.0.0-next.23next2026/11/076 天前
3.0.0-next.222026/11/049 天前
3.0.0-next.212026/11/0310 天前

关于 @embedpdf/plugin-redaction 的常见问题

@embedpdf/plugin-redaction 是什么?

文档范围编辑:破坏性应用阶段大于编辑注释标记——待排队查看,附带估计,以及doc.redact. 应用包装。 标记本身在注释机上.

如何安装 @embedpdf/plugin-redaction?

在项目目录运行 npm install @embedpdf/plugin-redaction,或使用 pnpm add / yarn add / bun add。

@embedpdf/plugin-redaction 支持 TypeScript 吗?

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

@embedpdf/plugin-redaction 支持 ESM 还是 CommonJS?

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

@embedpdf/plugin-redaction 可以商用吗?

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

@embedpdf/plugin-redaction 的下载量有多少?

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

@embedpdf/plugin-redaction 还在维护吗?

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