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

Merge native mobile release v1.0 to master #14061

Merged
merged 21 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f5852b9
Bump plugin version to 5.1.0-rc.1
noisysocks Feb 18, 2019
81e13d6
RichText: only ignore input types that insert HTML (#13914)
ellatrix Feb 20, 2019
bfe46d6
Bump plugin version to 5.1.0
noisysocks Feb 20, 2019
bb39e9a
Merge branch 'master' into rnmobile/release-v1.0
hypest Feb 20, 2019
2240dcf
Deprecate RichTextInputEvent on mobile too (#13975)
hypest Feb 20, 2019
ece3caf
The undelying RichText component implementation has changed the param…
daniloercoli Feb 20, 2019
d2e2a18
Fixes wrong state comparison (#13987)
marecar3 Feb 20, 2019
811fbe0
Re-add rootTagsToEliminate prop (#14006)
pinarol Feb 21, 2019
762f769
[Mobile]Update PostTitle to apply borders when it is focused (#13970)
pinarol Feb 21, 2019
7c32d3a
Mobile: Rename ref to innerRef on PostTitle (#14024)
etoledom Feb 21, 2019
258a10b
Fixes a red screen in mobile. (#14011)
diegoreymendez Feb 22, 2019
36b7447
Change background color on image placeholder block (#14033)
marecar3 Feb 22, 2019
1171ec5
Fix post title native syntax (#14041)
Tug Feb 22, 2019
d5de5f5
Mobile: Links UI using BottomSheet component (#13972)
etoledom Feb 22, 2019
85550bb
Fixes pasting links. (#14038)
diegoreymendez Feb 22, 2019
e485688
Update post title vertical paddings (#14040)
pinarol Feb 22, 2019
331b68d
Add try/catch fallback to plain text for pasteHandler (#14044)
mkevins Feb 22, 2019
0cbf01c
Fix link interface. (#14052)
SergioEstevao Feb 22, 2019
db68e6c
[Mobile]Fix title padding on Android (#14057)
pinarol Feb 22, 2019
0718f7e
Revert wrong format image color (#14058)
marecar3 Feb 22, 2019
987a5a4
Stop building the mobile release branch on Travis (#14060)
hypest Feb 22, 2019
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
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