Skip to content
PACKAGES

segmentText()

Split segmented text into render-ready pieces.

import { segmentText } from "@graphrefly/ts/solutions/reactive-layout";
function segmentText(
text: string,
segmentAdapter: SegmentAdapter,
): {
readonly texts: string[];
readonly isWordLike: boolean[];
readonly kinds: SegmentBreakKind[];
}[]
ParameterTypeDescription
textstringInput text.
segmentAdapterSegmentAdapterSegment adapter used to split words and graphemes.

Segment pieces with text, word-like, and break-kind arrays.

segmentText("Hello world", getDefaultSegmentAdapter());

packages/ts/src/solutions/reactive-layout/segment.ts