* manipulate the attributes of a block
* in the context of an editor.
* @property {WPBlockVariation[]} [variations] The list of block variations.
* @property {Object} [example] Example provides structured data for
* the block preview. When not defined
* then no preview is shown.
* Mapping of legacy category slugs to their latest normal values, used to
* accommodate updates of the default set of block categories.
* @type {Record<string,string>}
var LEGACY_CATEGORY_MAPPING = {
var serverSideBlockDefinitions = {};
* Sets the server side block definition of blocks.
* @param {Object} definitions Server-side block definitions
// eslint-disable-next-line camelcase
function unstable__bootstrapServerSideBlockDefinitions(definitions) {
for (var _i = 0, _Object$keys = Object.keys(definitions); _i < _Object$keys.length; _i++) {
var blockName = _Object$keys[_i];
// Don't overwrite if already set. It covers the case when metadata
// was initialized from the server.
if (serverSideBlockDefinitions[blockName]) {
serverSideBlockDefinitions[blockName] = Object(external_lodash_["mapKeys"])(Object(external_lodash_["pickBy"])(definitions[blockName], function (value) {
return !Object(external_lodash_["isNil"])(value);
}), function (value, key) {
return Object(external_lodash_["camelCase"])(key);
* Registers a new block provided a unique name and an object defining its
* behavior. Once registered, the block is made available as an option to any
* editor interface where blocks are implemented.
* @param {string} name Block name.
* @param {Object} settings Block settings.
* @return {?WPBlock} The block, if it has been successfully registered;
function registerBlockType(name, settings) {
settings = registration_objectSpread(registration_objectSpread({
icon: block_default["a" /* default */],
}, serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]), settings);
if (typeof name !== 'string') {
console.error('Block names must be strings.');
if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block');
if (Object(external_wp_data_["select"])(store).getBlockType(name)) {
console.error('Block "' + name + '" is already registered.');
var preFilterSettings = registration_objectSpread({}, settings);
settings = Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name);
if (settings.deprecated) {
settings.deprecated = settings.deprecated.map(function (deprecation) {
return Object(external_lodash_["pick"])( // Only keep valid deprecation keys.
Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
// so that filters that depend on specific keys being
registration_objectSpread(registration_objectSpread({}, Object(external_lodash_["omit"])(preFilterSettings, DEPRECATED_ENTRY_KEYS)), deprecation), name), DEPRECATED_ENTRY_KEYS);
if (!Object(external_lodash_["isPlainObject"])(settings)) {
console.error('Block settings must be a valid object.');
if (!Object(external_lodash_["isFunction"])(settings.save)) {
console.error('The "save" property must be a valid function.');
if ('edit' in settings && !Object(external_lodash_["isFunction"])(settings.edit)) {
console.error('The "edit" property must be a valid function.');
} // Canonicalize legacy categories to equivalent fallback.
if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
if ('category' in settings && !Object(external_lodash_["some"])(Object(external_wp_data_["select"])(store).getCategories(), {
console.warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
delete settings.category;
if (!('title' in settings) || settings.title === '') {
console.error('The block "' + name + '" must have a title.');
if (typeof settings.title !== 'string') {
console.error('Block titles must be strings.');
settings.icon = normalizeIconObject(settings.icon);
if (!isValidIcon(settings.icon.src)) {
console.error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional');
Object(external_wp_data_["dispatch"])(store).addBlockTypes(settings);
* Registers a new block collection to group blocks in the same namespace in the inserter.
* @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace.
* @param {Object} settings The block collection settings.
* @param {string} settings.title The title to display in the block inserter.
* @param {Object} [settings.icon] The icon to display in the block inserter.
function registerBlockCollection(namespace, _ref) {
Object(external_wp_data_["dispatch"])(store).addBlockCollection(namespace, title, icon);
* Unregisters a block collection
* @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
function unregisterBlockCollection(namespace) {
Object(external_wp_data_["dispatch"])(store).removeBlockCollection(namespace);
* @param {string} name Block name.
* @return {?WPBlock} The previous block value, if it has been successfully
* unregistered; otherwise `undefined`.
function unregisterBlockType(name) {
var oldBlock = Object(external_wp_data_["select"])(store).getBlockType(name);
console.error('Block "' + name + '" is not registered.');
Object(external_wp_data_["dispatch"])(store).removeBlockTypes(name);
* Assigns name of block for handling non-block content.
* @param {string} blockName Block name.
function setFreeformContentHandlerName(blockName) {
Object(external_wp_data_["dispatch"])(store).setFreeformFallbackBlockName(blockName);
* Retrieves name of block handling non-block content, or undefined if no
* handler has been defined.
* @return {?string} Block name.
function getFreeformContentHandlerName() {
return Object(external_wp_data_["select"])(store).getFreeformFallbackBlockName();
* Retrieves name of block used for handling grouping interactions.
* @return {?string} Block name.
function registration_getGroupingBlockName() {
return Object(external_wp_data_["select"])(store).getGroupingBlockName();
* Assigns name of block handling unregistered block types.
* @param {string} blockName Block name.
function setUnregisteredTypeHandlerName(blockName) {
Object(external_wp_data_["dispatch"])(store).setUnregisteredFallbackBlockName(blockName);
* Retrieves name of block handling unregistered block types, or undefined if no
* handler has been defined.
* @return {?string} Block name.
function getUnregisteredTypeHandlerName() {
return Object(external_wp_data_["select"])(store).getUnregisteredFallbackBlockName();
* Assigns the default block name.
* @param {string} name Block name.
function registration_setDefaultBlockName(name) {
Object(external_wp_data_["dispatch"])(store).setDefaultBlockName(name);
* Assigns name of block for handling block grouping interactions.
* @param {string} name Block name.
function registration_setGroupingBlockName(name) {
Object(external_wp_data_["dispatch"])(store).setGroupingBlockName(name);
* Retrieves the default block name.
* @return {?string} Block name.
function registration_getDefaultBlockName() {
return Object(external_wp_data_["select"])(store).getDefaultBlockName();
* Returns a registered block type.
* @param {string} name Block name.
* @return {?Object} Block type.
function registration_getBlockType(name) {
return Object(external_wp_data_["select"])(store).getBlockType(name);
* Returns all registered blocks.
* @return {Array} Block settings.
function registration_getBlockTypes() {
return Object(external_wp_data_["select"])(store).getBlockTypes();
* Returns the block support value for a feature, if defined.
* @param {(string|Object)} nameOrType Block name or type object
* @param {string} feature Feature to retrieve
* @param {*} defaultSupports Default value to return if not
* @return {?*} Block support value
function registration_getBlockSupport(nameOrType, feature, defaultSupports) {
return Object(external_wp_data_["select"])(store).getBlockSupport(nameOrType, feature, defaultSupports);
* Returns true if the block defines support for a feature, or false otherwise.
* @param {(string|Object)} nameOrType Block name or type object.
* @param {string} feature Feature to test.
* @param {boolean} defaultSupports Whether feature is supported by
* default if not explicitly defined.
* @return {boolean} Whether block supports feature.
function registration_hasBlockSupport(nameOrType, feature, defaultSupports) {
return Object(external_wp_data_["select"])(store).hasBlockSupport(nameOrType, feature, defaultSupports);
* Determines whether or not the given block is a reusable block. This is a
* special block type that is used to point to a global block stored via the
* @param {Object} blockOrType Block or Block Type to test.
* @return {boolean} Whether the given block is a reusable block.
function isReusableBlock(blockOrType) {
return blockOrType.name === 'core/block';
* Returns an array with the child blocks of a given block.
* @param {string} blockName Name of block (example: “latest-posts”).
* @return {Array} Array of child block names.
var registration_getChildBlockNames = function getChildBlockNames(blockName) {
return Object(external_wp_data_["select"])(store).getChildBlockNames(blockName);
* Returns a boolean indicating if a block has child blocks or not.
* @param {string} blockName Name of block (example: “latest-posts”).
* @return {boolean} True if a block contains child blocks and false otherwise.
var registration_hasChildBlocks = function hasChildBlocks(blockName) {
return Object(external_wp_data_["select"])(store).hasChildBlocks(blockName);
* Returns a boolean indicating if a block has at least one child block with inserter support.
* @param {string} blockName Block type name.
* @return {boolean} True if a block contains at least one child blocks with inserter support
var registration_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(blockName) {
return Object(external_wp_data_["select"])(store).hasChildBlocksWithInserterSupport(blockName);
* Registers a new block style variation for the given block.
* @param {string} blockName Name of block (example: “core/latest-posts”).
* @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
var registration_registerBlockStyle = function registerBlockStyle(blockName, styleVariation) {
Object(external_wp_data_["dispatch"])(store).addBlockStyles(blockName, styleVariation);
* Unregisters a block style variation for the given block.
* @param {string} blockName Name of block (example: “core/latest-posts”).
* @param {string} styleVariationName Name of class applied to the block.
var registration_unregisterBlockStyle = function unregisterBlockStyle(blockName, styleVariationName) {
Object(external_wp_data_["dispatch"])(store).removeBlockStyles(blockName, styleVariationName);
* Returns an array with the variations of a given block type.
* @param {string} blockName Name of block (example: “core/columns”).
* @param {WPBlockVariationScope} [scope] Block variation scope name.
* @return {(WPBlockVariation[]|void)} Block variations.
var registration_getBlockVariations = function getBlockVariations(blockName, scope) {
return Object(external_wp_data_["select"])(store).getBlockVariations(blockName, scope);
* Registers a new block variation for the given block type.
* @param {string} blockName Name of the block (example: “core/columns”).
* @param {WPBlockVariation} variation Object describing a block variation.
var registration_registerBlockVariation = function registerBlockVariation(blockName, variation) {
Object(external_wp_data_["dispatch"])(store).addBlockVariations(blockName, variation);
* Unregisters a block variation defined for the given block type.
* @param {string} blockName Name of the block (example: “core/columns”).
* @param {string} variationName Name of the variation defined for the block.
var registration_unregisterBlockVariation = function unregisterBlockVariation(blockName, variationName) {
Object(external_wp_data_["dispatch"])(store).removeBlockVariations(blockName, variationName);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
function factory_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function factory_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { factory_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { factory_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
* Returns a block object given its type and attributes.
* @param {string} name Block name.
* @param {Object} attributes Block attributes.
* @param {?Array} innerBlocks Nested blocks.
* @return {Object} Block object.
function createBlock(name) {
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var sanitizedAttributes = sanitizeBlockAttributes(name, attributes);
var clientId = Object(v4["a" /* default */])(); // Blocks are stored with a unique ID, the assigned type name, the block
// attributes, and their inner blocks.
attributes: sanitizedAttributes,
* Given an array of InnerBlocks templates or Block Objects,
* returns an array of created Blocks from them.
* It handles the case of having InnerBlocks as Blocks by
* converting them to the proper format to continue recursively.
* @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.
* @return {Object[]} Array of Block objects.
function createBlocksFromInnerBlocksTemplate() {
var innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return innerBlocksOrTemplate.map(function (innerBlock) {
var innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
var _innerBlockTemplate = Object(slicedToArray["a" /* default */])(innerBlockTemplate, 3),
name = _innerBlockTemplate[0],
attributes = _innerBlockTemplate[1],
_innerBlockTemplate$ = _innerBlockTemplate[2],
innerBlocks = _innerBlockTemplate$ === void 0 ? [] : _innerBlockTemplate$;
return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
* Given a block object, returns a copy of the block object while sanitizing its attributes,
* optionally merging new attributes and/or replacing its inner blocks.
* @param {Object} block Block instance.
* @param {Object} mergeAttributes Block attributes.
* @param {?Array} newInnerBlocks Nested blocks.
* @return {Object} A cloned block.