Epstein Unredactor
Home
Architecture
API
GitHub
Home
Architecture
API
GitHub
  • Getting Started

    • Setup & Deployment
    • Local Development
    • Production Deployment
    • /setup-and-deployment/TROUBLESHOOTING.html
  • Architecture

    • Epstein Unredactor — Architecture Overview
  • Redaction Processing

    • Redaction Processing — Backend Logic
    • ProcessRedactions.py
    • BoxDetector.py Documentation
    • SurroundingWordWidth.py Documentation
    • Scale & Size Detection
    • Artifact Visualizer — Documentation
    • width_calculator.py
    • extract_fonts — Font Detection Module
  • Frontend Implementation

    • Frontend — JavaScript Module Reference
    • State Management — state.js
    • PDF Viewer — pdf-viewer.js
    • API & Candidate Logic — api.js
    • UI Events — ui-events.js
    • WebGL Mask — webgl-mask.js
    • Formatting Bridge — text-tool.js
  • API Reference

    • API Reference

Formatting Bridge — text-tool.js

text-tool.js manages the Unified Options Bar and acts as a formatting bridge between the Redaction Matcher and the Embedded Text Viewer (ETV).

It ensures that rich text properties (Bold, Italic, Color, etc.) are synchronized across all interactive text elements in the viewer.


Unified Options Bar

The viewer features a centralized formatting toolbar (#unified-options-bar-container) located and shared between the core and the plugins.

Shared Controls

ControlIDDescription
Font FamilyfontDropdown: Arial, Times New Roman, Calibri, Courier New
Font SizesizeGlobal font size in points
Scale %calc-scaleWidth scaling for HarfBuzz measurements
Boldbtn-boldToggle for font-weight: bold
Italicbtn-italicToggle for font-style: italic
Underlinebtn-underlineToggle for text-decoration: underline
Text Colorcolor-pickerColor applied to labels and spans

The Formatting Bridge

text-tool.js tracks the currently focused element via the document.activeElement. It listens for changes on any of the toolbar inputs and broadcasts them.

text-format-changed Event

When a formatting property is changed in the toolbar, text-tool.js dispatches a CustomEvent to the focused element.

Example Payload:

{
  detail: {
    element: HTMLElement,
    styles: {
      fontWeight: "bold",
      fontStyle: "italic",
      color: "#ff0000",
      ...
    }
  }
}

Participating Modules:

  • Redaction Matching: api.js listens for this event to update the state.redactions[idx].settings so that formatting persists during re-renders.
  • Embedded Text Viewer: Automatically applies styles to the underlying PDF text layer.

Selection Management

The bridge automatically detects when a .redaction-label or an .etv-span gains focus. It then:

  1. Reads the current styles of the element.
  2. Updates the toolbar buttons (e.g., highlighting the "B" button if the text is bold).
  3. Ensures the toolbar remains visible and active for as long as a text element is being manipulated.
Edit this page
Last Updated: 4/6/26, 10:34 AM
Contributors: JaguarM
Prev
WebGL Mask — webgl-mask.js