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 mobile development branch into master (v2) #14503

Merged
merged 45 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
926ed3f
[Native mobile] Bring release v1.0.1 back to "mobile develop" (#14075)
hypest Feb 24, 2019
4f166f4
Rnmobile/refactor rich text sizing code (#14164)
SergioEstevao Mar 4, 2019
3f702dd
Mobile: Fix pasting in header (#14118)
diegoreymendez Mar 5, 2019
2a41903
Mobile: Fix links ui on landscape iOS v2 (#14240)
etoledom Mar 5, 2019
eb59a11
Mobile: Avoid adding empty link to text. (#14270)
etoledom Mar 7, 2019
60fbafb
Avoid to reset html to empty string if block is heading and platform …
marecar3 Mar 8, 2019
8f82fd3
Set minHeight based on fontSize or style. (#14344)
SergioEstevao Mar 8, 2019
ea8d9d7
Remove unused styles classes. (#14338)
SergioEstevao Mar 12, 2019
38377fe
[Mobile]Fix placeholder position of block appender (#14386)
pinarol Mar 12, 2019
de77ad8
[Mobile]Update caret position on insert link (#14317)
pinarol Mar 13, 2019
a981491
Get the last master changes into the mobile develop branch (#14375)
Tug Mar 14, 2019
3f234fa
[RNmobile] Bring Placeholder text back working on Heading blocks (#14…
daniloercoli Mar 14, 2019
3581b0e
Add disableEditingMenu prop to manage showing editing menu on iOS (#1…
pinarol Mar 15, 2019
d38fc17
Merge remote-tracking branch 'origin/master' into rnmobile/develop
Tug Mar 18, 2019
aece780
Fix merge errors
Tug Mar 19, 2019
3b96fab
Update README.md
Tug Mar 19, 2019
475fa28
Fix tab linting error in scss
Tug Mar 19, 2019
87a8ca4
[React Native] request cancel image upload (#14391)
mzorz Mar 19, 2019
1fd1aef
Fix lint errors
Tug Mar 21, 2019
c64ef84
Investigate travis error
Tug Mar 21, 2019
0c528f7
Line modifications for packages/block-editor/src/index.js
Tug Mar 21, 2019
aa021f4
Fix circle dependency
Tug Mar 21, 2019
61c075e
Update README.md
Tug Mar 21, 2019
f7c1604
Revert travis logging
Tug Mar 21, 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
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* External dependencies
*/
import { TextInput, TouchableWithoutFeedback, View } from 'react-native';
import { TouchableWithoutFeedback, View } from 'react-native';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { RichText } from '@wordpress/block-editor';
import { compose } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
import { withSelect, withDispatch } from '@wordpress/data';
Expand All @@ -21,6 +22,7 @@ export function DefaultBlockAppender( {
isVisible,
onAppend,
placeholder,
containerStyle,
} ) {
if ( isLocked || ! isVisible ) {
return null;
Expand All @@ -32,16 +34,10 @@ export function DefaultBlockAppender( {
<TouchableWithoutFeedback
onPress={ onAppend }
>
<View style={ styles.blockHolder } pointerEvents="box-only">
<View style={ styles.blockContainer }>
<TextInput
style={ styles.textView }
textAlignVertical="top"
multiline
numberOfLines={ 0 }
value={ value }
/>
</View>
<View style={ [ styles.blockHolder, containerStyle ] } pointerEvents="box-only">
<RichText
placeholder={ value }
/>
</View>
</TouchableWithoutFeedback>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// @format

@import "variables.scss";
@import "colors.scss";

.blockHolder {
flex: 1 1 auto;
}
Expand Down
22 changes: 22 additions & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Block Creation Components
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why this file exists separate from index.js? Is it necessary that it does? Or did it just help simplify the migration? I'm concerned about the maintenance overhead in how new exported components need to be added to two files. And typically it's only made apparent after the fact (I'm encountering this in #21467).

Could we have a file of "common" imports? I mean, ideally all the components are made available in either environment, but I suppose it may unavoidable we'd need to exclude / include some as specific to one or the other.

export { default as BlockControls } from './block-controls';
export { default as BlockEdit } from './block-edit';
export { default as BlockFormatControls } from './block-format-controls';
export * from './colors';
export * from './font-sizes';
export { default as InspectorControls } from './inspector-controls';
export { default as PlainText } from './plain-text';
export {
default as RichText,
RichTextShortcut,
RichTextToolbarButton,
UnstableRichTextInputEvent,
} from './rich-text';
export { default as MediaPlaceholder } from './media-placeholder';
export { default as URLInput } from './url-input';

// Content Related Components
export { default as DefaultBlockAppender } from './default-block-appender';

// State Related Components
export { default as BlockEditorProvider } from './provider';
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "variables.scss";

.block-editor-plain-text {
font-family: $default-regular-font;
Expand Down
150 changes: 150 additions & 0 deletions packages/block-editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { SlotFillProvider } from '@wordpress/components';
import { withDispatch, RegistryConsumer } from '@wordpress/data';
import { createHigherOrderComponent, compose } from '@wordpress/compose';

/**
* Higher-order component which renders the original component with the current
* registry context passed as its `registry` prop.
*
* @param {WPComponent} OriginalComponent Original component.
*
* @return {WPComponent} Enhanced component.
*/
const withRegistry = createHigherOrderComponent(
( OriginalComponent ) => ( props ) => (
<RegistryConsumer>
{ ( registry ) => (
<OriginalComponent
{ ...props }
registry={ registry }
/>
) }
</RegistryConsumer>
),
'withRegistry'
);

class BlockEditorProvider extends Component {
componentDidMount() {
this.props.updateSettings( this.props.settings );
this.props.resetBlocks( this.props.value );
this.attachChangeObserver( this.props.registry );
}

componentDidUpdate( prevProps ) {
const {
settings,
updateSettings,
value,
resetBlocks,
registry,
} = this.props;

if ( settings !== prevProps.settings ) {
updateSettings( settings );
}

if ( registry !== prevProps.registry ) {
this.attachChangeObserver( registry );
}

if ( this.isSyncingOutcomingValue ) {
this.isSyncingOutcomingValue = false;
} else if ( value !== prevProps.value ) {
this.isSyncingIncomingValue = true;
resetBlocks( value );
}
}

componentWillUnmount() {
if ( this.unsubscribe ) {
this.unsubscribe();
}
}

/**
* Given a registry object, overrides the default dispatch behavior for the
* `core/block-editor` store to interpret a state change and decide whether
* we should call `onChange` or `onInput` depending on whether the change
* is persistent or not.
*
* This needs to be done synchronously after state changes (instead of using
* `componentDidUpdate`) in order to avoid batching these changes.
*
* @param {WPDataRegistry} registry Registry from which block editor
* dispatch is to be overriden.
*/
attachChangeObserver( registry ) {
if ( this.unsubscribe ) {
this.unsubscribe();
}

const {
getBlocks,
isLastBlockChangePersistent,
} = registry.select( 'core/block-editor' );

let blocks = getBlocks();
let isPersistent = isLastBlockChangePersistent();

this.unsubscribe = registry.subscribe( () => {
const {
onChange,
onInput,
} = this.props;
const newBlocks = getBlocks();
const newIsPersistent = isLastBlockChangePersistent();
if ( newBlocks !== blocks && this.isSyncingIncomingValue ) {
this.isSyncingIncomingValue = false;
blocks = newBlocks;
isPersistent = newIsPersistent;
return;
}

if (
newBlocks !== blocks ||
// This happens when a previous input is explicitely marked as persistent.
( newIsPersistent && ! isPersistent )
) {
blocks = newBlocks;
isPersistent = newIsPersistent;

this.isSyncingOutcomingValue = true;
if ( isPersistent ) {
onChange( blocks );
} else {
onInput( blocks );
}
}
} );
}

render() {
const { children } = this.props;

return (
<SlotFillProvider>
{ children }
</SlotFillProvider>
);
}
}

export default compose( [
withDispatch( ( dispatch ) => {
const {
updateSettings,
resetBlocks,
} = dispatch( 'core/block-editor' );

return {
updateSettings,
resetBlocks,
};
} ),
withRegistry,
] )( BlockEditorProvider );
35 changes: 29 additions & 6 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class RichText extends Component {
start: 0,
end: 0,
formatPlaceholder: null,
height: 0,
};
}

Expand All @@ -96,9 +97,16 @@ export class RichText extends Component {
*/
getRecord() {
const { formatPlaceholder, start, end } = this.state;

let value = this.props.value === undefined ? null : this.props.value;

// Since we get the text selection from Aztec we need to be in sync with the HTML `value`
// Removing leading white spaces using `trim()` should make sure this is the case.
const { formats, replacements, text } = this.formatToValue( this.props.value === undefined ? undefined : this.props.value.trimLeft() );
if ( typeof value === 'string' || value instanceof String ) {
value = value.trimLeft();
}

const { formats, replacements, text } = this.formatToValue( value );

return { formats, replacements, formatPlaceholder, text, start, end };
}
Expand Down Expand Up @@ -189,6 +197,12 @@ export class RichText extends Component {
} );
if ( newContent && newContent !== this.props.value ) {
this.props.onChange( newContent );
if ( record.needsSelectionUpdate && record.start && record.end ) {
this.setState( { start: record.start, end: record.end } );
}
this.setState( {
needsSelectionUpdate: record.needsSelectionUpdate,
} );
} else {
// make sure the component rerenders without refreshing the text on gutenberg
// (this can trigger other events that might update the active formats on aztec)
Expand Down Expand Up @@ -235,9 +249,7 @@ export class RichText extends Component {

onContentSizeChange( contentSize ) {
const contentHeight = contentSize.height;
this.props.onContentSizeChange( {
aztecHeight: contentHeight,
} );
this.setState( { height: contentHeight } );
}

// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -501,6 +513,13 @@ export class RichText extends Component {
this.lastEventCount = undefined; // force a refresh on the native side
}

let minHeight = styles[ 'block-editor-rich-text' ].minHeight;
if ( style && style.minHeight ) {
minHeight = style.minHeight;
}

const selection = this.state.needsSelectionUpdate ? { start: this.state.start, end: this.state.end } : null;

return (
<View>
{ isSelected && (
Expand All @@ -516,7 +535,11 @@ export class RichText extends Component {
this.props.setRef( ref );
}
} }
text={ { text: html, eventCount: this.lastEventCount } }
style={ {
...style,
minHeight: Math.max( minHeight, this.state.height ),
} }
text={ { text: html, eventCount: this.lastEventCount, selection } }
placeholder={ this.props.placeholder }
placeholderTextColor={ this.props.placeholderTextColor || styles[ 'block-editor-rich-text' ].textDecorationColor }
onChange={ this.onChange }
Expand All @@ -533,11 +556,11 @@ export class RichText extends Component {
blockType={ { tag: tagName } }
color={ 'black' }
maxImagesWidth={ 200 }
style={ style }
fontFamily={ this.props.fontFamily || styles[ 'block-editor-rich-text' ].fontFamily }
fontSize={ this.props.fontSize }
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
disableEditingMenu={ this.props.disableEditingMenu }
/>
{ isSelected && <FormatEdit value={ record } onChange={ this.onFormatChange } /> }
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "variables.scss";
@import "colors.scss";

.block-editor-rich-text {
font-family: $default-regular-font;
text-decoration-color: $gray;
min-height: $min-height-paragraph;
}
2 changes: 0 additions & 2 deletions packages/block-library/src/code/theme.native.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* stylelint-disable font-family-no-missing-generic-family-keyword */

@import "variables.scss";

.blockCode {
font-family: $default-monospace-font;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/heading/editor.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.wp-block-heading {
min-height: $min-height-heading;
}
5 changes: 5 additions & 0 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import { isURL } from '@wordpress/url';
import { doAction, hasAction } from '@wordpress/hooks';

/**
* Internal dependencies
Expand Down Expand Up @@ -87,6 +88,10 @@ class ImageEdit extends React.Component {
}

componentWillUnmount() {
// this action will only exist if the user pressed the trash button on the block holder
if ( hasAction( 'blocks.onRemoveBlockCheckUpload' ) && this.state.isUploadInProgress ) {
doAction( 'blocks.onRemoveBlockCheckUpload', this.props.attributes.id );
}
this.removeMediaUploadListener();
}

Expand Down
2 changes: 0 additions & 2 deletions packages/block-library/src/image/styles.native.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @format

@import "variables.scss";

.imageContainer {
flex: 1;
justify-content: center;
Expand Down
2 changes: 0 additions & 2 deletions packages/block-library/src/nextpage/editor.native.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @format

@import "variables.scss";

.block-library-nextpage__container {
align-items: center;
padding: 4px 4px 4px 4px;
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@wordpress/a11y": "file:../a11y",
Expand Down
Loading