Skip to content

Commit

Permalink
Merge pull request #17 from Automattic/feature/load-code-block-getblo…
Browse files Browse the repository at this point in the history
…ckfortype

Use getBlockForType to get the right block edit function
  • Loading branch information
hypest authored Mar 21, 2018
2 parents 8dd286f + 5d5308e commit 7a01d38
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions block-management/block-holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,23 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
}
}

render() {
// TODO: This is a place holder, this should call the edit() method of the block depending on this.props.blockType
getBlockForType() {
if ( this.props.blockType === 'code' ) {
const Code = codeBlock.edit;
// TODO: input text needs to be kept by updating the attributes
return (
<TouchableWithoutFeedback
onPress={ this.props.onBlockHolderPressed.bind( this, this.props.index ) }
>
<View style={ styles.blockHolder }>
<View style={ styles.blockTitle }>
<Text>BlockType: { this.props.blockType }</Text>
</View>
<Code
attributes={ { content: this.props.content } }
// TODO: input text needs to be kept by updating the attributes
setAttributes={ attrs => console.log( { attrs } ) }
/>
{ this.renderToolbarIfBlockFocused.bind( this )() }
</View>
</TouchableWithoutFeedback>
<Code
attributes={ { content: this.props.content } }
setAttributes={ attrs => console.log( { attrs } ) }
/>
);
} else {
// Default block placeholder
return <Text>{ this.props.content }</Text>;
}
}

render() {
return (
<TouchableWithoutFeedback
onPress={ this.props.onBlockHolderPressed.bind( this, this.props.index ) }
Expand All @@ -63,9 +57,7 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
<View style={ styles.blockTitle }>
<Text>BlockType: { this.props.blockType }</Text>
</View>
<View style={ styles.blockContent }>
<Text>{ this.props.content }</Text>
</View>
<View style={ styles.blockContainer }>{ this.getBlockForType.bind( this )() }</View>
{ this.renderToolbarIfBlockFocused.bind( this )() }
</View>
</TouchableWithoutFeedback>
Expand All @@ -77,8 +69,10 @@ const styles = StyleSheet.create( {
blockHolder: {
flex: 1,
},
blockContent: {
blockContainer: {
backgroundColor: 'white',
},
blockContent: {
padding: 10,
},
blockTitle: {
Expand Down

0 comments on commit 7a01d38

Please sign in to comment.