Skip to content

Type Editor


Type Editor / @type-editor/dom-util / text-nodes-after / textNodeAfter

Function: textNodeAfter()

ts
function textNodeAfter(node, offset): Text;

Defined in: text-nodes-after.ts:22

Finds the text node after a given position in the DOM tree.

Traverses the DOM tree forward from the given position to find the nearest following text node. Stops at non-editable elements and block boundaries.

Parameters

ParameterTypeDescription
nodeNodeThe starting DOM node
offsetnumberThe offset within the starting node

Returns

Text

The text node after the position, or null if none exists

Example

typescript
const element = document.getElementById("myElement");
const textNode = textNodeAfter(element, 0);