UNPKG

@wordpress/block-editor

Version:
36 lines (33 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addMetaAttribute = addMetaAttribute; var _hooks = require("@wordpress/hooks"); /** * WordPress dependencies */ const META_ATTRIBUTE_NAME = 'metadata'; /** * Filters registered block settings, extending attributes to include `metadata`. * * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012 * * @param {Object} blockTypeSettings Original block settings. * @return {Object} Filtered block settings. */ function addMetaAttribute(blockTypeSettings) { // Allow blocks to specify their own attribute definition with default values if needed. if (blockTypeSettings?.attributes?.[META_ATTRIBUTE_NAME]?.type) { return blockTypeSettings; } blockTypeSettings.attributes = { ...blockTypeSettings.attributes, [META_ATTRIBUTE_NAME]: { type: 'object' } }; return blockTypeSettings; } (0, _hooks.addFilter)('blocks.registerBlockType', 'core/metadata/addMetaAttribute', addMetaAttribute); //# sourceMappingURL=metadata.js.map