@wordpress/edit-site 5.33.0 → 5.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-page/index.js +3 -0
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +8 -7
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +20 -5
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +3 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +28 -5
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +9 -3
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +7 -2
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +22 -20
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +8 -2
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/header-edit-mode/index.js +33 -49
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +3 -97
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +0 -49
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/index.js +7 -4
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +9 -38
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +4 -3
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/dataviews-pattern-actions.js +11 -7
- package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build/components/page-patterns/header.js +3 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +20 -49
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -0
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/hooks.js.map +1 -0
- package/build/components/{page-templates-template-parts → page-templates}/index.js +67 -80
- package/build/components/page-templates/index.js.map +1 -0
- package/build/components/pattern-modal/duplicate.js +7 -5
- package/build/components/pattern-modal/duplicate.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +9 -0
- package/build/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +9 -6
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +3 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +40 -9
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +24 -17
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +2 -5
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +39 -8
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +6 -13
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +3 -2
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +34 -28
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +5 -35
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -8
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-actions/index.js +1 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/deprecated.js +55 -0
- package/build/deprecated.js.map +1 -0
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +35 -4
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +18 -18
- package/build/index.js.map +1 -1
- package/build/utils/constants.js +1 -2
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/add-new-page/index.js +3 -0
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +8 -7
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/block-editor/resize-handle.js +21 -6
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +3 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +28 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +9 -3
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +7 -2
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +22 -20
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +8 -2
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +39 -55
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +5 -99
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +0 -49
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/index.js +7 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +9 -38
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +5 -4
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/dataviews-pattern-actions.js +11 -7
- package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build-module/components/page-patterns/header.js +3 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +22 -51
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +1 -0
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/hooks.js.map +1 -0
- package/build-module/components/{page-templates-template-parts → page-templates}/index.js +67 -80
- package/build-module/components/page-templates/index.js.map +1 -0
- package/build-module/components/pattern-modal/duplicate.js +7 -5
- package/build-module/components/pattern-modal/duplicate.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +8 -0
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +9 -6
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +4 -3
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +43 -12
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +25 -17
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +3 -6
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +40 -9
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +6 -13
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +35 -29
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +5 -35
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -8
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +1 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/deprecated.js +45 -0
- package/build-module/deprecated.js.map +1 -0
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +34 -4
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +2 -4
- package/build-module/index.js.map +1 -1
- package/build-module/utils/constants.js +0 -1
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +79 -125
- package/build-style/style.css +79 -125
- package/package.json +42 -42
- package/src/components/add-new-page/index.js +7 -1
- package/src/components/add-new-pattern/index.js +15 -12
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/src/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/src/components/block-editor/resize-handle.js +30 -11
- package/src/components/block-editor/style.scss +10 -15
- package/src/components/create-template-part-modal/index.js +3 -0
- package/src/components/editor/index.js +42 -3
- package/src/components/editor/style.scss +6 -1
- package/src/components/global-styles/font-library-modal/context.js +9 -3
- package/src/components/global-styles/font-library-modal/font-collection.js +31 -12
- package/src/components/global-styles/font-library-modal/installed-fonts.js +82 -54
- package/src/components/global-styles/font-library-modal/style.scss +17 -0
- package/src/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/src/components/global-styles/style-variations-container.js +11 -2
- package/src/components/header-edit-mode/index.js +56 -76
- package/src/components/header-edit-mode/more-menu/index.js +8 -145
- package/src/components/header-edit-mode/style.scss +13 -85
- package/src/components/keyboard-shortcuts/register.js +0 -58
- package/src/components/layout/index.js +11 -2
- package/src/components/layout/router.js +9 -49
- package/src/components/page-pages/index.js +14 -4
- package/src/components/page-pages/style.scss +11 -0
- package/src/components/page-patterns/dataviews-pattern-actions.js +8 -9
- package/src/components/page-patterns/header.js +3 -1
- package/src/components/page-patterns/index.js +17 -76
- package/src/components/page-patterns/style.scss +14 -1
- package/src/components/page-patterns/use-patterns.js +1 -0
- package/src/components/{page-templates-template-parts → page-templates}/index.js +23 -46
- package/src/components/{page-templates-template-parts → page-templates}/style.scss +2 -2
- package/src/components/pattern-modal/duplicate.js +4 -3
- package/src/components/plugin-template-setting-panel/index.js +8 -0
- package/src/components/resizable-frame/index.js +4 -3
- package/src/components/sidebar-edit-mode/index.js +13 -2
- package/src/components/sidebar-edit-mode/page-panels/index.js +49 -21
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +31 -19
- package/src/components/sidebar-edit-mode/template-panel/index.js +2 -12
- package/src/components/sidebar-navigation-screen-page/index.js +48 -9
- package/src/components/sidebar-navigation-screen-pattern/index.js +6 -11
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +2 -1
- package/src/components/sidebar-navigation-screen-patterns/index.js +30 -38
- package/src/components/sidebar-navigation-screen-template/index.js +1 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +7 -39
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -4
- package/src/components/template-actions/index.js +1 -1
- package/src/deprecated.js +42 -0
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +69 -16
- package/src/index.js +2 -9
- package/src/style.scss +1 -5
- package/src/utils/constants.js +1 -1
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -59
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +0 -1
- package/build/components/header-edit-mode/tools-more-menu-group/index.js +0 -23
- package/build/components/header-edit-mode/tools-more-menu-group/index.js.map +0 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +0 -56
- package/build/components/keyboard-shortcuts/edit-mode.js.map +0 -1
- package/build/components/page-templates-template-parts/add-new-template-part.js +0 -65
- package/build/components/page-templates-template-parts/add-new-template-part.js.map +0 -1
- package/build/components/page-templates-template-parts/hooks.js.map +0 -1
- package/build/components/page-templates-template-parts/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +0 -188
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +0 -1
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -52
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +0 -1
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js +0 -16
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +0 -49
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +0 -1
- package/build-module/components/page-templates-template-parts/add-new-template-part.js +0 -57
- package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +0 -1
- package/build-module/components/page-templates-template-parts/hooks.js.map +0 -1
- package/build-module/components/page-templates-template-parts/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +0 -180
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +0 -1
- package/src/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -51
- package/src/components/header-edit-mode/tools-more-menu-group/index.js +0 -16
- package/src/components/keyboard-shortcuts/edit-mode.js +0 -59
- package/src/components/page-templates-template-parts/add-new-template-part.js +0 -62
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +0 -249
- package/src/components/sidebar-edit-mode/page-panels/style.scss +0 -34
- /package/build/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
- /package/build-module/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
- /package/src/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
|
@@ -109,7 +109,7 @@ function ResetMenuItem({
|
|
|
109
109
|
},
|
|
110
110
|
onCancel: () => setIsModalOpen(false),
|
|
111
111
|
confirmButtonText: (0, _i18n.__)('Reset')
|
|
112
|
-
}, (0, _i18n.__)('
|
|
112
|
+
}, (0, _i18n.__)('Reset to default and clear all customizations?')));
|
|
113
113
|
}
|
|
114
114
|
function DeleteMenuItem({
|
|
115
115
|
onRemove,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_icons","_notices","_htmlEntities","_store","_isTemplateRemovable","_interopRequireDefault","_isTemplateRevertable","_renamePostMenuItem","_constants","TemplateActions","postType","postId","className","toggleProps","onRemove","template","useSelect","select","coreStore","getEntityRecord","removeTemplate","useDispatch","editSiteStore","isRemovable","isTemplateRemovable","isRevertable","isTemplateRevertable","_react","createElement","DropdownMenu","icon","moreVertical","label","__","onClose","MenuGroup","Fragment","default","post","DeleteMenuItem","title","rendered","ResetMenuItem","isModalOpen","setIsModalOpen","useState","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","revertAndSaveTemplate","allowUndo","type","id","sprintf","decodeEntities","error","fallbackErrorMessage","TEMPLATE_POST_TYPE","errorMessage","message","code","MenuItem","onClick","__experimentalConfirmDialog","isOpen","onConfirm","onCancel","confirmButtonText","isDestructive"],"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenamePostMenuItem from '../rename-post-menu-item';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate } = useDispatch( editSiteStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenamePostMenuItem\n\t\t\t\t\t\t\t\tpost={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttitle={ template.title.rendered }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isRevertable && (\n\t\t\t\t\t\t<ResetMenuItem\n\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction ResetMenuItem( { template, onClose } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\tdecodeEntities( template.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst fallbackErrorMessage =\n\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t? __( 'An error occurred while reverting the template.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t );\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setIsModalOpen( true ) }>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Reset' ) }\n\t\t\t>\n\t\t\t\t{ __( '
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_icons","_notices","_htmlEntities","_store","_isTemplateRemovable","_interopRequireDefault","_isTemplateRevertable","_renamePostMenuItem","_constants","TemplateActions","postType","postId","className","toggleProps","onRemove","template","useSelect","select","coreStore","getEntityRecord","removeTemplate","useDispatch","editSiteStore","isRemovable","isTemplateRemovable","isRevertable","isTemplateRevertable","_react","createElement","DropdownMenu","icon","moreVertical","label","__","onClose","MenuGroup","Fragment","default","post","DeleteMenuItem","title","rendered","ResetMenuItem","isModalOpen","setIsModalOpen","useState","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","revertAndSaveTemplate","allowUndo","type","id","sprintf","decodeEntities","error","fallbackErrorMessage","TEMPLATE_POST_TYPE","errorMessage","message","code","MenuItem","onClick","__experimentalConfirmDialog","isOpen","onConfirm","onCancel","confirmButtonText","isDestructive"],"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenamePostMenuItem from '../rename-post-menu-item';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate } = useDispatch( editSiteStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenamePostMenuItem\n\t\t\t\t\t\t\t\tpost={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttitle={ template.title.rendered }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isRevertable && (\n\t\t\t\t\t\t<ResetMenuItem\n\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction ResetMenuItem( { template, onClose } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\tdecodeEntities( template.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst fallbackErrorMessage =\n\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t? __( 'An error occurred while reverting the template.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t );\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setIsModalOpen( true ) }>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Reset' ) }\n\t\t\t>\n\t\t\t\t{ __( 'Reset to default and clear all customizations?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, title } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem isDestructive onClick={ () => setIsModalOpen( true ) }>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: The template or template part's title.\n\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,oBAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,mBAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AAxBA;AACA;AACA;;AAeA;AACA;AACA;;AAOe,SAASc,eAAeA,CAAE;EACxCC,QAAQ;EACRC,MAAM;EACNC,SAAS;EACTC,WAAW;EACXC;AACD,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAG,I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,IAAApC,QAAE,EAAE,QAAS;EAAG,GAElC,IAAAsB,aAAO;EACR;EACA,IAAAtB,QAAE,EAAE,uCAAwC,CAAC,EAC7C,IAAAuB,4BAAc,EAAEhB,KAAM,CACvB,CACc,CACd,CAAC;AAEL","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.PluginMoreMenuItem = PluginMoreMenuItem;
|
|
8
|
+
exports.PluginSidebar = PluginSidebar;
|
|
9
|
+
exports.PluginSidebarMoreMenuItem = PluginSidebarMoreMenuItem;
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _editor = require("@wordpress/editor");
|
|
12
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const deprecateSlot = name => {
|
|
18
|
+
(0, _deprecated.default)(`wp.editPost.${name}`, {
|
|
19
|
+
since: '6.6',
|
|
20
|
+
alternative: `wp.editor.${name}`
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/* eslint-disable jsdoc/require-param */
|
|
25
|
+
/**
|
|
26
|
+
* @see PluginMoreMenuItem in @wordpress/editor package.
|
|
27
|
+
*/
|
|
28
|
+
function PluginMoreMenuItem(props) {
|
|
29
|
+
deprecateSlot('PluginMoreMenuItem');
|
|
30
|
+
return (0, _react.createElement)(_editor.PluginMoreMenuItem, {
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @see PluginSidebar in @wordpress/editor package.
|
|
37
|
+
*/
|
|
38
|
+
function PluginSidebar(props) {
|
|
39
|
+
deprecateSlot('PluginSidebar');
|
|
40
|
+
return (0, _react.createElement)(_editor.PluginSidebar, {
|
|
41
|
+
...props
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @see PluginSidebarMoreMenuItem in @wordpress/editor package.
|
|
47
|
+
*/
|
|
48
|
+
function PluginSidebarMoreMenuItem(props) {
|
|
49
|
+
deprecateSlot('PluginSidebarMoreMenuItem');
|
|
50
|
+
return (0, _react.createElement)(_editor.PluginSidebarMoreMenuItem, {
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/* eslint-enable jsdoc/require-param */
|
|
55
|
+
//# sourceMappingURL=deprecated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_editor","require","_deprecated","_interopRequireDefault","deprecateSlot","name","deprecated","since","alternative","PluginMoreMenuItem","props","_react","createElement","PluginSidebar","PluginSidebarMoreMenuItem"],"sources":["@wordpress/edit-site/src/deprecated.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPluginMoreMenuItem as EditorPluginMoreMenuItem,\n\tPluginSidebar as EditorPluginSidebar,\n\tPluginSidebarMoreMenuItem as EditorPluginSidebarMoreMenuItem,\n} from '@wordpress/editor';\nimport deprecated from '@wordpress/deprecated';\n\nconst deprecateSlot = ( name ) => {\n\tdeprecated( `wp.editPost.${ name }`, {\n\t\tsince: '6.6',\n\t\talternative: `wp.editor.${ name }`,\n\t} );\n};\n\n/* eslint-disable jsdoc/require-param */\n/**\n * @see PluginMoreMenuItem in @wordpress/editor package.\n */\nexport function PluginMoreMenuItem( props ) {\n\tdeprecateSlot( 'PluginMoreMenuItem' );\n\treturn <EditorPluginMoreMenuItem { ...props } />;\n}\n\n/**\n * @see PluginSidebar in @wordpress/editor package.\n */\nexport function PluginSidebar( props ) {\n\tdeprecateSlot( 'PluginSidebar' );\n\treturn <EditorPluginSidebar { ...props } />;\n}\n\n/**\n * @see PluginSidebarMoreMenuItem in @wordpress/editor package.\n */\nexport function PluginSidebarMoreMenuItem( props ) {\n\tdeprecateSlot( 'PluginSidebarMoreMenuItem' );\n\treturn <EditorPluginSidebarMoreMenuItem { ...props } />;\n}\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAQA,MAAMG,aAAa,GAAKC,IAAI,IAAM;EACjC,IAAAC,mBAAU,EAAG,eAAeD,IAAM,EAAC,EAAE;IACpCE,KAAK,EAAE,KAAK;IACZC,WAAW,EAAG,aAAaH,IAAM;EAClC,CAAE,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAEC,KAAK,EAAG;EAC3CN,aAAa,CAAE,oBAAqB,CAAC;EACrC,OAAO,IAAAO,MAAA,CAAAC,aAAA,EAACZ,OAAA,CAAAS,kBAAwB;IAAA,GAAMC;EAAK,CAAI,CAAC;AACjD;;AAEA;AACA;AACA;AACO,SAASG,aAAaA,CAAEH,KAAK,EAAG;EACtCN,aAAa,CAAE,eAAgB,CAAC;EAChC,OAAO,IAAAO,MAAA,CAAAC,aAAA,EAACZ,OAAA,CAAAa,aAAmB;IAAA,GAAMH;EAAK,CAAI,CAAC;AAC5C;;AAEA;AACA;AACA;AACO,SAASI,yBAAyBA,CAAEJ,KAAK,EAAG;EAClDN,aAAa,CAAE,2BAA4B,CAAC;EAC5C,OAAO,IAAAO,MAAA,CAAAC,aAAA,EAACZ,OAAA,CAAAc,yBAA+B;IAAA,GAAMJ;EAAK,CAAI,CAAC;AACxD;AACA","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = useThemeStyleVariationsByProperty;
|
|
8
8
|
exports.filterObjectByProperty = void 0;
|
|
9
|
+
exports.isVariationWithSingleProperty = isVariationWithSingleProperty;
|
|
9
10
|
exports.removePropertyFromObject = removePropertyFromObject;
|
|
10
11
|
exports.useCurrentMergeThemeStyleVariationsWithUserConfig = useCurrentMergeThemeStyleVariationsWithUserConfig;
|
|
11
12
|
var _data = require("@wordpress/data");
|
|
@@ -145,9 +146,14 @@ function useThemeStyleVariationsByProperty({
|
|
|
145
146
|
return variations;
|
|
146
147
|
}
|
|
147
148
|
const clonedBaseVariation = typeof baseVariation === 'object' && Object.keys(baseVariation).length > 0 ? (0, _cloneDeep.default)(baseVariation) : null;
|
|
148
|
-
let processedStyleVariations = variations.
|
|
149
|
+
let processedStyleVariations = variations.reduce((accumulator, variation) => {
|
|
150
|
+
const variationFilteredByProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
151
|
+
// Remove variations that are empty once the property is filtered out.
|
|
152
|
+
if (Object.keys(variationFilteredByProperty).length === 0) {
|
|
153
|
+
return accumulator;
|
|
154
|
+
}
|
|
149
155
|
let result = {
|
|
150
|
-
...
|
|
156
|
+
...variationFilteredByProperty,
|
|
151
157
|
title: variation?.title,
|
|
152
158
|
description: variation?.description
|
|
153
159
|
};
|
|
@@ -158,12 +164,37 @@ function useThemeStyleVariationsByProperty({
|
|
|
158
164
|
*/
|
|
159
165
|
result = (0, _globalStylesProvider.mergeBaseAndUserConfigs)(clonedBaseVariation, result);
|
|
160
166
|
}
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
|
|
168
|
+
// Detect if this is a duplicate variation.
|
|
169
|
+
const isDuplicate = accumulator.some(item => {
|
|
170
|
+
return JSON.stringify(item.styles) === JSON.stringify(result?.styles) && JSON.stringify(item.settings) === JSON.stringify(result?.settings);
|
|
171
|
+
});
|
|
172
|
+
if (isDuplicate) {
|
|
173
|
+
return accumulator;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// If the variation is not a duplicate, add it to the accumulator.
|
|
177
|
+
accumulator.push(result);
|
|
178
|
+
return accumulator;
|
|
179
|
+
}, [] // Initial accumulator value.
|
|
180
|
+
);
|
|
163
181
|
if ('function' === typeof filter) {
|
|
164
182
|
processedStyleVariations = processedStyleVariations.filter(filter);
|
|
165
183
|
}
|
|
166
184
|
return processedStyleVariations;
|
|
167
185
|
}, [variations, property, baseVariation, filter]);
|
|
168
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Compares a style variation to the same variation filtered by a single property.
|
|
190
|
+
* Returns true if the variation contains only the property specified.
|
|
191
|
+
*
|
|
192
|
+
* @param {Object} variation The variation to compare.
|
|
193
|
+
* @param {string} property The property to compare.
|
|
194
|
+
* @return {boolean} Whether the variation contains only a single property.
|
|
195
|
+
*/
|
|
196
|
+
function isVariationWithSingleProperty(variation, property) {
|
|
197
|
+
const variationWithProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
198
|
+
return JSON.stringify(variationWithProperty?.styles) === JSON.stringify(variation?.styles) && JSON.stringify(variationWithProperty?.settings) === JSON.stringify(variation?.settings);
|
|
199
|
+
}
|
|
169
200
|
//# sourceMappingURL=use-theme-style-variations-by-property.js.map
|
package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_i18n","_globalStylesProvider","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","unlock","blockEditorPrivateApis","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","filter","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","baseVariation","useContext","variations","useMemo","title","__","settings","styles","useThemeStyleVariationsByProperty","cloneDeep","filterObjectByProperty","newObject","forEach","newFilter","exports","clonedBaseVariation","processedStyleVariations","map","variation","result","description","mergeBaseAndUserConfigs"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mergeBaseAndUserConfigs } from '../../components/global-styles/global-styles-provider';\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,\n * and user-defined global style/settings object.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n\tfilter,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: baseVariation } = useContext( GlobalStylesContext );\n\n\tconst variations = useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: __( 'Default' ),\n\t\t\t\tsettings: {},\n\t\t\t\tstyles: {},\n\t\t\t},\n\t\t\t...variationsFromTheme,\n\t\t];\n\t}, [ variationsFromTheme ] );\n\n\treturn useThemeStyleVariationsByProperty( {\n\t\tvariations,\n\t\tproperty,\n\t\tfilter,\n\t\tbaseVariation: removePropertyFromObject(\n\t\t\tcloneDeep( baseVariation ),\n\t\t\tproperty\n\t\t),\n\t} );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Returns a new object with only the properties specified in `property`.\n * Optional merges the baseVariation object with the variation object.\n * Note: this function will only overwrite the specified property in baseVariation if it exists.\n * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.\n * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.\n *\n * @param {Object} props Object of hook args.\n * @param {Object[]} props.variations The theme style variations to filter.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.\n * @return {Object[]|*} The merged object.\n */\nexport default function useThemeStyleVariationsByProperty( {\n\tvariations,\n\tproperty,\n\tfilter,\n\tbaseVariation,\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! property || ! variations || variations?.length === 0 ) {\n\t\t\treturn variations;\n\t\t}\n\n\t\tconst clonedBaseVariation =\n\t\t\ttypeof baseVariation === 'object' &&\n\t\t\tObject.keys( baseVariation ).length > 0\n\t\t\t\t? cloneDeep( baseVariation )\n\t\t\t\t: null;\n\n\t\tlet processedStyleVariations = variations.map( ( variation ) => {\n\t\t\tlet result = {\n\t\t\t\t...filterObjectByProperty( cloneDeep( variation ), property ),\n\t\t\t\ttitle: variation?.title,\n\t\t\t\tdescription: variation?.description,\n\t\t\t};\n\n\t\t\tif ( clonedBaseVariation ) {\n\t\t\t\t/*\n\t\t\t\t * Overwrites all baseVariation object `styleProperty` properties\n\t\t\t\t * with the theme variation `styleProperty` properties.\n\t\t\t\t */\n\t\t\t\tresult = mergeBaseAndUserConfigs( clonedBaseVariation, result );\n\t\t\t}\n\t\t\treturn result;\n\t\t} );\n\n\t\tif ( 'function' === typeof filter ) {\n\t\t\tprocessedStyleVariations =\n\t\t\t\tprocessedStyleVariations.filter( filter );\n\t\t}\n\n\t\treturn processedStyleVariations;\n\t}, [ variations, property, baseVariation, filter ] );\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAKA,MAAM;EAAES;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CAAEC,MAAM,EA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IAAIA,UAAU,EAAEb,MAAM,KAAK,CAAC,EAAG;MAC7D,OAAOa,UAAU;IAClB;IAEA,MAAMa,mBAAmB,GACxB,OAAOf,aAAa,KAAK,QAAQ,IACjCb,MAAM,CAACC,IAAI,CAAEY,aAAc,CAAC,CAACX,MAAM,GAAG,CAAC,GACpC,IAAAoB,kBAAS,EAAET,aAAc,CAAC,GAC1B,IAAI;IAER,IAAIgB,wBAAwB,GAAGd,UAAU,CAACe,GAAG,CAAIC,SAAS,IAAM;MAC/D,IAAIC,MAAM,GAAG;QACZ,GAAGT,sBAAsB,CAAE,IAAAD,kBAAS,EAAES,SAAU,CAAC,EAAEhC,QAAS,CAAC;QAC7DkB,KAAK,EAAEc,SAAS,EAAEd,KAAK;QACvBgB,WAAW,EAAEF,SAAS,EAAEE;MACzB,CAAC;MAED,IAAKL,mBAAmB,EAAG;QAC1B;AACJ;AACA;AACA;QACII,MAAM,GAAG,IAAAE,6CAAuB,EAAEN,mBAAmB,EAAEI,MAAO,CAAC;MAChE;MACA,OAAOA,MAAM;IACd,CAAE,CAAC;IAEH,IAAK,UAAU,KAAK,OAAO3B,MAAM,EAAG;MACnCwB,wBAAwB,GACvBA,wBAAwB,CAACxB,MAAM,CAAEA,MAAO,CAAC;IAC3C;IAEA,OAAOwB,wBAAwB;EAChC,CAAC,EAAE,CAAEd,UAAU,EAAEhB,QAAQ,EAAEc,aAAa,EAAER,MAAM,CAAG,CAAC;AACrD","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_i18n","_globalStylesProvider","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","unlock","blockEditorPrivateApis","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","filter","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","baseVariation","useContext","variations","useMemo","title","__","settings","styles","useThemeStyleVariationsByProperty","cloneDeep","filterObjectByProperty","newObject","forEach","newFilter","exports","clonedBaseVariation","processedStyleVariations","reduce","accumulator","variation","variationFilteredByProperty","result","description","mergeBaseAndUserConfigs","isDuplicate","some","item","JSON","stringify","push","isVariationWithSingleProperty","variationWithProperty"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mergeBaseAndUserConfigs } from '../../components/global-styles/global-styles-provider';\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,\n * and user-defined global style/settings object.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n\tfilter,\n} ) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: baseVariation } = useContext( GlobalStylesContext );\n\n\tconst variations = useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: __( 'Default' ),\n\t\t\t\tsettings: {},\n\t\t\t\tstyles: {},\n\t\t\t},\n\t\t\t...variationsFromTheme,\n\t\t];\n\t}, [ variationsFromTheme ] );\n\n\treturn useThemeStyleVariationsByProperty( {\n\t\tvariations,\n\t\tproperty,\n\t\tfilter,\n\t\tbaseVariation: removePropertyFromObject(\n\t\t\tcloneDeep( baseVariation ),\n\t\t\tproperty\n\t\t),\n\t} );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Returns a new object with only the properties specified in `property`.\n * Optional merges the baseVariation object with the variation object.\n * Note: this function will only overwrite the specified property in baseVariation if it exists.\n * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.\n * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.\n *\n * @param {Object} props Object of hook args.\n * @param {Object[]} props.variations The theme style variations to filter.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.\n * @return {Object[]|*} The merged object.\n */\nexport default function useThemeStyleVariationsByProperty( {\n\tvariations,\n\tproperty,\n\tfilter,\n\tbaseVariation,\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! property || ! variations || variations?.length === 0 ) {\n\t\t\treturn variations;\n\t\t}\n\n\t\tconst clonedBaseVariation =\n\t\t\ttypeof baseVariation === 'object' &&\n\t\t\tObject.keys( baseVariation ).length > 0\n\t\t\t\t? cloneDeep( baseVariation )\n\t\t\t\t: null;\n\n\t\tlet processedStyleVariations = variations.reduce(\n\t\t\t( accumulator, variation ) => {\n\t\t\t\tconst variationFilteredByProperty = filterObjectByProperty(\n\t\t\t\t\tcloneDeep( variation ),\n\t\t\t\t\tproperty\n\t\t\t\t);\n\t\t\t\t// Remove variations that are empty once the property is filtered out.\n\t\t\t\tif ( Object.keys( variationFilteredByProperty ).length === 0 ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tlet result = {\n\t\t\t\t\t...variationFilteredByProperty,\n\t\t\t\t\ttitle: variation?.title,\n\t\t\t\t\tdescription: variation?.description,\n\t\t\t\t};\n\n\t\t\t\tif ( clonedBaseVariation ) {\n\t\t\t\t\t/*\n\t\t\t\t\t * Overwrites all baseVariation object `styleProperty` properties\n\t\t\t\t\t * with the theme variation `styleProperty` properties.\n\t\t\t\t\t */\n\t\t\t\t\tresult = mergeBaseAndUserConfigs(\n\t\t\t\t\t\tclonedBaseVariation,\n\t\t\t\t\t\tresult\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Detect if this is a duplicate variation.\n\t\t\t\tconst isDuplicate = accumulator.some( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tJSON.stringify( item.styles ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.styles ) &&\n\t\t\t\t\t\tJSON.stringify( item.settings ) ===\n\t\t\t\t\t\t\tJSON.stringify( result?.settings )\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t\tif ( isDuplicate ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// If the variation is not a duplicate, add it to the accumulator.\n\t\t\t\taccumulator.push( result );\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[] // Initial accumulator value.\n\t\t);\n\n\t\tif ( 'function' === typeof filter ) {\n\t\t\tprocessedStyleVariations =\n\t\t\t\tprocessedStyleVariations.filter( filter );\n\t\t}\n\n\t\treturn processedStyleVariations;\n\t}, [ variations, property, baseVariation, filter ] );\n}\n\n/**\n * Compares a style variation to the same variation filtered by a single property.\n * Returns true if the variation contains only the property specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string} property The property to compare.\n * @return {boolean} Whether the variation contains only a single property.\n */\nexport function isVariationWithSingleProperty( variation, property ) {\n\tconst variationWithProperty = filterObjectByProperty(\n\t\tcloneDeep( variation ),\n\t\tproperty\n\t);\n\n\treturn (\n\t\tJSON.stringify( variationWithProperty?.styles ) ===\n\t\t\tJSON.stringify( variation?.styles ) &&\n\t\tJSON.stringify( variationWithProperty?.settings ) ===\n\t\t\tJSON.stringify( variation?.settings )\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAKA,MAAM;EAAES;AAAoB,CA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AAC;MAErC,CAAE,CAAC;MACH,IAAKkB,WAAW,EAAG;QAClB,OAAON,WAAW;MACnB;;MAEA;MACAA,WAAW,CAACW,IAAI,CAAER,MAAO,CAAC;MAC1B,OAAOH,WAAW;IACnB,CAAC,EACD,EAAE,CAAC;IACJ,CAAC;IAED,IAAK,UAAU,KAAK,OAAO1B,MAAM,EAAG;MACnCwB,wBAAwB,GACvBA,wBAAwB,CAACxB,MAAM,CAAEA,MAAO,CAAC;IAC3C;IAEA,OAAOwB,wBAAwB;EAChC,CAAC,EAAE,CAAEd,UAAU,EAAEhB,QAAQ,EAAEc,aAAa,EAAER,MAAM,CAAG,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASsC,6BAA6BA,CAAEX,SAAS,EAAEjC,QAAQ,EAAG;EACpE,MAAM6C,qBAAqB,GAAGrB,sBAAsB,CACnD,IAAAD,kBAAS,EAAEU,SAAU,CAAC,EACtBjC,QACD,CAAC;EAED,OACCyC,IAAI,CAACC,SAAS,CAAEG,qBAAqB,EAAExB,MAAO,CAAC,KAC9CoB,IAAI,CAACC,SAAS,CAAET,SAAS,EAAEZ,MAAO,CAAC,IACpCoB,IAAI,CAACC,SAAS,CAAEG,qBAAqB,EAAEzB,QAAS,CAAC,KAChDqB,IAAI,CAACC,SAAS,CAAET,SAAS,EAAEb,QAAS,CAAC;AAExC","ignoreList":[]}
|
package/build/index.js
CHANGED
|
@@ -4,24 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(exports, "PluginSidebar", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _editor.PluginSidebar;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "PluginSidebarMoreMenuItem", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _editor.PluginSidebarMoreMenuItem;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
initializeEditor: true,
|
|
9
|
+
reinitializeEditor: true,
|
|
10
|
+
store: true,
|
|
11
|
+
PluginTemplateSettingPanel: true
|
|
12
|
+
};
|
|
25
13
|
Object.defineProperty(exports, "PluginTemplateSettingPanel", {
|
|
26
14
|
enumerable: true,
|
|
27
15
|
get: function () {
|
|
@@ -49,6 +37,18 @@ require("./hooks");
|
|
|
49
37
|
var _store = require("./store");
|
|
50
38
|
var _app = _interopRequireDefault(require("./components/app"));
|
|
51
39
|
var _pluginTemplateSettingPanel = _interopRequireDefault(require("./components/plugin-template-setting-panel"));
|
|
40
|
+
var _deprecated2 = require("./deprecated");
|
|
41
|
+
Object.keys(_deprecated2).forEach(function (key) {
|
|
42
|
+
if (key === "default" || key === "__esModule") return;
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
44
|
+
if (key in exports && exports[key] === _deprecated2[key]) return;
|
|
45
|
+
Object.defineProperty(exports, key, {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return _deprecated2[key];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
52
|
/**
|
|
53
53
|
* WordPress dependencies
|
|
54
54
|
*/
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_blockLibrary","_data","_deprecated","_interopRequireDefault","_element","_editor","_preferences","_widgets","_store","_app","_pluginTemplateSettingPanel","initializeEditor","id","settings","target","document","getElementById","root","createRoot","dispatch","blocksStore","reapplyBlockTypeFilters","coreBlocks","__experimentalGetCoreBlocks","filter","name","registerCoreBlocks","setFreeformFallbackBlockName","registerLegacyWidgetBlock","inserter","registerWidgetGroupBlock","process","env","IS_GUTENBERG_PLUGIN","__experimentalRegisterExperimentalCoreBlocks","enableFSEBlocks","preferencesStore","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","_react","createElement","default","reinitializeEditor","deprecated","since","version"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {
|
|
1
|
+
{"version":3,"names":["_blocks","require","_blockLibrary","_data","_deprecated","_interopRequireDefault","_element","_editor","_preferences","_widgets","_store","_app","_pluginTemplateSettingPanel","_deprecated2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","initializeEditor","id","settings","target","document","getElementById","root","createRoot","dispatch","blocksStore","reapplyBlockTypeFilters","coreBlocks","__experimentalGetCoreBlocks","filter","name","registerCoreBlocks","setFreeformFallbackBlockName","registerLegacyWidgetBlock","inserter","registerWidgetGroupBlock","process","env","IS_GUTENBERG_PLUGIN","__experimentalRegisterExperimentalCoreBlocks","enableFSEBlocks","preferencesStore","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","_react","createElement","default","reinitializeEditor","deprecated","since","version"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\twelcomeGuidePage: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\tdistractionFree: false,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tinactivePanels: [],\n\t\tkeepCaretInsideBlock: false,\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\nexport { store } from './store';\nexport * from './deprecated';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAQAA,OAAA;AACA,IAAAS,MAAA,GAAAT,OAA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AC,MAAA,CAAAC,aAAA,EAACpE,IAAA,CAAAqE,OAAG,MAAE,CAAE,CAAC;EAEtB,OAAOhD,IAAI;AACZ;AAEO,SAASiD,kBAAkBA,CAAA,EAAG;EACpC,IAAAC,mBAAU,EAAE,gCAAgC,EAAE;IAC7CC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/build/utils/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TEMPLATE_POST_TYPE = exports.TEMPLATE_PART_POST_TYPE = exports.TEMPLATE_PART_AREA_DEFAULT_CATEGORY = exports.TEMPLATE_PART_ALL_AREAS_CATEGORY = exports.TEMPLATE_ORIGINS = exports.POST_TYPE_LABELS = exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.OPERATOR_IS_NOT = exports.OPERATOR_IS_NONE = exports.OPERATOR_IS_ANY = exports.OPERATOR_IS = exports.NAVIGATION_POST_TYPE = exports.LAYOUT_TABLE = exports.LAYOUT_LIST = exports.LAYOUT_GRID = exports.FOCUSABLE_ENTITIES = exports.EXCLUDED_PATTERN_SOURCES =
|
|
6
|
+
exports.TEMPLATE_POST_TYPE = exports.TEMPLATE_PART_POST_TYPE = exports.TEMPLATE_PART_AREA_DEFAULT_CATEGORY = exports.TEMPLATE_PART_ALL_AREAS_CATEGORY = exports.TEMPLATE_ORIGINS = exports.POST_TYPE_LABELS = exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.OPERATOR_IS_NOT = exports.OPERATOR_IS_NONE = exports.OPERATOR_IS_ANY = exports.OPERATOR_IS = exports.NAVIGATION_POST_TYPE = exports.LAYOUT_TABLE = exports.LAYOUT_LIST = exports.LAYOUT_GRID = exports.FOCUSABLE_ENTITIES = exports.EXCLUDED_PATTERN_SOURCES = void 0;
|
|
7
7
|
var _i18n = require("@wordpress/i18n");
|
|
8
8
|
var _patterns = require("@wordpress/patterns");
|
|
9
9
|
var _lockUnlock = require("../lock-unlock");
|
|
@@ -56,7 +56,6 @@ const POST_TYPE_LABELS = exports.POST_TYPE_LABELS = {
|
|
|
56
56
|
const LAYOUT_GRID = exports.LAYOUT_GRID = 'grid';
|
|
57
57
|
const LAYOUT_TABLE = exports.LAYOUT_TABLE = 'table';
|
|
58
58
|
const LAYOUT_LIST = exports.LAYOUT_LIST = 'list';
|
|
59
|
-
const ENUMERATION_TYPE = exports.ENUMERATION_TYPE = 'enumeration';
|
|
60
59
|
const OPERATOR_IS = exports.OPERATOR_IS = 'is';
|
|
61
60
|
const OPERATOR_IS_NOT = exports.OPERATOR_IS_NOT = 'isNot';
|
|
62
61
|
const OPERATOR_IS_ANY = exports.OPERATOR_IS_ANY = 'isAny';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_patterns","_lockUnlock","NAVIGATION_POST_TYPE","exports","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","TEMPLATE_PART_ALL_AREAS_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","unlock","patternPrivateApis","FOCUSABLE_ENTITIES","user","POST_TYPE_LABELS","__","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_patterns","_lockUnlock","NAVIGATION_POST_TYPE","exports","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","TEMPLATE_PART_ALL_AREAS_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","unlock","patternPrivateApis","FOCUSABLE_ENTITIES","user","POST_TYPE_LABELS","__","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_ANY","OPERATOR_IS_NONE"],"sources":["@wordpress/edit-site/src/utils/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// Navigation\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\n\n// Templates.\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\nexport const TEMPLATE_PART_ALL_AREAS_CATEGORY = 'all-parts';\n\n// Patterns.\nexport const {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternPrivateApis );\n\n// Entities that are editable in focus mode.\nexport const FOCUSABLE_ENTITIES = [\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nexport const POST_TYPE_LABELS = {\n\t[ TEMPLATE_POST_TYPE ]: __( 'Template' ),\n\t[ TEMPLATE_PART_POST_TYPE ]: __( 'Template part' ),\n\t[ PATTERN_TYPES.user ]: __( 'Pattern' ),\n\t[ NAVIGATION_POST_TYPE ]: __( 'Navigation' ),\n};\n\n// DataViews constants\nexport const LAYOUT_GRID = 'grid';\nexport const LAYOUT_TABLE = 'table';\nexport const LAYOUT_LIST = 'list';\n\nexport const OPERATOR_IS = 'is';\nexport const OPERATOR_IS_NOT = 'isNot';\nexport const OPERATOR_IS_ANY = 'isAny';\nexport const OPERATOR_IS_NONE = 'isNone';\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACO,MAAMG,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,eAAe;;AAEnD;AACO,MAAME,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG,aAAa;AACxC,MAAMC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA,GAAG,kBAAkB;AAClD,MAAMC,gBAAgB,GAAAH,OAAA,CAAAG,gBAAA,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AACM,MAAMC,mCAAmC,GAAAP,OAAA,CAAAO,mCAAA,GAAG,eAAe;AAC3D,MAAMC,gCAAgC,GAAAR,OAAA,CAAAQ,gCAAA,GAAG,WAAW;;AAE3D;AACO,MAAM;EACZC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,wBAAwB;EACxBC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAmB,CAAC;;AAEhC;AAAAf,OAAA,CAAAa,kBAAA,GAAAA,kBAAA;AAAAb,OAAA,CAAAY,wBAAA,GAAAA,wBAAA;AAAAZ,OAAA,CAAAW,qBAAA,GAAAA,qBAAA;AAAAX,OAAA,CAAAU,wBAAA,GAAAA,wBAAA;AAAAV,OAAA,CAAAS,aAAA,GAAAA,aAAA;AACO,MAAMO,kBAAkB,GAAAhB,OAAA,CAAAgB,kBAAA,GAAG,CACjCd,uBAAuB,EACvBH,oBAAoB,EACpBU,aAAa,CAACQ,IAAI,CAClB;AAEM,MAAMC,gBAAgB,GAAAlB,OAAA,CAAAkB,gBAAA,GAAG;EAC/B,CAAEjB,kBAAkB,GAAI,IAAAkB,QAAE,EAAE,UAAW,CAAC;EACxC,CAAEjB,uBAAuB,GAAI,IAAAiB,QAAE,EAAE,eAAgB,CAAC;EAClD,CAAEV,aAAa,CAACQ,IAAI,GAAI,IAAAE,QAAE,EAAE,SAAU,CAAC;EACvC,CAAEpB,oBAAoB,GAAI,IAAAoB,QAAE,EAAE,YAAa;AAC5C,CAAC;;AAED;AACO,MAAMC,WAAW,GAAApB,OAAA,CAAAoB,WAAA,GAAG,MAAM;AAC1B,MAAMC,YAAY,GAAArB,OAAA,CAAAqB,YAAA,GAAG,OAAO;AAC5B,MAAMC,WAAW,GAAAtB,OAAA,CAAAsB,WAAA,GAAG,MAAM;AAE1B,MAAMC,WAAW,GAAAvB,OAAA,CAAAuB,WAAA,GAAG,IAAI;AACxB,MAAMC,eAAe,GAAAxB,OAAA,CAAAwB,eAAA,GAAG,OAAO;AAC/B,MAAMC,eAAe,GAAAzB,OAAA,CAAAyB,eAAA,GAAG,OAAO;AAC/B,MAAMC,gBAAgB,GAAA1B,OAAA,CAAA0B,gBAAA,GAAG,QAAQ","ignoreList":[]}
|
|
@@ -58,6 +58,7 @@ export default function AddNewPageModal({
|
|
|
58
58
|
}, createElement(VStack, {
|
|
59
59
|
spacing: 3
|
|
60
60
|
}, createElement(TextControl, {
|
|
61
|
+
__next40pxDefaultSize: true,
|
|
61
62
|
label: __('Page title'),
|
|
62
63
|
onChange: setTitle,
|
|
63
64
|
placeholder: __('No title'),
|
|
@@ -66,9 +67,11 @@ export default function AddNewPageModal({
|
|
|
66
67
|
spacing: 2,
|
|
67
68
|
justify: "end"
|
|
68
69
|
}, createElement(Button, {
|
|
70
|
+
__next40pxDefaultSize: true,
|
|
69
71
|
variant: "tertiary",
|
|
70
72
|
onClick: onClose
|
|
71
73
|
}, __('Cancel')), createElement(Button, {
|
|
74
|
+
__next40pxDefaultSize: true,
|
|
72
75
|
variant: "primary",
|
|
73
76
|
type: "submit",
|
|
74
77
|
isBusy: isCreatingPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useState","store","coreStore","noticesStore","AddNewPageModal","onSave","onClose","isCreatingPage","setIsCreatingPage","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","createPage","event","preventDefault","newPage","status","slug","throwOnError","rendered","type","error","errorMessage","message","code","createElement","onRequestClose","onSubmit","spacing","label","onChange","placeholder","value","justify","variant","onClick","isBusy"],"sources":["@wordpress/edit-site/src/components/add-new-page/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function AddNewPageModal( { onSave, onClose } ) {\n\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPage ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPage( true );\n\t\ttry {\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title || __( 'No title' ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tnewPage.title?.rendered || title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the page.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPage( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal title={ __( 'Draft a new page' ) } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Page title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button
|
|
1
|
+
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useState","store","coreStore","noticesStore","AddNewPageModal","onSave","onClose","isCreatingPage","setIsCreatingPage","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","createPage","event","preventDefault","newPage","status","slug","throwOnError","rendered","type","error","errorMessage","message","code","createElement","onRequestClose","onSubmit","spacing","__next40pxDefaultSize","label","onChange","placeholder","value","justify","variant","onClick","isBusy"],"sources":["@wordpress/edit-site/src/components/add-new-page/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function AddNewPageModal( { onSave, onClose } ) {\n\tconst [ isCreatingPage, setIsCreatingPage ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPage ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPage( true );\n\t\ttry {\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title || __( 'No title' ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tnewPage.title?.rendered || title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the page.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPage( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal title={ __( 'Draft a new page' ) } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Page title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPage }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPage }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create draft' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,QACL,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE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J,CAAC,SAAS;MACTd,iBAAiB,CAAE,KAAM,CAAC;IAC3B;EACD;EAEA,OACCmB,aAAA,CAACpC,KAAK;IAACkB,KAAK,EAAGZ,EAAE,CAAE,kBAAmB,CAAG;IAAC+B,cAAc,EAAGtB;EAAS,GACnEqB,aAAA;IAAME,QAAQ,EAAGf;EAAY,GAC5Ba,aAAA,CAAChC,MAAM;IAACmC,OAAO,EAAG;EAAG,GACpBH,aAAA,CAAC/B,WAAW;IACXmC,qBAAqB;IACrBC,KAAK,EAAGnC,EAAE,CAAE,YAAa,CAAG;IAC5BoC,QAAQ,EAAGvB,QAAU;IACrBwB,WAAW,EAAGrC,EAAE,CAAE,UAAW,CAAG;IAChCsC,KAAK,EAAG1B;EAAO,CACf,CAAC,EACFkB,aAAA,CAAClC,MAAM;IAACqC,OAAO,EAAG,CAAG;IAACM,OAAO,EAAC;EAAK,GAClCT,aAAA,CAACrC,MAAM;IACNyC,qBAAqB;IACrBM,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGhC;EAAS,GAEjBT,EAAE,CAAE,QAAS,CACR,CAAC,EACT8B,aAAA,CAACrC,MAAM;IACNyC,qBAAqB;IACrBM,OAAO,EAAC,SAAS;IACjBf,IAAI,EAAC,QAAQ;IACbiB,MAAM,EAAGhC,cAAgB;IACzB,iBAAgBA;EAAgB,GAE9BV,EAAE,CAAE,cAAe,CACd,CACD,CACD,CACH,CACA,CAAC;AAEV","ignoreList":[]}
|
|
@@ -9,8 +9,8 @@ import { plus, symbol, symbolFilled, upload } from '@wordpress/icons';
|
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
10
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
11
11
|
import { privateApis as editPatternsPrivateApis, store as patternsStore } from '@wordpress/patterns';
|
|
12
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
13
12
|
import { store as noticesStore } from '@wordpress/notices';
|
|
13
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -34,9 +34,6 @@ export default function AddNewPattern() {
|
|
|
34
34
|
} = useLocation();
|
|
35
35
|
const [showPatternModal, setShowPatternModal] = useState(false);
|
|
36
36
|
const [showTemplatePartModal, setShowTemplatePartModal] = useState(false);
|
|
37
|
-
const isBlockBasedTheme = useSelect(select => {
|
|
38
|
-
return select(coreStore).getCurrentTheme()?.is_block_theme;
|
|
39
|
-
}, []);
|
|
40
37
|
const {
|
|
41
38
|
createPatternFromFile
|
|
42
39
|
} = unlock(useDispatch(patternsStore));
|
|
@@ -45,6 +42,7 @@ export default function AddNewPattern() {
|
|
|
45
42
|
createErrorNotice
|
|
46
43
|
} = useDispatch(noticesStore);
|
|
47
44
|
const patternUploadInputRef = useRef();
|
|
45
|
+
const isBlockBasedTheme = useSelect(select => select(coreStore).getCurrentTheme()?.is_block_theme, []);
|
|
48
46
|
function handleCreatePattern({
|
|
49
47
|
pattern,
|
|
50
48
|
categoryId
|
|
@@ -72,11 +70,12 @@ export default function AddNewPattern() {
|
|
|
72
70
|
setShowPatternModal(false);
|
|
73
71
|
setShowTemplatePartModal(false);
|
|
74
72
|
}
|
|
75
|
-
const controls = [
|
|
73
|
+
const controls = [];
|
|
74
|
+
controls.push({
|
|
76
75
|
icon: symbol,
|
|
77
76
|
onClick: () => setShowPatternModal(true),
|
|
78
77
|
title: __('Create pattern')
|
|
79
|
-
}
|
|
78
|
+
});
|
|
80
79
|
if (isBlockBasedTheme) {
|
|
81
80
|
controls.push({
|
|
82
81
|
icon: symbolFilled,
|
|
@@ -118,7 +117,9 @@ export default function AddNewPattern() {
|
|
|
118
117
|
ref: patternUploadInputRef,
|
|
119
118
|
onChange: async event => {
|
|
120
119
|
const file = event.target.files?.[0];
|
|
121
|
-
if (!file)
|
|
120
|
+
if (!file) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
122
123
|
try {
|
|
123
124
|
let currentCategoryId;
|
|
124
125
|
// When we're not handling template parts, we should
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DropdownMenu","useState","useRef","__","sprintf","plus","symbol","symbolFilled","upload","useSelect","useDispatch","privateApis","routerPrivateApis","editPatternsPrivateApis","store","patternsStore","coreStore","noticesStore","CreateTemplatePartModal","SidebarButton","unlock","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","TEMPLATE_PART_POST_TYPE","useHistory","useLocation","CreatePatternModal","useAddPatternCategory","AddNewPattern","history","params","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","isBlockBasedTheme","select","getCurrentTheme","is_block_theme","createPatternFromFile","createSuccessNotice","createErrorNotice","patternUploadInputRef","handleCreatePattern","pattern","categoryId","push","postId","id","postType","user","categoryType","theme","canvas","handleCreateTemplatePart","templatePart","handleError","controls","icon","onClick","title","current","click","categoryMap","findOrCreateTerm","createElement","Fragment","toggleProps","as","label","onClose","onSuccess","onError","closeModal","blocks","onCreate","type","accept","hidden","ref","onChange","event","file","target","files","currentCategoryId","currentCategory","values","find","term","name","undefined","path","raw","err","message","value"],"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus, symbol, symbolFilled, upload } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editPatternsPrivateApis,\n\tstore as patternsStore,\n} from '@wordpress/patterns';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport SidebarButton from '../sidebar-button';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { CreatePatternModal, useAddPatternCategory } = unlock(\n\teditPatternsPrivateApis\n);\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\tconst isBlockBasedTheme = useSelect( ( select ) => {\n\t\treturn select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t}, [] );\n\tconst { createPatternFromFile } = unlock( useDispatch( patternsStore ) );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst patternUploadInputRef = useRef();\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\tcategoryType: PATTERN_TYPES.theme,\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: TEMPLATE_PART_POST_TYPE,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [\n\t\t{\n\t\t\ticon: symbol,\n\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\ttitle: __( 'Create pattern' ),\n\t\t},\n\t];\n\n\tif ( isBlockBasedTheme ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: __( 'Create template part' ),\n\t\t} );\n\t}\n\n\tcontrols.push( {\n\t\ticon: upload,\n\t\tonClick: () => {\n\t\t\tpatternUploadInputRef.current.click();\n\t\t},\n\t\ttitle: __( 'Import pattern from JSON' ),\n\t} );\n\n\tconst { categoryMap, findOrCreateTerm } = useAddPatternCategory();\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ controls }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tas: SidebarButton,\n\t\t\t\t} }\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Create pattern' ) }\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tonClose={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonSuccess={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\".json\"\n\t\t\t\thidden\n\t\t\t\tref={ patternUploadInputRef }\n\t\t\t\tonChange={ async ( event ) => {\n\t\t\t\t\tconst file = event.target.files?.[ 0 ];\n\t\t\t\t\tif ( ! file ) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet currentCategoryId;\n\t\t\t\t\t\t// When we're not handling template parts, we should\n\t\t\t\t\t\t// add or create the proper pattern category.\n\t\t\t\t\t\tif ( params.categoryType !== TEMPLATE_PART_POST_TYPE ) {\n\t\t\t\t\t\t\tconst currentCategory = categoryMap\n\t\t\t\t\t\t\t\t.values()\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t( term ) => term.name === params.categoryId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( !! currentCategory ) {\n\t\t\t\t\t\t\t\tcurrentCategoryId =\n\t\t\t\t\t\t\t\t\tcurrentCategory.id ||\n\t\t\t\t\t\t\t\t\t( await findOrCreateTerm(\n\t\t\t\t\t\t\t\t\t\tcurrentCategory.label\n\t\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\tconst pattern = await createPatternFromFile(\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tcurrentCategoryId\n\t\t\t\t\t\t\t\t? [ currentCategoryId ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Navigate to the All patterns category for the newly created pattern\n\t\t\t\t\t\t// if we're not on that page already and if we're not in the `my-patterns`\n\t\t\t\t\t\t// category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! currentCategoryId &&\n\t\t\t\t\t\t\tparams.categoryId !== 'my-patterns'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\tpath: `/patterns`,\n\t\t\t\t\t\t\t\tcategoryType: PATTERN_TYPES.theme,\n\t\t\t\t\t\t\t\tcategoryId: PATTERN_DEFAULT_CATEGORY,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The imported pattern's title.\n\t\t\t\t\t\t\t\t__( 'Imported \"%s\" from JSON.' ),\n\t\t\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'import-pattern-success',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tcreateErrorNotice( err.message, {\n\t\t\t\t\t\t\ttype: 'snackbar',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E,UAAU;UAChB5B,EAAE,EAAE;QACL,CAAE,CAAC;MACJ,CAAC,SAAS;QACTiC,KAAK,CAACE,MAAM,CAACa,KAAK,GAAG,EAAE;MACxB;IACD;EAAG,CACH,CACA,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["DropdownMenu","useState","useRef","__","sprintf","plus","symbol","symbolFilled","upload","useSelect","useDispatch","privateApis","routerPrivateApis","editPatternsPrivateApis","store","patternsStore","noticesStore","coreStore","CreateTemplatePartModal","SidebarButton","unlock","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","TEMPLATE_PART_POST_TYPE","useHistory","useLocation","CreatePatternModal","useAddPatternCategory","AddNewPattern","history","params","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","createPatternFromFile","createSuccessNotice","createErrorNotice","patternUploadInputRef","isBlockBasedTheme","select","getCurrentTheme","is_block_theme","handleCreatePattern","pattern","categoryId","push","postId","id","postType","user","categoryType","theme","canvas","handleCreateTemplatePart","templatePart","handleError","controls","icon","onClick","title","current","click","categoryMap","findOrCreateTerm","createElement","Fragment","toggleProps","as","label","onClose","onSuccess","onError","closeModal","blocks","onCreate","type","accept","hidden","ref","onChange","event","file","target","files","currentCategoryId","currentCategory","values","find","term","name","undefined","path","raw","err","message","value"],"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus, symbol, symbolFilled, upload } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editPatternsPrivateApis,\n\tstore as patternsStore,\n} from '@wordpress/patterns';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport SidebarButton from '../sidebar-button';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { CreatePatternModal, useAddPatternCategory } = unlock(\n\teditPatternsPrivateApis\n);\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\tconst { createPatternFromFile } = unlock( useDispatch( patternsStore ) );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst patternUploadInputRef = useRef();\n\tconst isBlockBasedTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\tcategoryType: PATTERN_TYPES.theme,\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: TEMPLATE_PART_POST_TYPE,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [];\n\n\tcontrols.push( {\n\t\ticon: symbol,\n\t\tonClick: () => setShowPatternModal( true ),\n\t\ttitle: __( 'Create pattern' ),\n\t} );\n\n\tif ( isBlockBasedTheme ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: __( 'Create template part' ),\n\t\t} );\n\t}\n\n\tcontrols.push( {\n\t\ticon: upload,\n\t\tonClick: () => {\n\t\t\tpatternUploadInputRef.current.click();\n\t\t},\n\t\ttitle: __( 'Import pattern from JSON' ),\n\t} );\n\n\tconst { categoryMap, findOrCreateTerm } = useAddPatternCategory();\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ controls }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tas: SidebarButton,\n\t\t\t\t} }\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Create pattern' ) }\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tonClose={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonSuccess={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\".json\"\n\t\t\t\thidden\n\t\t\t\tref={ patternUploadInputRef }\n\t\t\t\tonChange={ async ( event ) => {\n\t\t\t\t\tconst file = event.target.files?.[ 0 ];\n\t\t\t\t\tif ( ! file ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet currentCategoryId;\n\t\t\t\t\t\t// When we're not handling template parts, we should\n\t\t\t\t\t\t// add or create the proper pattern category.\n\t\t\t\t\t\tif ( params.categoryType !== TEMPLATE_PART_POST_TYPE ) {\n\t\t\t\t\t\t\tconst currentCategory = categoryMap\n\t\t\t\t\t\t\t\t.values()\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t( term ) => term.name === params.categoryId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( !! currentCategory ) {\n\t\t\t\t\t\t\t\tcurrentCategoryId =\n\t\t\t\t\t\t\t\t\tcurrentCategory.id ||\n\t\t\t\t\t\t\t\t\t( await findOrCreateTerm(\n\t\t\t\t\t\t\t\t\t\tcurrentCategory.label\n\t\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\tconst pattern = await createPatternFromFile(\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tcurrentCategoryId\n\t\t\t\t\t\t\t\t? [ currentCategoryId ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Navigate to the All patterns category for the newly created pattern\n\t\t\t\t\t\t// if we're not on that page already and if we're not in the `my-patterns`\n\t\t\t\t\t\t// category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! currentCategoryId &&\n\t\t\t\t\t\t\tparams.categoryId !== 'my-patterns'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\tpath: `/patterns`,\n\t\t\t\t\t\t\t\tcategoryType: PATTERN_TYPES.theme,\n\t\t\t\t\t\t\t\tcategoryId: PATTERN_DEFAULT_CATEGORY,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The imported pattern's title.\n\t\t\t\t\t\t\t\t__( 'Imported \"%s\" from JSON.' ),\n\t\t\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'import-pattern-success',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tcreateErrorNotice( err.message, {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'import-pattern-error',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tevent.target.value = '';\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,IAAI,EAAEC,MAAM,EAAEC,YAAY,EAAEC,MAAM,QAAQ,kBAAkB;AACrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SACCD,WAAW,IAAIE,uBAAuB,EACtCC,KAAK,IAAIC,aAAa,QAChB,qBAAqB;AAC5B,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,+BAA+B;AACnE,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SACCC,aAAa,EACbC,wBAAwB,EACxBC,uBAAuB,QACjB,uBAAuB;AAE9B,MAAM;EAAEC,UAAU;EAAEC;AAAY,CAAC,GAAGL,MAAM,CAAER,iBAAkB,CAAC;AAC/D,MAAM;EAAEc,kBAAkB;EAAEC;AAAsB,CAAC,GAAGP,MAAM,CAC3DP,uBACD,CAAC;AAED,eAAe,SAASe,aAAaA,CAAA,EAAG;EACvC,MAAMC,OAAO,GAAGL,UAA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CAAC,EACD;UACCjB,IAAI,EAAE,UAAU;UAChB5B,EAAE,EAAE;QACL,CACD,CAAC;MACF,CAAC,CAAC,OAAQ8C,GAAG,EAAG;QACfzD,iBAAiB,CAAEyD,GAAG,CAACC,OAAO,EAAE;UAC/BnB,IAAI,EAAE,UAAU;UAChB5B,EAAE,EAAE;QACL,CAAE,CAAC;MACJ,CAAC,SAAS;QACTiC,KAAK,CAACE,MAAM,CAACa,KAAK,GAAG,EAAE;MACxB;IACD;EAAG,CACH,CACA,CAAC;AAEL","ignoreList":[]}
|
package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js
CHANGED
|
@@ -37,6 +37,7 @@ function AddCustomGenericTemplateModalContent({
|
|
|
37
37
|
}, createElement(VStack, {
|
|
38
38
|
spacing: 6
|
|
39
39
|
}, createElement(TextControl, {
|
|
40
|
+
__next40pxDefaultSize: true,
|
|
40
41
|
__nextHasNoMarginBottom: true,
|
|
41
42
|
label: __('Name'),
|
|
42
43
|
value: title,
|
|
@@ -48,11 +49,13 @@ function AddCustomGenericTemplateModalContent({
|
|
|
48
49
|
className: "edit-site-custom-generic-template__modal-actions",
|
|
49
50
|
justify: "right"
|
|
50
51
|
}, createElement(Button, {
|
|
52
|
+
__next40pxDefaultSize: true,
|
|
51
53
|
variant: "tertiary",
|
|
52
54
|
onClick: () => {
|
|
53
55
|
onClose();
|
|
54
56
|
}
|
|
55
57
|
}, __('Cancel')), createElement(Button, {
|
|
58
|
+
__next40pxDefaultSize: true,
|
|
56
59
|
variant: "primary",
|
|
57
60
|
type: "submit",
|
|
58
61
|
isBusy: isBusy,
|
package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["paramCase","kebabCase","useState","__","Button","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","AddCustomGenericTemplateModalContent","onClose","createTemplate","title","setTitle","defaultTitle","isBusy","setIsBusy","onCreateTemplate","event","preventDefault","slug","createElement","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","className","justify","variant","onClick","type"],"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-generic-template-modal-content.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nfunction AddCustomGenericTemplateModalContent( { onClose, createTemplate } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst defaultTitle = __( 'Custom Template' );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\tasync function onCreateTemplate( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsBusy( true );\n\t\ttry {\n\t\t\tawait createTemplate(\n\t\t\t\t{\n\t\t\t\t\tslug:\n\t\t\t\t\t\t'wp-custom-template-' +\n\t\t\t\t\t\tkebabCase( title || defaultTitle ),\n\t\t\t\t\ttitle: title || defaultTitle,\n\t\t\t\t},\n\t\t\t\tfalse\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsBusy( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form onSubmit={ onCreateTemplate }>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\tplaceholder={ defaultTitle }\n\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-site-custom-generic-template__modal-actions\"\n\t\t\t\t\tjustify=\"right\"\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nexport default AddCustomGenericTemplateModalContent;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,MAAM,EACNC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAE9B,SAASC,oCAAoCA,CAAE;EAAEC,OAAO;EAAEC;AAAe,CAAC,EAAG;EAC5E,MAAM,CAAEC,KAAK,EAAEC,QAAQ,CAAE,GAAGZ,QAAQ,CAAE,EAAG,CAAC;EAC1C,MAAMa,YAAY,GAAGZ,EAAE,CAAE,iBAAkB,CAAC;EAC5C,MAAM,CAAEa,MAAM,EAAEC,SAAS,CAAE,GAAGf,QAAQ,CAAE,KAAM,CAAC;EAC/C,eAAegB,gBAAgBA,CAAEC,KAAK,EAAG;IACxCA,KAAK,CAACC,cAAc,CAAC,CAAC;IACtB,IAAKJ,MAAM,EAAG;MACb;IACD;IACAC,SAAS,CAAE,IAAK,CAAC;IACjB,IAAI;MACH,MAAML,cAAc,CACnB;QACCS,IAAI,EACH,qBAAqB,GACrBpB,SAAS,CAAEY,KAAK,IAAIE,YAAa,CAAC;QACnCF,KAAK,EAAEA,KAAK,IAAIE;MACjB,CAAC,EACD,KACD,CAAC;IACF,CAAC,SAAS;MACTE,SAAS,CAAE,KAAM,CAAC;IACnB;EACD;EACA,OACCK,aAAA;IAAMC,QAAQ,EAAGL;EAAkB,GAClCI,aAAA,CAACb,MAAM;IAACe,OAAO,EAAG;EAAG,GACpBF,aAAA,CAACjB,WAAW;IACXoB,uBAAuB;IACvBC,KAAK,
|
|
1
|
+
{"version":3,"names":["paramCase","kebabCase","useState","__","Button","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","AddCustomGenericTemplateModalContent","onClose","createTemplate","title","setTitle","defaultTitle","isBusy","setIsBusy","onCreateTemplate","event","preventDefault","slug","createElement","onSubmit","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","className","justify","variant","onClick","type"],"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-generic-template-modal-content.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nfunction AddCustomGenericTemplateModalContent( { onClose, createTemplate } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst defaultTitle = __( 'Custom Template' );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\tasync function onCreateTemplate( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsBusy( true );\n\t\ttry {\n\t\t\tawait createTemplate(\n\t\t\t\t{\n\t\t\t\t\tslug:\n\t\t\t\t\t\t'wp-custom-template-' +\n\t\t\t\t\t\tkebabCase( title || defaultTitle ),\n\t\t\t\t\ttitle: title || defaultTitle,\n\t\t\t\t},\n\t\t\t\tfalse\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsBusy( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form onSubmit={ onCreateTemplate }>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\tplaceholder={ defaultTitle }\n\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-site-custom-generic-template__modal-actions\"\n\t\t\t\t\tjustify=\"right\"\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nexport default AddCustomGenericTemplateModalContent;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa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