@wordpress/blocks
Version:
Block API for WordPress.
8 lines (7 loc) • 24.4 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/api/factory.js"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { createHooks, applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockType,\n\tgetBlockTypes,\n\tgetGroupingBlockName,\n} from './registration';\nimport {\n\tisBlockRegistered,\n\tnormalizeBlockType,\n\t__experimentalSanitizeBlockAttributes,\n} from './utils';\n\n/**\n * Returns a block object given its type and attributes.\n *\n * @param {string} name Block name.\n * @param {Object} attributes Block attributes.\n * @param {?Array} innerBlocks Nested blocks.\n *\n * @return {Object} Block object.\n */\nexport function createBlock( name, attributes = {}, innerBlocks = [] ) {\n\tif ( ! isBlockRegistered( name ) ) {\n\t\treturn createBlock( 'core/missing', {\n\t\t\toriginalName: name,\n\t\t\toriginalContent: '',\n\t\t\toriginalUndelimitedContent: '',\n\t\t} );\n\t}\n\n\tconst sanitizedAttributes = __experimentalSanitizeBlockAttributes(\n\t\tname,\n\t\tattributes\n\t);\n\n\tconst clientId = uuid();\n\n\t// Blocks are stored with a unique ID, the assigned type name, the block\n\t// attributes, and their inner blocks.\n\treturn {\n\t\tclientId,\n\t\tname,\n\t\tisValid: true,\n\t\tattributes: sanitizedAttributes,\n\t\tinnerBlocks,\n\t};\n}\n\n/**\n * Given an array of InnerBlocks templates or Block Objects,\n * returns an array of created Blocks from them.\n * It handles the case of having InnerBlocks as Blocks by\n * converting them to the proper format to continue recursively.\n *\n * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.\n *\n * @return {Object[]} Array of Block objects.\n */\nexport function createBlocksFromInnerBlocksTemplate(\n\tinnerBlocksOrTemplate = []\n) {\n\treturn innerBlocksOrTemplate.map( ( innerBlock ) => {\n\t\tconst innerBlockTemplate = Array.isArray( innerBlock )\n\t\t\t? innerBlock\n\t\t\t: [\n\t\t\t\t\tinnerBlock.name,\n\t\t\t\t\tinnerBlock.attributes,\n\t\t\t\t\tinnerBlock.innerBlocks,\n\t\t\t ];\n\t\tconst [ name, attributes, innerBlocks = [] ] = innerBlockTemplate;\n\t\treturn createBlock(\n\t\t\tname,\n\t\t\tattributes,\n\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocks )\n\t\t);\n\t} );\n}\n\n/**\n * Given a block object, returns a copy of the block object while sanitizing its attributes,\n * optionally merging new attributes and/or replacing its inner blocks.\n *\n * @param {Object} block Block instance.\n * @param {Object} mergeAttributes Block attributes.\n * @param {?Array} newInnerBlocks Nested blocks.\n *\n * @return {Object} A cloned block.\n */\nexport function __experimentalCloneSanitizedBlock(\n\tblock,\n\tmergeAttributes = {},\n\tnewInnerBlocks\n) {\n\tconst { name } = block;\n\n\tif ( ! isBlockRegistered( name ) ) {\n\t\treturn createBlock( 'core/missing', {\n\t\t\toriginalName: name,\n\t\t\toriginalContent: '',\n\t\t\toriginalUndelimitedContent: '',\n\t\t} );\n\t}\n\n\tconst clientId = uuid();\n\n\tconst sanitizedAttributes = __experimentalSanitizeBlockAttributes( name, {\n\t\t...block.attributes,\n\t\t...mergeAttributes,\n\t} );\n\n\treturn {\n\t\t...block,\n\t\tclientId,\n\t\tattributes: sanitizedAttributes,\n\t\tinnerBlocks:\n\t\t\tnewInnerBlocks ||\n\t\t\tblock.innerBlocks.map( ( innerBlock ) =>\n\t\t\t\t__experimentalCloneSanitizedBlock( innerBlock )\n\t\t\t),\n\t};\n}\n\n/**\n * Given a block object, returns a copy of the block object,\n * optionally merging new attributes and/or replacing its inner blocks.\n *\n * @param {Object} block Block instance.\n * @param {Object} mergeAttributes Block attributes.\n * @param {?Array} newInnerBlocks Nested blocks.\n *\n * @return {Object} A cloned block.\n */\nexport function cloneBlock( block, mergeAttributes = {}, newInnerBlocks ) {\n\tconst clientId = uuid();\n\n\treturn {\n\t\t...block,\n\t\tclientId,\n\t\tattributes: {\n\t\t\t...block.attributes,\n\t\t\t...mergeAttributes,\n\t\t},\n\t\tinnerBlocks:\n\t\t\tnewInnerBlocks ||\n\t\t\tblock.innerBlocks.map( ( innerBlock ) => cloneBlock( innerBlock ) ),\n\t};\n}\n\n/**\n * Returns a boolean indicating whether a transform is possible based on\n * various bits of context.\n *\n * @param {Object} transform The transform object to validate.\n * @param {string} direction Is this a 'from' or 'to' transform.\n * @param {Array} blocks The blocks to transform from.\n *\n * @return {boolean} Is the transform possible?\n */\nconst isPossibleTransformForSource = ( transform, direction, blocks ) => {\n\tif ( ! blocks.length ) {\n\t\treturn false;\n\t}\n\n\t// If multiple blocks are selected, only multi block transforms\n\t// or wildcard transforms are allowed.\n\tconst isMultiBlock = blocks.length > 1;\n\tconst firstBlockName = blocks[ 0 ].name;\n\tconst isValidForMultiBlocks =\n\t\tisWildcardBlockTransform( transform ) ||\n\t\t! isMultiBlock ||\n\t\ttransform.isMultiBlock;\n\tif ( ! isValidForMultiBlocks ) {\n\t\treturn false;\n\t}\n\n\t// Check non-wildcard transforms to ensure that transform is valid\n\t// for a block selection of multiple blocks of different types.\n\tif (\n\t\t! isWildcardBlockTransform( transform ) &&\n\t\t! blocks.every( ( block ) => block.name === firstBlockName )\n\t) {\n\t\treturn false;\n\t}\n\n\t// Only consider 'block' type transforms as valid.\n\tconst isBlockType = transform.type === 'block';\n\tif ( ! isBlockType ) {\n\t\treturn false;\n\t}\n\n\t// Check if the transform's block name matches the source block (or is a wildcard)\n\t// only if this is a transform 'from'.\n\tconst sourceBlock = blocks[ 0 ];\n\tconst hasMatchingName =\n\t\tdirection !== 'from' ||\n\t\ttransform.blocks.indexOf( sourceBlock.name ) !== -1 ||\n\t\tisWildcardBlockTransform( transform );\n\tif ( ! hasMatchingName ) {\n\t\treturn false;\n\t}\n\n\t// Don't allow single Grouping blocks to be transformed into\n\t// a Grouping block.\n\tif (\n\t\t! isMultiBlock &&\n\t\tdirection === 'from' &&\n\t\tisContainerGroupBlock( sourceBlock.name ) &&\n\t\tisContainerGroupBlock( transform.blockName )\n\t) {\n\t\treturn false;\n\t}\n\n\t// If the transform has a `isMatch` function specified, check that it returns true.\n\tif ( ! maybeCheckTransformIsMatch( transform, blocks ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n};\n\n/**\n * Returns block types that the 'blocks' can be transformed into, based on\n * 'from' transforms on other blocks.\n *\n * @param {Array} blocks The blocks to transform from.\n *\n * @return {Array} Block types that the blocks can be transformed into.\n */\nconst getBlockTypesForPossibleFromTransforms = ( blocks ) => {\n\tif ( ! blocks.length ) {\n\t\treturn [];\n\t}\n\n\tconst allBlockTypes = getBlockTypes();\n\n\t// filter all blocks to find those with a 'from' transform.\n\tconst blockTypesWithPossibleFromTransforms = allBlockTypes.filter(\n\t\t( blockType ) => {\n\t\t\tconst fromTransforms = getBlockTransforms( 'from', blockType.name );\n\t\t\treturn !! findTransform( fromTransforms, ( transform ) => {\n\t\t\t\treturn isPossibleTransformForSource(\n\t\t\t\t\ttransform,\n\t\t\t\t\t'from',\n\t\t\t\t\tblocks\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\t);\n\n\treturn blockTypesWithPossibleFromTransforms;\n};\n\n/**\n * Returns block types that the 'blocks' can be transformed into, based on\n * the source block's own 'to' transforms.\n *\n * @param {Array} blocks The blocks to transform from.\n *\n * @return {Array} Block types that the source can be transformed into.\n */\nconst getBlockTypesForPossibleToTransforms = ( blocks ) => {\n\tif ( ! blocks.length ) {\n\t\treturn [];\n\t}\n\n\tconst sourceBlock = blocks[ 0 ];\n\tconst blockType = getBlockType( sourceBlock.name );\n\tconst transformsTo = blockType\n\t\t? getBlockTransforms( 'to', blockType.name )\n\t\t: [];\n\n\t// filter all 'to' transforms to find those that are possible.\n\tconst possibleTransforms = transformsTo.filter( ( transform ) => {\n\t\treturn (\n\t\t\ttransform && isPossibleTransformForSource( transform, 'to', blocks )\n\t\t);\n\t} );\n\n\t// Build a list of block names using the possible 'to' transforms.\n\tconst blockNames = possibleTransforms\n\t\t.map( ( transformation ) => transformation.blocks )\n\t\t.flat();\n\n\t// Map block names to block types.\n\treturn blockNames.map( getBlockType );\n};\n\n/**\n * Determines whether transform is a \"block\" type\n * and if so whether it is a \"wildcard\" transform\n * ie: targets \"any\" block type\n *\n * @param {Object} t the Block transform object\n *\n * @return {boolean} whether transform is a wildcard transform\n */\nexport const isWildcardBlockTransform = ( t ) =>\n\tt &&\n\tt.type === 'block' &&\n\tArray.isArray( t.blocks ) &&\n\tt.blocks.includes( '*' );\n\n/**\n * Determines whether the given Block is the core Block which\n * acts as a container Block for other Blocks as part of the\n * Grouping mechanics\n *\n * @param {string} name the name of the Block to test against\n *\n * @return {boolean} whether or not the Block is the container Block type\n */\nexport const isContainerGroupBlock = ( name ) =>\n\tname === getGroupingBlockName();\n\n/**\n * Returns an array of block types that the set of blocks received as argument\n * can be transformed into.\n *\n * @param {Array} blocks Blocks array.\n *\n * @return {Array} Block types that the blocks argument can be transformed to.\n */\nexport function getPossibleBlockTransformations( blocks ) {\n\tif ( ! blocks.length ) {\n\t\treturn [];\n\t}\n\n\tconst blockTypesForFromTransforms =\n\t\tgetBlockTypesForPossibleFromTransforms( blocks );\n\tconst blockTypesForToTransforms =\n\t\tgetBlockTypesForPossibleToTransforms( blocks );\n\n\treturn [\n\t\t...new Set( [\n\t\t\t...blockTypesForFromTransforms,\n\t\t\t...blockTypesForToTransforms,\n\t\t] ),\n\t];\n}\n\n/**\n * Given an array of transforms, returns the highest-priority transform where\n * the predicate function returns a truthy value. A higher-priority transform\n * is one with a lower priority value (i.e. first in priority order). Returns\n * null if the transforms set is empty or the predicate function returns a\n * falsey value for all entries.\n *\n * @param {Object[]} transforms Transforms to search.\n * @param {Function} predicate Function returning true on matching transform.\n *\n * @return {?Object} Highest-priority transform candidate.\n */\nexport function findTransform( transforms, predicate ) {\n\t// The hooks library already has built-in mechanisms for managing priority\n\t// queue, so leverage via locally-defined instance.\n\tconst hooks = createHooks();\n\n\tfor ( let i = 0; i < transforms.length; i++ ) {\n\t\tconst candidate = transforms[ i ];\n\t\tif ( predicate( candidate ) ) {\n\t\t\thooks.addFilter(\n\t\t\t\t'transform',\n\t\t\t\t'transform/' + i.toString(),\n\t\t\t\t( result ) => ( result ? result : candidate ),\n\t\t\t\tcandidate.priority\n\t\t\t);\n\t\t}\n\t}\n\n\t// Filter name is arbitrarily chosen but consistent with above aggregation.\n\treturn hooks.applyFilters( 'transform', null );\n}\n\n/**\n * Returns normal block transforms for a given transform direction, optionally\n * for a specific block by name, or an empty array if there are no transforms.\n * If no block name is provided, returns transforms for all blocks. A normal\n * transform object includes `blockName` as a property.\n *\n * @param {string} direction Transform direction (\"to\", \"from\").\n * @param {string|Object} blockTypeOrName Block type or name.\n *\n * @return {Array} Block transforms for direction.\n */\nexport function getBlockTransforms( direction, blockTypeOrName ) {\n\t// When retrieving transforms for all block types, recurse into self.\n\tif ( blockTypeOrName === undefined ) {\n\t\treturn getBlockTypes()\n\t\t\t.map( ( { name } ) => getBlockTransforms( direction, name ) )\n\t\t\t.flat();\n\t}\n\n\t// Validate that block type exists and has array of direction.\n\tconst blockType = normalizeBlockType( blockTypeOrName );\n\tconst { name: blockName, transforms } = blockType || {};\n\tif ( ! transforms || ! Array.isArray( transforms[ direction ] ) ) {\n\t\treturn [];\n\t}\n\n\tconst usingMobileTransformations =\n\t\ttransforms.supportedMobileTransforms &&\n\t\tArray.isArray( transforms.supportedMobileTransforms );\n\tconst filteredTransforms = usingMobileTransformations\n\t\t? transforms[ direction ].filter( ( t ) => {\n\t\t\t\tif ( t.type === 'raw' ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( t.type === 'prefix' ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( ! t.blocks || ! t.blocks.length ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( isWildcardBlockTransform( t ) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn t.blocks.every( ( transformBlockName ) =>\n\t\t\t\t\ttransforms.supportedMobileTransforms.includes(\n\t\t\t\t\t\ttransformBlockName\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t } )\n\t\t: transforms[ direction ];\n\n\t// Map transforms to normal form.\n\treturn filteredTransforms.map( ( transform ) => ( {\n\t\t...transform,\n\t\tblockName,\n\t\tusingMobileTransformations,\n\t} ) );\n}\n\n/**\n * Checks that a given transforms isMatch method passes for given source blocks.\n *\n * @param {Object} transform A transform object.\n * @param {Array} blocks Blocks array.\n *\n * @return {boolean} True if given blocks are a match for the transform.\n */\nfunction maybeCheckTransformIsMatch( transform, blocks ) {\n\tif ( typeof transform.isMatch !== 'function' ) {\n\t\treturn true;\n\t}\n\tconst sourceBlock = blocks[ 0 ];\n\tconst attributes = transform.isMultiBlock\n\t\t? blocks.map( ( block ) => block.attributes )\n\t\t: sourceBlock.attributes;\n\tconst block = transform.isMultiBlock ? blocks : sourceBlock;\n\n\treturn transform.isMatch( attributes, block );\n}\n\n/**\n * Switch one or more blocks into one or more blocks of the new block type.\n *\n * @param {Array|Object} blocks Blocks array or block object.\n * @param {string} name Block name.\n *\n * @return {?Array} Array of blocks or null.\n */\nexport function switchToBlockType( blocks, name ) {\n\tconst blocksArray = Array.isArray( blocks ) ? blocks : [ blocks ];\n\tconst isMultiBlock = blocksArray.length > 1;\n\tconst firstBlock = blocksArray[ 0 ];\n\tconst sourceName = firstBlock.name;\n\n\t// Find the right transformation by giving priority to the \"to\"\n\t// transformation.\n\tconst transformationsFrom = getBlockTransforms( 'from', name );\n\tconst transformationsTo = getBlockTransforms( 'to', sourceName );\n\n\tconst transformation =\n\t\tfindTransform(\n\t\t\ttransformationsTo,\n\t\t\t( t ) =>\n\t\t\t\tt.type === 'block' &&\n\t\t\t\t( isWildcardBlockTransform( t ) ||\n\t\t\t\t\tt.blocks.indexOf( name ) !== -1 ) &&\n\t\t\t\t( ! isMultiBlock || t.isMultiBlock ) &&\n\t\t\t\tmaybeCheckTransformIsMatch( t, blocksArray )\n\t\t) ||\n\t\tfindTransform(\n\t\t\ttransformationsFrom,\n\t\t\t( t ) =>\n\t\t\t\tt.type === 'block' &&\n\t\t\t\t( isWildcardBlockTransform( t ) ||\n\t\t\t\t\tt.blocks.indexOf( sourceName ) !== -1 ) &&\n\t\t\t\t( ! isMultiBlock || t.isMultiBlock ) &&\n\t\t\t\tmaybeCheckTransformIsMatch( t, blocksArray )\n\t\t);\n\n\t// Stop if there is no valid transformation.\n\tif ( ! transformation ) {\n\t\treturn null;\n\t}\n\n\tlet transformationResults;\n\n\tif ( transformation.isMultiBlock ) {\n\t\tif ( '__experimentalConvert' in transformation ) {\n\t\t\ttransformationResults =\n\t\t\t\ttransformation.__experimentalConvert( blocksArray );\n\t\t} else {\n\t\t\ttransformationResults = transformation.transform(\n\t\t\t\tblocksArray.map( ( currentBlock ) => currentBlock.attributes ),\n\t\t\t\tblocksArray.map( ( currentBlock ) => currentBlock.innerBlocks )\n\t\t\t);\n\t\t}\n\t} else if ( '__experimentalConvert' in transformation ) {\n\t\ttransformationResults =\n\t\t\ttransformation.__experimentalConvert( firstBlock );\n\t} else {\n\t\ttransformationResults = transformation.transform(\n\t\t\tfirstBlock.attributes,\n\t\t\tfirstBlock.innerBlocks\n\t\t);\n\t}\n\n\t// Ensure that the transformation function returned an object or an array\n\t// of objects.\n\tif (\n\t\ttransformationResults === null ||\n\t\ttypeof transformationResults !== 'object'\n\t) {\n\t\treturn null;\n\t}\n\n\t// If the transformation function returned a single object, we want to work\n\t// with an array instead.\n\ttransformationResults = Array.isArray( transformationResults )\n\t\t? transformationResults\n\t\t: [ transformationResults ];\n\n\t// Ensure that every block object returned by the transformation has a\n\t// valid block type.\n\tif (\n\t\ttransformationResults.some(\n\t\t\t( result ) => ! getBlockType( result.name )\n\t\t)\n\t) {\n\t\treturn null;\n\t}\n\n\tconst hasSwitchedBlock = transformationResults.some(\n\t\t( result ) => result.name === name\n\t);\n\n\t// Ensure that at least one block object returned by the transformation has\n\t// the expected \"destination\" block type.\n\tif ( ! hasSwitchedBlock ) {\n\t\treturn null;\n\t}\n\n\tconst ret = transformationResults.map( ( result, index, results ) => {\n\t\t/**\n\t\t * Filters an individual transform result from block transformation.\n\t\t * All of the original blocks are passed, since transformations are\n\t\t * many-to-many, not one-to-one.\n\t\t *\n\t\t * @param {Object} transformedBlock The transformed block.\n\t\t * @param {Object[]} blocks Original blocks transformed.\n\t\t * @param {Object[]} index Index of the transformed block on the array of results.\n\t\t * @param {Object[]} results An array all the blocks that resulted from the transformation.\n\t\t */\n\t\treturn applyFilters(\n\t\t\t'blocks.switchToBlockType.transformedBlock',\n\t\t\tresult,\n\t\t\tblocks,\n\t\t\tindex,\n\t\t\tresults\n\t\t);\n\t} );\n\n\treturn ret;\n}\n\n/**\n * Create a block object from the example API.\n *\n * @param {string} name\n * @param {Object} example\n *\n * @return {Object} block.\n */\nexport const getBlockFromExample = ( name, example ) =>\n\tcreateBlock(\n\t\tname,\n\t\texample.attributes,\n\t\t( example.innerBlocks ?? [] ).map( ( innerBlock ) =>\n\t\t\tgetBlockFromExample( innerBlock.name, innerBlock )\n\t\t)\n\t);\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2B;AAK3B,mBAA0C;AAK1C,0BAIO;AACP,mBAIO;AAWA,SAAS,YAAa,MAAM,aAAa,CAAC,GAAG,cAAc,CAAC,GAAI;AACtE,MAAK,KAAE,gCAAmB,IAAK,GAAI;AAClC,WAAO,YAAa,gBAAgB;AAAA,MACnC,cAAc;AAAA,MACd,iBAAiB;AAAA,MACjB,4BAA4B;AAAA,IAC7B,CAAE;AAAA,EACH;AAEA,QAAM,0BAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,EACD;AAEA,QAAM,eAAW,YAAAA,IAAK;AAItB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,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