-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port heading block to mobile (#8774)
* Adds tagName prop to RichText Instead of forcing a paragraph, make the wrapper tag logic more generic and allow for customization * Adds React Native implementation of heading block * Fix lint issues * Remove RichText tagName default value * Remove unused (for now) class name props
- Loading branch information
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { Component } from '@wordpress/element'; | ||
import { RichText } from '@wordpress/editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './editor.scss'; | ||
|
||
const minHeight = 50; | ||
|
||
class HeadingEdit extends Component { | ||
render() { | ||
const { | ||
attributes, | ||
setAttributes, | ||
} = this.props; | ||
|
||
const { | ||
level, | ||
placeholder, | ||
} = attributes; | ||
|
||
const tagName = 'h' + level; | ||
|
||
return ( | ||
<View> | ||
<RichText | ||
tagName={ tagName } | ||
content={ { contentTree: attributes.content, eventCount: attributes.eventCount } } | ||
style={ { | ||
minHeight: Math.max( minHeight, typeof attributes.aztecHeight === 'undefined' ? 0 : attributes.aztecHeight ), | ||
} } | ||
onChange={ ( value ) => { | ||
setAttributes( value ); | ||
} } | ||
onContentSizeChange={ ( event ) => { | ||
setAttributes( { aztecHeight: event.aztecHeight } ); | ||
} } | ||
placeholder={ placeholder || __( 'Write heading…' ) } | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
export default HeadingEdit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters