* 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
28 lines
777 B
JavaScript
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>;
|
|
}
|
|
}
|