From 57ea22129aeea3fcdc209fe562fb87facb8681b2 Mon Sep 17 00:00:00 2001 From: etoledom Date: Thu, 18 Apr 2019 16:55:01 +0200 Subject: [PATCH 1/4] RNMobile: Add ability to send extra props (i.e. props needed just for mobile) to the list block. --- packages/block-library/src/list/edit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/block-library/src/list/edit.js b/packages/block-library/src/list/edit.js index 9695563538efda..a328092998e98c 100644 --- a/packages/block-library/src/list/edit.js +++ b/packages/block-library/src/list/edit.js @@ -12,6 +12,7 @@ export default function ListEdit( { mergeBlocks, onReplace, className, + ...props } ) { const { ordered, values } = attributes; @@ -47,6 +48,7 @@ export default function ListEdit( { } onRemove={ () => onReplace( [] ) } onTagNameChange={ ( tag ) => setAttributes( { ordered: tag === 'ol' } ) } + { ...props } /> ); } From 70d47f5bb8043894341e48a5caa54b68ab844743 Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 19 Apr 2019 18:05:22 +0200 Subject: [PATCH 2/4] Adding onCaretVerticalPositionChange to RichText via context --- packages/block-editor/src/components/block-edit/index.js | 8 ++++---- .../block-editor/src/components/rich-text/index.native.js | 1 + packages/block-library/src/list/edit.js | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/block-edit/index.js b/packages/block-editor/src/components/block-edit/index.js index cb98989d852558..63c475a50692ff 100644 --- a/packages/block-editor/src/components/block-edit/index.js +++ b/packages/block-editor/src/components/block-edit/index.js @@ -27,13 +27,13 @@ class BlockEdit extends Component { ); } - propsToContext( name, isSelected, clientId, onFocus ) { - return { name, isSelected, clientId, onFocus }; + propsToContext( name, isSelected, clientId, onFocus, onCaretVerticalPositionChange ) { + return { name, isSelected, clientId, onFocus, onCaretVerticalPositionChange }; } render() { - const { name, isSelected, clientId, onFocus } = this.props; - const value = this.propsToContext( name, isSelected, clientId, onFocus ); + const { name, isSelected, clientId, onFocus, onCaretVerticalPositionChange } = this.props; + const value = this.propsToContext( name, isSelected, clientId, onFocus, onCaretVerticalPositionChange ); return ( diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index ffea24cffbf2a5..ea0a96bd989c93 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -769,6 +769,7 @@ const RichTextContainer = compose( [ clientId: context.clientId, isSelected: context.isSelected, onFocus: context.onFocus || ownProps.onFocus, + onCaretVerticalPositionChange: context.onCaretVerticalPositionChange, }; } ), ] )( RichText ); diff --git a/packages/block-library/src/list/edit.js b/packages/block-library/src/list/edit.js index a328092998e98c..9695563538efda 100644 --- a/packages/block-library/src/list/edit.js +++ b/packages/block-library/src/list/edit.js @@ -12,7 +12,6 @@ export default function ListEdit( { mergeBlocks, onReplace, className, - ...props } ) { const { ordered, values } = attributes; @@ -48,7 +47,6 @@ export default function ListEdit( { } onRemove={ () => onReplace( [] ) } onTagNameChange={ ( tag ) => setAttributes( { ordered: tag === 'ol' } ) } - { ...props } /> ); } From 07889493c3723f9dbd7aff1cc99ef6a824b8856f Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 19 Apr 2019 18:12:14 +0200 Subject: [PATCH 3/4] Passing onCaretVerticalPositionChange via context to RichText for all RichText based blocks This makes it not necessary to pass onCaretVerticalPositionChange as a prop directly to RichText from the block component. --- packages/block-editor/src/components/rich-text/index.native.js | 1 + packages/block-library/src/heading/edit.native.js | 1 - packages/block-library/src/paragraph/edit.native.js | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index ea0a96bd989c93..4be5aad2e8b19e 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -761,6 +761,7 @@ const RichTextContainer = compose( [ return { isSelected: context.isSelected, clientId: context.clientId, + onCaretVerticalPositionChange: context.onCaretVerticalPositionChange, }; } diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index eb44dd8126dcc9..fdb9ad613214fe 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -104,7 +104,6 @@ class HeadingEdit extends Component { } } onFocus={ this.props.onFocus } // always assign onFocus as a props onBlur={ this.props.onBlur } // always assign onBlur as a props - onCaretVerticalPositionChange={ this.props.onCaretVerticalPositionChange } onChange={ ( value ) => setAttributes( { content: value } ) } onMerge={ mergeBlocks } onSplit={ this.splitBlock } diff --git a/packages/block-library/src/paragraph/edit.native.js b/packages/block-library/src/paragraph/edit.native.js index f7d26d596a656e..6b43018a2f3650 100644 --- a/packages/block-library/src/paragraph/edit.native.js +++ b/packages/block-library/src/paragraph/edit.native.js @@ -102,7 +102,6 @@ class ParagraphEdit extends Component { isSelected={ this.props.isSelected } 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={ style } onChange={ ( nextContent ) => { setAttributes( { From 6c27d076773018ab4dd45a91582ff388f7f02983 Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 19 Apr 2019 18:21:18 +0200 Subject: [PATCH 4/4] Update jest snapshot for block-edit --- .../components/block-controls/test/__snapshots__/index.js.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap index b3a9114f732726..ff2040497b12a7 100644 --- a/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap +++ b/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap @@ -7,6 +7,7 @@ exports[`BlockControls should render a dynamic toolbar of controls 1`] = ` "clientId": undefined, "isSelected": true, "name": undefined, + "onCaretVerticalPositionChange": undefined, "onFocus": undefined, } }