Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add onTouchStart #499

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -98,6 +99,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
onContentSizeChange,
id,
inputMode,
onTouchStart,
},
ref,
) => {
Expand Down Expand Up @@ -590,6 +592,14 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
divRef.current = r as MarkdownTextInputElement;
};

const handleTouchStart = (event: TouchEvent<HTMLDivElement>) => {
if (!onTouchStart) {
return;
}
const e = event as unknown as GestureResponderEvent;
onTouchStart(e);
tomekzaw marked this conversation as resolved.
Show resolved Hide resolved
};

useClientEffect(
function parseAndStyleValue() {
if (!divRef.current || value === divRef.current.value) {
Expand Down Expand Up @@ -676,6 +686,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
dir={dir}
inputMode={inputMode}
onSelect={updateSelection}
onTouchStart={handleTouchStart}
/>
);
},
Expand Down
Loading