diff --git a/MarkdownView.js b/MarkdownView.js index 564f44e..f5d0598 100644 --- a/MarkdownView.js +++ b/MarkdownView.js @@ -81,12 +81,13 @@ class MarkdownView extends Component { onLinkPress?: (string) => void, styles?: Styles, children: string, + replaceAllDefaultStyles?: boolean, } render() { - const {rules = {}, styles = {}, onLinkPress} = this.props + const {rules = {}, styles = {}, onLinkPress, replaceAllDefaultStyles = false} = this.props - const mergedStyles = mergeStyles(DefaultStyles, styles) + const mergedStyles = replaceAllDefaultStyles ? styles : mergeStyles(DefaultStyles, styles) const mergedRules = mergeRules(SimpleMarkdown.defaultRules, simpleMarkdownRules(mergeRules(DefaultRules, rules), mergedStyles)) const markdown = (Array.isArray(this.props.children) ? this.props.children.join('') : this.props.children) + '\n\n' @@ -158,6 +159,11 @@ MarkdownView.propTypes = { */ styles: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.object, PropTypes.number])), + /** + * A boolean indicating if all default styles should be overridden by the given styles property. + */ + replaceAllDefaultStyles: PropTypes.bool, + /** * Callback function for when a link is pressed. The callback receives the URL of the link as a * string (first and only argument). diff --git a/README.md b/README.md index 65882d5..28b8732 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,12 @@ e.g. } ``` -## onLinkPress +### replaceAllDefaultStyles (default to false) + +A boolean indicating if all default styles should be overridden by the given styles property. + + +### onLinkPress Callback function for when a link is pressed. The callback receives the URL of the link as a string (first and only argument).