@wordpress/block-library 7.15.1-next.4d3b314fd5.0 → 7.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/code/utils.js +3 -3
- package/build/code/utils.js.map +1 -1
- package/build/group/edit.js +1 -1
- package/build/group/edit.js.map +1 -1
- package/build/navigation/edit/index.js +12 -12
- package/build/navigation/edit/index.js.map +1 -1
- package/build/paragraph/deprecated.js +49 -10
- package/build/paragraph/deprecated.js.map +1 -1
- package/build/paragraph/edit.js +19 -3
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/save.js +3 -1
- package/build/paragraph/save.js.map +1 -1
- package/build/post-author/edit.js +20 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author/index.js +8 -0
- package/build/post-author/index.js.map +1 -1
- package/build/post-featured-image/index.js +1 -1
- package/build/post-featured-image/overlay.js +2 -2
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-terms/index.js +4 -0
- package/build/post-terms/index.js.map +1 -1
- package/build/query/edit/inspector-controls/author-control.js +2 -1
- package/build/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +2 -1
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/utils.js +1 -1
- package/build/query/utils.js.map +1 -1
- package/build/quote/index.js +0 -1
- package/build/quote/index.js.map +1 -1
- package/build/site-title/index.js +2 -1
- package/build/site-title/index.js.map +1 -1
- package/build/template-part/index.js +2 -2
- package/build/template-part/index.js.map +1 -1
- package/build/video/edit.js +13 -1
- package/build/video/edit.js.map +1 -1
- package/build-module/code/utils.js +3 -3
- package/build-module/code/utils.js.map +1 -1
- package/build-module/group/edit.js +1 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +12 -12
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/paragraph/deprecated.js +49 -11
- package/build-module/paragraph/deprecated.js.map +1 -1
- package/build-module/paragraph/edit.js +19 -3
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/save.js +2 -1
- package/build-module/paragraph/save.js.map +1 -1
- package/build-module/post-author/edit.js +21 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author/index.js +8 -0
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-featured-image/index.js +1 -1
- package/build-module/post-featured-image/overlay.js +2 -2
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-terms/index.js +4 -0
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/author-control.js +2 -1
- package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/utils.js +1 -1
- package/build-module/query/utils.js.map +1 -1
- package/build-module/quote/index.js +0 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/site-title/index.js +2 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/video/edit.js +15 -3
- package/build-module/video/edit.js.map +1 -1
- package/build-style/code/style-rtl.css +3 -0
- package/build-style/code/style.css +3 -0
- package/build-style/editor-rtl.css +69 -29
- package/build-style/editor.css +69 -29
- package/build-style/navigation/editor-rtl.css +4 -0
- package/build-style/navigation/editor.css +4 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/paragraph/style-rtl.css +5 -0
- package/build-style/paragraph/style.css +5 -0
- package/build-style/post-featured-image/editor-rtl.css +39 -29
- package/build-style/post-featured-image/editor.css +39 -29
- package/build-style/post-terms/style-rtl.css +4 -1
- package/build-style/post-terms/style.css +4 -1
- package/build-style/site-title/editor-rtl.css +4 -0
- package/build-style/site-title/editor.css +4 -0
- package/build-style/site-title/style-rtl.css +79 -0
- package/build-style/site-title/style.css +79 -0
- package/build-style/style-rtl.css +19 -1
- package/build-style/style.css +19 -1
- package/build-style/video/editor-rtl.css +22 -0
- package/build-style/video/editor.css +22 -0
- package/package.json +28 -28
- package/src/categories/index.php +1 -1
- package/src/code/style.scss +12 -7
- package/src/code/utils.js +3 -3
- package/src/comment-author-name/index.php +1 -1
- package/src/comment-reply-link/index.php +1 -1
- package/src/comment-template/index.php +2 -3
- package/src/cover/index.php +1 -1
- package/src/group/edit.js +1 -1
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +12 -10
- package/src/navigation/editor.scss +6 -0
- package/src/navigation/style.scss +8 -0
- package/src/page-list/index.php +2 -2
- package/src/paragraph/deprecated.js +36 -0
- package/src/paragraph/edit.js +23 -8
- package/src/paragraph/save.js +5 -1
- package/src/paragraph/style.scss +5 -0
- package/src/post-author/block.json +8 -0
- package/src/post-author/edit.js +29 -3
- package/src/post-author/index.php +7 -1
- package/src/post-featured-image/block.json +1 -1
- package/src/post-featured-image/editor.scss +79 -72
- package/src/post-featured-image/index.php +18 -24
- package/src/post-featured-image/overlay.js +17 -14
- package/src/post-terms/block.json +4 -0
- package/src/post-terms/style.scss +7 -2
- package/src/query/edit/inspector-controls/author-control.js +1 -0
- package/src/query/edit/inspector-controls/index.js +1 -4
- package/src/query/edit/inspector-controls/parent-control.js +1 -0
- package/src/query/edit/inspector-controls/taxonomy-controls.js +1 -0
- package/src/query/utils.js +1 -1
- package/src/quote/block.json +0 -1
- package/src/site-title/block.json +2 -1
- package/src/site-title/editor.scss +6 -0
- package/src/site-title/style.scss +5 -0
- package/src/style.scss +1 -0
- package/src/template-part/index.js +2 -2
- package/src/video/edit.js +19 -0
- package/src/video/editor.scss +37 -0
- package/build/navigation-submenu/view.js +0 -56
- package/build/navigation-submenu/view.js.map +0 -1
- package/build-module/navigation-submenu/view.js +0 -54
- package/build-module/navigation-submenu/view.js.map +0 -1
- package/src/navigation-submenu/view.js +0 -67
package/build/query/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowControls","isControlAllowed","allowedControls","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAC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AAF,CAP2B,CAA5B;AASA,QAAMyB,SAAS,GAAI,GAAGtB,aAAe,IAAIqB,mBAAqB,EAA9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BtD,MAAF,IAAc;AACb,QAAK,CAAEoD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFxD,MAAM,CAAEyD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE3C,MAAzB,GAAkC0C,SAAlC,GAA8CtB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;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mBAAmB,GAAG,qBACzBnD,MAAF;AAAA;;AAAA,qCACCA,MAAM,CAAE6B,aAAF,CAAN,CAAsBC,uBAAtB,CACCC,aADD,EAECH,UAFD,CADD,2DACC,uBAGGnC,IAJJ;AAAA,GAD2B,EAO3B,CAAEmC,UAAF,CAP2B,CAA5B;AASA,QAAMwB,SAAS,GAAI,GAAGrB,aAAe,IAAIoB,mBAAqB,EAA9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BrD,MAAF,IAAc;AACb,QAAK,CAAEmD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFvD,MAAM,CAAEwD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE1C,MAAzB,GAAkCyC,SAAlC,GAA8CrB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
|
package/build/quote/index.js
CHANGED
package/build/quote/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/quote/index.js"],"names":["name","metadata","settings","icon","example","attributes","citation","innerBlocks","content","transforms","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/quote/index.js"],"names":["name","metadata","settings","icon","example","attributes","citation","innerBlocks","content","transforms","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,QAAQ,EAAE;AADC,KADJ;AAIRC,IAAAA,WAAW,EAAE,CACZ;AACCP,MAAAA,IAAI,EAAE,gBADP;AAECK,MAAAA,UAAU,EAAE;AACXG,QAAAA,OAAO,EAAE,cAAI,uCAAJ;AADE;AAFb,KADY;AAJL,GAFc;AAevBC,EAAAA,UAAU,EAAVA,mBAfuB;AAgBvBC,EAAAA,IAAI,EAAJA,aAhBuB;AAiBvBC,EAAAA,IAAI,EAAJA,aAjBuB;AAkBvBC,EAAAA,UAAU,EAAVA;AAlBuB,CAAjB;;;AAqBA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEb,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { quote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcitation: 'Julio Cortázar',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( 'In quoting others, we cite ourselves.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/site-title/index.js"],"names":["name","metadata","settings","icon","edit","transforms","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/site-title/index.js"],"names":["name","metadata","settings","icon","edit","transforms","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,UAAU,EAAVA,mBAHuB;AAIvBC,EAAAA,UAAU,EAAVA;AAJuB,CAAjB;;;AAOA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEP,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { mapMarker as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\nimport transforms from './transforms';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\ttransforms,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -102,14 +102,14 @@ const init = () => {
|
|
|
102
102
|
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/template-part', _variations.enhanceTemplatePartVariations); // Prevent adding template parts inside post templates.
|
|
103
103
|
|
|
104
104
|
const DISALLOWED_PARENTS = ['core/post-template', 'core/post-content'];
|
|
105
|
-
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromPostTemplates', (
|
|
105
|
+
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromPostTemplates', (canInsert, blockType, rootClientId, _ref2) => {
|
|
106
106
|
let {
|
|
107
107
|
getBlock,
|
|
108
108
|
getBlockParentsByBlockName
|
|
109
109
|
} = _ref2;
|
|
110
110
|
|
|
111
111
|
if (blockType.name !== 'core/template-part') {
|
|
112
|
-
return
|
|
112
|
+
return canInsert;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
for (const disallowedParentType of DISALLOWED_PARENTS) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","init","enhanceTemplatePartVariations","DISALLOWED_PARENTS","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","init","enhanceTemplatePartVariations","DISALLOWED_PARENTS","canInsert","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEC,mBADiB;AAEvBC,EAAAA,mBAAmB,EAAE,QAAuB;AAAA;;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;;AAC3C;AACA;AACA,QAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAED,UAAME,MAAM,GAAG,kBAAQC,eAAR,EAAwBC,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdH,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WACC,mDAAgBA,MAAM,CAACG,KAAvB,kDAAgB,cAAcC,QAA9B,KACA,6BAAaJ,MAAM,CAACF,IAApB,CAFD;AAIA,GAtBsB;AAuBvBO,EAAAA,IAAI,EAAJA;AAvBuB,CAAjB;;;AA0BA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBACC,0BADD,EAEC,oBAFD,EAGCC,yCAHD,EADyB,CAOzB;;AACA,QAAMC,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACA,wBACC,0CADD,EAEC,sCAFD,EAGC,CACCC,SADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,QADJ;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KACI;;AACJ,QAAKH,SAAS,CAAClB,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,aAAOiB,SAAP;AACA;;AAED,SAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,YAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0BnB,IAA1B,MAAmCsB,oBAAnC,IACAD,0BAA0B,CACzBF,YADyB,EAEzBG,oBAFyB,CAA1B,CAGEE,MALH;;AAMA,UAAKD,mBAAL,EAA2B;AAC1B,eAAO,KAAP;AACA;AACD;;AACD,WAAO,IAAP;AACA,GAzBF;AA4BA,SAAO,wBAAW;AAAEvB,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CAtCM","sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) ||\n\t\t\tcapitalCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn canInsert;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
|
package/build/video/edit.js
CHANGED
|
@@ -48,6 +48,17 @@ var _tracks = _interopRequireDefault(require("./tracks"));
|
|
|
48
48
|
/**
|
|
49
49
|
* Internal dependencies
|
|
50
50
|
*/
|
|
51
|
+
// Much of this description is duplicated from MediaPlaceholder.
|
|
52
|
+
const placeholder = content => {
|
|
53
|
+
return (0, _element.createElement)(_components.Placeholder, {
|
|
54
|
+
className: "block-editor-media-placeholder",
|
|
55
|
+
withIllustration: true,
|
|
56
|
+
icon: _icons.video,
|
|
57
|
+
label: (0, _i18n.__)('Video'),
|
|
58
|
+
instructions: (0, _i18n.__)('Upload a video file, pick one from your media library, or add one with a URL.')
|
|
59
|
+
}, content);
|
|
60
|
+
};
|
|
61
|
+
|
|
51
62
|
const ALLOWED_MEDIA_TYPES = ['video'];
|
|
52
63
|
const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
|
|
53
64
|
|
|
@@ -170,7 +181,8 @@ function VideoEdit(_ref) {
|
|
|
170
181
|
accept: "video/*",
|
|
171
182
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
172
183
|
value: attributes,
|
|
173
|
-
onError: onUploadError
|
|
184
|
+
onError: onUploadError,
|
|
185
|
+
placeholder: placeholder
|
|
174
186
|
}));
|
|
175
187
|
}
|
|
176
188
|
|
package/build/video/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","media","onSelectVideo","onError","onUploadError","allowedTypes","current","load","url","undefined","image","icon","onSelectURL","newSrc","embedBlock","createErrorNotice","noticesStore","message","type","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA6BA;;AA1BA;;AAKA;;AACA;;AAOA;;AAcA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA3CA;AACA;AACA;;AAGA;AACA;AACA;;AA8BA;AACA;AACA;AAMA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;AACA,MAAMC,gCAAgC,GAAG,CAAE,OAAF,CAAzC;;AAEA,SAASC,SAAT,OAOI;AAAA,MAPgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,UAFmB;AAGnBC,IAAAA,SAHmB;AAInBC,IAAAA,aAJmB;AAKnBC,IAAAA,iBALmB;AAMnBC,IAAAA;AANmB,GAOhB;AACH,QAAMC,UAAU,GAAG,4BAAeP,SAAf,CAAnB;AACA,QAAMQ,WAAW,GAAG,sBAApB;AACA,QAAMC,iBAAiB,GAAG,sBAA1B;AACA,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,OAAN;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA,MAAzB;AAAiCC,IAAAA,GAAjC;AAAsCC,IAAAA;AAAtC,MAAiDb,UAAvD;AACA,QAAMc,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWI,GAAX,CAAjC;AACA,QAAMG,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,WAA3B,GAAyCH,WADpC,EAEnB,EAFmB,CAApB;AAKA,0BAAW,MAAM;AAChB,QAAK,CAAEP,EAAF,IAAQ,qBAAWI,GAAX,CAAb,EAAgC;AAC/B,YAAMO,IAAI,GAAG,w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f;AAWC,IAAA,aAAa,MAXd;AAYC,IAAA,sBAAsB,EAAG,MACxB/C,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAbnB,IAlBF,CA7ED,CADD;AAsHA;;eAEcL,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction VideoEdit( {\n\tisSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst instanceId = useInstanceId( VideoEdit );\n\tconst videoPlayer = useRef();\n\tconst posterImageButton = useRef();\n\tconst { id, caption, controls, poster, src, tracks } = attributes;\n\tconst isTemporaryVideo = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ media ] ) => onSelectVideo( media ),\n\t\t\t\t\tonError: onUploadError,\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined, poster: undefined } );\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryVideo,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<TracksEditor\n\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\tVIDEO_POSTER_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\tvideoPosterDescription\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ ! poster\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'The current poster image url is %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tposter\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the video tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tvideo when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryVideo && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taria-label={ __( 'Video caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["placeholder","content","icon","ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","media","onSelectVideo","onError","onUploadError","allowedTypes","current","load","url","undefined","image","onSelectURL","newSrc","embedBlock","createErrorNotice","noticesStore","message","type","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA8BA;;AA3BA;;AAKA;;AACA;;AAQA;;AAcA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5CA;AACA;AACA;;AAGA;AACA;AACA;;AA+BA;AACA;AACA;AAMA;AACA,MAAMA,WAAW,GAAKC,OAAF,IAAe;AAClC,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,gBAAgB,EAAG,IAFpB;AAGC,IAAA,IAAI,EAAGC,YAHR;AAIC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAJT;AAKC,IAAA,YAAY,EAAG,cACd,+EADc;AALhB,KASGD,OATH,CADD;AAaA,CAdD;;AAgBA,MAAME,m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ATJ,CAzBD,EAsCG,CAAC,CAAEA,MAAH,IACD,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAG+B,cADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIG,cAAI,QAAJ,CAJH,CAvCF,CADD,CALD,CADD,CApBD,EA6EC,sCAAaF,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAEzC;AAAzB,KACC;AACC,IAAA,QAAQ,EAAGW,QADZ;AAEC,IAAA,MAAM,EAAGC,MAFV;AAGC,IAAA,GAAG,EAAGC,GAHP;AAIC,IAAA,GAAG,EAAGN;AAJP,KAMC,4BAAC,eAAD;AAAQ,IAAA,MAAM,EAAGO;AAAjB,IAND,CADD,CAND,EAgBGC,gBAAgB,IAAI,4BAAC,mBAAD,OAhBvB,EAiBG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBvC,OAAlB,CAAF,IAAiCV,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,IAAA,SAAS,EAAG,oDACX,SADW,CAFb;AAKC,kBAAa,cAAI,oBAAJ,CALd;AAMC,IAAA,WAAW,EAAG,cAAI,aAAJ,CANf;AAOC,IAAA,KAAK,EAAGU,OAPT;AAQC,IAAA,QAAQ,EAAKwC,KAAF,IACV/C,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEwC;AAAX,KAAF,CATf;AAWC,IAAA,aAAa,MAXd;AAYC,IAAA,sBAAsB,EAAG,MACxB9C,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAbnB,IAlBF,CA7ED,CADD;AAsHA;;eAEcL,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n\tPlaceholder,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\n\n// Much of this description is duplicated from MediaPlaceholder.\nconst placeholder = ( content ) => {\n\treturn (\n\t\t<Placeholder\n\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\twithIllustration={ true }\n\t\t\ticon={ icon }\n\t\t\tlabel={ __( 'Video' ) }\n\t\t\tinstructions={ __(\n\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t) }\n\t\t>\n\t\t\t{ content }\n\t\t</Placeholder>\n\t);\n};\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction VideoEdit( {\n\tisSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst instanceId = useInstanceId( VideoEdit );\n\tconst videoPlayer = useRef();\n\tconst posterImageButton = useRef();\n\tconst { id, caption, controls, poster, src, tracks } = attributes;\n\tconst isTemporaryVideo = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ media ] ) => onSelectVideo( media ),\n\t\t\t\t\tonError: onUploadError,\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined, poster: undefined } );\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryVideo,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<TracksEditor\n\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\tVIDEO_POSTER_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\tvideoPosterDescription\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ ! poster\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'The current poster image url is %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tposter\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the video tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tvideo when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryVideo && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taria-label={ __( 'Video caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { pipe } from '@wordpress/compose';
|
|
5
5
|
/**
|
|
6
6
|
* Escapes ampersands, shortcodes, and links.
|
|
7
7
|
*
|
|
@@ -10,7 +10,7 @@ import { flow } from 'lodash';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export function escape(content) {
|
|
13
|
-
return
|
|
13
|
+
return pipe(escapeOpeningSquareBrackets, escapeProtocolInIsolatedUrls)(content || '');
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Returns the given content with all opening shortcode characters converted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/code/utils.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/code/utils.js"],"names":["pipe","escape","content","escapeOpeningSquareBrackets","escapeProtocolInIsolatedUrls","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,MAAT,CAAiBC,OAAjB,EAA2B;AACjC,SAAOF,IAAI,CACVG,2BADU,EAEVC,4BAFU,CAAJ,CAGJF,OAAO,IAAI,EAHP,CAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,2BAAT,CAAsCD,OAAtC,EAAgD;AAC/C,SAAOA,OAAO,CAACG,OAAR,CAAiB,KAAjB,EAAwB,OAAxB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASD,4BAAT,CAAuCF,OAAvC,EAAiD;AAChD,SAAOA,OAAO,CAACG,OAAR,CACN,mCADM,EAEN,gBAFM,CAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\n\n/**\n * Escapes ampersands, shortcodes, and links.\n *\n * @param {string} content The content of a code block.\n * @return {string} The given content with some characters escaped.\n */\nexport function escape( content ) {\n\treturn pipe(\n\t\tescapeOpeningSquareBrackets,\n\t\tescapeProtocolInIsolatedUrls\n\t)( content || '' );\n}\n\n/**\n * Returns the given content with all opening shortcode characters converted\n * into their HTML entity counterpart (i.e. [ => [). For instance, a\n * shortcode like [embed] becomes [embed]\n *\n * This function replicates the escaping of HTML tags, where a tag like\n * <strong> becomes <strong>.\n *\n * @param {string} content The content of a code block.\n * @return {string} The given content with its opening shortcode characters\n * converted into their HTML entity counterpart\n * (i.e. [ => [)\n */\nfunction escapeOpeningSquareBrackets( content ) {\n\treturn content.replace( /\\[/g, '[' );\n}\n\n/**\n * Converts the first two forward slashes of any isolated URL into their HTML\n * counterparts (i.e. // => //). For instance, https://youtube.com/watch?x\n * becomes https://youtube.com/watch?x.\n *\n * An isolated URL is a URL that sits in its own line, surrounded only by spacing\n * characters.\n *\n * See https://github.com/WordPress/wordpress-develop/blob/5.1.1/src/wp-includes/class-wp-embed.php#L403\n *\n * @param {string} content The content of a code block.\n * @return {string} The given content with its ampersands converted into\n * their HTML entity counterpart (i.e. & => &)\n */\nfunction escapeProtocolInIsolatedUrls( content ) {\n\treturn content.replace(\n\t\t/^(\\s*https?:)\\/\\/([^\\s<>\"]+\\s*)$/m,\n\t\t'$1//$2'\n\t);\n}\n"]}
|
|
@@ -53,7 +53,7 @@ function GroupEdit(_ref) {
|
|
|
53
53
|
const {
|
|
54
54
|
type = 'default'
|
|
55
55
|
} = usedLayout;
|
|
56
|
-
const layoutSupportEnabled = themeSupportsLayout || type
|
|
56
|
+
const layoutSupportEnabled = themeSupportsLayout || type === 'flex';
|
|
57
57
|
const blockProps = useBlockProps();
|
|
58
58
|
const innerBlocksProps = useInnerBlocksProps(layoutSupportEnabled ? blockProps : {
|
|
59
59
|
className: 'wp-block-group__inner-container'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","useSetting","store","blockEditorStore","SelectControl","__","htmlElementMessages","header","main","section","article","aside","footer","GroupEdit","attributes","setAttributes","clientId","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","defaultLayout","tagName","TagName","templateLock","layout","usedLayout","type","layoutSupportEnabled","blockProps","innerBlocksProps","className","renderAppender","undefined","ButtonBlockAppender","__experimentalLayout","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AAEA,SACCC,WADD,EAECC,aAFD,EAGCC,iBAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,KAAK,IAAIC,gBANV,QAOO,yBAPP;AAQA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,mBAAmB,GAAG;AAC3BC,EAAAA,MAAM,EAAEF,EAAE,CACT,qHADS,CADiB;AAI3BG,EAAAA,IAAI,EAAEH,EAAE,CACP,mFADO,CAJmB;AAO3BI,EAAAA,OAAO,EAAEJ,EAAE,CACV,kIADU,CAPgB;AAU3BK,EAAAA,OAAO,EAAEL,EAAE,CACV,gGADU,CAVgB;AAa3BM,EAAAA,KAAK,EAAEN,EAAE,CACR,uIADQ,CAbkB;AAgB3BO,EAAAA,MAAM,EAAEP,EAAE,CACT,8HADS;AAhBiB,CAA5B;;AAqBA,SAASQ,SAAT,OAA8D;AAAA,MAA1C;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA;AAA7B,GAA0C;AAC7D,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAA0CtB,SAAS,CACtDuB,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAA4BF,MAAM,CAAEhB,gBAAF,CAAxC;AACA,UAAMmB,KAAK,GAAGF,QAAQ,CAAEJ,QAAF,CAAtB;AACA,WAAO;AACNC,MAAAA,cAAc,EAAE,CAAC,EAAIK,KAAK,IAAIA,KAAK,CAACC,WAAN,CAAkBC,MAA/B,CADX;AAENN,MAAAA,mBAAmB,kBAAEG,WAAW,EAAb,iDAAE,aAAeI;AAF9B,KAAP;AAIA,GARuD,EASxD,CAAET,QAAF,CATwD,CAAzD;AAWA,QAAMU,aAAa,GAAGzB,UAAU,CAAE,QAAF,CAAV,IAA0B,EAAhD;AACA,QAAM;AAAE0B,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAArB;AAA4BC,IAAAA,YAA5B;AAA0CC,IAAAA,MAAM,GAAG;AAAnD,MAA0DhB,UAAhE;AACA,QAAMiB,UAAU,GAAG,EAAED,MAAF,aAAEA,MAAF,eAAEA,MAAM,CAAEE,IAAV,IAChB,EAAE,GAAGN,aAAL;AAAoB,OAAGI,MAAvB;AAA+BE,IAAAA,IAAI,EAAE;AAArC,GADgB,GAEhB,EAAE,GAAGN,aAAL;AAAoB,OAAGI;AAAvB,GAFH;AAGA,QAAM;AAAEE,IAAAA,IAAI,GAAG;AAAT,MAAuBD,UAA7B;AACA,QAAME,oBAAoB,GAAGf,mBAAmB,IAAIc,IAAI,KAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","useSetting","store","blockEditorStore","SelectControl","__","htmlElementMessages","header","main","section","article","aside","footer","GroupEdit","attributes","setAttributes","clientId","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","defaultLayout","tagName","TagName","templateLock","layout","usedLayout","type","layoutSupportEnabled","blockProps","innerBlocksProps","className","renderAppender","undefined","ButtonBlockAppender","__experimentalLayout","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AAEA,SACCC,WADD,EAECC,aAFD,EAGCC,iBAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,KAAK,IAAIC,gBANV,QAOO,yBAPP;AAQA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,mBAAmB,GAAG;AAC3BC,EAAAA,MAAM,EAAEF,EAAE,CACT,qHADS,CADiB;AAI3BG,EAAAA,IAAI,EAAEH,EAAE,CACP,mFADO,CAJmB;AAO3BI,EAAAA,OAAO,EAAEJ,EAAE,CACV,kIADU,CAPgB;AAU3BK,EAAAA,OAAO,EAAEL,EAAE,CACV,gGADU,CAVgB;AAa3BM,EAAAA,KAAK,EAAEN,EAAE,CACR,uIADQ,CAbkB;AAgB3BO,EAAAA,MAAM,EAAEP,EAAE,CACT,8HADS;AAhBiB,CAA5B;;AAqBA,SAASQ,SAAT,OAA8D;AAAA,MAA1C;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA;AAA7B,GAA0C;AAC7D,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAA0CtB,SAAS,CACtDuB,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAA4BF,MAAM,CAAEhB,gBAAF,CAAxC;AACA,UAAMmB,KAAK,GAAGF,QAAQ,CAAEJ,QAAF,CAAtB;AACA,WAAO;AACNC,MAAAA,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CACT;AAAEoC,MAAAA,KAAK,EAAEpC,EAAE,CAAE,iBAAF,CAAX;AAAkCqC,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE;AAA5B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,QAAT;AAAmBC,MAAAA,KAAK,EAAE;AAA1B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAJS,EAKT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KALS,EAMT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KANS,EAOT;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE;AAA5B,KAPS,CAFX;AAWC,IAAA,KAAK,EAAGd,OAXT;AAYC,IAAA,QAAQ,EAAKc,KAAF,IACV3B,aAAa,CAAE;AAAEY,MAAAA,OAAO,EAAEe;AAAX,KAAF,CAbf;AAeC,IAAA,IAAI,EAAGpC,mBAAmB,CAAEsB,OAAF;AAf3B,IADD,CADD,EAoBGK,oBAAoB,IAAI,cAAC,OAAD,EAAcE,gBAAd,CApB3B,EAuBG,CAAEF,oBAAF,IACD,cAAC,OAAD,EAAcC,UAAd,EACC,qBAAUC,gBAAV,CADD,CAxBF,CADD;AA+BA;;AAED,eAAetB,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst htmlElementMessages = {\n\theader: __(\n\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t),\n\tmain: __(\n\t\t'The <main> element should be used for the primary content of your document only. '\n\t),\n\tsection: __(\n\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t),\n\tarticle: __(\n\t\t'The <article> element should represent a self contained, syndicatable portion of the document.'\n\t),\n\taside: __(\n\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t),\n\tfooter: __(\n\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t),\n};\n\nfunction GroupEdit( { attributes, setAttributes, clientId } ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst { tagName: TagName = 'div', templateLock, layout = {} } = attributes;\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst { type = 'default' } = usedLayout;\n\tconst layoutSupportEnabled = themeSupportsLayout || type === 'flex';\n\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\trenderAppender: hasInnerBlocks\n\t\t\t\t? undefined\n\t\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t\t__experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ layoutSupportEnabled && <TagName { ...innerBlocksProps } /> }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"]}
|
|
@@ -211,19 +211,19 @@ function Navigation(_ref) {
|
|
|
211
211
|
// - there are no uncontrolled blocks.
|
|
212
212
|
|
|
213
213
|
const isPlaceholder = !ref && !isCreatingNavigationMenu && !isConvertingClassicMenu && hasResolvedNavigationMenus && !hasUncontrolledInnerBlocks;
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (isPlaceholder && !ref) {
|
|
216
|
+
/**
|
|
217
|
+
* this fallback only displays (both in editor and on front)
|
|
218
|
+
* the list of pages block if no menu is available as a fallback.
|
|
219
|
+
* We don't want the fallback to request a save,
|
|
220
|
+
* nor to be undoable, hence we mark it non persistent.
|
|
221
|
+
*/
|
|
222
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
214
223
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* the list of pages block if no menu is available as a fallback.
|
|
219
|
-
* We don't want the fallback to request a save,
|
|
220
|
-
* nor to be undoable, hence we mark it non persistent.
|
|
221
|
-
*/
|
|
222
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
223
|
-
|
|
224
|
-
replaceInnerBlocks(clientId, [createBlock('core/page-list')]);
|
|
225
|
-
}
|
|
226
|
-
|
|
224
|
+
replaceInnerBlocks(clientId, [createBlock('core/page-list')]);
|
|
225
|
+
}
|
|
226
|
+
}, [clientId, isPlaceholder, ref]);
|
|
227
227
|
const isEntityAvailable = !isNavigationMenuMissing && isNavigationMenuResolved; // "loading" state:
|
|
228
228
|
// - there is a menu creation process in progress.
|
|
229
229
|
// - there is a classic menu conversion process in progress.
|