@wordpress/edit-site 4.10.0 → 4.11.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/components/add-new-template/add-custom-template-modal.js +22 -42
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +17 -20
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +366 -239
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +183 -13
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +95 -17
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +31 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +7 -6
- package/build/components/header/index.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js +23 -43
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +18 -21
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +365 -227
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +183 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +94 -22
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +29 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +8 -6
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-style/style-rtl.css +25 -25
- package/build-style/style.css +25 -25
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-template-modal.js +27 -45
- package/src/components/add-new-template/new-template.js +27 -64
- package/src/components/add-new-template/style.scss +20 -8
- package/src/components/add-new-template/utils.js +398 -229
- package/src/components/block-editor/index.js +0 -2
- package/src/components/global-styles/dimensions-panel.js +207 -14
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/test/use-global-styles-output.js +64 -1
- package/src/components/global-styles/use-global-styles-output.js +100 -8
- package/src/components/global-styles/utils.js +31 -0
- package/src/components/header/index.js +9 -10
- package/src/components/header/style.scss +5 -3
- package/src/components/sidebar/style.scss +4 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- package/src/components/edit-template-part-menu-button/index.js +0 -82
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"names":["get","useSelect","store","coreStore","editorStore","decodeEntities","useMemo","__","sprintf","blockMeta","post","mapToIHasNameAndId","entities","path","map","entity","name","taxonomyBaseConfig","entityName","getOrderBy","search","getIcon","getTitle","labels","singular_name","getDescription","postTypeBaseConfig","recordNamePath","_icon","startsWith","slice","entitiesConfig","postType","templatePrefix","page","taxonomy","category","tag","templateSlug","useExistingTemplates","select","getEntityRecords","per_page","useDefaultTemplateTypes","__experimentalGetDefaultTemplateTypes","usePublicPostTypes","postTypes","getPostTypes","excludedPostTypes","filter","viewable","slug","includes","usePostTypes","usePostTypePage","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","useTaxonomies","specialTaxonomies","useTaxonomyCategory","useTaxonomyTag","useEntitiesInfo","existingTemplates","slugsToExcludePerEntity","reduce","accumulator","_prefix","slugsWithTemplates","_accumulator","existingTemplate","push","substring","length","recordsToExcludePerEntity","Object","entries","postsWithTemplates","_fields","context","entitiesInfo","existingEntitiesIds","id","hasEntities","exclude","useExtraTemplates","entityConfig","onClickMenuItem","defaultTemplateTypes","existingTemplateSlugs","extraTemplates","icon","slugForGeneralTemplate","defaultTemplateType","find","_slug","generalTemplateSlug","hasGeneralTemplate","menuItem","title","description","onClick","template","type","config","postsToExclude"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,IAApB,QAAgC,kBAAhC;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAG,CAAEC,QAAF,EAAYC,IAAZ,KAAsB;AACvD,SAAO,CAAED,QAAQ,IAAI,EAAd,EAAmBE,GAAnB,CAA0BC,MAAF,KAAgB,EAC9C,GAAGA,MAD2C;AAE9CC,IAAAA,IAAI,EAAEX,cAAc,CAAEL,GAAG,CAAEe,MAAF,EAAUF,IAAV,CAAL;AAF0B,GAAhB,CAA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B;AAgDA,SAAOwB,cAAP;AACA,CAhEM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post } from '@wordpress/icons';\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 * 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 * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\n/**\n * @typedef {Object} EntityConfig\n * @property {string} entityName The entity's name.\n * @property {Function} getOrderBy Getter for an entity's `orderBy` query parameter, given the object\n * {search} as argument.\n * @property {Function} getIcon Getter function for returning an entity's icon for the menu item.\n * @property {Function} getTitle Getter function for returning an entity's title for the menu item.\n * @property {Function} getDescription Getter function for returning an entity's description for the menu item.\n * @property {string} recordNamePath The path to an entity's properties to use as a `name`. If not provided\n * is assumed that `name` property exists.\n * @property {string} templatePrefix The template prefix to create new templates and check against existing\n * templates. For example custom post types need a `single-` prefix to all\n * templates(`single-post-hello`), whereas `pages` don't (`page-hello`).\n * @property {string} templateSlug If this property is provided, it is going to be used for the creation of\n * new templates and the check against existing templates in the place\n * of the actual entity's `slug`. An example is `Tag` templates where the\n * the Tag's taxonomy slug is `post_tag`, but template hierarchy is based\n * on `tag` alias.\n */\n\nconst taxonomyBaseConfig = {\n\tentityName: 'taxonomy',\n\tgetOrderBy: ( { search } ) => ( search ? 'name' : 'count' ),\n\tgetIcon: () => blockMeta,\n\tgetTitle: ( labels ) =>\n\t\tsprintf(\n\t\t\t// translators: %s: Name of the taxonomy e.g: \"Cagegory\".\n\t\t\t__( 'Single taxonomy: %s' ),\n\t\t\tlabels.singular_name\n\t\t),\n\tgetDescription: ( labels ) =>\n\t\tsprintf(\n\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t__( 'Displays a single taxonomy: %s.' ),\n\t\t\tlabels.singular_name\n\t\t),\n};\nconst postTypeBaseConfig = {\n\tentityName: 'postType',\n\tgetOrderBy: ( { search } ) => ( search ? 'relevance' : 'modified' ),\n\trecordNamePath: 'title.rendered',\n\t// `icon` is the `menu_icon` property of a post type. We\n\t// only handle `dashicons` for now, even if the `menu_icon`\n\t// also supports urls and svg as values.\n\tgetIcon: ( _icon ) =>\n\t\t_icon?.startsWith( 'dashicons-' ) ? _icon.slice( 10 ) : post,\n\tgetTitle: ( labels ) =>\n\t\tsprintf(\n\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t__( 'Single item: %s' ),\n\t\t\tlabels.singular_name\n\t\t),\n\tgetDescription: ( labels ) =>\n\t\tsprintf(\n\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\tlabels.singular_name\n\t\t),\n};\nexport const entitiesConfig = {\n\tpostType: {\n\t\t...postTypeBaseConfig,\n\t\ttemplatePrefix: 'single-',\n\t},\n\tpage: { ...postTypeBaseConfig },\n\ttaxonomy: {\n\t\t...taxonomyBaseConfig,\n\t\ttemplatePrefix: 'taxonomy-',\n\t},\n\tcategory: { ...taxonomyBaseConfig },\n\ttag: { ...taxonomyBaseConfig, templateSlug: 'tag' },\n};\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} ),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplateTypes(),\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t}, [ postTypes ] );\n};\n\n// `page` post type is a special case in the template hierarchy,\n// so we exclude it from the list of post types and we handle it\n// separately.\nexport const usePostTypes = () => {\n\tconst postTypes = usePublicPostTypes();\n\treturn useMemo( () => {\n\t\treturn postTypes?.filter( ( { slug } ) => slug !== 'page' );\n\t}, [ postTypes ] );\n};\nexport const usePostTypePage = () => {\n\tconst postTypes = usePublicPostTypes();\n\treturn useMemo( () => {\n\t\treturn postTypes?.filter( ( { slug } ) => slug === 'page' );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\n/**\n * `category` and `post_tag` are handled specifically in template\n * hierarchy so we need to differentiate them and return the rest,\n * e.g. `category-$slug` and `taxonomy-$taxonomy-$term`.\n */\nexport const useTaxonomies = () => {\n\tconst taxonomies = usePublicTaxonomies();\n\tconst specialTaxonomies = [ 'category', 'post_tag' ];\n\treturn useMemo(\n\t\t() =>\n\t\t\ttaxonomies?.filter(\n\t\t\t\t( { slug } ) => ! specialTaxonomies.includes( slug )\n\t\t\t),\n\t\t[ taxonomies ]\n\t);\n};\n\nexport const useTaxonomyCategory = () => {\n\tconst taxonomies = usePublicTaxonomies();\n\treturn useMemo(\n\t\t() => taxonomies?.filter( ( { slug } ) => slug === 'category' ),\n\t\t[ taxonomies ]\n\t);\n};\nexport const useTaxonomyTag = () => {\n\tconst taxonomies = usePublicTaxonomies();\n\treturn useMemo(\n\t\t() => taxonomies?.filter( ( { slug } ) => slug === 'post_tag' ),\n\t\t[ taxonomies ]\n\t);\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaing record, by excluding them.\n *\n * @param {string[]} existingTemplates The existing templates.\n * @param {Object[]} entities The array of entities we need to get extra information.\n * @param {EntityConfig} entityConfig The entity config.\n * @return {Record<string,EntitiesInfo>} An object with the `entities.slug` as `keys` and EntitiesInfo as values.\n */\nconst useEntitiesInfo = (\n\texistingTemplates,\n\tentities,\n\t{ entityName, templatePrefix, templateSlug }\n) => {\n\tconst slugsToExcludePerEntity = useMemo( () => {\n\t\treturn entities?.reduce( ( accumulator, entity ) => {\n\t\t\tlet _prefix = `${ templateSlug || entity.slug }-`;\n\t\t\tif ( templatePrefix ) {\n\t\t\t\t_prefix = templatePrefix + _prefix;\n\t\t\t}\n\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\texistingTemplate.slug.substring( _prefix.length )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn _accumulator;\n\t\t\t\t},\n\t\t\t\t[]\n\t\t\t);\n\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\taccumulator[ entity.slug ] = slugsWithTemplates;\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ entities, existingTemplates ] );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! slugsToExcludePerEntity ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn Object.entries( slugsToExcludePerEntity ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst postsWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\tif ( postsWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = postsWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\tconst entitiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\treturn entities?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\tentityName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.length,\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t}, {} );\n\t\t},\n\t\t[ entities, recordsToExcludePerEntity ]\n\t);\n\treturn entitiesInfo;\n};\n\nexport const useExtraTemplates = (\n\tentities,\n\tentityConfig,\n\tonClickMenuItem\n) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst entitiesInfo = useEntitiesInfo(\n\t\texistingTemplates,\n\t\tentities,\n\t\tentityConfig\n\t);\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst extraTemplates = ( entities || [] ).reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { slug, labels, icon } = entity;\n\t\t\tconst slugForGeneralTemplate = entityConfig.templateSlug || slug;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === slugForGeneralTemplate\n\t\t\t);\n\t\t\tconst generalTemplateSlug =\n\t\t\t\tdefaultTemplateType?.slug ||\n\t\t\t\t`${ entityConfig.templatePrefix }${ slug }`;\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? { ...defaultTemplateType }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: entityConfig.getTitle( labels ),\n\t\t\t\t\t\tdescription: entityConfig.getDescription( labels ),\n\t\t\t\t\t\ticon: entityConfig.getIcon?.( icon ),\n\t\t\t\t };\n\t\t\tconst hasEntities = entitiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: entityConfig.entityName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: entityConfig,\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\tpostsToExclude:\n\t\t\t\t\t\t\tentitiesInfo[ slug ].existingEntitiesIds,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\treturn extraTemplates;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"names":["get","useSelect","store","coreStore","editorStore","decodeEntities","useMemo","__","sprintf","blockMeta","post","mapToIHasNameAndId","entities","path","map","entity","name","useExistingTemplates","select","getEntityRecords","per_page","useDefaultTemplateTypes","__experimentalGetDefaultTemplateTypes","usePublicPostTypes","postTypes","getPostTypes","excludedPostTypes","filter","viewable","slug","includes","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","usePostTypeMenuItems","onClickMenuItem","publicPostTypes","existingTemplates","defaultTemplateTypes","templatePrefixes","reduce","accumulator","suffix","postTypeLabels","labels","singularName","singular_name","toLowerCase","needsUniqueIdentifier","postTypesInfo","useEntitiesInfo","existingTemplateSlugs","menuItems","postType","icon","generalTemplateSlug","defaultTemplateType","find","_slug","hasGeneralTemplate","_needsUniqueIdentifier","menuItemTitle","menuItem","title","description","startsWith","slice","hasEntities","onClick","template","type","config","recordNamePath","queryArgs","search","_fields","orderBy","exclude","existingEntitiesIds","getSpecificTemplate","suggestion","push","postTypesMenuItems","key","defaultPostTypesMenuItems","useTaxonomiesMenuItems","publicTaxonomies","taxonomyLabels","taxonomiesInfo","taxonomy","taxonomiesMenuItems","defaultTaxonomiesMenuItems","useExistingTemplateSlugs","existingSlugs","Object","entries","prefix","slugsWithTemplates","_accumulator","existingTemplate","_prefix","substring","length","useTemplatesToExclude","entityName","slugsToExcludePerEntity","recordsToExcludePerEntity","entitiesWithTemplates","context","entitiesInfo","keys","id"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,IAApB,QAAgC,kBAAhC;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAG,CAAEC,QAAF,EAAYC,IAAZ,KAAsB;AACvD,SAAO,CAAED,QAAQ,IAAI,EAAd,EAAmBE,GAAnB,CAA0BC,MAAF,KAAgB,EAC9C,GAAGA,MAD2C;AAE9CC,IAAAA,IAAI,EAAEX,cAAc,CAAEL,GAAG,CAAEe,MAAF,EAAUF,IAAV,CAAL;AAF0B,GAAhB,CAAxB,CAAP;AAIA,CALM;AAOP;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMI,oBAAoB,GAAG,MAAM;AACzC,SAAOhB,SAAS,CACbiB,MAAF,IACCA,MAAM,CAAEf,SAAF,CAAN,CAAoBgB,gBAApB,CAAsC,UAAtC,EAAkD,aAAlD,EAAiE;AAChEC,IAAAA,QAAQ,EAAE,CAAC;AADqD,GAAjE,CAFc,EAKf,EALe,CAAhB;AAOA,CARM;AAUP,OAAO,MAAMC,uBAAuB,GAAG,MAAM;AAC5C,SAAOpB,SAAS,CACbiB,MAAF,IACCA,MAAM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f,GAArC,CACC;AAAA,YAAE;AAAEmG,UAAAA;AAAF,SAAF;AAAA,eAAcA,EAAd;AAAA,OADD,MAEK,EAHN;AAIAtE,MAAAA,WAAW,CAAEd,IAAF,CAAX,GAAsB;AACrBwC,QAAAA,WAAW,EAAE,CAAC,2BAAEnD,MAAM,CAAEf,SAAF,CAAN,CAAoBgB,gBAApB,CACfuF,UADe,EAEf7E,IAFe,EAGf;AACCT,UAAAA,QAAQ,EAAE,CADX;AAECyD,UAAAA,OAAO,EAAE,IAFV;AAGCiC,UAAAA,OAAO,EAAE,MAHV;AAIC/B,UAAAA,OAAO,EAAEC;AAJV,SAHe,CAAF,kDAAE,sBASbwB,MATW,CADO;AAWrBxB,QAAAA;AAXqB,OAAtB;AAaA,aAAOrC,WAAP;AACA,KApBK,EAqBN,EArBM,CAAP;AAuBA,GAzB4B,EA0B7B,CAAEF,gBAAF,EAAoBmE,yBAApB,CA1B6B,CAA9B;AA4BA,SAAOG,YAAP;AACA,CAlCD","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post } from '@wordpress/icons';\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 * 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 * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} ),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplateTypes(),\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = publicPostTypes?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\taccumulator[ singularName ] =\n\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t};\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\tlabels.singular_name\n\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = sprintf(\n\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t__( 'Single item: %1$s (%2$s)' ),\n\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\tslug\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? { ...defaultTemplateType }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon: icon?.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t: post,\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tlet title = sprintf(\n\t\t\t\t\t\t\t\t\t// translators: Represents the title of a user's custom template in the Site Editor, where %1$s is the singular name of a post type and %2$s is the name of the post, e.g. \"Page: Hello\".\n\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst description = sprintf(\n\t\t\t\t\t\t\t\t\t// translators: Represents the description of a user's custom template in the Site Editor, e.g. \"Template for Page: Hello\"\n\t\t\t\t\t\t\t\t\t__( 'Template for %1$s' ),\n\t\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: Represents the title of a user's custom template in the Site Editor, where %1$s is the template title and %2$s is the slug of the post type, e.g. \"Project: Hello (project_type)\"\n\t\t\t\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\t`(${ slug })`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\tslug: `${ templatePrefixes[ slug ] }-${ suggestion.slug }`,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\taccumulator[ singularName ] =\n\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\treturn taxonomyLabels[ singularName ] > 1 && singularName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = sprintf(\n\t\t\t\t\t// translators: %1s: Name of the taxonomy e.g: \"Category\"; %2s: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\tslug\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? { ...defaultTemplateType }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tlet title = sprintf(\n\t\t\t\t\t\t\t\t\t// translators: Represents the title of a user's custom template in the Site Editor, where %1$s is the singular name of a taxonomy and %2$s is the name of the term, e.g. \"Category: shoes\".\n\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst description = sprintf(\n\t\t\t\t\t\t\t\t\t// translators: Represents the description of a user's custom template in the Site Editor, e.g. \"Template for Category: shoes\"\n\t\t\t\t\t\t\t\t\t__( 'Template for %1$s' ),\n\t\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: Represents the title of a user's custom template in the Site Editor, where %1$s is the template title and %2$s is the slug of the taxonomy, e.g. \"Category: shoes (product_tag)\"\n\t\t\t\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\t`(${ slug })`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\tslug: `${ templatePrefixes[ slug ] }-${ suggestion.slug }`,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: tag-apple }, { slug: page-about }, { slug: tag } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: [apple] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = ( entityName, templatePrefixes ) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = ( entityName, templatePrefixes ) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes\n\t);\n\tconst entitiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\t\thasEntities: !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t\tentityName,\n\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)?.length,\n\t\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t\t};\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ templatePrefixes, recordsToExcludePerEntity ]\n\t);\n\treturn entitiesInfo;\n};\n"]}
|
|
@@ -29,7 +29,6 @@ import NavigateToLink from '../navigate-to-link';
|
|
|
29
29
|
import { SidebarInspectorFill } from '../sidebar';
|
|
30
30
|
import { store as editSiteStore } from '../../store';
|
|
31
31
|
import BlockInspectorButton from './block-inspector-button';
|
|
32
|
-
import EditTemplatePartMenuButton from '../edit-template-part-menu-button';
|
|
33
32
|
import BackButton from './back-button';
|
|
34
33
|
import ResizableEditor from './resizable-editor';
|
|
35
34
|
const LAYOUT = {
|
|
@@ -122,7 +121,7 @@ export default function BlockEditor(_ref) {
|
|
|
122
121
|
onInput: onInput,
|
|
123
122
|
onChange: onChange,
|
|
124
123
|
useSubRegistry: false
|
|
125
|
-
}, createElement(
|
|
124
|
+
}, createElement(TemplatePartConverter, null), createElement(__experimentalLinkControl.ViewerFill, null, useCallback(fillProps => createElement(NavigateToLink, _extends({}, fillProps, {
|
|
126
125
|
activePage: page,
|
|
127
126
|
onActivePageChange: setPage
|
|
128
127
|
})), [page])), createElement(SidebarInspectorFill, null, createElement(BlockInspector, null)), createElement(BlockTools, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","omit","unionBy","useSelect","useDispatch","useCallback","useMemo","useRef","Fragment","useEntityBlockEditor","store","coreStore","BlockList","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockTools","__unstableBlockToolbarLastItem","__unstableBlockSettingsMenuFirstItem","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","__unstableBlockNameContext","useMergeRefs","useViewportMatch","ReusableBlocksMenuItems","listView","ToolbarButton","ToolbarGroup","__","interfaceStore","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","editSiteStore","BlockInspectorButton","EditTemplatePartMenuButton","BackButton","ResizableEditor","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","storedSettings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","blockPatternCategories","settings","blocks","onInput","onChange","setPage","enableComplementaryArea","openNavigationSidebar","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","isTemplatePart","hasBlocks","length","NavMenuSidebarToggle","MaybeNavMenuSidebarToggle","process","env","IS_GUTENBERG_PLUGIN","fillProps","event","target","currentTarget","undefined","onClose","blockName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,EAAeC,OAAf,QAA8B,QAA9B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+B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c,IAAIC,SAAlB,GAA8B,KAA9B,GAAsCW;AAJxC,IAXD,CAdD,EAiCC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CAjCD,EAsCC,cAAC,8BAAD,QACC,cAAC,0BAAD,CAA4B,QAA5B,QACKC,SAAF,IACDA,SAAS,KAAK,iBAAd,IACC,cAAC,yBAAD,OAHH,CADD,CAtCD,CAxBD,EAwEC,cAAC,uBAAD,OAxED,CADD;AA4EA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit, unionBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo, useRef, Fragment } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockToolbarLastItem,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\t__unstableBlockNameContext,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { listView } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport EditTemplatePartMenuButton from '../edit-template-part-menu-button';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { storedSettings, templateType, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, getEditedPostId, getPage } =\n\t\t\t\tselect( editSiteStore );\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpen ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() => unionBy( settingsBlockPatterns, restBlockPatterns, 'name' ),\n\t\t[ settingsBlockPatterns, restBlockPatterns ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\tunionBy(\n\t\t\t\tsettingsBlockPatternCategories,\n\t\t\t\trestBlockPatternCategories,\n\t\t\t\t'name'\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...omit( storedSettings, [\n\t\t\t\t'__experimentalAdditionalBlockPatterns',\n\t\t\t\t'__experimentalAdditionalBlockPatternCategories',\n\t\t\t] ),\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t} ),\n\t\t[ storedSettings, blockPatterns, blockPatternCategories ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst openNavigationSidebar = useCallback( () => {\n\t\tenableComplementaryArea(\n\t\t\t'core/edit-site',\n\t\t\t'edit-site/navigation-menu'\n\t\t);\n\t}, [ enableComplementaryArea ] );\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\n\tconst NavMenuSidebarToggle = () => (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Open list view' ) }\n\t\t\t\tonClick={ openNavigationSidebar }\n\t\t\t\ticon={ listView }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavMenuSidebarToggle = Fragment;\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavMenuSidebarToggle = NavMenuSidebarToggle;\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<EditTemplatePartMenuButton />\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t<BackButton />\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\trenderAppender={\n\t\t\t\t\t\t\tisTemplatePart && hasBlocks ? false : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t<__unstableBlockToolbarLastItem>\n\t\t\t\t\t<__unstableBlockNameContext.Consumer>\n\t\t\t\t\t\t{ ( blockName ) =>\n\t\t\t\t\t\t\tblockName === 'core/navigation' && (\n\t\t\t\t\t\t\t\t<MaybeNavMenuSidebarToggle />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</__unstableBlockNameContext.Consumer>\n\t\t\t\t</__unstableBlockToolbarLastItem>\n\t\t\t</BlockTools>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","omit","unionBy","useSelect","useDispatch","useCallback","useMemo","useRef","Fragment","useEntityBlockEditor","store","coreStore","BlockList","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockTools","__unstableBlockToolbarLastItem","__unstableBlockSettingsMenuFirstItem","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","__unstableBlockNameContext","useMergeRefs","useViewportMatch","ReusableBlocksMenuItems","listView","ToolbarButton","ToolbarGroup","__","interfaceStore","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","editSiteStore","BlockInspectorButton","BackButton","ResizableEditor","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","storedSettings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","blockPatternCategories","settings","blocks","onInput","onChange","setPage","enableComplementaryArea","openNavigationSidebar","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","isTemplatePart","hasBlocks","length","NavMenuSidebarToggle","MaybeNavMenuSidebarToggle","process","env","IS_GUTENBERG_PLUGIN","fillProps","event","target","currentTarget","undefined","onClose","blockName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,EAAeC,OAAf,QAA8B,QAA9B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,MAA/B,EAAuCC,QAAvC,QAAuD,oBAAvD;AACA,SAASC,oBAAT,EAA+BC,KAAK,IAAIC,SAAxC,QAAyD,sBAAzD;AACA,SACCC,SADD,EAECC,mBAFD,EAGCC,yBAHD,EAICC,cAJD,EAKCC,UALD,EAMCC,8BAND,EAOCC,oCAPD,EAQCC,2BAA2B,IAAIC,iBARhC,EASCC,4BATD,EAUCX,KAAK,IAAIY,gBAVV,EAWCC,0BAXD,QAYO,yBAZP;AAaA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,oBAA/C;AACA,SAASC,uBAAT,QAAwC,4BAAxC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,uBAA5C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASpB,KAAK,IAAIqB,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASxB,KAAK,IAAIyB,aAAlB,QAAuC,aAAvC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AAC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AiBD,KAAK,CAACE,aAA5B,EAA4C;AAC3CZ,QAAAA,kBAAkB;AAClB;AACD;AAVF,KAYC,cAAC,4BAAD,CAA8B,QAA9B,OAZD,EAaC,cAAC,UAAD,OAbD,EAcC,cAAC,eAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAG7B,UAFP;AAGC,IAAA,cAAc,EACb8B,cAAc,IACd;AACA,KAAEF,gBANJ;AAQC,IAAA,QAAQ,EAAGT,QARZ;AASC,IAAA,UAAU,EAAGQ;AATd,KAWC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGlC,MAFxB;AAGC,IAAA,cAAc,EACbqC,cAAc,IAAIC,SAAlB,GAA8B,KAA9B,GAAsCW;AAJxC,IAXD,CAdD,EAiCC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CAjCD,EAsCC,cAAC,8BAAD,QACC,cAAC,0BAAD,CAA4B,QAA5B,QACKC,SAAF,IACDA,SAAS,KAAK,iBAAd,IACC,cAAC,yBAAD,OAHH,CADD,CAtCD,CAvBD,EAuEC,cAAC,uBAAD,OAvED,CADD;AA2EA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit, unionBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo, useRef, Fragment } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockToolbarLastItem,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\t__unstableBlockNameContext,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { listView } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { storedSettings, templateType, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, getEditedPostId, getPage } =\n\t\t\t\tselect( editSiteStore );\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpen ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() => unionBy( settingsBlockPatterns, restBlockPatterns, 'name' ),\n\t\t[ settingsBlockPatterns, restBlockPatterns ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\tunionBy(\n\t\t\t\tsettingsBlockPatternCategories,\n\t\t\t\trestBlockPatternCategories,\n\t\t\t\t'name'\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...omit( storedSettings, [\n\t\t\t\t'__experimentalAdditionalBlockPatterns',\n\t\t\t\t'__experimentalAdditionalBlockPatternCategories',\n\t\t\t] ),\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t} ),\n\t\t[ storedSettings, blockPatterns, blockPatternCategories ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst openNavigationSidebar = useCallback( () => {\n\t\tenableComplementaryArea(\n\t\t\t'core/edit-site',\n\t\t\t'edit-site/navigation-menu'\n\t\t);\n\t}, [ enableComplementaryArea ] );\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\n\tconst NavMenuSidebarToggle = () => (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Open list view' ) }\n\t\t\t\tonClick={ openNavigationSidebar }\n\t\t\t\ticon={ listView }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavMenuSidebarToggle = Fragment;\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavMenuSidebarToggle = NavMenuSidebarToggle;\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t<BackButton />\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\trenderAppender={\n\t\t\t\t\t\t\tisTemplatePart && hasBlocks ? false : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t<__unstableBlockToolbarLastItem>\n\t\t\t\t\t<__unstableBlockNameContext.Consumer>\n\t\t\t\t\t\t{ ( blockName ) =>\n\t\t\t\t\t\t\tblockName === 'core/navigation' && (\n\t\t\t\t\t\t\t\t<MaybeNavMenuSidebarToggle />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</__unstableBlockNameContext.Consumer>\n\t\t\t\t</__unstableBlockToolbarLastItem>\n\t\t\t</BlockTools>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -4,8 +4,9 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalBoxControl as BoxControl, __experimentalUnitControl as UnitControl, __experimentalUseCustomUnits as useCustomUnits } from '@wordpress/components';
|
|
7
|
+
import { __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalBoxControl as BoxControl, __experimentalHStack as HStack, __experimentalUnitControl as UnitControl, __experimentalUseCustomUnits as useCustomUnits, __experimentalView as View } from '@wordpress/components';
|
|
8
8
|
import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';
|
|
9
|
+
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
@@ -13,10 +14,24 @@ import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block
|
|
|
13
14
|
import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
|
|
14
15
|
const AXIAL_SIDES = ['horizontal', 'vertical'];
|
|
15
16
|
export function useHasDimensionsPanel(name) {
|
|
17
|
+
const hasContentSize = useHasContentSize(name);
|
|
18
|
+
const hasWideSize = useHasWideSize(name);
|
|
16
19
|
const hasPadding = useHasPadding(name);
|
|
17
20
|
const hasMargin = useHasMargin(name);
|
|
18
21
|
const hasGap = useHasGap(name);
|
|
19
|
-
return hasPadding || hasMargin || hasGap;
|
|
22
|
+
return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function useHasContentSize(name) {
|
|
26
|
+
const supports = getSupportedGlobalStylesPanels(name);
|
|
27
|
+
const [settings] = useSetting('layout.contentSize', name);
|
|
28
|
+
return settings && supports.includes('contentSize');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function useHasWideSize(name) {
|
|
32
|
+
const supports = getSupportedGlobalStylesPanels(name);
|
|
33
|
+
const [settings] = useSetting('layout.wideSize', name);
|
|
34
|
+
return settings && supports.includes('wideSize');
|
|
20
35
|
}
|
|
21
36
|
|
|
22
37
|
function useHasPadding(name) {
|
|
@@ -74,18 +89,44 @@ function splitStyleValue(value) {
|
|
|
74
89
|
}
|
|
75
90
|
|
|
76
91
|
return value;
|
|
77
|
-
}
|
|
92
|
+
} // Props for managing `layout.contentSize`.
|
|
78
93
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
|
|
95
|
+
function useContentSizeProps(name) {
|
|
96
|
+
const [contentSizeValue, setContentSizeValue] = useSetting('layout.contentSize', name);
|
|
97
|
+
const [userSetContentSizeValue] = useSetting('layout.contentSize', name, 'user');
|
|
98
|
+
|
|
99
|
+
const hasUserSetContentSizeValue = () => !!userSetContentSizeValue;
|
|
100
|
+
|
|
101
|
+
const resetContentSizeValue = () => setContentSizeValue('');
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
contentSizeValue,
|
|
105
|
+
setContentSizeValue,
|
|
106
|
+
hasUserSetContentSizeValue,
|
|
107
|
+
resetContentSizeValue
|
|
108
|
+
};
|
|
109
|
+
} // Props for managing `layout.wideSize`.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function useWideSizeProps(name) {
|
|
113
|
+
const [wideSizeValue, setWideSizeValue] = useSetting('layout.wideSize', name);
|
|
114
|
+
const [userSetWideSizeValue] = useSetting('layout.wideSize', name, 'user');
|
|
115
|
+
|
|
116
|
+
const hasUserSetWideSizeValue = () => !!userSetWideSizeValue;
|
|
117
|
+
|
|
118
|
+
const resetWideSizeValue = () => setWideSizeValue('');
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
wideSizeValue,
|
|
122
|
+
setWideSizeValue,
|
|
123
|
+
hasUserSetWideSizeValue,
|
|
124
|
+
resetWideSizeValue
|
|
125
|
+
};
|
|
126
|
+
} // Props for managing `spacing.padding`.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
function usePaddingProps(name) {
|
|
89
130
|
const [rawPadding, setRawPadding] = useStyle('spacing.padding', name);
|
|
90
131
|
const paddingValues = splitStyleValue(rawPadding);
|
|
91
132
|
const paddingSides = useCustomSides(name, 'padding');
|
|
@@ -100,6 +141,18 @@ export default function DimensionsPanel(_ref) {
|
|
|
100
141
|
|
|
101
142
|
const hasPaddingValue = () => !!paddingValues && Object.keys(paddingValues).length;
|
|
102
143
|
|
|
144
|
+
return {
|
|
145
|
+
paddingValues,
|
|
146
|
+
paddingSides,
|
|
147
|
+
isAxialPadding,
|
|
148
|
+
setPaddingValues,
|
|
149
|
+
resetPaddingValue,
|
|
150
|
+
hasPaddingValue
|
|
151
|
+
};
|
|
152
|
+
} // Props for managing `spacing.margin`.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
function useMarginProps(name) {
|
|
103
156
|
const [rawMargin, setRawMargin] = useStyle('spacing.margin', name);
|
|
104
157
|
const marginValues = splitStyleValue(rawMargin);
|
|
105
158
|
const marginSides = useCustomSides(name, 'margin');
|
|
@@ -114,22 +167,138 @@ export default function DimensionsPanel(_ref) {
|
|
|
114
167
|
|
|
115
168
|
const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
|
|
116
169
|
|
|
170
|
+
return {
|
|
171
|
+
marginValues,
|
|
172
|
+
marginSides,
|
|
173
|
+
isAxialMargin,
|
|
174
|
+
setMarginValues,
|
|
175
|
+
resetMarginValue,
|
|
176
|
+
hasMarginValue
|
|
177
|
+
};
|
|
178
|
+
} // Props for managing `spacing.blockGap`.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
function useBlockGapProps(name) {
|
|
117
182
|
const [gapValue, setGapValue] = useStyle('spacing.blockGap', name);
|
|
118
183
|
|
|
119
184
|
const resetGapValue = () => setGapValue(undefined);
|
|
120
185
|
|
|
121
186
|
const hasGapValue = () => !!gapValue;
|
|
122
187
|
|
|
188
|
+
return {
|
|
189
|
+
gapValue,
|
|
190
|
+
setGapValue,
|
|
191
|
+
resetGapValue,
|
|
192
|
+
hasGapValue
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export default function DimensionsPanel(_ref) {
|
|
197
|
+
let {
|
|
198
|
+
name
|
|
199
|
+
} = _ref;
|
|
200
|
+
const showContentSizeControl = useHasContentSize(name);
|
|
201
|
+
const showWideSizeControl = useHasWideSize(name);
|
|
202
|
+
const showPaddingControl = useHasPadding(name);
|
|
203
|
+
const showMarginControl = useHasMargin(name);
|
|
204
|
+
const showGapControl = useHasGap(name);
|
|
205
|
+
const units = useCustomUnits({
|
|
206
|
+
availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
|
|
207
|
+
}); // Props for managing `layout.contentSize`.
|
|
208
|
+
|
|
209
|
+
const {
|
|
210
|
+
contentSizeValue,
|
|
211
|
+
setContentSizeValue,
|
|
212
|
+
hasUserSetContentSizeValue,
|
|
213
|
+
resetContentSizeValue
|
|
214
|
+
} = useContentSizeProps(name); // Props for managing `layout.wideSize`.
|
|
215
|
+
|
|
216
|
+
const {
|
|
217
|
+
wideSizeValue,
|
|
218
|
+
setWideSizeValue,
|
|
219
|
+
hasUserSetWideSizeValue,
|
|
220
|
+
resetWideSizeValue
|
|
221
|
+
} = useWideSizeProps(name); // Props for managing `spacing.padding`.
|
|
222
|
+
|
|
223
|
+
const {
|
|
224
|
+
paddingValues,
|
|
225
|
+
paddingSides,
|
|
226
|
+
isAxialPadding,
|
|
227
|
+
setPaddingValues,
|
|
228
|
+
resetPaddingValue,
|
|
229
|
+
hasPaddingValue
|
|
230
|
+
} = usePaddingProps(name); // Props for managing `spacing.margin`.
|
|
231
|
+
|
|
232
|
+
const {
|
|
233
|
+
marginValues,
|
|
234
|
+
marginSides,
|
|
235
|
+
isAxialMargin,
|
|
236
|
+
setMarginValues,
|
|
237
|
+
resetMarginValue,
|
|
238
|
+
hasMarginValue
|
|
239
|
+
} = useMarginProps(name); // Props for managing `spacing.blockGap`.
|
|
240
|
+
|
|
241
|
+
const {
|
|
242
|
+
gapValue,
|
|
243
|
+
setGapValue,
|
|
244
|
+
resetGapValue,
|
|
245
|
+
hasGapValue
|
|
246
|
+
} = useBlockGapProps(name);
|
|
247
|
+
|
|
123
248
|
const resetAll = () => {
|
|
124
249
|
resetPaddingValue();
|
|
125
250
|
resetMarginValue();
|
|
126
251
|
resetGapValue();
|
|
252
|
+
resetContentSizeValue();
|
|
253
|
+
resetWideSizeValue();
|
|
127
254
|
};
|
|
128
255
|
|
|
129
256
|
return createElement(ToolsPanel, {
|
|
130
257
|
label: __('Dimensions'),
|
|
131
258
|
resetAll: resetAll
|
|
132
|
-
},
|
|
259
|
+
}, (showContentSizeControl || showWideSizeControl) && createElement("span", {
|
|
260
|
+
className: "span-columns"
|
|
261
|
+
}, __('Set the width of the main content area.')), showContentSizeControl && createElement(ToolsPanelItem, {
|
|
262
|
+
className: "single-column",
|
|
263
|
+
label: __('Content size'),
|
|
264
|
+
hasValue: hasUserSetContentSizeValue,
|
|
265
|
+
onDeselect: resetContentSizeValue,
|
|
266
|
+
isShownByDefault: true
|
|
267
|
+
}, createElement(HStack, {
|
|
268
|
+
alignment: "flex-end",
|
|
269
|
+
justify: "flex-start"
|
|
270
|
+
}, createElement(UnitControl, {
|
|
271
|
+
label: __('Content'),
|
|
272
|
+
labelPosition: "top",
|
|
273
|
+
__unstableInputWidth: "80px",
|
|
274
|
+
value: contentSizeValue || '',
|
|
275
|
+
onChange: nextContentSize => {
|
|
276
|
+
setContentSizeValue(nextContentSize);
|
|
277
|
+
},
|
|
278
|
+
units: units
|
|
279
|
+
}), createElement(View, null, createElement(Icon, {
|
|
280
|
+
icon: positionCenter
|
|
281
|
+
})))), showWideSizeControl && createElement(ToolsPanelItem, {
|
|
282
|
+
className: "single-column",
|
|
283
|
+
label: __('Wide size'),
|
|
284
|
+
hasValue: hasUserSetWideSizeValue,
|
|
285
|
+
onDeselect: resetWideSizeValue,
|
|
286
|
+
isShownByDefault: true
|
|
287
|
+
}, createElement(HStack, {
|
|
288
|
+
alignment: "flex-end",
|
|
289
|
+
justify: "flex-start"
|
|
290
|
+
}, createElement(UnitControl, {
|
|
291
|
+
label: __('Wide'),
|
|
292
|
+
labelPosition: "top",
|
|
293
|
+
__unstableInputWidth: "80px",
|
|
294
|
+
value: wideSizeValue || '',
|
|
295
|
+
onChange: nextWideSize => {
|
|
296
|
+
setWideSizeValue(nextWideSize);
|
|
297
|
+
},
|
|
298
|
+
units: units
|
|
299
|
+
}), createElement(View, null, createElement(Icon, {
|
|
300
|
+
icon: stretchWide
|
|
301
|
+
})))), showPaddingControl && createElement(ToolsPanelItem, {
|
|
133
302
|
hasValue: hasPaddingValue,
|
|
134
303
|
label: __('Padding'),
|
|
135
304
|
onDeselect: resetPaddingValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/dimensions-panel.js"],"names":["__","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalBoxControl","BoxControl","__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__experimentalUseCustomSides","useCustomSides","getSupportedGlobalStylesPanels","useSetting","useStyle","AXIAL_SIDES","useHasDimensionsPanel","name","hasPadding","useHasPadding","hasMargin","useHasMargin","hasGap","useHasGap","supports","settings","includes","filterValuesBySides","values","sides","filteredValues","forEach","side","top","bottom","left","right","splitStyleValue","value","DimensionsPanel","showPaddingControl","showMarginControl","showGapControl","units","availableUnits","rawPadding","setRawPadding","paddingValues","paddingSides","isAxialPadding","some","setPaddingValues","newPaddingValues","padding","resetPaddingValue","hasPaddingValue","Object","keys","length","rawMargin","setRawMargin","marginValues","marginSides","isAxialMargin","setMarginValues","newMarginValues","margin","resetMarginValue","hasMarginValue","gapValue","setGapValue","resetGapValue","undefined","hasGapValue","resetAll"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,wBAAwB,IAAIC,UAD7B,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,wBAAwB,IAAIC,UAH7B,EAICC,yBAAyB,IAAIC,WAJ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Q,EAAG2B,cADZ;AAEC,IAAA,KAAK,EAAGrE,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAGoE,gBAHd;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,UAAD;AACC,IAAA,MAAM,EAAGN,YADV;AAEC,IAAA,QAAQ,EAAGG,eAFZ;AAGC,IAAA,KAAK,EAAGjE,EAAE,CAAE,QAAF,CAHX;AAIC,IAAA,KAAK,EAAG+D,WAJT;AAKC,IAAA,KAAK,EAAGnB,KALT;AAMC,IAAA,UAAU,EAAG,KANd;AAOC,IAAA,WAAW,EAAGoB;AAPf,IAND,CApBF,EAqCGrB,cAAc,IACf,cAAC,cAAD;AACC,IAAA,QAAQ,EAAG+B,WADZ;AAEC,IAAA,KAAK,EAAG1E,EAAE,CAAE,eAAF,CAFX;AAGC,IAAA,UAAU,EAAGwE,aAHd;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGxE,EAAE,CAAE,eAAF,CADX;AAEC,IAAA,oBAAoB,EAAC,MAFtB;AAGC,IAAA,GAAG,EAAG,CAHP;AAIC,IAAA,QAAQ,EAAGuE,WAJZ;AAKC,IAAA,KAAK,EAAG3B,KALT;AAMC,IAAA,KAAK,EAAG0B;AANT,IAND,CAtCF,CADD;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nconst AXIAL_SIDES = [ 'horizontal', 'vertical' ];\n\nexport function useHasDimensionsPanel( name ) {\n\tconst hasPadding = useHasPadding( name );\n\tconst hasMargin = useHasMargin( name );\n\tconst hasGap = useHasGap( name );\n\n\treturn hasPadding || hasMargin || hasGap;\n}\n\nfunction useHasPadding( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.padding', name );\n\n\treturn settings && supports.includes( 'padding' );\n}\n\nfunction useHasMargin( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.margin', name );\n\n\treturn settings && supports.includes( 'margin' );\n}\n\nfunction useHasGap( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.blockGap', name );\n\n\treturn settings && supports.includes( 'blockGap' );\n}\n\nfunction filterValuesBySides( values, sides ) {\n\tif ( ! sides ) {\n\t\t// If no custom side configuration all sides are opted into by default.\n\t\treturn values;\n\t}\n\n\t// Only include sides opted into within filtered values.\n\tconst filteredValues = {};\n\tsides.forEach( ( side ) => {\n\t\tif ( side === 'vertical' ) {\n\t\t\tfilteredValues.top = values.top;\n\t\t\tfilteredValues.bottom = values.bottom;\n\t\t}\n\t\tif ( side === 'horizontal' ) {\n\t\t\tfilteredValues.left = values.left;\n\t\t\tfilteredValues.right = values.right;\n\t\t}\n\t\tfilteredValues[ side ] = values[ side ];\n\t} );\n\n\treturn filteredValues;\n}\n\nfunction splitStyleValue( value ) {\n\t// Check for shorthand value ( a string value ).\n\tif ( value && typeof value === 'string' ) {\n\t\t// Convert to value for individual sides for BoxControl.\n\t\treturn {\n\t\t\ttop: value,\n\t\t\tright: value,\n\t\t\tbottom: value,\n\t\t\tleft: value,\n\t\t};\n\t}\n\n\treturn value;\n}\n\nexport default function DimensionsPanel( { name } ) {\n\tconst showPaddingControl = useHasPadding( name );\n\tconst showMarginControl = useHasMargin( name );\n\tconst showGapControl = useHasGap( name );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units', name )[ 0 ] || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst [ rawPadding, setRawPadding ] = useStyle( 'spacing.padding', name );\n\tconst paddingValues = splitStyleValue( rawPadding );\n\tconst paddingSides = useCustomSides( name, 'padding' );\n\tconst isAxialPadding =\n\t\tpaddingSides &&\n\t\tpaddingSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setPaddingValues = ( newPaddingValues ) => {\n\t\tconst padding = filterValuesBySides( newPaddingValues, paddingSides );\n\t\tsetRawPadding( padding );\n\t};\n\tconst resetPaddingValue = () => setPaddingValues( {} );\n\tconst hasPaddingValue = () =>\n\t\t!! paddingValues && Object.keys( paddingValues ).length;\n\n\tconst [ rawMargin, setRawMargin ] = useStyle( 'spacing.margin', name );\n\tconst marginValues = splitStyleValue( rawMargin );\n\tconst marginSides = useCustomSides( name, 'margin' );\n\tconst isAxialMargin =\n\t\tmarginSides &&\n\t\tmarginSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setMarginValues = ( newMarginValues ) => {\n\t\tconst margin = filterValuesBySides( newMarginValues, marginSides );\n\t\tsetRawMargin( margin );\n\t};\n\tconst resetMarginValue = () => setMarginValues( {} );\n\tconst hasMarginValue = () =>\n\t\t!! marginValues && Object.keys( marginValues ).length;\n\n\tconst [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );\n\tconst resetGapValue = () => setGapValue( undefined );\n\tconst hasGapValue = () => !! gapValue;\n\n\tconst resetAll = () => {\n\t\tresetPaddingValue();\n\t\tresetMarginValue();\n\t\tresetGapValue();\n\t};\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n\t\t\t{ showPaddingControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasPaddingValue }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ resetPaddingValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ paddingValues }\n\t\t\t\t\t\tonChange={ setPaddingValues }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ paddingSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialPadding }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showMarginControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasMarginValue }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ resetMarginValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ marginValues }\n\t\t\t\t\t\tonChange={ setMarginValues }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ marginSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialMargin }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showGapControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasGapValue }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ resetGapValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ setGapValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tvalue={ gapValue }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/dimensions-panel.js"],"names":["__","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalBoxControl","BoxControl","__experimentalHStack","HStack","__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__experimentalView","View","__experimentalUseCustomSides","useCustomSides","Icon","positionCenter","stretchWide","getSupportedGlobalStylesPanels","useSetting","useStyle","AXIAL_SIDES","useHasDimensionsPanel","name","hasContentSize","useHasContentSize","hasWideSize","useHasWideSize","hasPadding","useHasPadding","hasMargin","useHasMargin","hasGap","useHasGap","supports","settings","includes","filterValuesBySides","values","sides","filteredValues","forEach","side","top","bottom","left","right","splitStyleValue","value","useContentSizeProps","contentSizeValue","setContentSizeValue","userSetContentSizeValue","hasUserSetContentSizeValue","resetContentSizeValue","useWideSizeProps","wideSizeValue","setWideSizeValue","userSetWideSizeValue","hasUserSetWideSizeValue","resetWideSizeValue","usePaddingProps","rawPadding","setRawPadding","paddingValues","paddingSides","isAxialPadding","some","setPaddingValues","newPaddingValues","padding","resetPaddingValue","hasPaddingValue","Object","keys","length","useMarginProps","rawMargin","setRawMargin","marginValues","marginSides","isAxialMargin","setMarginValues","newMarginValues","margin","resetMarginValue","hasMarginValue","useBlockGapProps","gapValue","setGapValue","resetGapValue","undefined","hasGapValue","DimensionsPanel","showContentSizeControl","showWideSizeControl","showPaddingControl","showMarginControl","showGapControl","units","availableUnits","resetAll","nextContentSize","nextWideSize"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,wBAAwB,IAAIC,UAD7B,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,wBAAwB,IAAIC,UAH7B,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,yBAAyB,IAAIC,WAL9B,EAMCC,4BAA4B,IAAIC,cANjC,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A,KAAK,EAAGmB,KALT;AAMC,IAAA,UAAU,EAAG,KANd;AAOC,IAAA,WAAW,EAAGlB;AAPf,IAND,CA3EF,EA4FGiB,cAAc,IACf,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGN,WADZ;AAEC,IAAA,KAAK,EAAG9F,EAAE,CAAE,eAAF,CAFX;AAGC,IAAA,UAAU,EAAG4F,aAHd;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,WAAD;AACC,IAAA,KAAK,EAAG5F,EAAE,CAAE,eAAF,CADX;AAEC,IAAA,oBAAoB,EAAC,MAFtB;AAGC,IAAA,GAAG,EAAG,CAHP;AAIC,IAAA,QAAQ,EAAG2F,WAJZ;AAKC,IAAA,KAAK,EAAGU,KALT;AAMC,IAAA,KAAK,EAAGX;AANT,IAND,CA7FF,CADD;AAgHA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalView as View,\n} from '@wordpress/components';\nimport { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';\nimport { Icon, positionCenter, stretchWide } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nconst AXIAL_SIDES = [ 'horizontal', 'vertical' ];\n\nexport function useHasDimensionsPanel( name ) {\n\tconst hasContentSize = useHasContentSize( name );\n\tconst hasWideSize = useHasWideSize( name );\n\tconst hasPadding = useHasPadding( name );\n\tconst hasMargin = useHasMargin( name );\n\tconst hasGap = useHasGap( name );\n\n\treturn hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap;\n}\n\nfunction useHasContentSize( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'layout.contentSize', name );\n\n\treturn settings && supports.includes( 'contentSize' );\n}\n\nfunction useHasWideSize( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'layout.wideSize', name );\n\n\treturn settings && supports.includes( 'wideSize' );\n}\n\nfunction useHasPadding( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.padding', name );\n\n\treturn settings && supports.includes( 'padding' );\n}\n\nfunction useHasMargin( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.margin', name );\n\n\treturn settings && supports.includes( 'margin' );\n}\n\nfunction useHasGap( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ settings ] = useSetting( 'spacing.blockGap', name );\n\n\treturn settings && supports.includes( 'blockGap' );\n}\n\nfunction filterValuesBySides( values, sides ) {\n\tif ( ! sides ) {\n\t\t// If no custom side configuration all sides are opted into by default.\n\t\treturn values;\n\t}\n\n\t// Only include sides opted into within filtered values.\n\tconst filteredValues = {};\n\tsides.forEach( ( side ) => {\n\t\tif ( side === 'vertical' ) {\n\t\t\tfilteredValues.top = values.top;\n\t\t\tfilteredValues.bottom = values.bottom;\n\t\t}\n\t\tif ( side === 'horizontal' ) {\n\t\t\tfilteredValues.left = values.left;\n\t\t\tfilteredValues.right = values.right;\n\t\t}\n\t\tfilteredValues[ side ] = values[ side ];\n\t} );\n\n\treturn filteredValues;\n}\n\nfunction splitStyleValue( value ) {\n\t// Check for shorthand value ( a string value ).\n\tif ( value && typeof value === 'string' ) {\n\t\t// Convert to value for individual sides for BoxControl.\n\t\treturn {\n\t\t\ttop: value,\n\t\t\tright: value,\n\t\t\tbottom: value,\n\t\t\tleft: value,\n\t\t};\n\t}\n\n\treturn value;\n}\n\n// Props for managing `layout.contentSize`.\nfunction useContentSizeProps( name ) {\n\tconst [ contentSizeValue, setContentSizeValue ] = useSetting(\n\t\t'layout.contentSize',\n\t\tname\n\t);\n\tconst [ userSetContentSizeValue ] = useSetting(\n\t\t'layout.contentSize',\n\t\tname,\n\t\t'user'\n\t);\n\tconst hasUserSetContentSizeValue = () => !! userSetContentSizeValue;\n\tconst resetContentSizeValue = () => setContentSizeValue( '' );\n\treturn {\n\t\tcontentSizeValue,\n\t\tsetContentSizeValue,\n\t\thasUserSetContentSizeValue,\n\t\tresetContentSizeValue,\n\t};\n}\n\n// Props for managing `layout.wideSize`.\nfunction useWideSizeProps( name ) {\n\tconst [ wideSizeValue, setWideSizeValue ] = useSetting(\n\t\t'layout.wideSize',\n\t\tname\n\t);\n\tconst [ userSetWideSizeValue ] = useSetting(\n\t\t'layout.wideSize',\n\t\tname,\n\t\t'user'\n\t);\n\tconst hasUserSetWideSizeValue = () => !! userSetWideSizeValue;\n\tconst resetWideSizeValue = () => setWideSizeValue( '' );\n\treturn {\n\t\twideSizeValue,\n\t\tsetWideSizeValue,\n\t\thasUserSetWideSizeValue,\n\t\tresetWideSizeValue,\n\t};\n}\n\n// Props for managing `spacing.padding`.\nfunction usePaddingProps( name ) {\n\tconst [ rawPadding, setRawPadding ] = useStyle( 'spacing.padding', name );\n\tconst paddingValues = splitStyleValue( rawPadding );\n\tconst paddingSides = useCustomSides( name, 'padding' );\n\tconst isAxialPadding =\n\t\tpaddingSides &&\n\t\tpaddingSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setPaddingValues = ( newPaddingValues ) => {\n\t\tconst padding = filterValuesBySides( newPaddingValues, paddingSides );\n\t\tsetRawPadding( padding );\n\t};\n\tconst resetPaddingValue = () => setPaddingValues( {} );\n\tconst hasPaddingValue = () =>\n\t\t!! paddingValues && Object.keys( paddingValues ).length;\n\n\treturn {\n\t\tpaddingValues,\n\t\tpaddingSides,\n\t\tisAxialPadding,\n\t\tsetPaddingValues,\n\t\tresetPaddingValue,\n\t\thasPaddingValue,\n\t};\n}\n\n// Props for managing `spacing.margin`.\nfunction useMarginProps( name ) {\n\tconst [ rawMargin, setRawMargin ] = useStyle( 'spacing.margin', name );\n\tconst marginValues = splitStyleValue( rawMargin );\n\tconst marginSides = useCustomSides( name, 'margin' );\n\tconst isAxialMargin =\n\t\tmarginSides &&\n\t\tmarginSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setMarginValues = ( newMarginValues ) => {\n\t\tconst margin = filterValuesBySides( newMarginValues, marginSides );\n\t\tsetRawMargin( margin );\n\t};\n\tconst resetMarginValue = () => setMarginValues( {} );\n\tconst hasMarginValue = () =>\n\t\t!! marginValues && Object.keys( marginValues ).length;\n\n\treturn {\n\t\tmarginValues,\n\t\tmarginSides,\n\t\tisAxialMargin,\n\t\tsetMarginValues,\n\t\tresetMarginValue,\n\t\thasMarginValue,\n\t};\n}\n\n// Props for managing `spacing.blockGap`.\nfunction useBlockGapProps( name ) {\n\tconst [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );\n\tconst resetGapValue = () => setGapValue( undefined );\n\tconst hasGapValue = () => !! gapValue;\n\treturn {\n\t\tgapValue,\n\t\tsetGapValue,\n\t\tresetGapValue,\n\t\thasGapValue,\n\t};\n}\n\nexport default function DimensionsPanel( { name } ) {\n\tconst showContentSizeControl = useHasContentSize( name );\n\tconst showWideSizeControl = useHasWideSize( name );\n\tconst showPaddingControl = useHasPadding( name );\n\tconst showMarginControl = useHasMargin( name );\n\tconst showGapControl = useHasGap( name );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units', name )[ 0 ] || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\t// Props for managing `layout.contentSize`.\n\tconst {\n\t\tcontentSizeValue,\n\t\tsetContentSizeValue,\n\t\thasUserSetContentSizeValue,\n\t\tresetContentSizeValue,\n\t} = useContentSizeProps( name );\n\n\t// Props for managing `layout.wideSize`.\n\tconst {\n\t\twideSizeValue,\n\t\tsetWideSizeValue,\n\t\thasUserSetWideSizeValue,\n\t\tresetWideSizeValue,\n\t} = useWideSizeProps( name );\n\n\t// Props for managing `spacing.padding`.\n\tconst {\n\t\tpaddingValues,\n\t\tpaddingSides,\n\t\tisAxialPadding,\n\t\tsetPaddingValues,\n\t\tresetPaddingValue,\n\t\thasPaddingValue,\n\t} = usePaddingProps( name );\n\n\t// Props for managing `spacing.margin`.\n\tconst {\n\t\tmarginValues,\n\t\tmarginSides,\n\t\tisAxialMargin,\n\t\tsetMarginValues,\n\t\tresetMarginValue,\n\t\thasMarginValue,\n\t} = useMarginProps( name );\n\n\t// Props for managing `spacing.blockGap`.\n\tconst { gapValue, setGapValue, resetGapValue, hasGapValue } =\n\t\tuseBlockGapProps( name );\n\n\tconst resetAll = () => {\n\t\tresetPaddingValue();\n\t\tresetMarginValue();\n\t\tresetGapValue();\n\t\tresetContentSizeValue();\n\t\tresetWideSizeValue();\n\t};\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n\t\t\t{ ( showContentSizeControl || showWideSizeControl ) && (\n\t\t\t\t<span className=\"span-columns\">\n\t\t\t\t\t{ __( 'Set the width of the main content area.' ) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t{ showContentSizeControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Content size' ) }\n\t\t\t\t\thasValue={ hasUserSetContentSizeValue }\n\t\t\t\t\tonDeselect={ resetContentSizeValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"flex-end\" justify=\"flex-start\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ contentSizeValue || '' }\n\t\t\t\t\t\t\tonChange={ ( nextContentSize ) => {\n\t\t\t\t\t\t\t\tsetContentSizeValue( nextContentSize );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<View>\n\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</HStack>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showWideSizeControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Wide size' ) }\n\t\t\t\t\thasValue={ hasUserSetWideSizeValue }\n\t\t\t\t\tonDeselect={ resetWideSizeValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"flex-end\" justify=\"flex-start\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ wideSizeValue || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWideSize ) => {\n\t\t\t\t\t\t\t\tsetWideSizeValue( nextWideSize );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<View>\n\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</HStack>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showPaddingControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasPaddingValue }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ resetPaddingValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ paddingValues }\n\t\t\t\t\t\tonChange={ setPaddingValues }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ paddingSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialPadding }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showMarginControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasMarginValue }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ resetMarginValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ marginValues }\n\t\t\t\t\t\tonChange={ setMarginValues }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ marginSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialMargin }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showGapControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasGapValue }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ resetGapValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ setGapValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tvalue={ gapValue }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
@@ -130,7 +130,7 @@ export function useStyle(path, blockName) {
|
|
|
130
130
|
|
|
131
131
|
return [result, setStyle];
|
|
132
132
|
}
|
|
133
|
-
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding'];
|
|
133
|
+
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding', 'contentSize', 'wideSize'];
|
|
134
134
|
export function getSupportedGlobalStylesPanels(name) {
|
|
135
135
|
var _blockType$supports, _blockType$supports$s, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports3$, _blockType$supports3$2, _blockType$supports3$3;
|
|
136
136
|
|