@wordpress/edit-site 4.1.0 → 4.3.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 (170) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template-part.js +2 -9
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +28 -12
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/block-editor/index.js +53 -4
  7. package/build/components/block-editor/index.js.map +1 -1
  8. package/build/components/editor/index.js +9 -3
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +25 -24
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/color-indicator-wrapper.js +37 -0
  13. package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
  14. package/build/components/global-styles/dimensions-panel.js +6 -2
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/header.js +1 -4
  17. package/build/components/global-styles/header.js.map +1 -1
  18. package/build/components/global-styles/icon-with-current-color.js +34 -0
  19. package/build/components/global-styles/icon-with-current-color.js.map +1 -0
  20. package/build/components/global-styles/navigation-button.js +7 -3
  21. package/build/components/global-styles/navigation-button.js.map +1 -1
  22. package/build/components/global-styles/palette.js +8 -5
  23. package/build/components/global-styles/palette.js.map +1 -1
  24. package/build/components/global-styles/preview.js +142 -26
  25. package/build/components/global-styles/preview.js.map +1 -1
  26. package/build/components/global-styles/screen-block-list.js +2 -2
  27. package/build/components/global-styles/screen-block-list.js.map +1 -1
  28. package/build/components/global-styles/screen-colors.js +11 -3
  29. package/build/components/global-styles/screen-colors.js.map +1 -1
  30. package/build/components/global-styles/screen-root.js +7 -5
  31. package/build/components/global-styles/screen-root.js.map +1 -1
  32. package/build/components/global-styles/screen-style-variations.js +12 -5
  33. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  34. package/build/components/header/document-actions/index.js +13 -11
  35. package/build/components/header/document-actions/index.js.map +1 -1
  36. package/build/components/header/index.js +5 -3
  37. package/build/components/header/index.js.map +1 -1
  38. package/build/components/header/more-menu/index.js +9 -1
  39. package/build/components/header/more-menu/index.js.map +1 -1
  40. package/build/components/header/more-menu/site-export.js +5 -2
  41. package/build/components/header/more-menu/site-export.js.map +1 -1
  42. package/build/components/header/plugin-more-menu-item/index.js +5 -0
  43. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  44. package/build/components/list/actions/rename-menu-item.js +3 -10
  45. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  46. package/build/components/preferences-modal/enable-feature.js +40 -0
  47. package/build/components/preferences-modal/enable-feature.js.map +1 -0
  48. package/build/components/preferences-modal/index.js +68 -0
  49. package/build/components/preferences-modal/index.js.map +1 -0
  50. package/build/components/sidebar/index.js +12 -1
  51. package/build/components/sidebar/index.js.map +1 -1
  52. package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
  53. package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  54. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
  55. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  56. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
  57. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  58. package/build/components/template-part-converter/convert-to-regular.js +6 -0
  59. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  60. package/build/index.js +1 -0
  61. package/build/index.js.map +1 -1
  62. package/build/store/actions.js +3 -3
  63. package/build/store/actions.js.map +1 -1
  64. package/build/store/selectors.js +3 -1
  65. package/build/store/selectors.js.map +1 -1
  66. package/build-module/components/add-new-template/new-template-part.js +3 -10
  67. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  68. package/build-module/components/add-new-template/new-template.js +27 -12
  69. package/build-module/components/add-new-template/new-template.js.map +1 -1
  70. package/build-module/components/block-editor/index.js +51 -6
  71. package/build-module/components/block-editor/index.js.map +1 -1
  72. package/build-module/components/editor/index.js +8 -3
  73. package/build-module/components/editor/index.js.map +1 -1
  74. package/build-module/components/global-styles/border-panel.js +27 -26
  75. package/build-module/components/global-styles/border-panel.js.map +1 -1
  76. package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
  77. package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
  78. package/build-module/components/global-styles/dimensions-panel.js +6 -2
  79. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  80. package/build-module/components/global-styles/header.js +2 -5
  81. package/build-module/components/global-styles/header.js.map +1 -1
  82. package/build-module/components/global-styles/icon-with-current-color.js +22 -0
  83. package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
  84. package/build-module/components/global-styles/navigation-button.js +7 -3
  85. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  86. package/build-module/components/global-styles/palette.js +8 -6
  87. package/build-module/components/global-styles/palette.js.map +1 -1
  88. package/build-module/components/global-styles/preview.js +141 -27
  89. package/build-module/components/global-styles/preview.js.map +1 -1
  90. package/build-module/components/global-styles/screen-block-list.js +2 -2
  91. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  92. package/build-module/components/global-styles/screen-colors.js +10 -3
  93. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  94. package/build-module/components/global-styles/screen-root.js +8 -7
  95. package/build-module/components/global-styles/screen-root.js.map +1 -1
  96. package/build-module/components/global-styles/screen-style-variations.js +13 -6
  97. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  98. package/build-module/components/header/document-actions/index.js +13 -11
  99. package/build-module/components/header/document-actions/index.js.map +1 -1
  100. package/build-module/components/header/index.js +5 -3
  101. package/build-module/components/header/index.js.map +1 -1
  102. package/build-module/components/header/more-menu/index.js +8 -1
  103. package/build-module/components/header/more-menu/index.js.map +1 -1
  104. package/build-module/components/header/more-menu/site-export.js +5 -2
  105. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  106. package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
  107. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
  108. package/build-module/components/list/actions/rename-menu-item.js +4 -11
  109. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  110. package/build-module/components/preferences-modal/enable-feature.js +27 -0
  111. package/build-module/components/preferences-modal/enable-feature.js.map +1 -0
  112. package/build-module/components/preferences-modal/index.js +57 -0
  113. package/build-module/components/preferences-modal/index.js.map +1 -0
  114. package/build-module/components/sidebar/index.js +11 -1
  115. package/build-module/components/sidebar/index.js.map +1 -1
  116. package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
  117. package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  118. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
  119. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  120. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
  121. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  122. package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
  123. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  124. package/build-module/index.js +1 -0
  125. package/build-module/index.js.map +1 -1
  126. package/build-module/store/actions.js +3 -3
  127. package/build-module/store/actions.js.map +1 -1
  128. package/build-module/store/selectors.js +3 -1
  129. package/build-module/store/selectors.js.map +1 -1
  130. package/build-style/style-rtl.css +86 -5
  131. package/build-style/style.css +86 -5
  132. package/package.json +29 -29
  133. package/src/components/add-new-template/new-template-part.js +3 -12
  134. package/src/components/add-new-template/new-template.js +49 -12
  135. package/src/components/block-editor/index.js +79 -9
  136. package/src/components/editor/index.js +13 -0
  137. package/src/components/global-styles/border-panel.js +32 -26
  138. package/src/components/global-styles/color-indicator-wrapper.js +23 -0
  139. package/src/components/global-styles/dimensions-panel.js +7 -2
  140. package/src/components/global-styles/header.js +2 -7
  141. package/src/components/global-styles/icon-with-current-color.js +21 -0
  142. package/src/components/global-styles/navigation-button.js +6 -4
  143. package/src/components/global-styles/palette.js +8 -11
  144. package/src/components/global-styles/preview.js +186 -29
  145. package/src/components/global-styles/screen-block-list.js +1 -3
  146. package/src/components/global-styles/screen-colors.js +7 -6
  147. package/src/components/global-styles/screen-root.js +15 -17
  148. package/src/components/global-styles/screen-style-variations.js +13 -4
  149. package/src/components/global-styles/style.scss +18 -6
  150. package/src/components/header/document-actions/index.js +14 -10
  151. package/src/components/header/index.js +6 -1
  152. package/src/components/header/more-menu/index.js +15 -0
  153. package/src/components/header/more-menu/site-export.js +13 -2
  154. package/src/components/header/plugin-more-menu-item/index.js +2 -0
  155. package/src/components/header/style.scss +45 -0
  156. package/src/components/list/actions/rename-menu-item.js +3 -13
  157. package/src/components/preferences-modal/enable-feature.js +24 -0
  158. package/src/components/preferences-modal/index.js +76 -0
  159. package/src/components/sidebar/index.js +12 -0
  160. package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
  161. package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
  162. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
  163. package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
  164. package/src/components/sidebar/style.scss +1 -1
  165. package/src/components/template-part-converter/convert-to-regular.js +9 -0
  166. package/src/index.js +1 -0
  167. package/src/store/actions.js +4 -4
  168. package/src/store/selectors.js +10 -0
  169. package/src/store/test/selectors.js +4 -0
  170. package/src/style.scss +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header/document-actions/index.js"],"names":["classnames","sprintf","__","__experimentalGetBlockLabel","getBlockLabel","getBlockType","useSelect","Dropdown","Button","VisuallyHidden","__experimentalText","Text","chevronDown","useRef","store","blockEditorStore","getBlockDisplayText","block","blockType","name","attributes","useSecondaryText","getBlock","activeEntityBlockId","select","__experimentalGetActiveBlockIdByBlockNames","label","isActive","DocumentActions","entityTitle","entityLabel","isLoaded","children","dropdownContent","titleRef","anchorRef","current","isOpen","onToggle"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,QAGO,mBAHP;AAIA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,cAHD,EAICC,kBAAkB,IAAIC,IAJvB,QAKO,uBALP;AAMA,SAASC,WAAT,QAA4B,kBAA5B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AACrC,MAAKA,KAAL,EAAa;AACZ,UAAMC,SAAS,GAAGb,YAAY,CAAEY,KAAK,CAACE,IAAR,CAA9B;AACA,WAAOD,SAAS,GAAGd,aAAa,CAAEc,SAAF,EAAaD,KAAK,CAACG,UAAnB,CAAhB,GAAkD,IAAlE;AACA;;AACD,SAAO,IAAP;AACA;;AAED,SAASC,gBAAT,GAA4B;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAehB,SAAS,CAAES,gBAAF,CAA9B;AACA,QAAMQ,mBAAmB,GAAGjB,SAAS,CAClCkB,MAAF,IACCA,MAAM,CACLT,gBADK,CAAN,CAEEU,0CAFF,CAE8C,CAC7C,oBAD6C,CAF9C,CAFmC,EAOpC,EAPoC,CAArC;;AAUA,MAAKF,mBAAL,EAA2B;AAC1B,WAAO;AACNG,MAAAA,KAAK,EAAEV,mBAAmB,CAAEM,QAAQ,CAAEC,mBAAF,CAAV,CADpB;AAENI,MAAAA,QAAQ,EAAE;AAFJ,KAAP;AAIA;;AAED,SAAO,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASC,eAAT,OAKX;AAAA,MAL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;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,MAAD;AACC,QAAA,SAAS,EAAC,sCADX;AAEC,QAAA,IAAI,EAAG1B,WAFR;AAGC,yBAAgByB,MAHjB;AAIC,yBAAc,MAJf;AAKC,QAAA,OAAO,EAAGC,QALX;AAMC,QAAA,KAAK,EAAGrC,OAAO;AACd;AACAC,QAAAA,EAAE,CAAE,iBAAF,CAFY,EAGd4B,WAHc;AANhB,QADc;AAAA,KALhB;AAmBC,IAAA,gBAAgB,EAAC,2CAnBlB;AAoBC,IAAA,aAAa,EAAGG;AApBjB,IA3BF,CALD,CADD;AA2DA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport {\n\t__experimentalGetBlockLabel as getBlockLabel,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tDropdown,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getBlockDisplayText( block ) {\n\tif ( block ) {\n\t\tconst blockType = getBlockType( block.name );\n\t\treturn blockType ? getBlockLabel( blockType, block.attributes ) : null;\n\t}\n\treturn null;\n}\n\nfunction useSecondaryText() {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst activeEntityBlockId = useSelect(\n\t\t( select ) =>\n\t\t\tselect(\n\t\t\t\tblockEditorStore\n\t\t\t).__experimentalGetActiveBlockIdByBlockNames( [\n\t\t\t\t'core/template-part',\n\t\t\t] ),\n\t\t[]\n\t);\n\n\tif ( activeEntityBlockId ) {\n\t\treturn {\n\t\t\tlabel: getBlockDisplayText( getBlock( activeEntityBlockId ) ),\n\t\t\tisActive: true,\n\t\t};\n\t}\n\n\treturn {};\n}\n\n/**\n * @param {Object} props Props for the DocumentActions component.\n * @param {string} props.entityTitle The title to display.\n * @param {string} props.entityLabel A label to use for entity-related options.\n * E.g. \"template\" would be used for \"edit\n * template\" and \"show template details\".\n * @param {boolean} props.isLoaded Whether the data is available.\n * @param {Function} props.children React component to use for the\n * information dropdown area. Should be a\n * function which accepts dropdown props.\n */\nexport default function DocumentActions( {\n\tentityTitle,\n\tentityLabel,\n\tisLoaded,\n\tchildren: dropdownContent,\n} ) {\n\tconst { label } = useSecondaryText();\n\n\t// The title ref is passed to the popover as the anchorRef so that the\n\t// dropdown is centered over the whole title area rather than just one\n\t// part of it.\n\tconst titleRef = useRef();\n\n\t// Return a simple loading indicator until we have information to show.\n\tif ( ! isLoaded ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Loading…' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Return feedback that the template does not seem to exist.\n\tif ( ! entityTitle ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Template not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-document-actions', {\n\t\t\t\t'has-secondary-label': !! label,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ titleRef }\n\t\t\t\tclassName=\"edit-site-document-actions__title-wrapper\"\n\t\t\t>\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tclassName=\"edit-site-document-actions__title\"\n\t\t\t\t\tas=\"h1\"\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: the entity being edited, like \"template\"*/\n\t\t\t\t\t\t\t__( 'Editing %s: ' ),\n\t\t\t\t\t\t\tentityLabel\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t{ entityTitle }\n\t\t\t\t</Text>\n\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tclassName=\"edit-site-document-actions__secondary-item\"\n\t\t\t\t>\n\t\t\t\t\t{ label ?? '' }\n\t\t\t\t</Text>\n\n\t\t\t\t{ dropdownContent && (\n\t\t\t\t\t<Dropdown\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tanchorRef: titleRef.current,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-site-document-actions__get-info\"\n\t\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: the entity to see details about, like \"template\"*/\n\t\t\t\t\t\t\t\t\t__( 'Show %s details' ),\n\t\t\t\t\t\t\t\t\tentityLabel\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\tcontentClassName=\"edit-site-document-actions__info-dropdown\"\n\t\t\t\t\t\trenderContent={ dropdownContent }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header/document-actions/index.js"],"names":["classnames","sprintf","__","__experimentalGetBlockLabel","getBlockLabel","getBlockType","useSelect","Dropdown","Button","VisuallyHidden","__experimentalText","Text","chevronDown","useRef","store","blockEditorStore","getBlockDisplayText","block","blockType","name","attributes","useSecondaryText","getBlock","activeEntityBlockId","select","__experimentalGetActiveBlockIdByBlockNames","label","isActive","DocumentActions","entityTitle","entityLabel","isLoaded","children","dropdownContent","showIconLabels","titleRef","anchorRef","current","isOpen","onToggle"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,QAGO,mBAHP;AAIA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,cAHD,EAICC,kBAAkB,IAAIC,IAJvB,QAKO,uBALP;AAMA,SAASC,WAAT,QAA4B,kBAA5B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AACrC,MAAKA,KAAL,EAAa;AACZ,UAAMC,SAAS,GAAGb,YAAY,CAAEY,KAAK,CAACE,IAAR,CAA9B;AACA,WAAOD,SAAS,GAAGd,aAAa,CAAEc,SAAF,EAAaD,KAAK,CAACG,UAAnB,CAAhB,GAAkD,IAAlE;AACA;;AACD,SAAO,IAAP;AACA;;AAED,SAASC,gBAAT,GAA4B;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAehB,SAAS,CAAES,gBAAF,CAA9B;AACA,QAAMQ,mBAAmB,GAAGjB,SAAS,CAClCkB,MAAF,IACCA,MAAM,CACLT,gBADK,CAAN,CAEEU,0CAFF,CAE8C,CAC7C,oBAD6C,CAF9C,CAFmC,EAOpC,EAPoC,CAArC;;AAUA,MAAKF,mBAAL,EAA2B;AAC1B,WAAO;AACNG,MAAAA,KAAK,EAAEV,mBAAmB,CAAEM,QAAQ,CAAEC,mBAAF,CAAV,CADpB;AAENI,MAAAA,QAAQ,EAAE;AAFJ,KAAP;AAIA;;AAED,SAAO,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASC,eA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V;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,MAAD;AACC,QAAA,SAAS,EAAC,sCADX;AAEC,QAAA,IAAI,EAAG3B,WAFR;AAGC,yBAAgB0B,MAHjB;AAIC,yBAAc,MAJf;AAKC,QAAA,OAAO,EAAGC,QALX;AAMC,QAAA,KAAK,EAAGtC,OAAO;AACd;AACAC,QAAAA,EAAE,CAAE,iBAAF,CAFY,EAGd4B,WAHc;AANhB,SAYGI,cAAc,IAAIhC,EAAE,CAAE,SAAF,CAZvB,CADc;AAAA,KALhB;AAqBC,IAAA,gBAAgB,EAAC,2CArBlB;AAsBC,IAAA,aAAa,EAAG+B;AAtBjB,IA3BF,CALD,CADD;AA6DA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport {\n\t__experimentalGetBlockLabel as getBlockLabel,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tDropdown,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getBlockDisplayText( block ) {\n\tif ( block ) {\n\t\tconst blockType = getBlockType( block.name );\n\t\treturn blockType ? getBlockLabel( blockType, block.attributes ) : null;\n\t}\n\treturn null;\n}\n\nfunction useSecondaryText() {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst activeEntityBlockId = useSelect(\n\t\t( select ) =>\n\t\t\tselect(\n\t\t\t\tblockEditorStore\n\t\t\t).__experimentalGetActiveBlockIdByBlockNames( [\n\t\t\t\t'core/template-part',\n\t\t\t] ),\n\t\t[]\n\t);\n\n\tif ( activeEntityBlockId ) {\n\t\treturn {\n\t\t\tlabel: getBlockDisplayText( getBlock( activeEntityBlockId ) ),\n\t\t\tisActive: true,\n\t\t};\n\t}\n\n\treturn {};\n}\n\n/**\n * @param {Object} props Props for the DocumentActions component.\n * @param {string} props.entityTitle The title to display.\n * @param {string} props.entityLabel A label to use for entity-related options.\n * E.g. \"template\" would be used for \"edit\n * template\" and \"show template details\".\n * @param {boolean} props.isLoaded Whether the data is available.\n * @param {Function} props.children React component to use for the\n * information dropdown area. Should be a\n * function which accepts dropdown props.\n * @param {boolean} props.showIconLabels Whether buttons display icons or text labels.\n */\nexport default function DocumentActions( {\n\tentityTitle,\n\tentityLabel,\n\tisLoaded,\n\tchildren: dropdownContent,\n\tshowIconLabels,\n} ) {\n\tconst { label } = useSecondaryText();\n\n\t// The title ref is passed to the popover as the anchorRef so that the\n\t// dropdown is centered over the whole title area rather than just one\n\t// part of it.\n\tconst titleRef = useRef();\n\n\t// Return a simple loading indicator until we have information to show.\n\tif ( ! isLoaded ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Loading…' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Return feedback that the template does not seem to exist.\n\tif ( ! entityTitle ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Template not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-document-actions', {\n\t\t\t\t'has-secondary-label': !! label,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ titleRef }\n\t\t\t\tclassName=\"edit-site-document-actions__title-wrapper\"\n\t\t\t>\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tclassName=\"edit-site-document-actions__title\"\n\t\t\t\t\tas=\"h1\"\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: the entity being edited, like \"template\"*/\n\t\t\t\t\t\t\t__( 'Editing %s: ' ),\n\t\t\t\t\t\t\tentityLabel\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t{ entityTitle }\n\t\t\t\t</Text>\n\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tclassName=\"edit-site-document-actions__secondary-item\"\n\t\t\t\t>\n\t\t\t\t\t{ label ?? '' }\n\t\t\t\t</Text>\n\n\t\t\t\t{ dropdownContent && (\n\t\t\t\t\t<Dropdown\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tanchorRef: titleRef.current,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-site-document-actions__get-info\"\n\t\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: the entity to see details about, like \"template\"*/\n\t\t\t\t\t\t\t\t\t__( 'Show %s details' ),\n\t\t\t\t\t\t\t\t\tentityLabel\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{ showIconLabels && __( 'Details' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tcontentClassName=\"edit-site-document-actions__info-dropdown\"\n\t\t\t\t\t\trenderContent={ dropdownContent }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -33,7 +33,8 @@ const preventDefault = event => {
33
33
  export default function Header(_ref) {
34
34
  let {
35
35
  openEntitiesSavedStates,
36
- isEntitiesSavedStatesOpen
36
+ isEntitiesSavedStatesOpen,
37
+ showIconLabels
37
38
  } = _ref;
38
39
  const inserterButton = useRef();
39
40
  const {
@@ -114,7 +115,7 @@ export default function Header(_ref) {
114
115
  onClick: openInserter,
115
116
  icon: plus,
116
117
  label: _x('Toggle block inserter', 'Generic label for block inserter button')
117
- }), isLargeViewport && createElement(Fragment, null, createElement(ToolbarItem, {
118
+ }, showIconLabels && (!isInserterOpen ? __('Add') : __('Close'))), isLargeViewport && createElement(Fragment, null, createElement(ToolbarItem, {
118
119
  as: ToolSelector,
119
120
  disabled: !isVisualMode
120
121
  }), createElement(UndoButton, null), createElement(RedoButton, null), createElement(Button, {
@@ -132,7 +133,8 @@ export default function Header(_ref) {
132
133
  }, createElement(DocumentActions, {
133
134
  entityTitle: entityTitle,
134
135
  entityLabel: templateType === 'wp_template_part' ? 'template part' : 'template',
135
- isLoaded: isLoaded
136
+ isLoaded: isLoaded,
137
+ showIconLabels: showIconLabels
136
138
  }, _ref2 => {
137
139
  let {
138
140
  onClose
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header/index.js"],"names":["useCallback","useRef","useViewportMatch","ToolSelector","__experimentalPreviewOptions","PreviewOptions","useSelect","useDispatch","PinnedItems","_x","__","listView","plus","Button","ToolbarItem","store","keyboardShortcutsStore","editorStore","coreStore","MoreMenu","SaveButton","UndoButton","RedoButton","DocumentActions","TemplateDetails","editSiteStore","preventDefault","event","Header","openEntitiesSavedStates","isEntitiesSavedStatesOpen","inserterButton","deviceType","entityTitle","template","templateType","isInserterOpen","isListViewOpen","listViewShortcut","isLoaded","isVisualMode","select","__experimentalGetPreviewDeviceType","getEditedPostType","getEditedPostId","isInserterOpened","isListViewOpened","getEditorMode","getEditedEntityRecord","__experimentalGetTemplateInfo","getTemplateInfo","getShortcutRepresentation","postType","postId","record","_isLoaded","title","__experimentalSetPreviewDeviceType","setPreviewDeviceType","setIsInserterOpened","setIsListViewOpened","isLargeViewport","openInserter","current","focus","toggleListView","isFocusMode","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SACCC,YADD,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASF,KAAK,IAAIG,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAAST,KAAK,IAAIU,aAAlB,QAAuC,aAAvC;;AAEA,MAAMC,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,eAAe,SAASE,MAAT,OAGX;AAAA,MAH4B;AAC/BC,IAAAA,uBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAMC,cAAc,GAAG9B,MAAM,EAA7B;AACA,QAAM;AACL+B,IAAAA,UADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,QAHK;AAILC,IAAAA,YAJK;AAKLC,IAAAA,cALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,gBAPK;AAQLC,IAAAA,QARK;AASLC,I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AA,SAAS,EAAG0B;AACZ;AALD;AAMC,IAAA,KAAK,EAAG3B,EAAE,CAAE,WAAF,CANX;AAOC,IAAA,OAAO,EAAGuD,cAPX;AAQC,IAAA,QAAQ,EAAG3B;AARZ,IAPD,CAhBF,CADD,CADD,EAwCC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,eAAD;AACC,IAAA,WAAW,EAAGL,WADf;AAEC,IAAA,WAAW,EACVE,YAAY,KAAK,kBAAjB,GACG,eADH,GAEG,UALL;AAOC,IAAA,QAAQ,EAAGI;AAPZ,KASG;AAAA,QAAE;AAAE4B,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,eAAD;AACC,MAAA,QAAQ,EAAGjC,QADZ;AAEC,MAAA,OAAO,EAAGiC;AAFX,MADC;AAAA,GATH,CADD,CAxCD,EA2DC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAED,WAAF,IACD,cAAC,cAAD;AACC,IAAA,UAAU,EAAGlC,UADd;AAEC,IAAA,aAAa,EAAG0B;AAFjB,IAFF,EAOC,cAAC,UAAD;AACC,IAAA,uBAAuB,EAAG7B,uBAD3B;AAEC,IAAA,yBAAyB,EAAGC;AAF7B,IAPD,EAWC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IAXD,EAYC,cAAC,QAAD,OAZD,CADD,CA3DD,CADD;AA8EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tToolSelector,\n\t__experimentalPreviewOptions as PreviewOptions,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { _x, __ } from '@wordpress/i18n';\nimport { listView, plus } from '@wordpress/icons';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport MoreMenu from './more-menu';\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport DocumentActions from './document-actions';\nimport TemplateDetails from '../template-details';\nimport { store as editSiteStore } from '../../store';\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nexport default function Header( {\n\topenEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n} ) {\n\tconst inserterButton = useRef();\n\tconst {\n\t\tdeviceType,\n\t\tentityTitle,\n\t\ttemplate,\n\t\ttemplateType,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tisLoaded,\n\t\tisVisualMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t} = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tentityTitle: getTemplateInfo( record ).title,\n\t\t\tisLoaded: _isLoaded,\n\t\t\ttemplate: record,\n\t\t\ttemplateType: postType,\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-site/toggle-list-view'\n\t\t\t),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\t__experimentalSetPreviewDeviceType: setPreviewDeviceType,\n\t\tsetIsInserterOpened,\n\t\tsetIsListViewOpened,\n\t} = useDispatch( editSiteStore );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\tconst openInserter = useCallback( () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tinserterButton.current.focus();\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpen, setIsInserterOpened ] );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst isFocusMode = templateType === 'wp_template_part';\n\n\treturn (\n\t\t<div className=\"edit-site-header\">\n\t\t\t<div className=\"edit-site-header_start\">\n\t\t\t\t<div className=\"edit-site-header__toolbar\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\tclassName=\"edit-site-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ openInserter }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-site-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"edit-site-header_center\">\n\t\t\t\t<DocumentActions\n\t\t\t\t\tentityTitle={ entityTitle }\n\t\t\t\t\tentityLabel={\n\t\t\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t\t\t\t\t? 'template part'\n\t\t\t\t\t\t\t: 'template'\n\t\t\t\t\t}\n\t\t\t\t\tisLoaded={ isLoaded }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<TemplateDetails\n\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</DocumentActions>\n\t\t\t</div>\n\n\t\t\t<div className=\"edit-site-header_end\">\n\t\t\t\t<div className=\"edit-site-header__actions\">\n\t\t\t\t\t{ ! isFocusMode && (\n\t\t\t\t\t\t<PreviewOptions\n\t\t\t\t\t\t\tdeviceType={ deviceType }\n\t\t\t\t\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<SaveButton\n\t\t\t\t\t\topenEntitiesSavedStates={ openEntitiesSavedStates }\n\t\t\t\t\t\tisEntitiesSavedStatesOpen={ isEntitiesSavedStatesOpen }\n\t\t\t\t\t/>\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header/index.js"],"names":["useCallback","useRef","useViewportMatch","ToolSelector","__experimentalPreviewOptions","PreviewOptions","useSelect","useDispatch","PinnedItems","_x","__","listView","plus","Button","ToolbarItem","store","keyboardShortcutsStore","editorStore","coreStore","MoreMenu","SaveButton","UndoButton","RedoButton","DocumentActions","TemplateDetails","editSiteStore","preventDefault","event","Header","openEntitiesSavedStates","isEntitiesSavedStatesOpen","showIconLabels","inserterButton","deviceType","entityTitle","template","templateType","isInserterOpen","isListViewOpen","listViewShortcut","isLoaded","isVisualMode","select","__experimentalGetPreviewDeviceType","getEditedPostType","getEditedPostId","isInserterOpened","isListViewOpened","getEditorMode","getEditedEntityRecord","__experimentalGetTemplateInfo","getTemplateInfo","getShortcutRepresentation","postType","postId","record","_isLoaded","title","__experimentalSetPreviewDeviceType","setPreviewDeviceType","setIsInserterOpened","setIsListViewOpened","isLargeViewport","openInserter","current","focus","toggleListView","isFocusMode","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SACCC,YADD,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AACA,SAASD,KAAK,IAAIE,WAAlB,Q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,KAUG;AAAA,QAAE;AAAEqC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,eAAD;AACC,MAAA,QAAQ,EAAGjC,QADZ;AAEC,MAAA,OAAO,EAAGiC;AAFX,MADC;AAAA,GAVH,CADD,CA3CD,EA+DC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAED,WAAF,IACD,cAAC,cAAD;AACC,IAAA,UAAU,EAAGlC,UADd;AAEC,IAAA,aAAa,EAAG0B;AAFjB,IAFF,EAOC,cAAC,UAAD;AACC,IAAA,uBAAuB,EAAG9B,uBAD3B;AAEC,IAAA,yBAAyB,EAAGC;AAF7B,IAPD,EAWC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IAXD,EAYC,cAAC,QAAD,OAZD,CADD,CA/DD,CADD;AAkFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tToolSelector,\n\t__experimentalPreviewOptions as PreviewOptions,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { _x, __ } from '@wordpress/i18n';\nimport { listView, plus } from '@wordpress/icons';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport MoreMenu from './more-menu';\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport DocumentActions from './document-actions';\nimport TemplateDetails from '../template-details';\nimport { store as editSiteStore } from '../../store';\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nexport default function Header( {\n\topenEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n\tshowIconLabels,\n} ) {\n\tconst inserterButton = useRef();\n\tconst {\n\t\tdeviceType,\n\t\tentityTitle,\n\t\ttemplate,\n\t\ttemplateType,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tisLoaded,\n\t\tisVisualMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t} = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tentityTitle: getTemplateInfo( record ).title,\n\t\t\tisLoaded: _isLoaded,\n\t\t\ttemplate: record,\n\t\t\ttemplateType: postType,\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-site/toggle-list-view'\n\t\t\t),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\t__experimentalSetPreviewDeviceType: setPreviewDeviceType,\n\t\tsetIsInserterOpened,\n\t\tsetIsListViewOpened,\n\t} = useDispatch( editSiteStore );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\tconst openInserter = useCallback( () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tinserterButton.current.focus();\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpen, setIsInserterOpened ] );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst isFocusMode = templateType === 'wp_template_part';\n\n\treturn (\n\t\t<div className=\"edit-site-header\">\n\t\t\t<div className=\"edit-site-header_start\">\n\t\t\t\t<div className=\"edit-site-header__toolbar\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\tclassName=\"edit-site-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ openInserter }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showIconLabels &&\n\t\t\t\t\t\t\t( ! isInserterOpen ? __( 'Add' ) : __( 'Close' ) ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-site-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"edit-site-header_center\">\n\t\t\t\t<DocumentActions\n\t\t\t\t\tentityTitle={ entityTitle }\n\t\t\t\t\tentityLabel={\n\t\t\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t\t\t\t\t? 'template part'\n\t\t\t\t\t\t\t: 'template'\n\t\t\t\t\t}\n\t\t\t\t\tisLoaded={ isLoaded }\n\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<TemplateDetails\n\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</DocumentActions>\n\t\t\t</div>\n\n\t\t\t<div className=\"edit-site-header_end\">\n\t\t\t\t<div className=\"edit-site-header__actions\">\n\t\t\t\t\t{ ! isFocusMode && (\n\t\t\t\t\t\t<PreviewOptions\n\t\t\t\t\t\t\tdeviceType={ deviceType }\n\t\t\t\t\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<SaveButton\n\t\t\t\t\t\topenEntitiesSavedStates={ openEntitiesSavedStates }\n\t\t\t\t\t\tisEntitiesSavedStatesOpen={ isEntitiesSavedStatesOpen }\n\t\t\t\t\t/>\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -16,6 +16,7 @@ import { PreferenceToggleMenuItem } from '@wordpress/preferences';
16
16
  */
17
17
 
18
18
  import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
19
+ import EditSitePreferencesModal from '../../preferences-modal';
19
20
  import ToolsMoreMenuGroup from '../tools-more-menu-group';
20
21
  import SiteExport from './site-export';
21
22
  import WelcomeGuideMenuItem from './welcome-guide-menu-item';
@@ -23,6 +24,7 @@ import CopyContentMenuItem from './copy-content-menu-item';
23
24
  import ModeSwitcher from '../mode-switcher';
24
25
  export default function MoreMenu() {
25
26
  const [isModalActive, toggleModal] = useReducer(isActive => !isActive, false);
27
+ const [isPreferencesModalActive, togglePreferencesModal] = useReducer(isActive => !isActive, false);
26
28
  useShortcut('core/edit-site/keyboard-shortcuts', toggleModal);
27
29
  return createElement(Fragment, null, createElement(MoreMenuDropdown, null, _ref => {
28
30
  let {
@@ -70,10 +72,15 @@ export default function MoreMenu() {
70
72
  fillProps: {
71
73
  onClose
72
74
  }
73
- })));
75
+ })), createElement(MenuGroup, null, createElement(MenuItem, {
76
+ onClick: togglePreferencesModal
77
+ }, __('Preferences'))));
74
78
  }), createElement(KeyboardShortcutHelpModal, {
75
79
  isModalActive: isModalActive,
76
80
  toggleModal: toggleModal
81
+ }), createElement(EditSitePreferencesModal, {
82
+ isModalActive: isPreferencesModalActive,
83
+ toggleModal: togglePreferencesModal
77
84
  }));
78
85
  }
79
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header/more-menu/index.js"],"names":["__","_x","useReducer","useShortcut","displayShortcut","external","MenuGroup","MenuItem","VisuallyHidden","ActionItem","MoreMenuDropdown","PreferenceToggleMenuItem","KeyboardShortcutHelpModal","ToolsMoreMenuGroup","SiteExport","WelcomeGuideMenuItem","CopyContentMenuItem","ModeSwitcher","MoreMenu","isModalActive","toggleModal","isActive","onClose","onClick","access"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,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ADjB;AAEC,IAAA,WAAW,EAAGC;AAFf,IAzED,CADD;AAgFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { external } from '@wordpress/icons';\nimport { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';\nimport { ActionItem, MoreMenuDropdown } from '@wordpress/interface';\nimport { PreferenceToggleMenuItem } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';\nimport ToolsMoreMenuGroup from '../tools-more-menu-group';\nimport SiteExport from './site-export';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport ModeSwitcher from '../mode-switcher';\n\nexport default function MoreMenu() {\n\tconst [ isModalActive, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tuseShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );\n\n\treturn (\n\t\t<>\n\t\t\t<MoreMenuDropdown>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\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<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\t\t\t\t\tname=\"focusMode\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Focus on one block at a time' ) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode deactivated'\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<ModeSwitcher />\n\t\t\t\t\t\t\t<ActionItem.Slot\n\t\t\t\t\t\t\t\tname=\"core/edit-site/plugin-more-menu\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Plugins' ) }\n\t\t\t\t\t\t\t\tas={ MenuGroup }\n\t\t\t\t\t\t\t\tfillProps={ { 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 label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<SiteExport />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ toggleModal }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/site-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { onClose } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</MoreMenuDropdown>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isModalActive }\n\t\t\t\ttoggleModal={ toggleModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header/more-menu/index.js"],"names":["__","_x","useReducer","useShortcut","displayShortcut","external","MenuGroup","MenuItem","VisuallyHidden","ActionItem","MoreMenuDropdown","PreferenceToggleMenuItem","KeyboardShortcutHelpModal","EditSitePreferencesModal","ToolsMoreMenuGroup","SiteExport","WelcomeGuideMenuItem","CopyContentMenuItem","ModeSwitcher","MoreMenu","isModalActive","toggleModal","isActive","isPreferencesModalActive","togglePreferencesModal","onClose","onClick","access"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,QAAT,QAAy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QAAD;AAAU,MAAA,OAAO,EAAGD;AAApB,OACGxB,EAAE,CAAE,aAAF,CADL,CADD,CAnED,CADC;AAAA,GADH,CADD,EA8EC,cAAC,yBAAD;AACC,IAAA,aAAa,EAAGoB,aADjB;AAEC,IAAA,WAAW,EAAGC;AAFf,IA9ED,EAkFC,cAAC,wBAAD;AACC,IAAA,aAAa,EAAGE,wBADjB;AAEC,IAAA,WAAW,EAAGC;AAFf,IAlFD,CADD;AAyFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { external } from '@wordpress/icons';\nimport { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';\nimport { ActionItem, MoreMenuDropdown } from '@wordpress/interface';\nimport { PreferenceToggleMenuItem } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';\nimport EditSitePreferencesModal from '../../preferences-modal';\nimport ToolsMoreMenuGroup from '../tools-more-menu-group';\nimport SiteExport from './site-export';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport ModeSwitcher from '../mode-switcher';\n\nexport default function MoreMenu() {\n\tconst [ isModalActive, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tconst [ isPreferencesModalActive, togglePreferencesModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tuseShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );\n\n\treturn (\n\t\t<>\n\t\t\t<MoreMenuDropdown>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\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<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\t\t\t\t\tname=\"focusMode\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Focus on one block at a time' ) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode deactivated'\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<ModeSwitcher />\n\t\t\t\t\t\t\t<ActionItem.Slot\n\t\t\t\t\t\t\t\tname=\"core/edit-site/plugin-more-menu\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Plugins' ) }\n\t\t\t\t\t\t\t\tas={ MenuGroup }\n\t\t\t\t\t\t\t\tfillProps={ { 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 label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<SiteExport />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ toggleModal }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/site-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { 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 onClick={ togglePreferencesModal }>\n\t\t\t\t\t\t\t\t{ __( 'Preferences' ) }\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</MoreMenuDropdown>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isModalActive }\n\t\t\t\ttoggleModal={ toggleModal }\n\t\t\t/>\n\t\t\t<EditSitePreferencesModal\n\t\t\t\tisModalActive={ isPreferencesModalActive }\n\t\t\t\ttoggleModal={ togglePreferencesModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -26,7 +26,10 @@ export default function SiteExport() {
26
26
  parse: false
27
27
  });
28
28
  const blob = await response.blob();
29
- downloadjs(blob, 'edit-site-export.zip', 'application/zip');
29
+ const contentDisposition = response.headers.get('content-disposition');
30
+ const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
31
+ const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export';
32
+ downloadjs(blob, fileName + '.zip', 'application/zip');
30
33
  } catch (errorResponse) {
31
34
  let error = {};
32
35
 
@@ -45,7 +48,7 @@ export default function SiteExport() {
45
48
  role: "menuitem",
46
49
  icon: download,
47
50
  onClick: handleExport,
48
- info: __('Download your templates and styles as a theme.')
51
+ info: __('Download your theme with updated templates and styles.')
49
52
  }, _x('Export', 'site exporter menu item'));
50
53
  }
51
54
  //# sourceMappingURL=site-export.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header/more-menu/site-export.js"],"names":["downloadjs","__","_x","MenuItem","apiFetch","download","useDispatch","store","noticesStore","SiteExport","createErrorNotice","handleExport","response","path","parse","blob","errorResponse","error","json","e","errorMessage","message","code","type"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAwBJ,WAAW,CAAEE,YAAF,CAAzC;;AAEA,iBAAeG,YAAf,GAA8B;AAC7B,QAAI;AACH,YAAMC,QAAQ,GAAG,MAAMR,QAAQ,CAAE;AAChCS,QAAAA,IAAI,EAAE,4BAD0B;AAEhCC,QAAAA,KAAK,EAAE;AAFyB,OAAF,CAA/B;AAIA,YAAMC,IAAI,GAAG,MAAMH,QAAQ,CAACG,IAAT,EAAnB;AAEAf,MAAAA,UAAU,CAAEe,IAAF,EAAQ,sBAAR,EAAgC,iBAAhC,CAAV;AACA,KARD,CAQE,OAAQC,aAAR,EAAwB;AACzB,UAAIC,KAAK,GAAG,EAAZ;;AACA,UAAI;AACHA,QAAAA,KAAK,GAAG,MAAMD,aAAa,CAACE,IAAd,EAAd;AACA,OAFD,CAEE,OAAQC,CAAR,EAAY,CAAE;;AAChB,YAAMC,YAAY,GACjBH,KAAK,CAACI,OAAN,IAAiBJ,KAAK,CAACK,IAAN,KAAe,eAAhC,GACGL,KAAK,CAACI,OADT,GAEGpB,EAAE,CAAE,mDAAF,CAHN;AAKAS,MAAAA,iBAAiB,CAAEU,YAAF,EAAgB;AAAEG,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,cAAC,QAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGlB,QAFR;AAGC,IAAA,OAAO,EAAGM,YAHX;AAIC,IAAA,IAAI,EAAGV,EAAE,CAAE,gDAAF;AAJV,KAMGC,EAAE,CAAE,QAAF,EAAY,yBAAZ,CANL,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\n\t\t\tdownloadjs( blob, 'edit-site-export.zip', 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __( 'Download your templates and styles as a theme.' ) }\n\t\t>\n\t\t\t{ _x( 'Export', 'site exporter menu item' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header/more-menu/site-export.js"],"names":["downloadjs","__","_x","MenuItem","apiFetch","download","useDispatch","store","noticesStore","SiteExport","createErrorNotice","handleExport","response","path","parse","blob","contentDisposition","headers","get","contentDispositionMatches","match","fileName","errorResponse","error","json","e","errorMessage","message","code","type"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAwBJ,WAAW,CAAEE,YAAF,CA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**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\t\t\tconst contentDisposition = response.headers.get(\n\t\t\t\t'content-disposition'\n\t\t\t);\n\t\t\tconst contentDispositionMatches = contentDisposition.match(\n\t\t\t\t/=(.+)\\.zip/\n\t\t\t);\n\t\t\tconst fileName = contentDispositionMatches[ 1 ]\n\t\t\t\t? contentDispositionMatches[ 1 ]\n\t\t\t\t: 'edit-site-export';\n\n\t\t\tdownloadjs( blob, fileName + '.zip', 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __(\n\t\t\t\t'Download your theme with updated templates and styles.'\n\t\t\t) }\n\t\t>\n\t\t\t{ _x( 'Export', 'site exporter menu item' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { ActionItem } from '@wordpress/interface';
5
5
  import { compose } from '@wordpress/compose';
6
+ import { MenuItem } from '@wordpress/components';
6
7
  import { withPluginContext } from '@wordpress/plugins';
7
8
  /**
8
9
  * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
@@ -62,7 +63,10 @@ import { withPluginContext } from '@wordpress/plugins';
62
63
  */
63
64
 
64
65
  export default compose(withPluginContext((context, ownProps) => {
66
+ var _ownProps$as;
67
+
65
68
  return {
69
+ as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : MenuItem,
66
70
  icon: ownProps.icon || context.icon,
67
71
  name: 'core/edit-site/plugin-more-menu'
68
72
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header/plugin-more-menu-item/index.js"],"names":["ActionItem","compose","withPluginContext","context","ownProps","icon","name"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,sBAA3B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeD,OAAO,CACrBC,iBAAiB,CAAE,CAAEC,OAAF,EAAWC,QAAX,KAAyB;AAC3C,SAAO;AACNC,IAAAA,IAAI,EAAED,QAAQ,CAACC,IAAT,IAAiBF,OAAO,CAACE,IADzB;AAENC,IAAAA,IAAI,EAAE;AAFA,GAAP;AAIA,CALgB,CADI,CAAP,CAOZN,UAPY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ActionItem } from '@wordpress/interface';\nimport { compose } from '@wordpress/compose';\nimport { withPluginContext } from '@wordpress/plugins';\n\n/**\n * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.\n * The text within the component appears as the menu item label.\n *\n * @param {Object} props Component properties.\n * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.\n * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.\n * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.\n * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * function MyButtonMoreMenuItem() {\n * \treturn wp.element.createElement(\n * \t\tPluginMoreMenuItem,\n * \t\t{\n * \t\t\ticon: moreIcon,\n * \t\t\tonClick: onButtonClick,\n * \t\t},\n * \t\t__( 'My button title' )\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginMoreMenuItem } from '@wordpress/edit-site';\n * import { more } from '@wordpress/icons';\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * const MyButtonMoreMenuItem = () => (\n * \t<PluginMoreMenuItem\n * \t\ticon={ more }\n * \t\tonClick={ onButtonClick }\n * \t>\n * \t\t{ __( 'My button title' ) }\n * \t</PluginMoreMenuItem>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default compose(\n\twithPluginContext( ( context, ownProps ) => {\n\t\treturn {\n\t\t\ticon: ownProps.icon || context.icon,\n\t\t\tname: 'core/edit-site/plugin-more-menu',\n\t\t};\n\t} )\n)( ActionItem );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header/plugin-more-menu-item/index.js"],"names":["ActionItem","compose","MenuItem","withPluginContext","context","ownProps","as","icon","name"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,sBAA3B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeF,OAAO,CACrBE,iBAAiB,CAAE,CAAEC,OAAF,EAAWC,QAAX,KAAyB;AAAA;;AAC3C,SAAO;AACNC,IAAAA,EAAE,kBAAED,QAAQ,CAACC,EAAX,uDAAiBJ,QADb;AAENK,IAAAA,IAAI,EAAEF,QAAQ,CAACE,IAAT,IAAiBH,OAAO,CAACG,IAFzB;AAGNC,IAAAA,IAAI,EAAE;AAHA,GAAP;AAKA,CANgB,CADI,CAAP,CAQZR,UARY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ActionItem } from '@wordpress/interface';\nimport { compose } from '@wordpress/compose';\nimport { MenuItem } from '@wordpress/components';\nimport { withPluginContext } from '@wordpress/plugins';\n\n/**\n * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.\n * The text within the component appears as the menu item label.\n *\n * @param {Object} props Component properties.\n * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.\n * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.\n * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.\n * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * function MyButtonMoreMenuItem() {\n * \treturn wp.element.createElement(\n * \t\tPluginMoreMenuItem,\n * \t\t{\n * \t\t\ticon: moreIcon,\n * \t\t\tonClick: onButtonClick,\n * \t\t},\n * \t\t__( 'My button title' )\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginMoreMenuItem } from '@wordpress/edit-site';\n * import { more } from '@wordpress/icons';\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * const MyButtonMoreMenuItem = () => (\n * \t<PluginMoreMenuItem\n * \t\ticon={ more }\n * \t\tonClick={ onButtonClick }\n * \t>\n * \t\t{ __( 'My button title' ) }\n * \t</PluginMoreMenuItem>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default compose(\n\twithPluginContext( ( context, ownProps ) => {\n\t\treturn {\n\t\t\tas: ownProps.as ?? MenuItem,\n\t\t\ticon: ownProps.icon || context.icon,\n\t\t\tname: 'core/edit-site/plugin-more-menu',\n\t\t};\n\t} )\n)( ActionItem );\n"]}
@@ -5,7 +5,7 @@ import { createElement, Fragment } from "@wordpress/element";
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { useState } from '@wordpress/element';
8
- import { useDispatch, useSelect } from '@wordpress/data';
8
+ import { useDispatch } from '@wordpress/data';
9
9
  import { Button, Flex, FlexItem, MenuItem, Modal, TextControl } from '@wordpress/components';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
11
  import { store as noticesStore } from '@wordpress/notices';
@@ -16,9 +16,6 @@ export default function RenameMenuItem(_ref) {
16
16
  } = _ref;
17
17
  const [title, setTitle] = useState(() => template.title.rendered);
18
18
  const [isModalOpen, setIsModalOpen] = useState(false);
19
- const {
20
- getLastEntitySaveError
21
- } = useSelect(coreStore);
22
19
  const {
23
20
  editEntityRecord,
24
21
  saveEditedEntityRecord
@@ -44,13 +41,9 @@ export default function RenameMenuItem(_ref) {
44
41
  setIsModalOpen(false);
45
42
  onClose(); // Persist edited entity.
46
43
 
47
- await saveEditedEntityRecord('postType', template.type, template.id);
48
- const lastError = getLastEntitySaveError('postType', template.type, template.id);
49
-
50
- if (lastError) {
51
- throw lastError;
52
- }
53
-
44
+ await saveEditedEntityRecord('postType', template.type, template.id, {
45
+ throwOnError: true
46
+ });
54
47
  createSuccessNotice(__('Entity renamed.'), {
55
48
  type: 'snackbar'
56
49
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/actions/rename-menu-item.js"],"names":["__","useState","useDispatch","useSelect","Button","Flex","FlexItem","MenuItem","Modal","TextControl","store","coreStore","noticesStore","RenameMenuItem","template","onClose","title","setTitle","rendered","isModalOpen","setIsModalOpen","getLastEntitySaveError","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","is_custom","onTemplateRename","event","preventDefault","type","id","lastError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,KALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,oBAAtC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,IAAA,QAAQ,EAAG;AAHZ,KAKC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMGpB,EAAE,CAAE,QAAF,CANL,CADD,CALD,EAeC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CADD,CAfD,CAZD,CARD,CAVF,CADD;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tMenuItem,\n\tModal,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => template.title.rendered );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = useDispatch(\n\t\tcoreStore\n\t);\n\tconst { createSuccessNotice, createErrorNotice } = useDispatch(\n\t\tnoticesStore\n\t);\n\n\tif ( ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tconst lastError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tif ( lastError ) {\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( template.title.rendered );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-site-list__rename-modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/actions/rename-menu-item.js"],"names":["__","useState","useDispatch","Button","Flex","FlexItem","MenuItem","Modal","TextControl","store","coreStore","noticesStore","RenameMenuItem","template","onClose","title","setTitle","rendered","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","is_custom","onTemplateRename","event","preventDefault","type","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SACCC,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,KALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QA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,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMGnB,EAAE,CAAE,QAAF,CANL,CADD,CALD,EAeC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CADD,CAfD,CAZD,CARD,CAVF,CADD;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tMenuItem,\n\tModal,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => template.title.rendered );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } = useDispatch(\n\t\tcoreStore\n\t);\n\tconst { createSuccessNotice, createErrorNotice } = useDispatch(\n\t\tnoticesStore\n\t);\n\n\tif ( ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( template.title.rendered );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-site-list__rename-modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createElement } from "@wordpress/element";
3
+
4
+ /**
5
+ * WordPress dependencies
6
+ */
7
+ import { useSelect, useDispatch } from '@wordpress/data';
8
+ import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
9
+ import { store as preferencesStore } from '@wordpress/preferences';
10
+ export default function EnableFeature(props) {
11
+ const {
12
+ featureName,
13
+ ...remainingProps
14
+ } = props;
15
+ const isChecked = useSelect(select => !!select(preferencesStore).get('core/edit-site', featureName), [featureName]);
16
+ const {
17
+ toggle
18
+ } = useDispatch(preferencesStore);
19
+
20
+ const onChange = () => toggle('core/edit-site', featureName);
21
+
22
+ return createElement(BaseOption, _extends({
23
+ onChange: onChange,
24
+ isChecked: isChecked
25
+ }, remainingProps));
26
+ }
27
+ //# sourceMappingURL=enable-feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/enable-feature.js"],"names":["useSelect","useDispatch","___unstablePreferencesModalBaseOption","BaseOption","store","preferencesStore","EnableFeature","props","featureName","remainingProps","isChecked","select","get","toggle","onChange"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,qCAAqC,IAAIC,UAAlD,QAAoE,sBAApE;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,eAAe,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AAC9C,QAAM;AAAEC,IAAAA,WAAF;AAAe,OAAGC;AAAlB,MAAqCF,KAA3C;AACA,QAAMG,SAAS,GAAGV,SAAS,CACxBW,MAAF,IACC,CAAC,CAAEA,MAAM,CAAEN,gBAAF,CAAN,CAA2BO,GAA3B,CAAgC,gBAAhC,EAAkDJ,WAAlD,CAFsB,EAG1B,CAAEA,WAAF,CAH0B,CAA3B;AAKA,QAAM;AAAEK,IAAAA;AAAF,MAAaZ,WAAW,CAAEI,gBAAF,CAA9B;;AACA,QAAMS,QAAQ,GAAG,MAAMD,MAAM,CAAE,gBAAF,EAAoBL,WAApB,CAA7B;;AACA,SACC,cAAC,UAAD;AACC,IAAA,QAAQ,EAAGM,QADZ;AAEC,IAAA,SAAS,EAAGJ;AAFb,KAGMD,cAHN,EADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function EnableFeature( props ) {\n\tconst { featureName, ...remainingProps } = props;\n\tconst isChecked = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get( 'core/edit-site', featureName ),\n\t\t[ featureName ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst onChange = () => toggle( 'core/edit-site', featureName );\n\treturn (\n\t\t<BaseOption\n\t\t\tonChange={ onChange }\n\t\t\tisChecked={ isChecked }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n}\n"]}
@@ -0,0 +1,57 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { PreferencesModal, PreferencesModalTabs, PreferencesModalSection } from '@wordpress/interface';
7
+ import { useMemo } from '@wordpress/element';
8
+ import { __ } from '@wordpress/i18n';
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ import EnableFeature from './enable-feature';
14
+ export default function EditSitePreferencesModal(_ref) {
15
+ let {
16
+ isModalActive,
17
+ toggleModal
18
+ } = _ref;
19
+ const sections = useMemo(() => [{
20
+ name: 'general',
21
+ tabLabel: __('General'),
22
+ content: createElement(PreferencesModalSection, {
23
+ title: __('Appearance'),
24
+ description: __('Customize options related to the block editor interface and editing flow.')
25
+ }, createElement(EnableFeature, {
26
+ featureName: "focusMode",
27
+ help: __('Highlights the current block and fades other content.'),
28
+ label: __('Spotlight mode')
29
+ }), createElement(EnableFeature, {
30
+ featureName: "showIconLabels",
31
+ label: __('Show button text labels'),
32
+ help: __('Show text instead of icons on buttons')
33
+ }))
34
+ }, {
35
+ name: 'blocks',
36
+ tabLabel: __('Blocks'),
37
+ content: createElement(PreferencesModalSection, {
38
+ title: __('Block interactions'),
39
+ description: __('Customize how you interact with blocks in the block library and editing canvas.')
40
+ }, createElement(EnableFeature, {
41
+ featureName: "keepCaretInsideBlock",
42
+ help: __('Aids screen readers by stopping text caret from leaving blocks.'),
43
+ label: __('Contain text cursor inside block')
44
+ }))
45
+ }]);
46
+
47
+ if (!isModalActive) {
48
+ return null;
49
+ }
50
+
51
+ return createElement(PreferencesModal, {
52
+ closeModal: toggleModal
53
+ }, createElement(PreferencesModalTabs, {
54
+ sections: sections
55
+ }));
56
+ }
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/index.js"],"names":["PreferencesModal","PreferencesModalTabs","PreferencesModalSection","useMemo","__","EnableFeature","EditSitePreferencesModal","isModalActive","toggleModal","sections","name","tabLabel","content"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,gBADD,EAECC,oBAFD,EAGCC,uBAHD,QAIO,sBAJP;AAKA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAAS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AC,gBAAD;AAAkB,IAAA,UAAU,EAAGC;AAA/B,KACC,cAAC,oBAAD;AAAsB,IAAA,QAAQ,EAAGC;AAAjC,IADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPreferencesModal,\n\tPreferencesModalTabs,\n\tPreferencesModalSection,\n} from '@wordpress/interface';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EnableFeature from './enable-feature';\n\nexport default function EditSitePreferencesModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tconst sections = useMemo( () => [\n\t\t{\n\t\t\tname: 'general',\n\t\t\ttabLabel: __( 'General' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Appearance' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize options related to the block editor interface and editing flow.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"focusMode\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Highlights the current block and fades other content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"showIconLabels\"\n\t\t\t\t\t\tlabel={ __( 'Show button text labels' ) }\n\t\t\t\t\t\thelp={ __( 'Show text instead of icons on buttons' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tname: 'blocks',\n\t\t\ttabLabel: __( 'Blocks' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Block interactions' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize how you interact with blocks in the block library and editing canvas.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"keepCaretInsideBlock\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Contain text cursor inside block' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t] );\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<PreferencesModal closeModal={ toggleModal }>\n\t\t\t<PreferencesModalTabs sections={ sections } />\n\t\t</PreferencesModal>\n\t);\n}\n"]}
@@ -16,6 +16,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
16
16
 
17
17
  import DefaultSidebar from './default-sidebar';
18
18
  import GlobalStylesSidebar from './global-styles-sidebar';
19
+ import NavigationMenuSidebar from './navigation-menu-sidebar';
19
20
  import { STORE_NAME } from '../../store/constants';
20
21
  import SettingsHeader from './settings-header';
21
22
  import TemplateCard from './template-card';
@@ -57,6 +58,15 @@ export function SidebarComplementaryAreaFills() {
57
58
 
58
59
  if (!isEditorSidebarOpened) {
59
60
  sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
61
+ } // Conditionally include NavMenu sidebar in Plugin only.
62
+ // Optimise for dead code elimination.
63
+ // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
64
+
65
+
66
+ let MaybeNavigationMenuSidebar = 'Fragment';
67
+
68
+ if (process.env.IS_GUTENBERG_PLUGIN) {
69
+ MaybeNavigationMenuSidebar = NavigationMenuSidebar;
60
70
  }
61
71
 
62
72
  return createElement(Fragment, null, createElement(DefaultSidebar, {
@@ -70,6 +80,6 @@ export function SidebarComplementaryAreaFills() {
70
80
  headerClassName: "edit-site-sidebar__panel-tabs"
71
81
  }, sidebarName === SIDEBAR_TEMPLATE && createElement(PanelBody, null, createElement(TemplateCard, null)), sidebarName === SIDEBAR_BLOCK && createElement(InspectorSlot, {
72
82
  bubblesVirtually: true
73
- })), createElement(GlobalStylesSidebar, null));
83
+ })), createElement(GlobalStylesSidebar, null), createElement(MaybeNavigationMenuSidebar, null));
74
84
  }
75
85
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["createSlotFill","PanelBody","__","cog","useEffect","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","getBlockSelectionStart","enableComplementaryArea","sidebarName"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,GAAT,QAAoB,kBAApB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,aAAhD;AAEA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IAA+CpB,cAAc,CAClE,0BAD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AAGC,IAAA,IAAI,EAAGC,GAHR;AAIC,IAAA,UAAU,EAAGD,EAAE,CAAE,wBAAF,CAJhB;AAKC,IAAA,MAAM,EAAG,cAAC,cAAD;AAAgB,MAAA,WAAW,EAAG+B;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKjB,gBAAhB,IACD,cAAC,SAAD,QACC,cAAC,YAAD,OADD,CATF,EAaGiB,WAAW,KAAKlB,aAAhB,IACD,cAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBC,cAAC,mBAAD,OAlBD,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cog } from '@wordpress/icons';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst { sidebar, isEditorSidebarOpened, hasBlockSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst _sidebar = select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( STORE_NAME );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tSIDEBAR_BLOCK,\n\t\t\t\tSIDEBAR_TEMPLATE,\n\t\t\t].includes( _sidebar );\n\t\t\treturn {\n\t\t\t\tsidebar: _sidebar,\n\t\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\t\thasBlockSelection: !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ cog }\n\t\t\t\tcloseLabel={ __( 'Close settings sidebar' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t<GlobalStylesSidebar />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["createSlotFill","PanelBody","__","cog","useEffect","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","NavigationMenuSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","getBlockSelectionStart","enableComplementaryArea","sidebarName","MaybeNavigationMenuSidebar","process","env","IS_GUTENBERG_PLUGIN"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,GAAT,QAAoB,kBAApB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,aAAhD;AAEA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IAA+CrB,cAAc,CAClE,0BADkE,CAAnE;AAGA,OAAO,MAAMsB,oBAAoB,GAAGD,aAA7B;AAEP,OAAO,SAASE,6BAAT,GAAyC;AAC/C,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,qBAAX;AAAkCC,IAAAA;AAAlC,MAAwDrB,SAAS,CACpEsB,MAAF,IAAc;AACb,UAAMC,QAAQ,GAAGD,MAAM,CACtBnB,cADsB,CAAN,CAEfqB,0BAFe,CA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AAC,cAAD;AAAgB,MAAA,WAAW,EAAGgC;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKjB,gBAAhB,IACD,cAAC,SAAD,QACC,cAAC,YAAD,OADD,CATF,EAaGiB,WAAW,KAAKlB,aAAhB,IACD,cAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBC,cAAC,mBAAD,OAlBD,EAmBC,cAAC,0BAAD,OAnBD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cog } from '@wordpress/icons';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport NavigationMenuSidebar from './navigation-menu-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst { sidebar, isEditorSidebarOpened, hasBlockSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst _sidebar = select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( STORE_NAME );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tSIDEBAR_BLOCK,\n\t\t\t\tSIDEBAR_TEMPLATE,\n\t\t\t].includes( _sidebar );\n\t\t\treturn {\n\t\t\t\tsidebar: _sidebar,\n\t\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\t\thasBlockSelection: !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavigationMenuSidebar = 'Fragment';\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavigationMenuSidebar = NavigationMenuSidebar;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ cog }\n\t\t\t\tcloseLabel={ __( 'Close settings sidebar' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t<GlobalStylesSidebar />\n\t\t\t<MaybeNavigationMenuSidebar />\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { FlexBlock, Flex } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+ import { navigation } from '@wordpress/icons';
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ import DefaultSidebar from '../default-sidebar';
14
+ import NavigationInspector from './navigation-inspector';
15
+ export default function NavigationMenuSidebar() {
16
+ return createElement(DefaultSidebar, {
17
+ className: "edit-site-navigation-menu-sidebar",
18
+ identifier: "edit-site/navigation-menu",
19
+ title: __('Navigation Menus'),
20
+ icon: navigation,
21
+ closeLabel: __('Close navigation menu sidebar'),
22
+ panelClassName: "edit-site-navigation-menu-sidebar__panel",
23
+ header: createElement(Flex, null, createElement(FlexBlock, null, createElement("strong", null, __('Navigation Menus'))))
24
+ }, createElement(NavigationInspector, null));
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/navigation-menu-sidebar/index.js"],"names":["FlexBlock","Flex","__","navigation","DefaultSidebar","NavigationInspector","NavigationMenuSidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,IAApB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,mBAAP,MAAgC,wBAAhC;AAEA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,SACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,UAAU,EAAC,2BAFZ;AAGC,IAAA,KAAK,EAAGJ,EAAE,CAAE,kBAAF,CAHX;AAIC,IAAA,IAAI,EAAGC,UAJR;AAKC,IAAA,UAAU,EAAGD,EAAE,CAAE,+BAAF,CALhB;AAMC,IAAA,cAAc,EAAC,0CANhB;AAOC,IAAA,MAAM,EACL,cAAC,IAAD,QACC,cAAC,SAAD,QACC,8BAAUA,EAAE,CAAE,kBAAF,CAAZ,CADD,CADD;AARF,KAeC,cAAC,mBAAD,OAfD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { navigation } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from '../default-sidebar';\nimport NavigationInspector from './navigation-inspector';\n\nexport default function NavigationMenuSidebar() {\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-navigation-menu-sidebar\"\n\t\t\tidentifier=\"edit-site/navigation-menu\"\n\t\t\ttitle={ __( 'Navigation Menus' ) }\n\t\t\ticon={ navigation }\n\t\t\tcloseLabel={ __( 'Close navigation menu sidebar' ) }\n\t\t\tpanelClassName=\"edit-site-navigation-menu-sidebar__panel\"\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Navigation Menus' ) }</strong>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<NavigationInspector />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}