OMD Documentation

omdDisplay

A high-level component for displaying mathematical expressions or a series of equation steps. It handles rendering, automatic centering, scaling, and layout management within a given HTML container.

Class Definition

export class omdDisplay

Constructor

new omdDisplay(container, [options])

Creates a new omdDisplay instance.

Public Methods

render(expression)

Renders a mathematical expression or equation within the display. It intelligently handles different input types:

update(newNode)

Replaces the currently displayed node with a new one, applying the current font size and centering if enabled. The new node is initialized before being added to the display.

getCurrentNode()

Returns the node currently being displayed.

centerNode()

Manually triggers the centering and scaling logic for the current node. This is particularly useful for omdEquationSequenceNode instances to align them by their equals signs, and for ensuring content fits within the container based on autoScale and maxScale options.

fitToContent()

Adjusts the SVG container's dimensions to tightly fit the rendered content. Use contentPadding when exported SVGs need extra breathing room.

setFontSize(size)

Updates the base font size for the currently displayed node and for any future content rendered. This will trigger a re-layout and re-centering.

setFont(fontFamily, fontWeight)

Applies a specific font family and weight to all text elements within the rendered SVG. This setting is also stored for future content.

clear()

Removes the current expression from the display.

destroy()

Cleans up the component, removing all DOM elements and detaching the resize observer.

Internal Methods

↑ Top