@wordpress/edit-post 8.40.2-next.v.202602241322.0 → 8.41.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/layout/index.cjs +1 -1
- package/build/components/layout/index.cjs.map +2 -2
- package/build/components/meta-boxes/use-meta-box-initialization.cjs +17 -3
- package/build/components/meta-boxes/use-meta-box-initialization.cjs.map +3 -3
- package/build-module/components/layout/index.mjs +1 -1
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/meta-boxes/use-meta-box-initialization.mjs +17 -3
- package/build-module/components/meta-boxes/use-meta-box-initialization.mjs.map +2 -2
- package/package.json +33 -33
- package/src/components/layout/index.js +1 -1
- package/src/components/meta-boxes/use-meta-box-initialization.js +22 -4
package/CHANGELOG.md
CHANGED
|
@@ -275,7 +275,7 @@ function MetaBoxesMain({ isLegacy }) {
|
|
|
275
275
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
276
276
|
import_admin_ui.NavigableRegion,
|
|
277
277
|
{
|
|
278
|
-
|
|
278
|
+
ariaLabel: paneLabel,
|
|
279
279
|
ref: setMainRefs,
|
|
280
280
|
className: (0, import_clsx.default)(
|
|
281
281
|
"edit-post-meta-boxes-main",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/layout/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tAutosaveMonitor,\n\tLocalAutosaveMonitor,\n\tUnsavedChangesWarning,\n\tEditorKeyboardShortcutsRegister,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getLayoutStyles } from '@wordpress/global-styles-engine';\nimport { PluginArea } from '@wordpress/plugins';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tIcon,\n\tSlotFillProvider,\n\tTooltip,\n\tVisuallyHidden,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tuseMediaQuery,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackButton from '../back-button';\nimport EditorInitialization from '../editor-initialization';\nimport EditPostKeyboardShortcuts from '../keyboard-shortcuts';\nimport InitPatternModal from '../init-pattern-modal';\nimport BrowserURL from '../browser-url';\nimport MetaBoxes from '../meta-boxes';\nimport PostEditorMoreMenu from '../more-menu';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useEditPostCommands from '../../commands/use-commands';\nimport { useShouldIframe } from './use-should-iframe';\nimport useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';\nimport { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n/** @type {{} & {useDrag: import('@use-gesture/react').useDrag}} */\nconst { useDrag } = unlock( componentsPrivateApis );\nconst { Editor, FullscreenMode } = unlock( editorPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\nconst DESIGN_POST_TYPES = [\n\t'wp_template',\n\t'wp_template_part',\n\t'wp_block',\n\t'wp_navigation',\n];\n\nfunction useEditorStyles( settings ) {\n\tconst { hasThemeStyleSupport } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasThemeStyleSupport:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'themeStyles' ),\n\t\t};\n\t}, [] );\n\n\t// Compute the default styles.\n\treturn useMemo( () => {\n\t\tconst presetStyles =\n\t\t\tsettings.styles?.filter(\n\t\t\t\t( style ) =>\n\t\t\t\t\tstyle.__unstableType && style.__unstableType !== 'theme'\n\t\t\t) ?? [];\n\n\t\tconst defaultEditorStyles = [\n\t\t\t...( settings?.defaultEditorStyles ?? [] ),\n\t\t\t...presetStyles,\n\t\t];\n\n\t\t// Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).\n\t\tconst hasThemeStyles =\n\t\t\thasThemeStyleSupport &&\n\t\t\tpresetStyles.length !== ( settings.styles?.length ?? 0 );\n\n\t\t// If theme styles are not present or displayed, ensure that\n\t\t// base layout styles are still present in the editor.\n\t\tif ( ! settings.disableLayoutStyles && ! hasThemeStyles ) {\n\t\t\tdefaultEditorStyles.push( {\n\t\t\t\tcss: getLayoutStyles( {\n\t\t\t\t\tstyle: {},\n\t\t\t\t\tselector: 'body',\n\t\t\t\t\thasBlockGapSupport: false,\n\t\t\t\t\thasFallbackGapSupport: true,\n\t\t\t\t\tfallbackGapValue: '0.5em',\n\t\t\t\t} ),\n\t\t\t} );\n\t\t}\n\n\t\treturn hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;\n\t}, [\n\t\tsettings.defaultEditorStyles,\n\t\tsettings.disableLayoutStyles,\n\t\tsettings.styles,\n\t\thasThemeStyleSupport,\n\t] );\n}\n\n/**\n * @param {Object} props\n * @param {boolean} props.isLegacy True for device previews where split view is disabled.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\taria-label={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord(\n\t\tinitialPostId,\n\t\tinitialPostType,\n\t\t'post-only'\n\t);\n\tconst isEditingTemplate = currentPostType === 'wp_template';\n\tconst {\n\t\tmode,\n\t\tisFullscreenActive,\n\t\thasResolvedMode,\n\t\thasActiveMetaboxes,\n\t\thasBlockSelected,\n\t\tshowIconLabels,\n\t\tisDistractionFree,\n\t\tshowMetaBoxes,\n\t\tisWelcomeGuideVisible,\n\t\ttemplateId,\n\t\tisDevicePreview,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { isFeatureActive, hasMetaBoxes } = select( editPostStore );\n\t\t\tconst { canUser, getPostType, getTemplateId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode = settings.supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPostType )?.viewable ?? false;\n\t\t\tconst canViewTemplate = canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst { getBlockSelectionStart, isZoomOut } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getEditorMode, getDefaultRenderingMode, getDeviceType } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst isNotDesignPostType =\n\t\t\t\t! DESIGN_POST_TYPES.includes( currentPostType );\n\t\t\tconst isDirectlyEditingPattern =\n\t\t\t\tcurrentPostType === 'wp_block' &&\n\t\t\t\t! onNavigateToPreviousEntityRecord;\n\t\t\tconst _templateId = getTemplateId( currentPostType, currentPostId );\n\t\t\tconst defaultMode = getDefaultRenderingMode( currentPostType );\n\n\t\t\treturn {\n\t\t\t\tmode: getEditorMode(),\n\t\t\t\tisFullscreenActive: isFeatureActive( 'fullscreenMode' ),\n\t\t\t\thasActiveMetaboxes: hasMetaBoxes(),\n\t\t\t\thasResolvedMode:\n\t\t\t\t\tdefaultMode === 'template-locked'\n\t\t\t\t\t\t? !! _templateId\n\t\t\t\t\t\t: defaultMode !== undefined,\n\t\t\t\thasBlockSelected: !! getBlockSelectionStart(),\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tshowMetaBoxes:\n\t\t\t\t\t( isNotDesignPostType && ! isZoomOut() ) ||\n\t\t\t\t\tisDirectlyEditingPattern,\n\t\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\t\ttemplateId:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanViewTemplate &&\n\t\t\t\t\t! isEditingTemplate\n\t\t\t\t\t\t? _templateId\n\t\t\t\t\t\t: null,\n\t\t\t\tisDevicePreview: getDeviceType() !== 'Desktop',\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcurrentPostType,\n\t\t\tcurrentPostId,\n\t\t\tisEditingTemplate,\n\t\t\tsettings.supportsTemplateMode,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );\n\n\t// Set the right context for the command palette\n\tconst commandContext = hasBlockSelected\n\t\t? 'block-selection-edit'\n\t\t: 'entity-edit';\n\tuseCommandContext( commandContext );\n\tconst styles = useEditorStyles( settings );\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\t// We need to add the show-icon-labels class to the body element so it is applied to modals.\n\tif ( showIconLabels ) {\n\t\tdocument.body.classList.add( 'show-icon-labels' );\n\t} else {\n\t\tdocument.body.classList.remove( 'show-icon-labels' );\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\n\tconst className = clsx( 'edit-post-layout', 'is-mode-' + mode, {\n\t\t'has-metaboxes': hasActiveMetaboxes,\n\t} );\n\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\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\ttrashed: 1,\n\t\t\t\t\t\t\tpost_type: items[ 0 ].type,\n\t\t\t\t\t\t\tids: items[ 0 ].id,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\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: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ) || __( '(no title)' )\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: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\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},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst backButton =\n\t\tuseViewportMatch( 'medium' ) && isFullscreenActive ? (\n\t\t\t<BackButton initialPost={ initialPost } />\n\t\t) : null;\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ErrorBoundary canCopyContent>\n\t\t\t\t<WelcomeGuide postType={ currentPostType } />\n\t\t\t\t<div\n\t\t\t\t\tclassName={ navigateRegionsProps.className }\n\t\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\t\tref={ navigateRegionsProps.ref }\n\t\t\t\t>\n\t\t\t\t\t<Editor\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tpostType={ currentPostType }\n\t\t\t\t\t\tpostId={ currentPostId }\n\t\t\t\t\t\ttemplateId={ templateId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tdisableIframe={ ! shouldIframe }\n\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t\tshowMetaBoxes && <MetaBoxes location=\"side\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t\textraContent={\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\tshowMetaBoxes && (\n\t\t\t\t\t\t\t\t<MetaBoxesMain isLegacy={ isDevicePreview } />\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\t<PostLockedModal />\n\t\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t\t<FullscreenMode isActive={ isFullscreenActive } />\n\t\t\t\t\t\t<BrowserURL />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<AutosaveMonitor />\n\t\t\t\t\t\t<LocalAutosaveMonitor />\n\t\t\t\t\t\t<EditPostKeyboardShortcuts />\n\t\t\t\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t\t\t\t<BlockKeyboardShortcuts />\n\t\t\t\t\t\t{ currentPostType === 'wp_block' && (\n\t\t\t\t\t\t\t<InitPatternModal />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<PostEditorMoreMenu />\n\t\t\t\t\t\t{ backButton }\n\t\t\t\t\t\t<SnackbarNotices className=\"edit-post-layout__snackbar\" />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,sBAAgC;AAChC,oBASO;AACP,kBAAuC;AACvC,0BAA0C;AAC1C,kCAAgC;AAChC,qBAA2B;AAC3B,kBAA4B;AAC5B,qBAMO;AACP,mBAAuC;AACvC,qBAAuD;AACvD,yBAA0C;AAC1C,sBAAmD;AACnD,2BAAuD;AACvD,iBAA6B;AAC7B,2BAA+B;AAC/B,uBAAmC;AACnC,wBAOO;AACP,qBAKO;AAKP,yBAAuB;AACvB,mCAAiC;AACjC,gCAAsC;AACtC,gCAA6B;AAC7B,yBAAuB;AACvB,wBAAsB;AACtB,uBAA+B;AAC/B,2BAAyB;AACzB,mBAAuC;AACvC,yBAAuB;AACvB,0BAAgC;AAChC,+BAAgC;AAChC,2CAAsC;AACtC,yCAAyC;AAgNvC;AA9MF,IAAM,EAAE,kBAAkB,QAAI,2BAAQ,gBAAAA,WAAoB;AAE1D,IAAM,EAAE,QAAQ,QAAI,2BAAQ,kBAAAC,WAAsB;AAClD,IAAM,EAAE,QAAQ,eAAe,QAAI,2BAAQ,cAAAC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A,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tAutosaveMonitor,\n\tLocalAutosaveMonitor,\n\tUnsavedChangesWarning,\n\tEditorKeyboardShortcutsRegister,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getLayoutStyles } from '@wordpress/global-styles-engine';\nimport { PluginArea } from '@wordpress/plugins';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tIcon,\n\tSlotFillProvider,\n\tTooltip,\n\tVisuallyHidden,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tuseMediaQuery,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackButton from '../back-button';\nimport EditorInitialization from '../editor-initialization';\nimport EditPostKeyboardShortcuts from '../keyboard-shortcuts';\nimport InitPatternModal from '../init-pattern-modal';\nimport BrowserURL from '../browser-url';\nimport MetaBoxes from '../meta-boxes';\nimport PostEditorMoreMenu from '../more-menu';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useEditPostCommands from '../../commands/use-commands';\nimport { useShouldIframe } from './use-should-iframe';\nimport useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';\nimport { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n/** @type {{} & {useDrag: import('@use-gesture/react').useDrag}} */\nconst { useDrag } = unlock( componentsPrivateApis );\nconst { Editor, FullscreenMode } = unlock( editorPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\nconst DESIGN_POST_TYPES = [\n\t'wp_template',\n\t'wp_template_part',\n\t'wp_block',\n\t'wp_navigation',\n];\n\nfunction useEditorStyles( settings ) {\n\tconst { hasThemeStyleSupport } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasThemeStyleSupport:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'themeStyles' ),\n\t\t};\n\t}, [] );\n\n\t// Compute the default styles.\n\treturn useMemo( () => {\n\t\tconst presetStyles =\n\t\t\tsettings.styles?.filter(\n\t\t\t\t( style ) =>\n\t\t\t\t\tstyle.__unstableType && style.__unstableType !== 'theme'\n\t\t\t) ?? [];\n\n\t\tconst defaultEditorStyles = [\n\t\t\t...( settings?.defaultEditorStyles ?? [] ),\n\t\t\t...presetStyles,\n\t\t];\n\n\t\t// Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).\n\t\tconst hasThemeStyles =\n\t\t\thasThemeStyleSupport &&\n\t\t\tpresetStyles.length !== ( settings.styles?.length ?? 0 );\n\n\t\t// If theme styles are not present or displayed, ensure that\n\t\t// base layout styles are still present in the editor.\n\t\tif ( ! settings.disableLayoutStyles && ! hasThemeStyles ) {\n\t\t\tdefaultEditorStyles.push( {\n\t\t\t\tcss: getLayoutStyles( {\n\t\t\t\t\tstyle: {},\n\t\t\t\t\tselector: 'body',\n\t\t\t\t\thasBlockGapSupport: false,\n\t\t\t\t\thasFallbackGapSupport: true,\n\t\t\t\t\tfallbackGapValue: '0.5em',\n\t\t\t\t} ),\n\t\t\t} );\n\t\t}\n\n\t\treturn hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;\n\t}, [\n\t\tsettings.defaultEditorStyles,\n\t\tsettings.disableLayoutStyles,\n\t\tsettings.styles,\n\t\thasThemeStyleSupport,\n\t] );\n}\n\n/**\n * @param {Object} props\n * @param {boolean} props.isLegacy True for device previews where split view is disabled.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\tariaLabel={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord(\n\t\tinitialPostId,\n\t\tinitialPostType,\n\t\t'post-only'\n\t);\n\tconst isEditingTemplate = currentPostType === 'wp_template';\n\tconst {\n\t\tmode,\n\t\tisFullscreenActive,\n\t\thasResolvedMode,\n\t\thasActiveMetaboxes,\n\t\thasBlockSelected,\n\t\tshowIconLabels,\n\t\tisDistractionFree,\n\t\tshowMetaBoxes,\n\t\tisWelcomeGuideVisible,\n\t\ttemplateId,\n\t\tisDevicePreview,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { isFeatureActive, hasMetaBoxes } = select( editPostStore );\n\t\t\tconst { canUser, getPostType, getTemplateId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode = settings.supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPostType )?.viewable ?? false;\n\t\t\tconst canViewTemplate = canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst { getBlockSelectionStart, isZoomOut } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getEditorMode, getDefaultRenderingMode, getDeviceType } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst isNotDesignPostType =\n\t\t\t\t! DESIGN_POST_TYPES.includes( currentPostType );\n\t\t\tconst isDirectlyEditingPattern =\n\t\t\t\tcurrentPostType === 'wp_block' &&\n\t\t\t\t! onNavigateToPreviousEntityRecord;\n\t\t\tconst _templateId = getTemplateId( currentPostType, currentPostId );\n\t\t\tconst defaultMode = getDefaultRenderingMode( currentPostType );\n\n\t\t\treturn {\n\t\t\t\tmode: getEditorMode(),\n\t\t\t\tisFullscreenActive: isFeatureActive( 'fullscreenMode' ),\n\t\t\t\thasActiveMetaboxes: hasMetaBoxes(),\n\t\t\t\thasResolvedMode:\n\t\t\t\t\tdefaultMode === 'template-locked'\n\t\t\t\t\t\t? !! _templateId\n\t\t\t\t\t\t: defaultMode !== undefined,\n\t\t\t\thasBlockSelected: !! getBlockSelectionStart(),\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tshowMetaBoxes:\n\t\t\t\t\t( isNotDesignPostType && ! isZoomOut() ) ||\n\t\t\t\t\tisDirectlyEditingPattern,\n\t\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\t\ttemplateId:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanViewTemplate &&\n\t\t\t\t\t! isEditingTemplate\n\t\t\t\t\t\t? _templateId\n\t\t\t\t\t\t: null,\n\t\t\t\tisDevicePreview: getDeviceType() !== 'Desktop',\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcurrentPostType,\n\t\t\tcurrentPostId,\n\t\t\tisEditingTemplate,\n\t\t\tsettings.supportsTemplateMode,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );\n\n\t// Set the right context for the command palette\n\tconst commandContext = hasBlockSelected\n\t\t? 'block-selection-edit'\n\t\t: 'entity-edit';\n\tuseCommandContext( commandContext );\n\tconst styles = useEditorStyles( settings );\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\t// We need to add the show-icon-labels class to the body element so it is applied to modals.\n\tif ( showIconLabels ) {\n\t\tdocument.body.classList.add( 'show-icon-labels' );\n\t} else {\n\t\tdocument.body.classList.remove( 'show-icon-labels' );\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\n\tconst className = clsx( 'edit-post-layout', 'is-mode-' + mode, {\n\t\t'has-metaboxes': hasActiveMetaboxes,\n\t} );\n\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\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\ttrashed: 1,\n\t\t\t\t\t\t\tpost_type: items[ 0 ].type,\n\t\t\t\t\t\t\tids: items[ 0 ].id,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\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: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ) || __( '(no title)' )\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: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\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},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst backButton =\n\t\tuseViewportMatch( 'medium' ) && isFullscreenActive ? (\n\t\t\t<BackButton initialPost={ initialPost } />\n\t\t) : null;\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ErrorBoundary canCopyContent>\n\t\t\t\t<WelcomeGuide postType={ currentPostType } />\n\t\t\t\t<div\n\t\t\t\t\tclassName={ navigateRegionsProps.className }\n\t\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\t\tref={ navigateRegionsProps.ref }\n\t\t\t\t>\n\t\t\t\t\t<Editor\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tpostType={ currentPostType }\n\t\t\t\t\t\tpostId={ currentPostId }\n\t\t\t\t\t\ttemplateId={ templateId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tdisableIframe={ ! shouldIframe }\n\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t\tshowMetaBoxes && <MetaBoxes location=\"side\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t\textraContent={\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\tshowMetaBoxes && (\n\t\t\t\t\t\t\t\t<MetaBoxesMain isLegacy={ isDevicePreview } />\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\t<PostLockedModal />\n\t\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t\t<FullscreenMode isActive={ isFullscreenActive } />\n\t\t\t\t\t\t<BrowserURL />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<AutosaveMonitor />\n\t\t\t\t\t\t<LocalAutosaveMonitor />\n\t\t\t\t\t\t<EditPostKeyboardShortcuts />\n\t\t\t\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t\t\t\t<BlockKeyboardShortcuts />\n\t\t\t\t\t\t{ currentPostType === 'wp_block' && (\n\t\t\t\t\t\t\t<InitPatternModal />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<PostEditorMoreMenu />\n\t\t\t\t\t\t{ backButton }\n\t\t\t\t\t\t<SnackbarNotices className=\"edit-post-layout__snackbar\" />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,sBAAgC;AAChC,oBASO;AACP,kBAAuC;AACvC,0BAA0C;AAC1C,kCAAgC;AAChC,qBAA2B;AAC3B,kBAA4B;AAC5B,qBAMO;AACP,mBAAuC;AACvC,qBAAuD;AACvD,yBAA0C;AAC1C,sBAAmD;AACnD,2BAAuD;AACvD,iBAA6B;AAC7B,2BAA+B;AAC/B,uBAAmC;AACnC,wBAOO;AACP,qBAKO;AAKP,yBAAuB;AACvB,mCAAiC;AACjC,gCAAsC;A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B,4CAAC,iCAAgB;AAAA,cACjB,4CAAC,sCAAqB;AAAA,cACtB,4CAAC,0BAAAC,SAAA,EAA0B;AAAA,cAC3B,4CAAC,iDAAgC;AAAA,cACjC,4CAAC,0BAAuB;AAAA,cACtB,oBAAoB,cACrB,4CAAC,0BAAAC,SAAA,EAAiB;AAAA,cAEnB,4CAAC,6BAAW,SAAU,mBAAoB;AAAA,cAC1C,4CAAC,iBAAAC,SAAA,EAAmB;AAAA,cAClB;AAAA,cACF,4CAAC,kCAAgB,WAAU,8BAA6B;AAAA;AAAA;AAAA,QACzD;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["commandsPrivateApis", "componentsPrivateApis", "editorPrivateApis", "blockLibraryPrivateApis", "editPostStore", "preferencesStore", "MetaBoxes", "clsx", "useEditPostCommands", "noticesStore", "useNavigateToEntityRecord", "coreStore", "blockEditorStore", "editorStore", "useNavigateRegions", "BackButton", "WelcomeGuide", "EditorInitialization", "BrowserURL", "EditPostKeyboardShortcuts", "InitPatternModal", "PostEditorMoreMenu"]
|
|
7
7
|
}
|
|
@@ -24,19 +24,33 @@ __export(use_meta_box_initialization_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(use_meta_box_initialization_exports);
|
|
25
25
|
var import_data = require("@wordpress/data");
|
|
26
26
|
var import_editor = require("@wordpress/editor");
|
|
27
|
+
var import_core_data = require("@wordpress/core-data");
|
|
27
28
|
var import_element = require("@wordpress/element");
|
|
28
29
|
var import_store = require("../../store/index.cjs");
|
|
30
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
29
31
|
var useMetaBoxInitialization = (enabled) => {
|
|
30
|
-
const isEnabledAndEditorReady = (0, import_data.useSelect)(
|
|
31
|
-
(select) =>
|
|
32
|
+
const { isEnabledAndEditorReady, isCollaborationEnabled } = (0, import_data.useSelect)(
|
|
33
|
+
(select) => ({
|
|
34
|
+
isEnabledAndEditorReady: enabled && select(import_editor.store).__unstableIsEditorReady(),
|
|
35
|
+
isCollaborationEnabled: select(import_editor.store).isCollaborationEnabledForCurrentPost()
|
|
36
|
+
}),
|
|
32
37
|
[enabled]
|
|
33
38
|
);
|
|
39
|
+
const { setCollaborationSupported } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_core_data.store));
|
|
34
40
|
const { initializeMetaBoxes } = (0, import_data.useDispatch)(import_store.store);
|
|
35
41
|
(0, import_element.useEffect)(() => {
|
|
36
42
|
if (isEnabledAndEditorReady) {
|
|
37
43
|
initializeMetaBoxes();
|
|
44
|
+
if (isCollaborationEnabled) {
|
|
45
|
+
setCollaborationSupported(false);
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
|
-
}, [
|
|
48
|
+
}, [
|
|
49
|
+
isEnabledAndEditorReady,
|
|
50
|
+
initializeMetaBoxes,
|
|
51
|
+
isCollaborationEnabled,
|
|
52
|
+
setCollaborationSupported
|
|
53
|
+
]);
|
|
40
54
|
};
|
|
41
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
56
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/meta-boxes/use-meta-box-initialization.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst isEnabledAndEditorReady = useSelect(\n\t\t( select )
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,oBAAqC;AACrC,qBAA0B;AAK1B,mBAAuC;
|
|
6
|
-
"names": ["editorStore", "editPostStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisEnabledAndEditorReady:\n\t\t\t\tenabled && select( editorStore ).__unstableIsEditorReady(),\n\t\t\tisCollaborationEnabled:\n\t\t\t\tselect( editorStore ).isCollaborationEnabledForCurrentPost(),\n\t\t} ),\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\n\t\t\t// Disable real-time collaboration when legacy meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled ) {\n\t\t\t\tsetCollaborationSupported( false );\n\t\t\t}\n\t\t}\n\t}, [\n\t\tisEnabledAndEditorReady,\n\t\tinitializeMetaBoxes,\n\t\tisCollaborationEnabled,\n\t\tsetCollaborationSupported,\n\t] );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,oBAAqC;AACrC,uBAAmC;AACnC,qBAA0B;AAK1B,mBAAuC;AACvC,yBAAuB;AAOhB,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM,EAAE,yBAAyB,uBAAuB,QAAI;AAAA,IAC3D,CAAE,YAAc;AAAA,MACf,yBACC,WAAW,OAAQ,cAAAA,KAAY,EAAE,wBAAwB;AAAA,MAC1D,wBACC,OAAQ,cAAAA,KAAY,EAAE,qCAAqC;AAAA,IAC7D;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,QAAI,+BAAQ,yBAAa,iBAAAC,KAAU,CAAE;AAEvE,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAC,KAAc;AAG3D,gCAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,wBAAyB;AAC7B,kCAA2B,KAAM;AAAA,MAClC;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
|
+
"names": ["editorStore", "coreStore", "editPostStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/layout/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tAutosaveMonitor,\n\tLocalAutosaveMonitor,\n\tUnsavedChangesWarning,\n\tEditorKeyboardShortcutsRegister,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getLayoutStyles } from '@wordpress/global-styles-engine';\nimport { PluginArea } from '@wordpress/plugins';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tIcon,\n\tSlotFillProvider,\n\tTooltip,\n\tVisuallyHidden,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tuseMediaQuery,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackButton from '../back-button';\nimport EditorInitialization from '../editor-initialization';\nimport EditPostKeyboardShortcuts from '../keyboard-shortcuts';\nimport InitPatternModal from '../init-pattern-modal';\nimport BrowserURL from '../browser-url';\nimport MetaBoxes from '../meta-boxes';\nimport PostEditorMoreMenu from '../more-menu';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useEditPostCommands from '../../commands/use-commands';\nimport { useShouldIframe } from './use-should-iframe';\nimport useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';\nimport { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n/** @type {{} & {useDrag: import('@use-gesture/react').useDrag}} */\nconst { useDrag } = unlock( componentsPrivateApis );\nconst { Editor, FullscreenMode } = unlock( editorPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\nconst DESIGN_POST_TYPES = [\n\t'wp_template',\n\t'wp_template_part',\n\t'wp_block',\n\t'wp_navigation',\n];\n\nfunction useEditorStyles( settings ) {\n\tconst { hasThemeStyleSupport } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasThemeStyleSupport:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'themeStyles' ),\n\t\t};\n\t}, [] );\n\n\t// Compute the default styles.\n\treturn useMemo( () => {\n\t\tconst presetStyles =\n\t\t\tsettings.styles?.filter(\n\t\t\t\t( style ) =>\n\t\t\t\t\tstyle.__unstableType && style.__unstableType !== 'theme'\n\t\t\t) ?? [];\n\n\t\tconst defaultEditorStyles = [\n\t\t\t...( settings?.defaultEditorStyles ?? [] ),\n\t\t\t...presetStyles,\n\t\t];\n\n\t\t// Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).\n\t\tconst hasThemeStyles =\n\t\t\thasThemeStyleSupport &&\n\t\t\tpresetStyles.length !== ( settings.styles?.length ?? 0 );\n\n\t\t// If theme styles are not present or displayed, ensure that\n\t\t// base layout styles are still present in the editor.\n\t\tif ( ! settings.disableLayoutStyles && ! hasThemeStyles ) {\n\t\t\tdefaultEditorStyles.push( {\n\t\t\t\tcss: getLayoutStyles( {\n\t\t\t\t\tstyle: {},\n\t\t\t\t\tselector: 'body',\n\t\t\t\t\thasBlockGapSupport: false,\n\t\t\t\t\thasFallbackGapSupport: true,\n\t\t\t\t\tfallbackGapValue: '0.5em',\n\t\t\t\t} ),\n\t\t\t} );\n\t\t}\n\n\t\treturn hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;\n\t}, [\n\t\tsettings.defaultEditorStyles,\n\t\tsettings.disableLayoutStyles,\n\t\tsettings.styles,\n\t\thasThemeStyleSupport,\n\t] );\n}\n\n/**\n * @param {Object} props\n * @param {boolean} props.isLegacy True for device previews where split view is disabled.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\taria-label={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord(\n\t\tinitialPostId,\n\t\tinitialPostType,\n\t\t'post-only'\n\t);\n\tconst isEditingTemplate = currentPostType === 'wp_template';\n\tconst {\n\t\tmode,\n\t\tisFullscreenActive,\n\t\thasResolvedMode,\n\t\thasActiveMetaboxes,\n\t\thasBlockSelected,\n\t\tshowIconLabels,\n\t\tisDistractionFree,\n\t\tshowMetaBoxes,\n\t\tisWelcomeGuideVisible,\n\t\ttemplateId,\n\t\tisDevicePreview,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { isFeatureActive, hasMetaBoxes } = select( editPostStore );\n\t\t\tconst { canUser, getPostType, getTemplateId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode = settings.supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPostType )?.viewable ?? false;\n\t\t\tconst canViewTemplate = canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst { getBlockSelectionStart, isZoomOut } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getEditorMode, getDefaultRenderingMode, getDeviceType } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst isNotDesignPostType =\n\t\t\t\t! DESIGN_POST_TYPES.includes( currentPostType );\n\t\t\tconst isDirectlyEditingPattern =\n\t\t\t\tcurrentPostType === 'wp_block' &&\n\t\t\t\t! onNavigateToPreviousEntityRecord;\n\t\t\tconst _templateId = getTemplateId( currentPostType, currentPostId );\n\t\t\tconst defaultMode = getDefaultRenderingMode( currentPostType );\n\n\t\t\treturn {\n\t\t\t\tmode: getEditorMode(),\n\t\t\t\tisFullscreenActive: isFeatureActive( 'fullscreenMode' ),\n\t\t\t\thasActiveMetaboxes: hasMetaBoxes(),\n\t\t\t\thasResolvedMode:\n\t\t\t\t\tdefaultMode === 'template-locked'\n\t\t\t\t\t\t? !! _templateId\n\t\t\t\t\t\t: defaultMode !== undefined,\n\t\t\t\thasBlockSelected: !! getBlockSelectionStart(),\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tshowMetaBoxes:\n\t\t\t\t\t( isNotDesignPostType && ! isZoomOut() ) ||\n\t\t\t\t\tisDirectlyEditingPattern,\n\t\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\t\ttemplateId:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanViewTemplate &&\n\t\t\t\t\t! isEditingTemplate\n\t\t\t\t\t\t? _templateId\n\t\t\t\t\t\t: null,\n\t\t\t\tisDevicePreview: getDeviceType() !== 'Desktop',\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcurrentPostType,\n\t\t\tcurrentPostId,\n\t\t\tisEditingTemplate,\n\t\t\tsettings.supportsTemplateMode,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );\n\n\t// Set the right context for the command palette\n\tconst commandContext = hasBlockSelected\n\t\t? 'block-selection-edit'\n\t\t: 'entity-edit';\n\tuseCommandContext( commandContext );\n\tconst styles = useEditorStyles( settings );\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\t// We need to add the show-icon-labels class to the body element so it is applied to modals.\n\tif ( showIconLabels ) {\n\t\tdocument.body.classList.add( 'show-icon-labels' );\n\t} else {\n\t\tdocument.body.classList.remove( 'show-icon-labels' );\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\n\tconst className = clsx( 'edit-post-layout', 'is-mode-' + mode, {\n\t\t'has-metaboxes': hasActiveMetaboxes,\n\t} );\n\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\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\ttrashed: 1,\n\t\t\t\t\t\t\tpost_type: items[ 0 ].type,\n\t\t\t\t\t\t\tids: items[ 0 ].id,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\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: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ) || __( '(no title)' )\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: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\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},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst backButton =\n\t\tuseViewportMatch( 'medium' ) && isFullscreenActive ? (\n\t\t\t<BackButton initialPost={ initialPost } />\n\t\t) : null;\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ErrorBoundary canCopyContent>\n\t\t\t\t<WelcomeGuide postType={ currentPostType } />\n\t\t\t\t<div\n\t\t\t\t\tclassName={ navigateRegionsProps.className }\n\t\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\t\tref={ navigateRegionsProps.ref }\n\t\t\t\t>\n\t\t\t\t\t<Editor\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tpostType={ currentPostType }\n\t\t\t\t\t\tpostId={ currentPostId }\n\t\t\t\t\t\ttemplateId={ templateId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tdisableIframe={ ! shouldIframe }\n\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t\tshowMetaBoxes && <MetaBoxes location=\"side\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t\textraContent={\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\tshowMetaBoxes && (\n\t\t\t\t\t\t\t\t<MetaBoxesMain isLegacy={ isDevicePreview } />\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\t<PostLockedModal />\n\t\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t\t<FullscreenMode isActive={ isFullscreenActive } />\n\t\t\t\t\t\t<BrowserURL />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<AutosaveMonitor />\n\t\t\t\t\t\t<LocalAutosaveMonitor />\n\t\t\t\t\t\t<EditPostKeyboardShortcuts />\n\t\t\t\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t\t\t\t<BlockKeyboardShortcuts />\n\t\t\t\t\t\t{ currentPostType === 'wp_block' && (\n\t\t\t\t\t\t\t<InitPatternModal />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<PostEditorMoreMenu />\n\t\t\t\t\t\t{ backButton }\n\t\t\t\t\t\t<SnackbarNotices className=\"edit-post-layout__snackbar\" />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB,SAAS,oBAAoB;AACvD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,eAAe,2BAA2B;AACnD,SAAS,eAAe,+BAA+B;AACvD,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,EAChC,eAAe;AAAA,OACT;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,OAAO,gBAAgB;AACvB,OAAO,0BAA0B;AACjC,OAAO,+BAA+B;AACtC,OAAO,sBAAsB;AAC7B,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,wBAAwB;AAC/B,OAAO,kBAAkB;AACzB,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AACvB,OAAO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,gBAAgB;AAAA;AAAA,IACtB,GACD;AAAA,IACA,oBAAC,kBAAe,IAAK,iBAClB;AAAA,MACD;AAAA,IACD,GACD;AAAA,KACD;AAGD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tAutosaveMonitor,\n\tLocalAutosaveMonitor,\n\tUnsavedChangesWarning,\n\tEditorKeyboardShortcutsRegister,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getLayoutStyles } from '@wordpress/global-styles-engine';\nimport { PluginArea } from '@wordpress/plugins';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tIcon,\n\tSlotFillProvider,\n\tTooltip,\n\tVisuallyHidden,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tuseMediaQuery,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackButton from '../back-button';\nimport EditorInitialization from '../editor-initialization';\nimport EditPostKeyboardShortcuts from '../keyboard-shortcuts';\nimport InitPatternModal from '../init-pattern-modal';\nimport BrowserURL from '../browser-url';\nimport MetaBoxes from '../meta-boxes';\nimport PostEditorMoreMenu from '../more-menu';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useEditPostCommands from '../../commands/use-commands';\nimport { useShouldIframe } from './use-should-iframe';\nimport useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';\nimport { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n/** @type {{} & {useDrag: import('@use-gesture/react').useDrag}} */\nconst { useDrag } = unlock( componentsPrivateApis );\nconst { Editor, FullscreenMode } = unlock( editorPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\nconst DESIGN_POST_TYPES = [\n\t'wp_template',\n\t'wp_template_part',\n\t'wp_block',\n\t'wp_navigation',\n];\n\nfunction useEditorStyles( settings ) {\n\tconst { hasThemeStyleSupport } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasThemeStyleSupport:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'themeStyles' ),\n\t\t};\n\t}, [] );\n\n\t// Compute the default styles.\n\treturn useMemo( () => {\n\t\tconst presetStyles =\n\t\t\tsettings.styles?.filter(\n\t\t\t\t( style ) =>\n\t\t\t\t\tstyle.__unstableType && style.__unstableType !== 'theme'\n\t\t\t) ?? [];\n\n\t\tconst defaultEditorStyles = [\n\t\t\t...( settings?.defaultEditorStyles ?? [] ),\n\t\t\t...presetStyles,\n\t\t];\n\n\t\t// Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).\n\t\tconst hasThemeStyles =\n\t\t\thasThemeStyleSupport &&\n\t\t\tpresetStyles.length !== ( settings.styles?.length ?? 0 );\n\n\t\t// If theme styles are not present or displayed, ensure that\n\t\t// base layout styles are still present in the editor.\n\t\tif ( ! settings.disableLayoutStyles && ! hasThemeStyles ) {\n\t\t\tdefaultEditorStyles.push( {\n\t\t\t\tcss: getLayoutStyles( {\n\t\t\t\t\tstyle: {},\n\t\t\t\t\tselector: 'body',\n\t\t\t\t\thasBlockGapSupport: false,\n\t\t\t\t\thasFallbackGapSupport: true,\n\t\t\t\t\tfallbackGapValue: '0.5em',\n\t\t\t\t} ),\n\t\t\t} );\n\t\t}\n\n\t\treturn hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;\n\t}, [\n\t\tsettings.defaultEditorStyles,\n\t\tsettings.disableLayoutStyles,\n\t\tsettings.styles,\n\t\thasThemeStyleSupport,\n\t] );\n}\n\n/**\n * @param {Object} props\n * @param {boolean} props.isLegacy True for device previews where split view is disabled.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\tariaLabel={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord(\n\t\tinitialPostId,\n\t\tinitialPostType,\n\t\t'post-only'\n\t);\n\tconst isEditingTemplate = currentPostType === 'wp_template';\n\tconst {\n\t\tmode,\n\t\tisFullscreenActive,\n\t\thasResolvedMode,\n\t\thasActiveMetaboxes,\n\t\thasBlockSelected,\n\t\tshowIconLabels,\n\t\tisDistractionFree,\n\t\tshowMetaBoxes,\n\t\tisWelcomeGuideVisible,\n\t\ttemplateId,\n\t\tisDevicePreview,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { isFeatureActive, hasMetaBoxes } = select( editPostStore );\n\t\t\tconst { canUser, getPostType, getTemplateId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode = settings.supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPostType )?.viewable ?? false;\n\t\t\tconst canViewTemplate = canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst { getBlockSelectionStart, isZoomOut } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getEditorMode, getDefaultRenderingMode, getDeviceType } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst isNotDesignPostType =\n\t\t\t\t! DESIGN_POST_TYPES.includes( currentPostType );\n\t\t\tconst isDirectlyEditingPattern =\n\t\t\t\tcurrentPostType === 'wp_block' &&\n\t\t\t\t! onNavigateToPreviousEntityRecord;\n\t\t\tconst _templateId = getTemplateId( currentPostType, currentPostId );\n\t\t\tconst defaultMode = getDefaultRenderingMode( currentPostType );\n\n\t\t\treturn {\n\t\t\t\tmode: getEditorMode(),\n\t\t\t\tisFullscreenActive: isFeatureActive( 'fullscreenMode' ),\n\t\t\t\thasActiveMetaboxes: hasMetaBoxes(),\n\t\t\t\thasResolvedMode:\n\t\t\t\t\tdefaultMode === 'template-locked'\n\t\t\t\t\t\t? !! _templateId\n\t\t\t\t\t\t: defaultMode !== undefined,\n\t\t\t\thasBlockSelected: !! getBlockSelectionStart(),\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tshowMetaBoxes:\n\t\t\t\t\t( isNotDesignPostType && ! isZoomOut() ) ||\n\t\t\t\t\tisDirectlyEditingPattern,\n\t\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\t\ttemplateId:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanViewTemplate &&\n\t\t\t\t\t! isEditingTemplate\n\t\t\t\t\t\t? _templateId\n\t\t\t\t\t\t: null,\n\t\t\t\tisDevicePreview: getDeviceType() !== 'Desktop',\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcurrentPostType,\n\t\t\tcurrentPostId,\n\t\t\tisEditingTemplate,\n\t\t\tsettings.supportsTemplateMode,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );\n\n\t// Set the right context for the command palette\n\tconst commandContext = hasBlockSelected\n\t\t? 'block-selection-edit'\n\t\t: 'entity-edit';\n\tuseCommandContext( commandContext );\n\tconst styles = useEditorStyles( settings );\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\t// We need to add the show-icon-labels class to the body element so it is applied to modals.\n\tif ( showIconLabels ) {\n\t\tdocument.body.classList.add( 'show-icon-labels' );\n\t} else {\n\t\tdocument.body.classList.remove( 'show-icon-labels' );\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\n\tconst className = clsx( 'edit-post-layout', 'is-mode-' + mode, {\n\t\t'has-metaboxes': hasActiveMetaboxes,\n\t} );\n\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\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\ttrashed: 1,\n\t\t\t\t\t\t\tpost_type: items[ 0 ].type,\n\t\t\t\t\t\t\tids: items[ 0 ].id,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\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: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ) || __( '(no title)' )\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: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\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},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst backButton =\n\t\tuseViewportMatch( 'medium' ) && isFullscreenActive ? (\n\t\t\t<BackButton initialPost={ initialPost } />\n\t\t) : null;\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ErrorBoundary canCopyContent>\n\t\t\t\t<WelcomeGuide postType={ currentPostType } />\n\t\t\t\t<div\n\t\t\t\t\tclassName={ navigateRegionsProps.className }\n\t\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\t\tref={ navigateRegionsProps.ref }\n\t\t\t\t>\n\t\t\t\t\t<Editor\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tpostType={ currentPostType }\n\t\t\t\t\t\tpostId={ currentPostId }\n\t\t\t\t\t\ttemplateId={ templateId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tdisableIframe={ ! shouldIframe }\n\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t\tshowMetaBoxes && <MetaBoxes location=\"side\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t\textraContent={\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\tshowMetaBoxes && (\n\t\t\t\t\t\t\t\t<MetaBoxesMain isLegacy={ isDevicePreview } />\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\t<PostLockedModal />\n\t\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t\t<FullscreenMode isActive={ isFullscreenActive } />\n\t\t\t\t\t\t<BrowserURL />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<AutosaveMonitor />\n\t\t\t\t\t\t<LocalAutosaveMonitor />\n\t\t\t\t\t\t<EditPostKeyboardShortcuts />\n\t\t\t\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t\t\t\t<BlockKeyboardShortcuts />\n\t\t\t\t\t\t{ currentPostType === 'wp_block' && (\n\t\t\t\t\t\t\t<InitPatternModal />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<PostEditorMoreMenu />\n\t\t\t\t\t\t{ backButton }\n\t\t\t\t\t\t<SnackbarNotices className=\"edit-post-layout__snackbar\" />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,S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AAgB,CAAE;AAAA,YAGlB,WAAY,CAAE;AAAA,YACd;AAAA,YACA,oBACC,iBAAiB,oBAAC,aAAU,UAAS,QAAO;AAAA,YAE7C,cACC,CAAE,qBACF,iBACC,oBAAC,iBAAc,UAAW,iBAAkB;AAAA,YAI9C;AAAA,kCAAC,mBAAgB;AAAA,cACjB,oBAAC,wBAAqB;AAAA,cACtB,oBAAC,kBAAe,UAAW,oBAAqB;AAAA,cAChD,oBAAC,cAAW;AAAA,cACZ,oBAAC,yBAAsB;AAAA,cACvB,oBAAC,mBAAgB;AAAA,cACjB,oBAAC,wBAAqB;AAAA,cACtB,oBAAC,6BAA0B;AAAA,cAC3B,oBAAC,mCAAgC;AAAA,cACjC,oBAAC,0BAAuB;AAAA,cACtB,oBAAoB,cACrB,oBAAC,oBAAiB;AAAA,cAEnB,oBAAC,cAAW,SAAU,mBAAoB;AAAA,cAC1C,oBAAC,sBAAmB;AAAA,cAClB;AAAA,cACF,oBAAC,mBAAgB,WAAU,8BAA6B;AAAA;AAAA;AAAA,QACzD;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
// packages/edit-post/src/components/meta-boxes/use-meta-box-initialization.js
|
|
2
2
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
3
3
|
import { store as editorStore } from "@wordpress/editor";
|
|
4
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
4
5
|
import { useEffect } from "@wordpress/element";
|
|
5
6
|
import { store as editPostStore } from "../../store/index.mjs";
|
|
7
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
6
8
|
var useMetaBoxInitialization = (enabled) => {
|
|
7
|
-
const isEnabledAndEditorReady = useSelect(
|
|
8
|
-
(select) =>
|
|
9
|
+
const { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(
|
|
10
|
+
(select) => ({
|
|
11
|
+
isEnabledAndEditorReady: enabled && select(editorStore).__unstableIsEditorReady(),
|
|
12
|
+
isCollaborationEnabled: select(editorStore).isCollaborationEnabledForCurrentPost()
|
|
13
|
+
}),
|
|
9
14
|
[enabled]
|
|
10
15
|
);
|
|
16
|
+
const { setCollaborationSupported } = unlock(useDispatch(coreStore));
|
|
11
17
|
const { initializeMetaBoxes } = useDispatch(editPostStore);
|
|
12
18
|
useEffect(() => {
|
|
13
19
|
if (isEnabledAndEditorReady) {
|
|
14
20
|
initializeMetaBoxes();
|
|
21
|
+
if (isCollaborationEnabled) {
|
|
22
|
+
setCollaborationSupported(false);
|
|
23
|
+
}
|
|
15
24
|
}
|
|
16
|
-
}, [
|
|
25
|
+
}, [
|
|
26
|
+
isEnabledAndEditorReady,
|
|
27
|
+
initializeMetaBoxes,
|
|
28
|
+
isCollaborationEnabled,
|
|
29
|
+
setCollaborationSupported
|
|
30
|
+
]);
|
|
17
31
|
};
|
|
18
32
|
export {
|
|
19
33
|
useMetaBoxInitialization
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/meta-boxes/use-meta-box-initialization.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst isEnabledAndEditorReady = useSelect(\n\t\t( select )
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,mBAAmB;AACrC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisEnabledAndEditorReady:\n\t\t\t\tenabled && select( editorStore ).__unstableIsEditorReady(),\n\t\t\tisCollaborationEnabled:\n\t\t\t\tselect( editorStore ).isCollaborationEnabledForCurrentPost(),\n\t\t} ),\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\n\t\t\t// Disable real-time collaboration when legacy meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled ) {\n\t\t\t\tsetCollaborationSupported( false );\n\t\t\t}\n\t\t}\n\t}, [\n\t\tisEnabledAndEditorReady,\n\t\tinitializeMetaBoxes,\n\t\tisCollaborationEnabled,\n\t\tsetCollaborationSupported,\n\t] );\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAOhB,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM,EAAE,yBAAyB,uBAAuB,IAAI;AAAA,IAC3D,CAAE,YAAc;AAAA,MACf,yBACC,WAAW,OAAQ,WAAY,EAAE,wBAAwB;AAAA,MAC1D,wBACC,OAAQ,WAAY,EAAE,qCAAqC;AAAA,IAC7D;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,IAAI,OAAQ,YAAa,SAAU,CAAE;AAEvE,QAAM,EAAE,oBAAoB,IAAI,YAAa,aAAc;AAG3D,YAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,wBAAyB;AAC7B,kCAA2B,KAAM;AAAA,MAClC;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.41.0",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -48,37 +48,37 @@
|
|
|
48
48
|
"postbox"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wordpress/a11y": "^4.
|
|
52
|
-
"@wordpress/admin-ui": "^1.
|
|
53
|
-
"@wordpress/api-fetch": "^7.
|
|
54
|
-
"@wordpress/base-styles": "^6.
|
|
55
|
-
"@wordpress/block-editor": "^15.
|
|
56
|
-
"@wordpress/block-library": "^9.
|
|
57
|
-
"@wordpress/blocks": "^15.
|
|
58
|
-
"@wordpress/commands": "^1.
|
|
59
|
-
"@wordpress/components": "^32.3.
|
|
60
|
-
"@wordpress/compose": "^7.
|
|
61
|
-
"@wordpress/core-data": "^7.
|
|
62
|
-
"@wordpress/data": "^10.
|
|
63
|
-
"@wordpress/deprecated": "^4.
|
|
64
|
-
"@wordpress/dom": "^4.
|
|
65
|
-
"@wordpress/editor": "^14.
|
|
66
|
-
"@wordpress/element": "^6.
|
|
67
|
-
"@wordpress/global-styles-engine": "^1.
|
|
68
|
-
"@wordpress/hooks": "^4.
|
|
69
|
-
"@wordpress/html-entities": "^4.
|
|
70
|
-
"@wordpress/i18n": "^6.
|
|
71
|
-
"@wordpress/icons": "^11.
|
|
72
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
73
|
-
"@wordpress/keycodes": "^4.
|
|
74
|
-
"@wordpress/notices": "^5.
|
|
75
|
-
"@wordpress/plugins": "^7.
|
|
76
|
-
"@wordpress/preferences": "^4.
|
|
77
|
-
"@wordpress/private-apis": "^1.
|
|
78
|
-
"@wordpress/url": "^4.
|
|
79
|
-
"@wordpress/viewport": "^6.
|
|
80
|
-
"@wordpress/warning": "^3.
|
|
81
|
-
"@wordpress/widgets": "^4.
|
|
51
|
+
"@wordpress/a11y": "^4.41.0",
|
|
52
|
+
"@wordpress/admin-ui": "^1.9.0",
|
|
53
|
+
"@wordpress/api-fetch": "^7.41.0",
|
|
54
|
+
"@wordpress/base-styles": "^6.17.0",
|
|
55
|
+
"@wordpress/block-editor": "^15.14.0",
|
|
56
|
+
"@wordpress/block-library": "^9.41.0",
|
|
57
|
+
"@wordpress/blocks": "^15.14.0",
|
|
58
|
+
"@wordpress/commands": "^1.41.0",
|
|
59
|
+
"@wordpress/components": "^32.3.0",
|
|
60
|
+
"@wordpress/compose": "^7.41.0",
|
|
61
|
+
"@wordpress/core-data": "^7.41.0",
|
|
62
|
+
"@wordpress/data": "^10.41.0",
|
|
63
|
+
"@wordpress/deprecated": "^4.41.0",
|
|
64
|
+
"@wordpress/dom": "^4.41.0",
|
|
65
|
+
"@wordpress/editor": "^14.41.0",
|
|
66
|
+
"@wordpress/element": "^6.41.0",
|
|
67
|
+
"@wordpress/global-styles-engine": "^1.8.0",
|
|
68
|
+
"@wordpress/hooks": "^4.41.0",
|
|
69
|
+
"@wordpress/html-entities": "^4.41.0",
|
|
70
|
+
"@wordpress/i18n": "^6.14.0",
|
|
71
|
+
"@wordpress/icons": "^11.8.0",
|
|
72
|
+
"@wordpress/keyboard-shortcuts": "^5.41.0",
|
|
73
|
+
"@wordpress/keycodes": "^4.41.0",
|
|
74
|
+
"@wordpress/notices": "^5.41.0",
|
|
75
|
+
"@wordpress/plugins": "^7.41.0",
|
|
76
|
+
"@wordpress/preferences": "^4.41.0",
|
|
77
|
+
"@wordpress/private-apis": "^1.41.0",
|
|
78
|
+
"@wordpress/url": "^4.41.0",
|
|
79
|
+
"@wordpress/viewport": "^6.41.0",
|
|
80
|
+
"@wordpress/warning": "^3.41.0",
|
|
81
|
+
"@wordpress/widgets": "^4.41.0",
|
|
82
82
|
"clsx": "^2.1.1",
|
|
83
83
|
"memize": "^2.1.0"
|
|
84
84
|
},
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "8bfc179b9aed74c0a6dd6e8edf7a49e40e4f87cc"
|
|
93
93
|
}
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as editorStore } from '@wordpress/editor';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
7
|
import { useEffect } from '@wordpress/element';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
12
|
import { store as editPostStore } from '../../store';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Initializes WordPress `postboxes` script and the logic for saving meta boxes.
|
|
@@ -16,17 +18,33 @@ import { store as editPostStore } from '../../store';
|
|
|
16
18
|
* @param { boolean } enabled
|
|
17
19
|
*/
|
|
18
20
|
export const useMetaBoxInitialization = ( enabled ) => {
|
|
19
|
-
const isEnabledAndEditorReady = useSelect(
|
|
20
|
-
( select ) =>
|
|
21
|
-
|
|
21
|
+
const { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(
|
|
22
|
+
( select ) => ( {
|
|
23
|
+
isEnabledAndEditorReady:
|
|
24
|
+
enabled && select( editorStore ).__unstableIsEditorReady(),
|
|
25
|
+
isCollaborationEnabled:
|
|
26
|
+
select( editorStore ).isCollaborationEnabledForCurrentPost(),
|
|
27
|
+
} ),
|
|
22
28
|
[ enabled ]
|
|
23
29
|
);
|
|
30
|
+
const { setCollaborationSupported } = unlock( useDispatch( coreStore ) );
|
|
31
|
+
|
|
24
32
|
const { initializeMetaBoxes } = useDispatch( editPostStore );
|
|
25
33
|
// The effect has to rerun when the editor is ready because initializeMetaBoxes
|
|
26
34
|
// will noop until then.
|
|
27
35
|
useEffect( () => {
|
|
28
36
|
if ( isEnabledAndEditorReady ) {
|
|
29
37
|
initializeMetaBoxes();
|
|
38
|
+
|
|
39
|
+
// Disable real-time collaboration when legacy meta boxes are detected.
|
|
40
|
+
if ( isCollaborationEnabled ) {
|
|
41
|
+
setCollaborationSupported( false );
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
|
-
}, [
|
|
44
|
+
}, [
|
|
45
|
+
isEnabledAndEditorReady,
|
|
46
|
+
initializeMetaBoxes,
|
|
47
|
+
isCollaborationEnabled,
|
|
48
|
+
setCollaborationSupported,
|
|
49
|
+
] );
|
|
32
50
|
};
|