-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12987 from b1tjoy/b1tjoy-fix-8311
Fix context menu when long press on url and email link
- Loading branch information
Showing
15 changed files
with
360 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 38 additions & 7 deletions
45
src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/BasePreRenderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,59 @@ | ||
import React, {forwardRef} from 'react'; | ||
import {ScrollView} from 'react-native-gesture-handler'; | ||
import {View} from 'react-native'; | ||
import {Pressable} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import htmlRendererPropTypes from '../htmlRendererPropTypes'; | ||
import withLocalize from '../../../withLocalize'; | ||
import {ShowContextMenuContext, showContextMenuForReport} from '../../../ShowContextMenuContext'; | ||
|
||
const propTypes = { | ||
/** Press in handler for the code block */ | ||
onPressIn: PropTypes.func, | ||
|
||
/** Press out handler for the code block */ | ||
onPressOut: PropTypes.func, | ||
|
||
...htmlRendererPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
onPressIn: undefined, | ||
onPressOut: undefined, | ||
}; | ||
|
||
const BasePreRenderer = forwardRef((props, ref) => { | ||
const TDefaultRenderer = props.TDefaultRenderer; | ||
const defaultRendererProps = _.omit(props, ['TDefaultRenderer']); | ||
const defaultRendererProps = _.omit(props, ['TDefaultRenderer', 'onPressIn', 'onPressOut', 'onLongPress']); | ||
|
||
return ( | ||
<ScrollView | ||
ref={ref} | ||
horizontal | ||
> | ||
<View onStartShouldSetResponder={() => true}> | ||
{/* eslint-disable-next-line react/jsx-props-no-spreading */} | ||
<TDefaultRenderer {...defaultRendererProps} /> | ||
</View> | ||
<ShowContextMenuContext.Consumer> | ||
{({ | ||
anchor, | ||
reportID, | ||
action, | ||
checkIfContextMenuActive, | ||
}) => ( | ||
<Pressable | ||
onPressIn={props.onPressIn} | ||
onPressOut={props.onPressOut} | ||
onLongPress={event => showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive)} | ||
> | ||
{/* eslint-disable-next-line react/jsx-props-no-spreading */} | ||
<TDefaultRenderer {...defaultRendererProps} /> | ||
</Pressable> | ||
)} | ||
</ShowContextMenuContext.Consumer> | ||
</ScrollView> | ||
); | ||
}); | ||
|
||
BasePreRenderer.displayName = 'BasePreRenderer'; | ||
BasePreRenderer.propTypes = htmlRendererPropTypes; | ||
BasePreRenderer.propTypes = propTypes; | ||
BasePreRenderer.defaultProps = defaultProps; | ||
|
||
export default withLocalize(BasePreRenderer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.