Skip to main content

$getTextNodeOffset

function

Get a normalized offset into a TextNode given a numeric offset or a direction for which end of the string to use. Throws in dev if the offset is not in the bounds of the text content size.

function $getTextNodeOffset(origin: TextNode, offset: number | CaretDirection, mode?: 'error' | 'clamp'): number

Import

import { $getTextNodeOffset } from '@modular/sdk/editor';

Notes

returns
An absolute offset into the TextNode string