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
new DomRenderer(target): DomRenderer;Defined in: renderers/dom/dom-renderer.ts:99
Parameters
| Parameter | Type | Description |
|---|---|---|
target | string | Element | A 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()
mount(state): void;Defined in: renderers/dom/dom-renderer.ts:110
Parameters
| Parameter | Type | Description |
|---|---|---|
state | TTypewriterState | The initial typewriter state |
Returns
void
Description
Resolve the target element and perform the initial render
Implementation of
render()
render(state): void;Defined in: renderers/dom/dom-renderer.ts:127
Parameters
| Parameter | Type | Description |
|---|---|---|
state | TTypewriterState | The current typewriter state |
Returns
void
Description
Update the target element with the latest document text, all cursors, and all selections
Implementation of
unmount()
unmount(): void;Defined in: renderers/dom/dom-renderer.ts:135
Returns
void
Description
Release the reference to the target element