Skip to content

Commit

Permalink
Block Bindings: Register bindings sources in widgets screens (WordPre…
Browse files Browse the repository at this point in the history
…ss#65937)

* Register sources in customize-widgets

* Register sources in edit-widgets

Co-authored-by: SantosGuillamot <[email protected]>
Co-authored-by: gziolo <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent 8ae8cc1 commit 4dc8a02
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/customize-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@wordpress/core-data": "file:../core-data",
"@wordpress/data": "file:../data",
"@wordpress/dom": "file:../dom",
"@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
Expand Down
11 changes: 11 additions & 0 deletions packages/customize-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
store as blocksStore,
} from '@wordpress/blocks';
import { dispatch } from '@wordpress/data';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { store as preferencesStore } from '@wordpress/preferences';

/**
Expand All @@ -26,6 +27,7 @@ import CustomizeWidgets from './components/customize-widgets';
import getSidebarSection from './controls/sidebar-section';
import getSidebarControl from './controls/sidebar-control';
import './filters';
import { unlock } from './lock-unlock';

const { wp } = window;

Expand All @@ -37,6 +39,11 @@ const DISABLED_BLOCKS = [
];
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;

const {
registerCoreBlockBindingsSources,
bootstrapBlockBindingsSourcesFromServer,
} = unlock( editorPrivateApis );

/**
* Initializes the widgets block editor in the customizer.
*
Expand All @@ -60,6 +67,10 @@ export function initialize( editorName, blockEditorSettings ) {
);
} );
registerCoreBlocks( coreBlocks );
bootstrapBlockBindingsSourcesFromServer(
blockEditorSettings?.blockBindingsSources
);
registerCoreBlockBindingsSources();
registerLegacyWidgetBlock();
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
__experimentalRegisterExperimentalCoreBlocks( {
Expand Down
1 change: 1 addition & 0 deletions packages/edit-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/dom": "file:../dom",
"@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
Expand Down
10 changes: 9 additions & 1 deletion packages/edit-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@wordpress/blocks';
import { dispatch } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { StrictMode, createRoot } from '@wordpress/element';
import {
registerCoreBlocks,
Expand All @@ -29,7 +30,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
import './store';
import './filters';
import * as widgetArea from './blocks/widget-area';

import { unlock } from './lock-unlock';
import Layout from './components/layout';
import {
ALLOW_REUSABLE_BLOCKS,
Expand All @@ -43,6 +44,11 @@ const disabledBlocks = [
...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),
];

const {
registerCoreBlockBindingsSources,
bootstrapBlockBindingsSourcesFromServer,
} = unlock( editorPrivateApis );

/**
* Initializes the block editor in the widgets screen.
*
Expand Down Expand Up @@ -72,6 +78,8 @@ export function initializeEditor( id, settings ) {

dispatch( blocksStore ).reapplyBlockTypeFilters();
registerCoreBlocks( coreBlocks );
bootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );
registerCoreBlockBindingsSources();
registerLegacyWidgetBlock();
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
__experimentalRegisterExperimentalCoreBlocks( {
Expand Down

0 comments on commit 4dc8a02

Please sign in to comment.