@wordpress/edit-site 3.0.22 → 3.0.27

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 (126) 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/editor/index.js +11 -1
  4. package/build/components/editor/index.js.map +1 -1
  5. package/build/components/error-boundary/index.js +11 -27
  6. package/build/components/error-boundary/index.js.map +1 -1
  7. package/build/components/error-boundary/warning.js +70 -0
  8. package/build/components/error-boundary/warning.js.map +1 -0
  9. package/build/components/global-styles/screen-background-color.js +8 -9
  10. package/build/components/global-styles/screen-background-color.js.map +1 -1
  11. package/build/components/global-styles/screen-link-color.js +6 -10
  12. package/build/components/global-styles/screen-link-color.js.map +1 -1
  13. package/build/components/global-styles/screen-text-color.js +6 -10
  14. package/build/components/global-styles/screen-text-color.js.map +1 -1
  15. package/build/components/header/more-menu/index.js +68 -39
  16. package/build/components/header/more-menu/index.js.map +1 -1
  17. package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
  18. package/build/components/header/more-menu/site-export.js.map +1 -0
  19. package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  20. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  21. package/build/components/header/tools-more-menu-group/index.js +1 -5
  22. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  23. package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
  24. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  25. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
  26. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  27. package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
  28. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  29. package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
  30. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  31. package/build/components/keyboard-shortcuts/index.js +9 -0
  32. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  33. package/build/components/list/added-by.js +51 -50
  34. package/build/components/list/added-by.js.map +1 -1
  35. package/build/components/routes/redirect-to-homepage.js +106 -0
  36. package/build/components/routes/redirect-to-homepage.js.map +1 -0
  37. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  38. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  39. package/build/components/url-query-controller/index.js +1 -38
  40. package/build/components/url-query-controller/index.js.map +1 -1
  41. package/build/index.js +23 -4
  42. package/build/index.js.map +1 -1
  43. package/build/store/actions.js +7 -25
  44. package/build/store/actions.js.map +1 -1
  45. package/build-module/components/add-new-template/new-template-part.js +4 -1
  46. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  47. package/build-module/components/editor/index.js +11 -1
  48. package/build-module/components/editor/index.js.map +1 -1
  49. package/build-module/components/error-boundary/index.js +9 -26
  50. package/build-module/components/error-boundary/index.js.map +1 -1
  51. package/build-module/components/error-boundary/warning.js +60 -0
  52. package/build-module/components/error-boundary/warning.js.map +1 -0
  53. package/build-module/components/global-styles/screen-background-color.js +8 -10
  54. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  55. package/build-module/components/global-styles/screen-link-color.js +7 -11
  56. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  57. package/build-module/components/global-styles/screen-text-color.js +7 -11
  58. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  59. package/build-module/components/header/more-menu/index.js +65 -40
  60. package/build-module/components/header/more-menu/index.js.map +1 -1
  61. package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
  62. package/build-module/components/header/more-menu/site-export.js.map +1 -0
  63. package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  64. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  65. package/build-module/components/header/tools-more-menu-group/index.js +2 -5
  66. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  67. package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
  68. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  69. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
  70. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  71. package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
  72. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  73. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
  74. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  75. package/build-module/components/keyboard-shortcuts/index.js +9 -0
  76. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  77. package/build-module/components/list/added-by.js +52 -51
  78. package/build-module/components/list/added-by.js.map +1 -1
  79. package/build-module/components/routes/redirect-to-homepage.js +94 -0
  80. package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
  81. package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
  82. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  83. package/build-module/components/url-query-controller/index.js +3 -40
  84. package/build-module/components/url-query-controller/index.js.map +1 -1
  85. package/build-module/index.js +20 -3
  86. package/build-module/index.js.map +1 -1
  87. package/build-module/store/actions.js +7 -23
  88. package/build-module/store/actions.js.map +1 -1
  89. package/build-style/style-rtl.css +55 -5
  90. package/build-style/style.css +55 -5
  91. package/package.json +9 -9
  92. package/src/components/add-new-template/new-template-part.js +7 -1
  93. package/src/components/block-editor/style.scss +6 -6
  94. package/src/components/editor/index.js +14 -0
  95. package/src/components/error-boundary/index.js +11 -28
  96. package/src/components/error-boundary/warning.js +59 -0
  97. package/src/components/global-styles/screen-background-color.js +6 -9
  98. package/src/components/global-styles/screen-link-color.js +6 -14
  99. package/src/components/global-styles/screen-text-color.js +6 -14
  100. package/src/components/header/more-menu/index.js +103 -44
  101. package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
  102. package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  103. package/src/components/header/tools-more-menu-group/index.js +2 -7
  104. package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
  105. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
  106. package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
  107. package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
  108. package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
  109. package/src/components/keyboard-shortcuts/index.js +10 -0
  110. package/src/components/list/added-by.js +57 -63
  111. package/src/components/routes/redirect-to-homepage.js +94 -0
  112. package/src/components/template-part-converter/convert-to-template-part.js +6 -1
  113. package/src/components/url-query-controller/index.js +3 -35
  114. package/src/index.js +25 -2
  115. package/src/store/actions.js +7 -35
  116. package/src/store/test/actions.js +0 -90
  117. package/src/style.scss +1 -0
  118. package/build/plugins/index.js +0 -28
  119. package/build/plugins/index.js.map +0 -1
  120. package/build/plugins/site-export.js.map +0 -1
  121. package/build/plugins/welcome-guide-menu-item.js.map +0 -1
  122. package/build-module/plugins/index.js +0 -20
  123. package/build-module/plugins/index.js.map +0 -1
  124. package/build-module/plugins/site-export.js.map +0 -1
  125. package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
  126. package/src/plugins/index.js +0 -24
@@ -45,67 +45,75 @@ function CustomizedTooltip(_ref) {
45
45
  }, children);
46
46
  }
47
47
 
48
- function AddedByTheme(_ref2) {
49
- var _theme$name;
50
-
48
+ function BaseAddedBy(_ref2) {
51
49
  let {
52
- slug,
50
+ text,
51
+ icon,
52
+ imageUrl,
53
53
  isCustomized
54
54
  } = _ref2;
55
- const theme = (0, _data.useSelect)(select => select(_coreData.store).getTheme(slug), [slug]);
55
+ const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
56
56
  return (0, _element.createElement)(_components.__experimentalHStack, {
57
57
  alignment: "left"
58
58
  }, (0, _element.createElement)(CustomizedTooltip, {
59
59
  isCustomized: isCustomized
60
- }, (0, _element.createElement)("div", {
60
+ }, imageUrl ? (0, _element.createElement)("div", {
61
+ className: (0, _classnames.default)('edit-site-list-added-by__avatar', {
62
+ 'is-loaded': isImageLoaded
63
+ })
64
+ }, (0, _element.createElement)("img", {
65
+ onLoad: () => setIsImageLoaded(true),
66
+ alt: "",
67
+ src: imageUrl
68
+ })) : (0, _element.createElement)("div", {
61
69
  className: (0, _classnames.default)('edit-site-list-added-by__icon', {
62
70
  'is-customized': isCustomized
63
71
  })
64
72
  }, (0, _element.createElement)(_components.Icon, {
65
- icon: _icons.layout
66
- }))), (0, _element.createElement)("span", null, (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug));
73
+ icon: icon
74
+ }))), (0, _element.createElement)("span", null, text));
67
75
  }
68
76
 
69
- function AddedByPlugin(_ref3) {
77
+ function AddedByTheme(_ref3) {
78
+ var _theme$name;
79
+
70
80
  let {
71
81
  slug,
72
82
  isCustomized
73
83
  } = _ref3;
84
+ const theme = (0, _data.useSelect)(select => select(_coreData.store).getTheme(slug), [slug]);
85
+ return (0, _element.createElement)(BaseAddedBy, {
86
+ icon: _icons.layout,
87
+ text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
88
+ isCustomized: isCustomized
89
+ });
90
+ }
91
+
92
+ function AddedByPlugin(_ref4) {
93
+ let {
94
+ slug,
95
+ isCustomized
96
+ } = _ref4;
74
97
  const plugin = (0, _data.useSelect)(select => select(_coreData.store).getPlugin(slug), [slug]);
75
- return (0, _element.createElement)(_components.__experimentalHStack, {
76
- alignment: "left"
77
- }, (0, _element.createElement)(CustomizedTooltip, {
98
+ return (0, _element.createElement)(BaseAddedBy, {
99
+ icon: _icons.plugins,
100
+ text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
78
101
  isCustomized: isCustomized
79
- }, (0, _element.createElement)("div", {
80
- className: "edit-site-list-added-by__icon"
81
- }, (0, _element.createElement)(_components.Icon, {
82
- icon: _icons.plugins
83
- }))), (0, _element.createElement)("span", null, (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug));
102
+ });
84
103
  }
85
104
 
86
- function AddedByAuthor(_ref4) {
105
+ function AddedByAuthor(_ref5) {
87
106
  var _user$avatar_urls;
88
107
 
89
108
  let {
90
109
  id
91
- } = _ref4;
110
+ } = _ref5;
92
111
  const user = (0, _data.useSelect)(select => select(_coreData.store).getUser(id), [id]);
93
- const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
94
- const avatarURL = user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48];
95
- const hasAvatar = !!avatarURL;
96
- return (0, _element.createElement)(_components.__experimentalHStack, {
97
- alignment: "left"
98
- }, (0, _element.createElement)("div", {
99
- className: (0, _classnames.default)(hasAvatar ? 'edit-site-list-added-by__avatar' : 'edit-site-list-added-by__icon', {
100
- 'is-loaded': isImageLoaded
101
- })
102
- }, hasAvatar ? (0, _element.createElement)("img", {
103
- onLoad: () => setIsImageLoaded(true),
104
- alt: "",
105
- src: avatarURL
106
- }) : (0, _element.createElement)(_components.Icon, {
107
- icon: _icons.commentAuthorAvatar
108
- })), (0, _element.createElement)("span", null, user === null || user === void 0 ? void 0 : user.nickname));
112
+ return (0, _element.createElement)(BaseAddedBy, {
113
+ icon: _icons.commentAuthorAvatar,
114
+ imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
115
+ text: user === null || user === void 0 ? void 0 : user.nickname
116
+ });
109
117
  }
110
118
 
111
119
  function AddedBySite() {
@@ -121,29 +129,22 @@ function AddedBySite() {
121
129
  } = select(_coreData.store);
122
130
  const siteData = getEntityRecord('root', '__unstableBase');
123
131
  return {
124
- name: siteData.name,
132
+ name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
125
133
  logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
126
134
  };
127
135
  }, []);
128
- const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
129
- return (0, _element.createElement)(_components.__experimentalHStack, {
130
- alignment: "left"
131
- }, (0, _element.createElement)("div", {
132
- className: (0, _classnames.default)('edit-site-list-added-by__avatar', {
133
- 'is-loaded': isImageLoaded
134
- })
135
- }, (0, _element.createElement)("img", {
136
- onLoad: () => setIsImageLoaded(true),
137
- alt: "",
138
- src: logoURL
139
- })), (0, _element.createElement)("span", null, name));
136
+ return (0, _element.createElement)(BaseAddedBy, {
137
+ icon: _icons.globe,
138
+ imageUrl: logoURL,
139
+ text: name
140
+ });
140
141
  }
141
142
 
142
- function AddedBy(_ref5) {
143
+ function AddedBy(_ref6) {
143
144
  let {
144
145
  templateType,
145
146
  template
146
- } = _ref5;
147
+ } = _ref6;
147
148
 
148
149
  if (!template) {
149
150
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","AddedByTheme","slug","theme","select","coreStore","getTheme","themeIcon","name","rendered","AddedByPlugin","plugin","getPlugin","pluginIcon","AddedByAuthor","id","user","getUser","isImageLoaded","setIsImageLoaded","avatarURL","avatar_urls","hasAvatar","authorIcon","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AAKA;;AACA;;AAEA;;AAKA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;AAgBA,MAAMA,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAA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QAAQ,CAACI,MAAT,KAAoB;AAFpC,QADD;AAMA,KAjBuD,CAmBxD;;;AACA,QAAKJ,QAAQ,CAACE,cAAT,IAA2BF,QAAQ,CAACG,MAAT,KAAoB,QAApD,EAA+D;AAC9D,aACC,4BAAC,aAAD;AACC,QAAA,IAAI,EAAGH,QAAQ,CAAChC,KADjB;AAEC,QAAA,YAAY,EAAGgC,QAAQ,CAACI,MAAT,KAAoB;AAFpC,QADD;AAMA,KA3BuD,CA6BxD;AACA;AACA;;;AACA,QACC,CAAEJ,QAAQ,CAACE,cAAX,IACAF,QAAQ,CAACI,MAAT,KAAoB,QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,4BAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,4BAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__icon', {\n\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ themeIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ theme?.name?.rendered || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ pluginIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ plugin?.name || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\tconst avatarURL = user?.avatar_urls?.[ 48 ];\n\tconst hasAvatar = !! avatarURL;\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\thasAvatar\n\t\t\t\t\t\t? 'edit-site-list-added-by__avatar'\n\t\t\t\t\t\t: 'edit-site-list-added-by__icon',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ hasAvatar ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span>{ user?.nickname }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ logoURL }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ name }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","BaseAddedBy","text","icon","imageUrl","isImageLoaded","setIsImageLoaded","AddedByTheme","slug","theme","select","coreStore","getTheme","themeIcon","name","rendered","AddedByPlugin","plugin","getPlugin","pluginIcon","AddedByAuthor","id","user","getUser","authorIcon","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","globeIcon","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AAKA;;AACA;;AAEA;;AAMA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;AAiBA,MAAMA,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP;AACA;;AAED,SACC,4BAAC,mBAAD;AAAS,IAAA,IAAI,EAAG,c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QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,4BAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,4BAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction BaseAddedBy( { text, icon, imageUrl, isCustomized } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t{ imageUrl ? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-list-added-by__avatar',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-list-added-by__icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ themeIcon }\n\t\t\ttext={ theme?.name?.rendered || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t/>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ pluginIcon }\n\t\t\ttext={ plugin?.name || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t/>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ authorIcon }\n\t\t\timageUrl={ user?.avatar_urls?.[ 48 ] }\n\t\t\ttext={ user?.nickname }\n\t\t/>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData?.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<BaseAddedBy icon={ globeIcon } imageUrl={ logoURL } text={ name } />\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = redirectToHomepage;
9
+
10
+ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
11
+
12
+ var _url = require("@wordpress/url");
13
+
14
+ var _history = _interopRequireDefault(require("../../utils/history"));
15
+
16
+ var _getIsListPage = _interopRequireDefault(require("../../utils/get-is-list-page"));
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ function getNeedsHomepageRedirect(params) {
26
+ const {
27
+ postType
28
+ } = params;
29
+ return !(0, _getIsListPage.default)(params) && !['post', 'page', 'wp_template', 'wp_template_part'].includes(postType);
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
+
39
+
40
+ async function getHomepageParams(siteUrl) {
41
+ const siteSettings = await (0, _apiFetch.default)({
42
+ path: '/wp/v2/settings'
43
+ });
44
+
45
+ if (!siteSettings) {
46
+ throw new Error('`getHomepageParams`: unable to load site settings.');
47
+ }
48
+
49
+ const {
50
+ show_on_front: showOnFront,
51
+ page_on_front: frontpageId
52
+ } = siteSettings; // If the user has set a page as the homepage, use those details.
53
+
54
+ if (showOnFront === 'page') {
55
+ return {
56
+ postType: 'page',
57
+ postId: frontpageId
58
+ };
59
+ } // Else get the home template.
60
+ // This matches the logic in `__experimentalGetTemplateForLink`.
61
+ // (packages/core-data/src/resolvers.js)
62
+
63
+
64
+ const template = await window.fetch((0, _url.addQueryArgs)(siteUrl, {
65
+ '_wp-find-template': true
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 => {
73
+ let {
74
+ data
75
+ } = _ref;
76
+
77
+ if (data.message) {
78
+ throw new Error(`\`getHomepageParams\`: REST API error, ${data.message}`);
79
+ }
80
+
81
+ return data;
82
+ });
83
+
84
+ if (!(template !== null && template !== void 0 && template.id)) {
85
+ throw new Error('`getHomepageParams`: unable to find home template.');
86
+ }
87
+
88
+ return {
89
+ postType: 'wp_template',
90
+ postId: template.id
91
+ };
92
+ }
93
+
94
+ async function redirectToHomepage(siteUrl) {
95
+ const searchParams = new URLSearchParams(_history.default.location.search);
96
+ const params = Object.fromEntries(searchParams.entries());
97
+
98
+ if (getNeedsHomepageRedirect(params)) {
99
+ const homepageParams = await getHomepageParams(siteUrl);
100
+
101
+ if (homepageParams) {
102
+ _history.default.replace(homepageParams);
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=redirect-to-homepage.js.map
@@ -0,0 +1 @@
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,EAAs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,QAAR,CAAiBC,MAAtC,CAArB;AACA,QAAM9B,MAAM,GAAG+B,MAAM,CAACC,WAAP,CAAoBN,YAAY,CAACO,OAAb,EAApB,CAAf;;AAEA,MAAKlC,wBAAwB,CAAEC,MAAF,CAA7B,EAA0C;AACzC,UAAMkC,cAAc,GAAG,MAAM/B,iBAAiB,CAAEC,OAAF,CAA9C;;AAEA,QAAK8B,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\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"]}
@@ -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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AYGD,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,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;AACA;AACA,UAAMC,SAAS,GACd,uBAAWF,KAAX,EAAmBG,OAAnB,CAA4B,UAA5B,EAAwC,EAAxC,KAAgD,gBADjD;AAGA,UAAMC,YAAY,GAAG,MAAMT,gBAAgB,CAC1C,UAD0C,EAE1C,kBAF0C,EAG1C;AACCU,MAAAA,IAAI,EAAEH,SADP;AAECF,MAAAA,KAFD;AAGCM,MAAAA,OAAO,EAAE,uBAAWhB,MAAX,CAHV;AAICW,MAAAA;AAJD,KAH0C,CAA3C;AAUAR,IAAAA,aAAa,CACZJ,SADY,EAEZ,yBAAa,oBAAb,EAAmC;AAClCgB,MAAAA,IAAI,EAAED,YAAY,CAACC,IADe;AAElCE,MAAAA,KAAK,EAAEH,YAAY,CAACG;AAFc,KAAnC,CAFY,CAAb;AAOAV,IAAAA,mBAAmB,CAAE,cAAI,wBAAJ,CAAF,EAAkC;AACpDW,MAAAA,IAAI,EAAE;AAD8C,KAAlC,CAAnB,CAvB8C,CA2B9C;AACA;AACA,GA7BD;;AA+BA,SACC,qDACC,4BAAC,sCAAD,QACG,MACD,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfhB,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\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"]}
@@ -24,25 +24,16 @@ function URLQueryController() {
24
24
  const {
25
25
  setTemplate,
26
26
  setTemplatePart,
27
- showHomepage,
28
27
  setPage
29
28
  } = (0, _data.useDispatch)(_store.store);
30
- const history = (0, _routes.useHistory)();
31
29
  const {
32
30
  params: {
33
31
  postId,
34
32
  postType
35
33
  }
36
- } = (0, _routes.useLocation)();
37
- const {
38
- getPage,
39
- getEditedPostId,
40
- getEditedPostType
41
- } = (0, _data.useSelect)(_store.store); // Set correct entity on page navigation.
34
+ } = (0, _routes.useLocation)(); // Set correct entity on page navigation.
42
35
 
43
36
  (0, _element.useEffect)(() => {
44
- let isMounted = true;
45
-
46
37
  if ('page' === postType || 'post' === postType) {
47
38
  setPage({
48
39
  context: {
@@ -54,35 +45,7 @@ function URLQueryController() {
54
45
  setTemplate(postId);
55
46
  } else if ('wp_template_part' === postType) {
56
47
  setTemplatePart(postId);
57
- } else {
58
- showHomepage().then(() => {
59
- var _page$context, _page$context2;
60
-
61
- if (!isMounted) {
62
- return;
63
- }
64
-
65
- const page = getPage();
66
- const editedPostId = getEditedPostId();
67
- const editedPostType = getEditedPostType();
68
-
69
- if (page !== null && page !== void 0 && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId && page !== null && page !== void 0 && (_page$context2 = page.context) !== null && _page$context2 !== void 0 && _page$context2.postType) {
70
- history.replace({
71
- postId: page.context.postId,
72
- postType: page.context.postType
73
- });
74
- } else if (editedPostId && editedPostType) {
75
- history.replace({
76
- postId: editedPostId,
77
- postType: editedPostType
78
- });
79
- }
80
- });
81
48
  }
82
-
83
- return () => {
84
- isMounted = false;
85
- };
86
49
  }, [postId, postType]);
87
50
  return null;
88
51
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","editSiteStore","history","params","postId","postType","getPage","getEditedPostId","getEditedPostType","isMounted","context","then","page","editedPostId","editedPostType","replace"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0D,uBAC/DC,YAD+D,CAAhE;AAGA,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEF,0BAFJ;AAGA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,eAAX;AAA4BC,IAAAA;AAA5B,MAAkD,qBACvDP,YADuD,CAAxD,CAR4C,CAY5C;;AACA,0BAAW,MAAM;AAChB,QAAIQ,SAAS,GAAG,IAAhB;;AAEA,QAAK,WAAWJ,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDL,MAAAA,OAAO,CAAE;AAAEU,QAAAA,OAAO,EAAE;AAAEL,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCR,MAAAA,WAAW,CAAEO,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CP,MAAAA,eAAe,CAAEM,MAAF,CAAf;AACA,KAFM,MAEA;AACNL,MAAAA,YAAY,GAAGY,IAAf,CAAqB,MAAM;AAAA;;AAC1B,YAAK,CAAEF,SAAP,EAAmB;AAClB;AACA;;AAED,cAAMG,IAAI,GAAGN,OAAO,EAApB;AACA,cAAMO,YAAY,GAAGN,eAAe,EAApC;AACA,cAAMO,cAAc,GAAGN,iBAAiB,EAAxC;;AAEA,YAAKI,IAAI,SAAJ,IAAAA,IAAI,WAAJ,qBAAAA,IAAI,CAAEF,OAAN,wDAAeN,MAAf,IAAyBQ,IAAzB,aAAyBA,IAAzB,iCAAyBA,IAAI,CAAEF,OAA/B,2CAAyB,eAAeL,QAA7C,EAAwD;AACvDH,UAAAA,OAAO,CAACa,OAAR,CAAiB;AAChBX,YAAAA,MAAM,EAAEQ,IAAI,CAACF,OAAL,CAAaN,MADL;AAEhBC,YAAAA,QAAQ,EAAEO,IAAI,CAACF,OAAL,CAAaL;AAFP,WAAjB;AAIA,SALD,MAKO,IAAKQ,YAAY,IAAIC,cAArB,EAAsC;AAC5CZ,UAAAA,OAAO,CAACa,OAAR,CAAiB;AAChBX,YAAAA,MAAM,EAAES,YADQ;AAEhBR,YAAAA,QAAQ,EAAES;AAFM,WAAjB;AAIA;AACD,OApBD;AAqBA;;AAED,WAAO,MAAM;AACZL,MAAAA,SAAS,GAAG,KAAZ;AACA,KAFD;AAGA,GApCD,EAoCG,CAAEL,MAAF,EAAUC,QAAV,CApCH;AAsCA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\tconst history = useHistory();\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\tconst { getPage, getEditedPostId, getEditedPostType } = useSelect(\n\t\teditSiteStore\n\t);\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\tlet isMounted = true;\n\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t} else {\n\t\t\tshowHomepage().then( () => {\n\t\t\t\tif ( ! isMounted ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst page = getPage();\n\t\t\t\tconst editedPostId = getEditedPostId();\n\t\t\t\tconst editedPostType = getEditedPostType();\n\n\t\t\t\tif ( page?.context?.postId && page?.context?.postType ) {\n\t\t\t\t\thistory.replace( {\n\t\t\t\t\t\tpostId: page.context.postId,\n\t\t\t\t\t\tpostType: page.context.postType,\n\t\t\t\t\t} );\n\t\t\t\t} else if ( editedPostId && editedPostType ) {\n\t\t\t\t\thistory.replace( {\n\t\t\t\t\t\tpostId: editedPostId,\n\t\t\t\t\t\tpostType: editedPostType,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tisMounted = false;\n\t\t};\n\t}, [ postId, postType ] );\n\n\treturn null;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["URLQueryController","setTemplate","setTemplatePart","setPage","editSiteStore","params","postId","postType","context"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MAA4C,uBACjDC,YADiD,CAAlD;AAGA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEF,0BAFJ,CAJ4C,CAQ5C;;AACA,0BAAW,MAAM;AAChB,QAAK,WAAWA,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDJ,MAAAA,OAAO,CAAE;AAAEK,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCN,MAAAA,WAAW,CAAEK,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CL,MAAAA,eAAe,CAAEI,MAAF,CAAf;AACA;AACD,GARD,EAQG,CAAEA,MAAF,EAAUC,QAAV,CARH;AAUA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t}\n\t}, [ postId, postType ] );\n\n\treturn null;\n}\n"]}
package/build/index.js CHANGED
@@ -50,12 +50,12 @@ 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");
56
58
 
57
- require("./plugins");
58
-
59
59
  require("./hooks");
60
60
 
61
61
  var _store = require("./store");
@@ -64,6 +64,10 @@ var _app = _interopRequireDefault(require("./components/app"));
64
64
 
65
65
  var _getIsListPage = _interopRequireDefault(require("./utils/get-is-list-page"));
66
66
 
67
+ var _redirectToHomepage = _interopRequireDefault(require("./components/routes/redirect-to-homepage"));
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"));
@@ -90,8 +94,23 @@ var _pluginMoreMenuItem = _interopRequireDefault(require("./components/header/pl
90
94
  * @param {Element} target DOM node in which editor is rendered.
91
95
  * @param {?Object} settings Editor settings object.
92
96
  */
93
- function reinitializeEditor(target, settings) {
94
- // This will be a no-op if the target doesn't have any React nodes.
97
+ async function reinitializeEditor(target, settings) {
98
+ // The site editor relies on `postType` and `postId` params in the URL to
99
+ // define what's being edited. When visiting via the dashboard link, these
100
+ // won't be present. Do a client side redirect to the 'homepage' if that's
101
+ // the case.
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
+
113
+
95
114
  (0, _element.unmountComponentAtNode)(target);
96
115
  const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
97
116
  // so that we won't trigger unnecessary re-renders with useEffect.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","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","GUTENBERG_PHASE","enableFSEBlocks"],"m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AA,QAAQ,CAACqB,8BAAT,GAA0CC,oCAA1C;AACAtB,EAAAA,QAAQ,CAACuB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMxB,MAAM,GAAGyB,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;;AAEA,sBAAUS,aAAV,EAAwBC,qCAAxB;;AACA;;AACA,MAAKC,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAEDjC,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 './plugins';\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\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 function reinitializeEditor( target, settings ) {\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\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.GUTENBERG_PHASE === 2 ) {\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","GUTENBERG_PHASE","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,eAAZ,KAAgC,CAArC,EAAyC;AACxC,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.GUTENBERG_PHASE === 2 ) {\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"]}
@@ -20,7 +20,6 @@ exports.setNavigationPanelActiveMenu = setNavigationPanelActiveMenu;
20
20
  exports.setPage = setPage;
21
21
  exports.setTemplate = setTemplate;
22
22
  exports.setTemplatePart = setTemplatePart;
23
- exports.showHomepage = showHomepage;
24
23
  exports.toggleFeature = toggleFeature;
25
24
  exports.updateSettings = updateSettings;
26
25
 
@@ -218,10 +217,16 @@ function* setPage(page) {
218
217
  page.path = (0, _url.getPathAndQueryString)(entity.link);
219
218
  }
220
219
 
220
+ const template = yield _data.controls.resolveSelect(_coreData.store, '__experimentalGetTemplateForLink', page.path);
221
+
222
+ if (!template) {
223
+ return;
224
+ }
225
+
221
226
  const {
222
227
  id: templateId,
223
228
  slug: templateSlug
224
- } = yield _data.controls.resolveSelect(_coreData.store, '__experimentalGetTemplateForLink', page.path);
229
+ } = template;
225
230
  yield {
226
231
  type: 'SET_PAGE',
227
232
  page: !templateSlug ? page : { ...page,
@@ -233,29 +238,6 @@ function* setPage(page) {
233
238
  };
234
239
  return templateId;
235
240
  }
236
- /**
237
- * Displays the site homepage for editing in the editor.
238
- */
239
-
240
-
241
- function* showHomepage() {
242
- const {
243
- show_on_front: showOnFront,
244
- page_on_front: frontpageId
245
- } = yield _data.controls.resolveSelect(_coreData.store, 'getEntityRecord', 'root', 'site');
246
- const {
247
- siteUrl
248
- } = yield _data.controls.select(_constants.STORE_NAME, 'getSettings');
249
- const page = {
250
- path: siteUrl,
251
- context: showOnFront === 'page' ? {
252
- postType: 'page',
253
- postId: frontpageId
254
- } : {}
255
- };
256
- const homeTemplate = yield* setPage(page);
257
- yield setHomeTemplateId(homeTemplate);
258
- }
259
241
  /**
260
242
  * Returns an action object used to set the active navigation panel menu.
261
243
  *