mattermost-mobile/app/components/markdown/markdown_link.js
Harrison Healey 07af08b74a PLT-5717 Initial markdown support (#354)
* Added CommonMark-based post rendering

* Fixed text wrapping in most block elements

* Fixed paragraphs not being rendered as children of lists

* Replaced markdown images with a placeholder

* Fixed font colour in code spans
2017-03-20 16:27:33 -03:00

28 lines
777 B
JavaScript

// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React, {PropTypes, PureComponent} from 'react';
import {Linking, Text} from 'react-native';
import CustomPropTypes from 'app/constants/custom_prop_types';
export default class MarkdownLink extends PureComponent {
static propTypes = {
children: CustomPropTypes.Children.isRequired,
href: PropTypes.string.isRequired
};
handlePress = () => {
const url = this.props.href;
Linking.canOpenURL(url).then((supported) => {
if (supported) {
Linking.openURL(url);
}
});
};
render() {
return <Text onPress={this.handlePress}>{this.props.children}</Text>;
}
}