@wordpress/edit-site 4.0.1 → 4.0.2

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 (81) hide show
  1. package/build/components/add-new-template/new-template-part.js +4 -1
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/error-boundary/index.js +11 -27
  4. package/build/components/error-boundary/index.js.map +1 -1
  5. package/build/components/error-boundary/warning.js +70 -0
  6. package/build/components/error-boundary/warning.js.map +1 -0
  7. package/build/components/global-styles/navigation-button.js +7 -27
  8. package/build/components/global-styles/navigation-button.js.map +1 -1
  9. package/build/components/global-styles/typography-panel.js +5 -2
  10. package/build/components/global-styles/typography-panel.js.map +1 -1
  11. package/build/components/global-styles/use-global-styles-output.js +21 -4
  12. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  13. package/build/components/list/table.js +3 -1
  14. package/build/components/list/table.js.map +1 -1
  15. package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
  16. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  17. package/build/components/routes/redirect-to-homepage.js +22 -3
  18. package/build/components/routes/redirect-to-homepage.js.map +1 -1
  19. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  20. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  21. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  22. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  23. package/build/index.js +15 -1
  24. package/build/index.js.map +1 -1
  25. package/build/store/actions.js +191 -155
  26. package/build/store/actions.js.map +1 -1
  27. package/build/store/index.js +0 -3
  28. package/build/store/index.js.map +1 -1
  29. package/build/store/selectors.js +3 -2
  30. package/build/store/selectors.js.map +1 -1
  31. package/build-module/components/add-new-template/new-template-part.js +4 -1
  32. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  33. package/build-module/components/error-boundary/index.js +9 -26
  34. package/build-module/components/error-boundary/index.js.map +1 -1
  35. package/build-module/components/error-boundary/warning.js +60 -0
  36. package/build-module/components/error-boundary/warning.js.map +1 -0
  37. package/build-module/components/global-styles/navigation-button.js +8 -28
  38. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  39. package/build-module/components/global-styles/typography-panel.js +6 -3
  40. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  41. package/build-module/components/global-styles/use-global-styles-output.js +20 -4
  42. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build-module/components/list/table.js +2 -1
  44. package/build-module/components/list/table.js.map +1 -1
  45. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
  46. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  47. package/build-module/components/routes/redirect-to-homepage.js +22 -3
  48. package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
  49. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  50. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  51. package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
  52. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  53. package/build-module/index.js +13 -1
  54. package/build-module/index.js.map +1 -1
  55. package/build-module/store/actions.js +170 -145
  56. package/build-module/store/actions.js.map +1 -1
  57. package/build-module/store/index.js +0 -2
  58. package/build-module/store/index.js.map +1 -1
  59. package/build-module/store/selectors.js +3 -2
  60. package/build-module/store/selectors.js.map +1 -1
  61. package/build-style/style-rtl.css +11 -10
  62. package/build-style/style.css +11 -10
  63. package/package.json +18 -18
  64. package/src/components/add-new-template/new-template-part.js +7 -1
  65. package/src/components/error-boundary/index.js +11 -28
  66. package/src/components/error-boundary/warning.js +59 -0
  67. package/src/components/global-styles/navigation-button.js +6 -25
  68. package/src/components/global-styles/typography-panel.js +12 -5
  69. package/src/components/global-styles/use-global-styles-output.js +19 -3
  70. package/src/components/list/table.js +5 -2
  71. package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
  72. package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
  73. package/src/components/routes/redirect-to-homepage.js +27 -4
  74. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  75. package/src/components/template-part-converter/convert-to-template-part.js +6 -1
  76. package/src/index.js +17 -1
  77. package/src/store/actions.js +161 -205
  78. package/src/store/index.js +0 -2
  79. package/src/store/selectors.js +3 -0
  80. package/src/store/test/actions.js +186 -92
  81. package/src/store/test/selectors.js +8 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-toggle/index.js"],"names":["NavigationToggle","icon","isNavigationOpen","isRequestingSiteIcon","siteIconUrl","select","getEntityRecord","isResolving","coreDataStore","siteData","undefined","editSiteStore","isNavigationOpened","site_icon_url","setIsNavigationPanelOpened","disableMotion","navigationToggleRef","current","focus","toggleNavigationPanel","buttonIcon","wordpress","effect","expand","scale","borderRadius","transition","type","duration"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,SAASA,gBAAT,OAAsC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACrC,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,oBAApB;AAA0CC,IAAAA;AAA1C,MAA0D,qBAC7DC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAmCF,MAAM,CAAEG,eAAF,CAA/C;AACA,UAAMC,QAAQ,GACbH,eAAe,CAAE,MAAF,EAAU,gBAAV,EAA4BI,SAA5B,CAAf,IAA0D,EAD3D;AAGA,WAAO;AACNR,MAAAA,gBAAgB,EAAEG,MAAM,CAAEM,YAAF,CAAN,CAAwBC,kBAAxB,EADZ;AAENT,MAAAA,oBAAoB,EAAEI,WAAW,CAAE,MAAF,EAAU,iBAAV,EAA6B,CAC7D,MAD6D,EAE7D,gBAF6D,EAG7DG,SAH6D,CAA7B,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,MAAA,IAAI,EAAGnB;AAAzB,MAAb;AACA;;AAED,SACC,4BAAC,4BAAD,CAAQ,GAAR;AACC,IAAA,SAAS,EACR,iCACEC,gBAAgB,GAAG,UAAH,GAAgB,EADlC,CAFF;AAKC,IAAA,UAAU,EAAC;AALZ,KAOC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAG,cAAI,mBAAJ,CAFT;AAGC,IAAA,GAAG,EAAGc,mBAHP,CAIC;AAJD;AAKC,oBAAed,gBALhB;AAMC,IAAA,OAAO,EAAGiB,qBANX;AAOC,IAAA,WAAW;AAPZ,KASGC,UATH,CAPD,CADD;AAqBA;;eAEcpB,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tButton,\n\tIcon,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { wordpress } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nfunction NavigationToggle( { icon } ) {\n\tconst { isNavigationOpen, isRequestingSiteIcon, siteIconUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, isResolving } = select( coreDataStore );\n\t\t\tconst siteData =\n\t\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\t\treturn {\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t\tisRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [\n\t\t\t\t\t'root',\n\t\t\t\t\t'__unstableBase',\n\t\t\t\t\tundefined,\n\t\t\t\t] ),\n\t\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { setIsNavigationPanelOpened } = useDispatch( editSiteStore );\n\n\tconst disableMotion = useReducedMotion();\n\n\tconst navigationToggleRef = useRef();\n\n\tuseEffect( () => {\n\t\t// TODO: Remove this effect when alternative solution is merged.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/37314\n\t\tif ( ! isNavigationOpen ) {\n\t\t\tnavigationToggleRef.current.focus();\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\tconst toggleNavigationPanel = () =>\n\t\tsetIsNavigationPanelOpened( ! isNavigationOpen );\n\n\tlet buttonIcon = <Icon size=\"36px\" icon={ wordpress } />;\n\n\tconst effect = {\n\t\texpand: {\n\t\t\tscale: 1.7,\n\t\t\tborderRadius: 0,\n\t\t\ttransition: { type: 'tween', duration: '0.2' },\n\t\t},\n\t};\n\n\tif ( siteIconUrl ) {\n\t\tbuttonIcon = (\n\t\t\t<motion.img\n\t\t\t\tvariants={ ! disableMotion && effect }\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"edit-site-navigation-toggle__site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t} else if ( isRequestingSiteIcon ) {\n\t\tbuttonIcon = null;\n\t} else if ( icon ) {\n\t\tbuttonIcon = <Icon size=\"36px\" icon={ icon } />;\n\t}\n\n\treturn (\n\t\t<motion.div\n\t\t\tclassName={\n\t\t\t\t'edit-site-navigation-toggle' +\n\t\t\t\t( isNavigationOpen ? ' is-open' : '' )\n\t\t\t}\n\t\t\twhileHover=\"expand\"\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-navigation-toggle__button has-icon\"\n\t\t\t\tlabel={ __( 'Toggle navigation' ) }\n\t\t\t\tref={ navigationToggleRef }\n\t\t\t\t// isPressed will add unwanted styles.\n\t\t\t\taria-pressed={ isNavigationOpen }\n\t\t\t\tonClick={ toggleNavigationPanel }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t{ buttonIcon }\n\t\t\t</Button>\n\t\t</motion.div>\n\t);\n}\n\nexport default NavigationToggle;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-toggle/index.js"],"names":["NavigationToggle","icon","isNavigationOpen","isRequestingSiteIcon","siteIconUrl","select","getEntityRecord","isResolving","coreDataStore","siteData","undefined","editSiteStore","isNavigationOpened","site_icon_url","setIsNavigationPanelOpened","disableMotion","navigationToggleRef","current","focus","toggleNavigationPanel","buttonIcon","wordpress","effect","expand","scale","transition","type","duration","classes"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGA,SAASA,gBAAT,OAAsC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACrC,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,oBAApB;AAA0CC,IAAAA;AAA1C,MAA0D,qBAC7DC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAmCF,MAAM,CAAEG,eAAF,CAA/C;AACA,UAAMC,QAAQ,GACbH,eAAe,CAAE,MAAF,EAAU,gBAAV,EAA4BI,SAA5B,CAAf,IAA0D,EAD3D;AAGA,WAAO;AACNR,MAAAA,gBAAgB,EAAEG,MAAM,CAAEM,YAAF,CAAN,CAAwBC,kBAAxB,EADZ;AAENT,MAAAA,oBAAoB,EAAEI,WAAW,CAAE,MAAF,EAAU,iBAAV,EAA6B,CAC7D,MAD6D,EAE7D,gBAF6D,EAG7DG,SAH6D,CAA7B,CAF3B;AAONN,MAAAA,WAAW,EAAEK,QAAQ,CAACI;AAPhB,KAAP;AASA,GAf8D,EAgB/D,EAhB+D,CAAhE;AAkBA,QAAM;AAAEC,IAAAA;AAAF,MAAiC,uBAAaH,YAAb,CAAvC;AAEA,QAAMI,aAAa,GAAG,gCAAtB;AAEA,QAAMC,mBAAmB,GAAG,sBAA5B;AAEA,0BAAW,MAA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AAC,kBAAD;AACC,IAAA,SAAS,EAAG0B,OADb;AAEC,IAAA,KAAK,EAAG,cAAI,mBAAJ,CAFT;AAGC,IAAA,GAAG,EAAGZ,mBAHP,CAIC;AAJD;AAKC,oBAAed,gBALhB;AAMC,IAAA,OAAO,EAAGiB,qBANX;AAOC,IAAA,WAAW;AAPZ,KASGC,UATH,CAPD,CADD;AAqBA;;eAEcpB,gB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tButton,\n\tIcon,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { wordpress } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nfunction NavigationToggle( { icon } ) {\n\tconst { isNavigationOpen, isRequestingSiteIcon, siteIconUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, isResolving } = select( coreDataStore );\n\t\t\tconst siteData =\n\t\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\t\treturn {\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t\tisRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [\n\t\t\t\t\t'root',\n\t\t\t\t\t'__unstableBase',\n\t\t\t\t\tundefined,\n\t\t\t\t] ),\n\t\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { setIsNavigationPanelOpened } = useDispatch( editSiteStore );\n\n\tconst disableMotion = useReducedMotion();\n\n\tconst navigationToggleRef = useRef();\n\n\tuseEffect( () => {\n\t\t// TODO: Remove this effect when alternative solution is merged.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/37314\n\t\tif ( ! isNavigationOpen ) {\n\t\t\tnavigationToggleRef.current.focus();\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\tconst toggleNavigationPanel = () =>\n\t\tsetIsNavigationPanelOpened( ! isNavigationOpen );\n\n\tlet buttonIcon = <Icon size=\"36px\" icon={ wordpress } />;\n\n\tconst effect = {\n\t\texpand: {\n\t\t\tscale: 1.25,\n\t\t\ttransition: { type: 'tween', duration: '0.3' },\n\t\t},\n\t};\n\n\tif ( siteIconUrl ) {\n\t\tbuttonIcon = (\n\t\t\t<motion.img\n\t\t\t\tvariants={ ! disableMotion && effect }\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"edit-site-navigation-toggle__site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t} else if ( isRequestingSiteIcon ) {\n\t\tbuttonIcon = null;\n\t} else if ( icon ) {\n\t\tbuttonIcon = <Icon size=\"36px\" icon={ icon } />;\n\t}\n\n\tconst classes = classnames( {\n\t\t'edit-site-navigation-toggle__button': true,\n\t\t'has-icon': siteIconUrl,\n\t} );\n\n\treturn (\n\t\t<motion.div\n\t\t\tclassName={\n\t\t\t\t'edit-site-navigation-toggle' +\n\t\t\t\t( isNavigationOpen ? ' is-open' : '' )\n\t\t\t}\n\t\t\twhileHover=\"expand\"\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName={ classes }\n\t\t\t\tlabel={ __( 'Toggle navigation' ) }\n\t\t\t\tref={ navigationToggleRef }\n\t\t\t\t// isPressed will add unwanted styles.\n\t\t\t\taria-pressed={ isNavigationOpen }\n\t\t\t\tonClick={ toggleNavigationPanel }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t{ buttonIcon }\n\t\t\t</Button>\n\t\t</motion.div>\n\t);\n}\n\nexport default NavigationToggle;\n"]}
@@ -28,6 +28,14 @@ function getNeedsHomepageRedirect(params) {
28
28
  } = params;
29
29
  return !(0, _getIsListPage.default)(params) && !['post', 'page', 'wp_template', 'wp_template_part'].includes(postType);
30
30
  }
31
+ /**
32
+ * Returns the postType and postId of the default homepage.
33
+ *
34
+ * @param {string} siteUrl The URL of the site.
35
+ * @return {Object} An object containing the postType and postId properties
36
+ * or `undefined` if a homepage could not be found.
37
+ */
38
+
31
39
 
32
40
  async function getHomepageParams(siteUrl) {
33
41
  const siteSettings = await (0, _apiFetch.default)({
@@ -35,7 +43,7 @@ async function getHomepageParams(siteUrl) {
35
43
  });
36
44
 
37
45
  if (!siteSettings) {
38
- return;
46
+ throw new Error('`getHomepageParams`: unable to load site settings.');
39
47
  }
40
48
 
41
49
  const {
@@ -55,15 +63,26 @@ async function getHomepageParams(siteUrl) {
55
63
 
56
64
  const template = await window.fetch((0, _url.addQueryArgs)(siteUrl, {
57
65
  '_wp-find-template': true
58
- })).then(res => res.json()).then(_ref => {
66
+ })).then(response => {
67
+ if (!response.ok) {
68
+ throw new Error(`\`getHomepageParams\`: HTTP status error, ${response.status} ${response.statusText}`);
69
+ }
70
+
71
+ return response.json();
72
+ }).then(_ref => {
59
73
  let {
60
74
  data
61
75
  } = _ref;
76
+
77
+ if (data.message) {
78
+ throw new Error(`\`getHomepageParams\`: REST API error, ${data.message}`);
79
+ }
80
+
62
81
  return data;
63
82
  });
64
83
 
65
84
  if (!(template !== null && template !== void 0 && template.id)) {
66
- return;
85
+ throw new Error('`getHomepageParams`: unable to find home template.');
67
86
  }
68
87
 
69
88
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/routes/redirect-to-homepage.js"],"names":["getNeedsHomepageRedirect","params","postType","includes","getHomepageParams","siteUrl","siteSettings","path","show_on_front","showOnFront","page_on_front","frontpageId","postId","template","window","fetch","then","res","json","data","id","redirectToHomepage","searchParams","URLSearchParams","history","location","search","Object","fromEntries","entries","homepageParams","replace"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,wBAAT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AtC,CAArB;AACA,QAAMzB,MAAM,GAAG0B,MAAM,CAACC,WAAP,CAAoBN,YAAY,CAACO,OAAb,EAApB,CAAf;;AAEA,MAAK7B,wBAAwB,CAAEC,MAAF,CAA7B,EAA0C;AACzC,UAAM6B,cAAc,GAAG,MAAM1B,iBAAiB,CAAEC,OAAF,CAA9C;;AAEA,QAAKyB,cAAL,EAAsB;AACrBN,uBAAQO,OAAR,CAAiBD,cAAjB;AACA;AACD;AACD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport history from '../../utils/history';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nfunction getNeedsHomepageRedirect( params ) {\n\tconst { postType } = params;\n\treturn (\n\t\t! getIsListPage( params ) &&\n\t\t! [ 'post', 'page', 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t)\n\t);\n}\n\nasync function getHomepageParams( siteUrl ) {\n\tconst siteSettings = await apiFetch( { path: '/wp/v2/settings' } );\n\tif ( ! siteSettings ) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = siteSettings;\n\n\t// If the user has set a page as the homepage, use those details.\n\tif ( showOnFront === 'page' ) {\n\t\treturn {\n\t\t\tpostType: 'page',\n\t\t\tpostId: frontpageId,\n\t\t};\n\t}\n\n\t// Else get the home template.\n\t// This matches the logic in `__experimentalGetTemplateForLink`.\n\t// (packages/core-data/src/resolvers.js)\n\tconst template = await window\n\t\t.fetch( addQueryArgs( siteUrl, { '_wp-find-template': true } ) )\n\t\t.then( ( res ) => res.json() )\n\t\t.then( ( { data } ) => data );\n\n\tif ( ! template?.id ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tpostType: 'wp_template',\n\t\tpostId: template.id,\n\t};\n}\n\nexport default async function redirectToHomepage( siteUrl ) {\n\tconst searchParams = new URLSearchParams( history.location.search );\n\tconst params = Object.fromEntries( searchParams.entries() );\n\n\tif ( getNeedsHomepageRedirect( params ) ) {\n\t\tconst homepageParams = await getHomepageParams( siteUrl );\n\n\t\tif ( homepageParams ) {\n\t\t\thistory.replace( homepageParams );\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/routes/redirect-to-homepage.js"],"names":["getNeedsHomepageRedirect","params","postType","includes","getHomepageParams","siteUrl","siteSettings","path","Error","show_on_front","showOnFront","page_on_front","frontpageId","postId","template","window","fetch","then","response","ok","status","statusText","json","data","message","id","redirectToHomepage","searchParams","URLSearchParams","history","location","search","Object","fromEntries","entries","homepageParams","replace"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,wBAAT,CAAmCC,MAAnC,EAA4C;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAeD,MAArB;AACA,SACC,CAAE,4BAAeA,MAAf,CAAF,IACA,CAAE,CAAE,MAAF,EAAU,MAAV,EAAkB,aAAlB,EAAiC,kBAAjC,EAAsDE,QAAtD,CACDD,QADC,CAFH;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeE,iBAAf,CAAkCC,OAAlC,EAA4C;AAC3C,QAAMC,YAAY,GAAG,MAAM,uBAAU;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAAV,CAA3B;;AACA,MAAK,CAAED,YAAP,EAAsB;AACrB,UAAM,IAAIE,KAAJ,CAAW,oDAAX,CAAN;AACA;;AAED,QAAM;AACLC,IAAAA,aAAa,EAAEC,WADV;AAELC,IAAAA,aAAa,EAAEC;AAFV,MAGFN,YAHJ,CAN2C,CAW3C;;AACA,MAAKI,WAAW,KAAK,MAArB,EAA8B;AAC7B,WAAO;AACNR,MAAAA,QAAQ,EAAE,MADJ;AAENW,MAAAA,MAAM,EAAED;AAFF,KAAP;AAIA,GAjB0C,CAmB3C;AACA;AAC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sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport history from '../../utils/history';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nfunction getNeedsHomepageRedirect( params ) {\n\tconst { postType } = params;\n\treturn (\n\t\t! getIsListPage( params ) &&\n\t\t! [ 'post', 'page', 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t)\n\t);\n}\n\n/**\n * Returns the postType and postId of the default homepage.\n *\n * @param {string} siteUrl The URL of the site.\n * @return {Object} An object containing the postType and postId properties\n * or `undefined` if a homepage could not be found.\n */\nasync function getHomepageParams( siteUrl ) {\n\tconst siteSettings = await apiFetch( { path: '/wp/v2/settings' } );\n\tif ( ! siteSettings ) {\n\t\tthrow new Error( '`getHomepageParams`: unable to load site settings.' );\n\t}\n\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = siteSettings;\n\n\t// If the user has set a page as the homepage, use those details.\n\tif ( showOnFront === 'page' ) {\n\t\treturn {\n\t\t\tpostType: 'page',\n\t\t\tpostId: frontpageId,\n\t\t};\n\t}\n\n\t// Else get the home template.\n\t// This matches the logic in `__experimentalGetTemplateForLink`.\n\t// (packages/core-data/src/resolvers.js)\n\tconst template = await window\n\t\t.fetch( addQueryArgs( siteUrl, { '_wp-find-template': true } ) )\n\t\t.then( ( response ) => {\n\t\t\tif ( ! response.ok ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\\`getHomepageParams\\`: HTTP status error, ${ response.status } ${ response.statusText }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn response.json();\n\t\t} )\n\t\t.then( ( { data } ) => {\n\t\t\tif ( data.message ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`\\`getHomepageParams\\`: REST API error, ${ data.message }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn data;\n\t\t} );\n\n\tif ( ! template?.id ) {\n\t\tthrow new Error( '`getHomepageParams`: unable to find home template.' );\n\t}\n\n\treturn {\n\t\tpostType: 'wp_template',\n\t\tpostId: template.id,\n\t};\n}\n\nexport default async function redirectToHomepage( siteUrl ) {\n\tconst searchParams = new URLSearchParams( history.location.search );\n\tconst params = Object.fromEntries( searchParams.entries() );\n\n\tif ( getNeedsHomepageRedirect( params ) ) {\n\t\tconst homepageParams = await getHomepageParams( siteUrl );\n\n\t\tif ( homepageParams ) {\n\t\t\thistory.replace( homepageParams );\n\t\t}\n\t}\n}\n"]}
@@ -34,16 +34,6 @@ function ListViewSidebar() {
34
34
  const {
35
35
  setIsListViewOpened
36
36
  } = (0, _data.useDispatch)(_store.store);
37
- const {
38
- clearSelectedBlock,
39
- selectBlock
40
- } = (0, _data.useDispatch)(_blockEditor.store);
41
-
42
- async function selectEditorBlock(clientId) {
43
- await clearSelectedBlock();
44
- selectBlock(clientId, -1);
45
- }
46
-
47
37
  const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
48
38
  const headerFocusReturnRef = (0, _compose.useFocusReturn)();
49
39
  const contentFocusReturnRef = (0, _compose.useFocusReturn)();
@@ -74,7 +64,6 @@ function ListViewSidebar() {
74
64
  className: "edit-site-editor__list-view-panel-content",
75
65
  ref: (0, _compose.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
76
66
  }, (0, _element.createElement)(_blockEditor.__experimentalListView, {
77
- onSelect: selectEditorBlock,
78
67
  showNestedBlocks: true,
79
68
  __experimentalFeatures: true,
80
69
  __experimentalPersistentListViewFeatures: true
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"names":["ListViewSidebar","setIsListViewOpened","editSiteStore","clearSelectedBlock","selectBlock","blockEditorStore","selectEditorBlock","clientId","focusOnMountRef","headerFocusReturnRef","contentFocusReturnRef","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","instanceId","labelId","closeSmall"],"mappings":";;;;;;;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,2CADX;AAEC,MAAA,GAAG,EAAG,2BAAc,CACnBS,qBADmB,EAEnBF,eAFmB,CAAd;AAFP,OAOC,4BAAC,mCAAD;AACC,MAAA,QAAQ,EAAGF,iBADZ;AAEC,MAAA,gBAAgB,MAFjB;AAGC,MAAA,sBAAsB,MAHvB;AAIC,MAAA,wCAAwC;AAJzC,MAPD,CAhBD;AAFD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalListView as ListView,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport {\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseInstanceId,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\tconst { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );\n\tasync function selectEditorBlock( clientId ) {\n\t\tawait clearSelectedBlock();\n\t\tselectBlock( clientId, -1 );\n\t}\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst headerFocusReturnRef = useFocusReturn();\n\tconst contentFocusReturnRef = useFocusReturn();\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( ListViewSidebar );\n\tconst labelId = `edit-site-editor__list-view-panel-label-${ instanceId }`;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\taria-labelledby={ labelId }\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-header\"\n\t\t\t\tref={ headerFocusReturnRef }\n\t\t\t>\n\t\t\t\t<strong id={ labelId }>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close List View Sidebar' ) }\n\t\t\t\t\tonClick={ () => setIsListViewOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tcontentFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<ListView\n\t\t\t\t\tonSelect={ selectEditorBlock }\n\t\t\t\t\tshowNestedBlocks\n\t\t\t\t\t__experimentalFeatures\n\t\t\t\t\t__experimentalPersistentListViewFeatures\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/secondary-sidebar/list-view-sidebar.js"],"names":["ListViewSidebar","setIsListViewOpened","editSiteStore","focusOnMountRef","headerFocusReturnRef","contentFocusReturnRef","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","instanceId","labelId","closeSmall"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGe,SAASA,eAAT,GAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,YAAb,CAAhC;AAEA,QAAMC,eAAe,GAAG,8BAAiB,cAAjB,CAAxB;AACA,QAAMC,oBAAoB,GAAG,8BAA7B;AACA,QAAMC,qBAAqB,GAAG,8BAA9B;;AACA,WAASC,aAAT,CAAwBC,KAAxB,EAAgC;AAC/B,QAAKA,KAAK,CAACC,OAAN,KAAkBC,gBAAlB,IAA4B,CAAEF,KAAK,CAACG,gBAAzC,EAA4D;AAC3DT,MAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;AACD;;AAED,QAAMU,UAAU,GAAG,4BAAeX,eAAf,CAAnB;AACA,QAAMY,OAAO,GAAI,2CAA2CD,UAAY,EAAxE;AAEA,SACC;AACA;AACC,yBAAkBC,OADnB;AAEC,MAAA,SAAS,EAAC,mCAFX;AAGC,MAAA,SAAS,EAAGN;AAHb,OAKC;AACC,MAAA,SAAS,EAAC,0CADX;AAEC,MAAA,GAAG,EAAGF;AAFP,OAIC;AAAQ,MAAA,EAAE,EAAGQ;AAAb,OAAyB,cAAI,WAAJ,CAAzB,CAJD,EAKC,4BAAC,kBAAD;AACC,MAAA,IAAI,EAAGC,iBADR;AAEC,MAAA,KAAK,EAAG,cAAI,yBAAJ,CAFT;AAGC,MAAA,OAAO,EAAG,MAAMZ,mBAAmB,CAAE,KAAF;AAHpC,MALD,CALD,EAgBC;AACC,MAAA,SAAS,EAAC,2CADX;AAEC,MAAA,GAAG,EAAG,2BAAc,CACnBI,qBADmB,EAEnBF,eAFmB,CAAd;AAFP,OAOC,4BAAC,mCAAD;AACC,MAAA,gBAAgB,MADjB;AAEC,MAAA,sBAAsB,MAFvB;AAGC,MAAA,wCAAwC;AAHzC,MAPD,CAhBD;AAFD;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport {\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseInstanceId,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst headerFocusReturnRef = useFocusReturn();\n\tconst contentFocusReturnRef = useFocusReturn();\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( ListViewSidebar );\n\tconst labelId = `edit-site-editor__list-view-panel-label-${ instanceId }`;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\taria-labelledby={ labelId }\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-header\"\n\t\t\t\tref={ headerFocusReturnRef }\n\t\t\t>\n\t\t\t\t<strong id={ labelId }>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close List View Sidebar' ) }\n\t\t\t\t\tonClick={ () => setIsListViewOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tcontentFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<ListView\n\t\t\t\t\tshowNestedBlocks\n\t\t\t\t\t__experimentalFeatures\n\t\t\t\t\t__experimentalPersistentListViewFeatures\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -59,8 +59,11 @@ function ConvertToTemplatePart(_ref) {
59
59
  title,
60
60
  area
61
61
  } = _ref2;
62
+ // Currently template parts only allow latin chars.
63
+ // Fallback slug will receive suffix by default.
64
+ const cleanSlug = (0, _lodash.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
62
65
  const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
63
- slug: (0, _lodash.kebabCase)(title),
66
+ slug: cleanSlug,
64
67
  title,
65
68
  content: (0, _blocks.serialize)(blocks),
66
69
  area
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","blockEditorStore","saveEntityRecord","coreStore","createSuccessNotice","noticesStore","onConvert","title","area","templatePart","slug","content","theme","type"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGe,SAASA,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAwB;AACtE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,kBAAb,CAA1B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;;AAEA,QAAMC,SAAS,GAAG,eAA6B;AAAA,QAArB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAqB;AAC9C,UAAMC,YAAY,GAAG,MAAMP,gBAAgB,CAC1C,UAD0C,EAE1C,kBAF0C,EAG1C;AACCQ,MAAAA,IAAI,EAAE,uBAAWH,KAAX,CADP;AAECA,MAAAA,KAFD;AAGCI,MAAAA,OAAO,EAAE,uBAAWd,MAAX,CAHV;AAICW,MAAAA;AAJD,KAH0C,CAA3C;AAUAR,IAAAA,aAAa,CACZJ,SADY,EAEZ,yBAAa,oBAAb,EAAmC;AAClCc,MAAAA,IAAI,EAAED,YAAY,CAACC,IADe;AAElCE,MAAAA,KAAK,EAAEH,YAAY,CAACG;AAFc,KAAnC,CAFY,CAAb;AAOAR,IAAAA,mBAAmB,CAAE,cAAI,wBAAJ,CAAF,EAAkC;AACpDS,MAAAA,IAAI,EAAE;AAD8C,KAAlC,CAAnB,CAlB8C,CAsB9C;AACA;AACA,GAxBD;;AA0BA,SACC,qDACC,4BAAC,sCAAD,QACG,MACD,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfd,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAHF,KAKG,cAAI,oBAAJ,CALH,CAFF,CADD,EAYGD,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAM;AAClBC,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGO;AAJZ,IAbF,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock, serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onConvert = async ( { title, area } ) => {\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\ttitle,\n\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\tarea,\n\t\t\t}\n\t\t);\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\n\t\t// The modal and this component will be unmounted because of `replaceBlocks` above,\n\t\t// so no need to call `closeModal` or `onClose`.\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ () => (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Make template part' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t) }\n\t\t\t</BlockSettingsMenuControls>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","blockEditorStore","saveEntityRecord","coreStore","createSuccessNotice","noticesStore","onConvert","title","area","cleanSlug","replace","templatePart","slug","content","theme","type"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGe,SAASA,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,IAAA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,cAAc,CAAE,KAAF,CAAd;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGO;AAJZ,IAbF,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock, serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onConvert = async ( { title, area } ) => {\n\t\t// Currently template parts only allow latin chars.\n\t\t// Fallback slug will receive suffix by default.\n\t\tconst cleanSlug =\n\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: cleanSlug,\n\t\t\t\ttitle,\n\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\tarea,\n\t\t\t}\n\t\t);\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\n\t\t// The modal and this component will be unmounted because of `replaceBlocks` above,\n\t\t// so no need to call `closeModal` or `onClose`.\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ () => (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Make template part' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t) }\n\t\t\t</BlockSettingsMenuControls>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
package/build/index.js CHANGED
@@ -50,6 +50,8 @@ var _coreData = require("@wordpress/core-data");
50
50
 
51
51
  var _editor = require("@wordpress/editor");
52
52
 
53
+ var _i18n = require("@wordpress/i18n");
54
+
53
55
  var _viewport = require("@wordpress/viewport");
54
56
 
55
57
  var _url = require("@wordpress/url");
@@ -64,6 +66,8 @@ var _getIsListPage = _interopRequireDefault(require("./utils/get-is-list-page"))
64
66
 
65
67
  var _redirectToHomepage = _interopRequireDefault(require("./components/routes/redirect-to-homepage"));
66
68
 
69
+ var _warning = _interopRequireDefault(require("./components/error-boundary/warning"));
70
+
67
71
  var _mainDashboardButton = _interopRequireDefault(require("./components/main-dashboard-button"));
68
72
 
69
73
  var _navigationToggle = _interopRequireDefault(require("./components/navigation-sidebar/navigation-toggle"));
@@ -95,7 +99,17 @@ async function reinitializeEditor(target, settings) {
95
99
  // define what's being edited. When visiting via the dashboard link, these
96
100
  // won't be present. Do a client side redirect to the 'homepage' if that's
97
101
  // the case.
98
- await (0, _redirectToHomepage.default)(settings.siteUrl); // This will be a no-op if the target doesn't have any React nodes.
102
+ try {
103
+ await (0, _redirectToHomepage.default)(settings.siteUrl);
104
+ } catch (error) {
105
+ (0, _element.render)((0, _element.createElement)(_warning.default, {
106
+ message: (0, _i18n.__)('The editor is unable to find a block template for the homepage.'),
107
+ error: error,
108
+ dashboardLink: "index.php"
109
+ }), target);
110
+ return;
111
+ } // This will be a no-op if the target doesn't have any React nodes.
112
+
99
113
 
100
114
  (0, _element.unmountComponentAtNode)(target);
101
115
  const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","siteUrl","reboot","bind","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","viewportStore","isViewportMatch","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AA4EA;;AACA;;AACA;;AACA;;AACA;;AAzGA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,kBAAf,CAAmCC,MAAnC,EAA2CC,QAA3C,EAAsD;AAC5D;AACA;AACA;AACA;AACA,QAAM,iCAAoBA,QAAQ,CAACC,OAA7B,CAAN,CAL4D,CAO5D;;AACA,uCAAwBF,MAAxB;AACA,QAAMG,MAAM,GAAGJ,kBAAkB,CAACK,IAAnB,CAAyB,IAAzB,EAA+BJ,MAA/B,EAAuCC,QAAvC,CAAf,CAT4D,CAW5D;AACA;;AACA;AACC,wBAAUI,YAAV,EAA0BC,cAA1B,CAA0CL,QAA1C,EADD,CAGC;AACA;AACA;AACA;;AACA,wBAAUM,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,MAAAA,oBAAoB,EAAER,QAAQ,CAACQ,oBADc;AAE7CC,MAAAA,wBAAwB,EAAET,QAAQ,CAACS;AAFU,KAA9C;AAKA,UAAMC,mBAAmB,GAAG,4BAC3B,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAD2B,CAA5B;;AAIA,QAAKH,mBAAL,EAA2B;AAC1B;AACA;AACA,0BAAUN,YAAV,EAA0BU,0BAA1B,CACC,kBAAQC,eAAR,EAAwBC,eAAxB,CAAyC,QAAzC,CADD;AAGA;AACD;AAED,uBAAQ,4BAAC,YAAD;AAAa,IAAA,MAAM,EAAGd;AAAtB,IAAR,EAA2CH,MAA3C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,gBAAT,CAA2BC,EAA3B,EAA+BlB,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAACmB,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6CrB,QAA7C,CADD;;AAEAA,EAAAA,QAAQ,CAACsB,8BAAT,GAA0CC,oCAA1C;AACAvB,EAAAA,QAAQ,CAACwB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMzB,MAAM,GAAG0B,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;;AAEA,sBAAUS,aAAV,EAAwBC,qCAAxB;;AACA;;AACA,MAAKC,OAAO,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAEDlC,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\nimport redirectToHomepage from './components/routes/redirect-to-homepage';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport async function reinitializeEditor( target, settings ) {\n\t// The site editor relies on `postType` and `postId` params in the URL to\n\t// define what's being edited. When visiting via the dashboard link, these\n\t// won't be present. Do a client side redirect to the 'homepage' if that's\n\t// the case.\n\tawait redirectToHomepage( settings.siteUrl );\n\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","siteUrl","error","reboot","bind","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","viewportStore","isViewportMatch","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA0FA;;AACA;;AACA;;AACA;;AACA;;AAzHA;AACA;AACA;;AAiBA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,kBAAf,CAAmCC,MAAnC,EAA2CC,QAA3C,EAAsD;AAC5D;AACA;AACA;AACA;AACA,MAAI;AACH,UAAM,iCAAoBA,QAAQ,CAACC,OAA7B,CAAN;AACA,GAFD,CAEE,OAAQC,KAAR,EAAgB;AACjB,yBACC,4BAAC,gBAAD;AACC,MAAA,OAAO,EAAG,cACT,iEADS,CADX;AAIC,MAAA,KAAK,EAAGA,KAJT;AAKC,MAAA,aAAa,EAAC;AALf,MADD,EAQCH,MARD;AAUA;AACA,GAnB2D,CAqB5D;;;AACA,uCAAwBA,MAAxB;AACA,QAAMI,MAAM,GAAGL,kBAAkB,CAACM,IAAnB,CAAyB,IAAzB,EAA+BL,MAA/B,EAAuCC,QAAvC,CAAf,CAvB4D,CAyB5D;AACA;;AACA;AACC,wBAAUK,YAAV,EAA0BC,cAA1B,CAA0CN,QAA1C,EADD,CAGC;AACA;AACA;AACA;;AACA,wBAAUO,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,MAAAA,oBAAoB,EAAET,QAAQ,CAACS,oBADc;AAE7CC,MAAAA,wBAAwB,EAAEV,QAAQ,CAACU;AAFU,KAA9C;AAKA,UAAMC,mBAAmB,GAAG,4BAC3B,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAD2B,CAA5B;;AAIA,QAAKH,mBAAL,EAA2B;AAC1B;AACA;AACA,0BAAUN,YAAV,EAA0BU,0BAA1B,CACC,kBAAQC,eAAR,EAAwBC,eAAxB,CAAyC,QAAzC,CADD;AAGA;AACD;AAED,uBAAQ,4BAAC,YAAD;AAAa,IAAA,MAAM,EAAGd;AAAtB,IAAR,EAA2CJ,MAA3C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,gBAAT,CAA2BC,EAA3B,EAA+BnB,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAACoB,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6CtB,QAA7C,CADD;;AAEAA,EAAAA,QAAQ,CAACuB,8BAAT,GAA0CC,oCAA1C;AACAxB,EAAAA,QAAQ,CAACyB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAM1B,MAAM,GAAG2B,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;;AAEA,sBAAUS,aAAV,EAAwBC,qCAAxB;;AACA;;AACA,MAAKC,OAAO,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAEDnC,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\nimport redirectToHomepage from './components/routes/redirect-to-homepage';\nimport ErrorBoundaryWarning from './components/error-boundary/warning';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport async function reinitializeEditor( target, settings ) {\n\t// The site editor relies on `postType` and `postId` params in the URL to\n\t// define what's being edited. When visiting via the dashboard link, these\n\t// won't be present. Do a client side redirect to the 'homepage' if that's\n\t// the case.\n\ttry {\n\t\tawait redirectToHomepage( settings.siteUrl );\n\t} catch ( error ) {\n\t\trender(\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor is unable to find a block template for the homepage.'\n\t\t\t\t) }\n\t\t\t\terror={ error }\n\t\t\t\tdashboardLink=\"index.php\"\n\t\t\t/>,\n\t\t\ttarget\n\t\t);\n\t\treturn;\n\t}\n\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}