Skip to content

eo-typewriterjs


eo-typewriterjs / DomRenderer

Class: DomRenderer

Defined in: renderers/dom/dom-renderer.ts:88

Description

A DOM renderer that writes the current typewriter state into a target HTML element. All active cursors are rendered as inline elements at their correct document positions. All active per-cursor selections are rendered as highlighted spans. Text styles from the rich-text document are applied as span attributes, CSS classes, and/or inline styles - renderer-agnostic style objects are fully honoured. Adjacent text segments that share the same style stack and selection state are coalesced into a single span to minimise DOM node count.

The target may be specified as a CSS selector string or a direct element reference.

Implements

Constructors

Constructor

ts
new DomRenderer(target): DomRenderer;

Defined in: renderers/dom/dom-renderer.ts:99

Parameters

ParameterTypeDescription
targetstring | ElementA CSS selector string or an Element to render into

Returns

DomRenderer

Description

Create a DomRenderer targeting a specific element or CSS selector. Also ensures the built-in blink stylesheet is injected into the document.

Methods

mount()

ts
mount(state): void;

Defined in: renderers/dom/dom-renderer.ts:110

Parameters

ParameterTypeDescription
stateTTypewriterStateThe initial typewriter state

Returns

void

Description

Resolve the target element and perform the initial render

Implementation of

IRenderer.mount


render()

ts
render(state): void;

Defined in: renderers/dom/dom-renderer.ts:127

Parameters

ParameterTypeDescription
stateTTypewriterStateThe current typewriter state

Returns

void

Description

Update the target element with the latest document text, all cursors, and all selections

Implementation of

IRenderer.render


unmount()

ts
unmount(): void;

Defined in: renderers/dom/dom-renderer.ts:135

Returns

void

Description

Release the reference to the target element

Implementation of

IRenderer.unmount

Released under the MIT License.