@embedpdf/plugin-redaction (英语)
编辑 EmbedPDF —— 标记删除内容, 审查待处理 标记,然后永久销毁内容.
编辑是 两阶段 工作流程(ISO 32000-2):
- 标记 是无损的 并且住在注解飞机上 A 类
编辑标记是真实的
redact注释:它使、选择、, 同步, 并像其他注释一样删除, 没有被删除 还没有。 您不需要这个插件来标记 ——redact工具舰@embedpdf/plugin-annotation——但它为代码添加了标记动词. - 应用 具有破坏性, 并且是这个插件所包裹的内容 : 在每一个标记区域下永久删除,配置 覆盖( 填充 + 标签) 的位置被涂上, 所消耗的标记 加上与该区域相交叉的任何注释,将删除. 那边 无法消除.
信入分界. 在分层/分层文档上,应用重写 当前图层的字节。 不可移动的基准文档保存原始 内容——编辑的内容只有在留下的内容中才能真正恢复 系统(一层下载/导出,或本地文档保存于 (适用)。 任何"永久删除"的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。 。 。 .