diff --git a/Libraries/Text/TextProps.js b/Libraries/Text/TextProps.js index 7426b5ab5..289424a7e 100644 --- a/Libraries/Text/TextProps.js +++ b/Libraries/Text/TextProps.js @@ -10,7 +10,7 @@ 'use strict'; -import type {LayoutEvent, PressEvent} from 'CoreEventTypes'; +import type {LayoutEvent, PressEvent, TextLayoutEvent} from 'CoreEventTypes'; import type React from 'React'; import type {DangerouslyImpreciseStyleProp} from 'StyleSheet'; import type { @@ -48,6 +48,7 @@ export type TextProps = $ReadOnly<{ onResponderTerminate?: ?Function, onResponderTerminationRequest?: ?Function, onStartShouldSetResponder?: ?Function, + onTextLayout?: ?(event: TextLayoutEvent) => mixed, pressRetentionOffset?: ?PressRetentionOffset, selectable?: ?boolean, style?: ?DangerouslyImpreciseStyleProp, diff --git a/Libraries/Types/CoreEventTypes.js b/Libraries/Types/CoreEventTypes.js index 58a0cc5ed..17e6de6f1 100644 --- a/Libraries/Types/CoreEventTypes.js +++ b/Libraries/Types/CoreEventTypes.js @@ -36,12 +36,27 @@ export type Layout = $ReadOnly<{| height: number, |}>; +export type TextLayout = $ReadOnly<{| + ...Layout, + ascender: number, + capHeight: number, + descender: number, + text: string, + xHeight: number, +|}>; + export type LayoutEvent = SyntheticEvent< $ReadOnly<{| layout: Layout, |}>, >; +export type TextLayoutEvent = SyntheticEvent< + $ReadOnly<{| + lines: Array, + |}>, +>; + export type PressEvent = SyntheticEvent< $ReadOnly<{| changedTouches: $ReadOnlyArray<$PropertyType>,