Skip to content

Commit

Permalink
Merge native mobile release v1.0 to master (#14061)
Browse files Browse the repository at this point in the history
* Bump plugin version to 5.1.0-rc.1

* RichText: only ignore input types that insert HTML (#13914)

* RichText: only ignore input types that insert HTML

* Mark RichTextInputEvent as unstable

* Use Set

* Bump plugin version to 5.1.0

* Deprecate RichTextInputEvent on mobile too (#13975)

* The undelying RichText component implementation has changed the parameters returned onChange, and we forgot to update the PostTitle component (#13967)

* Fixes wrong state comparison (#13987)

Upload media progress bar is missing while media is uploading new

* Re-add rootTagsToEliminate prop (#14006)

* [Mobile]Update PostTitle to apply borders when it is focused (#13970)

* Trigger onFocusStatusChange from PostTitle

* Fix lint issue

* Update post title shadow mechanism

Also open inner ref so that focus state can be updated when focus is made programmatically

* Update props

* Update onRef as ref

* Update title padding&margin

* Mobile: Rename ref to innerRef on PostTitle (#14024)

* Fixes a red screen in mobile. (#14011)

* Change background color on image placeholder block (#14033)

* Changed upload media icon color

* Changed media placeholder background color

* Fix post title native syntax (#14041)

* Fix unexpected token in native code

* Dummy commit to trigger Travis

* Include the rnmobile release branch to Travis builds

* Mobile: Links UI using BottomSheet component (#13972)

* Mobile: Replaced Links UI with bottom-sheet component

* Mobile links UI: Removed commented code.

* Mobile: Fix lint issues

* Mobile Links UI: Remove autofocus on Android.
This hides an issue where the modal sometimes will be under the keyboard on Android.

* Fixes pasting links. (#14038)

* Update post title vertical paddings (#14040)

* Add try/catch fallback to plain text for pasteHandler (#14044)

* Fix link interface. (#14052)

* [Mobile]Fix title padding on Android (#14057)

* Remove title vertical paddings for Android

* Revert "Remove title vertical paddings for Android"

This reverts commit 09f0d35.

* Import padding variables

* Revert wrong format image color (#14058)

* Stop building the mobile release branch on Travis (#14060)
  • Loading branch information
hypest authored Feb 22, 2019
1 parent d9b232d commit 666989f
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 222 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ImageEdit extends React.Component {
updateMediaProgress( payload ) {
const { setAttributes } = this.props;
this.setState( { progress: payload.progress, isUploadInProgress: true, isUploadFailed: false } );
if ( payload.mediaUrl !== undefined ) {
if ( payload.mediaUrl ) {
setAttributes( { url: payload.mediaUrl } );
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
default as RichText,
RichTextShortcut,
RichTextToolbarButton,
RichTextInputEvent,
UnstableRichTextInputEvent,
} from './rich-text';
export { default as MediaPlaceholder } from './media-placeholder';
export { default as BlockFormatControls } from './block-format-controls';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #f2f2f2;
background-color: #e9eff3;
padding-left: 12;
padding-right: 12;
padding-top: 12;
Expand Down
13 changes: 10 additions & 3 deletions packages/editor/src/components/mobile/bottom-sheet/cell.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import styles from './styles.scss';
import platformStyles from './cellStyles.scss';

export default class Cell extends Component {
constructor() {
constructor( props ) {
super( ...arguments );
this.state = {
isEditingValue: false,
isEditingValue: props.autoFocus || false,
};
}

Expand Down Expand Up @@ -53,7 +53,7 @@ export default class Cell extends Component {

const onCellPress = () => {
if ( isValueEditable ) {
this.setState( { isEditingValue: true } );
startEditing();
} else if ( onPress !== undefined ) {
onPress();
}
Expand All @@ -63,6 +63,12 @@ export default class Cell extends Component {
this.setState( { isEditingValue: false } );
};

const startEditing = () => {
if ( this.state.isEditingValue === false ) {
this.setState( { isEditingValue: true } );
}
};

const separatorStyle = () => {
const leftMarginStyle = { ...styles.cellSeparator, ...platformStyles.separatorMarginLeft };
switch ( separatorType ) {
Expand Down Expand Up @@ -97,6 +103,7 @@ export default class Cell extends Component {
onChangeText={ onChangeValue }
editable={ isValueEditable }
pointerEvents={ this.state.isEditingValue ? 'auto' : 'none' }
onFocus={ startEditing }
onBlur={ finishEditing }
{ ...valueProps }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
border-top-left-radius: 8px;
width: 100%;
max-width: 512;
padding-bottom: 0;
}

.content {
Expand Down
76 changes: 54 additions & 22 deletions packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { View } from 'react-native';

/**
* WordPress dependencies
*/
Expand All @@ -8,6 +13,11 @@ import { withDispatch } from '@wordpress/data';
import { withFocusOutside } from '@wordpress/components';
import { withInstanceId, compose } from '@wordpress/compose';

/**
* Internal dependencies
*/
import styles from './style.scss';

const minHeight = 30;

class PostTitle extends Component {
Expand All @@ -16,17 +26,31 @@ class PostTitle extends Component {

this.onSelect = this.onSelect.bind( this );
this.onUnselect = this.onUnselect.bind( this );
this.titleViewRef = null;

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

componentDidMount() {
if ( this.props.innerRef ) {
this.props.innerRef( this );
}
}

handleFocusOutside() {
this.onUnselect();
}

focus() {
if ( this.titleViewRef ) {
this.titleViewRef.focus();
this.setState( { isSelected: true } );
}
}

onSelect() {
this.setState( { isSelected: true } );
this.props.clearSelectedBlock();
Expand All @@ -41,33 +65,41 @@ class PostTitle extends Component {
placeholder,
style,
title,
focusedBorderColor,
borderStyle,
} = this.props;

const decodedPlaceholder = decodeEntities( placeholder );
const borderColor = this.state.isSelected ? focusedBorderColor : 'transparent';

return (
<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 }
value={ title }
onSplit={ this.props.onEnterPress }
setRef={ this.props.setRef }
>
</RichText>
<View style={ [ styles.titleContainer, borderStyle, { borderColor } ] }>
<RichText
tagName={ 'p' }
rootTagsToEliminate={ [ 'strong' ] }
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={ ( value ) => {
this.props.onUpdate( value );
} }
onContentSizeChange={ ( event ) => {
this.setState( { aztecHeight: event.aztecHeight } );
} }
placeholder={ decodedPlaceholder }
value={ title }
onSplit={ this.props.onEnterPress }
setRef={ ( ref ) => {
this.titleViewRef = ref;
} }
>
</RichText>
</View>
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/components/post-title/style.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

@import "variables.scss";

.titleContainer {
padding-left: 16;
padding-right: 16;
padding-top: $title-block-padding-top;
padding-bottom: $title-block-padding-bottom;
margin-top: 24;
}
34 changes: 26 additions & 8 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ const unescapeSpaces = ( text ) => {
return text.replace( /&nbsp;|&#160;/gi, ' ' );
};

/**
* Calls {@link pasteHandler} with a fallback to plain text when HTML processing
* results in errors
*
* @param {Object} [options] The options to pass to {@link pasteHandler}
*
* @return {Array|string} A list of blocks or a string, depending on
* `handlerMode`.
*/
const saferPasteHandler = ( options ) => {
try {
return pasteHandler( options );
} catch ( error ) {
window.console.log( 'Pasting HTML failed:', error );
window.console.log( 'HTML:', options.HTML );
window.console.log( 'Falling back to plain text.' );
// fallback to plain text
return pasteHandler( { ...options, HTML: '' } );
}
};

const gutenbergFormatNamesToAztec = {
'core/bold': 'bold',
'core/italic': 'italic',
Expand Down Expand Up @@ -289,9 +310,8 @@ export class RichText extends Component {
},
} );
this.lastContent = this.valueToFormat( linkedRecord );
this.props.onChange( {
content: this.lastContent,
} );
this.lastEventCount = undefined;
this.props.onChange( this.lastContent );

// Allows us to ask for this information when we get a report.
window.console.log( 'Created link:\n\n', trimmedText );
Expand All @@ -310,7 +330,7 @@ export class RichText extends Component {
mode = 'AUTO';
}

const pastedContent = pasteHandler( {
const pastedContent = saferPasteHandler( {
HTML: pastedHtml,
plainText: pastedText,
mode,
Expand All @@ -324,9 +344,7 @@ export class RichText extends Component {
const newContent = this.valueToFormat( insertedContent );
this.lastEventCount = undefined;
this.lastContent = newContent;
this.props.onChange( {
content: this.lastContent,
} );
this.props.onChange( this.lastContent );
} else if ( onSplit ) {
if ( ! pastedContent.length ) {
return;
Expand Down Expand Up @@ -568,4 +586,4 @@ RichTextContainer.Content.defaultProps = {
export default RichTextContainer;
export { RichTextShortcut } from './shortcut';
export { RichTextToolbarButton } from './toolbar-button';
export { RichTextInputEvent } from './input-event';
export { UnstableRichTextInputEvent } from './input-event';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { Component } from '@wordpress/element';

export class RichTextInputEvent extends Component {
export class UnstableRichTextInputEvent extends Component {
render() {
return null;
}
Expand Down
24 changes: 0 additions & 24 deletions packages/format-library/src/link/button.native.js

This file was deleted.

20 changes: 9 additions & 11 deletions packages/format-library/src/link/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ export const link = {

return (
<Fragment>
{ this.state.addingLink &&
<ModalLinkUI
isVisible
isActive={ isActive }
activeAttributes={ activeAttributes }
onClose={ this.stopAddingLink }
onChange={ onChange }
onRemove={ this.onRemoveFormat }
value={ linkSelection }
/>
}
<ModalLinkUI
isVisible={ this.state.addingLink }
isActive={ isActive }
activeAttributes={ activeAttributes }
onClose={ this.stopAddingLink }
onChange={ onChange }
onRemove={ this.onRemoveFormat }
value={ linkSelection }
/>
<RichTextToolbarButton
name="link"
icon="admin-links"
Expand Down
Loading

0 comments on commit 666989f

Please sign in to comment.