Skip to content
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

[RN-MOBILE] fix line height crash #23507

Merged
merged 3 commits into from
Jun 26, 2020
Merged
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
15 changes: 14 additions & 1 deletion packages/react-native-aztec/src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,24 @@ class AztecView extends React.Component {

render() {
// eslint-disable-next-line no-unused-vars
const { onActiveFormatsChange, onFocus, ...otherProps } = this.props;
const { onActiveFormatsChange, style, ...otherProps } = this.props;

if ( style.hasOwnProperty( 'lineHeight' ) ) {
delete style.lineHeight;
window.console.warn(
"Removing lineHeight style as it's not supported by native AztecView"
);
// IMPORTANT: Current Gutenberg implementation is supporting line-height without unit e.g. 'line-height':1.5
// and library which we are using to convert css to react-native requires unit to be included with dimension
// https://github.com/kristerkari/css-to-react-native-transform/blob/945866e84a505fdfb1a43b03ebe4bd32784a7f22/src/index.spec.js#L1234
// which means that we would need to patch the library if we want to support line-height from native AztecView in the future.
}

return (
<TouchableWithoutFeedback onPress={ this._onPress }>
<RCTAztecView
{ ...otherProps }
style={ style }
onContentSizeChange={ this._onContentSizeChange }
onHTMLContentWithCursor={ this._onHTMLContentWithCursor }
onSelectionChange={ this._onSelectionChange }
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native-editor/src/initial-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,8 @@ else:
<!-- /wp:heading -->

<!-- wp:rss /-->

<!-- wp:heading {"align":"left","level":4,"className":"has-primary-background-color has-background","style":{"typography":{"lineHeight":"2.5"}}} -->
<h4 class="has-text-align-left has-primary-background-color has-background" style="line-height:2.5">Heading with line-height set</h4>
<!-- /wp:heading -->
`;