-
-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x] Added textProps prop #349
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
058a829
Added textProps prop that would be applyed to text wrapper
Peretz30 28d57f2
Added textWrapperProps prop
Peretz30 5e23fb9
Merge branch 'master' of https://github.com/Peretz30/react-native-ren…
Peretz30 d2c5175
fix code formatting
Peretz30 ea0488f
some refactoring
Peretz30 a7abfd8
Revert "fix code formatting"
Peretz30 685f1e2
Revert "some refactoring"
Peretz30 dbf100b
Revert "Merge branch 'master' of https://github.com/Peretz30/react-na…
Peretz30 8863b13
fix format
Peretz30 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,8 @@ export default class HTML extends PureComponent { | |
emSize: PropTypes.number.isRequired, | ||
ptSize: PropTypes.number.isRequired, | ||
baseFontStyle: PropTypes.object.isRequired, | ||
textSelectable: PropTypes.bool, | ||
renderersProps: PropTypes.object, | ||
allowFontScaling: PropTypes.bool | ||
textWrapperProps: PropTypes.object, | ||
} | ||
|
||
static defaultProps = { | ||
|
@@ -64,8 +63,7 @@ export default class HTML extends PureComponent { | |
baseFontStyle: { fontSize: 14 }, | ||
tagsStyles: {}, | ||
classesStyles: {}, | ||
textSelectable: false, | ||
allowFontScaling: true | ||
textWrapperProps: {}, | ||
} | ||
|
||
constructor (props) { | ||
|
@@ -388,15 +386,14 @@ export default class HTML extends PureComponent { | |
*/ | ||
renderRNElements (RNElements, parentWrapper = 'root', parentIndex = 0, props = this.props) { | ||
const { | ||
allowFontScaling, | ||
allowedStyles, | ||
baseFontStyle, | ||
classesStyles, | ||
emSize, | ||
ignoredStyles, | ||
ptSize, | ||
tagsStyles, | ||
textSelectable | ||
textWrapperProps, | ||
} = props; | ||
|
||
return RNElements && RNElements.length ? RNElements.map((element, index) => { | ||
|
@@ -446,7 +443,6 @@ export default class HTML extends PureComponent { | |
const classStyles = _getElementClassStyles(attribs, classesStyles); | ||
const textElement = data ? | ||
<Text | ||
allowFontScaling={allowFontScaling} | ||
style={computeTextStyles( | ||
element, | ||
{ | ||
|
@@ -459,6 +455,7 @@ export default class HTML extends PureComponent { | |
ignoredStyles, | ||
allowedStyles | ||
})} | ||
{ ...textWrapperProps } | ||
> | ||
{ data } | ||
</Text> : | ||
|
@@ -474,8 +471,7 @@ export default class HTML extends PureComponent { | |
|
||
const renderersProps = {}; | ||
if (Wrapper === Text) { | ||
renderersProps.allowFontScaling = allowFontScaling; | ||
renderersProps.selectable = textSelectable; | ||
renderersProps = textWrapperProps; | ||
} | ||
return ( | ||
<Wrapper key={key} style={style} {...renderersProps}> | ||
|
@@ -487,7 +483,7 @@ export default class HTML extends PureComponent { | |
} | ||
|
||
render () { | ||
const { allowFontScaling, customWrapper, remoteLoadingView, remoteErrorView } = this.props; | ||
const { textWrapperProps, customWrapper, remoteLoadingView, remoteErrorView } = this.props; | ||
const { RNNodes, loadingRemoteURL, errorLoadingRemoteURL } = this.state; | ||
if (!RNNodes && !loadingRemoteURL && !errorLoadingRemoteURL) { | ||
return null; | ||
|
@@ -504,7 +500,7 @@ export default class HTML extends PureComponent { | |
remoteErrorView(this.props, this.state) : | ||
( | ||
<View style={{ flex: 1, alignItems: 'center' }}> | ||
<Text allowFontScaling={allowFontScaling} style={{ fontStyle: 'italic', fontSize: 16 }}>Could not load { this.props.uri }</Text> | ||
<Text { ...textWrapperProps } style={{ fontStyle: 'italic', fontSize: 16 }}>Could not load { this.props.uri }</Text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ibdem |
||
</View> | ||
); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied