-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix context menu when long press on url and email link
- Loading branch information
Showing
12 changed files
with
280 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
import React from 'react'; | ||
import * as anchorForCommentsOnlyPropTypes from './anchorForCommentsOnlyPropTypes'; | ||
import _ from 'underscore'; | ||
import {propTypes as anchorForCommentsOnlyPropTypes, defaultProps} from './anchorForCommentsOnlyPropTypes'; | ||
import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly'; | ||
import canUseTouchScreen from '../../libs/canUseTouchscreen'; | ||
import ControlSelection from '../../libs/ControlSelection'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; | ||
|
||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
const AnchorForCommentsOnly = props => <BaseAnchorForCommentsOnly {...props} />; | ||
AnchorForCommentsOnly.propTypes = anchorForCommentsOnlyPropTypes.propTypes; | ||
AnchorForCommentsOnly.defaultProps = anchorForCommentsOnlyPropTypes.defaultProps; | ||
const propTypes = { | ||
...anchorForCommentsOnlyPropTypes, | ||
...windowDimensionsPropTypes, | ||
}; | ||
|
||
const AnchorForCommentsOnly = props => ( | ||
<BaseAnchorForCommentsOnly | ||
onPressIn={() => props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} | ||
onPressOut={() => ControlSelection.unblock()} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...(_.omit(props, ['onPressIn', 'onPressOut']))} | ||
/> | ||
); | ||
|
||
AnchorForCommentsOnly.propTypes = propTypes; | ||
AnchorForCommentsOnly.defaultProps = defaultProps; | ||
AnchorForCommentsOnly.displayName = 'AnchorForCommentsOnly'; | ||
|
||
export default AnchorForCommentsOnly; | ||
export default withWindowDimensions(AnchorForCommentsOnly); |
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
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
Oops, something went wrong.