@wordpress/editor 14.36.1-next.8b30e05b0.0 → 14.37.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/README.md +2 -3
- package/build/components/autocompleters/user.js.map +2 -2
- package/build/components/collab-sidebar/comments.js +4 -12
- package/build/components/collab-sidebar/comments.js.map +2 -2
- package/build/components/collab-sidebar/hooks.js +7 -19
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/document-bar/index.js +19 -8
- package/build/components/document-bar/index.js.map +3 -3
- package/build/components/document-bar/useEditedSectionDetails.js +95 -0
- package/build/components/document-bar/useEditedSectionDetails.js.map +7 -0
- package/build/components/page-attributes/parent.js +1 -0
- package/build/components/page-attributes/parent.js.map +2 -2
- package/build/components/post-card-panel/index.js +1 -1
- package/build/components/post-card-panel/index.js.map +2 -2
- package/build/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +2 -2
- package/build/components/post-taxonomies/flat-term-selector.js +3 -16
- package/build/components/post-taxonomies/flat-term-selector.js.map +3 -3
- package/build/components/post-taxonomies/index.js +1 -5
- package/build/components/post-taxonomies/index.js.map +2 -2
- package/build/components/provider/use-block-editor-settings.js +10 -2
- package/build/components/provider/use-block-editor-settings.js.map +2 -2
- package/build/components/style-book/index.js +3 -5
- package/build/components/style-book/index.js.map +2 -2
- package/build/dataviews/store/private-actions.js +9 -1
- package/build/dataviews/store/private-actions.js.map +2 -2
- package/build/store/utils/notice-builder.js +12 -4
- package/build/store/utils/notice-builder.js.map +2 -2
- package/build/utils/get-template-part-icon.js +9 -4
- package/build/utils/get-template-part-icon.js.map +3 -3
- package/build-module/components/autocompleters/user.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +4 -12
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +7 -20
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/document-bar/index.js +20 -9
- package/build-module/components/document-bar/index.js.map +2 -2
- package/build-module/components/document-bar/useEditedSectionDetails.js +74 -0
- package/build-module/components/document-bar/useEditedSectionDetails.js.map +7 -0
- package/build-module/components/page-attributes/parent.js +1 -0
- package/build-module/components/page-attributes/parent.js.map +2 -2
- package/build-module/components/post-card-panel/index.js +1 -1
- package/build-module/components/post-card-panel/index.js.map +2 -2
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js +4 -17
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +2 -2
- package/build-module/components/post-taxonomies/index.js +1 -5
- package/build-module/components/post-taxonomies/index.js.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.js +10 -2
- package/build-module/components/provider/use-block-editor-settings.js.map +2 -2
- package/build-module/components/style-book/index.js +3 -5
- package/build-module/components/style-book/index.js.map +2 -2
- package/build-module/dataviews/store/private-actions.js +11 -2
- package/build-module/dataviews/store/private-actions.js.map +2 -2
- package/build-module/store/utils/notice-builder.js +12 -4
- package/build-module/store/utils/notice-builder.js.map +2 -2
- package/build-module/utils/get-template-part-icon.js +10 -4
- package/build-module/utils/get-template-part-icon.js.map +2 -2
- package/build-style/style-rtl.css +76 -161
- package/build-style/style.css +76 -161
- package/build-types/components/autocompleters/user.d.ts +8 -2
- package/build-types/components/autocompleters/user.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts +8 -0
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -0
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +3 -5
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/style-book/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/utils/notice-builder.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts +3 -3
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/package.json +40 -40
- package/src/components/autocompleters/user.js +6 -0
- package/src/components/collab-sidebar/comments.js +16 -23
- package/src/components/collab-sidebar/hooks.js +7 -24
- package/src/components/document-bar/index.js +41 -9
- package/src/components/document-bar/useEditedSectionDetails.js +103 -0
- package/src/components/global-styles-sidebar/style.scss +0 -4
- package/src/components/page-attributes/parent.js +2 -1
- package/src/components/post-card-panel/index.js +1 -1
- package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/src/components/post-taxonomies/flat-term-selector.js +6 -27
- package/src/components/post-taxonomies/index.js +1 -7
- package/src/components/provider/use-block-editor-settings.js +8 -0
- package/src/components/style-book/index.js +3 -5
- package/src/dataviews/store/private-actions.ts +16 -0
- package/src/store/utils/notice-builder.js +12 -4
- package/src/utils/get-template-part-icon.js +19 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/document-bar/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPES } from '../../store/constants';\nimport { store as editorStore } from '../../store';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nimport { getStylesCanvasTitle } from '../styles-canvas';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import(\"@wordpress/components\").IconType} IconType */\n\nconst MotionButton = motion.create( Button );\n\n/**\n * This component renders a navigation bar at the top of the editor. It displays the title of the current document,\n * a back button (if applicable), and a command center button. It also handles different states of the document,\n * such as \"not found\" or \"unsynced\".\n *\n * @example\n * ```jsx\n * <DocumentBar />\n * ```\n *\n * @param {Object} props The component props.\n * @param {string} props.title A title for the document, defaulting to the document or template title currently being edited.\n * @param {IconType} props.icon An icon for the document, no default.\n * (A default icon indicating the document post type is no longer used.)\n *\n * @return {React.ReactNode} The rendered DocumentBar component.\n */\nexport default function DocumentBar( props ) {\n\tconst {\n\t\tpostId,\n\t\tpostType,\n\t\tpostTypeLabel,\n\t\tdocumentTitle,\n\t\tisNotFound,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t\tisTemplatePreview,\n\t\tstylesCanvasTitle,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t} = select( editorStore );\n\n\t\tconst {\n\t\t\tgetEditedEntityRecord,\n\t\t\tgetPostType,\n\t\t\tgetCurrentTheme,\n\t\t\tisResolving: isResolvingSelector,\n\t\t} = select( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\n\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\tgetCurrentTheme() ?? {};\n\n\t\tconst _templateInfo = getTemplateInfo( {\n\t\t\ttemplateTypes,\n\t\t\ttemplate: _document,\n\t\t} );\n\t\tconst _postTypeLabel = getPostType( _postType )?.labels?.singular_name;\n\n\t\t// Check if styles canvas is active and get its title\n\t\tconst { getStylesPath, getShowStylebook } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst _stylesPath = getStylesPath();\n\t\tconst _showStylebook = getShowStylebook();\n\t\tconst _stylesCanvasTitle = getStylesCanvasTitle(\n\t\t\t_stylesPath,\n\t\t\t_showStylebook\n\t\t);\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: _postType,\n\t\t\tpostTypeLabel: _postTypeLabel,\n\t\t\tdocumentTitle: _document.title,\n\t\t\tisNotFound:\n\t\t\t\t! _document &&\n\t\t\t\t! isResolvingSelector(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t'postType',\n\t\t\t\t\t_postType,\n\t\t\t\t\t_postId\n\t\t\t\t),\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisTemplatePreview: getRenderingMode() === 'template-locked',\n\t\t\tstylesCanvasTitle: _stylesCanvasTitle,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst hasBackButton
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA0B;AAC1B,kBAAuC;AACvC,wBAKO;AACP,
|
|
6
|
-
"names": ["motion", "editorStore", "coreStore", "commandsStore", "usePageTypeBadge", "clsx", "AnimatePresence", "Text", "stripHTML"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPES } from '../../store/constants';\nimport { store as editorStore } from '../../store';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nimport { getStylesCanvasTitle } from '../styles-canvas';\nimport { unlock } from '../../lock-unlock';\nimport useEditedSectionDetails from './useEditedSectionDetails';\n\n/** @typedef {import(\"@wordpress/components\").IconType} IconType */\n\nconst MotionButton = motion.create( Button );\n\n/**\n * This component renders a navigation bar at the top of the editor. It displays the title of the current document,\n * a back button (if applicable), and a command center button. It also handles different states of the document,\n * such as \"not found\" or \"unsynced\".\n *\n * @example\n * ```jsx\n * <DocumentBar />\n * ```\n *\n * @param {Object} props The component props.\n * @param {string} props.title A title for the document, defaulting to the document or template title currently being edited.\n * @param {IconType} props.icon An icon for the document, no default.\n * (A default icon indicating the document post type is no longer used.)\n *\n * @return {React.ReactNode} The rendered DocumentBar component.\n */\nexport default function DocumentBar( props ) {\n\t// Get action to lock the pattern design\n\tconst { stopEditingContentOnlySection } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\t// Get details about the currently edited content-only section\n\tconst unlockedPatternInfo = useEditedSectionDetails();\n\n\tconst {\n\t\tpostId,\n\t\tpostType,\n\t\tpostTypeLabel,\n\t\tdocumentTitle,\n\t\tisNotFound,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t\tisTemplatePreview,\n\t\tstylesCanvasTitle,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t} = select( editorStore );\n\n\t\tconst {\n\t\t\tgetEditedEntityRecord,\n\t\t\tgetPostType,\n\t\t\tgetCurrentTheme,\n\t\t\tisResolving: isResolvingSelector,\n\t\t} = select( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\n\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\tgetCurrentTheme() ?? {};\n\n\t\tconst _templateInfo = getTemplateInfo( {\n\t\t\ttemplateTypes,\n\t\t\ttemplate: _document,\n\t\t} );\n\t\tconst _postTypeLabel = getPostType( _postType )?.labels?.singular_name;\n\n\t\t// Check if styles canvas is active and get its title\n\t\tconst { getStylesPath, getShowStylebook } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst _stylesPath = getStylesPath();\n\t\tconst _showStylebook = getShowStylebook();\n\t\tconst _stylesCanvasTitle = getStylesCanvasTitle(\n\t\t\t_stylesPath,\n\t\t\t_showStylebook\n\t\t);\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: _postType,\n\t\t\tpostTypeLabel: _postTypeLabel,\n\t\t\tdocumentTitle: _document.title,\n\t\t\tisNotFound:\n\t\t\t\t! _document &&\n\t\t\t\t! isResolvingSelector(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t'postType',\n\t\t\t\t\t_postType,\n\t\t\t\t\t_postId\n\t\t\t\t),\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisTemplatePreview: getRenderingMode() === 'template-locked',\n\t\t\tstylesCanvasTitle: _stylesCanvasTitle,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst hasBackButton =\n\t\t!! onNavigateToPreviousEntityRecord || !! unlockedPatternInfo;\n\tconst entityTitle = isTemplate ? templateTitle : documentTitle;\n\n\t// Use pattern info if a pattern block is unlocked, otherwise use document/entity info\n\tconst title =\n\t\tunlockedPatternInfo?.patternTitle ||\n\t\tprops.title ||\n\t\tstylesCanvasTitle ||\n\t\tentityTitle;\n\tconst icon = props.icon;\n\n\t// Determine the back button action\n\tconst handleBackClick = ( event ) => {\n\t\tevent.stopPropagation();\n\t\tif ( unlockedPatternInfo ) {\n\t\t\tstopEditingContentOnlySection();\n\t\t} else if ( onNavigateToPreviousEntityRecord ) {\n\t\t\tonNavigateToPreviousEntityRecord();\n\t\t}\n\t};\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tmountedRef.current = true;\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'editor-document-bar', {\n\t\t\t\t'has-back-button': hasBackButton,\n\t\t\t} ) }\n\t\t>\n\t\t\t<AnimatePresence>\n\t\t\t\t{ hasBackButton && (\n\t\t\t\t\t<MotionButton\n\t\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\t\tonClick={ handleBackClick }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? { opacity: 0, transform: 'translateX(15%)' }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ { opacity: 1, transform: 'translateX(0%)' } }\n\t\t\t\t\t\texit={ { opacity: 0, transform: 'translateX(15%)' } }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</MotionButton>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t\t{ ! isTemplate && isTemplatePreview && ! hasBackButton && (\n\t\t\t\t<BlockIcon\n\t\t\t\t\ticon={ layout }\n\t\t\t\t\tclassName=\"editor-document-bar__icon-layout\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isNotFound ? (\n\t\t\t\t<Text>{ __( 'Document not found' ) }</Text>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\t// Force entry animation when the back button is added or removed.\n\t\t\t\t\t\tkey={ hasBackButton }\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t\ttransform: hasBackButton\n\t\t\t\t\t\t\t\t\t\t\t? 'translateX(15%)'\n\t\t\t\t\t\t\t\t\t\t\t: 'translateX(-15%)',\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\ttransform: 'translateX(0%)',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon && <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-title\">\n\t\t\t\t\t\t\t\t{ title\n\t\t\t\t\t\t\t\t\t? stripHTML( title )\n\t\t\t\t\t\t\t\t\t: __( 'No title' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ unlockedPatternInfo && (\n\t\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-type-label\">\n\t\t\t\t\t\t\t\t\t{ unlockedPatternInfo.type ===\n\t\t\t\t\t\t\t\t\t'template-part'\n\t\t\t\t\t\t\t\t\t\t? `\u00B7 ${ __( 'Template Part' ) }`\n\t\t\t\t\t\t\t\t\t\t: `\u00B7 ${ __( 'Pattern' ) }` }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! unlockedPatternInfo && pageTypeBadge && (\n\t\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-type-label\">\n\t\t\t\t\t\t\t\t\t{ `\u00B7 ${ pageTypeBadge }` }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! unlockedPatternInfo &&\n\t\t\t\t\t\t\t\tpostTypeLabel &&\n\t\t\t\t\t\t\t\t! props.title &&\n\t\t\t\t\t\t\t\t! pageTypeBadge && (\n\t\t\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-type-label\">\n\t\t\t\t\t\t\t\t\t\t{ `\u00B7 ${ decodeEntities(\n\t\t\t\t\t\t\t\t\t\t\tpostTypeLabel\n\t\t\t\t\t\t\t\t\t\t) }` }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</motion.div>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA0B;AAC1B,kBAAuC;AACvC,wBAKO;AACP,0BAAqD;AACrD,mBAA4D;AAC5D,sBAAgC;AAChC,uBAAmC;AACnC,sBAAuC;AACvC,qBAAkC;AAClC,qBAAiC;AACjC,2BAA+B;AAC/B,iBAAiD;AAKjD,uBAAoC;AACpC,mBAAqC;AACrC,2BAA6B;AAC7B,+BAAgC;AAChC,2BAAqC;AACrC,yBAAuB;AACvB,qCAAoC;AAkJ/B;AA9IL,IAAM,eAAe,kBAAAA,iBAAO,OAAQ,wBAAO;AAmB5B,SAAR,YAA8B,OAAQ;AAE5C,QAAM,EAAE,8BAA8B,QAAI;AAAA,QACzC,yBAAa,oBAAAC,KAAiB;AAAA,EAC/B;AAGA,QAAM,0BAAsB,+BAAAC,SAAwB;AAEpD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5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A,gBAAP;AAAA,kBACA,WAAU;AAAA,kBAGV,SACC,WAAW,UACR;AAAA,oBACA,SAAS;AAAA,oBACT,WAAW,gBACR,oBACA;AAAA,kBACH,IACA;AAAA,kBAEJ,SAAU;AAAA,oBACT,SAAS;AAAA,oBACT,WAAW;AAAA,kBACZ;AAAA,kBACA,YACC,kBAAkB,EAAE,UAAU,EAAE,IAAI;AAAA,kBAGnC;AAAA,4BAAQ,4CAAC,iCAAU,MAAc;AAAA,oBACnC,6CAAC,kBAAAS,oBAAA,EAAK,MAAK,QAAO,IAAG,MACpB;AAAA,kEAAC,UAAK,WAAU,mCACb,sBACC,WAAAC,qBAAW,KAAM,QACjB,gBAAI,UAAW,GACnB;AAAA,sBACE,uBACD,4CAAC,UAAK,WAAU,wCACb,8BAAoB,SACtB,kBACG,YAAM,gBAAI,eAAgB,CAAE,KAC5B,YAAM,gBAAI,SAAU,CAAE,IAC1B;AAAA,sBAEC,CAAE,uBAAuB,iBAC1B,4CAAC,UAAK,WAAU,wCACb,kBAAM,aAAc,IACvB;AAAA,sBAEC,CAAE,uBACH,iBACA,CAAE,MAAM,SACR,CAAE,iBACD,4CAAC,UAAK,WAAU,wCACb,sBAAM;AAAA,wBACP;AAAA,sBACD,CAAE,IACH;AAAA,uBAEH;AAAA;AAAA;AAAA,gBAjDM;AAAA,cAkDP;AAAA,cACA,4CAAC,UAAK,WAAU,iCACb,0CAAgB,QAAS,GAAI,GAChC;AAAA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
+
"names": ["motion", "blockEditorStore", "useEditedSectionDetails", "editorStore", "coreStore", "commandsStore", "usePageTypeBadge", "clsx", "AnimatePresence", "Text", "stripHTML"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/editor/src/components/document-bar/useEditedSectionDetails.js
|
|
21
|
+
var useEditedSectionDetails_exports = {};
|
|
22
|
+
__export(useEditedSectionDetails_exports, {
|
|
23
|
+
default: () => useEditedSectionDetails
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useEditedSectionDetails_exports);
|
|
26
|
+
var import_data = require("@wordpress/data");
|
|
27
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
28
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
29
|
+
var import_core_data = require("@wordpress/core-data");
|
|
30
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
31
|
+
function useEditedSectionDetails() {
|
|
32
|
+
return (0, import_data.useSelect)((select) => {
|
|
33
|
+
if (!window?.__experimentalContentOnlyPatternInsertion) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const {
|
|
37
|
+
getBlockAttributes,
|
|
38
|
+
getBlockName,
|
|
39
|
+
__experimentalGetParsedPattern
|
|
40
|
+
} = select(import_block_editor.store);
|
|
41
|
+
const { getEditedEntityRecord, getCurrentTheme } = select(import_core_data.store);
|
|
42
|
+
const { getEditedContentOnlySection } = (0, import_lock_unlock.unlock)(
|
|
43
|
+
select(import_block_editor.store)
|
|
44
|
+
);
|
|
45
|
+
const editedSectionId = getEditedContentOnlySection();
|
|
46
|
+
if (!editedSectionId) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const attributes = getBlockAttributes(editedSectionId);
|
|
50
|
+
const patternName = attributes?.metadata?.patternName;
|
|
51
|
+
if (patternName) {
|
|
52
|
+
const pattern = typeof __experimentalGetParsedPattern === "function" ? __experimentalGetParsedPattern(patternName) : null;
|
|
53
|
+
return {
|
|
54
|
+
patternName,
|
|
55
|
+
patternTitle: pattern?.title || attributes?.metadata?.name,
|
|
56
|
+
type: "pattern"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const blockName = getBlockName(editedSectionId);
|
|
60
|
+
if (blockName === "core/block" && !!attributes?.ref) {
|
|
61
|
+
const entity = getEditedEntityRecord(
|
|
62
|
+
"postType",
|
|
63
|
+
"wp_block",
|
|
64
|
+
attributes.ref
|
|
65
|
+
);
|
|
66
|
+
if (entity?.title) {
|
|
67
|
+
return {
|
|
68
|
+
patternName: attributes.ref,
|
|
69
|
+
patternTitle: (0, import_html_entities.decodeEntities)(entity.title),
|
|
70
|
+
type: "synced-pattern"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (blockName === "core/template-part" && !!attributes?.slug) {
|
|
75
|
+
const theme = attributes.theme || getCurrentTheme()?.stylesheet;
|
|
76
|
+
const templatePartId = theme ? `${theme}//${attributes.slug}` : null;
|
|
77
|
+
if (templatePartId) {
|
|
78
|
+
const entity = getEditedEntityRecord(
|
|
79
|
+
"postType",
|
|
80
|
+
"wp_template_part",
|
|
81
|
+
templatePartId
|
|
82
|
+
);
|
|
83
|
+
if (entity?.title) {
|
|
84
|
+
return {
|
|
85
|
+
patternName: attributes.slug,
|
|
86
|
+
patternTitle: (0, import_html_entities.decodeEntities)(entity.title),
|
|
87
|
+
type: "template-part"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}, []);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=useEditedSectionDetails.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/document-bar/useEditedSectionDetails.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Hook to get details about the currently edited content-only section.\n * Only returns information when the content only pattern insertion experiment is enabled.\n *\n * @return {Object|null} Object with patternName, patternTitle, and type, or null if no section is being edited or experiment is disabled.\n */\nexport default function useEditedSectionDetails() {\n\treturn useSelect( ( select ) => {\n\t\t// Only run when the content only pattern insertion experiment is enabled\n\t\tif ( ! window?.__experimentalContentOnlyPatternInsertion ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst {\n\t\t\tgetBlockAttributes,\n\t\t\tgetBlockName,\n\t\t\t__experimentalGetParsedPattern,\n\t\t} = select( blockEditorStore );\n\t\tconst { getEditedEntityRecord, getCurrentTheme } = select( coreStore );\n\t\tconst { getEditedContentOnlySection } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\t// Get the clientId of the unlocked pattern/section\n\t\tconst editedSectionId = getEditedContentOnlySection();\n\t\tif ( ! editedSectionId ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst attributes = getBlockAttributes( editedSectionId );\n\n\t\t// Handle unsynced patterns (contentOnly patterns with patternName)\n\t\tconst patternName = attributes?.metadata?.patternName;\n\t\tif ( patternName ) {\n\t\t\t// Get pattern details if available\n\t\t\tconst pattern =\n\t\t\t\ttypeof __experimentalGetParsedPattern === 'function'\n\t\t\t\t\t? __experimentalGetParsedPattern( patternName )\n\t\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tpatternName,\n\t\t\t\tpatternTitle: pattern?.title || attributes?.metadata?.name,\n\t\t\t\ttype: 'pattern',\n\t\t\t};\n\t\t}\n\n\t\tconst blockName = getBlockName( editedSectionId );\n\n\t\t// Handle synced patterns (core/block)\n\t\tif ( blockName === 'core/block' && !! attributes?.ref ) {\n\t\t\tconst entity = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\tattributes.ref\n\t\t\t);\n\t\t\tif ( entity?.title ) {\n\t\t\t\treturn {\n\t\t\t\t\tpatternName: attributes.ref,\n\t\t\t\t\tpatternTitle: decodeEntities( entity.title ),\n\t\t\t\t\ttype: 'synced-pattern',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Handle template parts (core/template-part)\n\t\tif ( blockName === 'core/template-part' && !! attributes?.slug ) {\n\t\t\tconst theme = attributes.theme || getCurrentTheme()?.stylesheet;\n\t\t\tconst templatePartId = theme\n\t\t\t\t? `${ theme }//${ attributes.slug }`\n\t\t\t\t: null;\n\t\t\tif ( templatePartId ) {\n\t\t\t\tconst entity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\ttemplatePartId\n\t\t\t\t);\n\t\t\t\tif ( entity?.title ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpatternName: attributes.slug,\n\t\t\t\t\t\tpatternTitle: decodeEntities( entity.title ),\n\t\t\t\t\t\ttype: 'template-part',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}, [] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,2BAA+B;AAC/B,0BAA0C;AAC1C,uBAAmC;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K,QAAQ,OAAQ;AACpB,iBAAO;AAAA,YACN,aAAa,WAAW;AAAA,YACxB,kBAAc,qCAAgB,OAAO,KAAM;AAAA,YAC3C,MAAM;AAAA,UACP;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AACP;",
|
|
6
|
+
"names": ["blockEditorStore", "coreStore"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-attributes/parent.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-parent__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\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\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\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</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<PageAttributesParent />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport default PageAttributesParent;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAK1B,kBAA4B;AAC5B,wBAKO;AACP,qBAAyB;AACzB,qBAIO;AACP,kBAAuC;AACvC,2BAA+B;AAC/B,uBAAmC;AACnC,0BAA+E;AAC/E,iBAAoC;AAKpC,4BAAyB;AACzB,mBAA+B;AAC/B,mBAAqC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst {\n\t\tisHierarchical,\n\t\tparentPostId,\n\t\tparentPostTitle,\n\t\tpageItems,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetPostType,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tisResolving,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t\tquery.orderby = 'relevance';\n\t\t\t}\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: null,\n\t\t\t\tisLoading: postIsHierarchical\n\t\t\t\t\t? isResolving( 'getEntityRecords', [\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t ] )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t\tisLoading={ isLoading }\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-parent__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\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\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\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</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<PageAttributesParent />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport default PageAttributesParent;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAK1B,kBAA4B;AAC5B,wBAKO;AACP,qBAAyB;AACzB,qBAIO;AACP,kBAAuC;AACvC,2BAA+B;AAC/B,uBAAmC;AACnC,0BAA+E;AAC/E,iBAAoC;AAKpC,4BAAyB;AACzB,mBAA+B;AAC/B,mBAAqC;AAm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;AAAA,gBACD;AAAA,cACC;AAAA,YACD;AAAA,YACA;AAAA,cACC,GACC;AAAA,gBAAC;AAAA;AAAA,kBACA,UAAO;AAAA,oBACN;AAAA,kBACD;AAAA;AAAA,cACD;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,4CAAC,wBAAqB;AAAA,SACvB;AAAA;AAAA,EAEF,GACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["removeAccents", "editorStore", "coreStore", "tree", "PostPanelRow", "InspectorPopoverHeader"]
|
|
7
7
|
}
|
|
@@ -105,7 +105,7 @@ function PostCardPanel({
|
|
|
105
105
|
{
|
|
106
106
|
spacing: 2,
|
|
107
107
|
className: "editor-post-card-panel__header",
|
|
108
|
-
|
|
108
|
+
alignment: "flex-start",
|
|
109
109
|
children: [
|
|
110
110
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { className: "editor-post-card-panel__icon", icon }),
|
|
111
111
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-card-panel/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport PostActions from '../post-actions';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.\n *\n * @param {Object} props - Component props.\n * @param {string} [props.postType] - The post type string.\n * @param {string|string[]} [props.postId] - The post id or list of post ids.\n * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostCardPanel( {\n\tpostType,\n\tpostId,\n\tonActionPerformed,\n} ) {\n\tconst postIds = useMemo(\n\t\t() => ( Array.isArray( postId ) ? postId : [ postId ] ),\n\t\t[ postId ]\n\t);\n\tconst { postTitle, icon, labels } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getCurrentTheme, getPostType } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getPostIcon } = unlock( select( editorStore ) );\n\t\t\tlet _title = '';\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostIds[ 0 ]\n\t\t\t);\n\t\t\tif ( postIds.length === 1 ) {\n\t\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\t\tgetCurrentTheme() ?? {};\n\n\t\t\t\tconst _templateInfo = [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t].includes( postType )\n\t\t\t\t\t? getTemplateInfo( {\n\t\t\t\t\t\t\ttemplate: _record,\n\t\t\t\t\t\t\ttemplateTypes,\n\t\t\t\t\t } )\n\t\t\t\t\t: {};\n\t\t\t\t_title = _templateInfo?.title || _record?.title;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostTitle: _title,\n\t\t\t\ticon: getPostIcon( postType, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\tlet title = __( 'No title' );\n\tif ( labels?.name && postIds.length > 1 ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: %1$d number of selected items %2$s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%1$d %2$s' ),\n\t\t\tpostIds.length,\n\t\t\tlabels?.name\n\t\t);\n\t} else if ( postTitle ) {\n\t\ttitle = stripHTML( postTitle );\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 } className=\"editor-post-card-panel\">\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,uBAAmC;AACnC,kBAA0B;AAC1B,qBAAwB;AACxB,kBAA4B;AAC5B,iBAAiD;AAKjD,mBAAqC;AACrC,uBAGO;AACP,yBAAuB;AACvB,0BAAwB;AACxB,2BAA6B;AAC7B,+BAAgC;AA+E5B;AA9EJ,IAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAWjC,SAAR,cAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,cAAU;AAAA,IACf,MAAQ,MAAM,QAAS,MAAO,IAAI,SAAS,CAAE,MAAO;AAAA,IACpD,CAAE,MAAO;AAAA,EACV;AACA,QAAM,EAAE,WAAW,MAAM,OAAO,QAAI;AAAA,IACnC,CAAE,WAAY;AACb,YAAM,EAAE,uBAAuB,iBAAiB,YAAY,IAC3D,OAAQ,iBAAAC,KAAU;AACnB,YAAM,EAAE,YAAY,QAAI,2BAAQ,OAAQ,aAAAC,KAAY,CAAE;AACtD,UAAI,SAAS;AACb,YAAM,UAAU;AAAA,QACf;AAAA,QACA;AAAA,QACA,QAAS,CAAE;AAAA,MACZ;AACA,UAAK,QAAQ,WAAW,GAAI;AAC3B,cAAM,EAAE,wBAAwB,gBAAgB,CAAC,EAAE,IAClD,gBAAgB,KAAK,CAAC;AAEvB,cAAM,gBAAgB;AAAA,UACrB;AAAA,UACA;AAAA,QACD,EAAE,SAAU,QAAS,QAClB,0CAAiB;AAAA,UACjB,UAAU;AAAA,UACV;AAAA,QACA,CAAE,IACF,CAAC;AACJ,iBAAS,eAAe,SAAS,SAAS;AAAA,MAC3C;AAEA,aAAO;AAAA,QACN,WAAW;AAAA,QACX,MAAM,YAAa,UAAU;AAAA,UAC5B,MAAM,SAAS;AAAA,QAChB,CAAE;AAAA,QACF,QAAQ,YAAa,QAAS,GAAG;AAAA,MAClC;AAAA,IACD;AAAA,IACA,CAAE,SAAS,QAAS;AAAA,EACrB;AAEA,QAAM,oBAAgB,qBAAAC,SAAkB,MAAO;AAC/C,MAAI,YAAQ,gBAAI,UAAW;AAC3B,MAAK,QAAQ,QAAQ,QAAQ,SAAS,GAAI;AACzC,gBAAQ;AAAA;AAAA,UAEP,gBAAI,WAAY;AAAA,MAChB,QAAQ;AAAA,MACR,QAAQ;AAAA,IACT;AAAA,EACD,WAAY,WAAY;AACvB,gBAAQ,WAAAC,qBAAW,SAAU;AAAA,EAC9B;AAEA,SACC,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GAAI,WAAU,0BAC/B;AAAA;AAAA,MAAC,kBAAAC;AAAA,MAAA;AAAA,QACA,SAAU;AAAA,QACV,WAAU;AAAA,QACV,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport PostActions from '../post-actions';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.\n *\n * @param {Object} props - Component props.\n * @param {string} [props.postType] - The post type string.\n * @param {string|string[]} [props.postId] - The post id or list of post ids.\n * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostCardPanel( {\n\tpostType,\n\tpostId,\n\tonActionPerformed,\n} ) {\n\tconst postIds = useMemo(\n\t\t() => ( Array.isArray( postId ) ? postId : [ postId ] ),\n\t\t[ postId ]\n\t);\n\tconst { postTitle, icon, labels } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getCurrentTheme, getPostType } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getPostIcon } = unlock( select( editorStore ) );\n\t\t\tlet _title = '';\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostIds[ 0 ]\n\t\t\t);\n\t\t\tif ( postIds.length === 1 ) {\n\t\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\t\tgetCurrentTheme() ?? {};\n\n\t\t\t\tconst _templateInfo = [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t].includes( postType )\n\t\t\t\t\t? getTemplateInfo( {\n\t\t\t\t\t\t\ttemplate: _record,\n\t\t\t\t\t\t\ttemplateTypes,\n\t\t\t\t\t } )\n\t\t\t\t\t: {};\n\t\t\t\t_title = _templateInfo?.title || _record?.title;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostTitle: _title,\n\t\t\t\ticon: getPostIcon( postType, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\tlet title = __( 'No title' );\n\tif ( labels?.name && postIds.length > 1 ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: %1$d number of selected items %2$s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%1$d %2$s' ),\n\t\t\tpostIds.length,\n\t\t\tlabels?.name\n\t\t);\n\t} else if ( postTitle ) {\n\t\ttitle = stripHTML( postTitle );\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 } className=\"editor-post-card-panel\">\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\talignment=\"flex-start\"\n\t\t\t>\n\t\t\t\t<Icon className=\"editor-post-card-panel__icon\" icon={ icon } />\n\t\t\t\t<Text\n\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\ttruncate\n\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"editor-post-card-panel__title-name\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ pageTypeBadge && postIds.length === 1 && (\n\t\t\t\t\t\t<Badge>{ pageTypeBadge }</Badge>\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t{ postIds.length === 1 && (\n\t\t\t\t\t<PostActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postIds[ 0 ] }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ postIds.length > 1 && (\n\t\t\t\t<Text className=\"editor-post-card-panel__description\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t\t\t\t__( 'Changes will be applied to all selected %s.' ),\n\t\t\t\t\t\tlabels?.name.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,uBAAmC;AACnC,kBAA0B;AAC1B,qBAAwB;AACxB,kBAA4B;AAC5B,iBAAiD;AAKjD,mBAAqC;AACrC,uBAGO;AACP,yBAAuB;AACvB,0BAAwB;AACxB,2BAA6B;AAC7B,+BAAgC;AA+E5B;AA9EJ,IAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAWjC,SAAR,cAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,cAAU;AAAA,IACf,MAAQ,MAAM,QAAS,MAAO,IAAI,SAAS,CAAE,MAAO;AAAA,IACpD,CAAE,MAAO;AAAA,EACV;AACA,QAAM,EAAE,WAAW,MAAM,OAAO,QAAI;AAAA,IACnC,CAAE,WAAY;AACb,YAAM,EAAE,uBAAuB,iBAAiB,YAAY,IAC3D,OAAQ,iBAAAC,KAAU;AACnB,YAAM,EAAE,YAAY,QAAI,2BAAQ,OAAQ,aAAAC,KAAY,CAAE;AACtD,UAAI,SAAS;AACb,YAAM,UAAU;AAAA,QACf;AAAA,QACA;AAAA,QACA,QAAS,CAAE;AAAA,MACZ;AACA,UAAK,QAAQ,WAAW,GAAI;AAC3B,cAAM,EAAE,wBAAwB,gBAAgB,CAAC,EAAE,IAClD,gBAAgB,KAAK,CAAC;AAEvB,cAAM,gBAAgB;AAAA,UACrB;AAAA,UACA;AAAA,QACD,EAAE,SAAU,QAAS,QAClB,0CAAiB;AAAA,UACjB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kBAAAD,oBAAA,EAAK,WAAU,uCACb;AAAA;AAAA,UAED,gBAAI,6CAA8C;AAAA,MAClD,QAAQ,KAAK,YAAY;AAAA,IAC1B,GACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["componentsPrivateApis", "coreStore", "editorStore", "usePageTypeBadge", "stripHTML", "VStack", "HStack", "Text", "PostActions"]
|
|
7
7
|
}
|
|
@@ -60,7 +60,7 @@ var TagsPanel = () => {
|
|
|
60
60
|
),
|
|
61
61
|
tagLabel
|
|
62
62
|
) }),
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_flat_term_selector.default, { slug: "post_tag"
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_flat_term_selector.default, { slug: "post_tag" })
|
|
64
64
|
] });
|
|
65
65
|
};
|
|
66
66
|
var MaybeTagsPanel = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-publish-panel/maybe-tags-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst tagLabels = useSelect( ( select ) => {\n\t\tconst taxonomy = select( coreStore ).getTaxonomy( 'post_tag' );\n\t\treturn taxonomy?.labels;\n\t}, [] );\n\n\tconst addNewItem = tagLabels?.add_new_item ?? __( 'Add tag' );\n\tconst tagLabel = tagLabels?.name ?? __( 'Tags' );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ addNewItem }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s is the taxonomy name (e.g., \"Tags\").\n\t\t\t\t\t__(\n\t\t\t\t\t\t'%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t\t),\n\t\t\t\t\ttagLabel\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\"
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAyB;AACzB,kBAA0B;AAC1B,wBAA0B;AAC1B,uBAAmC;AAKnC,gCAA6B;AAC7B,mBAAqC;AAanC;AAXF,IAAM,YAAY,MAAM;AACvB,QAAM,gBAAY,uBAAW,CAAE,WAAY;AAC1C,UAAM,WAAW,OAAQ,iBAAAA,KAAU,EAAE,YAAa,UAAW;AAC7D,WAAO,UAAU;AAAA,EAClB,GAAG,CAAC,CAAE;AAEN,QAAM,aAAa,WAAW,oBAAgB,gBAAI,SAAU;AAC5D,QAAM,WAAW,WAAW,YAAQ,gBAAI,MAAO;AAE/C,QAAM,iBAAiB;AAAA,QACtB,gBAAI,aAAc;AAAA,IAClB,4CAAC,UAAK,WAAU,mCACb,wBADmD,OAEtD;AAAA,EACD;AAEA,SACC,6CAAC,+BAAU,aAAc,OAAQ,OAAQ,gBACxC;AAAA,gDAAC,OACE;AAAA;AAAA,UAED;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,IACD,GACD;AAAA,IACA,4CAAC,0BAAAC,SAAA,EAAiB,MAAK,YAAW
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst tagLabels = useSelect( ( select ) => {\n\t\tconst taxonomy = select( coreStore ).getTaxonomy( 'post_tag' );\n\t\treturn taxonomy?.labels;\n\t}, [] );\n\n\tconst addNewItem = tagLabels?.add_new_item ?? __( 'Add tag' );\n\tconst tagLabel = tagLabels?.name ?? __( 'Tags' );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ addNewItem }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s is the taxonomy name (e.g., \"Tags\").\n\t\t\t\t\t__(\n\t\t\t\t\t\t'%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t\t),\n\t\t\t\t\ttagLabel\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(\n\t\t( select ) => {\n\t\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t'post_tag'\n\t\t\t);\n\t\t\tconst _isPostTypeSupported =\n\t\t\t\ttagsTaxonomy?.types?.includes( postType );\n\t\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\t\tconst tags =\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t\t);\n\t\t\tconst siteTags = _isPostTypeSupported\n\t\t\t\t? !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'post_tag',\n\t\t\t\t\t\t{ per_page: 1 }\n\t\t\t\t )?.length\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tpostHasTags: !! tags?.length,\n\t\t\t\tsiteHasTags: siteTags,\n\t\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );\n\n\t/**\n\t * We only want to show the tag panel if the post type supports\n\t * tags and the site has tags.\n\t */\n\tif ( ! isPostTypeSupported || ! siteHasTags ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.postHasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.postHasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\tif ( ! hadTagsWhenOpeningThePanel ) {\n\t\treturn <TagsPanel />;\n\t}\n\n\treturn null;\n};\n\nexport default MaybeTagsPanel;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAyB;AACzB,kBAA0B;AAC1B,wBAA0B;AAC1B,uBAAmC;AAKnC,gCAA6B;AAC7B,mBAAqC;AAanC;AAXF,IAAM,YAAY,MAAM;AACvB,QAAM,gBAAY,uBAAW,CAAE,WAAY;AAC1C,UAAM,WAAW,OAAQ,iBAAAA,KAAU,EAAE,YAAa,UAAW;AAC7D,WAAO,UAAU;AAAA,EAClB,GAAG,CAAC,CAAE;AAEN,QAAM,aAAa,WAAW,oBAAgB,gBAAI,SAAU;AAC5D,QAAM,WAAW,WAAW,YAAQ,gBAAI,MAAO;AAE/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]
|
|
7
7
|
}
|
|
@@ -38,7 +38,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
38
38
|
var import_element = require("@wordpress/element");
|
|
39
39
|
var import_components = require("@wordpress/components");
|
|
40
40
|
var import_data = require("@wordpress/data");
|
|
41
|
-
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
42
41
|
var import_core_data = require("@wordpress/core-data");
|
|
43
42
|
var import_compose = require("@wordpress/compose");
|
|
44
43
|
var import_a11y = require("@wordpress/a11y");
|
|
@@ -60,21 +59,10 @@ var termNamesToIds = (names, terms) => {
|
|
|
60
59
|
(termName) => terms.find((term) => isSameTermName(term.name, termName))?.id
|
|
61
60
|
).filter((id) => id !== void 0);
|
|
62
61
|
};
|
|
63
|
-
|
|
64
|
-
function FlatTermSelector({ slug, __nextHasNoMarginBottom }) {
|
|
62
|
+
function FlatTermSelector({ slug }) {
|
|
65
63
|
const [values, setValues] = (0, import_element.useState)([]);
|
|
66
64
|
const [search, setSearch] = (0, import_element.useState)("");
|
|
67
65
|
const debouncedSearch = (0, import_compose.useDebounce)(setSearch, 500);
|
|
68
|
-
if (!__nextHasNoMarginBottom) {
|
|
69
|
-
(0, import_deprecated.default)(
|
|
70
|
-
"Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector",
|
|
71
|
-
{
|
|
72
|
-
since: "6.7",
|
|
73
|
-
version: "7.0",
|
|
74
|
-
hint: "Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version."
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
66
|
const {
|
|
79
67
|
terms,
|
|
80
68
|
termIds,
|
|
@@ -230,7 +218,7 @@ function FlatTermSelector({ slug, __nextHasNoMarginBottom }) {
|
|
|
230
218
|
(0, import_i18n._x)("Remove %s", "term"),
|
|
231
219
|
singularName
|
|
232
220
|
);
|
|
233
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: 4, children: [
|
|
234
222
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
235
223
|
import_components.FormTokenField,
|
|
236
224
|
{
|
|
@@ -245,8 +233,7 @@ function FlatTermSelector({ slug, __nextHasNoMarginBottom }) {
|
|
|
245
233
|
added: termAddedLabel,
|
|
246
234
|
removed: termRemovedLabel,
|
|
247
235
|
remove: removeTermLabel
|
|
248
|
-
}
|
|
249
|
-
__nextHasNoMarginBottom
|
|
236
|
+
}
|
|
250
237
|
}
|
|
251
238
|
),
|
|
252
239
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_most_used_terms.default, { taxonomy, onSelect: appendTerm })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-taxonomies/flat-term-selector.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAChC,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport {\n\tFormTokenField,\n\twithFilters,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * How the max suggestions limit was chosen:\n * - Matches the `per_page` range set by the REST API.\n * - Can't use \"unbound\" query. The `FormTokenField` needs a fixed number.\n * - Matches default for `FormTokenField`.\n */\nconst MAX_TERMS_SUGGESTIONS = 100;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names\n\t\t.map(\n\t\t\t( termName ) =>\n\t\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) )\n\t\t\t\t\t?.id\n\t\t)\n\t\t.filter( ( id ) => id !== undefined );\n};\n\n/**\n * Renders a flat term selector component.\n *\n * @param {Object} props The component props.\n * @param {string} props.slug The slug of the taxonomy.\n *\n * @return {React.ReactNode} The rendered flat term selector component.\n */\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getEntityRecord( 'root', 'taxonomy', slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\tonUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\t// In case of a failure, try assigning available terms.\n\t\t\t\t// This will invalidate the optimistic update.\n\t\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add Tag' ) : __( 'Add Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t<FormTokenField\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</VStack>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAChC,qBAA6C;AAC7C,wBAIO;AACP,kBAAuC;AACvC,uBAAmC;AACnC,qBAA4B;AAC5B,kBAAsB;AACtB,qBAAsC;AAKtC,mBAAqC;AACrC,mBAA6C;AAC7C,6BAA0B;AAqQxB;AA7PF,IAAM,cAAc,CAAC;AAQrB,IAAM,wBAAwB;AAC9B,IAAM,gBAAgB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AACV;AAEA,IAAM,iBAAiB,CAAE,OAAO,cAC/B,6BAAgB,KAAM,EAAE,YAAY,UACpC,6BAAgB,KAAM,EAAE,YAAY;AAErC,IAAM,iBAAiB,CAAE,OAAO,UAAW;AAC1C,SAAO,MACL;AAAA,IACA,CAAE,aACD,MAAM,KAAM,CAAE,SAAU,eAAgB,KAAK,MAAM,QAAS,CAAE,GAC3D;AAA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AO,kBAAkB,WAAY;AACrC,kBAAe,UAAW;AAAA,EAC3B;AAEA,QAAM,eACL,UAAU,QAAQ,iBAChB,SAAS,iBAAa,gBAAI,SAAU,QAAI,gBAAI,UAAW;AAC1D,QAAM,eACL,UAAU,QAAQ,kBAChB,SAAS,iBAAa,gBAAI,KAAM,QAAI,gBAAI,MAAO;AAClD,QAAM,qBAAiB;AAAA;AAAA,QAEtB,gBAAI,YAAY,MAAO;AAAA,IACvB;AAAA,EACD;AACA,QAAM,uBAAmB;AAAA;AAAA,QAExB,gBAAI,cAAc,MAAO;AAAA,IACzB;AAAA,EACD;AACA,QAAM,sBAAkB;AAAA;AAAA,QAEvB,gBAAI,aAAa,MAAO;AAAA,IACxB;AAAA,EACD;AAEA,SACC,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GACjB;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,eAAgB;AAAA,QAChB,gBAAiB;AAAA,QACjB,OAAQ;AAAA,QACR,UAAW;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,QAAQ;AAAA,QACT;AAAA;AAAA,IACD;AAAA,IACA,4CAAC,uBAAAC,SAAA,EAAc,UAAsB,UAAW,YAAa;AAAA,KAC9D;AAEF;AAEA,IAAO,iCAAQ,+BAAa,yBAA0B,EAAG,gBAAiB;",
|
|
6
|
+
"names": ["editorStore", "coreStore", "noticesStore", "VStack", "MostUsedTerms"]
|
|
7
7
|
}
|
|
@@ -62,12 +62,8 @@ function PostTaxonomies({ taxonomyWrapper = identity }) {
|
|
|
62
62
|
);
|
|
63
63
|
return visibleTaxonomies.map((taxonomy) => {
|
|
64
64
|
const TaxonomyComponent = taxonomy.hierarchical ? import_hierarchical_term_selector.default : import_flat_term_selector.default;
|
|
65
|
-
const taxonomyComponentProps = {
|
|
66
|
-
slug: taxonomy.slug,
|
|
67
|
-
...taxonomy.hierarchical ? {} : { __nextHasNoMarginBottom: true }
|
|
68
|
-
};
|
|
69
65
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.Fragment, { children: taxonomyWrapper(
|
|
70
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaxonomyComponent, {
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaxonomyComponent, { slug: taxonomy.slug }),
|
|
71
67
|
taxonomy
|
|
72
68
|
) }, `taxonomy-${taxonomy.slug}`);
|
|
73
69
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-taxonomies/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( { taxonomyWrapper = identity } ) {\n\tconst { postType, taxonomies } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t{ per_page: -1 }\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst visibleTaxonomies = ( taxonomies ?? [] ).filter(\n\t\t( taxonomy ) =>\n\t\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t\ttaxonomy.types.includes( postType ) && taxonomy.visibility?.show_ui\n\t);\n\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,kBAA0B;AAC1B,uBAAmC;AAKnC,wCAAqC;AACrC,gCAA6B;AAC7B,mBAAqC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( { taxonomyWrapper = identity } ) {\n\tconst { postType, taxonomies } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t{ per_page: -1 }\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst visibleTaxonomies = ( taxonomies ?? [] ).filter(\n\t\t( taxonomy ) =>\n\t\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t\ttaxonomy.types.includes( postType ) && taxonomy.visibility?.show_ui\n\t);\n\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\n/**\n * Renders the taxonomies associated with a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.\n *\n * @return {Array} An array of JSX elements representing the visible taxonomies.\n */\nexport default PostTaxonomies;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,kBAA0B;AAC1B,uBAAmC;AAKnC,wCAAqC;AACrC,gCAA6B;AAC7B,mBAAqC;AA8BhC;AA5BL,IAAM,WAAW,CAAE,MAAO;AAEnB,SAAS,eAAgB,EAAE,kBAAkB,SAAS,GAAI;AAChE,QAAM,EAAE,UAAU,WAAW,QAAI,uBAAW,CAAE,WAAY;AACzD,WAAO;AAAA,MACN,UAAU,OAAQ,aAAAA,KAAY,EAAE,mBAAmB;AAAA,MACnD,YAAY,OAAQ,iBAAAC,KAAU,EAAE;AAAA,QAC/B;AAAA,QACA;AAAA,QACA,EAAE,UAAU,GAAG;AAAA,MAChB;AAAA,IACD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,qBAAsB,cAAc,CAAC,GAAI;AAAA,IAC9C,CAAE;AAAA;AAAA;AAAA,MAGD,SAAS,MAAM,SAAU,QAAS,KAAK,SAAS,YAAY;AAAA;AAAA,EAC9D;AAEA,SAAO,kBAAkB,IAAK,CAAE,aAAc;AAC7C,UAAM,oBAAoB,SAAS,eAChC,kCAAAC,UACA,0BAAAC;AAEH,WACC,4CAAC,2BACE;AAAA,MACD,4CAAC,qBAAkB,MAAO,SAAS,MAAO;AAAA,MAC1C;AAAA,IACD,KAJe,YAAa,SAAS,IAAK,EAK3C;AAAA,EAEF,CAAE;AACH;AAUA,IAAO,0BAAQ;",
|
|
6
6
|
"names": ["editorStore", "coreStore", "HierarchicalTermSelector", "FlatTermSelector"]
|
|
7
7
|
}
|
|
@@ -112,7 +112,8 @@ var {
|
|
|
112
112
|
reusableBlocksSelectKey,
|
|
113
113
|
sectionRootClientIdKey,
|
|
114
114
|
mediaEditKey,
|
|
115
|
-
getMediaSelectKey
|
|
115
|
+
getMediaSelectKey,
|
|
116
|
+
isIsolatedEditorKey
|
|
116
117
|
} = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
117
118
|
function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
118
119
|
const isLargeViewport = (0, import_compose.useViewportMatch)("medium");
|
|
@@ -294,7 +295,14 @@ function useBlockEditorSettings(settings, postType, postId, renderingMode) {
|
|
|
294
295
|
template: postType === "wp_navigation" ? [["core/navigation", {}, []]] : settings.template,
|
|
295
296
|
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
296
297
|
[sectionRootClientIdKey]: sectionRootClientId,
|
|
297
|
-
editorTool: renderingMode === "post-only" && postType !== "wp_template" ? "edit" : void 0
|
|
298
|
+
editorTool: renderingMode === "post-only" && postType !== "wp_template" ? "edit" : void 0,
|
|
299
|
+
// When editing template parts, patterns, or navigation directly,
|
|
300
|
+
// we're in an isolated editing context (focused on that entity alone).
|
|
301
|
+
[isIsolatedEditorKey]: [
|
|
302
|
+
"wp_template_part",
|
|
303
|
+
"wp_block",
|
|
304
|
+
"wp_navigation"
|
|
305
|
+
].includes(postType)
|
|
298
306
|
};
|
|
299
307
|
return blockEditorSettings;
|
|
300
308
|
}, [
|