@wordpress/edit-post 8.39.1-next.v.202602091733.0 → 8.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/commands/use-commands.cjs +1 -0
- package/build/commands/use-commands.cjs.map +2 -2
- package/build/components/layout/index.cjs +3 -10
- package/build/components/layout/index.cjs.map +2 -2
- package/build/components/layout/use-should-iframe.cjs +13 -8
- package/build/components/layout/use-should-iframe.cjs.map +2 -2
- package/build/hooks/use-navigate-to-entity-record.cjs +41 -14
- package/build/hooks/use-navigate-to-entity-record.cjs.map +3 -3
- package/build-module/commands/use-commands.mjs +1 -0
- package/build-module/commands/use-commands.mjs.map +2 -2
- package/build-module/components/layout/index.mjs +4 -12
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/layout/use-should-iframe.mjs +13 -8
- package/build-module/components/layout/use-should-iframe.mjs.map +2 -2
- package/build-module/hooks/use-navigate-to-entity-record.mjs +43 -16
- package/build-module/hooks/use-navigate-to-entity-record.mjs.map +3 -3
- package/build-style/style-rtl.css +11 -42
- package/build-style/style.css +11 -42
- package/package.json +33 -33
- package/src/commands/use-commands.js +1 -0
- package/src/components/layout/index.js +4 -11
- package/src/components/layout/style.scss +6 -14
- package/src/components/layout/use-should-iframe.js +18 -12
- package/src/hooks/use-navigate-to-entity-record.js +50 -23
package/CHANGELOG.md
CHANGED
|
@@ -41,6 +41,7 @@ function useCommands() {
|
|
|
41
41
|
name: "core/toggle-fullscreen-mode",
|
|
42
42
|
label: isFullscreen ? (0, import_i18n.__)("Exit fullscreen") : (0, import_i18n.__)("Enter fullscreen"),
|
|
43
43
|
icon: import_icons.fullscreen,
|
|
44
|
+
category: "command",
|
|
44
45
|
callback: ({ close }) => {
|
|
45
46
|
toggle("core/edit-post", "fullscreenMode");
|
|
46
47
|
close();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/use-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { fullscreen } from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useCommands() {\n\tconst { isFullscreen } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,kBAAmB;AACnB,mBAA2B;AAC3B,sBAA2B;AAC3B,yBAA0C;AAC1C,qBAAsC;AAEvB,SAAR,cAA+B;AACrC,QAAM,EAAE,aAAa,QAAI,uBAAW,CAAE,WAAY;AACjD,UAAM,EAAE,IAAI,IAAI,OAAQ,mBAAAA,KAAiB;AAEzC,WAAO;AAAA,MACN,cAAc,IAAK,kBAAkB,gBAAiB;AAAA,IACvD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,OAAO,QAAI,yBAAa,mBAAAA,KAAiB;AACjD,QAAM,EAAE,iBAAiB,QAAI,yBAAa,eAAAC,KAAa;AAEvD,kCAAY;AAAA,IACX,MAAM;AAAA,IACN,OAAO,mBACJ,gBAAI,iBAAkB,QACtB,gBAAI,kBAAmB;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,aAAQ,kBAAkB,gBAAiB;AAC3C,YAAM;AACN;AAAA,QACC,mBAAe,gBAAI,iBAAkB,QAAI,gBAAI,gBAAiB;AAAA,QAC9D;AAAA,UACC,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,WAAO,gBAAI,MAAO;AAAA,cAClB,SAAS,MAAM;AACd,uBAAQ,kBAAkB,gBAAiB;AAAA,cAC5C;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { fullscreen } from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useCommands() {\n\tconst { isFullscreen } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcategory: 'command',\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,kBAAmB;AACnB,mBAA2B;AAC3B,sBAA2B;AAC3B,yBAA0C;AAC1C,qBAAsC;AAEvB,SAAR,cAA+B;AACrC,QAAM,EAAE,aAAa,QAAI,uBAAW,CAAE,WAAY;AACjD,UAAM,EAAE,IAAI,IAAI,OAAQ,mBAAAA,KAAiB;AAEzC,WAAO;AAAA,MACN,cAAc,IAAK,kBAAkB,gBAAiB;AAAA,IACvD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,OAAO,QAAI,yBAAa,mBAAAA,KAAiB;AACjD,QAAM,EAAE,iBAAiB,QAAI,yBAAa,eAAAC,KAAa;AAEvD,kCAAY;AAAA,IACX,MAAM;AAAA,IACN,OAAO,mBACJ,gBAAI,iBAAkB,QACtB,gBAAI,kBAAmB;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,aAAQ,kBAAkB,gBAAiB;AAC3C,YAAM;AACN;AAAA,QACC,mBAAe,gBAAI,iBAAkB,QAAI,gBAAI,gBAAiB;AAAA,QAC9D;AAAA,UACC,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,WAAO,gBAAI,MAAO;AAAA,cAClB,SAAS,MAAM;AACd,uBAAQ,kBAAkB,gBAAiB;AAAA,cAC5C;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": ["preferencesStore", "noticesStore"]
|
|
7
7
|
}
|
|
@@ -304,8 +304,7 @@ function Layout({
|
|
|
304
304
|
const {
|
|
305
305
|
currentPost: { postId: currentPostId, postType: currentPostType },
|
|
306
306
|
onNavigateToEntityRecord,
|
|
307
|
-
onNavigateToPreviousEntityRecord
|
|
308
|
-
previousSelectedBlockPath
|
|
307
|
+
onNavigateToPreviousEntityRecord
|
|
309
308
|
} = (0, import_use_navigate_to_entity_record.default)(
|
|
310
309
|
initialPostId,
|
|
311
310
|
initialPostType,
|
|
@@ -480,14 +479,8 @@ function Layout({
|
|
|
480
479
|
disableIframe: !shouldIframe,
|
|
481
480
|
autoFocus: !isWelcomeGuideVisible,
|
|
482
481
|
onActionPerformed,
|
|
483
|
-
initialSelection: previousSelectedBlockPath,
|
|
484
482
|
extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_meta_boxes.default, { location: "side" }),
|
|
485
|
-
extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
486
|
-
MetaBoxesMain,
|
|
487
|
-
{
|
|
488
|
-
isLegacy: !shouldIframe || isDevicePreview
|
|
489
|
-
}
|
|
490
|
-
),
|
|
483
|
+
extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MetaBoxesMain, { isLegacy: isDevicePreview }),
|
|
491
484
|
children: [
|
|
492
485
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.PostLockedModal, {}),
|
|
493
486
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor_initialization.default, {}),
|
|
@@ -503,7 +496,7 @@ function Layout({
|
|
|
503
496
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugins.PluginArea, { onError: onPluginAreaError }),
|
|
504
497
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_more_menu.default, {}),
|
|
505
498
|
backButton,
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_notices.SnackbarNotices, { className: "edit-post-layout__snackbar" })
|
|
507
500
|
]
|
|
508
501
|
}
|
|
509
502
|
)
|
|
@@ -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\tEditorSnackbars,\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 { 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 when the editor canvas is not in an iframe.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\taria-label={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t\tpreviousSelectedBlockPath,\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\tinitialSelection={ previousSelectedBlockPath }\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\n\t\t\t\t\t\t\t\t\tisLegacy={\n\t\t\t\t\t\t\t\t\t\t! shouldIframe || isDevicePreview\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\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<EditorSnackbars />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,sBAAgC;AAChC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tAutosaveMonitor,\n\tLocalAutosaveMonitor,\n\tUnsavedChangesWarning,\n\tEditorKeyboardShortcutsRegister,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getLayoutStyles } from '@wordpress/global-styles-engine';\nimport { PluginArea } from '@wordpress/plugins';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tIcon,\n\tSlotFillProvider,\n\tTooltip,\n\tVisuallyHidden,\n\t__unstableUseNavigateRegions as useNavigateRegions,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tuseMediaQuery,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseViewportMatch,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackButton from '../back-button';\nimport EditorInitialization from '../editor-initialization';\nimport EditPostKeyboardShortcuts from '../keyboard-shortcuts';\nimport InitPatternModal from '../init-pattern-modal';\nimport BrowserURL from '../browser-url';\nimport MetaBoxes from '../meta-boxes';\nimport PostEditorMoreMenu from '../more-menu';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useEditPostCommands from '../../commands/use-commands';\nimport { useShouldIframe } from './use-should-iframe';\nimport useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';\nimport { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n/** @type {{} & {useDrag: import('@use-gesture/react').useDrag}} */\nconst { useDrag } = unlock( componentsPrivateApis );\nconst { Editor, FullscreenMode } = unlock( editorPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\nconst DESIGN_POST_TYPES = [\n\t'wp_template',\n\t'wp_template_part',\n\t'wp_block',\n\t'wp_navigation',\n];\n\nfunction useEditorStyles( settings ) {\n\tconst { hasThemeStyleSupport } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\thasThemeStyleSupport:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'themeStyles' ),\n\t\t};\n\t}, [] );\n\n\t// Compute the default styles.\n\treturn useMemo( () => {\n\t\tconst presetStyles =\n\t\t\tsettings.styles?.filter(\n\t\t\t\t( style ) =>\n\t\t\t\t\tstyle.__unstableType && style.__unstableType !== 'theme'\n\t\t\t) ?? [];\n\n\t\tconst defaultEditorStyles = [\n\t\t\t...( settings?.defaultEditorStyles ?? [] ),\n\t\t\t...presetStyles,\n\t\t];\n\n\t\t// Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).\n\t\tconst hasThemeStyles =\n\t\t\thasThemeStyleSupport &&\n\t\t\tpresetStyles.length !== ( settings.styles?.length ?? 0 );\n\n\t\t// If theme styles are not present or displayed, ensure that\n\t\t// base layout styles are still present in the editor.\n\t\tif ( ! settings.disableLayoutStyles && ! hasThemeStyles ) {\n\t\t\tdefaultEditorStyles.push( {\n\t\t\t\tcss: getLayoutStyles( {\n\t\t\t\t\tstyle: {},\n\t\t\t\t\tselector: 'body',\n\t\t\t\t\thasBlockGapSupport: false,\n\t\t\t\t\thasFallbackGapSupport: true,\n\t\t\t\t\tfallbackGapValue: '0.5em',\n\t\t\t\t} ),\n\t\t\t} );\n\t\t}\n\n\t\treturn hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;\n\t}, [\n\t\tsettings.defaultEditorStyles,\n\t\tsettings.disableLayoutStyles,\n\t\tsettings.styles,\n\t\thasThemeStyleSupport,\n\t] );\n}\n\n/**\n * @param {Object} props\n * @param {boolean} props.isLegacy True for device previews where split view is disabled.\n */\nfunction MetaBoxesMain( { isLegacy } ) {\n\tconst [ isOpen, openHeight, hasAnyVisible ] = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isMetaBoxLocationVisible } = select( editPostStore );\n\t\treturn [\n\t\t\t!! get( 'core/edit-post', 'metaBoxesMainIsOpen' ),\n\t\t\tget( 'core/edit-post', 'metaBoxesMainOpenHeight' ),\n\t\t\tisMetaBoxLocationVisible( 'normal' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'advanced' ) ||\n\t\t\t\tisMetaBoxLocationVisible( 'side' ),\n\t\t];\n\t}, [] );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst isShort = useMediaQuery( '(max-height: 549px)' );\n\n\tconst [ { min = 0, max }, setHeightConstraints ] = useState( () => ( {} ) );\n\t// Keeps the resizable area\u2019s size constraints updated taking into account\n\t// editor notices. The constraints are also used to derive the value for the\n\t// aria-valuenow attribute on the separator.\n\tconst effectSizeConstraints = useRefEffect( ( node ) => {\n\t\tconst container = node.closest(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst noticeLists = container.querySelectorAll(\n\t\t\t':scope > .components-notice-list'\n\t\t);\n\t\tconst resizeHandle = container.querySelector(\n\t\t\t'.edit-post-meta-boxes-main__presenter'\n\t\t);\n\t\tconst deriveConstraints = () => {\n\t\t\tconst fullHeight = container.offsetHeight;\n\t\t\tlet nextMax = fullHeight;\n\t\t\tfor ( const element of noticeLists ) {\n\t\t\t\tnextMax -= element.offsetHeight;\n\t\t\t}\n\t\t\tconst nextMin = resizeHandle.offsetHeight;\n\t\t\tsetHeightConstraints( { min: nextMin, max: nextMax } );\n\t\t};\n\t\tconst observer = new window.ResizeObserver( deriveConstraints );\n\t\tobserver.observe( container );\n\t\tfor ( const element of noticeLists ) {\n\t\t\tobserver.observe( element );\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [] );\n\tconst metaBoxesMainRef = useRef();\n\tconst setMainRefs = useMergeRefs( [\n\t\tmetaBoxesMainRef,\n\t\teffectSizeConstraints,\n\t] );\n\n\tconst separatorRef = useRef();\n\tconst separatorHelpId = useId();\n\n\tconst heightRef = useRef();\n\n\t/**\n\t * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.\n\t * @param {boolean} isPersistent Whether to persist the height in preferences.\n\t */\n\tconst applyHeight = ( candidateHeight = 'auto', isPersistent ) => {\n\t\tlet styleHeight;\n\t\tif ( candidateHeight === 'auto' ) {\n\t\t\tisPersistent = false; // Just in case \u2014 \u201Cauto\u201D should never persist.\n\t\t\tstyleHeight = candidateHeight;\n\t\t} else {\n\t\t\tcandidateHeight = Math.min( max, Math.max( min, candidateHeight ) );\n\t\t\theightRef.current = candidateHeight;\n\t\t\tstyleHeight = `${ candidateHeight }px`;\n\t\t}\n\t\tif ( isPersistent ) {\n\t\t\tsetPreference(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'metaBoxesMainOpenHeight',\n\t\t\t\tcandidateHeight\n\t\t\t);\n\t\t}\n\t\t// Applies imperative DOM updates only when not persisting the value\n\t\t// because otherwise it's done by the subsequent render.\n\t\telse {\n\t\t\tmetaBoxesMainRef.current.style.height = styleHeight;\n\t\t\tif ( ! isShort ) {\n\t\t\t\tseparatorRef.current.ariaValueNow =\n\t\t\t\t\tgetAriaValueNow( candidateHeight );\n\t\t\t}\n\t\t}\n\t};\n\n\t// useDrag includes keyboard support with arrow keys emulating a drag.\n\t// TODO: Support more/all keyboard interactions from the window splitter pattern:\n\t// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/\n\tconst bindDragGesture = useDrag(\n\t\t( { movement, first, last, memo, tap, args } ) => {\n\t\t\tconst pane = metaBoxesMainRef.current;\n\t\t\tconst [ , yMovement ] = movement;\n\t\t\tif ( first ) {\n\t\t\t\tpane.classList.add( 'is-resizing' );\n\t\t\t\tlet fromHeight = heightRef.current ?? pane.offsetHeight;\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t// Starts from max in case shortening the window has imposed it.\n\t\t\t\t\tif ( fromHeight > max ) {\n\t\t\t\t\t\tfromHeight = max;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfromHeight = min;\n\t\t\t\t}\n\t\t\t\tapplyHeight( fromHeight - yMovement );\n\t\t\t\treturn { fromHeight };\n\t\t\t}\n\n\t\t\tif ( ! first && ! last && ! tap ) {\n\t\t\t\tapplyHeight( memo.fromHeight - yMovement );\n\t\t\t\treturn memo;\n\t\t\t}\n\t\t\t// Here, `last === true` \u2013 it\u2019s the final event of the gesture.\n\n\t\t\tpane.classList.remove( 'is-resizing' );\n\t\t\tif ( tap ) {\n\t\t\t\tconst [ onTap ] = args;\n\t\t\t\tonTap?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextIsOpen = heightRef.current > min;\n\t\t\tpersistIsOpen( nextIsOpen );\n\t\t\t// Persists height only if still open. This is so that when closed by a drag the\n\t\t\t// prior height can be restored by the toggle button instead of having to drag\n\t\t\t// the pane open again.\n\t\t\tapplyHeight( heightRef.current, nextIsOpen );\n\t\t},\n\t\t{ keyboardDisplacement: 20, filterTaps: true }\n\t);\n\n\tif ( ! hasAnyVisible ) {\n\t\treturn;\n\t}\n\n\tconst contents = (\n\t\t<div\n\t\t\t// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.\n\t\t\tclassName=\"edit-post-layout__metaboxes edit-post-meta-boxes-main__liner\"\n\t\t\thidden={ ! isLegacy && ! isOpen }\n\t\t>\n\t\t\t<MetaBoxes location=\"normal\" />\n\t\t\t<MetaBoxes location=\"advanced\" />\n\t\t</div>\n\t);\n\n\tif ( isLegacy ) {\n\t\treturn contents;\n\t}\n\n\tconst isAutoHeight = openHeight === undefined;\n\tconst usedOpenHeight = isShort ? 'auto' : openHeight;\n\tconst usedHeight = isOpen ? usedOpenHeight : min;\n\n\tconst getAriaValueNow = ( height ) =>\n\t\tMath.round( ( ( height - min ) / ( max - min ) ) * 100 );\n\tconst usedAriaValueNow =\n\t\tmax === undefined || isAutoHeight ? 50 : getAriaValueNow( usedHeight );\n\n\tconst persistIsOpen = ( to = ! isOpen ) =>\n\t\tsetPreference( 'core/edit-post', 'metaBoxesMainIsOpen', to );\n\n\tconst paneLabel = __( 'Meta Boxes' );\n\n\t// The toggle button. It also resizes when the viewport is tall to provide\n\t// a larger hit area than the small separator button.\n\tconst toggle = (\n\t\t<button\n\t\t\taria-expanded={ isOpen }\n\t\t\t// Toggles for all clicks when short and only keyboard \u201Cclicks\u201D when\n\t\t\t// resizable because pointer input is handled by the drag gesture.\n\t\t\tonClick={ ( { detail } ) => {\n\t\t\t\tif ( isShort || ! detail ) {\n\t\t\t\t\tpersistIsOpen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t// Passes a toggle callback that the drag gesture handler calls when\n\t\t\t// it interprets the input as a click/tap.\n\t\t\t{ ...( ! isShort && bindDragGesture( persistIsOpen ) ) }\n\t\t>\n\t\t\t{ paneLabel }\n\t\t\t<Icon icon={ isOpen ? chevronUp : chevronDown } />\n\t\t</button>\n\t);\n\n\t// The separator button that provides a11y for resizing.\n\tconst separator = ! isShort && (\n\t\t<>\n\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t<button // eslint-disable-line jsx-a11y/role-supports-aria-props\n\t\t\t\t\tref={ separatorRef }\n\t\t\t\t\trole=\"separator\" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role\n\t\t\t\t\taria-valuenow={ usedAriaValueNow }\n\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\taria-describedby={ separatorHelpId }\n\t\t\t\t\t{ ...bindDragGesture() }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t\t<VisuallyHidden id={ separatorHelpId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use up and down arrow keys to resize the meta box pane.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<NavigableRegion\n\t\t\taria-label={ paneLabel }\n\t\t\tref={ setMainRefs }\n\t\t\tclassName={ clsx(\n\t\t\t\t'edit-post-meta-boxes-main',\n\t\t\t\t! isShort && 'is-resizable'\n\t\t\t) }\n\t\t\tstyle={ { height: usedHeight } }\n\t\t>\n\t\t\t<div className=\"edit-post-meta-boxes-main__presenter\">\n\t\t\t\t{ toggle }\n\t\t\t\t{ separator }\n\t\t\t</div>\n\t\t\t{ contents }\n\t\t</NavigableRegion>\n\t);\n}\n\nfunction Layout( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n} ) {\n\tuseEditPostCommands();\n\tconst shouldIframe = useShouldIframe();\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst {\n\t\tcurrentPost: { postId: currentPostId, postType: currentPostType },\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord(\n\t\tinitialPostId,\n\t\tinitialPostType,\n\t\t'post-only'\n\t);\n\tconst isEditingTemplate = currentPostType === 'wp_template';\n\tconst {\n\t\tmode,\n\t\tisFullscreenActive,\n\t\thasResolvedMode,\n\t\thasActiveMetaboxes,\n\t\thasBlockSelected,\n\t\tshowIconLabels,\n\t\tisDistractionFree,\n\t\tshowMetaBoxes,\n\t\tisWelcomeGuideVisible,\n\t\ttemplateId,\n\t\tisDevicePreview,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\t\t\tconst { isFeatureActive, hasMetaBoxes } = select( editPostStore );\n\t\t\tconst { canUser, getPostType, getTemplateId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode = settings.supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPostType )?.viewable ?? false;\n\t\t\tconst canViewTemplate = canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst { getBlockSelectionStart, isZoomOut } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tconst { getEditorMode, getDefaultRenderingMode, getDeviceType } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst isNotDesignPostType =\n\t\t\t\t! DESIGN_POST_TYPES.includes( currentPostType );\n\t\t\tconst isDirectlyEditingPattern =\n\t\t\t\tcurrentPostType === 'wp_block' &&\n\t\t\t\t! onNavigateToPreviousEntityRecord;\n\t\t\tconst _templateId = getTemplateId( currentPostType, currentPostId );\n\t\t\tconst defaultMode = getDefaultRenderingMode( currentPostType );\n\n\t\t\treturn {\n\t\t\t\tmode: getEditorMode(),\n\t\t\t\tisFullscreenActive: isFeatureActive( 'fullscreenMode' ),\n\t\t\t\thasActiveMetaboxes: hasMetaBoxes(),\n\t\t\t\thasResolvedMode:\n\t\t\t\t\tdefaultMode === 'template-locked'\n\t\t\t\t\t\t? !! _templateId\n\t\t\t\t\t\t: defaultMode !== undefined,\n\t\t\t\thasBlockSelected: !! getBlockSelectionStart(),\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tshowMetaBoxes:\n\t\t\t\t\t( isNotDesignPostType && ! isZoomOut() ) ||\n\t\t\t\t\tisDirectlyEditingPattern,\n\t\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\t\ttemplateId:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanViewTemplate &&\n\t\t\t\t\t! isEditingTemplate\n\t\t\t\t\t\t? _templateId\n\t\t\t\t\t\t: null,\n\t\t\t\tisDevicePreview: getDeviceType() !== 'Desktop',\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcurrentPostType,\n\t\t\tcurrentPostId,\n\t\t\tisEditingTemplate,\n\t\t\tsettings.supportsTemplateMode,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\tuseMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );\n\n\t// Set the right context for the command palette\n\tconst commandContext = hasBlockSelected\n\t\t? 'block-selection-edit'\n\t\t: 'entity-edit';\n\tuseCommandContext( commandContext );\n\tconst styles = useEditorStyles( settings );\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\tstyles,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t]\n\t);\n\n\t// We need to add the show-icon-labels class to the body element so it is applied to modals.\n\tif ( showIconLabels ) {\n\t\tdocument.body.classList.add( 'show-icon-labels' );\n\t} else {\n\t\tdocument.body.classList.remove( 'show-icon-labels' );\n\t}\n\n\tconst navigateRegionsProps = useNavigateRegions();\n\n\tconst className = clsx( 'edit-post-layout', 'is-mode-' + mode, {\n\t\t'has-metaboxes': hasActiveMetaboxes,\n\t} );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\ttrashed: 1,\n\t\t\t\t\t\t\tpost_type: items[ 0 ].type,\n\t\t\t\t\t\t\tids: items[ 0 ].id,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ) || __( '(no title)' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst backButton =\n\t\tuseViewportMatch( 'medium' ) && isFullscreenActive ? (\n\t\t\t<BackButton initialPost={ initialPost } />\n\t\t) : null;\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ErrorBoundary canCopyContent>\n\t\t\t\t<WelcomeGuide postType={ currentPostType } />\n\t\t\t\t<div\n\t\t\t\t\tclassName={ navigateRegionsProps.className }\n\t\t\t\t\t{ ...navigateRegionsProps }\n\t\t\t\t\tref={ navigateRegionsProps.ref }\n\t\t\t\t>\n\t\t\t\t\t<Editor\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tpostType={ currentPostType }\n\t\t\t\t\t\tpostId={ currentPostId }\n\t\t\t\t\t\ttemplateId={ templateId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tdisableIframe={ ! shouldIframe }\n\t\t\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t\tshowMetaBoxes && <MetaBoxes location=\"side\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t\textraContent={\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\tshowMetaBoxes && (\n\t\t\t\t\t\t\t\t<MetaBoxesMain isLegacy={ isDevicePreview } />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostLockedModal />\n\t\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t\t<FullscreenMode isActive={ isFullscreenActive } />\n\t\t\t\t\t\t<BrowserURL />\n\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t<AutosaveMonitor />\n\t\t\t\t\t\t<LocalAutosaveMonitor />\n\t\t\t\t\t\t<EditPostKeyboardShortcuts />\n\t\t\t\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t\t\t\t<BlockKeyboardShortcuts />\n\t\t\t\t\t\t{ currentPostType === 'wp_block' && (\n\t\t\t\t\t\t\t<InitPatternModal />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t\t\t<PostEditorMoreMenu />\n\t\t\t\t\t\t{ backButton }\n\t\t\t\t\t\t<SnackbarNotices className=\"edit-post-layout__snackbar\" />\n\t\t\t\t\t</Editor>\n\t\t\t\t</div>\n\t\t\t</ErrorBoundary>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Layout;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,sBAAgC;AAChC,oBASO;AACP,kBAAuC;AACvC,0BAA0C;AAC1C,kCAAgC;AAChC,qBAA2B;AAC3B,kBAA4B;AAC5B,qBAMO;AACP,mBAAuC;AACvC,qBAAuD;AACvD,yBAA0C;AAC1C,sBAAmD;AACnD,2BAAuD;AACvD,iBAA6B;AAC7B,2BAA+B;AAC/B,uBAAmC;AACnC,wBAOO;AACP,qBAKO;AAKP,yBAAuB;AACvB,mCAAiC;AACjC,gCAAsC;AACtC,gCAA6B;AAC7B,yBAAuB;AACvB,wBAAsB;AACtB,uBAA+B;AAC/B,2BAAyB;AACzB,mBAAuC;AACvC,yBAAuB;AACvB,0BAAgC;AAChC,+BAAgC;AAChC,2CAAsC;AACtC,yCAAyC;AAgNvC;AA9MF,IAAM,EAAE,kBAAkB,QAAI,2BAAQ,gBAAAA,WAAoB;AAE1D,IAAM,EAAE,QAAQ,QAAI,2BAAQ,kBAAAC,WAAsB;AAClD,IAAM,EAAE,QAAQ,eAAe,QAAI,2BAAQ,cAAAC,WAAkB;AAC7D,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,qBAAAC,WAAwB;AACnE,IAAM,oBAAoB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,SAAS,gBAAiB,UAAW;AACpC,QAAM,EAAE,qBAAqB,QAAI,uBAAW,CAAE,WAAY;AACzD,WAAO;AAAA,MACN,sBACC,OAAQ,aAAAC,KAAc,EAAE,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W,iBAAkB;AAAA,IAC3C;AAAA,MAAC;AAAA;AAAA,QACA,WAAY,qBAAqB;AAAA,QAC/B,GAAG;AAAA,QACL,KAAM,qBAAqB;AAAA,QAE3B;AAAA,UAAC;AAAA;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,UAAW;AAAA,YACX,QAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,cAAe;AAAA,YACf,eAAgB,CAAE;AAAA,YAGlB,WAAY,CAAE;AAAA,YACd;AAAA,YACA,oBACC,iBAAiB,4CAAC,kBAAAV,SAAA,EAAU,UAAS,QAAO;AAAA,YAE7C,cACC,CAAE,qBACF,iBACC,4CAAC,iBAAc,UAAW,iBAAkB;AAAA,YAI9C;AAAA,0DAAC,iCAAgB;AAAA,cACjB,4CAAC,6BAAAW,SAAA,EAAqB;AAAA,cACtB,4CAAC,kBAAe,UAAW,oBAAqB;AAAA,cAChD,4CAAC,mBAAAC,SAAA,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
|
}
|
|
@@ -30,17 +30,22 @@ var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
|
30
30
|
var isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;
|
|
31
31
|
function useShouldIframe() {
|
|
32
32
|
return (0, import_data.useSelect)((select) => {
|
|
33
|
-
const {
|
|
33
|
+
const { getCurrentPostType, getDeviceType } = select(import_editor.store);
|
|
34
|
+
const { getClientIdsWithDescendants, getBlockName } = select(import_block_editor.store);
|
|
35
|
+
const { getBlockType } = select(import_blocks.store);
|
|
34
36
|
return (
|
|
35
|
-
// If the
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
37
|
+
// If the Gutenberg plugin is active, we ALWAYS use the iframe for
|
|
38
|
+
// consistency across the post and site editor. We plan on enforcing
|
|
39
|
+
// the iframe in the future, so Gutenberg both serves as way for us
|
|
40
|
+
// to warn plugin developers and for plugin developers to test their
|
|
41
|
+
// blocks easily. Before GB v22.5, we only enforced it for
|
|
42
|
+
// block-based themes (classic themes used the same rules as core).
|
|
43
|
+
isGutenbergPlugin || // We also still want to iframe all the special
|
|
39
44
|
// editor features and modes such as device previews, zoom out, and
|
|
40
45
|
// template/pattern editing.
|
|
41
|
-
getDeviceType() !== "Desktop" || ["wp_template", "wp_block"].includes(getCurrentPostType()) || (0, import_lock_unlock.unlock)(select(import_block_editor.store)).isZoomOut() || // Finally, still iframe the editor if all blocks are v3
|
|
42
|
-
// they are marked as iframe-compatible).
|
|
43
|
-
|
|
46
|
+
getDeviceType() !== "Desktop" || ["wp_template", "wp_block"].includes(getCurrentPostType()) || (0, import_lock_unlock.unlock)(select(import_block_editor.store)).isZoomOut() || // Finally, still iframe the editor if all present blocks are v3
|
|
47
|
+
// (which means they are marked as iframe-compatible).
|
|
48
|
+
[...new Set(getClientIdsWithDescendants().map(getBlockName))].map(getBlockType).filter(Boolean).every((blockType) => blockType.apiVersion >= 3)
|
|
44
49
|
);
|
|
45
50
|
}, []);
|
|
46
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/layout/use-should-iframe.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport function useShouldIframe() {\n\treturn useSelect( ( select ) => {\n\t\tconst {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AACrC,kBAA0B;AAC1B,oBAAqC;AACrC,0BAA0C;AAK1C,yBAAuB;AAEvB,IAAM,oBAAoB,WAAW,sBAAsB,OAAO;AAE3D,SAAS,kBAAkB;AACjC,aAAO,uBAAW,CAAE,WAAY;AAC/B,UAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport function useShouldIframe() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getDeviceType } = select( editorStore );\n\t\tconst { getClientIdsWithDescendants, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\n\t\treturn (\n\t\t\t// If the Gutenberg plugin is active, we ALWAYS use the iframe for\n\t\t\t// consistency across the post and site editor. We plan on enforcing\n\t\t\t// the iframe in the future, so Gutenberg both serves as way for us\n\t\t\t// to warn plugin developers and for plugin developers to test their\n\t\t\t// blocks easily. Before GB v22.5, we only enforced it for\n\t\t\t// block-based themes (classic themes used the same rules as core).\n\t\t\tisGutenbergPlugin ||\n\t\t\t// We also still want to iframe all the special\n\t\t\t// editor features and modes such as device previews, zoom out, and\n\t\t\t// template/pattern editing.\n\t\t\tgetDeviceType() !== 'Desktop' ||\n\t\t\t[ 'wp_template', 'wp_block' ].includes( getCurrentPostType() ) ||\n\t\t\tunlock( select( blockEditorStore ) ).isZoomOut() ||\n\t\t\t// Finally, still iframe the editor if all present blocks are v3\n\t\t\t// (which means they are marked as iframe-compatible).\n\t\t\t[ ...new Set( getClientIdsWithDescendants().map( getBlockName ) ) ]\n\t\t\t\t.map( getBlockType )\n\t\t\t\t.filter( Boolean )\n\t\t\t\t.every( ( blockType ) => blockType.apiVersion >= 3 )\n\t\t);\n\t}, [] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AACrC,kBAA0B;AAC1B,oBAAqC;AACrC,0BAA0C;AAK1C,yBAAuB;AAEvB,IAAM,oBAAoB,WAAW,sBAAsB,OAAO;AAE3D,SAAS,kBAAkB;AACjC,aAAO,uBAAW,CAAE,WAAY;AAC/B,UAAM,EAAE,oBAAoB,cAAc,IAAI,OAAQ,cAAAA,KAAY;AAClE,UAAM,EAAE,6BAA6B,aAAa,IACjD,OAAQ,oBAAAC,KAAiB;AAC1B,UAAM,EAAE,aAAa,IAAI,OAAQ,cAAAC,KAAY;AAE7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOC;AAAA;AAAA;AAAA,MAIA,cAAc,MAAM,aACpB,CAAE,eAAe,UAAW,EAAE,SAAU,mBAAmB,CAAE,SAC7D,2BAAQ,OAAQ,oBAAAD,KAAiB,CAAE,EAAE,UAAU;AAAA;AAAA,MAG/C,CAAE,GAAG,IAAI,IAAK,4BAA4B,EAAE,IAAK,YAAa,CAAE,CAAE,EAChE,IAAK,YAAa,EAClB,OAAQ,OAAQ,EAChB,MAAO,CAAE,cAAe,UAAU,cAAc,CAAE;AAAA;AAAA,EAEtD,GAAG,CAAC,CAAE;AACP;",
|
|
6
6
|
"names": ["editorStore", "blockEditorStore", "blocksStore"]
|
|
7
7
|
}
|
|
@@ -25,18 +25,17 @@ module.exports = __toCommonJS(use_navigate_to_entity_record_exports);
|
|
|
25
25
|
var import_element = require("@wordpress/element");
|
|
26
26
|
var import_data = require("@wordpress/data");
|
|
27
27
|
var import_editor = require("@wordpress/editor");
|
|
28
|
-
var
|
|
29
|
-
var { useGenerateBlockPath } = (0, import_lock_unlock.unlock)(import_editor.privateApis);
|
|
28
|
+
var import_core_data = require("@wordpress/core-data");
|
|
30
29
|
function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
|
|
31
|
-
const
|
|
30
|
+
const registry = (0, import_data.useRegistry)();
|
|
32
31
|
const [postHistory, dispatch] = (0, import_element.useReducer)(
|
|
33
|
-
(historyState, { type, post: post2, previousRenderingMode: previousRenderingMode2,
|
|
32
|
+
(historyState, { type, post: post2, previousRenderingMode: previousRenderingMode2, selectedBlockClientId }) => {
|
|
34
33
|
if (type === "push") {
|
|
35
34
|
const updatedHistory = [...historyState];
|
|
36
35
|
const currentIndex = updatedHistory.length - 1;
|
|
37
36
|
updatedHistory[currentIndex] = {
|
|
38
37
|
...updatedHistory[currentIndex],
|
|
39
|
-
|
|
38
|
+
selectedBlockClientId
|
|
40
39
|
};
|
|
41
40
|
return [...updatedHistory, { post: post2, previousRenderingMode: previousRenderingMode2 }];
|
|
42
41
|
}
|
|
@@ -53,42 +52,70 @@ function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRender
|
|
|
53
52
|
}
|
|
54
53
|
]
|
|
55
54
|
);
|
|
56
|
-
const { post, previousRenderingMode
|
|
55
|
+
const { post, previousRenderingMode } = postHistory[postHistory.length - 1];
|
|
57
56
|
const { getRenderingMode } = (0, import_data.useSelect)(import_editor.store);
|
|
58
57
|
const { setRenderingMode } = (0, import_data.useDispatch)(import_editor.store);
|
|
58
|
+
const { editEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
|
|
59
59
|
const onNavigateToEntityRecord = (0, import_element.useCallback)(
|
|
60
60
|
(params) => {
|
|
61
|
-
const
|
|
61
|
+
const entityEdits = registry.select(import_core_data.store).getEntityRecordEdits("postType", post.postType, post.postId);
|
|
62
|
+
const externalClientId = entityEdits?.selection?.selectionStart?.clientId ?? null;
|
|
62
63
|
dispatch({
|
|
63
64
|
type: "push",
|
|
64
65
|
post: { postId: params.postId, postType: params.postType },
|
|
65
66
|
// Save the current rendering mode so we can restore it when navigating back.
|
|
66
67
|
previousRenderingMode: getRenderingMode(),
|
|
67
|
-
|
|
68
|
+
selectedBlockClientId: externalClientId
|
|
68
69
|
});
|
|
69
70
|
setRenderingMode(defaultRenderingMode);
|
|
70
71
|
},
|
|
71
72
|
[
|
|
73
|
+
registry,
|
|
74
|
+
post.postType,
|
|
75
|
+
post.postId,
|
|
72
76
|
getRenderingMode,
|
|
73
77
|
setRenderingMode,
|
|
74
|
-
defaultRenderingMode
|
|
75
|
-
generateBlockPath
|
|
78
|
+
defaultRenderingMode
|
|
76
79
|
]
|
|
77
80
|
);
|
|
78
81
|
const onNavigateToPreviousEntityRecord = (0, import_element.useCallback)(() => {
|
|
82
|
+
if (postHistory.length > 1) {
|
|
83
|
+
const previousItem = postHistory[postHistory.length - 2];
|
|
84
|
+
if (previousItem.selectedBlockClientId) {
|
|
85
|
+
editEntityRecord(
|
|
86
|
+
"postType",
|
|
87
|
+
previousItem.post.postType,
|
|
88
|
+
previousItem.post.postId,
|
|
89
|
+
{
|
|
90
|
+
selection: {
|
|
91
|
+
selectionStart: {
|
|
92
|
+
clientId: previousItem.selectedBlockClientId
|
|
93
|
+
},
|
|
94
|
+
selectionEnd: {
|
|
95
|
+
clientId: previousItem.selectedBlockClientId
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{ undoIgnore: true }
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
79
103
|
dispatch({
|
|
80
104
|
type: "pop"
|
|
81
105
|
});
|
|
82
106
|
if (previousRenderingMode) {
|
|
83
107
|
setRenderingMode(previousRenderingMode);
|
|
84
108
|
}
|
|
85
|
-
}, [
|
|
109
|
+
}, [
|
|
110
|
+
setRenderingMode,
|
|
111
|
+
previousRenderingMode,
|
|
112
|
+
postHistory,
|
|
113
|
+
editEntityRecord
|
|
114
|
+
]);
|
|
86
115
|
return {
|
|
87
116
|
currentPost: post,
|
|
88
117
|
onNavigateToEntityRecord,
|
|
89
|
-
onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : void 0
|
|
90
|
-
// Return the selected block path from the current history item
|
|
91
|
-
previousSelectedBlockPath: selectedBlockPath
|
|
118
|
+
onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : void 0
|
|
92
119
|
};
|
|
93
120
|
}
|
|
94
121
|
//# sourceMappingURL=use-navigate-to-entity-record.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-navigate-to-entity-record.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useReducer } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwC;AACxC,
|
|
6
|
-
"names": ["post", "previousRenderingMode", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useReducer } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * A hook that records the 'entity' history in the post editor as a user\n * navigates between editing a post and editing the post template or patterns.\n *\n * Implemented as a stack, so a little similar to the browser history API.\n *\n * Used to control displaying UI elements like the back button.\n *\n * @param {number} initialPostId The post id of the post when the editor loaded.\n * @param {string} initialPostType The post type of the post when the editor loaded.\n * @param {string} defaultRenderingMode The rendering mode to switch to when navigating.\n *\n * @return {Object} An object containing the `currentPost` variable and\n * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.\n */\nexport default function useNavigateToEntityRecord(\n\tinitialPostId,\n\tinitialPostType,\n\tdefaultRenderingMode\n) {\n\tconst registry = useRegistry();\n\tconst [ postHistory, dispatch ] = useReducer(\n\t\t(\n\t\t\thistoryState,\n\t\t\t{ type, post, previousRenderingMode, selectedBlockClientId }\n\t\t) => {\n\t\t\tif ( type === 'push' ) {\n\t\t\t\t// Update the current item with the selected block clientId before pushing new item\n\t\t\t\tconst updatedHistory = [ ...historyState ];\n\t\t\t\tconst currentIndex = updatedHistory.length - 1;\n\t\t\t\tupdatedHistory[ currentIndex ] = {\n\t\t\t\t\t...updatedHistory[ currentIndex ],\n\t\t\t\t\tselectedBlockClientId,\n\t\t\t\t};\n\t\t\t\treturn [ ...updatedHistory, { post, previousRenderingMode } ];\n\t\t\t}\n\t\t\tif ( type === 'pop' ) {\n\t\t\t\t// Remove the current item from history\n\t\t\t\tif ( historyState.length > 1 ) {\n\t\t\t\t\treturn historyState.slice( 0, -1 );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn historyState;\n\t\t},\n\t\t[\n\t\t\t{\n\t\t\t\tpost: { postId: initialPostId, postType: initialPostType },\n\t\t\t},\n\t\t]\n\t);\n\tconst { post, previousRenderingMode } =\n\t\tpostHistory[ postHistory.length - 1 ];\n\n\tconst { getRenderingMode } = useSelect( editorStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params ) => {\n\t\t\t// Read entity selection (already has external IDs from onChangeSelection)\n\t\t\tconst entityEdits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityRecordEdits( 'postType', post.postType, post.postId );\n\t\t\tconst externalClientId =\n\t\t\t\tentityEdits?.selection?.selectionStart?.clientId ?? null;\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'push',\n\t\t\t\tpost: { postId: params.postId, postType: params.postType },\n\t\t\t\t// Save the current rendering mode so we can restore it when navigating back.\n\t\t\t\tpreviousRenderingMode: getRenderingMode(),\n\t\t\t\tselectedBlockClientId: externalClientId,\n\t\t\t} );\n\t\t\tsetRenderingMode( defaultRenderingMode );\n\t\t},\n\t\t[\n\t\t\tregistry,\n\t\t\tpost.postType,\n\t\t\tpost.postId,\n\t\t\tgetRenderingMode,\n\t\t\tsetRenderingMode,\n\t\t\tdefaultRenderingMode,\n\t\t]\n\t);\n\n\tconst onNavigateToPreviousEntityRecord = useCallback( () => {\n\t\t// Get the item we're navigating back to (second to last in history)\n\t\t// to set its selection on the entity record\n\t\tif ( postHistory.length > 1 ) {\n\t\t\tconst previousItem = postHistory[ postHistory.length - 2 ];\n\n\t\t\tif ( previousItem.selectedBlockClientId ) {\n\t\t\t\t// Set the selection on the entity we're navigating back to\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpreviousItem.post.postType,\n\t\t\t\t\tpreviousItem.post.postId,\n\t\t\t\t\t{\n\t\t\t\t\t\tselection: {\n\t\t\t\t\t\t\tselectionStart: {\n\t\t\t\t\t\t\t\tclientId: previousItem.selectedBlockClientId,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tselectionEnd: {\n\t\t\t\t\t\t\t\tclientId: previousItem.selectedBlockClientId,\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{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'pop',\n\t\t} );\n\t\tif ( previousRenderingMode ) {\n\t\t\tsetRenderingMode( previousRenderingMode );\n\t\t}\n\t}, [\n\t\tsetRenderingMode,\n\t\tpreviousRenderingMode,\n\t\tpostHistory,\n\t\teditEntityRecord,\n\t] );\n\n\treturn {\n\t\tcurrentPost: post,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord:\n\t\t\tpostHistory.length > 1\n\t\t\t\t? onNavigateToPreviousEntityRecord\n\t\t\t\t: undefined,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwC;AACxC,kBAAoD;AACpD,oBAAqC;AACrC,uBAAmC;AAiBpB,SAAR,0BACN,eACA,iBACA,sBACC;AACD,QAAM,eAAW,yBAAY;AAC7B,QAAM,CAAE,aAAa,QAAS,QAAI;AAAA,IACjC,CACC,cACA,EAAE,MAAM,MAAAA,OAAM,uBAAAC,wBAAuB,sBAAsB,MACvD;AACJ,UAAK,SAAS,QAAS;AAEtB,cAAM,iBAAiB,CAAE,GAAG,YAAa;AACzC,cAAM,eAAe,eAAe,SAAS;AAC7C,uBAAgB,YAAa,IAAI;AAAA,UAChC,GAAG,eAAgB,YAAa;AAAA,UAChC;AAAA,QACD;AACA,eAAO,CAAE,GAAG,gBAAgB,EAAE,MAAAD,OAAM,uBAAAC,uBAAsB,CAAE;AAAA,MAC7D;AACA,UAAK,SAAS,OAAQ;AAErB,YAAK,aAAa,SAAS,GAAI;AAC9B,iBAAO,aAAa,MAAO,GAAG,EAAG;AAAA,QAClC;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC;AAAA,QACC,MAAM,EAAE,QAAQ,eAAe,UAAU,gBAAgB;AAAA,MAC1D;A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,qBAAsB;AAAA,IACzC;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN,aAAa;AAAA,IACb;AAAA,IACA,kCACC,YAAY,SAAS,IAClB,mCACA;AAAA,EACL;AACD;",
|
|
6
|
+
"names": ["post", "previousRenderingMode", "editorStore", "coreStore"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,7 @@ function useCommands() {
|
|
|
18
18
|
name: "core/toggle-fullscreen-mode",
|
|
19
19
|
label: isFullscreen ? __("Exit fullscreen") : __("Enter fullscreen"),
|
|
20
20
|
icon: fullscreen,
|
|
21
|
+
category: "command",
|
|
21
22
|
callback: ({ close }) => {
|
|
22
23
|
toggle("core/edit-post", "fullscreenMode");
|
|
23
24
|
close();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/use-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { fullscreen } from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useCommands() {\n\tconst { isFullscreen } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,oBAAoB;AAEvB,SAAR,cAA+B;AACrC,QAAM,EAAE,aAAa,IAAI,UAAW,CAAE,WAAY;AACjD,UAAM,EAAE,IAAI,IAAI,OAAQ,gBAAiB;AAEzC,WAAO;AAAA,MACN,cAAc,IAAK,kBAAkB,gBAAiB;AAAA,IACvD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,EAAE,iBAAiB,IAAI,YAAa,YAAa;AAEvD,aAAY;AAAA,IACX,MAAM;AAAA,IACN,OAAO,eACJ,GAAI,iBAAkB,IACtB,GAAI,kBAAmB;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,aAAQ,kBAAkB,gBAAiB;AAC3C,YAAM;AACN;AAAA,QACC,eAAe,GAAI,iBAAkB,IAAI,GAAI,gBAAiB;AAAA,QAC9D;AAAA,UACC,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,OAAO,GAAI,MAAO;AAAA,cAClB,SAAS,MAAM;AACd,uBAAQ,kBAAkB,gBAAiB;AAAA,cAC5C;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { fullscreen } from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function useCommands() {\n\tconst { isFullscreen } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcategory: 'command',\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,oBAAoB;AAEvB,SAAR,cAA+B;AACrC,QAAM,EAAE,aAAa,IAAI,UAAW,CAAE,WAAY;AACjD,UAAM,EAAE,IAAI,IAAI,OAAQ,gBAAiB;AAEzC,WAAO;AAAA,MACN,cAAc,IAAK,kBAAkB,gBAAiB;AAAA,IACvD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,EAAE,iBAAiB,IAAI,YAAa,YAAa;AAEvD,aAAY;AAAA,IACX,MAAM;AAAA,IACN,OAAO,eACJ,GAAI,iBAAkB,IACtB,GAAI,kBAAmB;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,aAAQ,kBAAkB,gBAAiB;AAC3C,YAAM;AACN;AAAA,QACC,eAAe,GAAI,iBAAkB,IAAI,GAAI,gBAAiB;AAAA,QAC9D;AAAA,UACC,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,OAAO,GAAI,MAAO;AAAA,cAClB,SAAS,MAAM;AACd,uBAAQ,kBAAkB,gBAAiB;AAAA,cAC5C;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
LocalAutosaveMonitor,
|
|
7
7
|
UnsavedChangesWarning,
|
|
8
8
|
EditorKeyboardShortcutsRegister,
|
|
9
|
-
EditorSnackbars,
|
|
10
9
|
ErrorBoundary,
|
|
11
10
|
PostLockedModal,
|
|
12
11
|
store as editorStore,
|
|
@@ -25,7 +24,7 @@ import {
|
|
|
25
24
|
useState
|
|
26
25
|
} from "@wordpress/element";
|
|
27
26
|
import { chevronDown, chevronUp } from "@wordpress/icons";
|
|
28
|
-
import { store as noticesStore } from "@wordpress/notices";
|
|
27
|
+
import { SnackbarNotices, store as noticesStore } from "@wordpress/notices";
|
|
29
28
|
import { store as preferencesStore } from "@wordpress/preferences";
|
|
30
29
|
import { privateApis as commandsPrivateApis } from "@wordpress/commands";
|
|
31
30
|
import { privateApis as blockLibraryPrivateApis } from "@wordpress/block-library";
|
|
@@ -299,8 +298,7 @@ function Layout({
|
|
|
299
298
|
const {
|
|
300
299
|
currentPost: { postId: currentPostId, postType: currentPostType },
|
|
301
300
|
onNavigateToEntityRecord,
|
|
302
|
-
onNavigateToPreviousEntityRecord
|
|
303
|
-
previousSelectedBlockPath
|
|
301
|
+
onNavigateToPreviousEntityRecord
|
|
304
302
|
} = useNavigateToEntityRecord(
|
|
305
303
|
initialPostId,
|
|
306
304
|
initialPostType,
|
|
@@ -475,14 +473,8 @@ function Layout({
|
|
|
475
473
|
disableIframe: !shouldIframe,
|
|
476
474
|
autoFocus: !isWelcomeGuideVisible,
|
|
477
475
|
onActionPerformed,
|
|
478
|
-
initialSelection: previousSelectedBlockPath,
|
|
479
476
|
extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ jsx(MetaBoxes, { location: "side" }),
|
|
480
|
-
extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ jsx(
|
|
481
|
-
MetaBoxesMain,
|
|
482
|
-
{
|
|
483
|
-
isLegacy: !shouldIframe || isDevicePreview
|
|
484
|
-
}
|
|
485
|
-
),
|
|
477
|
+
extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ jsx(MetaBoxesMain, { isLegacy: isDevicePreview }),
|
|
486
478
|
children: [
|
|
487
479
|
/* @__PURE__ */ jsx(PostLockedModal, {}),
|
|
488
480
|
/* @__PURE__ */ jsx(EditorInitialization, {}),
|
|
@@ -498,7 +490,7 @@ function Layout({
|
|
|
498
490
|
/* @__PURE__ */ jsx(PluginArea, { onError: onPluginAreaError }),
|
|
499
491
|
/* @__PURE__ */ jsx(PostEditorMoreMenu, {}),
|
|
500
492
|
backButton,
|
|
501
|
-
/* @__PURE__ */ jsx(
|
|
493
|
+
/* @__PURE__ */ jsx(SnackbarNotices, { className: "edit-post-layout__snackbar" })
|
|
502
494
|
]
|
|
503
495
|
}
|
|
504
496
|
)
|