Skip to content

Type Editor


Type Editor / @type-editor/dom-util / text-node-before

text-node-before

Functions

FunctionDescription

textNodeBefore

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

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

Example

typescript
const element = document.getElementById("myElement");
const textNode = textNodeBefore(element, 1);