@wordpress/edit-site 7.3.2-next.v.202608281122.0 → 7.4.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 +17 -1
- package/build/components/add-new-template/add-custom-template-modal-content.cjs +3 -1
- package/build/components/add-new-template/add-custom-template-modal-content.cjs.map +2 -2
- package/build/components/add-new-template/index.cjs +6 -4
- package/build/components/add-new-template/index.cjs.map +2 -2
- package/build/components/add-new-template/utils.cjs +84 -9
- package/build/components/add-new-template/utils.cjs.map +2 -2
- package/build/components/dataviews-actions/index.cjs +2 -55
- package/build/components/dataviews-actions/index.cjs.map +3 -3
- package/build/components/layout/index.cjs +2 -2
- package/build/components/layout/index.cjs.map +2 -2
- package/build/components/more-menu/welcome-guide-menu-item.cjs +10 -2
- package/build/components/more-menu/welcome-guide-menu-item.cjs.map +3 -3
- package/build/components/page-templates/fields.cjs +2 -126
- package/build/components/page-templates/fields.cjs.map +3 -3
- package/build/components/page-templates/index.cjs +46 -230
- package/build/components/page-templates/index.cjs.map +3 -3
- package/build/components/post-list/index.cjs +7 -17
- package/build/components/post-list/index.cjs.map +2 -2
- package/build/components/sidebar-global-styles/index.cjs +2 -2
- package/build/components/sidebar-global-styles/index.cjs.map +2 -2
- package/build/components/sidebar-identity/index.cjs +17 -22
- package/build/components/sidebar-identity/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-item/index.cjs +1 -8
- package/build/components/sidebar-navigation-item/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.cjs +34 -72
- package/build/components/sidebar-navigation-screen-templates-browse/content.cjs.map +3 -3
- package/build/components/sidebar-navigation-screen-templates-browse/index.cjs +1 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.cjs.map +3 -3
- package/build/components/site-editor-routes/templates.cjs +2 -4
- package/build/components/site-editor-routes/templates.cjs.map +3 -3
- package/build/index.cjs +0 -1
- package/build/index.cjs.map +2 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.mjs +3 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.mjs.map +2 -2
- package/build-module/components/add-new-template/index.mjs +7 -4
- package/build-module/components/add-new-template/index.mjs.map +2 -2
- package/build-module/components/add-new-template/utils.mjs +84 -9
- package/build-module/components/add-new-template/utils.mjs.map +2 -2
- package/build-module/components/dataviews-actions/index.mjs +1 -53
- package/build-module/components/dataviews-actions/index.mjs.map +2 -2
- package/build-module/components/layout/index.mjs +2 -2
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/more-menu/welcome-guide-menu-item.mjs +10 -2
- package/build-module/components/more-menu/welcome-guide-menu-item.mjs.map +2 -2
- package/build-module/components/page-templates/fields.mjs +3 -129
- package/build-module/components/page-templates/fields.mjs.map +3 -3
- package/build-module/components/page-templates/index.mjs +52 -253
- package/build-module/components/page-templates/index.mjs.map +2 -2
- package/build-module/components/post-list/index.mjs +8 -18
- package/build-module/components/post-list/index.mjs.map +2 -2
- package/build-module/components/sidebar-global-styles/index.mjs +2 -2
- package/build-module/components/sidebar-global-styles/index.mjs.map +2 -2
- package/build-module/components/sidebar-identity/index.mjs +17 -22
- package/build-module/components/sidebar-identity/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-item/index.mjs +1 -8
- package/build-module/components/sidebar-navigation-item/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs +42 -75
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs +1 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs.map +2 -2
- package/build-module/components/site-editor-routes/templates.mjs +2 -4
- package/build-module/components/site-editor-routes/templates.mjs.map +2 -2
- package/build-module/index.mjs +0 -1
- package/build-module/index.mjs.map +2 -2
- package/build-style/style-rtl.css +38 -81
- package/build-style/style.css +38 -81
- package/package.json +41 -38
- package/src/components/add-new-template/add-custom-template-modal-content.jsx +3 -1
- package/src/components/add-new-template/index.jsx +9 -4
- package/src/components/add-new-template/style.scss +8 -21
- package/src/components/add-new-template/utils.js +118 -9
- package/src/components/dataviews-actions/index.js +0 -61
- package/src/components/layout/index.jsx +5 -2
- package/src/components/more-menu/welcome-guide-menu-item.jsx +8 -3
- package/src/components/page-templates/fields.jsx +2 -146
- package/src/components/page-templates/index.jsx +30 -256
- package/src/components/post-list/index.jsx +7 -20
- package/src/components/sidebar-global-styles/index.jsx +7 -5
- package/src/components/sidebar-global-styles/style.scss +6 -0
- package/src/components/sidebar-identity/index.jsx +23 -19
- package/src/components/sidebar-identity/style.scss +7 -0
- package/src/components/sidebar-navigation-item/index.jsx +1 -7
- package/src/components/sidebar-navigation-screen-templates-browse/content.jsx +45 -80
- package/src/components/sidebar-navigation-screen-templates-browse/index.jsx +1 -8
- package/src/components/site-editor-routes/templates.jsx +2 -19
- package/src/components/welcome-guide/style.scss +1 -1
- package/src/index.jsx +0 -1
- package/src/style.scss +1 -1
- package/src/utils/test/get-filtered-template-parts.js +1 -0
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.cjs +0 -107
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.cjs.map +0 -7
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.cjs +0 -327
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.cjs.map +0 -7
- package/build/components/add-new-template-legacy/index.cjs +0 -390
- package/build/components/add-new-template-legacy/index.cjs.map +0 -7
- package/build/components/add-new-template-legacy/utils.cjs +0 -623
- package/build/components/add-new-template-legacy/utils.cjs.map +0 -7
- package/build/components/page-templates/hooks.cjs +0 -94
- package/build/components/page-templates/hooks.cjs.map +0 -7
- package/build/components/page-templates/index-legacy.cjs +0 -167
- package/build/components/page-templates/index-legacy.cjs.map +0 -7
- package/build/components/page-templates/view-utils.cjs +0 -79
- package/build/components/page-templates/view-utils.cjs.map +0 -7
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.cjs +0 -78
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.cjs.map +0 -7
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.mjs +0 -91
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.mjs.map +0 -7
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs +0 -315
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs.map +0 -7
- package/build-module/components/add-new-template-legacy/index.mjs +0 -391
- package/build-module/components/add-new-template-legacy/index.mjs.map +0 -7
- package/build-module/components/add-new-template-legacy/utils.mjs +0 -592
- package/build-module/components/add-new-template-legacy/utils.mjs.map +0 -7
- package/build-module/components/page-templates/hooks.mjs +0 -74
- package/build-module/components/page-templates/hooks.mjs.map +0 -7
- package/build-module/components/page-templates/index-legacy.mjs +0 -136
- package/build-module/components/page-templates/index-legacy.mjs.map +0 -7
- package/build-module/components/page-templates/view-utils.mjs +0 -52
- package/build-module/components/page-templates/view-utils.mjs.map +0 -7
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs +0 -52
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs.map +0 -7
- package/src/components/add-new-template-legacy/add-custom-generic-template-modal-content.jsx +0 -85
- package/src/components/add-new-template-legacy/add-custom-template-modal-content.jsx +0 -306
- package/src/components/add-new-template-legacy/index.jsx +0 -440
- package/src/components/add-new-template-legacy/utils.js +0 -757
- package/src/components/page-templates/hooks.js +0 -93
- package/src/components/page-templates/index-legacy.jsx +0 -143
- package/src/components/page-templates/view-utils.js +0 -50
- package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.jsx +0 -52
- package/src/components/sidebar-navigation-screen-templates-browse/style.scss +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/layout/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { NavigableRegion, getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tSlotFillProvider,\n} from '@wordpress/components';\nimport {\n\tuseReducedMotion,\n\tuseViewportMatch,\n\tuseResizeObserver,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useRef, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tUnsavedChangesWarning,\n\tErrorBoundary,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { PluginArea } from '@wordpress/plugins';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { Tooltip } from '@wordpress/ui';\nimport { SiteHubMobile } from '../site-hub';\nimport ResizableFrame from '../resizable-frame';\nimport { unlock } from '../../lock-unlock';\nimport SaveKeyboardShortcut from '../save-keyboard-shortcut';\nimport { useIsSiteEditorLoading } from './hooks';\nimport useMovingAnimation from './animation';\nimport { SidebarContent, SidebarNavigationProvider } from '../sidebar';\nimport SaveHub from '../save-hub';\nimport SavePanel from '../save-panel';\n\nconst { useLocation } = unlock( routerPrivateApis );\nconst { useStyle, UploadProgressSnackbar } = unlock( editorPrivateApis );\n\nconst ANIMATION_DURATION = 0.3;\nconst CONTENT_COLOR = { background: '#ffffff' };\n\nfunction Layout() {\n\tconst { query, name: routeKey, areas, widths } = useLocation();\n\t// Force canvas to 'view' on notfound route to show the error message and allow navigation.\n\tconst canvas = routeKey === 'notfound' ? 'view' : query?.canvas ?? 'view';\n\tconst showMobileSiteHub = !! areas.mobileContent;\n\tconst hasMobileAreas =\n\t\tareas.mobileSidebar || areas.mobileContent || areas.preview;\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst mobileToggleRef = useRef();\n\tconst sidebarRegionRef = useRef();\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst disableMotion = useReducedMotion();\n\tconst [ canvasResizer, canvasSize ] = useResizeObserver();\n\tconst isEditorLoading = useIsSiteEditorLoading();\n\tconst [ isResizableFrameOversized, setIsResizableFrameOversized ] =\n\t\tuseState( false );\n\tconst animationRef = useMovingAnimation( {\n\t\ttriggerAnimationOnChange: routeKey + '-' + canvas,\n\t} );\n\n\tconst { showIconLabels } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t} );\n\n\tconst backgroundColor = useStyle( 'color.background' );\n\tconst gradientValue = useStyle( 'color.gradient' );\n\tconst previousCanvaMode = usePrevious( canvas );\n\tuseEffect( () => {\n\t\tif ( previousCanvaMode === 'edit' ) {\n\t\t\tconst desktopToggle = sidebarRegionRef.current\n\t\t\t\t? // We're typically expecting the `<DashboardBackButton />` component as the first tabbable element.\n\t\t\t\t focus.tabbable.find( sidebarRegionRef.current )[ 0 ]\n\t\t\t\t: undefined;\n\t\t\t( desktopToggle ?? mobileToggleRef.current )?.focus();\n\t\t}\n\t\t// Should not depend on the previous canvas mode value but the next.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ canvas ] );\n\n\treturn (\n\t\t<>\n\t\t\t<UnsavedChangesWarning />\n\t\t\t{ canvas === 'view' && <SaveKeyboardShortcut /> }\n\t\t\t<div\n\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'edit-site-layout',\n\t\t\t\t\tnavigateRegionsProps.className,\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-full-canvas': canvas === 'edit',\n\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<div className=\"edit-site-layout__content\">\n\t\t\t\t\t{ /*\n\t\t\t\t\t\tThe NavigableRegion must always be rendered and not use\n\t\t\t\t\t\t`inert` otherwise `useNavigateRegions` will fail.\n\t\t\t\t\t*/ }\n\t\t\t\t\t{ ( ! isMobileViewport || ! hasMobileAreas ) && (\n\t\t\t\t\t\t<NavigableRegion\n\t\t\t\t\t\t\tref={ sidebarRegionRef }\n\t\t\t\t\t\t\tariaLabel={ __( 'Navigation' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__sidebar-region\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t\t\t{ canvas === 'view' && (\n\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\tinitial={ { opacity: 0 } }\n\t\t\t\t\t\t\t\t\t\tanimate={ { opacity: 1 } }\n\t\t\t\t\t\t\t\t\t\texit={ { opacity: 0 } }\n\t\t\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\t\t\t\tduration:\n\t\t\t\t\t\t\t\t\t\t\t\t// Disable transition in mobile to emulate a full page transition.\n\t\t\t\t\t\t\t\t\t\t\t\tdisableMotion ||\n\t\t\t\t\t\t\t\t\t\t\t\tisMobileViewport\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t: ANIMATION_DURATION,\n\t\t\t\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-layout__sidebar\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\tshouldAnimate={\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey !== 'styles' &&\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey !== 'identity'\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ areas.sidebar }\n\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t</SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t\t\t<SaveHub />\n\t\t\t\t\t\t\t\t\t\t<SavePanel />\n\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</AnimatePresence>\n\t\t\t\t\t\t</NavigableRegion>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<SnackbarNotices className=\"edit-site-layout__snackbar\" />\n\t\t\t\t\t<UploadProgressSnackbar />\n\n\t\t\t\t\t{ isMobileViewport && hasMobileAreas && (\n\t\t\t\t\t\t<div className=\"edit-site-layout__mobile\">\n\t\t\t\t\t\t\t<SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t{ canvas !== 'edit' ? (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ showMobileSiteHub && (\n\t\t\t\t\t\t\t\t\t\t\t<SiteHubMobile\n\t\t\t\t\t\t\t\t\t\t\t\tref={ mobileToggleRef }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ areas.mobileContent ? (\n\t\t\t\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t\t\t\t\t * ThemeProvider wraps SidebarContent (rather than\n\t\t\t\t\t\t\t\t\t\t\t * just the content) so the scroll wrapper it renders\n\t\t\t\t\t\t\t\t\t\t\t * inherits the content background tokens. See\n\t\t\t\t\t\t\t\t\t\t\t * `.edit-site-sidebar__screen-wrapper` in style.scss.\n\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\t\t\t<ThemeProvider\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={ CONTENT_COLOR }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-layout__mobile-content\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tareas.mobileContent\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ areas.mobileSidebar }\n\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t<SaveHub />\n\t\t\t\t\t\t\t\t\t\t<SavePanel />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t{ areas.preview }\n\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</SidebarNavigationProvider>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport &&\n\t\t\t\t\t\tareas.content &&\n\t\t\t\t\t\tcanvas !== 'edit' && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-site-layout__area\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tmaxWidth: widths?.content,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t{ areas.content }\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport && areas.edit && canvas !== 'edit' && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__area\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: widths?.edit,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t<ErrorBoundary>{ areas.edit }</ErrorBoundary>\n\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport && areas.preview && (\n\t\t\t\t\t\t<div className=\"edit-site-layout__canvas-container\">\n\t\t\t\t\t\t\t{ canvasResizer }\n\t\t\t\t\t\t\t{ !! canvasSize.width && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'edit-site-layout__canvas',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'is-right-aligned':\n\t\t\t\t\t\t\t\t\t\t\t\tisResizableFrameOversized,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tref={ animationRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t<ResizableFrame\n\t\t\t\t\t\t\t\t\t\t\tisReady={ ! isEditorLoading }\n\t\t\t\t\t\t\t\t\t\t\tisFullWidth={ canvas === 'edit' }\n\t\t\t\t\t\t\t\t\t\t\tdefaultSize={ {\n\t\t\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\t\t\tcanvasSize.width -\n\t\t\t\t\t\t\t\t\t\t\t\t\t24 /* $canvas-padding */,\n\t\t\t\t\t\t\t\t\t\t\t\theight: canvasSize.height,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tisOversized={\n\t\t\t\t\t\t\t\t\t\t\t\tisResizableFrameOversized\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tsetIsOversized={\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsResizableFrameOversized\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tinnerContentStyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\t\t\t\t\t\tgradientValue ??\n\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<ThemeProvider\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={ CONTENT_COLOR }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ areas.preview }\n\t\t\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t\t\t</ResizableFrame>\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default function LayoutWithGlobalStylesProvider( props ) {\n\tconst themeColors = useMemo( getAdminThemeColors, [] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<Tooltip.Provider>\n\t\t\t\t{ /** This needs to be within the SlotFillProvider */ }\n\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t<ThemeProvider\n\t\t\t\t\tisRoot\n\t\t\t\t\tcolor={ {\n\t\t\t\t\t\tprimary: themeColors.primary,\n\t\t\t\t\t\t...CONTENT_COLOR,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ThemeProvider color={ themeColors }>\n\t\t\t\t\t\t<Layout { ...props } />\n\t\t\t\t\t</ThemeProvider>\n\t\t\t\t</ThemeProvider>\n\t\t\t</Tooltip.Provider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB,2BAA2B;AACrD;AAAA,EACC,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa;AACtB,SAAS,IAAI,eAAe;AAC5B,SAAS,UAAU,QAAQ,WAAW,eAAe;AACrD;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,eAAe,yBAAyB;AACjD,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB,SAAS,oBAAoB;AACvD,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,OAAO,oBAAoB;AAC3B,SAAS,cAAc;AACvB,OAAO,0BAA0B;AACjC,SAAS,8BAA8B;AACvC,OAAO,wBAAwB;AAC/B,SAAS,gBAAgB,iCAAiC;AAC1D,OAAO,aAAa;AACpB,OAAO,eAAe;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { NavigableRegion, getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tSlotFillProvider,\n} from '@wordpress/components';\nimport {\n\tuseReducedMotion,\n\tuseViewportMatch,\n\tuseResizeObserver,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useRef, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tUnsavedChangesWarning,\n\tErrorBoundary,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { PluginArea } from '@wordpress/plugins';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { Tooltip } from '@wordpress/ui';\nimport { SiteHubMobile } from '../site-hub';\nimport ResizableFrame from '../resizable-frame';\nimport { unlock } from '../../lock-unlock';\nimport SaveKeyboardShortcut from '../save-keyboard-shortcut';\nimport { useIsSiteEditorLoading } from './hooks';\nimport useMovingAnimation from './animation';\nimport { SidebarContent, SidebarNavigationProvider } from '../sidebar';\nimport SaveHub from '../save-hub';\nimport SavePanel from '../save-panel';\n\nconst { useLocation } = unlock( routerPrivateApis );\nconst { useStyle, UploadProgressSnackbar } = unlock( editorPrivateApis );\n\nconst ANIMATION_DURATION = 0.3;\n// Reset to the default background color.\nconst CONTENT_COLOR = { background: '#fcfcfc' };\n\nfunction Layout() {\n\tconst { query, name: routeKey, areas, widths } = useLocation();\n\t// Force canvas to 'view' on notfound route to show the error message and allow navigation.\n\tconst canvas = routeKey === 'notfound' ? 'view' : query?.canvas ?? 'view';\n\tconst showMobileSiteHub = !! areas.mobileContent;\n\tconst hasMobileAreas =\n\t\tareas.mobileSidebar || areas.mobileContent || areas.preview;\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst mobileToggleRef = useRef();\n\tconst sidebarRegionRef = useRef();\n\tconst navigateRegionsProps = useNavigateRegions();\n\tconst disableMotion = useReducedMotion();\n\tconst [ canvasResizer, canvasSize ] = useResizeObserver();\n\tconst isEditorLoading = useIsSiteEditorLoading();\n\tconst [ isResizableFrameOversized, setIsResizableFrameOversized ] =\n\t\tuseState( false );\n\tconst animationRef = useMovingAnimation( {\n\t\ttriggerAnimationOnChange: routeKey + '-' + canvas,\n\t} );\n\n\tconst { showIconLabels } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t} );\n\n\tconst backgroundColor = useStyle( 'color.background' );\n\tconst gradientValue = useStyle( 'color.gradient' );\n\tconst previousCanvaMode = usePrevious( canvas );\n\tuseEffect( () => {\n\t\tif ( previousCanvaMode === 'edit' ) {\n\t\t\tconst desktopToggle = sidebarRegionRef.current\n\t\t\t\t? // We're typically expecting the `<DashboardBackButton />` component as the first tabbable element.\n\t\t\t\t focus.tabbable.find( sidebarRegionRef.current )[ 0 ]\n\t\t\t\t: undefined;\n\t\t\t( desktopToggle ?? mobileToggleRef.current )?.focus();\n\t\t}\n\t\t// Should not depend on the previous canvas mode value but the next.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ canvas ] );\n\n\treturn (\n\t\t<>\n\t\t\t<UnsavedChangesWarning />\n\t\t\t{ canvas === 'view' && <SaveKeyboardShortcut /> }\n\t\t\t<div\n\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'edit-site-layout',\n\t\t\t\t\tnavigateRegionsProps.className,\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-full-canvas': canvas === 'edit',\n\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<div className=\"edit-site-layout__content\">\n\t\t\t\t\t{ /*\n\t\t\t\t\t\tThe NavigableRegion must always be rendered and not use\n\t\t\t\t\t\t`inert` otherwise `useNavigateRegions` will fail.\n\t\t\t\t\t*/ }\n\t\t\t\t\t{ ( ! isMobileViewport || ! hasMobileAreas ) && (\n\t\t\t\t\t\t<NavigableRegion\n\t\t\t\t\t\t\tref={ sidebarRegionRef }\n\t\t\t\t\t\t\tariaLabel={ __( 'Navigation' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__sidebar-region\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t\t\t{ canvas === 'view' && (\n\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\tinitial={ { opacity: 0 } }\n\t\t\t\t\t\t\t\t\t\tanimate={ { opacity: 1 } }\n\t\t\t\t\t\t\t\t\t\texit={ { opacity: 0 } }\n\t\t\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\t\t\t\tduration:\n\t\t\t\t\t\t\t\t\t\t\t\t// Disable transition in mobile to emulate a full page transition.\n\t\t\t\t\t\t\t\t\t\t\t\tdisableMotion ||\n\t\t\t\t\t\t\t\t\t\t\t\tisMobileViewport\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t: ANIMATION_DURATION,\n\t\t\t\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-layout__sidebar\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\tshouldAnimate={\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey !== 'styles' &&\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey !== 'identity'\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ areas.sidebar }\n\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t</SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t\t\t<SaveHub />\n\t\t\t\t\t\t\t\t\t\t<SavePanel />\n\t\t\t\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</AnimatePresence>\n\t\t\t\t\t\t</NavigableRegion>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<SnackbarNotices className=\"edit-site-layout__snackbar\" />\n\t\t\t\t\t<UploadProgressSnackbar />\n\n\t\t\t\t\t{ isMobileViewport && hasMobileAreas && (\n\t\t\t\t\t\t<div className=\"edit-site-layout__mobile\">\n\t\t\t\t\t\t\t<SidebarNavigationProvider>\n\t\t\t\t\t\t\t\t{ canvas !== 'edit' ? (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ showMobileSiteHub && (\n\t\t\t\t\t\t\t\t\t\t\t<SiteHubMobile\n\t\t\t\t\t\t\t\t\t\t\t\tref={ mobileToggleRef }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ areas.mobileContent ? (\n\t\t\t\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t\t\t\t\t * ThemeProvider wraps SidebarContent (rather than\n\t\t\t\t\t\t\t\t\t\t\t * just the content) so the scroll wrapper it renders\n\t\t\t\t\t\t\t\t\t\t\t * inherits the content background tokens. See\n\t\t\t\t\t\t\t\t\t\t\t * `.edit-site-sidebar__screen-wrapper` in style.scss.\n\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\t\t\t<ThemeProvider\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={ CONTENT_COLOR }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-layout__mobile-content\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tareas.mobileContent\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<SidebarContent\n\t\t\t\t\t\t\t\t\t\t\t\trouteKey={ routeKey }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ areas.mobileSidebar }\n\t\t\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t</SidebarContent>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t<SaveHub />\n\t\t\t\t\t\t\t\t\t\t<SavePanel />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t\t{ areas.preview }\n\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</SidebarNavigationProvider>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport &&\n\t\t\t\t\t\tareas.content &&\n\t\t\t\t\t\tcanvas !== 'edit' && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-site-layout__area\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tmaxWidth: widths?.content,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t{ areas.content }\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport && areas.edit && canvas !== 'edit' && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__area\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: widths?.edit,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ThemeProvider color={ CONTENT_COLOR }>\n\t\t\t\t\t\t\t\t<ErrorBoundary>{ areas.edit }</ErrorBoundary>\n\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! isMobileViewport && areas.preview && (\n\t\t\t\t\t\t<div className=\"edit-site-layout__canvas-container\">\n\t\t\t\t\t\t\t{ canvasResizer }\n\t\t\t\t\t\t\t{ !! canvasSize.width && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'edit-site-layout__canvas',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'is-right-aligned':\n\t\t\t\t\t\t\t\t\t\t\t\tisResizableFrameOversized,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tref={ animationRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t\t\t\t<ResizableFrame\n\t\t\t\t\t\t\t\t\t\t\tisReady={ ! isEditorLoading }\n\t\t\t\t\t\t\t\t\t\t\tisFullWidth={ canvas === 'edit' }\n\t\t\t\t\t\t\t\t\t\t\tdefaultSize={ {\n\t\t\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\t\t\tcanvasSize.width -\n\t\t\t\t\t\t\t\t\t\t\t\t\t24 /* $canvas-padding */,\n\t\t\t\t\t\t\t\t\t\t\t\theight: canvasSize.height,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tisOversized={\n\t\t\t\t\t\t\t\t\t\t\t\tisResizableFrameOversized\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tsetIsOversized={\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsResizableFrameOversized\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tinnerContentStyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\t\t\t\t\t\tgradientValue ??\n\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<ThemeProvider\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={ CONTENT_COLOR }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ areas.preview }\n\t\t\t\t\t\t\t\t\t\t\t</ThemeProvider>\n\t\t\t\t\t\t\t\t\t\t</ResizableFrame>\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default function LayoutWithGlobalStylesProvider( props ) {\n\tconst themeColors = useMemo( getAdminThemeColors, [] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<Tooltip.Provider>\n\t\t\t\t{ /** This needs to be within the SlotFillProvider */ }\n\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t<ThemeProvider\n\t\t\t\t\tisRoot\n\t\t\t\t\tcolor={ {\n\t\t\t\t\t\tprimary: themeColors.primary,\n\t\t\t\t\t\t...CONTENT_COLOR,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ThemeProvider color={ themeColors }>\n\t\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t\t<Layout { ...props } />\n\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t</ThemeProvider>\n\t\t\t\t</ThemeProvider>\n\t\t\t</Tooltip.Provider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB,2BAA2B;AACrD;AAAA,EACC,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa;AACtB,SAAS,IAAI,eAAe;AAC5B,SAAS,UAAU,QAAQ,WAAW,eAAe;AACrD;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,eAAe,yBAAyB;AACjD,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB,SAAS,oBAAoB;AACvD,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAC1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[]
|
|
7
7
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// packages/edit-site/src/components/more-menu/welcome-guide-menu-item.jsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { useDispatch } from "@wordpress/data";
|
|
4
|
-
import {
|
|
4
|
+
import { privateApis as editorPrivateApis } from "@wordpress/editor";
|
|
5
5
|
import { store as preferencesStore } from "@wordpress/preferences";
|
|
6
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var { MoreMenuItem } = unlock(editorPrivateApis);
|
|
7
9
|
function WelcomeGuideMenuItem() {
|
|
8
10
|
const { toggle } = useDispatch(preferencesStore);
|
|
9
|
-
return /* @__PURE__ */ jsx(
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
MoreMenuItem,
|
|
13
|
+
{
|
|
14
|
+
onClick: () => toggle("core/edit-site", "welcomeGuide"),
|
|
15
|
+
children: __("Welcome Guide")
|
|
16
|
+
}
|
|
17
|
+
);
|
|
10
18
|
}
|
|
11
19
|
export {
|
|
12
20
|
WelcomeGuideMenuItem as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/more-menu/welcome-guide-menu-item.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { unlock } from '../../lock-unlock';\n\nconst { MoreMenuItem } = unlock( editorPrivateApis );\n\nexport default function WelcomeGuideMenuItem() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\treturn (\n\t\t<MoreMenuItem\n\t\t\tonClick={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }\n\t\t>\n\t\t\t{ __( 'Welcome Guide' ) }\n\t\t</MoreMenuItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,eAAe,yBAAyB;AACjD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAQrB;AANF,IAAM,EAAE,aAAa,IAAI,OAAQ,iBAAkB;AAEpC,SAAR,uBAAwC;AAC9C,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AAEjD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM,OAAQ,kBAAkB,cAAe;AAAA,MAEvD,aAAI,eAAgB;AAAA;AAAA,EACvB;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,49 +1,16 @@
|
|
|
1
1
|
// packages/edit-site/src/components/page-templates/fields.jsx
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
Icon as WCIcon,
|
|
5
|
-
__experimentalHStack as HStack,
|
|
6
|
-
privateApis as componentsPrivateApis
|
|
7
|
-
} from "@wordpress/components";
|
|
8
|
-
import { __, _x } from "@wordpress/i18n";
|
|
9
|
-
import { useState, useMemo } from "@wordpress/element";
|
|
10
|
-
import { decodeEntities } from "@wordpress/html-entities";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { useMemo } from "@wordpress/element";
|
|
11
4
|
import { parse } from "@wordpress/blocks";
|
|
12
5
|
import { BlockPreview } from "@wordpress/block-editor";
|
|
13
6
|
import {
|
|
14
7
|
EditorProvider,
|
|
15
8
|
privateApis as editorPrivateApis
|
|
16
9
|
} from "@wordpress/editor";
|
|
17
|
-
import {
|
|
18
|
-
privateApis as corePrivateApis,
|
|
19
|
-
store as coreStore
|
|
20
|
-
} from "@wordpress/core-data";
|
|
21
|
-
import { useSelect } from "@wordpress/data";
|
|
22
|
-
import { useAddedBy } from "./hooks.mjs";
|
|
23
|
-
import { useDefaultTemplateTypes } from "../add-new-template/utils.mjs";
|
|
24
10
|
import usePatternSettings from "../page-patterns/use-pattern-settings.mjs";
|
|
25
11
|
import { unlock } from "../../lock-unlock.mjs";
|
|
26
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
-
var { Badge: WCBadge } = unlock(componentsPrivateApis);
|
|
28
|
-
var { useEntityRecordsWithPermissions } = unlock(corePrivateApis);
|
|
29
13
|
var { useStyle } = unlock(editorPrivateApis);
|
|
30
|
-
function useAllDefaultTemplateTypes() {
|
|
31
|
-
const defaultTemplateTypes = useDefaultTemplateTypes();
|
|
32
|
-
const { records: staticRecords } = useEntityRecordsWithPermissions(
|
|
33
|
-
"root",
|
|
34
|
-
"registeredTemplate"
|
|
35
|
-
);
|
|
36
|
-
return [
|
|
37
|
-
...defaultTemplateTypes,
|
|
38
|
-
...staticRecords?.filter((record) => !record.is_custom).map((record) => {
|
|
39
|
-
return {
|
|
40
|
-
slug: record.slug,
|
|
41
|
-
title: record.title.rendered,
|
|
42
|
-
description: record.description
|
|
43
|
-
};
|
|
44
|
-
})
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
14
|
function PreviewField({ item }) {
|
|
48
15
|
const settings = usePatternSettings();
|
|
49
16
|
const backgroundColor = useStyle("color.background") ?? "white";
|
|
@@ -69,100 +36,7 @@ var previewField = {
|
|
|
69
36
|
render: PreviewField,
|
|
70
37
|
enableSorting: false
|
|
71
38
|
};
|
|
72
|
-
var descriptionField = {
|
|
73
|
-
label: __("Description"),
|
|
74
|
-
id: "description",
|
|
75
|
-
render: window?.__experimentalTemplateActivate ? function RenderDescription({ item }) {
|
|
76
|
-
const defaultTemplateTypes = useAllDefaultTemplateTypes();
|
|
77
|
-
const defaultTemplateType = defaultTemplateTypes.find(
|
|
78
|
-
(type) => type.slug === item.slug
|
|
79
|
-
);
|
|
80
|
-
return item.description ? decodeEntities(item.description) : defaultTemplateType?.description;
|
|
81
|
-
} : ({ item }) => {
|
|
82
|
-
return item.description && decodeEntities(item.description);
|
|
83
|
-
},
|
|
84
|
-
enableSorting: false,
|
|
85
|
-
enableGlobalSearch: true
|
|
86
|
-
};
|
|
87
|
-
function AuthorField({ item }) {
|
|
88
|
-
const [isImageLoaded, setIsImageLoaded] = useState(false);
|
|
89
|
-
const { text, icon, imageUrl } = useAddedBy(item.type, item.id);
|
|
90
|
-
return /* @__PURE__ */ jsxs(HStack, { alignment: "left", spacing: 0, children: [
|
|
91
|
-
imageUrl && /* @__PURE__ */ jsx(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
className: clsx("fields-controls__author-avatar", {
|
|
95
|
-
"is-loaded": isImageLoaded
|
|
96
|
-
}),
|
|
97
|
-
children: /* @__PURE__ */ jsx(
|
|
98
|
-
"img",
|
|
99
|
-
{
|
|
100
|
-
onLoad: () => setIsImageLoaded(true),
|
|
101
|
-
alt: "",
|
|
102
|
-
src: imageUrl
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
),
|
|
107
|
-
!imageUrl && /* @__PURE__ */ jsx("div", { className: "fields-controls__author-icon", children: /* @__PURE__ */ jsx(WCIcon, { icon }) }),
|
|
108
|
-
/* @__PURE__ */ jsx("span", { className: "fields-controls__author-name", children: text })
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
var authorField = {
|
|
112
|
-
label: __("Author"),
|
|
113
|
-
id: "author",
|
|
114
|
-
getValue: ({ item }) => item.author_text ?? item.author,
|
|
115
|
-
render: AuthorField
|
|
116
|
-
};
|
|
117
|
-
var activeField = {
|
|
118
|
-
label: __("Status"),
|
|
119
|
-
id: "active",
|
|
120
|
-
type: "boolean",
|
|
121
|
-
getValue: ({ item }) => item._isActive,
|
|
122
|
-
render: function Render({ item }) {
|
|
123
|
-
const activeLabel = item._isCustom ? _x("Active when used", "template") : _x("Active", "template");
|
|
124
|
-
const activeIntent = item._isCustom ? "info" : "success";
|
|
125
|
-
const isActive = item._isActive;
|
|
126
|
-
return /* @__PURE__ */ jsx(WCBadge, { intent: isActive ? activeIntent : "default", children: isActive ? activeLabel : _x("Inactive", "template") });
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var useThemeField = () => {
|
|
130
|
-
const activeTheme = useSelect(
|
|
131
|
-
(select) => select(coreStore).getCurrentTheme()
|
|
132
|
-
);
|
|
133
|
-
return useMemo(
|
|
134
|
-
() => ({
|
|
135
|
-
label: __("Compatible Theme"),
|
|
136
|
-
id: "theme",
|
|
137
|
-
getValue: ({ item }) => item.theme,
|
|
138
|
-
render: function Render3({ item }) {
|
|
139
|
-
if (item.theme === activeTheme.stylesheet) {
|
|
140
|
-
return /* @__PURE__ */ jsx(WCBadge, { intent: "success", children: item.theme });
|
|
141
|
-
}
|
|
142
|
-
return /* @__PURE__ */ jsx(WCBadge, { intent: "error", children: item.theme });
|
|
143
|
-
}
|
|
144
|
-
}),
|
|
145
|
-
[activeTheme]
|
|
146
|
-
);
|
|
147
|
-
};
|
|
148
|
-
var slugField = {
|
|
149
|
-
label: __("Template Type"),
|
|
150
|
-
id: "slug",
|
|
151
|
-
getValue: ({ item }) => item.slug,
|
|
152
|
-
render: function Render2({ item }) {
|
|
153
|
-
const defaultTemplateTypes = useAllDefaultTemplateTypes();
|
|
154
|
-
const defaultTemplateType = defaultTemplateTypes.find(
|
|
155
|
-
(type) => type.slug === item.slug
|
|
156
|
-
);
|
|
157
|
-
return defaultTemplateType?.title || _x("Custom", "template type");
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
39
|
export {
|
|
161
|
-
|
|
162
|
-
authorField,
|
|
163
|
-
descriptionField,
|
|
164
|
-
previewField,
|
|
165
|
-
slugField,
|
|
166
|
-
useThemeField
|
|
40
|
+
previewField
|
|
167
41
|
};
|
|
168
42
|
//# sourceMappingURL=fields.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/fields.jsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tEditorProvider,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { useStyle } = unlock( editorPrivateApis );\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst backgroundColor = useStyle( 'color.background' ) ?? 'white';\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AACP,OAAO,wBAAwB;AAC/B,SAAS,cAAc;AAqBpB,SAOG,KAPH;AAnBH,IAAM,EAAE,SAAS,IAAI,OAAQ,iBAAkB;AAE/C,SAAS,aAAc,EAAE,KAAK,GAAI;AACjC,QAAM,WAAW,mBAAmB;AACpC,QAAM,kBAAkB,SAAU,kBAAmB,KAAK;AAC1D,QAAM,SAAS,QAAS,MAAM;AAC7B,WAAO,MAAO,KAAK,QAAQ,GAAI;AAAA,EAChC,GAAG,CAAE,KAAK,QAAQ,GAAI,CAAE;AAExB,QAAM,UAAU,CAAE,QAAQ;AAQ1B,SACC,oBAAC,kBAAe,MAAO,MAAO,UAC7B;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,EAAE,gBAAgB;AAAA,MAExB;AAAA,mBAAW,GAAI,gBAAiB;AAAA,QAChC,CAAE,WACH,oBAAC,aAAa,OAAb,EACA,8BAAC,gBAAa,QAAkB,GACjC;AAAA;AAAA;AAAA,EAEF,GACD;AAEF;AAEO,IAAM,eAAe;AAAA,EAC3B,OAAO,GAAI,SAAU;AAAA,EACrB,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,eAAe;AAChB;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|