@wordpress/editor 14.18.0 → 14.19.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/build/components/document-outline/index.js +16 -16
  4. package/build/components/document-outline/index.js.map +1 -1
  5. package/build/components/entities-saved-states/entity-record-item.js +2 -1
  6. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  7. package/build/components/entities-saved-states/entity-type-list.js +2 -1
  8. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  9. package/build/components/entities-saved-states/index.js +66 -42
  10. package/build/components/entities-saved-states/index.js.map +1 -1
  11. package/build/components/post-actions/index.js +19 -28
  12. package/build/components/post-actions/index.js.map +1 -1
  13. package/build/components/post-card-panel/index.js +2 -2
  14. package/build/components/post-card-panel/index.js.map +1 -1
  15. package/build/components/post-featured-image/index.js +4 -2
  16. package/build/components/post-featured-image/index.js.map +1 -1
  17. package/build/components/post-template/block-theme.js +68 -48
  18. package/build/components/post-template/block-theme.js.map +1 -1
  19. package/build/components/post-template/classic-theme.js +30 -18
  20. package/build/components/post-template/classic-theme.js.map +1 -1
  21. package/build/components/post-template/create-new-template-modal.js +3 -1
  22. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  23. package/build/components/post-template/panel.js +3 -11
  24. package/build/components/post-template/panel.js.map +1 -1
  25. package/build/components/preferences-modal/block-visibility.js +2 -1
  26. package/build/components/preferences-modal/block-visibility.js.map +1 -1
  27. package/build/components/preferences-modal/index.js +1 -1
  28. package/build/components/preferences-modal/index.js.map +1 -1
  29. package/build/components/preview-dropdown/index.js +6 -3
  30. package/build/components/preview-dropdown/index.js.map +1 -1
  31. package/build/components/provider/index.js +19 -18
  32. package/build/components/provider/index.js.map +1 -1
  33. package/build/components/sidebar/header.js +1 -1
  34. package/build/components/sidebar/header.js.map +1 -1
  35. package/build/components/sidebar/index.js +1 -1
  36. package/build/components/sidebar/index.js.map +1 -1
  37. package/build/components/start-page-options/index.js +148 -23
  38. package/build/components/start-page-options/index.js.map +1 -1
  39. package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
  40. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  41. package/build/store/private-actions.js +29 -2
  42. package/build/store/private-actions.js.map +1 -1
  43. package/build/store/private-selectors.js +44 -0
  44. package/build/store/private-selectors.js.map +1 -1
  45. package/build/utils/media-upload/index.js +5 -2
  46. package/build/utils/media-upload/index.js.map +1 -1
  47. package/build-module/components/document-outline/index.js +17 -17
  48. package/build-module/components/document-outline/index.js.map +1 -1
  49. package/build-module/components/entities-saved-states/entity-record-item.js +2 -1
  50. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  51. package/build-module/components/entities-saved-states/entity-type-list.js +2 -1
  52. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  53. package/build-module/components/entities-saved-states/index.js +67 -43
  54. package/build-module/components/entities-saved-states/index.js.map +1 -1
  55. package/build-module/components/post-actions/index.js +19 -28
  56. package/build-module/components/post-actions/index.js.map +1 -1
  57. package/build-module/components/post-card-panel/index.js +2 -2
  58. package/build-module/components/post-card-panel/index.js.map +1 -1
  59. package/build-module/components/post-featured-image/index.js +4 -2
  60. package/build-module/components/post-featured-image/index.js.map +1 -1
  61. package/build-module/components/post-template/block-theme.js +68 -48
  62. package/build-module/components/post-template/block-theme.js.map +1 -1
  63. package/build-module/components/post-template/classic-theme.js +30 -18
  64. package/build-module/components/post-template/classic-theme.js.map +1 -1
  65. package/build-module/components/post-template/create-new-template-modal.js +3 -1
  66. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  67. package/build-module/components/post-template/panel.js +3 -11
  68. package/build-module/components/post-template/panel.js.map +1 -1
  69. package/build-module/components/preferences-modal/block-visibility.js +2 -1
  70. package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
  71. package/build-module/components/preferences-modal/index.js +1 -1
  72. package/build-module/components/preferences-modal/index.js.map +1 -1
  73. package/build-module/components/preview-dropdown/index.js +6 -3
  74. package/build-module/components/preview-dropdown/index.js.map +1 -1
  75. package/build-module/components/provider/index.js +19 -18
  76. package/build-module/components/provider/index.js.map +1 -1
  77. package/build-module/components/sidebar/header.js +1 -1
  78. package/build-module/components/sidebar/header.js.map +1 -1
  79. package/build-module/components/sidebar/index.js +1 -1
  80. package/build-module/components/sidebar/index.js.map +1 -1
  81. package/build-module/components/start-page-options/index.js +148 -24
  82. package/build-module/components/start-page-options/index.js.map +1 -1
  83. package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
  84. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  85. package/build-module/store/private-actions.js +25 -0
  86. package/build-module/store/private-actions.js.map +1 -1
  87. package/build-module/store/private-selectors.js +43 -0
  88. package/build-module/store/private-selectors.js.map +1 -1
  89. package/build-module/utils/media-upload/index.js +5 -2
  90. package/build-module/utils/media-upload/index.js.map +1 -1
  91. package/build-style/style-rtl.css +49 -8
  92. package/build-style/style.css +49 -8
  93. package/build-types/components/document-outline/index.d.ts.map +1 -1
  94. package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
  95. package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
  96. package/build-types/components/entities-saved-states/index.d.ts +6 -2
  97. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  98. package/build-types/components/post-actions/index.d.ts.map +1 -1
  99. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  100. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  101. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  102. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  103. package/build-types/components/post-template/panel.d.ts.map +1 -1
  104. package/build-types/components/preferences-modal/block-visibility.d.ts.map +1 -1
  105. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  106. package/build-types/components/provider/index.d.ts.map +1 -1
  107. package/build-types/components/start-page-options/index.d.ts +2 -1
  108. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  109. package/build-types/store/private-actions.d.ts +4 -0
  110. package/build-types/store/private-actions.d.ts.map +1 -1
  111. package/build-types/store/private-selectors.d.ts +13 -0
  112. package/build-types/store/private-selectors.d.ts.map +1 -1
  113. package/build-types/utils/media-upload/index.d.ts +3 -1
  114. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  115. package/package.json +37 -37
  116. package/src/components/document-outline/index.js +22 -16
  117. package/src/components/entities-saved-states/entity-record-item.js +1 -0
  118. package/src/components/entities-saved-states/entity-type-list.js +6 -2
  119. package/src/components/entities-saved-states/index.js +98 -58
  120. package/src/components/entities-saved-states/style.scss +40 -5
  121. package/src/components/post-actions/index.js +19 -37
  122. package/src/components/post-card-panel/index.js +7 -5
  123. package/src/components/post-featured-image/index.js +2 -0
  124. package/src/components/post-template/block-theme.js +76 -56
  125. package/src/components/post-template/classic-theme.js +31 -15
  126. package/src/components/post-template/create-new-template-modal.js +1 -0
  127. package/src/components/post-template/panel.js +2 -12
  128. package/src/components/post-text-editor/style.scss +0 -2
  129. package/src/components/preferences-modal/block-visibility.js +2 -1
  130. package/src/components/preferences-modal/index.js +1 -1
  131. package/src/components/preview-dropdown/index.js +8 -6
  132. package/src/components/provider/index.js +21 -30
  133. package/src/components/sidebar/header.js +1 -1
  134. package/src/components/sidebar/index.js +1 -1
  135. package/src/components/start-page-options/index.js +149 -23
  136. package/src/components/start-page-options/style.scss +27 -0
  137. package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
  138. package/src/store/private-actions.js +33 -0
  139. package/src/store/private-selectors.js +57 -0
  140. package/src/utils/media-upload/index.js +3 -0
  141. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","useEditedEntityRecordsWithPermissions","postType","postIds","items","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","map","postId","useMemo","item","index","PostActions","onActionPerformed","activeModalAction","setActiveModalAction","useState","_postIds","Array","isArray","itemsWithPermissions","allActions","usePostActions","actions","filter","action","isEligible","some","itemWithPermissions","length","supportsBulk","jsxs","Fragment","children","placement","jsx","TriggerButton","render","Button","size","icon","moreVertical","label","__","disabled","accessibleWhenDisabled","className","Popover","ActionsDropdownMenuGroup","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","useRegistry","Group","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nfunction useEditedEntityRecordsWithPermissions( postType, postIds ) {\n\tconst { items, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titems: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEditedEntityRecord( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t\tpermissions: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEntityRecordPermissions( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\treturn items.map( ( item, index ) => ( {\n\t\t\t...item,\n\t\t\tpermissions: permissions[ index ],\n\t\t} ) );\n\t}, [ items, permissions ] );\n}\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\tconst _postIds = useMemo( () => {\n\t\tif ( Array.isArray( postId ) ) {\n\t\t\treturn postId;\n\t\t}\n\t\treturn postId ? [ postId ] : [];\n\t}, [ postId ] );\n\n\tconst itemsWithPermissions = useEditedEntityRecordsWithPermissions(\n\t\tpostType,\n\t\t_postIds\n\t);\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t( ! action.isEligible ||\n\t\t\t\t\titemsWithPermissions.some( ( itemWithPermissions ) =>\n\t\t\t\t\t\taction.isEligible( itemWithPermissions )\n\t\t\t\t\t) ) &&\n\t\t\t\t( itemsWithPermissions.length < 2 || action.supportsBulk )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemsWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\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,EAAGA,MAAQ;QACjB2B,OAAO,EAAGA,CAAA,KAAM;UACf,IAAK,aAAa,IAAI3B,MAAM,EAAG;YAC9BV,oBAAoB,CAAEU,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAAC2C,QAAQ,CAAEpE,KAAK,EAAE;YAAEiE;UAAS,CAAE,CAAC;QACvC,CAAG;QACHjE,KAAK,EAAGA;MAAO,GATTyB,MAAM,CAACsC,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","PostActions","postType","postId","onActionPerformed","activeModalAction","setActiveModalAction","useState","item","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","itemWithPermissions","useMemo","allActions","usePostActions","actions","filter","action","isEligible","jsxs","Fragment","children","placement","jsx","TriggerButton","render","Button","size","icon","moreVertical","label","__","disabled","length","accessibleWhenDisabled","className","Popover","ActionsDropdownMenuGroup","items","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","useRegistry","Group","map","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\n\tconst { item, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titem: getEditedEntityRecord( 'postType', postType, postId ),\n\t\t\t\tpermissions: getEntityRecordPermissions(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\tconst itemWithPermissions = useMemo( () => {\n\t\treturn {\n\t\t\t...item,\n\t\t\tpermissions,\n\t\t};\n\t}, [ item, permissions ] );\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t! action.isEligible || action.isEligible( itemWithPermissions )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titems={ [ itemWithPermissions ] }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ itemWithPermissions ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\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;IACbyB,gBAAgB,EAAG,4CAA6C1D,SAAS,CACxEuB,MAAM,CAACoC,EACR,CAAC,EAAK;IAAAhC,QAAA,eAEN,IAAA7B,WAAA,CAAA+B,GAAA,EAACN,MAAM,CAACqC,WAAW;MAAChB,KAAK,EAAGA,KAAO;MAACE,UAAU,EAAGA;IAAY,CAAE;EAAC,CAC1D,CAAC;AAEV;AAEA,SAASH,wBAAwBA,CAAE;EAAEtB,OAAO;EAAEuB,KAAK;EAAEpC;AAAqB,CAAC,EAAG;EAC7E,MAAMqD,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,oBACC,IAAAhE,WAAA,CAAA+B,GAAA,EAAC9B,IAAI,CAACgE,KAAK;IAAApC,QAAA,EACRN,OAAO,CAAC2C,GAAG,CAAIzC,MAAM,IAAM;MAC5B,oBACC,IAAAzB,WAAA,CAAA+B,GAAA,EAACkB,uBAAuB;QAEvBxB,MAAM,EAAGA,MAAQ;QACjByB,OAAO,EAAGA,CAAA,KAAM;UACf,IAAK,aAAa,IAAIzB,MAAM,EAAG;YAC9Bf,oBAAoB,CAAEe,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAAC0C,QAAQ,CAAErB,KAAK,EAAE;YAAEiB;UAAS,CAAE,CAAC;QACvC,CAAG;QACHjB,KAAK,EAAGA;MAAO,GATTrB,MAAM,CAACoC,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
@@ -109,9 +109,9 @@ function PostCardPanel({
109
109
  }), pageTypeBadge && postIds.length === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(Badge, {
110
110
  children: pageTypeBadge
111
111
  })]
112
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_postActions.default, {
112
+ }), postIds.length === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_postActions.default, {
113
113
  postType: postType,
114
- postId: postId,
114
+ postId: postIds[0],
115
115
  onActionPerformed: onActionPerformed
116
116
  })]
117
117
  }), postIds.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_coreData","_data","_element","_i18n","_dom","_store","_constants","_lockUnlock","_postActions","_interopRequireDefault","_pageTypeBadge","_getTemplateInfo","_jsxRuntime","Badge","unlock","componentsPrivateApis","PostCardPanel","postType","postId","onActionPerformed","postIds","useMemo","Array","isArray","postTitle","icon","labels","useSelect","select","getEditedEntityRecord","getEntityRecord","getPostType","coreStore","getPostIcon","editorStore","_title","_record","length","_getEntityRecord","default_template_types","templateTypes","_templateInfo","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","includes","getTemplateInfo","template","title","area","pageTypeBadge","usePageTypeBadge","__","name","sprintf","stripHTML","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","align","jsx","Icon","__experimentalText","numberOfLines","truncate","as","default","toLowerCase"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"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, getEntityRecord, 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\tgetEntityRecord( 'root', '__unstableBase' ) ?? {};\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: %i number of selected items %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%i %s' ),\n\t\t\tpostId.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\talign=\"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<PostActions\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tpostId={ postId }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\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"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IA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2C,IAAA,EAACzD,WAAA,CAAA8D,oBAAM;MACNH,OAAO,EAAG,CAAG;MACbC,SAAS,EAAC,gCAAgC;MAC1CG,KAAK,EAAC,YAAY;MAAAF,QAAA,gBAElB,IAAA/C,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAiE,IAAI;QAACL,SAAS,EAAC,8BAA8B;QAACjC,IAAI,EAAGA;MAAM,CAAE,CAAC,eAC/D,IAAAb,WAAA,CAAA2C,IAAA,EAACzD,WAAA,CAAAkE,kBAAI;QACJC,aAAa,EAAG,CAAG;QACnBC,QAAQ;QACRR,SAAS,EAAC,+BAA+B;QACzCS,EAAE,EAAC,IAAI;QAAAR,QAAA,gBAEP,IAAA/C,WAAA,CAAAkD,GAAA;UAAMJ,SAAS,EAAC,oCAAoC;UAAAC,QAAA,EACjDZ;QAAK,CACF,CAAC,EACLE,aAAa,IAAI7B,OAAO,CAACiB,MAAM,KAAK,CAAC,iBACtC,IAAAzB,WAAA,CAAAkD,GAAA,EAACjD,KAAK;UAAA8C,QAAA,EAAGV;QAAa,CAAS,CAC/B;MAAA,CACI,CAAC,eACP,IAAArC,WAAA,CAAAkD,GAAA,EAACtD,YAAA,CAAA4D,OAAW;QACXnD,QAAQ,EAAGA,QAAU;QACrBC,MAAM,EAAGA,MAAQ;QACjBC,iBAAiB,EAAGA;MAAmB,CACvC,CAAC;IAAA,CACK,CAAC,EACPC,OAAO,CAACiB,MAAM,GAAG,CAAC,iBACnB,IAAAzB,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAkE,kBAAI;MAACN,SAAS,EAAC,qCAAqC;MAAAC,QAAA,EAClD,IAAAN,aAAO;MACR;MACA,IAAAF,QAAE,EAAE,6CAA8C,CAAC,EACnDzB,MAAM,EAAE0B,IAAI,CAACiB,WAAW,CAAC,CAC1B;IAAC,CACI,CACN;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_coreData","_data","_element","_i18n","_dom","_store","_constants","_lockUnlock","_postActions","_interopRequireDefault","_pageTypeBadge","_getTemplateInfo","_jsxRuntime","Badge","unlock","componentsPrivateApis","PostCardPanel","postType","postId","onActionPerformed","postIds","useMemo","Array","isArray","postTitle","icon","labels","useSelect","select","getEditedEntityRecord","getEntityRecord","getPostType","coreStore","getPostIcon","editorStore","_title","_record","length","_getEntityRecord","default_template_types","templateTypes","_templateInfo","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","includes","getTemplateInfo","template","title","area","pageTypeBadge","usePageTypeBadge","__","name","sprintf","stripHTML","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","align","jsx","Icon","__experimentalText","numberOfLines","truncate","as","default","toLowerCase"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"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, getEntityRecord, 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\tgetEntityRecord( 'root', '__unstableBase' ) ?? {};\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: %i number of selected items %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%i %s' ),\n\t\t\tpostId.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\talign=\"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"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,MAA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,EAAC,gCAAgC;MAC1CG,KAAK,EAAC,YAAY;MAAAF,QAAA,gBAElB,IAAA/C,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAiE,IAAI;QAACL,SAAS,EAAC,8BAA8B;QAACjC,IAAI,EAAGA;MAAM,CAAE,CAAC,eAC/D,IAAAb,WAAA,CAAA2C,IAAA,EAACzD,WAAA,CAAAkE,kBAAI;QACJC,aAAa,EAAG,CAAG;QACnBC,QAAQ;QACRR,SAAS,EAAC,+BAA+B;QACzCS,EAAE,EAAC,IAAI;QAAAR,QAAA,gBAEP,IAAA/C,WAAA,CAAAkD,GAAA;UAAMJ,SAAS,EAAC,oCAAoC;UAAAC,QAAA,EACjDZ;QAAK,CACF,CAAC,EACLE,aAAa,IAAI7B,OAAO,CAACiB,MAAM,KAAK,CAAC,iBACtC,IAAAzB,WAAA,CAAAkD,GAAA,EAACjD,KAAK;UAAA8C,QAAA,EAAGV;QAAa,CAAS,CAC/B;MAAA,CACI,CAAC,EACL7B,OAAO,CAACiB,MAAM,KAAK,CAAC,iBACrB,IAAAzB,WAAA,CAAAkD,GAAA,EAACtD,YAAA,CAAA4D,OAAW;QACXnD,QAAQ,EAAGA,QAAU;QACrBC,MAAM,EAAGE,OAAO,CAAE,CAAC,CAAI;QACvBD,iBAAiB,EAAGA;MAAmB,CACvC,CACD;IAAA,CACM,CAAC,EACPC,OAAO,CAACiB,MAAM,GAAG,CAAC,iBACnB,IAAAzB,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAkE,kBAAI;MAACN,SAAS,EAAC,qCAAqC;MAAAC,QAAA,EAClD,IAAAN,aAAO;MACR;MACA,IAAAF,QAAE,EAAE,6CAA8C,CAAC,EACnDzB,MAAM,EAAE0B,IAAI,CAACiB,WAAW,CAAC,CAC1B;IAAC,CACI,CACN;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
@@ -105,7 +105,8 @@ function PostFeaturedImage({
105
105
  onError(message) {
106
106
  noticeOperations.removeAllNotices();
107
107
  noticeOperations.createErrorNotice(message);
108
- }
108
+ },
109
+ multiple: false
109
110
  });
110
111
  }
111
112
 
@@ -261,7 +262,8 @@ const applyWithDispatch = (0, _data.withDispatch)((dispatch, {
261
262
  onError(message) {
262
263
  noticeOperations.removeAllNotices();
263
264
  noticeOperations.createErrorNotice(message);
264
- }
265
+ },
266
+ multiple: false
265
267
  });
266
268
  },
267
269
  onRemoveImage() {
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_hooks","_components","_blob","_element","_compose","_data","_blockEditor","_coreData","_check","_store","_jsxRuntime","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","__","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","jsx","children","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","applyFilters","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isRequestingFeaturedImageMedia","returnsFocusRef","useRef","isLoading","setIsLoading","useState","getSettings","useSelect","blockEditorStore","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","isBlobURL","url","onError","message","removeAllNotices","createErrorNotice","getImageDescription","imageMedia","alt_text","sprintf","full","file","slug","returnFocus","node","current","focus","isMissingMedia","jsxs","default","className","MediaUploadCheck","fallback","MediaUpload","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","Notice","status","isDismissible","Button","__next40pxDefaultSize","ref","onClick","disabled","accessibleWhenDisabled","src","alt","Spinner","set_featured_image","__experimentalHStack","clsx","variant","undefined","isDestructive","DropZone","onFilesDrop","value","applyWithSelect","withSelect","select","getMedia","getPostType","hasFinishedResolution","coreStore","getCurrentPostId","getEditedPostAttribute","editorStore","context","applyWithDispatch","withDispatch","dispatch","editPost","featured_media","onDropImage","_default","exports","compose","withNotices","withFilters"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\tNotice,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n\tisRequestingFeaturedImageMedia,\n} ) {\n\tconst returnsFocusRef = useRef( false );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { mediaSourceUrl } = getMediaDetails( media, currentPostId );\n\n\tfunction onDropFiles( filesList ) {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\t/**\n\t * Generates the featured image alt text for this editing context.\n\t *\n\t * @param {Object} imageMedia The image media object.\n\t * @param {string} imageMedia.alt_text The alternative text of the image.\n\t * @param {Object} imageMedia.media_details The media details of the image.\n\t * @param {Object} imageMedia.media_details.sizes The sizes of the image.\n\t * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.\n\t * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.\n\t * @param {string} imageMedia.slug The slug of the image.\n\t * @return {string} The featured image alt text.\n\t */\n\tfunction getImageDescription( imageMedia ) {\n\t\tif ( imageMedia.alt_text ) {\n\t\t\treturn sprintf(\n\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\timageMedia.alt_text\n\t\t\t);\n\t\t}\n\t\treturn sprintf(\n\t\t\t// Translators: %s: The selected image filename.\n\t\t\t__(\n\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t),\n\t\t\timageMedia.media_details.sizes?.full?.file || imageMedia.slug\n\t\t);\n\t}\n\n\tfunction returnFocus( node ) {\n\t\tif ( returnsFocusRef.current && node ) {\n\t\t\tnode.focus();\n\t\t\treturnsFocusRef.current = false;\n\t\t}\n\t}\n\n\tconst isMissingMedia =\n\t\t! isRequestingFeaturedImageMedia && !! featuredImageId && ! media;\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ getImageDescription( media ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t{ isMissingMedia ? (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Could not retrieve the featured image data.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tref={ returnFocus }\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Edit or replace the featured image'\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\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isLoading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__preview-image\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt={ getImageDescription(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmedia\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\t{ ( isLoading ||\n\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia ) && (\n\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-missing-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia,\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-is-requesting-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia,\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\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\t// Signal that the toggle button should be focused,\n\t\t\t\t\t\t\t\t\t\t\t\t// when it is rendered. Can't focus it directly here\n\t\t\t\t\t\t\t\t\t\t\t\t// because it's rendered conditionally.\n\t\t\t\t\t\t\t\t\t\t\t\treturnsFocusRef.current = true;\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tisDestructive={ isMissingMedia }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType, hasFinishedResolution } =\n\t\tselect( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t\tisRequestingFeaturedImageMedia:\n\t\t\t!! featuredImageId &&\n\t\t\t! hasFinishedResolution( 'getMedia', [\n\t\t\t\tfeaturedImageId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] ),\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\n/**\n * Renders the component for managing the featured image of a post.\n *\n * @param {Object} props Props.\n * @param {number} props.currentPostId ID of the current post.\n * @param {number} props.featuredImageId ID of the featured image.\n * @param {Function} props.onUpdateImage Function to call when the image is updated.\n * @param {Function} props.onRemoveImage Function to call when the image is removed.\n * @param {Object} props.media The media object representing the featured image.\n * @param {string} props.postType Post type.\n * @param {Element} props.noticeUI UI for displaying notices.\n * @param {Object} props.noticeOperations Operations for managing notices.\n *\n * @return {Element} Component to be rendered .\n */\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAAmD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,SAAS,EAAG;MACxB4D,MAAM,CAAE9D,kBAAiB,CAAC,CACxBF,WAAW,CAAC,CAAC,CACbK,WAAW,CAAE;QACbC,YAAY,EAAE,CAAE,OAAO,CAAE;QACzBF,SAAS;QACTG,YAAYA,CAAE,CAAEC,KAAK,CAAE,EAAG;UACzBoE,QAAQ,CAAE;YAAEC,cAAc,EAAErE,KAAK,CAAChC;UAAG,CAAE,CAAC;QACzC,CAAC;QACDmC,OAAOA,CAAEC,OAAO,EAAG;UAClBnB,gBAAgB,CAACoB,gBAAgB,CAAC,CAAC;UACnCpB,gBAAgB,CAACqB,iBAAiB,CAAEF,OAAQ,CAAC;QAC9C;MACD,CAAE,CAAC;IACL,CAAC;IACDtB,aAAaA,CAAA,EAAG;MACfsF,QAAQ,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdA,IAAAE,QAAA,GAAAC,OAAA,CAAApD,OAAA,GAee,IAAAqD,gBAAO,EACrBC,uBAAW,EACXpB,eAAe,EACfW,iBAAiB,EACjB,IAAAU,uBAAW,EAAE,0BAA2B,CACzC,CAAC,CAAEjG,iBAAkB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_hooks","_components","_blob","_element","_compose","_data","_blockEditor","_coreData","_check","_store","_jsxRuntime","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","__","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","jsx","children","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","applyFilters","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isRequestingFeaturedImageMedia","returnsFocusRef","useRef","isLoading","setIsLoading","useState","getSettings","useSelect","blockEditorStore","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","isBlobURL","url","onError","message","removeAllNotices","createErrorNotice","multiple","getImageDescription","imageMedia","alt_text","sprintf","full","file","slug","returnFocus","node","current","focus","isMissingMedia","jsxs","default","className","MediaUploadCheck","fallback","MediaUpload","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","Notice","status","isDismissible","Button","__next40pxDefaultSize","ref","onClick","disabled","accessibleWhenDisabled","src","alt","Spinner","set_featured_image","__experimentalHStack","clsx","variant","undefined","isDestructive","DropZone","onFilesDrop","value","applyWithSelect","withSelect","select","getMedia","getPostType","hasFinishedResolution","coreStore","getCurrentPostId","getEditedPostAttribute","editorStore","context","applyWithDispatch","withDispatch","dispatch","editPost","featured_media","onDropImage","_default","exports","compose","withNotices","withFilters"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\tNotice,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n\tisRequestingFeaturedImageMedia,\n} ) {\n\tconst returnsFocusRef = useRef( false );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { mediaSourceUrl } = getMediaDetails( media, currentPostId );\n\n\tfunction onDropFiles( filesList ) {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t\tmultiple: false,\n\t\t} );\n\t}\n\n\t/**\n\t * Generates the featured image alt text for this editing context.\n\t *\n\t * @param {Object} imageMedia The image media object.\n\t * @param {string} imageMedia.alt_text The alternative text of the image.\n\t * @param {Object} imageMedia.media_details The media details of the image.\n\t * @param {Object} imageMedia.media_details.sizes The sizes of the image.\n\t * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.\n\t * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.\n\t * @param {string} imageMedia.slug The slug of the image.\n\t * @return {string} The featured image alt text.\n\t */\n\tfunction getImageDescription( imageMedia ) {\n\t\tif ( imageMedia.alt_text ) {\n\t\t\treturn sprintf(\n\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\timageMedia.alt_text\n\t\t\t);\n\t\t}\n\t\treturn sprintf(\n\t\t\t// Translators: %s: The selected image filename.\n\t\t\t__(\n\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t),\n\t\t\timageMedia.media_details.sizes?.full?.file || imageMedia.slug\n\t\t);\n\t}\n\n\tfunction returnFocus( node ) {\n\t\tif ( returnsFocusRef.current && node ) {\n\t\t\tnode.focus();\n\t\t\treturnsFocusRef.current = false;\n\t\t}\n\t}\n\n\tconst isMissingMedia =\n\t\t! isRequestingFeaturedImageMedia && !! featuredImageId && ! media;\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ getImageDescription( media ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t{ isMissingMedia ? (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Could not retrieve the featured image data.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tref={ returnFocus }\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Edit or replace the featured image'\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\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isLoading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__preview-image\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt={ getImageDescription(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmedia\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\t{ ( isLoading ||\n\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia ) && (\n\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-missing-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia,\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-is-requesting-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia,\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\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\t// Signal that the toggle button should be focused,\n\t\t\t\t\t\t\t\t\t\t\t\t// when it is rendered. Can't focus it directly here\n\t\t\t\t\t\t\t\t\t\t\t\t// because it's rendered conditionally.\n\t\t\t\t\t\t\t\t\t\t\t\treturnsFocusRef.current = true;\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tisDestructive={ isMissingMedia }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType, hasFinishedResolution } =\n\t\tselect( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t\tisRequestingFeaturedImageMedia:\n\t\t\t!! featuredImageId &&\n\t\t\t! hasFinishedResolution( 'getMedia', [\n\t\t\t\tfeaturedImageId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] ),\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmultiple: false,\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\n/**\n * Renders the component for managing the featured image of a post.\n *\n * @param {Object} props Props.\n * @param {number} props.currentPostId ID of the current post.\n * @param {number} props.featuredImageId ID of the featured image.\n * @param {Function} props.onUpdateImage Function to call when the image is updated.\n * @param {Function} props.onRemoveImage Function to call when the image is removed.\n * @param {Object} props.media The media object representing the featured image.\n * @param {string} props.postType Post type.\n * @param {Element} props.noticeUI UI for displaying notices.\n * @param {Object} props.noticeOperations Operations for managing notices.\n *\n * @return {Element} Component to be rendered .\n */\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAAmD,IAAAY,WAAA,GAAAZ,OAAA;AAlCnD;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAIA,MAAMa,mBAAmB,GAAG,CAAE,OAAO,CAAE;;AAEvC;AACA,MAAMC,2BAA2B,GAAG,IAAAC,QAAE,EAAE,gBAAiB,CAAC;AAC1D,MAAMC,+BAA+B,GAAG,IAAAD,QAAE,EAAE,sBAAuB,CAAC;AAEpE,MAAME,YAAY,gBACjB,IAAAL,WAAA,CAAAM,GAAA;EAAAC,QAAA,EACG,IAAAJ,QAAE,EACH,kEACD;AAAC,CACC,CACH;AAED,SAASK,eAAeA,CAAEC,KAAK,EAAEC,MAAM,EAAG;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EACzC,IAAK,CAAEH,KAAK,EAAG;IACd,OAAO,CAAC,CAAC;EACV;EAEA,MAAMI,WAAW,GAAG,IAAAC,mBAAY,EAC/B,oCAAoC,EACpC,OAAO,EACPL,KAAK,CAACM,EAAE,EACRL,MACD,CAAC;EACD,IAAKG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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdA,IAAAE,QAAA,GAAAC,OAAA,CAAApD,OAAA,GAee,IAAAqD,gBAAO,EACrBC,uBAAW,EACXpB,eAAe,EACfW,iBAAiB,EACjB,IAAAU,uBAAW,EAAE,0BAA2B,CACzC,CAAC,CAAElG,iBAAkB,CAAC","ignoreList":[]}
@@ -8,11 +8,13 @@ exports.default = BlockThemeControl;
8
8
  var _data = require("@wordpress/data");
9
9
  var _htmlEntities = require("@wordpress/html-entities");
10
10
  var _components = require("@wordpress/components");
11
+ var _element = require("@wordpress/element");
11
12
  var _i18n = require("@wordpress/i18n");
12
13
  var _coreData = require("@wordpress/core-data");
13
14
  var _icons = require("@wordpress/icons");
14
15
  var _notices = require("@wordpress/notices");
15
16
  var _preferences = require("@wordpress/preferences");
17
+ var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
16
18
  var _store = require("../../store");
17
19
  var _swapTemplateButton = _interopRequireDefault(require("./swap-template-button"));
18
20
  var _resetDefaultTemplate = _interopRequireDefault(require("./reset-default-template"));
@@ -27,10 +29,10 @@ var _jsxRuntime = require("react/jsx-runtime");
27
29
  * Internal dependencies
28
30
  */
29
31
 
30
- const POPOVER_PROPS = {
31
- className: 'editor-post-template__dropdown',
32
- placement: 'bottom-start'
33
- };
32
+ /**
33
+ * Internal dependencies
34
+ */
35
+
34
36
  function BlockThemeControl({
35
37
  id
36
38
  }) {
@@ -63,12 +65,24 @@ function BlockThemeControl({
63
65
  createSuccessNotice
64
66
  } = (0, _data.useDispatch)(_notices.store);
65
67
  const {
66
- setRenderingMode
67
- } = (0, _data.useDispatch)(_store.store);
68
+ setRenderingMode,
69
+ setDefaultRenderingMode
70
+ } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
68
71
  const canCreateTemplate = (0, _data.useSelect)(select => !!select(_coreData.store).canUser('create', {
69
72
  kind: 'postType',
70
73
  name: 'wp_template'
71
74
  }), []);
75
+ const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
76
+ // Memoize popoverProps to avoid returning a new object every time.
77
+ const popoverProps = (0, _element.useMemo)(() => ({
78
+ // Anchor the popover to the middle of the entire row so that it doesn't
79
+ // move around when the label changes.
80
+ anchor: popoverAnchor,
81
+ className: 'editor-post-template__dropdown',
82
+ placement: 'left-start',
83
+ offset: 36,
84
+ shift: true
85
+ }), [popoverAnchor]);
72
86
  if (!hasResolved) {
73
87
  return null;
74
88
  }
@@ -87,49 +101,55 @@ function BlockThemeControl({
87
101
  });
88
102
  }
89
103
  };
90
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
91
- popoverProps: POPOVER_PROPS,
92
- focusOnMount: true,
93
- toggleProps: {
94
- size: 'compact',
95
- variant: 'tertiary',
96
- tooltipPosition: 'middle left'
97
- },
98
- label: (0, _i18n.__)('Template options'),
99
- text: (0, _htmlEntities.decodeEntities)(template.title),
100
- icon: null,
101
- children: ({
102
- onClose
103
- }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
104
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.MenuGroup, {
105
- children: [canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
106
- onClick: () => {
107
- onNavigateToEntityRecord({
108
- postId: template.id,
109
- postType: 'wp_template'
110
- });
111
- onClose();
112
- mayShowTemplateEditNotice();
113
- },
114
- children: (0, _i18n.__)('Edit template')
115
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_swapTemplateButton.default, {
116
- onClick: onClose
117
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_resetDefaultTemplate.default, {
118
- onClick: onClose
119
- }), canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplate.default, {
120
- onClick: onClose
104
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPanelRow.default, {
105
+ label: (0, _i18n.__)('Template'),
106
+ ref: setPopoverAnchor,
107
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
108
+ popoverProps: popoverProps,
109
+ focusOnMount: true,
110
+ toggleProps: {
111
+ size: 'compact',
112
+ variant: 'tertiary',
113
+ tooltipPosition: 'middle left'
114
+ },
115
+ label: (0, _i18n.__)('Template options'),
116
+ text: (0, _htmlEntities.decodeEntities)(template.title),
117
+ icon: null,
118
+ children: ({
119
+ onClose
120
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
121
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.MenuGroup, {
122
+ children: [canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
123
+ onClick: () => {
124
+ onNavigateToEntityRecord({
125
+ postId: template.id,
126
+ postType: 'wp_template'
127
+ });
128
+ onClose();
129
+ mayShowTemplateEditNotice();
130
+ },
131
+ children: (0, _i18n.__)('Edit template')
132
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_swapTemplateButton.default, {
133
+ onClick: onClose
134
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_resetDefaultTemplate.default, {
135
+ onClick: onClose
136
+ }), canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplate.default, {
137
+ onClick: onClose
138
+ })]
139
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
140
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
141
+ icon: !isTemplateHidden ? _icons.check : undefined,
142
+ isSelected: !isTemplateHidden,
143
+ role: "menuitemcheckbox",
144
+ onClick: () => {
145
+ const newRenderingMode = isTemplateHidden ? 'template-locked' : 'post-only';
146
+ setRenderingMode(newRenderingMode);
147
+ setDefaultRenderingMode(newRenderingMode);
148
+ },
149
+ children: (0, _i18n.__)('Show template')
150
+ })
121
151
  })]
122
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
123
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
124
- icon: !isTemplateHidden ? _icons.check : undefined,
125
- isSelected: !isTemplateHidden,
126
- role: "menuitemcheckbox",
127
- onClick: () => {
128
- setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
129
- },
130
- children: (0, _i18n.__)('Show template')
131
- })
132
- })]
152
+ })
133
153
  })
134
154
  });
135
155
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_htmlEntities","_components","_i18n","_coreData","_icons","_notices","_preferences","_store","_swapTemplateButton","_interopRequireDefault","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","DropdownMenu","popoverProps","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","children","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","default","check","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\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\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,mBAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,kBAAA,GAAAH,sBAAA,CAAAV,OAAA;AAAsD,IAAAc,WAAA,GAAAd,OAAA;AAnBtD;AACA;AACA;;AAUA;AACA;AACA;;AAOA,MAAMe,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,CAAC;AAEc,SAASC,iBAAiBA,CAAE;EAAEC;AAAG,CAAC,EAAG;EACnD,MAAM;IACLC,gBAAg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V,eAED,IAAApC,WAAA,CAAA2C,GAAA,EAAChD,mBAAA,CAAAoE,OAAkB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CAAC,eAC1C,IAAAxD,WAAA,CAAA2C,GAAA,EAAC9C,qBAAA,CAAAkE,OAAoB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CAAC,EAC1C3B,iBAAiB,iBAClB,IAAA7B,WAAA,CAAA2C,GAAA,EAAC5C,kBAAA,CAAAgE,OAAiB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CACxC;MAAA,CACS,CAAC,eACZ,IAAAxD,WAAA,CAAA2C,GAAA,EAACvD,WAAA,CAAAuE,SAAS;QAAAJ,QAAA,eACT,IAAAvD,WAAA,CAAA2C,GAAA,EAACvD,WAAA,CAAAwE,QAAQ;UACRN,IAAI,EAAG,CAAEhD,gBAAgB,GAAG0D,YAAK,GAAGzB,SAAW;UAC/C0B,UAAU,EAAG,CAAE3D,gBAAkB;UACjC4D,IAAI,EAAC,kBAAkB;UACvB7B,OAAO,EAAGA,CAAA,KAAM;YACfT,gBAAgB,CACftB,gBAAgB,GACb,iBAAiB,GACjB,WACJ,CAAC;UACF,CAAG;UAAAiD,QAAA,EAED,IAAAnB,QAAE,EAAE,eAAgB;QAAC,CACd;MAAC,CACD,CAAC;IAAA,CACX;EACF,CACY,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_htmlEntities","_components","_element","_i18n","_coreData","_icons","_notices","_preferences","_postPanelRow","_interopRequireDefault","_store","_swapTemplateButton","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","className","placement","offset","shift","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","default","ref","children","DropdownMenu","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","check","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\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\tclassName: 'editor-post-template__dropdown',\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\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,aAAA,GAAAC,sBAAA,CAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,qBAAA,GAAAH,sBAAA,CAAAV,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AACA,IAAAe,kBAAA,GAAAL,sBAAA,CAAAV,OAAA;AAAsD,IAAAgB,WAAA,GAAAhB,OAAA;AAzBtD;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;;AAOe,SAASiB,iBAAiBA,CAAE;EAAEC;AAAG,CAAC,EAAG;EACnD,MAAM;IACLC,g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BAAiB,GACjB,WAAW;cACdsB,gBAAgB,CAAEkD,gBAAiB,CAAC;cACpCjD,uBAAuB,CAAEiD,gBAAiB,CAAC;YAC5C,CAAG;YAAArB,QAAA,EAED,IAAAV,QAAE,EAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
@@ -16,6 +16,7 @@ var _notices = require("@wordpress/notices");
16
16
  var _store = require("../../store");
17
17
  var _createNewTemplateModal = _interopRequireDefault(require("./create-new-template-modal"));
18
18
  var _hooks = require("./hooks");
19
+ var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  /**
21
22
  * WordPress dependencies
@@ -25,10 +26,6 @@ var _jsxRuntime = require("react/jsx-runtime");
25
26
  * Internal dependencies
26
27
  */
27
28
 
28
- const POPOVER_PROPS = {
29
- className: 'editor-post-template__dropdown',
30
- placement: 'bottom-start'
31
- };
32
29
  function PostTemplateToggle({
33
30
  isOpen,
34
31
  onClick
@@ -175,20 +172,35 @@ function PostTemplateDropdownContent({
175
172
  });
176
173
  }
177
174
  function ClassicThemeControl() {
178
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
179
- popoverProps: POPOVER_PROPS,
180
- focusOnMount: true,
181
- renderToggle: ({
182
- isOpen,
183
- onToggle
184
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateToggle, {
185
- isOpen: isOpen,
186
- onClick: onToggle
187
- }),
188
- renderContent: ({
189
- onClose
190
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateDropdownContent, {
191
- onClose: onClose
175
+ const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
176
+ // Memoize popoverProps to avoid returning a new object every time.
177
+ const popoverProps = (0, _element.useMemo)(() => ({
178
+ // Anchor the popover to the middle of the entire row so that it doesn't
179
+ // move around when the label changes.
180
+ anchor: popoverAnchor,
181
+ className: 'editor-post-template__dropdown',
182
+ placement: 'left-start',
183
+ offset: 36,
184
+ shift: true
185
+ }), [popoverAnchor]);
186
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPanelRow.default, {
187
+ label: (0, _i18n.__)('Template'),
188
+ ref: setPopoverAnchor,
189
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
190
+ popoverProps: popoverProps,
191
+ focusOnMount: true,
192
+ renderToggle: ({
193
+ isOpen,
194
+ onToggle
195
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateToggle, {
196
+ isOpen: isOpen,
197
+ onClick: onToggle
198
+ }),
199
+ renderContent: ({
200
+ onClose
201
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateDropdownContent, {
202
+ onClose: onClose
203
+ })
192
204
  })
193
205
  });
194
206
  }