Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Removed editor store usage from native mobile block editor inserter #18794

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default compose(
getBlockName,
getBlockRootClientId,
getBlockSelectionEnd,
getSettings,
} = select( 'core/block-editor' );
const {
getChildBlockNames,
Expand All @@ -130,10 +131,13 @@ export default compose(
}
const destinationRootBlockName = getBlockName( destinationRootClientId );

const { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } = getSettings();

return {
rootChildBlocks: getChildBlockNames( destinationRootBlockName ),
items: getInserterItems( destinationRootClientId ),
destinationRootClientId,
shouldInsertAtTheTop,
};
} ),
withDispatch( ( dispatch, ownProps, { select } ) => {
Expand All @@ -154,13 +158,10 @@ export default compose(
getBlockSelectionEnd,
getBlockOrder,
} = select( 'core/block-editor' );
const {
isPostTitleSelected,
} = select( 'core/editor' );
const { clientId, destinationRootClientId, isAppender } = ownProps;
const { clientId, destinationRootClientId, isAppender, shouldInsertAtTheTop } = ownProps;

// if post title is selected insert as first block
if ( isPostTitleSelected() ) {
if ( shouldInsertAtTheTop ) {
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class EditorProvider extends Component {
hasUploadPermissions,
canUserUseUnfilteredHTML,
undo,
shouldInsertAtTheTop,
) {
return {
...pick( settings, [
Expand Down Expand Up @@ -122,6 +123,7 @@ class EditorProvider extends Component {
__experimentalFetchLinkSuggestions: fetchLinkSuggestions,
__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,
__experimentalUndo: undo,
__experimentalShouldInsertAtTheTop: shouldInsertAtTheTop,
};
}

Expand Down Expand Up @@ -167,6 +169,7 @@ class EditorProvider extends Component {
reusableBlocks,
resetEditorBlocksWithoutUndoLevel,
hasUploadPermissions,
isPostTitleSelected,
__experimentalFetchReusableBlocks,
undo,
} = this.props;
Expand All @@ -182,6 +185,7 @@ class EditorProvider extends Component {
hasUploadPermissions,
canUserUseUnfilteredHTML,
undo,
isPostTitleSelected,
);

return (
Expand Down Expand Up @@ -216,6 +220,7 @@ export default compose( [
getEditorSelectionStart,
getEditorSelectionEnd,
__experimentalGetReusableBlocks,
isPostTitleSelected,
} = select( 'core/editor' );
const { canUser } = select( 'core' );

Expand All @@ -227,6 +232,8 @@ export default compose( [
selectionEnd: getEditorSelectionEnd(),
reusableBlocks: __experimentalGetReusableBlocks(),
hasUploadPermissions: defaultTo( canUser( 'create', 'media' ), true ),
// This selector is only defined on mobile.
isPostTitleSelected: isPostTitleSelected && isPostTitleSelected(),
};
} ),
withDispatch( ( dispatch ) => {
Expand Down