From 3e92c5f4a8ee1470dd9ccd1671f8d63694730248 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhus Date: Mon, 12 Mar 2018 22:28:05 +0100 Subject: [PATCH] Add support for replacing all styles --- MarkdownView.js | 10 ++++++++-- README.md | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) 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).