Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions MarkdownView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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).
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).