From e73672be728a88319ad9b96b21ad1f5449cc1ba3 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Mon, 25 Mar 2019 16:18:16 +0100 Subject: [PATCH 1/4] Add back Heading native changes that were overwritten during last merge of rnmobile/develop into master --- .../block-library/src/heading/edit.native.js | 79 +++++++++++++------ 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index 7ead0d8bf074b..fd17945cc6384 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -16,20 +16,58 @@ import { Component } from '@wordpress/element'; import { RichText, BlockControls } from '@wordpress/block-editor'; import { createBlock } from '@wordpress/blocks'; -/** - * Internal dependencies - */ -import './editor.scss'; +import styles from './editor.scss'; -const minHeight = 24; +const name = 'core/heading'; class HeadingEdit extends Component { constructor( props ) { super( props ); - this.state = { - aztecHeight: 0, - }; + this.splitBlock = this.splitBlock.bind( this ); + } + + /** + * Split handler for RichText value, namely when content is pasted or the + * user presses the Enter key. + * + * @param {?Array} before Optional before value, to be used as content + * in place of what exists currently for the + * block. If undefined, the block is deleted. + * @param {?Array} after Optional after value, to be appended in a new + * paragraph block to the set of blocks passed + * as spread. + * @param {...WPBlock} blocks Optional blocks inserted between the before + * and after value blocks. + */ + splitBlock( before, after, ...blocks ) { + const { + attributes, + insertBlocksAfter, + setAttributes, + onReplace, + } = this.props; + + if ( after !== null ) { + // Append "After" content as a new paragraph block to the end of + // any other blocks being inserted after the current paragraph. + const newBlock = createBlock( name, { content: after } ); + blocks.push( newBlock ); + } + + if ( blocks.length && insertBlocksAfter ) { + insertBlocksAfter( blocks ); + } + + const { content } = attributes; + if ( before === null ) { + onReplace( [] ); + } else if ( content !== before ) { + // Only update content if it has in-fact changed. In case that user + // has created a new paragraph at end of an existing one, the value + // of before will be strictly equal to the current content. + setAttributes( { content: before } ); + } } render() { @@ -37,7 +75,7 @@ class HeadingEdit extends Component { attributes, setAttributes, mergeBlocks, - insertBlocksAfter, + style, } = this.props; const { @@ -47,6 +85,7 @@ class HeadingEdit extends Component { } = attributes; const tagName = 'h' + level; + return ( @@ -56,28 +95,16 @@ class HeadingEdit extends Component { tagName={ tagName } value={ content } isSelected={ this.props.isSelected } + style={ { + ...style, + minHeight: styles[ 'wp-block-heading' ].minHeight, + } } onFocus={ this.props.onFocus } // always assign onFocus as a props onBlur={ this.props.onBlur } // always assign onBlur as a props onCaretVerticalPositionChange={ this.props.onCaretVerticalPositionChange } - style={ { - minHeight: Math.max( minHeight, this.state.aztecHeight ), - } } onChange={ ( value ) => setAttributes( { content: value } ) } onMerge={ mergeBlocks } - onSplit={ - insertBlocksAfter ? - ( before, after, ...blocks ) => { - setAttributes( { content: before } ); - insertBlocksAfter( [ - ...blocks, - createBlock( 'core/paragraph', { content: after } ), - ] ); - } : - undefined - } - onContentSizeChange={ ( event ) => { - this.setState( { aztecHeight: event.aztecHeight } ); - } } + onSplit={ this.splitBlock } placeholder={ placeholder || __( 'Write heading…' ) } /> From d32725b20485c0fc34b1aefaa5fdb8af0bfa268f Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Mon, 25 Mar 2019 17:29:50 +0100 Subject: [PATCH 2/4] Add back Paragraph native changes that were overwritten during last merge of rnmobile/develop into master --- .../block-library/src/paragraph/edit.native.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/block-library/src/paragraph/edit.native.js b/packages/block-library/src/paragraph/edit.native.js index aae8912194725..f7d26d596a656 100644 --- a/packages/block-library/src/paragraph/edit.native.js +++ b/packages/block-library/src/paragraph/edit.native.js @@ -14,7 +14,6 @@ import { RichText } from '@wordpress/block-editor'; /** * Internal dependencies */ -import styles from './style.scss'; const name = 'core/paragraph'; @@ -23,10 +22,6 @@ class ParagraphEdit extends Component { super( props ); this.splitBlock = this.splitBlock.bind( this ); this.onReplace = this.onReplace.bind( this ); - - this.state = { - aztecHeight: 0, - }; } /** @@ -99,8 +94,6 @@ class ParagraphEdit extends Component { content, } = attributes; - const minHeight = styles.blockText.minHeight; - return ( { setAttributes( { content: nextContent, @@ -122,9 +112,6 @@ class ParagraphEdit extends Component { onSplit={ this.splitBlock } onMerge={ mergeBlocks } onReplace={ this.onReplace } - onContentSizeChange={ ( event ) => { - this.setState( { aztecHeight: event.aztecHeight } ); - } } placeholder={ placeholder || __( 'Start writing…' ) } /> From b812b2e279fb7fc6a9a6742a006ab5e7707ba3a2 Mon Sep 17 00:00:00 2001 From: Stefanos Togoulidis Date: Sun, 24 Feb 2019 22:04:21 +0200 Subject: [PATCH 3/4] [Native mobile] Bring release v1.0.1 back to "mobile develop" (#14075) * Don't allow placeholder to moves once we tap on it (#14066) * Use platform based SCSS vars for block minHeight (#14070) # Conflicts: # packages/block-library/src/heading/edit.native.js # packages/editor/src/components/post-title/style.native.scss --- packages/block-library/src/heading/style.native.scss | 5 +++++ packages/block-library/src/image/edit.native.js | 11 +++-------- .../block-library/src/paragraph/style.native.scss | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 packages/block-library/src/heading/style.native.scss diff --git a/packages/block-library/src/heading/style.native.scss b/packages/block-library/src/heading/style.native.scss new file mode 100644 index 0000000000000..d5018ce8e30b8 --- /dev/null +++ b/packages/block-library/src/heading/style.native.scss @@ -0,0 +1,5 @@ +@import "variables.scss"; + +.blockText { + min-height: $min-height-heading; +} diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index 2481d1ce3184a..8158a3612af92 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -347,14 +347,6 @@ class ImageEdit extends React.Component { imageHeightWithinContainer, } = sizes; - if ( imageWidthWithinContainer === undefined ) { - return ( - - - - ); - } - let finalHeight = imageHeightWithinContainer; if ( height > 0 && height < imageHeightWithinContainer ) { finalHeight = height; @@ -369,6 +361,9 @@ class ImageEdit extends React.Component { { getInspectorControls() } { getMediaOptions() } + { ! imageWidthWithinContainer && + + } Date: Tue, 26 Mar 2019 00:39:02 +0100 Subject: [PATCH 4/4] Remove unecessary imports in scss files --- packages/block-library/src/heading/style.native.scss | 1 - packages/block-library/src/paragraph/style.native.scss | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/block-library/src/heading/style.native.scss b/packages/block-library/src/heading/style.native.scss index d5018ce8e30b8..f4801b92a6bc5 100644 --- a/packages/block-library/src/heading/style.native.scss +++ b/packages/block-library/src/heading/style.native.scss @@ -1,4 +1,3 @@ -@import "variables.scss"; .blockText { min-height: $min-height-heading; diff --git a/packages/block-library/src/paragraph/style.native.scss b/packages/block-library/src/paragraph/style.native.scss index 574c3f1d05934..87d8ccedc8dc8 100644 --- a/packages/block-library/src/paragraph/style.native.scss +++ b/packages/block-library/src/paragraph/style.native.scss @@ -1,4 +1,3 @@ -@import "variables.scss"; .blockText { min-height: $min-height-paragraph;