From de9ea3ee402119f32b84fd77e0c5f57937e3c0a3 Mon Sep 17 00:00:00 2001 From: christianwen Date: Tue, 17 Sep 2024 22:47:57 +0700 Subject: [PATCH] type fix --- src/MarkdownTextInput.web.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 4d310b4a..072f0efa 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -9,9 +9,10 @@ import type { TextInputKeyPressEventData, TextInputFocusEventData, TextInputContentSizeChangeEventData, + GestureResponderEvent, } from 'react-native'; import React, {useEffect, useRef, useCallback, useMemo, useLayoutEffect} from 'react'; -import type {CSSProperties, MutableRefObject, ReactEventHandler, FocusEventHandler, MouseEvent, KeyboardEvent, SyntheticEvent, ClipboardEventHandler} from 'react'; +import type {CSSProperties, MutableRefObject, ReactEventHandler, FocusEventHandler, MouseEvent, KeyboardEvent, SyntheticEvent, ClipboardEventHandler, TouchEvent} from 'react'; import {StyleSheet} from 'react-native'; import {updateInputStructure} from './web/utils/parserUtils'; import InputHistory from './web/InputHistory'; @@ -591,6 +592,14 @@ const MarkdownTextInput = React.forwardRef( divRef.current = r as MarkdownTextInputElement; }; + const handleTouchStart = (event: TouchEvent) => { + if (!onTouchStart) { + return; + } + const e = event as unknown as GestureResponderEvent; + onTouchStart(e); + }; + useClientEffect( function parseAndStyleValue() { if (!divRef.current || value === divRef.current.value) { @@ -677,7 +686,7 @@ const MarkdownTextInput = React.forwardRef( dir={dir} inputMode={inputMode} onSelect={updateSelection} - onTouchStart={onTouchStart} + onTouchStart={handleTouchStart} /> ); },