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

[RNMobile] Use RichText component on Title block #13548

Merged
merged 16 commits into from
Feb 5, 2019
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
1 change: 1 addition & 0 deletions packages/block-library/src/code/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function CodeEdit( props ) {
isSelected={ props.isSelected }
onFocus={ onFocus }
onBlur={ onBlur }
fontFamily={ ( styles.blockCode.fontFamily ) }
/>
</View>
);
Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/code/theme.android.scss

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* stylelint-disable font-family-no-missing-generic-family-keyword */

@import "variables.scss";

.blockCode {
font-family: courier;
font-family: $default-monospace-font;
}

1 change: 1 addition & 0 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export default class ImageEdit extends React.Component {
<View style={ { padding: 12, flex: 1 } }>
<TextInput
style={ { textAlign: 'center' } }
fontFamily={ 'serif' }
underlineColorAndroid="transparent"
value={ caption }
placeholder={ __( 'Write caption…' ) }
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/nextpage/editor.native.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @format

@import "variables.scss";

.block-library-nextpage__container {
align-items: center;
padding: 4px 4px 4px 4px;
Expand All @@ -12,4 +14,5 @@

.block-library-nextpage__text {
text-decoration-style: solid;
font-family: $default-regular-font;
}
4 changes: 4 additions & 0 deletions packages/editor/src/components/plain-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default class PlainText extends Component {
} }
onFocus={ this.props.onFocus } // always assign onFocus as a props
onBlur={ this.props.onBlur } // always assign onBlur as a props
fontFamily={ this.props.fontFamily || ( styles[ 'editor-plain-text' ].fontFamily ) }
fontSize={ this.props.fontSize }
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
/>
);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/editor/src/components/plain-text/style.native.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@import "variables.scss";

.editor-plain-text {
font-family: $default-regular-font;
box-shadow: none;

border-width: 0;
Expand Down
43 changes: 23 additions & 20 deletions packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
/**
* External dependencies
*/
import { TextInput } from 'react-native';

/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { RichText } from '@wordpress/editor';
import { decodeEntities } from '@wordpress/html-entities';
import { withDispatch } from '@wordpress/data';
import { withFocusOutside } from '@wordpress/components';
import { withInstanceId, compose } from '@wordpress/compose';

const minHeight = 53;

class PostTitle extends Component {
constructor() {
super( ...arguments );

this.onChange = this.onChange.bind( this );
this.onSelect = this.onSelect.bind( this );
this.onUnselect = this.onUnselect.bind( this );

this.state = {
isSelected: false,
aztecHeight: 0,
};
}

Expand All @@ -38,10 +36,6 @@ class PostTitle extends Component {
this.setState( { isSelected: false } );
}

onChange( title ) {
this.props.onUpdate( title );
}

render() {
const {
placeholder,
Expand All @@ -52,18 +46,27 @@ class PostTitle extends Component {
const decodedPlaceholder = decodeEntities( placeholder );

return (
<TextInput
blurOnSubmit={ true }
textAlignVertical="top"
multiline={ false }
onSubmitEditing={ this.props.onEnterPress }
returnKeyType={ 'next' }
onChangeText={ this.onChange }
<RichText
tagName={ 'p' }
onFocus={ this.onSelect }
onBlur={ this.props.onBlur } // always assign onBlur as a props
multiline={ false }
style={ [ style, {
minHeight: Math.max( minHeight, this.state.aztecHeight ),
} ] }
fontSize={ 24 }
fontWeight={ 'bold' }
onChange={ ( event ) => {
this.props.onUpdate( event.content );
} }
onContentSizeChange={ ( event ) => {
this.setState( { aztecHeight: event.aztecHeight } );
} }
placeholder={ decodedPlaceholder }
style={ style }
value={ title }>
</TextInput>
value={ title }
onSplit={ this.props.onEnterPress }
>
</RichText>
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import styles from './style.scss';

const FORMATTING_CONTROLS = [
{
Expand Down Expand Up @@ -385,6 +386,10 @@ export class RichText extends Component {
color={ 'black' }
maxImagesWidth={ 200 }
style={ style }
fontFamily={ this.props.fontFamily || styles[ 'editor-rich-text' ].fontFamily }
fontSize={ this.props.fontSize }
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
/>
</View>
);
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/rich-text/style.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "variables.scss";

.editor-rich-text {
font-family: $default-regular-font;
}