Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4c32806
Fix : is block focused logic on Android platform
Oct 23, 2018
5e5fafb
Implement Slot/Fill "portal" pattern in gutenberg mobile
Oct 23, 2018
defae89
Merge branch 'master' into feature/toolbar_component
Oct 24, 2018
1b9e13b
Create block toolbar
marecar3 Oct 26, 2018
5893bd0
Merge branch 'master' into feature/toolbar_component
marecar3 Oct 26, 2018
b57680f
Renamed Toolbar to InlineToolbar as we want to avoid confusion about …
marecar3 Oct 26, 2018
20c9196
Small fixes
marecar3 Oct 26, 2018
4a06731
Fixed linter errors
marecar3 Oct 26, 2018
86b3334
Fixed typo
marecar3 Oct 26, 2018
4eb2387
Build against gutenberg branch
marecar3 Oct 26, 2018
7d8b433
Use BlockEdit so that we can propagate isSelected
marecar3 Oct 31, 2018
d185c2d
Merge
marecar3 Oct 31, 2018
750a430
Update gutenberg submodule
marecar3 Oct 31, 2018
31ff3e0
Fix lint error
marecar3 Oct 31, 2018
d3c24ea
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 1, 2018
79282fc
Update gutenberg submodule
marecar3 Nov 1, 2018
20e2dd5
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 1, 2018
8a23f20
Updated gutenberg submodule
marecar3 Nov 1, 2018
be2efca
Updated gutenberg submodule
marecar3 Nov 1, 2018
e8db9c4
Updated gutenberg submodule
marecar3 Nov 1, 2018
ec60322
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 1, 2018
3ff8de2
Removed unused method
marecar3 Nov 1, 2018
63c9ea5
Fixed tests
marecar3 Nov 1, 2018
b9af427
Small fix
marecar3 Nov 1, 2018
03257ad
Updated gutenberg submodule
marecar3 Nov 1, 2018
9f0d684
Fixed lint
marecar3 Nov 1, 2018
38d23ba
Updated gutenberg submodule
marecar3 Nov 1, 2018
e78187b
Updated gutenberg submodule
marecar3 Nov 1, 2018
659a04f
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 5, 2018
10944ce
Updated gutenberg submodule
marecar3 Nov 5, 2018
f476382
Updated gutenberg submodule
marecar3 Nov 6, 2018
f015d48
Updated gutenberg submodule
marecar3 Nov 6, 2018
b3f443d
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 6, 2018
95af1b7
Updated gutenberg submodule
marecar3 Nov 6, 2018
29faa67
Move keyboard to the bottom the screen
marecar3 Nov 6, 2018
c9861d9
Add mocked style to fix tests
marecar3 Nov 7, 2018
8429f0a
Fixed lint errors on style mock
marecar3 Nov 7, 2018
967d5db
Merge branch 'master' into feature/toolbar_component
marecar3 Nov 7, 2018
ab00094
Update gutenberg submodule
marecar3 Nov 7, 2018
e2ad784
Update gutenberg submodule
marecar3 Nov 7, 2018
525ab6c
Fix for package.json to avoid failing builds
marecar3 Nov 7, 2018
1051576
Update gutenberg submodule
marecar3 Nov 7, 2018
c972b6a
Add symlinked package @wordpress/date
daniloercoli Nov 7, 2018
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
8 changes: 7 additions & 1 deletion __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/** @flow
* @format */

module.exports = {};
module.exports = {

//Mock block paragraph style with minimum height
blockText: {
minHeight: 50,
},
};
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 146 files
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,25 @@
"jsdom-jscore": "git+https://github.com/iamcco/jsdom-jscore-rn.git#6eac88dd5d5e7c21ce6382abde7dbc376d7f7f59",
"jsx-to-string": "^1.3.1",
"memize": "^1.0.5",
"moment": "^2.22.1",
"moment-timezone": "^0.5.16",
"node-libs-react-native": "^1.0.2",
"node-sass": "^4.8.3",
"react": "16.5.0",
"react-native": "0.57.1",
"react-native-hr": "git+https://github.com/Riglerr/react-native-hr.git#2d01a5cf77212d100e8b99e0310cce5234f977b3",
"react-native-modal": "^6.5.0",
"react-native-recyclerview-list": "git+https://github.com/wordpress-mobile/react-native-recyclerview-list.git#336f7159eb6e7bad467c041b3f34667d485e7b58",
"react-native-svg": "^6.5.2",
"react-native-hr": "git+https://github.com/Riglerr/react-native-hr.git#2d01a5cf77212d100e8b99e0310cce5234f977b3",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-multi": "^0.1.12",
"redux-optimist": "^1.0.0",
"refx": "^3.0.0",
"rememo": "^3.0.0",
"shallowequal": "^1.0.2",
"simple-html-tokenizer": "^0.5.1",
"tinycolor2": "^1.4.1",
"turbo-combine-reducers": "^1.0.2"
}
}
}
2 changes: 1 addition & 1 deletion react-native-aztec
Submodule react-native-aztec updated 0 files
2 changes: 1 addition & 1 deletion src/app/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe( 'App', () => {
const contentComponent = blockHolderContainer.children[ 0 ];
const inputComponent =
contentComponent.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ]
.children[ 0 ].children[ 0 ];
.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ];
expect( inputComponent.type ).toBe( 'TextInput' );
}
} );
Expand Down
7 changes: 6 additions & 1 deletion src/app/MainApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import { subscribeParentGetHtml } from 'react-native-gutenberg-bridge';

import BlockManager, { type BlockListType } from '../block-management/block-manager';
import { SlotFillProvider } from '@wordpress/components';

import type { EmitterSubscription } from 'react-native';

Expand All @@ -27,6 +28,10 @@ export default class MainScreen extends React.Component<PropsType, StateType> {
}

render() {
return <BlockManager { ...this.props } />;
return (
<SlotFillProvider>
<BlockManager { ...this.props } />
</SlotFillProvider>
);
}
}
37 changes: 7 additions & 30 deletions src/block-management/block-holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

import React from 'react';
import { View, Text, TouchableWithoutFeedback } from 'react-native';
import Toolbar from './toolbar';
import InlineToolbar from './inline-toolbar';

import type { BlockType } from '../store/';

import styles from './block-holder.scss';

// Gutenberg imports
import { getBlockType, getUnregisteredTypeHandlerName } from '@wordpress/blocks';
import { BlockEdit } from '@wordpress/editor';

type PropsType = BlockType & {
showTitle: boolean,
onChange: ( clientId: string, attributes: mixed ) => void,
onToolbarButtonPressed: ( button: number, clientId: string ) => void,
onInlineToolbarButtonPressed: ( button: number, clientId: string ) => void,
onBlockHolderPressed: ( clientId: string ) => void,
insertBlocksAfter: ( blocks: Array<Object> ) => void,
mergeBlocks: ( forward: boolean ) => void,
Expand All @@ -40,9 +40,9 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
renderToolbarIfBlockFocused() {
if ( this.props.focused ) {
return (
<Toolbar
<InlineToolbar
clientId={ this.props.clientId }
onButtonPressed={ this.props.onToolbarButtonPressed }
onButtonPressed={ this.props.onInlineToolbarButtonPressed }
/>
);
}
Expand All @@ -52,20 +52,9 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
}

getBlockForType() {
// Since unsupported blocks are handled in block-manager.js, at this point the block should definitely
// be supported.
const blockType = getBlockType( this.props.name );
const Block = blockType.edit;

let style;
if ( blockType.name === 'core/code' ) {
style = styles.blockCode;
} else if ( blockType.name === 'core/paragraph' ) {
style = styles.blockText;
}

return (
<Block
<BlockEdit
Copy link
Contributor

@gziolo gziolo Oct 31, 2018

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gziolo !

name={ this.props.name }
attributes={ { ...this.props.attributes } }
// pass a curried version of onChanged with just one argument
setAttributes={ ( attrs ) =>
Expand All @@ -74,22 +63,10 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
insertBlocksAfter={ this.props.insertBlocksAfter }
mergeBlocks={ this.props.mergeBlocks }
isSelected={ this.props.focused }
style={ style }
/>
);
}

getBlockType( blockName: String ) {
let blockType = getBlockType( blockName );

if ( ! blockType ) {
const fallbackBlockName = getUnregisteredTypeHandlerName();
blockType = getBlockType( fallbackBlockName );
}

return blockType;
}

renderBlockTitle() {
return (
<View style={ styles.blockTitle }>
Expand Down
30 changes: 22 additions & 8 deletions src/block-management/block-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import React from 'react';
import { Platform, Switch, Text, View, FlatList, KeyboardAvoidingView } from 'react-native';
import RecyclerViewList, { DataSource } from 'react-native-recyclerview-list';
import BlockHolder from './block-holder';
import { ToolbarButton } from './constants';
import { InlineToolbarButton } from './constants';
import type { BlockType } from '../store/';
import styles from './block-manager.scss';
import BlockPicker from './block-picker';
import HTMLTextInput from '../components/html-text-input';
import BlockToolbar from './block-toolbar';

// Gutenberg imports
import { createBlock, getBlockType, switchToBlockType } from '@wordpress/blocks';
Expand Down Expand Up @@ -53,9 +54,21 @@ export default class BlockManager extends React.Component<PropsType, StateType>
}

onBlockHolderPressed( clientId: string ) {
this.focusDataSourceItem( clientId );
this.props.focusBlockAction( clientId );
}

focusDataSourceItem( clientId: string ) {
for ( let i = 0; i < this.state.dataSource.size(); ++i ) {
const block = this.state.dataSource.get( i );
if ( block.clientId === clientId ) {
block.focused = true;
} else {
block.focused = false;
}
}
}

getDataSourceIndexFromClientId( clientId: string ) {
for ( let i = 0; i < this.state.dataSource.size(); ++i ) {
const block = this.state.dataSource.get( i );
Expand Down Expand Up @@ -112,25 +125,25 @@ export default class BlockManager extends React.Component<PropsType, StateType>
return null;
}

onToolbarButtonPressed( button: number, clientId: string ) {
onInlineToolbarButtonPressed( button: number, clientId: string ) {
const dataSourceBlockIndex = this.getDataSourceIndexFromClientId( clientId );
switch ( button ) {
case ToolbarButton.UP:
case InlineToolbarButton.UP:
this.state.dataSource.moveUp( dataSourceBlockIndex );
this.props.moveBlockUpAction( clientId );
break;
case ToolbarButton.DOWN:
case InlineToolbarButton.DOWN:
this.state.dataSource.moveDown( dataSourceBlockIndex );
this.props.moveBlockDownAction( clientId );
break;
case ToolbarButton.DELETE:
case InlineToolbarButton.DELETE:
this.state.dataSource.splice( dataSourceBlockIndex, 1 );
this.props.deleteBlockAction( clientId );
break;
case ToolbarButton.PLUS:
case InlineToolbarButton.PLUS:
this.showBlockTypePicker( true );
break;
case ToolbarButton.SETTINGS:
case InlineToolbarButton.SETTINGS:
// TODO: implement settings
break;
}
Expand Down Expand Up @@ -260,6 +273,7 @@ export default class BlockManager extends React.Component<PropsType, StateType>
return (
<KeyboardAvoidingView style={ { flex: 1 } } behavior={ behavior }>
{ list }
<BlockToolbar />
</KeyboardAvoidingView>
);
}
Expand Down Expand Up @@ -324,7 +338,7 @@ export default class BlockManager extends React.Component<PropsType, StateType>
<View>
<BlockHolder
key={ value.clientId }
onToolbarButtonPressed={ this.onToolbarButtonPressed.bind( this ) }
onInlineToolbarButtonPressed={ this.onInlineToolbarButtonPressed.bind( this ) }
onBlockHolderPressed={ this.onBlockHolderPressed.bind( this ) }
onChange={ this.onChange.bind( this ) }
showTitle={ this.state.inspectBlocks }
Expand Down
14 changes: 14 additions & 0 deletions src/block-management/block-toolbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Component } from 'react';
import { View } from 'react-native';
import { BlockFormatControls, BlockControls } from '@wordpress/editor';

export default class BlockToolbar extends Component {
render() {
return (
<View style={ { height: 50, backgroundColor: '#DCDCDC', flexDirection: 'row' } }>
<BlockControls.Slot />
<BlockFormatControls.Slot />
</View>
);
}
}
4 changes: 2 additions & 2 deletions src/block-management/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* @flow
*/

const ToolbarButton = {
const InlineToolbarButton = {
UP: 1,
DOWN: 2,
SETTINGS: 3,
DELETE: 4,
PLUS: 5,
};

export { ToolbarButton };
export { InlineToolbarButton };
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@

import React from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import { ToolbarButton } from './constants';
import { InlineToolbarButton } from './constants';

import styles from './toolbar.scss';
import styles from './inline-toolbar.scss';

type PropsType = {
clientId: string,
onButtonPressed: ( button: number, clientId: string ) => void,
};

export default class Toolbar extends React.Component<PropsType> {
export default class InlineToolbar extends React.Component<PropsType> {
render() {
return (
<View style={ styles.toolbar }>
<View style={ styles.inlineToolbar }>
<TouchableOpacity
onPress={ this.props.onButtonPressed.bind(
this,
ToolbarButton.PLUS,
InlineToolbarButton.PLUS,
this.props.clientId
) }
>
<View style={ styles.toolbarButton }>
<View style={ styles.inlineToolbarButton }>
<Text>+</Text>
</View>
</TouchableOpacity>
<View style={ styles.buttonSeparator } />
<TouchableOpacity
onPress={ this.props.onButtonPressed.bind( this, ToolbarButton.UP, this.props.clientId ) }
onPress={ this.props.onButtonPressed.bind( this, InlineToolbarButton.UP, this.props.clientId ) }
>
<View style={ styles.toolbarButton }>
<View style={ styles.inlineToolbarButton }>
<Text>▲</Text>
</View>
</TouchableOpacity>
<View style={ styles.buttonSeparator } />
<TouchableOpacity
onPress={ this.props.onButtonPressed.bind(
this,
ToolbarButton.DOWN,
InlineToolbarButton.DOWN,
this.props.clientId
) }
>
<View style={ styles.toolbarButton }>
<View style={ styles.inlineToolbarButton }>
<Text>▼</Text>
</View>
</TouchableOpacity>
<View style={ styles.buttonSeparator } />
<TouchableOpacity
onPress={ this.props.onButtonPressed.bind(
this,
ToolbarButton.SETTINGS,
InlineToolbarButton.SETTINGS,
this.props.clientId
) }
>
<View style={ styles.toolbarButton }>
<View style={ styles.inlineToolbarButton }>
{ /* eslint-disable-next-line jsx-a11y/accessible-emoji */ }
<Text>⚙️</Text>
</View>
Expand All @@ -64,11 +64,11 @@ export default class Toolbar extends React.Component<PropsType> {
<TouchableOpacity
onPress={ this.props.onButtonPressed.bind(
this,
ToolbarButton.DELETE,
InlineToolbarButton.DELETE,
this.props.clientId
) }
>
<View style={ styles.toolbarButton }>
<View style={ styles.inlineToolbarButton }>
<Text>🗑</Text>
</View>
</TouchableOpacity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @format */

.toolbar {
.inlineToolbar {
height: 34;
background-color: white;
flex-direction: row;
padding-left: 8;
padding-right: 8;
}

.toolbarButton {
.inlineToolbarButton {
width: 50;
justify-content: center;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions symlinked-packages-in-parent/@wordpress/date
1 change: 1 addition & 0 deletions symlinked-packages/@wordpress/date
Loading