Skip to content

Improve redaction annotation to remove more#488

Open
JoackimPennerup wants to merge 2 commits intoembedpdf:mainfrom
JoackimPennerup:feat/redaction-annotation-hardening
Open

Improve redaction annotation to remove more#488
JoackimPennerup wants to merge 2 commits intoembedpdf:mainfrom
JoackimPennerup:feat/redaction-annotation-hardening

Conversation

@JoackimPennerup
Copy link

Summary

This PR hardens annotation-mode redaction to better match Acrobat-style behavior for applied redactions and to reduce residual sensitive data in annotations/forms.

What changed

  1. Intersecting annotation cleanup on apply
  • When a REDACT annotation is applied, intersecting page annotations are inspected.
  • Intersecting annotations are removed if they are not REDACT.
  1. Intersecting form widget handling (updated behavior)
  • Intersecting widgets are now removed.
  • No placeholder replacement annotation is created.
  • Visual result comes from redaction application itself.
  1. Linked redaction thread cleanup
  • Linked comment/reply thread annotations are removed via transitive inReplyToId traversal seeded from applied REDACT IDs.
  1. State/history synchronization
  • Annotation state, pending redaction state, and annotation history metadata are purged consistently for affected IDs (removed + applied).
  1. Shared geometry intersection utility
  • Added rectsIntersect(a, b) in @embedpdf/models and exported it.
  • Removed duplicate local intersection logic usage in annotation helper paths.
  1. PDFium checked-field deterministic behavior
  • setFormFieldValue(..., { kind: 'checked', isChecked }) now toggles only when current state differs from requested state (idempotent set-to-target behavior).

Important behavior notes

  • Redaction fill appearance remains controlled by redaction styling/config (including chosen color).
  • Legacy mode behavior remains unchanged.

Tests

Added/updated tests covering:

  • geometry intersection semantics (rectsIntersect)
  • deterministic checked-field set behavior in PDFium
  • redaction plugin annotation-mode behavior:
    • removes intersecting non-widget annotations
    • removes intersecting widgets
    • removes linked thread annotations
    • preserves unrelated non-intersecting annotations
    • failure path emits failed commit and avoids state/history purge

Validation

  • pnpm --filter @embedpdf/plugin-redaction test
  • pnpm --filter @embedpdf/models test
  • pnpm --filter @embedpdf/engines test

Out of scope / follow-up

  • “Redact All” multi-page rerender/page-discovery consistency is intentionally deferred to a follow-up PR (separate concern from hardening behavior).

@vercel
Copy link

vercel bot commented Feb 26, 2026

Someone is attempting to deploy a commit to the OpenBook Team on Vercel.

A member of the Team first needs to authorize it.

@JoackimPennerup
Copy link
Author

@bobsingor Any change you could have a look at this? I'd be happy to change it into another direction if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant