@wordpress/edit-site 4.10.0 → 4.12.1-next.d6164808d3.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 +4 -0
- package/build/components/add-new-template/add-custom-template-modal.js +26 -44
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +45 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +493 -242
- 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/block-editor/resizable-editor.js +26 -12
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +3 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +280 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +4 -4
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +1 -1
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +51 -7
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +157 -0
- package/build/components/global-styles/screen-heading-color.js.map +1 -0
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +82 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +217 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +183 -52
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +85 -5
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/document-actions/index.js +1 -0
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +27 -12
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +13 -3
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +2 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/list/actions/index.js +1 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/save-button/index.js +2 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +11 -1
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +11 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +1 -1
- package/build/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +1 -1
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +19 -9
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +47 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -0
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.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/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +27 -45
- 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 +45 -25
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +489 -230
- 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/block-editor/resizable-editor.js +26 -12
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +278 -22
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +4 -4
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +1 -1
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +143 -0
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +83 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +204 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +182 -61
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +82 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +1 -0
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +30 -14
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +13 -3
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/list/actions/index.js +1 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +9 -1
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +1 -1
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +19 -10
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +35 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
- package/build-module/components/template-part-converter/convert-to-template-part.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-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +40 -33
- package/build-style/style.css +40 -33
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-template-modal.js +39 -48
- package/src/components/add-new-template/new-template.js +50 -58
- package/src/components/add-new-template/style.scss +20 -8
- package/src/components/add-new-template/utils.js +529 -231
- package/src/components/block-editor/index.js +0 -2
- package/src/components/block-editor/resizable-editor.js +28 -18
- package/src/components/editor/style.scss +1 -0
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +344 -45
- package/src/components/global-styles/hooks.js +6 -3
- package/src/components/global-styles/screen-color-palette.js +1 -1
- package/src/components/global-styles/screen-colors.js +46 -4
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/style.scss +14 -6
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +143 -4
- package/src/components/global-styles/test/utils.js +68 -8
- package/src/components/global-styles/typography-panel.js +119 -48
- package/src/components/global-styles/typography-utils.js +228 -0
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +203 -53
- package/src/components/global-styles/utils.js +70 -4
- package/src/components/header/document-actions/index.js +3 -0
- package/src/components/header/index.js +41 -14
- package/src/components/header/mode-switcher/index.js +0 -3
- package/src/components/header/more-menu/index.js +7 -2
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/list/actions/index.js +3 -1
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/default-sidebar.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/plugin-sidebar/index.js +12 -0
- package/src/components/sidebar/style.scss +4 -0
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/edit-template-title.js +7 -3
- package/src/components/template-details/index.js +23 -8
- package/src/components/template-details/style.scss +0 -5
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-details/template-part-area-selector.js +38 -0
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/index.js +1 -1
- 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;AAC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AAf,uDAAG,mBAAwBkC,WAA5C,CAtB0B,CAuB1B;;AACA,QAAKA,WAAL,EAAmB;AAClBe,MAAAA,QAAQ,CAACG,OAAT,GAAqBC,QAAF,IAAgB;AAClCf,QAAAA,eAAe,CAAE;AAChBgB,UAAAA,IAAI,EAAEjB,YAAY,CAACtE,UADH;AAEhBiC,UAAAA,IAFgB;AAGhBuD,UAAAA,MAAM,EAAElB,YAHQ;AAIhBjE,UAAAA,MAJgB;AAKhB4E,UAAAA,kBALgB;AAMhBK,UAAAA,QANgB;AAOhBG,UAAAA,cAAc,EACbzB,YAAY,CAAE/B,IAAF,CAAZ,CAAqBgC;AARN,SAAF,CAAf;AAUA,OAXD;AAYA,KArCyB,CAsC1B;AACA;;;AACA,QAAK,CAAEgB,kBAAF,IAAwBd,WAA7B,EAA2C;AAC1CjB,MAAAA,WAAW,CAACK,IAAZ,CAAkB2B,QAAlB;AACA;;AACD,WAAOhC,WAAP;AACA,GA7CqB,EA8CtB,EA9CsB,CAAvB;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","useCallback","__","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","templatePrefix","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","useAuthorNeedsUniqueIndentifier","authors","getUsers","who","authorsCountByName","authorsCount","USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX","user","USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS","useAuthorMenuItem","authorInfo","authorNeedsUniqueId","authorMenuItem","needsUniqueId","search_items","not_found","all_items","useExistingTemplateSlugs","existingSlugs","Object","entries","prefix","slugsWithTemplates","_accumulator","existingTemplate","_prefix","substring","length","useTemplatesToExclude","entityName","additionalQueryParameters","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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AAF,SAAF;AAAA,eAAcA,EAAd;AAAA,OADD,MAEK,EAHN;AAIAzF,MAAAA,WAAW,CAAEd,IAAF,CAAX,GAAsB;AACrByC,QAAAA,WAAW,EAAE,CAAC,2BAAEpD,MAAM,CAAEhB,SAAF,CAAN,CAAoBiB,gBAApB,CACfyG,UADe,EAEf/F,IAFe,EAGf;AACCT,UAAAA,QAAQ,EAAE,CADX;AAEC0D,UAAAA,OAAO,EAAE,IAFV;AAGCmD,UAAAA,OAAO,EAAE,MAHV;AAICjD,UAAAA,OAAO,EAAEC,mBAJV;AAKC,aAAG4C,yBAAyB,CAAEhG,IAAF;AAL7B,SAHe,CAAF,kDAAE,sBAUb6F,MAVW,CADO;AAYrBzC,QAAAA;AAZqB,OAAtB;AAcA,aAAOtC,WAAP;AACA,KArBK,EAsBN,EAtBM,CAAP;AAwBA,GA1B4B,EA2B7B,CAAEF,gBAAF,EAAoBsF,yBAApB,CA3B6B,CAA9B;AA6BA,SAAOG,YAAP;AACA,CAxCD","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, useCallback } 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? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\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\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tslug\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\ttemplatePrefix: templatePrefixes[ 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? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\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\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tslug\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\ttemplatePrefix: templatePrefixes[ 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\nfunction useAuthorNeedsUniqueIndentifier() {\n\tconst authors = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getUsers( { who: 'authors', per_page: -1 } ),\n\t\t[]\n\t);\n\tconst authorsCountByName = useMemo( () => {\n\t\treturn ( authors || [] ).reduce( ( authorsCount, { name } ) => {\n\t\t\tauthorsCount[ name ] = ( authorsCount[ name ] || 0 ) + 1;\n\t\t\treturn authorsCount;\n\t\t}, {} );\n\t}, [ authors ] );\n\treturn useCallback(\n\t\t( name ) => {\n\t\t\treturn authorsCountByName[ name ] > 1;\n\t\t},\n\t\t[ authorsCountByName ]\n\t);\n}\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tconst authorNeedsUniqueId = useAuthorNeedsUniqueIndentifier();\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst needsUniqueId = authorNeedsUniqueId(\n\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst title = needsUniqueId\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %1$s: Represents the name of an author e.g: \"Jorge\", %2$s: Represents the slug of an author e.g: \"author-jorge-slug\".\n\t\t\t\t\t\t\t\t\t__( 'Author: %1$s (%2$s)' ),\n\t\t\t\t\t\t\t\t\tsuggestion.name,\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: Represents the name of an author e.g: \"Jorge\".\n\t\t\t\t\t\t\t\t\t__( 'Author: %s' ),\n\t\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t );\n\t\t\t\t\t\tconst description = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Represents the name of an author e.g: \"Jorge\".\n\t\t\t\t\t\t\t__( 'Template for Author: %s' ),\n\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tslug: `author-${ suggestion.slug }`,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\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 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters 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 = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\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\t...additionalQueryParameters[ slug ],\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 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\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\t...additionalQueryParameters[ slug ],\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+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,gB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tCD,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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AC,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"]}
|
|
@@ -53,15 +53,27 @@ function ResizableEditor(_ref) {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
let
|
|
56
|
+
let timeoutId = null;
|
|
57
57
|
|
|
58
58
|
function resizeHeight() {
|
|
59
|
-
if (!
|
|
60
|
-
// Throttle the updates on
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
if (!timeoutId) {
|
|
60
|
+
// Throttle the updates on timeout. This code previously
|
|
61
|
+
// used `requestAnimationFrame`, but that seems to not
|
|
62
|
+
// always work before an iframe is ready.
|
|
63
|
+
timeoutId = iframe.contentWindow.setTimeout(() => {
|
|
64
|
+
const {
|
|
65
|
+
readyState
|
|
66
|
+
} = iframe.contentDocument; // Continue deferring the timeout until the document is ready.
|
|
67
|
+
// Only then will it have a height.
|
|
68
|
+
|
|
69
|
+
if (readyState !== 'interactive' && readyState !== 'complete') {
|
|
70
|
+
resizeHeight();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setHeight(iframe.contentDocument.body.scrollHeight);
|
|
75
|
+
timeoutId = null; // 30 frames per second.
|
|
76
|
+
}, 1000 / 30);
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
|
|
@@ -71,10 +83,10 @@ function ResizableEditor(_ref) {
|
|
|
71
83
|
var _resizeObserver;
|
|
72
84
|
|
|
73
85
|
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
|
|
74
|
-
resizeObserver = new iframe.contentWindow.ResizeObserver(resizeHeight); //
|
|
75
|
-
//
|
|
86
|
+
resizeObserver = new iframe.contentWindow.ResizeObserver(resizeHeight); // Observe the body, since the `html` element seems to always
|
|
87
|
+
// have a height of `100%`.
|
|
76
88
|
|
|
77
|
-
resizeObserver.observe(iframe.contentDocument.
|
|
89
|
+
resizeObserver.observe(iframe.contentDocument.body);
|
|
78
90
|
resizeHeight();
|
|
79
91
|
} // This is only required in Firefox for some unknown reasons.
|
|
80
92
|
|
|
@@ -85,7 +97,7 @@ function ResizableEditor(_ref) {
|
|
|
85
97
|
return () => {
|
|
86
98
|
var _iframe$contentWindow, _resizeObserver2;
|
|
87
99
|
|
|
88
|
-
(_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : _iframe$contentWindow.
|
|
100
|
+
(_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : _iframe$contentWindow.clearTimeout(timeoutId);
|
|
89
101
|
(_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : _resizeObserver2.disconnect();
|
|
90
102
|
iframe.removeEventListener('load', registerObserver);
|
|
91
103
|
};
|
|
@@ -131,7 +143,9 @@ function ResizableEditor(_ref) {
|
|
|
131
143
|
right: HANDLE_STYLES_OVERRIDE
|
|
132
144
|
}
|
|
133
145
|
}, createElement(Iframe, _extends({
|
|
134
|
-
style: enableResizing ?
|
|
146
|
+
style: enableResizing ? {
|
|
147
|
+
height
|
|
148
|
+
} : deviceStyles,
|
|
135
149
|
head: createElement(Fragment, null, createElement(EditorStyles, {
|
|
136
150
|
styles: settings.styles
|
|
137
151
|
}), createElement("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["useState","useEffect","useRef","useCallback","ResizableBox","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","useSelect","useMergeRefs","store","editSiteStore","ResizeHandle","DEFAULT_STYLES","width","height","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","top","right","bottom","left","ResizableEditor","enableResizing","settings","children","props","deviceType","select","__experimentalGetPreviewDeviceType","deviceStyles","setWidth","setHeight","iframeRef","mouseMoveTypingResetRef","ref","autoResizeIframeHeight","iframe","current","animationFrame","resizeHeight","contentWindow","requestAnimationFrame","contentDocument","documentElement","scrollHeight","resizeObserver","registerObserver","disconnect","ResizeObserver","observe","addEventListener","cancelAnimationFrame","removeEventListener","resizeWidthBy","deltaPixels","offsetWidth","event","direction","element","style","styles","__unstableResolvedAssets","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,QAKO,yBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAI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HAHH,EAME;AACA;AACC,sDARH,CARF,CAHF;AAyBC,IAAA,MAAM,EAAGC,QAAQ,CAACsC,wBAzBnB;AA0BC,IAAA,GAAG,EAAG3B,GA1BP;AA2BC,IAAA,IAAI,EAAC,eA3BN;AA4BC,IAAA,SAAS,EAAC;AA5BX,KA6BMT,KA7BN,GAgCGF,QAAQ,CAACuC,UAhCZ,EAiCGtC,QAjCH,CAxCD,CADD;AA8EA;;AAED,eAAeH,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\nconst DEFAULT_STYLES = {\n\twidth: '100%',\n\theight: '100%',\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, children, ...props } ) {\n\tconst deviceType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( DEFAULT_STYLES.width );\n\tconst [ height, setHeight ] = useState( DEFAULT_STYLES.height );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tuseEffect(\n\t\tfunction autoResizeIframeHeight() {\n\t\t\tconst iframe = iframeRef.current;\n\n\t\t\tif ( ! iframe || ! enableResizing ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet animationFrame = null;\n\n\t\t\tfunction resizeHeight() {\n\t\t\t\tif ( ! animationFrame ) {\n\t\t\t\t\t// Throttle the updates on animation frame.\n\t\t\t\t\tanimationFrame = iframe.contentWindow.requestAnimationFrame(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tsetHeight(\n\t\t\t\t\t\t\t\tiframe.contentDocument.documentElement\n\t\t\t\t\t\t\t\t\t.scrollHeight\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tanimationFrame = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet resizeObserver;\n\n\t\t\tfunction registerObserver() {\n\t\t\t\tresizeObserver?.disconnect();\n\n\t\t\t\tresizeObserver = new iframe.contentWindow.ResizeObserver(\n\t\t\t\t\tresizeHeight\n\t\t\t\t);\n\t\t\t\t// Observing the <html> rather than the <body> because the latter\n\t\t\t\t// gets destroyed and remounted after initialization in <Iframe>.\n\t\t\t\tresizeObserver.observe(\n\t\t\t\t\tiframe.contentDocument.documentElement\n\t\t\t\t);\n\n\t\t\t\tresizeHeight();\n\t\t\t}\n\n\t\t\t// This is only required in Firefox for some unknown reasons.\n\t\t\tiframe.addEventListener( 'load', registerObserver );\n\t\t\t// This is required in Chrome and Safari.\n\t\t\tregisterObserver();\n\n\t\t\treturn () => {\n\t\t\t\tiframe.contentWindow?.cancelAnimationFrame( animationFrame );\n\t\t\t\tresizeObserver?.disconnect();\n\t\t\t\tiframe.removeEventListener( 'load', registerObserver );\n\t\t\t};\n\t\t},\n\t\t[ enableResizing ]\n\t);\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tstyle={ enableResizing ? undefined : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Force the <html> and <body>'s heights to fit the content.\n\t\t\t\t\t\t\t\t\t`html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`\n\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\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t\t{ settings.svgFilters }\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["useState","useEffect","useRef","useCallback","ResizableBox","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","useSelect","useMergeRefs","store","editSiteStore","ResizeHandle","DEFAULT_STYLES","width","height","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","top","right","bottom","left","ResizableEditor","enableResizing","settings","children","props","deviceType","select","__experimentalGetPreviewDeviceType","deviceStyles","setWidth","setHeight","iframeRef","mouseMoveTypingResetRef","ref","autoResizeIframeHeight","iframe","current","timeoutId","resizeHeight","contentWindow","setTimeout","readyState","contentDocument","body","scrollHeight","resizeObserver","registerObserver","disconnect","ResizeObserver","observe","addEventListener","clearTimeout","removeEventListener","resizeWidthBy","deltaPixels","offsetWidth","event","direction","element","style","styles","__unstableResolvedAssets","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,QAKO,yBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,KAAK,EAAE,MADe;AAEtBC,EAAAA,MAAM,EAAE;AAFc,CAAvB,C,CAKA;;AACA,MAAMC,sBAAsB,GAAG;AAC9BC,EAAAA,QAAQ,EAAEC,SADoB;AAE9BC,EAAAA,UAAU,EAAED,SAFkB;AAG9BE,EAAAA,MAAM,EAAEF,SAHsB;AAI9BJ,EAAAA,KAAK,EAAEI,SAJuB;AAK9BH,EAAAA,MAAM,EAAEG,SALsB;AAM9BG,EAAAA,GAAG,EAAEH,SANyB;AAO9BI,EAAAA,KAAK,EAAEJ,SAPuB;AAQ9BK,EAAAA,MAAM,EAAEL,SARsB;AAS9BM,EAAAA,IAAI,EAAEN;AATwB,CAA/B;;AAYA,SAASO,eAAT,OAA6E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AAC5E,QAAMC,UAAU,GA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M,EAAG;AACRQ,MAAAA,KAAK,EAAEI,cADC;AAERF,MAAAA,IAAI,EAAEE;AAFE,KAXV;AAeC,IAAA,UAAU,EAAGA,cAfd,CAgBC;AACA;AACA;AAlBD;AAmBC,IAAA,WAAW,EAAG,CAnBf;AAoBC,IAAA,eAAe,EAAG;AACjBF,MAAAA,IAAI,EACH,cAAC,YAAD;AACC,QAAA,SAAS,EAAC,MADX;AAEC,QAAA,aAAa,EAAGkC;AAFjB,QAFgB;AAOjBpC,MAAAA,KAAK,EACJ,cAAC,YAAD;AACC,QAAA,SAAS,EAAC,OADX;AAEC,QAAA,aAAa,EAAGoC;AAFjB;AARgB,KApBnB;AAkCC,IAAA,aAAa,EAAGxC,SAlCjB;AAmCC,IAAA,YAAY,EAAG;AACdM,MAAAA,IAAI,EAAER,sBADQ;AAEdM,MAAAA,KAAK,EAAEN;AAFO;AAnChB,KAwCC,cAAC,MAAD;AACC,IAAA,KAAK,EAAGU,cAAc,GAAG;AAAEX,MAAAA;AAAF,KAAH,GAAgBkB,YADvC;AAEC,IAAA,IAAI,EACH,8BACC,cAAC,YAAD;AAAc,MAAA,MAAM,EAAGN,QAAQ,CAACsC;AAAhC,MADD,EAEC,6BACC;AACA;AACC,gDAHF,CAFD,EAOGvC,cAAc,IACf,6BAEE;AACC,mHAHH,EAME;AACA;AACC,sDARH,CARF,CAHF;AAyBC,IAAA,MAAM,EAAGC,QAAQ,CAACuC,wBAzBnB;AA0BC,IAAA,GAAG,EAAG5B,GA1BP;AA2BC,IAAA,IAAI,EAAC,eA3BN;AA4BC,IAAA,SAAS,EAAC;AA5BX,KA6BMT,KA7BN,GAgCGF,QAAQ,CAACwC,UAhCZ,EAiCGvC,QAjCH,CAxCD,CADD;AA8EA;;AAED,eAAeH,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\nconst DEFAULT_STYLES = {\n\twidth: '100%',\n\theight: '100%',\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, children, ...props } ) {\n\tconst deviceType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( DEFAULT_STYLES.width );\n\tconst [ height, setHeight ] = useState( DEFAULT_STYLES.height );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tuseEffect(\n\t\tfunction autoResizeIframeHeight() {\n\t\t\tconst iframe = iframeRef.current;\n\n\t\t\tif ( ! iframe || ! enableResizing ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet timeoutId = null;\n\n\t\t\tfunction resizeHeight() {\n\t\t\t\tif ( ! timeoutId ) {\n\t\t\t\t\t// Throttle the updates on timeout. This code previously\n\t\t\t\t\t// used `requestAnimationFrame`, but that seems to not\n\t\t\t\t\t// always work before an iframe is ready.\n\t\t\t\t\ttimeoutId = iframe.contentWindow.setTimeout( () => {\n\t\t\t\t\t\tconst { readyState } = iframe.contentDocument;\n\n\t\t\t\t\t\t// Continue deferring the timeout until the document is ready.\n\t\t\t\t\t\t// Only then will it have a height.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\treadyState !== 'interactive' &&\n\t\t\t\t\t\t\treadyState !== 'complete'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tresizeHeight();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsetHeight( iframe.contentDocument.body.scrollHeight );\n\t\t\t\t\t\ttimeoutId = null;\n\n\t\t\t\t\t\t// 30 frames per second.\n\t\t\t\t\t}, 1000 / 30 );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet resizeObserver;\n\n\t\t\tfunction registerObserver() {\n\t\t\t\tresizeObserver?.disconnect();\n\n\t\t\t\tresizeObserver = new iframe.contentWindow.ResizeObserver(\n\t\t\t\t\tresizeHeight\n\t\t\t\t);\n\n\t\t\t\t// Observe the body, since the `html` element seems to always\n\t\t\t\t// have a height of `100%`.\n\t\t\t\tresizeObserver.observe( iframe.contentDocument.body );\n\n\t\t\t\tresizeHeight();\n\t\t\t}\n\n\t\t\t// This is only required in Firefox for some unknown reasons.\n\t\t\tiframe.addEventListener( 'load', registerObserver );\n\t\t\t// This is required in Chrome and Safari.\n\t\t\tregisterObserver();\n\n\t\t\treturn () => {\n\t\t\t\tiframe.contentWindow?.clearTimeout( timeoutId );\n\t\t\t\tresizeObserver?.disconnect();\n\t\t\t\tiframe.removeEventListener( 'load', registerObserver );\n\t\t\t};\n\t\t},\n\t\t[ enableResizing ]\n\t);\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tstyle={ enableResizing ? { height } : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Force the <html> and <body>'s heights to fit the content.\n\t\t\t\t\t\t\t\t\t`html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`\n\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\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t\t{ settings.svgFilters }\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
|
|
@@ -150,11 +150,11 @@ export default function BorderPanel(_ref) {
|
|
|
150
150
|
}, createElement(BorderBoxControl, {
|
|
151
151
|
colors: colors,
|
|
152
152
|
enableAlpha: true,
|
|
153
|
+
enableStyle: showBorderStyle,
|
|
153
154
|
onChange: onBorderChange,
|
|
154
|
-
showStyle: showBorderStyle,
|
|
155
|
-
value: border,
|
|
156
|
-
popoverPlacement: "left-start",
|
|
157
155
|
popoverOffset: 40,
|
|
156
|
+
popoverPlacement: "left-start",
|
|
157
|
+
value: border,
|
|
158
158
|
__experimentalHasMultipleOrigins: true,
|
|
159
159
|
__experimentalIsRenderedInSidebar: true
|
|
160
160
|
})), showBorderRadius && createElement(ToolsPanelItem, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","__","getSupportedGlobalStylesPanels","useColorsPerOrigin","useSetting","useStyle","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iCAAiC,IAAIC,mBAA9C,QAAyE,yBAAzE;AACA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,8BADD,EAECC,kBAFD,EAGCC,UAHD,EAICC,QAJD,QAKO,SALP;AAOA,OAAO,SAASC,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMC,QAAQ,GAAG,CAChBC,wBAAwB,CAAEF,IAAF,CADR,EAEhBG,yBAAyB,CAAEH,IAAF,CAFT,EAGhBI,wBAAwB,CAAEJ,IAAF,CAHR,EAIhBK,wBAAwB,CAAEL,IAAF,CAJR,CAAjB;AAOA,SAAOC,QAAQ,CAACK,IAAT,CAAeC,OAAf,CAAP;AACA;;AAED,SAASL,wBAAT,CAAmCF,IAAnC,EAA0C;AACzC,QAAMQ,QAAQ,GAAGb,8BAA8B,CAAEK,IAAF,CAA/C;AACA,SACCH,UAAU,CAAE,cAAF,E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cAAC,cAAD;AACC,IAAA,QAAQ,EAAG,MAAMpC,eAAe,CAAEiC,gBAAF,CADjC;AAEC,IAAA,KAAK,EAAG3B,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAG,MAAMyC,WAAW,EAH/B;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGZ,MADV;AAEC,IAAA,WAAW,EAAG,IAFf;AAGC,IAAA,QAAQ,EAAGe,cAHZ;AAIC,IAAA,SAAS,EAAGb,eAJb;AAKC,IAAA,KAAK,EAAGd,MALT;AAMC,IAAA,gBAAgB,EAAC,YANlB;AAOC,IAAA,aAAa,EAAG,EAPjB;AAQC,IAAA,gCAAgC,EAAG,IARpC;AASC,IAAA,iCAAiC,EAAG;AATrC,IAND,CAFF,EAqBGgB,gBAAgB,IACjB,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGG,eADZ;AAEC,IAAA,KAAK,EAAGpC,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAG,MAAMmC,eAAe,CAAEO,SAAF,CAHnC;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKc,KAAF,IAAa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalBorderRadiusControl as BorderRadiusControl } from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseColorsPerOrigin,\n\tuseSetting,\n\tuseStyle,\n} from './hooks';\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name } ) {\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useStyle( 'border', name, 'user' );\n\tconst [ border, setBorder ] = useStyle( 'border', name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useStyle(\n\t\t'border.radius',\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tshowStyle={ showBorderStyle }\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\t__experimentalHasMultipleOrigins={ true }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\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/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","__","getSupportedGlobalStylesPanels","useColorsPerOrigin","useSetting","useStyle","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iCAAiC,IAAIC,mBAA9C,QAAyE,yBAAzE;AACA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,8BADD,EAECC,kBAFD,EAGCC,UAHD,EAICC,QAJD,Q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Aa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalBorderRadiusControl as BorderRadiusControl } from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseColorsPerOrigin,\n\tuseSetting,\n\tuseStyle,\n} from './hooks';\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name } ) {\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useStyle( 'border', name, 'user' );\n\tconst [ border, setBorder ] = useStyle( 'border', name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useStyle(\n\t\t'border.radius',\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalHasMultipleOrigins={ true }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|