Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix Android lineHeight control changes.
  • Loading branch information
enejb committed Aug 27, 2021
commit 47c172737058a8c1ac94c72ca58d077240d640fb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public void setFontSize(ReactAztecText view, float fontSize) {
(int) Math.ceil(PixelUtil.toPixelFromSP(fontSize)));
}

@ReactProp(name = ViewProps.LINE_HEIGHT)
public void setLineHeight(ReactAztecText view, float lineHeight) {
float textSize = view.getTextSize();
view.setLineSpacing((lineHeight - textSize), (float) (lineHeight / textSize));
}

@ReactProp(name = ViewProps.FONT_FAMILY)
public void setFontFamily(ReactAztecText view, String fontFamily) {
int style = Typeface.NORMAL;
Expand Down
11 changes: 9 additions & 2 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const gutenbergFormatNamesToAztec = {

const EMPTY_PARAGRAPH_TAGS = '<p></p>';
const DEFAULT_FONT_SIZE = 16;
const DEFAULT_LINE_HEIGHT = 1.5;
const DEFAULT_LINE_HEIGHT = 1.6;

export class RichText extends Component {
constructor( {
Expand Down Expand Up @@ -771,6 +771,13 @@ export class RichText extends Component {
this.needsSelectionUpdate = true;
this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
}

if (
nextProps?.style?.lineHeight !== this.props?.style?.lineHeight
) {
this.needsSelectionUpdate = true;
this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
}
}

return true;
Expand Down Expand Up @@ -1016,7 +1023,6 @@ export class RichText extends Component {
? { width }
: { maxWidth } ),
minHeight: this.state.height,
lineHeight,
} }
text={ {
text: html,
Expand Down Expand Up @@ -1061,6 +1067,7 @@ export class RichText extends Component {
maxImagesWidth={ 200 }
fontFamily={ this.props.fontFamily || defaultFontFamily }
fontSize={ fontSize }
lineHeight={ lineHeight }
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
disableEditingMenu={ disableEditingMenu }
Expand Down