@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
65 lines (61 loc) • 1.87 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bootstrapBlockBindingsSourcesFromServer = bootstrapBlockBindingsSourcesFromServer;
exports.registerCoreBlockBindingsSources = registerCoreBlockBindingsSources;
var _blocks = require("@wordpress/blocks");
var _data = require("@wordpress/data");
var _patternOverrides = _interopRequireDefault(require("./pattern-overrides"));
var _postMeta = _interopRequireDefault(require("./post-meta"));
var _lockUnlock = require("../lock-unlock");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Function to register core block bindings sources provided by the editor.
*
* @example
* ```js
* import { registerCoreBlockBindingsSources } from '@wordpress/editor';
*
* registerCoreBlockBindingsSources();
* ```
*/
function registerCoreBlockBindingsSources() {
const {
registerBlockBindingsSource
} = (0, _lockUnlock.unlock)(_blocks.privateApis);
registerBlockBindingsSource(_patternOverrides.default);
registerBlockBindingsSource(_postMeta.default);
}
/**
* Function to bootstrap core block bindings sources defined in the server.
*
* @param {Object} sources Object containing the sources to bootstrap.
*
* @example
* ```js
* import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';
*
* bootstrapBlockBindingsSourcesFromServer( sources );
* ```
*/
function bootstrapBlockBindingsSourcesFromServer(sources) {
if (sources) {
const {
addBootstrappedBlockBindingsSource
} = (0, _lockUnlock.unlock)((0, _data.dispatch)(_blocks.store));
for (const [name, args] of Object.entries(sources)) {
addBootstrappedBlockBindingsSource({
name,
...args
});
}
}
}
//# sourceMappingURL=api.js.map