react-pdf-highlighter-extended

The props type for PdfHighlighter.

interface PdfHighlighterProps {
    children: ReactNode;
    highlights: Highlight[];
    mouseSelectionStyle?: CSSProperties;
    pdfDocument: PDFDocumentProxy;
    pdfScaleValue?: PdfScaleValue;
    selectionTip?: ReactNode;
    style?: CSSProperties;
    textSelectionColor?: string;
    enableAreaSelection?(event): boolean;
    onCreateGhostHighlight?(ghostHighlight): void;
    onRemoveGhostHighlight?(ghostHighlight): void;
    onScrollAway?(): void;
    onSelection?(PdfSelection): void;
    utilsRef(pdfHighlighterUtils): void;
}

Properties

children: ReactNode

This should be a highlight container/renderer of some sorts. It will be given appropriate context for a single highlight which it can then use to render a TextHighlight, AreaHighlight, etc. in the correct place.

highlights: Highlight[]

Array of all highlights to be organised and fed through to the child highlight container.

mouseSelectionStyle?: CSSProperties

Optional CSS styling for the rectangular mouse selection.

pdfDocument: PDFDocumentProxy

PDF document to view and overlay highlights.

pdfScaleValue?: PdfScaleValue

What scale to render the PDF at inside the viewer.

selectionTip?: ReactNode

Optional element that can be displayed as a tip whenever a user makes a selection.

style?: CSSProperties

Style properties for the PdfHighlighter (scrollbar, background, etc.), NOT the PDF.js viewer it encloses. If you want to edit the latter, use the other style props like textSelectionColor or overwrite pdf_viewer.css

textSelectionColor?: string

Coloring for unhighlighted, selected text.

Methods

  • Condition to check before any mouse selection starts.

    Parameters

    • event: MouseEvent

      mouse event associated with the new selection.

    Returns boolean

    • True if mouse selection should start.
  • Callback triggered whenever a ghost (non-permanent) highlight is created.

    Parameters

    Returns void

  • Callback triggered whenever a ghost (non-permanent) highlight is removed.

    Parameters

    Returns void

  • Event is called only once whenever the user changes scroll after the autoscroll function, scrollToHighlight, has been called.

    Returns void

  • Callback triggered whenever a user finishes making a mouse selection or has selected text.

    Parameters

    • PdfSelection: PdfSelection

      Content and positioning of the selection. NOTE: makeGhostHighlight will not work if the selection disappears.

    Returns void

  • Creates a reference to the PdfHighlighterContext above the component.

    Parameters

    • pdfHighlighterUtils: PdfHighlighterUtils

      various useful tools with a PdfHighlighter. See PdfHighlighterContext for more description.

    Returns void