react-pdf-highlighter-plus

The props type for TextHighlight.

interface TextHighlightProps {
    colorPresets?: string[];
    deleteIcon?: ReactNode;
    highlight: ViewportHighlight;
    highlightColor?: string;
    highlightStyle?: "underline" | "highlight" | "strikethrough";
    isScrolledTo: boolean;
    style?: CSSProperties;
    styleIcon?: ReactNode;
    onClick?(event): void;
    onContextMenu?(event): void;
    onDelete?(): void;
    onMouseOut?(event): void;
    onMouseOver?(event): void;
    onStyleChange?(style): void;
}

Properties

colorPresets?: string[]

Custom color presets for the style panel. Default: ["rgba(255, 226, 143, 1)", "#ffcdd2", "#c8e6c9", "#bbdefb", "#e1bee7"]

deleteIcon?: ReactNode

Custom delete icon. Replaces the default trash icon.

Highlight to render over text.

highlightColor?: string

Background/line color for the highlight. Default: "rgba(255, 226, 143, 1)" (yellow)

highlightStyle?: "underline" | "highlight" | "strikethrough"

Style mode for the highlight.

  • "highlight": Solid background color (default)
  • "underline": Line under the text
  • "strikethrough": Line through the text
isScrolledTo: boolean

Indicates whether the component is autoscrolled into view, affecting default theming.

style?: CSSProperties

Optional CSS styling applied to each TextHighlight part.

styleIcon?: ReactNode

Custom style icon. Replaces the default palette icon.

Methods

  • Callback triggered whenever the user clicks on the part of a highlight.

    Parameters

    • event: MouseEvent<HTMLDivElement, MouseEvent>

      Mouse event associated with click.

    Returns void

  • Callback triggered whenever the user tries to open context menu on highlight.

    Parameters

    • event: MouseEvent<HTMLDivElement, MouseEvent>

      Mouse event associated with click.

    Returns void

  • Callback triggered whenever the user leaves the area of a text highlight.

    Parameters

    • event: MouseEvent<HTMLDivElement, MouseEvent>

      Mouse event associated with movement.

    Returns void

  • Callback triggered whenever the user enters the area of a text highlight.

    Parameters

    • event: MouseEvent<HTMLDivElement, MouseEvent>

      Mouse event associated with movement.

    Returns void