Class: Footnotes

Footnotes(chunker, polisher, caller)

Handles the parsing, layout, and rendering of footnotes in paged content.

Manages footnote policies, markers, calls, layout overflow, and alignment. Extends the generic Handler class.

Constructor

new Footnotes(chunker, polisher, caller)

Creates an instance of Footnotes.

Creates an instance of Footnotes.

Parameters:
Name Type Description
chunker object

The chunker instance handling content chunks.

polisher object

The polisher instance handling polishing/layout.

caller object

The caller instance managing handler orchestration.

Source:

Members

footnotes :Object.<string, {selector: string, policy: string, display: string}>

Stores footnote selectors and their properties.

Stores footnote selectors and their properties.

Type:
  • Object.<string, {selector: string, policy: string, display: string}>
Source:

needsLayout :Array.<Node>

Array of DOM fragments that need layout recalculation.

Array of DOM fragments that need layout recalculation.

Type:
  • Array.<Node>
Source:

overflow :Array.<Element>

Array of footnote nodes that overflowed and are pending reinsertion.

Array of footnote nodes that overflowed and are pending reinsertion.

Type:
  • Array.<Element>
Source:

Methods

afterOverflowAdded(rendered) → {void}

Called after overflow content is added; reattaches footnotes and recalculates heights.

Called after overflow content is added; reattaches footnotes and recalculates heights.

Parameters:
Name Type Description
rendered Element

The DOM element where new content has been rendered.

Source:
Returns:
Type
void

afterOverflowRemoved(removed, rendered) → {void}

Called after overflow content is removed; updates footnotes accordingly.

Called after overflow content is removed; updates footnotes accordingly.

Parameters:
Name Type Description
removed Element

The DOM fragment containing removed overflow nodes.

rendered Element

The DOM element where content is currently rendered.

Source:
Returns:
Type
void

afterPageLayout(pageElement, page, breakToken, chunker) → {void}

Called after the page layout is complete to handle footnote overflow and layout.

Called after the page layout is complete to handle footnote overflow and layout.

Parameters:
Name Type Description
pageElement Element

The page's root element in the DOM.

page Object

The page object containing footnotes and layout info.

breakToken Object | null

The token representing a page break, if any.

chunker Object

The chunker instance managing page chunks.

Source:
Returns:
Type
void

afterParsed(parsed)

After parsing, processes and applies footnote attributes to matching elements.

After parsing, processes and applies footnote attributes to matching elements.

Parameters:
Name Type Description
parsed Document

The parsed DOM document or fragment.

Source:

beforePageLayout(page) → {void}

Called before laying out a page, to process any pending footnotes that need moving.

Called before laying out a page, to process any pending footnotes that need moving.

Parameters:
Name Type Description
page Object

The page object containing DOM and layout data.

Source:
Returns:
Type
void

borderHeight(element, totalopt) → {number}

Calculates the total vertical border height of an element.

Calculates the total vertical border height of an element.

Parameters:
Name Type Attributes Default Description
element Element

The DOM element to calculate border height for.

total boolean <optional>
true

Whether to include bottom border in the total.

Source:
Returns:

The sum of the top (and optionally bottom) border width in pixels.

Type
number

createFootnoteCall(node) → {HTMLAnchorElement}

Creates a footnote call (link) element that points to the footnote.

Creates a footnote call (link) element that points to the footnote.

Parameters:
Name Type Description
node Element

The footnote element to create a call for.

Source:
Returns:

The created footnote call anchor element.

Type
HTMLAnchorElement

findVisibleFootnotes(notes, node)

Finds visible footnotes within a node and moves them into the footnote area.

Finds visible footnotes within a node and moves them into the footnote area.

Parameters:
Name Type Description
notes NodeListOf.<Element>

List of footnote elements.

node Element

The container node to check visibility against.

Source:

handleAlignment(node) → {void}

Handles alignment properties for the last split footnote element.

Handles alignment properties for the last split footnote element.

Parameters:
Name Type Description
node Element

The footnote element to apply alignment on.

Source:
Returns:
Type
void

marginsHeight(element, totalopt) → {number}

Calculates the total vertical margin height of an element.

Calculates the total vertical margin height of an element.

Parameters:
Name Type Attributes Default Description
element Element

The DOM element to calculate margin height for.

total boolean <optional>
true

Whether to include bottom margin in the total.

Source:
Returns:

The sum of the top (and optionally bottom) margin in pixels.

Type
number

moveFootnote(node, pageArea, needsNoteCall) → {void}

Moves a footnote node to the footnote area of a given page.

Moves a footnote node to the footnote area of a given page.

Parameters:
Name Type Description
node Element

The footnote element to move.

pageArea Element

The page container element containing footnotes.

needsNoteCall boolean

Whether a footnote call link should be created.

Source:
Returns:
Type
void

onDeclaration(declaration, dItem, dList, rule)

Handles CSS declarations related to footnotes during parsing.

Handles CSS declarations related to footnotes during parsing. Detects float: footnote, footnote-policy, and footnote-display properties.

Parameters:
Name Type Description
declaration object

The CSS declaration node.

dItem object

Declaration item in the list.

dList object

Declaration list.

rule object

The CSS rule node.

Source:

onPseudoSelector(pseudoNode, pItem, pList, selector, rule)

Transforms pseudo selectors ::footnote-marker and ::footnote-call into attribute selectors with pseudo-elements to enable footnote rendering.

Transforms pseudo selectors ::footnote-marker and ::footnote-call into attribute selectors with pseudo-elements to enable footnote rendering.

Parameters:
Name Type Description
pseudoNode object

The pseudo selector node.

pItem object

The item in pseudo selector list.

pList object

The pseudo selector list.

selector string

The full selector string.

rule object

The CSS rule node.

Source:

paddingHeight(element, totalopt) → {number}

Calculates the total vertical padding height of an element.

Calculates the total vertical padding height of an element.

Parameters:
Name Type Attributes Default Description
element Element

The DOM element to calculate padding height for.

total boolean <optional>
true

Whether to include bottom padding in the total.

Source:
Returns:

The sum of the top (and optionally bottom) padding in pixels.

Type
number

processFootnoteContainer(node)

Walks up the DOM from a footnote element to find its container.

Walks up the DOM from a footnote element to find its container. Marks the closest container or last element with 'data-has-notes' attribute.

Parameters:
Name Type Description
node Element

The footnote element.

Source:

processFootnotes(parsed, notes)

Finds elements matching footnote selectors and adds footnote attributes.

Finds elements matching footnote selectors and adds footnote attributes. Also marks their container parents with data attributes to indicate presence of notes.

Parameters:
Name Type Description
parsed Document | Element

The root parsed element.

notes Object

The footnotes configuration object.

Source:

recalcFootnotesHeight(node, noteContent, pageArea, noteCall, needsNoteCall)

Recalculates the height of footnote content and adjusts page CSS variables to ensure proper layout according to footnote policy and overflow.

Recalculates the height of footnote content and adjusts page CSS variables to ensure proper layout according to footnote policy and overflow.

Parameters:
Name Type Description
node Element

The footnote node.

noteContent Element

The container of footnote content.

pageArea Element

The page area element.

noteCall Element | null

The footnote call element.

needsNoteCall boolean

Whether the footnote call should be rendered.

Source:

renderNode(node)

Processes a node during rendering to find and handle footnotes within it.

Processes a node during rendering to find and handle footnotes within it.

Parameters:
Name Type Description
node Node

The DOM node to render.

Source: