@wordpress/edit-post 8.43.1-next.v.202604091042.0 → 8.45.1-next.v.202604201441.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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.45.0-next.0 (2026-04-20)
6
+
7
+ ### Enhancements
8
+
9
+ - Use `--wpds-cursor-control` for interactive cursor styling. [#77360](https://github.com/WordPress/gutenberg/pull/77360)
10
+
11
+ ## 8.44.0 (2026-04-15)
12
+
5
13
  ## 8.43.0 (2026-04-01)
6
14
 
7
15
  ## 8.42.0 (2026-03-18)
@@ -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\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"],
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\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
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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A,EAAW;AAAA,cACZ,4CAAC,uCAAsB;AAAA,cACvB,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
  }
@@ -29,10 +29,15 @@ var import_element = require("@wordpress/element");
29
29
  var import_store = require("../../store/index.cjs");
30
30
  var import_lock_unlock = require("../../lock-unlock.cjs");
31
31
  var useMetaBoxInitialization = (enabled) => {
32
- const { isEnabledAndEditorReady, isCollaborationEnabled } = (0, import_data.useSelect)(
32
+ const {
33
+ isEnabledAndEditorReady,
34
+ isCollaborationEnabled,
35
+ hasIncompatibleMetaBoxes
36
+ } = (0, import_data.useSelect)(
33
37
  (select) => ({
34
38
  isEnabledAndEditorReady: enabled && select(import_editor.store).__unstableIsEditorReady(),
35
- isCollaborationEnabled: select(import_editor.store).isCollaborationEnabledForCurrentPost()
39
+ isCollaborationEnabled: select(import_editor.store).isCollaborationEnabledForCurrentPost(),
40
+ hasIncompatibleMetaBoxes: enabled ? select(import_store.store).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false
36
41
  }),
37
42
  [enabled]
38
43
  );
@@ -41,7 +46,7 @@ var useMetaBoxInitialization = (enabled) => {
41
46
  (0, import_element.useEffect)(() => {
42
47
  if (isEnabledAndEditorReady) {
43
48
  initializeMetaBoxes();
44
- if (isCollaborationEnabled) {
49
+ if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
45
50
  setCollaborationSupported(false);
46
51
  }
47
52
  }
@@ -49,7 +54,8 @@ var useMetaBoxInitialization = (enabled) => {
49
54
  isEnabledAndEditorReady,
50
55
  initializeMetaBoxes,
51
56
  isCollaborationEnabled,
52
- setCollaborationSupported
57
+ setCollaborationSupported,
58
+ hasIncompatibleMetaBoxes
53
59
  ]);
54
60
  };
55
61
  // Annotate the CommonJS export names for ESM import in node:
@@ -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 { 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"]
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 {\n\t\tisEnabledAndEditorReady,\n\t\tisCollaborationEnabled,\n\t\thasIncompatibleMetaBoxes,\n\t} = 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\thasIncompatibleMetaBoxes: enabled\n\t\t\t\t? select( editPostStore )\n\t\t\t\t\t\t.getAllMetaBoxes()\n\t\t\t\t\t\t.some( ( metaBox ) => ! metaBox.__rtc_compatible )\n\t\t\t\t: false,\n\t\t} ),\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\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 incompatible meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {\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\thasIncompatibleMetaBoxes,\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;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,YAAc;AAAA,MACf,yBACC,WAAW,OAAQ,cAAAA,KAAY,EAAE,wBAAwB;AAAA,MAC1D,wBACC,OAAQ,cAAAA,KAAY,EAAE,qCAAqC;AAAA,MAC5D,0BAA0B,UACvB,OAAQ,aAAAC,KAAc,EACrB,gBAAgB,EAChB,KAAM,CAAE,YAAa,CAAE,QAAQ,gBAAiB,IACjD;AAAA,IACJ;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,QAAI,+BAAQ,yBAAa,iBAAAC,KAAU,CAAE;AACvE,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAD,KAAc;AAI3D,gCAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,0BAA0B,0BAA2B;AACzD,kCAA2B,KAAM;AAAA,MAClC;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
+ "names": ["editorStore", "editPostStore", "coreStore"]
7
7
  }
@@ -43,7 +43,10 @@ function mergeMetaboxes(metaboxes = [], newMetaboxes) {
43
43
  (box) => box.id === metabox.id
44
44
  );
45
45
  if (existing !== -1) {
46
- mergedMetaboxes[existing] = metabox;
46
+ mergedMetaboxes[existing] = {
47
+ ...mergedMetaboxes[existing],
48
+ ...metabox
49
+ };
47
50
  } else {
48
51
  mergedMetaboxes.push(metabox);
49
52
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = metabox;\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,IAC/B,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,gBAAY,6BAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = {\n\t\t\t\t...mergedMetaboxes[ existing ],\n\t\t\t\t...metabox,\n\t\t\t};\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,QAC7B,GAAG,gBAAiB,QAAS;AAAA,QAC7B,GAAG;AAAA,MACJ;AAAA,IACD,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,gBAAY,6BAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
6
6
  "names": []
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\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"],
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\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
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;AA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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
  }
@@ -6,10 +6,15 @@ import { useEffect } from "@wordpress/element";
6
6
  import { store as editPostStore } from "../../store/index.mjs";
7
7
  import { unlock } from "../../lock-unlock.mjs";
8
8
  var useMetaBoxInitialization = (enabled) => {
9
- const { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(
9
+ const {
10
+ isEnabledAndEditorReady,
11
+ isCollaborationEnabled,
12
+ hasIncompatibleMetaBoxes
13
+ } = useSelect(
10
14
  (select) => ({
11
15
  isEnabledAndEditorReady: enabled && select(editorStore).__unstableIsEditorReady(),
12
- isCollaborationEnabled: select(editorStore).isCollaborationEnabledForCurrentPost()
16
+ isCollaborationEnabled: select(editorStore).isCollaborationEnabledForCurrentPost(),
17
+ hasIncompatibleMetaBoxes: enabled ? select(editPostStore).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false
13
18
  }),
14
19
  [enabled]
15
20
  );
@@ -18,7 +23,7 @@ var useMetaBoxInitialization = (enabled) => {
18
23
  useEffect(() => {
19
24
  if (isEnabledAndEditorReady) {
20
25
  initializeMetaBoxes();
21
- if (isCollaborationEnabled) {
26
+ if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
22
27
  setCollaborationSupported(false);
23
28
  }
24
29
  }
@@ -26,7 +31,8 @@ var useMetaBoxInitialization = (enabled) => {
26
31
  isEnabledAndEditorReady,
27
32
  initializeMetaBoxes,
28
33
  isCollaborationEnabled,
29
- setCollaborationSupported
34
+ setCollaborationSupported,
35
+ hasIncompatibleMetaBoxes
30
36
  ]);
31
37
  };
32
38
  export {
@@ -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 { 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;",
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 {\n\t\tisEnabledAndEditorReady,\n\t\tisCollaborationEnabled,\n\t\thasIncompatibleMetaBoxes,\n\t} = 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\thasIncompatibleMetaBoxes: enabled\n\t\t\t\t? select( editPostStore )\n\t\t\t\t\t\t.getAllMetaBoxes()\n\t\t\t\t\t\t.some( ( metaBox ) => ! metaBox.__rtc_compatible )\n\t\t\t\t: false,\n\t\t} ),\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\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 incompatible meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {\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\thasIncompatibleMetaBoxes,\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;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,YAAc;AAAA,MACf,yBACC,WAAW,OAAQ,WAAY,EAAE,wBAAwB;AAAA,MAC1D,wBACC,OAAQ,WAAY,EAAE,qCAAqC;AAAA,MAC5D,0BAA0B,UACvB,OAAQ,aAAc,EACrB,gBAAgB,EAChB,KAAM,CAAE,YAAa,CAAE,QAAQ,gBAAiB,IACjD;AAAA,IACJ;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,IAAI,OAAQ,YAAa,SAAU,CAAE;AACvE,QAAM,EAAE,oBAAoB,IAAI,YAAa,aAAc;AAI3D,YAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,0BAA0B,0BAA2B;AACzD,kCAA2B,KAAM;AAAA,MAClC;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -18,7 +18,10 @@ function mergeMetaboxes(metaboxes = [], newMetaboxes) {
18
18
  (box) => box.id === metabox.id
19
19
  );
20
20
  if (existing !== -1) {
21
- mergedMetaboxes[existing] = metabox;
21
+ mergedMetaboxes[existing] = {
22
+ ...mergedMetaboxes[existing],
23
+ ...metabox
24
+ };
22
25
  } else {
23
26
  mergedMetaboxes.push(metabox);
24
27
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = metabox;\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,IAC/B,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,YAAY,gBAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AACD,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = {\n\t\t\t\t...mergedMetaboxes[ existing ],\n\t\t\t\t...metabox,\n\t\t\t};\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,QAC7B,GAAG,gBAAiB,QAAS;AAAA,QAC7B,GAAG;AAAA,MACJ;AAAA,IACD,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,YAAY,gBAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AACD,CAAE;",
6
6
  "names": []
7
7
  }
@@ -92,9 +92,10 @@
92
92
  margin-left: auto;
93
93
  }
94
94
 
95
- html :where(.editor-styles-wrapper) {
95
+ .editor-styles-wrapper {
96
96
  padding: 8px;
97
97
  }
98
+
98
99
  html :where(.editor-styles-wrapper) .block-editor-block-list__layout.is-root-container > .wp-block[data-align=full] {
99
100
  margin-right: -8px;
100
101
  margin-left: -8px;
@@ -92,9 +92,10 @@
92
92
  margin-right: auto;
93
93
  }
94
94
 
95
- html :where(.editor-styles-wrapper) {
95
+ .editor-styles-wrapper {
96
96
  padding: 8px;
97
97
  }
98
+
98
99
  html :where(.editor-styles-wrapper) .block-editor-block-list__layout.is-root-container > .wp-block[data-align=full] {
99
100
  margin-left: -8px;
100
101
  margin-right: -8px;
@@ -109,7 +109,7 @@
109
109
  .admin-ui-page {
110
110
  display: flex;
111
111
  height: 100%;
112
- background-color: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
112
+ background-color: var(--wpds-color-bg-surface-neutral, #fcfcfc);
113
113
  color: var(--wpds-color-fg-content-neutral, #1e1e1e);
114
114
  position: relative;
115
115
  z-index: 1;
@@ -118,19 +118,19 @@
118
118
  }
119
119
 
120
120
  .admin-ui-page__header {
121
- padding: var(--wpds-dimension-padding-md, 12px) var(--wpds-dimension-padding-2xl, 24px);
122
- border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e0e0e0);
123
- background: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
121
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
122
+ border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e4e4e4);
123
+ background: var(--wpds-color-bg-surface-neutral-strong, #fff);
124
124
  position: sticky;
125
125
  top: 0;
126
126
  z-index: 1;
127
127
  }
128
128
 
129
129
  .admin-ui-page__header-title {
130
- font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
- font-size: var(--wpds-font-size-lg, 15px);
132
- font-weight: var(--wpds-font-weight-medium, 499);
133
- line-height: var(--wpds-font-line-height-lg, 28px);
130
+ font-family: var(--wpds-typography-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
+ font-size: var(--wpds-typography-font-size-lg, 15px);
132
+ font-weight: var(--wpds-typography-font-weight-medium, 499);
133
+ line-height: var(--wpds-typography-line-height-lg, 28px);
134
134
  margin: 0;
135
135
  overflow: hidden;
136
136
  text-overflow: ellipsis;
@@ -143,9 +143,9 @@
143
143
 
144
144
  .admin-ui-page__header-subtitle {
145
145
  padding-block-end: var(--wpds-dimension-padding-xs, 4px);
146
- color: var(--wpds-color-fg-content-neutral-weak, #6d6d6d);
147
- font-size: var(--wpds-font-size-md, 13px);
148
- line-height: var(--wpds-font-line-height-md, 24px);
146
+ color: var(--wpds-color-fg-content-neutral-weak, #707070);
147
+ font-size: var(--wpds-typography-font-size-md, 13px);
148
+ line-height: var(--wpds-typography-line-height-md, 24px);
149
149
  margin: 0;
150
150
  }
151
151
 
@@ -160,20 +160,6 @@
160
160
  padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
161
161
  }
162
162
 
163
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon {
164
- width: auto;
165
- padding: 0 var(--wpds-dimension-padding-xs, 4px);
166
- }
167
-
168
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon svg {
169
- display: none;
170
- }
171
-
172
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon::after {
173
- content: attr(aria-label);
174
- font-size: var(--wpds-font-size-sm, 12px);
175
- }
176
-
177
163
  /**
178
164
  * SCSS Variables.
179
165
  *
@@ -220,10 +206,10 @@
220
206
  * These variables do not appear to be used anywhere else.
221
207
  */
222
208
  .admin-ui-breadcrumbs__list {
223
- font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
224
- font-size: var(--wpds-font-size-lg, 15px);
225
- font-weight: var(--wpds-font-weight-medium, 499);
226
- line-height: var(--wpds-font-line-height-lg, 28px);
209
+ font-family: var(--wpds-typography-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
210
+ font-size: var(--wpds-typography-font-size-lg, 15px);
211
+ font-weight: var(--wpds-typography-font-weight-medium, 499);
212
+ line-height: var(--wpds-typography-line-height-lg, 28px);
227
213
  list-style: none;
228
214
  padding: 0;
229
215
  margin: 0;
@@ -367,7 +353,7 @@
367
353
  touch-action: none;
368
354
  }
369
355
  .edit-post-meta-boxes-main__presenter > button[aria-expanded] {
370
- cursor: pointer;
356
+ cursor: var(--wpds-cursor-control, pointer);
371
357
  width: 100%;
372
358
  display: flex;
373
359
  justify-content: space-between;
@@ -109,7 +109,7 @@
109
109
  .admin-ui-page {
110
110
  display: flex;
111
111
  height: 100%;
112
- background-color: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
112
+ background-color: var(--wpds-color-bg-surface-neutral, #fcfcfc);
113
113
  color: var(--wpds-color-fg-content-neutral, #1e1e1e);
114
114
  position: relative;
115
115
  z-index: 1;
@@ -118,19 +118,19 @@
118
118
  }
119
119
 
120
120
  .admin-ui-page__header {
121
- padding: var(--wpds-dimension-padding-md, 12px) var(--wpds-dimension-padding-2xl, 24px);
122
- border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e0e0e0);
123
- background: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
121
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
122
+ border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e4e4e4);
123
+ background: var(--wpds-color-bg-surface-neutral-strong, #fff);
124
124
  position: sticky;
125
125
  top: 0;
126
126
  z-index: 1;
127
127
  }
128
128
 
129
129
  .admin-ui-page__header-title {
130
- font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
- font-size: var(--wpds-font-size-lg, 15px);
132
- font-weight: var(--wpds-font-weight-medium, 499);
133
- line-height: var(--wpds-font-line-height-lg, 28px);
130
+ font-family: var(--wpds-typography-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
+ font-size: var(--wpds-typography-font-size-lg, 15px);
132
+ font-weight: var(--wpds-typography-font-weight-medium, 499);
133
+ line-height: var(--wpds-typography-line-height-lg, 28px);
134
134
  margin: 0;
135
135
  overflow: hidden;
136
136
  text-overflow: ellipsis;
@@ -143,9 +143,9 @@
143
143
 
144
144
  .admin-ui-page__header-subtitle {
145
145
  padding-block-end: var(--wpds-dimension-padding-xs, 4px);
146
- color: var(--wpds-color-fg-content-neutral-weak, #6d6d6d);
147
- font-size: var(--wpds-font-size-md, 13px);
148
- line-height: var(--wpds-font-line-height-md, 24px);
146
+ color: var(--wpds-color-fg-content-neutral-weak, #707070);
147
+ font-size: var(--wpds-typography-font-size-md, 13px);
148
+ line-height: var(--wpds-typography-line-height-md, 24px);
149
149
  margin: 0;
150
150
  }
151
151
 
@@ -160,20 +160,6 @@
160
160
  padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
161
161
  }
162
162
 
163
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon {
164
- width: auto;
165
- padding: 0 var(--wpds-dimension-padding-xs, 4px);
166
- }
167
-
168
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon svg {
169
- display: none;
170
- }
171
-
172
- .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon::after {
173
- content: attr(aria-label);
174
- font-size: var(--wpds-font-size-sm, 12px);
175
- }
176
-
177
163
  /**
178
164
  * SCSS Variables.
179
165
  *
@@ -220,10 +206,10 @@
220
206
  * These variables do not appear to be used anywhere else.
221
207
  */
222
208
  .admin-ui-breadcrumbs__list {
223
- font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
224
- font-size: var(--wpds-font-size-lg, 15px);
225
- font-weight: var(--wpds-font-weight-medium, 499);
226
- line-height: var(--wpds-font-line-height-lg, 28px);
209
+ font-family: var(--wpds-typography-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
210
+ font-size: var(--wpds-typography-font-size-lg, 15px);
211
+ font-weight: var(--wpds-typography-font-weight-medium, 499);
212
+ line-height: var(--wpds-typography-line-height-lg, 28px);
227
213
  list-style: none;
228
214
  padding: 0;
229
215
  margin: 0;
@@ -367,7 +353,7 @@
367
353
  touch-action: none;
368
354
  }
369
355
  .edit-post-meta-boxes-main__presenter > button[aria-expanded] {
370
- cursor: pointer;
356
+ cursor: var(--wpds-cursor-control, pointer);
371
357
  width: 100%;
372
358
  display: flex;
373
359
  justify-content: space-between;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "8.43.1-next.v.202604091042.0+668146787",
3
+ "version": "8.45.1-next.v.202604201441.0+dab6d8c07",
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.43.1-next.v.202604091042.0+668146787",
52
- "@wordpress/admin-ui": "^1.11.1-next.v.202604091042.0+668146787",
53
- "@wordpress/api-fetch": "^7.43.1-next.v.202604091042.0+668146787",
54
- "@wordpress/base-styles": "^6.19.1-next.v.202604091042.0+668146787",
55
- "@wordpress/block-editor": "^15.16.1-next.v.202604091042.0+668146787",
56
- "@wordpress/block-library": "^9.43.1-next.v.202604091042.0+668146787",
57
- "@wordpress/blocks": "^15.16.1-next.v.202604091042.0+668146787",
58
- "@wordpress/commands": "^1.43.1-next.v.202604091042.0+668146787",
59
- "@wordpress/components": "^32.5.2-next.v.202604091042.0+668146787",
60
- "@wordpress/compose": "^7.43.1-next.v.202604091042.0+668146787",
61
- "@wordpress/core-data": "^7.43.2-next.v.202604091042.0+668146787",
62
- "@wordpress/data": "^10.43.1-next.v.202604091042.0+668146787",
63
- "@wordpress/deprecated": "^4.43.1-next.v.202604091042.0+668146787",
64
- "@wordpress/dom": "^4.43.1-next.v.202604091042.0+668146787",
65
- "@wordpress/editor": "^14.43.1-next.v.202604091042.0+668146787",
66
- "@wordpress/element": "^6.44.1-next.v.202604091042.0+668146787",
67
- "@wordpress/global-styles-engine": "^1.10.1-next.v.202604091042.0+668146787",
68
- "@wordpress/hooks": "^4.43.1-next.v.202604091042.0+668146787",
69
- "@wordpress/html-entities": "^4.43.1-next.v.202604091042.0+668146787",
70
- "@wordpress/i18n": "^6.17.1-next.v.202604091042.0+668146787",
71
- "@wordpress/icons": "^12.1.1-next.v.202604091042.0+668146787",
72
- "@wordpress/keyboard-shortcuts": "^5.43.1-next.v.202604091042.0+668146787",
73
- "@wordpress/keycodes": "^4.43.1-next.v.202604091042.0+668146787",
74
- "@wordpress/notices": "^5.43.1-next.v.202604091042.0+668146787",
75
- "@wordpress/plugins": "^7.43.1-next.v.202604091042.0+668146787",
76
- "@wordpress/preferences": "^4.43.1-next.v.202604091042.0+668146787",
77
- "@wordpress/private-apis": "^1.43.1-next.v.202604091042.0+668146787",
78
- "@wordpress/url": "^4.43.1-next.v.202604091042.0+668146787",
79
- "@wordpress/viewport": "^6.43.1-next.v.202604091042.0+668146787",
80
- "@wordpress/warning": "^3.43.1-next.v.202604091042.0+668146787",
81
- "@wordpress/widgets": "^4.43.1-next.v.202604091042.0+668146787",
51
+ "@wordpress/a11y": "^4.44.1-next.v.202604201441.0+dab6d8c07",
52
+ "@wordpress/admin-ui": "^1.12.1-next.v.202604201441.0+dab6d8c07",
53
+ "@wordpress/api-fetch": "^7.44.1-next.v.202604201441.0+dab6d8c07",
54
+ "@wordpress/base-styles": "^6.20.1-next.v.202604201441.0+dab6d8c07",
55
+ "@wordpress/block-editor": "^15.18.1-next.v.202604201441.0+dab6d8c07",
56
+ "@wordpress/block-library": "^9.44.1-next.v.202604201441.0+dab6d8c07",
57
+ "@wordpress/blocks": "^15.17.2-next.v.202604201441.0+dab6d8c07",
58
+ "@wordpress/commands": "^1.45.1-next.v.202604201441.0+dab6d8c07",
59
+ "@wordpress/components": "^33.0.1-next.v.202604201441.0+dab6d8c07",
60
+ "@wordpress/compose": "^7.44.1-next.v.202604201441.0+dab6d8c07",
61
+ "@wordpress/core-data": "^7.44.1-next.v.202604201441.0+dab6d8c07",
62
+ "@wordpress/data": "^10.45.1-next.v.202604201441.0+dab6d8c07",
63
+ "@wordpress/deprecated": "^4.44.1-next.v.202604201441.0+dab6d8c07",
64
+ "@wordpress/dom": "^4.44.1-next.v.202604201441.0+dab6d8c07",
65
+ "@wordpress/editor": "^14.44.1-next.v.202604201441.0+dab6d8c07",
66
+ "@wordpress/element": "^6.44.1-next.v.202604201441.0+dab6d8c07",
67
+ "@wordpress/global-styles-engine": "^1.11.1-next.v.202604201441.0+dab6d8c07",
68
+ "@wordpress/hooks": "^4.44.1-next.v.202604201441.0+dab6d8c07",
69
+ "@wordpress/html-entities": "^4.44.1-next.v.202604201441.0+dab6d8c07",
70
+ "@wordpress/i18n": "^6.17.1-next.v.202604201441.0+dab6d8c07",
71
+ "@wordpress/icons": "^12.2.1-next.v.202604201441.0+dab6d8c07",
72
+ "@wordpress/keyboard-shortcuts": "^5.44.1-next.v.202604201441.0+dab6d8c07",
73
+ "@wordpress/keycodes": "^4.44.1-next.v.202604201441.0+dab6d8c07",
74
+ "@wordpress/notices": "^5.44.1-next.v.202604201441.0+dab6d8c07",
75
+ "@wordpress/plugins": "^7.44.1-next.v.202604201441.0+dab6d8c07",
76
+ "@wordpress/preferences": "^4.44.1-next.v.202604201441.0+dab6d8c07",
77
+ "@wordpress/private-apis": "^1.44.1-next.v.202604201441.0+dab6d8c07",
78
+ "@wordpress/url": "^4.44.1-next.v.202604201441.0+dab6d8c07",
79
+ "@wordpress/viewport": "^6.44.1-next.v.202604201441.0+dab6d8c07",
80
+ "@wordpress/warning": "^3.44.1-next.v.202604201441.0+dab6d8c07",
81
+ "@wordpress/widgets": "^4.44.1-next.v.202604201441.0+dab6d8c07",
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": "73606df74f1c38a084bfa5db97205259ef817593"
92
+ "gitHead": "c788005ba4ee2a34851c1217c51602656aa7c3a6"
93
93
  }
package/src/classic.scss CHANGED
@@ -14,8 +14,11 @@
14
14
  // Themes with theme.json can control this themselves.
15
15
  // For full-wide blocks, we compensate for the base padding.
16
16
  // These margins should match the padding value above.
17
- html :where(.editor-styles-wrapper) {
17
+ .editor-styles-wrapper {
18
18
  padding: 8px;
19
+ }
20
+
21
+ html :where(.editor-styles-wrapper) {
19
22
  .block-editor-block-list__layout.is-root-container > .wp-block[data-align="full"] {
20
23
  margin-left: -8px;
21
24
  margin-right: -8px;
@@ -329,7 +329,7 @@ function MetaBoxesMain( { isLegacy } ) {
329
329
  const separator = ! isShort && (
330
330
  <>
331
331
  <Tooltip text={ __( 'Drag to resize' ) }>
332
- <button // eslint-disable-line jsx-a11y/role-supports-aria-props
332
+ <button
333
333
  ref={ separatorRef }
334
334
  role="separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
335
335
  aria-valuenow={ usedAriaValueNow }
@@ -39,7 +39,7 @@
39
39
  }
40
40
 
41
41
  > button[aria-expanded] {
42
- cursor: pointer;
42
+ cursor: var(--wpds-cursor-control);
43
43
  width: 100%;
44
44
  display: flex;
45
45
  justify-content: space-between;
@@ -0,0 +1,191 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render } from '@testing-library/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { RegistryProvider, createRegistry } from '@wordpress/data';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { useMetaBoxInitialization } from '../use-meta-box-initialization';
15
+ import { STORE_NAME } from '../../../store/constants';
16
+
17
+ // Mock unlock to be an identity function so private actions are directly accessible.
18
+ jest.mock( '../../../lock-unlock', () => ( {
19
+ unlock: ( value ) => value,
20
+ } ) );
21
+
22
+ const storeConfig = {
23
+ actions: {
24
+ forceUpdate: jest.fn( () => ( { type: 'FORCE_UPDATE' } ) ),
25
+ },
26
+ reducer: ( state = {}, action ) =>
27
+ action.type === 'FORCE_UPDATE' ? { ...state } : state,
28
+ };
29
+
30
+ const setCollaborationSupported = jest.fn( () => ( {
31
+ type: 'SET_COLLABORATION_SUPPORTED',
32
+ } ) );
33
+
34
+ const initializeMetaBoxes = jest.fn( () => ( {
35
+ type: 'META_BOXES_INITIALIZED',
36
+ } ) );
37
+
38
+ function createMockStores( {
39
+ isEditorReady = true,
40
+ isCollaborationEnabled = true,
41
+ metaBoxes = [],
42
+ } = {} ) {
43
+ return {
44
+ 'core/editor': {
45
+ ...storeConfig,
46
+ selectors: {
47
+ __unstableIsEditorReady: jest.fn( () => isEditorReady ),
48
+ isCollaborationEnabledForCurrentPost: jest.fn(
49
+ () => isCollaborationEnabled
50
+ ),
51
+ },
52
+ },
53
+ core: {
54
+ ...storeConfig,
55
+ actions: {
56
+ ...storeConfig.actions,
57
+ setCollaborationSupported,
58
+ },
59
+ },
60
+ [ STORE_NAME ]: {
61
+ ...storeConfig,
62
+ actions: {
63
+ ...storeConfig.actions,
64
+ initializeMetaBoxes,
65
+ },
66
+ selectors: {
67
+ getAllMetaBoxes: jest.fn( () => metaBoxes ),
68
+ hasMetaBoxes: jest.fn( () => metaBoxes.length > 0 ),
69
+ getActiveMetaBoxLocations: jest.fn( () =>
70
+ metaBoxes.length > 0 ? [ 'normal' ] : []
71
+ ),
72
+ },
73
+ },
74
+ };
75
+ }
76
+
77
+ function TestComponent( { enabled } ) {
78
+ useMetaBoxInitialization( enabled );
79
+ return null;
80
+ }
81
+
82
+ function renderHook( registry, enabled = true ) {
83
+ return render(
84
+ <RegistryProvider value={ registry }>
85
+ <TestComponent enabled={ enabled } />
86
+ </RegistryProvider>
87
+ );
88
+ }
89
+
90
+ describe( 'useMetaBoxInitialization', () => {
91
+ afterEach( () => {
92
+ setCollaborationSupported.mockClear();
93
+ initializeMetaBoxes.mockClear();
94
+ } );
95
+
96
+ it( 'disables collaboration when metaboxes are present', () => {
97
+ const mockStores = createMockStores( {
98
+ metaBoxes: [
99
+ { id: 'my-metabox', title: 'My Meta Box' },
100
+ { id: 'another-metabox', title: 'Another' },
101
+ ],
102
+ } );
103
+ const registry = createRegistry( mockStores );
104
+
105
+ renderHook( registry );
106
+
107
+ expect( initializeMetaBoxes ).toHaveBeenCalled();
108
+ expect( setCollaborationSupported ).toHaveBeenCalledWith( false );
109
+ } );
110
+
111
+ it( 'does not disable collaboration when all metaboxes are rtcCompatible', () => {
112
+ const mockStores = createMockStores( {
113
+ metaBoxes: [
114
+ {
115
+ id: 'my-metabox',
116
+ title: 'My Meta Box',
117
+ __rtc_compatible: true,
118
+ },
119
+ {
120
+ id: 'another-metabox',
121
+ title: 'Another',
122
+ __rtc_compatible: true,
123
+ },
124
+ ],
125
+ } );
126
+ const registry = createRegistry( mockStores );
127
+
128
+ renderHook( registry );
129
+
130
+ expect( initializeMetaBoxes ).toHaveBeenCalled();
131
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
132
+ } );
133
+
134
+ it( 'disables collaboration when some metaboxes lack rtcCompatible', () => {
135
+ const mockStores = createMockStores( {
136
+ metaBoxes: [
137
+ {
138
+ id: 'compatible-metabox',
139
+ title: 'Compatible',
140
+ __rtc_compatible: true,
141
+ },
142
+ { id: 'incompatible-metabox', title: 'Incompatible' },
143
+ ],
144
+ } );
145
+ const registry = createRegistry( mockStores );
146
+
147
+ renderHook( registry );
148
+
149
+ expect( setCollaborationSupported ).toHaveBeenCalledWith( false );
150
+ } );
151
+
152
+ it( 'does not disable collaboration when the only metabox is rtcCompatible', () => {
153
+ const mockStores = createMockStores( {
154
+ metaBoxes: [
155
+ {
156
+ id: 'compatible-metabox',
157
+ title: 'Compatible',
158
+ __rtc_compatible: true,
159
+ },
160
+ ],
161
+ } );
162
+ const registry = createRegistry( mockStores );
163
+
164
+ renderHook( registry );
165
+
166
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
167
+ } );
168
+
169
+ it( 'does not disable collaboration when there are no metaboxes', () => {
170
+ const mockStores = createMockStores( {
171
+ metaBoxes: [],
172
+ } );
173
+ const registry = createRegistry( mockStores );
174
+
175
+ renderHook( registry );
176
+
177
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
178
+ } );
179
+
180
+ it( 'does not disable collaboration when collaboration is not enabled', () => {
181
+ const mockStores = createMockStores( {
182
+ isCollaborationEnabled: false,
183
+ metaBoxes: [ { id: 'my-metabox', title: 'My Meta Box' } ],
184
+ } );
185
+ const registry = createRegistry( mockStores );
186
+
187
+ renderHook( registry );
188
+
189
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
190
+ } );
191
+ } );
@@ -18,26 +18,35 @@ import { unlock } from '../../lock-unlock';
18
18
  * @param { boolean } enabled
19
19
  */
20
20
  export const useMetaBoxInitialization = ( enabled ) => {
21
- const { isEnabledAndEditorReady, isCollaborationEnabled } = useSelect(
21
+ const {
22
+ isEnabledAndEditorReady,
23
+ isCollaborationEnabled,
24
+ hasIncompatibleMetaBoxes,
25
+ } = useSelect(
22
26
  ( select ) => ( {
23
27
  isEnabledAndEditorReady:
24
28
  enabled && select( editorStore ).__unstableIsEditorReady(),
25
29
  isCollaborationEnabled:
26
30
  select( editorStore ).isCollaborationEnabledForCurrentPost(),
31
+ hasIncompatibleMetaBoxes: enabled
32
+ ? select( editPostStore )
33
+ .getAllMetaBoxes()
34
+ .some( ( metaBox ) => ! metaBox.__rtc_compatible )
35
+ : false,
27
36
  } ),
28
37
  [ enabled ]
29
38
  );
30
39
  const { setCollaborationSupported } = unlock( useDispatch( coreStore ) );
31
-
32
40
  const { initializeMetaBoxes } = useDispatch( editPostStore );
41
+
33
42
  // The effect has to rerun when the editor is ready because initializeMetaBoxes
34
43
  // will noop until then.
35
44
  useEffect( () => {
36
45
  if ( isEnabledAndEditorReady ) {
37
46
  initializeMetaBoxes();
38
47
 
39
- // Disable real-time collaboration when legacy meta boxes are detected.
40
- if ( isCollaborationEnabled ) {
48
+ // Disable real-time collaboration when incompatible meta boxes are detected.
49
+ if ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {
41
50
  setCollaborationSupported( false );
42
51
  }
43
52
  }
@@ -46,5 +55,6 @@ export const useMetaBoxInitialization = ( enabled ) => {
46
55
  initializeMetaBoxes,
47
56
  isCollaborationEnabled,
48
57
  setCollaborationSupported,
58
+ hasIncompatibleMetaBoxes,
49
59
  ] );
50
60
  };
@@ -32,7 +32,10 @@ function mergeMetaboxes( metaboxes = [], newMetaboxes ) {
32
32
  ( box ) => box.id === metabox.id
33
33
  );
34
34
  if ( existing !== -1 ) {
35
- mergedMetaboxes[ existing ] = metabox;
35
+ mergedMetaboxes[ existing ] = {
36
+ ...mergedMetaboxes[ existing ],
37
+ ...metabox,
38
+ };
36
39
  } else {
37
40
  mergedMetaboxes.push( metabox );
38
41
  }