-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[RNMobile] Enable reusable block only in WP.com sites #31744
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
Changes from 1 commit
f6f9014
5c190b7
1803eba
68434fc
f86d085
0b920ae
d9fe8f9
e157b22
ed8095f
d4c2e1a
233e227
26ea5fb
1f4ad23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { useMemo } from '@wordpress/element'; | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { store as coreStore } from '@wordpress/core-data'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import useBlockEditorSettings from './use-block-editor-settings.js'; | ||
|
|
||
| function useNativeBlockEditorSettings( settings, hasTemplate ) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this hook is to add custom code to the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the context here. I can see that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah exactly, the main difference between this version and the web is that |
||
| const capabilities = settings.capabilities ?? {}; | ||
| const editorSettings = useBlockEditorSettings( settings, hasTemplate ); | ||
|
|
||
| const supportReusableBlock = capabilities.reusableBlock === true; | ||
| const { reusableBlocks } = useSelect( | ||
| ( select ) => ( { | ||
| reusableBlocks: supportReusableBlock | ||
| ? select( coreStore ).getEntityRecords( | ||
| 'postType', | ||
| 'wp_block', | ||
| // Unbounded queries are not supported on native so as a workaround, we set per_page with the maximum value that native version can handle. | ||
| // Related issue: https://github.com/wordpress-mobile/gutenberg-mobile/issues/2661 | ||
| { per_page: 100 } | ||
| ) | ||
| : [], | ||
| } ), | ||
| [ supportReusableBlock ] | ||
| ); | ||
|
|
||
| return useMemo( | ||
| () => ( { | ||
| ...editorSettings, | ||
| __experimentalReusableBlocks: reusableBlocks, | ||
| } ), | ||
| [ reusableBlocks ] | ||
| ); | ||
| } | ||
|
|
||
| export default useNativeBlockEditorSettings; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reusable blocks are fetched in the native version of this hook, so we only fetch them for the web version.