@wordpress/edit-site 3.0.12 → 3.0.16

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 (217) hide show
  1. package/build/components/add-new-template/new-template-part.js +29 -18
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +30 -23
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/app/index.js +51 -0
  6. package/build/components/app/index.js.map +1 -0
  7. package/build/components/block-editor/back-button.js +8 -20
  8. package/build/components/block-editor/back-button.js.map +1 -1
  9. package/build/components/block-editor/index.js +2 -1
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/create-template-part-modal/index.js +0 -2
  12. package/build/components/create-template-part-modal/index.js.map +1 -1
  13. package/build/components/edit-template-part-menu-button/index.js +20 -8
  14. package/build/components/edit-template-part-menu-button/index.js.map +1 -1
  15. package/build/components/editor/index.js +11 -30
  16. package/build/components/editor/index.js.map +1 -1
  17. package/build/components/global-styles/gradients-palette-panel.js +16 -1
  18. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  19. package/build/components/global-styles/screen-background-color.js +2 -1
  20. package/build/components/global-styles/screen-background-color.js.map +1 -1
  21. package/build/components/global-styles/screen-link-color.js +2 -1
  22. package/build/components/global-styles/screen-link-color.js.map +1 -1
  23. package/build/components/global-styles/screen-text-color.js +2 -1
  24. package/build/components/global-styles/screen-text-color.js.map +1 -1
  25. package/build/components/global-styles/use-global-styles-output.js +1 -2
  26. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  27. package/build/components/header/document-actions/index.js +3 -6
  28. package/build/components/header/document-actions/index.js.map +1 -1
  29. package/build/components/list/actions/index.js +1 -1
  30. package/build/components/list/actions/index.js.map +1 -1
  31. package/build/components/list/index.js +17 -15
  32. package/build/components/list/index.js.map +1 -1
  33. package/build/components/list/table.js +31 -27
  34. package/build/components/list/table.js.map +1 -1
  35. package/build/components/navigation-sidebar/index.js +12 -13
  36. package/build/components/navigation-sidebar/index.js.map +1 -1
  37. package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
  38. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  39. package/build/components/routes/index.js +60 -0
  40. package/build/components/routes/index.js.map +1 -0
  41. package/build/components/routes/link.js +65 -0
  42. package/build/components/routes/link.js.map +1 -0
  43. package/build/components/routes/use-title.js +57 -0
  44. package/build/components/routes/use-title.js.map +1 -0
  45. package/build/components/sidebar/global-styles-sidebar.js +10 -0
  46. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  47. package/build/components/sidebar/template-card/template-areas.js +7 -4
  48. package/build/components/sidebar/template-card/template-areas.js.map +1 -1
  49. package/build/components/template-details/edit-template-title.js +33 -0
  50. package/build/components/template-details/edit-template-title.js.map +1 -0
  51. package/build/components/template-details/index.js +18 -12
  52. package/build/components/template-details/index.js.map +1 -1
  53. package/build/components/template-details/template-areas.js +28 -11
  54. package/build/components/template-details/template-areas.js.map +1 -1
  55. package/build/components/template-part-converter/convert-to-template-part.js +7 -12
  56. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  57. package/build/components/url-query-controller/index.js +41 -50
  58. package/build/components/url-query-controller/index.js.map +1 -1
  59. package/build/components/welcome-guide/editor.js +6 -0
  60. package/build/components/welcome-guide/editor.js.map +1 -1
  61. package/build/components/welcome-guide/index.js +1 -28
  62. package/build/components/welcome-guide/index.js.map +1 -1
  63. package/build/components/welcome-guide/styles.js +18 -1
  64. package/build/components/welcome-guide/styles.js.map +1 -1
  65. package/build/index.js +29 -35
  66. package/build/index.js.map +1 -1
  67. package/build/plugins/index.js +3 -23
  68. package/build/plugins/index.js.map +1 -1
  69. package/build/plugins/site-export.js +61 -0
  70. package/build/plugins/site-export.js.map +1 -0
  71. package/build/plugins/welcome-guide-menu-item.js +1 -7
  72. package/build/plugins/welcome-guide-menu-item.js.map +1 -1
  73. package/build/store/actions.js +0 -27
  74. package/build/store/actions.js.map +1 -1
  75. package/build/store/constants.js +1 -14
  76. package/build/store/constants.js.map +1 -1
  77. package/build/store/reducer.js +7 -16
  78. package/build/store/reducer.js.map +1 -1
  79. package/build/store/selectors.js +1 -31
  80. package/build/store/selectors.js.map +1 -1
  81. package/build/utils/get-is-list-page.js +23 -0
  82. package/build/utils/get-is-list-page.js.map +1 -0
  83. package/build/utils/history.js +35 -0
  84. package/build/utils/history.js.map +1 -0
  85. package/build-module/components/add-new-template/new-template-part.js +27 -16
  86. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  87. package/build-module/components/add-new-template/new-template.js +28 -18
  88. package/build-module/components/add-new-template/new-template.js.map +1 -1
  89. package/build-module/components/app/index.js +35 -0
  90. package/build-module/components/app/index.js.map +1 -0
  91. package/build-module/components/block-editor/back-button.js +8 -19
  92. package/build-module/components/block-editor/back-button.js.map +1 -1
  93. package/build-module/components/block-editor/index.js +2 -1
  94. package/build-module/components/block-editor/index.js.map +1 -1
  95. package/build-module/components/create-template-part-modal/index.js +0 -2
  96. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  97. package/build-module/components/edit-template-part-menu-button/index.js +17 -9
  98. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
  99. package/build-module/components/editor/index.js +13 -33
  100. package/build-module/components/editor/index.js.map +1 -1
  101. package/build-module/components/global-styles/gradients-palette-panel.js +16 -2
  102. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  103. package/build-module/components/global-styles/screen-background-color.js +2 -1
  104. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  105. package/build-module/components/global-styles/screen-link-color.js +2 -1
  106. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  107. package/build-module/components/global-styles/screen-text-color.js +2 -1
  108. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  109. package/build-module/components/global-styles/use-global-styles-output.js +1 -2
  110. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  111. package/build-module/components/header/document-actions/index.js +3 -6
  112. package/build-module/components/header/document-actions/index.js.map +1 -1
  113. package/build-module/components/list/actions/index.js +1 -1
  114. package/build-module/components/list/actions/index.js.map +1 -1
  115. package/build-module/components/list/index.js +15 -15
  116. package/build-module/components/list/index.js.map +1 -1
  117. package/build-module/components/list/table.js +31 -27
  118. package/build-module/components/list/table.js.map +1 -1
  119. package/build-module/components/navigation-sidebar/index.js +13 -13
  120. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  121. package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
  122. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  123. package/build-module/components/routes/index.js +47 -0
  124. package/build-module/components/routes/index.js.map +1 -0
  125. package/build-module/components/routes/link.js +51 -0
  126. package/build-module/components/routes/link.js.map +1 -0
  127. package/build-module/components/routes/use-title.js +44 -0
  128. package/build-module/components/routes/use-title.js.map +1 -0
  129. package/build-module/components/sidebar/global-styles-sidebar.js +8 -0
  130. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  131. package/build-module/components/sidebar/template-card/template-areas.js +8 -4
  132. package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
  133. package/build-module/components/template-details/edit-template-title.js +23 -0
  134. package/build-module/components/template-details/edit-template-title.js.map +1 -0
  135. package/build-module/components/template-details/index.js +15 -11
  136. package/build-module/components/template-details/index.js.map +1 -1
  137. package/build-module/components/template-details/template-areas.js +25 -10
  138. package/build-module/components/template-details/template-areas.js.map +1 -1
  139. package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
  140. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  141. package/build-module/components/url-query-controller/index.js +40 -49
  142. package/build-module/components/url-query-controller/index.js.map +1 -1
  143. package/build-module/components/welcome-guide/editor.js +7 -1
  144. package/build-module/components/welcome-guide/editor.js.map +1 -1
  145. package/build-module/components/welcome-guide/index.js +2 -26
  146. package/build-module/components/welcome-guide/index.js.map +1 -1
  147. package/build-module/components/welcome-guide/styles.js +18 -2
  148. package/build-module/components/welcome-guide/styles.js.map +1 -1
  149. package/build-module/index.js +28 -33
  150. package/build-module/index.js.map +1 -1
  151. package/build-module/plugins/index.js +2 -18
  152. package/build-module/plugins/index.js.map +1 -1
  153. package/build-module/plugins/site-export.js +45 -0
  154. package/build-module/plugins/site-export.js.map +1 -0
  155. package/build-module/plugins/welcome-guide-menu-item.js +2 -7
  156. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
  157. package/build-module/store/actions.js +0 -23
  158. package/build-module/store/actions.js.map +1 -1
  159. package/build-module/store/constants.js +0 -11
  160. package/build-module/store/constants.js.map +1 -1
  161. package/build-module/store/reducer.js +7 -16
  162. package/build-module/store/reducer.js.map +1 -1
  163. package/build-module/store/selectors.js +1 -27
  164. package/build-module/store/selectors.js.map +1 -1
  165. package/build-module/utils/get-is-list-page.js +16 -0
  166. package/build-module/utils/get-is-list-page.js.map +1 -0
  167. package/build-module/utils/history.js +25 -0
  168. package/build-module/utils/history.js.map +1 -0
  169. package/build-style/style-rtl.css +11 -10
  170. package/build-style/style.css +11 -10
  171. package/package.json +9 -8
  172. package/src/components/add-new-template/new-template-part.js +29 -11
  173. package/src/components/add-new-template/new-template.js +26 -12
  174. package/src/components/app/index.js +47 -0
  175. package/src/components/block-editor/back-button.js +6 -14
  176. package/src/components/block-editor/index.js +1 -0
  177. package/src/components/create-template-part-modal/index.js +0 -2
  178. package/src/components/edit-template-part-menu-button/index.js +16 -5
  179. package/src/components/editor/index.js +105 -131
  180. package/src/components/global-styles/gradients-palette-panel.js +20 -0
  181. package/src/components/global-styles/screen-background-color.js +1 -0
  182. package/src/components/global-styles/screen-link-color.js +1 -0
  183. package/src/components/global-styles/screen-text-color.js +1 -0
  184. package/src/components/global-styles/style.scss +12 -6
  185. package/src/components/global-styles/use-global-styles-output.js +0 -1
  186. package/src/components/header/document-actions/index.js +3 -9
  187. package/src/components/list/actions/index.js +1 -1
  188. package/src/components/list/index.js +11 -12
  189. package/src/components/list/style.scss +6 -11
  190. package/src/components/list/table.js +7 -6
  191. package/src/components/navigation-sidebar/index.js +18 -17
  192. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
  193. package/src/components/routes/index.js +53 -0
  194. package/src/components/routes/link.js +44 -0
  195. package/src/components/routes/use-title.js +56 -0
  196. package/src/components/sidebar/global-styles-sidebar.js +8 -0
  197. package/src/components/sidebar/template-card/template-areas.js +16 -4
  198. package/src/components/template-details/edit-template-title.js +28 -0
  199. package/src/components/template-details/index.js +21 -14
  200. package/src/components/template-details/template-areas.js +32 -9
  201. package/src/components/template-part-converter/convert-to-template-part.js +4 -2
  202. package/src/components/url-query-controller/index.js +34 -45
  203. package/src/components/welcome-guide/editor.js +10 -1
  204. package/src/components/welcome-guide/index.js +6 -25
  205. package/src/components/welcome-guide/styles.js +20 -2
  206. package/src/index.js +33 -36
  207. package/src/plugins/index.js +2 -32
  208. package/src/plugins/site-export.js +48 -0
  209. package/src/plugins/welcome-guide-menu-item.js +2 -16
  210. package/src/store/actions.js +0 -23
  211. package/src/store/constants.js +0 -12
  212. package/src/store/reducer.js +12 -26
  213. package/src/store/selectors.js +1 -27
  214. package/src/store/test/reducer.js +22 -39
  215. package/src/store/test/selectors.js +3 -34
  216. package/src/utils/get-is-list-page.js +11 -0
  217. package/src/utils/history.js +35 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Returns if the params match the list page route.
3
+ *
4
+ * @param {Object} params The search params.
5
+ * @param {string} params.postId The post ID.
6
+ * @param {string} params.postType The post type.
7
+ * @return {boolean} Is list page or not.
8
+ */
9
+ export default function getIsListPage(_ref) {
10
+ let {
11
+ postId,
12
+ postType
13
+ } = _ref;
14
+ return !!(!postId && postType);
15
+ }
16
+ //# sourceMappingURL=get-is-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","postId","postType"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,aAAT,OAA+C;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AAC7D,SAAO,CAAC,EAAI,CAAED,MAAF,IAAYC,QAAhB,CAAR;AACA","sourcesContent":["/**\n * Returns if the params match the list page route.\n *\n * @param {Object} params The search params.\n * @param {string} params.postId The post ID.\n * @param {string} params.postType The post type.\n * @return {boolean} Is list page or not.\n */\nexport default function getIsListPage( { postId, postType } ) {\n\treturn !! ( ! postId && postType );\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { createBrowserHistory } from 'history';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+
9
+ import { addQueryArgs } from '@wordpress/url';
10
+ const history = createBrowserHistory();
11
+ const originalHistoryPush = history.push;
12
+ const originalHistoryReplace = history.replace;
13
+
14
+ function push(params, state) {
15
+ return originalHistoryPush.call(history, addQueryArgs(window.location.href, params), state);
16
+ }
17
+
18
+ function replace(params, state) {
19
+ return originalHistoryReplace.call(history, addQueryArgs(window.location.href, params), state);
20
+ }
21
+
22
+ history.push = push;
23
+ history.replace = replace;
24
+ export default history;
25
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/utils/history.js"],"names":["createBrowserHistory","addQueryArgs","history","originalHistoryPush","push","originalHistoryReplace","replace","params","state","call","window","location","href"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAT,QAAqC,SAArC;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,MAAMC,OAAO,GAAGF,oBAAoB,EAApC;AAEA,MAAMG,mBAAmB,GAAGD,OAAO,CAACE,IAApC;AACA,MAAMC,sBAAsB,GAAGH,OAAO,CAACI,OAAvC;;AAEA,SAASF,IAAT,CAAeG,MAAf,EAAuBC,KAAvB,EAA+B;AAC9B,SAAOL,mBAAmB,CAACM,IAApB,CACNP,OADM,EAEND,YAAY,CAAES,MAAM,CAACC,QAAP,CAAgBC,IAAlB,EAAwBL,MAAxB,CAFN,EAGNC,KAHM,CAAP;AAKA;;AAED,SAASF,OAAT,CAAkBC,MAAlB,EAA0BC,KAA1B,EAAkC;AACjC,SAAOH,sBAAsB,CAACI,IAAvB,CACNP,OADM,EAEND,YAAY,CAAES,MAAM,CAACC,QAAP,CAAgBC,IAAlB,EAAwBL,MAAxB,CAFN,EAGNC,KAHM,CAAP;AAKA;;AAEDN,OAAO,CAACE,IAAR,GAAeA,IAAf;AACAF,OAAO,CAACI,OAAR,GAAkBA,OAAlB;AAEA,eAAeJ,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { createBrowserHistory } from 'history';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\nconst history = createBrowserHistory();\n\nconst originalHistoryPush = history.push;\nconst originalHistoryReplace = history.replace;\n\nfunction push( params, state ) {\n\treturn originalHistoryPush.call(\n\t\thistory,\n\t\taddQueryArgs( window.location.href, params ),\n\t\tstate\n\t);\n}\n\nfunction replace( params, state ) {\n\treturn originalHistoryReplace.call(\n\t\thistory,\n\t\taddQueryArgs( window.location.href, params ),\n\t\tstate\n\t);\n}\n\nhistory.push = push;\nhistory.replace = replace;\n\nexport default history;\n"]}
@@ -566,13 +566,11 @@ body.is-fullscreen-mode .interface-interface-skeleton {
566
566
  margin-right: 0;
567
567
  display: block;
568
568
  border-radius: 50%;
569
- border: 0;
570
569
  height: 24px;
571
570
  width: 24px;
572
571
  padding: 0;
573
- background-image: repeating-linear-gradient(-45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0), repeating-linear-gradient(-45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0);
574
- background-position: 100% 0, 25px 25px;
575
- background-size: calc(2 * 5px) calc(2 * 5px);
572
+ border: 1px solid #ddd;
573
+ background: linear-gradient(45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
576
574
  }
577
575
 
578
576
  .edit-site-global-styles-header__description {
@@ -594,6 +592,14 @@ body.is-fullscreen-mode .interface-interface-skeleton {
594
592
  min-height: 32px;
595
593
  }
596
594
 
595
+ h2.edit-site-global-styles-gradient-palette-panel__duotone-heading.components-heading {
596
+ text-transform: uppercase;
597
+ line-height: 24px;
598
+ font-weight: 500;
599
+ font-size: 11px;
600
+ margin-bottom: 8px;
601
+ }
602
+
597
603
  .edit-site-header {
598
604
  align-items: center;
599
605
  background-color: #fff;
@@ -1116,16 +1122,11 @@ body.is-fullscreen-mode .edit-site-list-header {
1116
1122
  }
1117
1123
  .edit-site .edit-site-list .interface-interface-skeleton__content {
1118
1124
  background: #fff;
1119
- }
1120
-
1121
- .edit-site-list-main {
1122
- display: flex;
1123
1125
  align-items: center;
1124
- justify-content: center;
1125
1126
  padding: 16px;
1126
1127
  }
1127
1128
  @media (min-width: 782px) {
1128
- .edit-site-list-main {
1129
+ .edit-site .edit-site-list .interface-interface-skeleton__content {
1129
1130
  padding: 72px;
1130
1131
  }
1131
1132
  }
@@ -566,13 +566,11 @@ body.is-fullscreen-mode .interface-interface-skeleton {
566
566
  margin-left: 0;
567
567
  display: block;
568
568
  border-radius: 50%;
569
- border: 0;
570
569
  height: 24px;
571
570
  width: 24px;
572
571
  padding: 0;
573
- background-image: repeating-linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0), repeating-linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0);
574
- background-position: 0 0, 25px 25px;
575
- background-size: calc(2 * 5px) calc(2 * 5px);
572
+ border: 1px solid #ddd;
573
+ background: linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
576
574
  }
577
575
 
578
576
  .edit-site-global-styles-header__description {
@@ -594,6 +592,14 @@ body.is-fullscreen-mode .interface-interface-skeleton {
594
592
  min-height: 32px;
595
593
  }
596
594
 
595
+ h2.edit-site-global-styles-gradient-palette-panel__duotone-heading.components-heading {
596
+ text-transform: uppercase;
597
+ line-height: 24px;
598
+ font-weight: 500;
599
+ font-size: 11px;
600
+ margin-bottom: 8px;
601
+ }
602
+
597
603
  .edit-site-header {
598
604
  align-items: center;
599
605
  background-color: #fff;
@@ -1116,16 +1122,11 @@ body.is-fullscreen-mode .edit-site-list-header {
1116
1122
  }
1117
1123
  .edit-site .edit-site-list .interface-interface-skeleton__content {
1118
1124
  background: #fff;
1119
- }
1120
-
1121
- .edit-site-list-main {
1122
- display: flex;
1123
1125
  align-items: center;
1124
- justify-content: center;
1125
1126
  padding: 16px;
1126
1127
  }
1127
1128
  @media (min-width: 782px) {
1128
- .edit-site-list-main {
1129
+ .edit-site .edit-site-list .interface-interface-skeleton__content {
1129
1130
  padding: 72px;
1130
1131
  }
1131
1132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "3.0.12",
3
+ "version": "3.0.16",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,33 +29,34 @@
29
29
  "@babel/runtime": "^7.16.0",
30
30
  "@wordpress/a11y": "^3.2.4",
31
31
  "@wordpress/api-fetch": "^5.2.6",
32
- "@wordpress/block-editor": "^8.0.6",
33
- "@wordpress/block-library": "^6.0.10",
32
+ "@wordpress/block-editor": "^8.0.10",
33
+ "@wordpress/block-library": "^6.0.14",
34
34
  "@wordpress/blocks": "^11.1.4",
35
- "@wordpress/components": "^19.1.0",
35
+ "@wordpress/components": "^19.1.4",
36
36
  "@wordpress/compose": "^5.0.6",
37
37
  "@wordpress/core-data": "^4.0.8",
38
38
  "@wordpress/data": "^6.1.4",
39
39
  "@wordpress/data-controls": "^2.2.7",
40
- "@wordpress/editor": "^12.0.9",
40
+ "@wordpress/editor": "^12.0.13",
41
41
  "@wordpress/element": "^4.0.4",
42
42
  "@wordpress/hooks": "^3.2.2",
43
43
  "@wordpress/html-entities": "^3.2.3",
44
44
  "@wordpress/i18n": "^4.2.4",
45
45
  "@wordpress/icons": "^6.1.1",
46
- "@wordpress/interface": "^4.1.8",
46
+ "@wordpress/interface": "^4.1.12",
47
47
  "@wordpress/keyboard-shortcuts": "^3.0.6",
48
48
  "@wordpress/keycodes": "^3.2.4",
49
49
  "@wordpress/media-utils": "^3.0.5",
50
50
  "@wordpress/notices": "^3.2.7",
51
51
  "@wordpress/plugins": "^4.0.6",
52
52
  "@wordpress/primitives": "^3.0.4",
53
- "@wordpress/reusable-blocks": "^3.0.12",
53
+ "@wordpress/reusable-blocks": "^3.0.16",
54
54
  "@wordpress/url": "^3.3.1",
55
55
  "@wordpress/viewport": "^4.0.6",
56
56
  "classnames": "^2.3.1",
57
57
  "downloadjs": "^1.4.7",
58
58
  "file-saver": "^2.0.2",
59
+ "history": "^5.1.0",
59
60
  "jszip": "^3.2.2",
60
61
  "lodash": "^4.17.21",
61
62
  "rememo": "^3.0.0"
@@ -63,5 +64,5 @@
63
64
  "publishConfig": {
64
65
  "access": "public"
65
66
  },
66
- "gitHead": "6d3bd917064b4b194677233ee426f5988fa441b9"
67
+ "gitHead": "3826b68f8c5b5026b318463af647f6fb19b534d2"
67
68
  }
@@ -7,21 +7,24 @@ import { kebabCase } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useState } from '@wordpress/element';
10
- import { useDispatch } from '@wordpress/data';
10
+ import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import { Button } from '@wordpress/components';
12
- import { addQueryArgs } from '@wordpress/url';
13
- import apiFetch from '@wordpress/api-fetch';
14
12
  import { __ } from '@wordpress/i18n';
15
13
  import { store as noticesStore } from '@wordpress/notices';
14
+ import { store as coreStore } from '@wordpress/core-data';
16
15
 
17
16
  /**
18
17
  * Internal dependencies
19
18
  */
19
+ import { useHistory } from '../routes';
20
20
  import CreateTemplatePartModal from '../create-template-part-modal';
21
21
 
22
22
  export default function NewTemplatePart( { postType } ) {
23
+ const history = useHistory();
23
24
  const [ isModalOpen, setIsModalOpen ] = useState( false );
24
25
  const { createErrorNotice } = useDispatch( noticesStore );
26
+ const { saveEntityRecord } = useDispatch( coreStore );
27
+ const { getLastEntitySaveError } = useSelect( coreStore );
25
28
 
26
29
  async function createTemplatePart( { title, area } ) {
27
30
  if ( ! title ) {
@@ -32,22 +35,35 @@ export default function NewTemplatePart( { postType } ) {
32
35
  }
33
36
 
34
37
  try {
35
- const templatePart = await apiFetch( {
36
- path: '/wp/v2/template-parts',
37
- method: 'POST',
38
- data: {
38
+ const templatePart = await saveEntityRecord(
39
+ 'postType',
40
+ 'wp_template_part',
41
+ {
39
42
  slug: kebabCase( title ),
40
43
  title,
41
44
  content: '',
42
45
  area,
43
- },
44
- } );
46
+ }
47
+ );
48
+
49
+ const lastEntitySaveError = getLastEntitySaveError(
50
+ 'postType',
51
+ 'wp_template_part',
52
+ templatePart.id
53
+ );
54
+ if ( lastEntitySaveError ) {
55
+ throw lastEntitySaveError;
56
+ }
57
+
58
+ setIsModalOpen( false );
45
59
 
46
60
  // Navigate to the created template part editor.
47
- window.location.href = addQueryArgs( window.location.href, {
61
+ history.push( {
48
62
  postId: templatePart.id,
49
- postType: 'wp_template_part',
63
+ postType: templatePart.type,
50
64
  } );
65
+
66
+ // TODO: Add a success notice?
51
67
  } catch ( error ) {
52
68
  const errorMessage =
53
69
  error.message && error.code !== 'unknown_error'
@@ -57,6 +73,8 @@ export default function NewTemplatePart( { postType } ) {
57
73
  );
58
74
 
59
75
  createErrorNotice( errorMessage, { type: 'snackbar' } );
76
+
77
+ setIsModalOpen( false );
60
78
  }
61
79
  }
62
80
 
@@ -15,11 +15,14 @@ import {
15
15
  import { useSelect, useDispatch } from '@wordpress/data';
16
16
  import { store as coreStore } from '@wordpress/core-data';
17
17
  import { store as editorStore } from '@wordpress/editor';
18
- import { addQueryArgs } from '@wordpress/url';
19
- import apiFetch from '@wordpress/api-fetch';
20
18
  import { __ } from '@wordpress/i18n';
21
19
  import { store as noticesStore } from '@wordpress/notices';
22
20
 
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+ import { useHistory } from '../routes';
25
+
23
26
  const DEFAULT_TEMPLATE_SLUGS = [
24
27
  'front-page',
25
28
  'single-post',
@@ -31,6 +34,7 @@ const DEFAULT_TEMPLATE_SLUGS = [
31
34
  ];
32
35
 
33
36
  export default function NewTemplate( { postType } ) {
37
+ const history = useHistory();
34
38
  const { templates, defaultTemplateTypes } = useSelect(
35
39
  ( select ) => ( {
36
40
  templates: select( coreStore ).getEntityRecords(
@@ -44,7 +48,9 @@ export default function NewTemplate( { postType } ) {
44
48
  } ),
45
49
  []
46
50
  );
51
+ const { saveEntityRecord } = useDispatch( coreStore );
47
52
  const { createErrorNotice } = useDispatch( noticesStore );
53
+ const { getLastEntitySaveError } = useSelect( coreStore );
48
54
 
49
55
  async function createTemplate( { slug } ) {
50
56
  try {
@@ -52,26 +58,34 @@ export default function NewTemplate( { postType } ) {
52
58
  slug,
53
59
  } );
54
60
 
55
- const template = await apiFetch( {
56
- path: '/wp/v2/templates',
57
- method: 'POST',
58
- data: {
61
+ const template = await saveEntityRecord(
62
+ 'postType',
63
+ 'wp_template',
64
+ {
59
65
  excerpt: description,
60
66
  // Slugs need to be strings, so this is for template `404`
61
67
  slug: slug.toString(),
62
68
  status: 'publish',
63
69
  title,
64
- },
65
- } );
70
+ }
71
+ );
72
+
73
+ const lastEntitySaveError = getLastEntitySaveError(
74
+ 'postType',
75
+ 'wp_template',
76
+ template.id
77
+ );
78
+ if ( lastEntitySaveError ) {
79
+ throw lastEntitySaveError;
80
+ }
66
81
 
67
82
  // Navigate to the created template editor.
68
- window.location.href = addQueryArgs( window.location.href, {
83
+ history.push( {
69
84
  postId: template.id,
70
- postType: 'wp_template',
85
+ postType: template.type,
71
86
  } );
72
87
 
73
- // Wait for async navigation to happen before closing the modal.
74
- await new Promise( () => {} );
88
+ // TODO: Add a success notice?
75
89
  } catch ( error ) {
76
90
  const errorMessage =
77
91
  error.message && error.code !== 'unknown_error'
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { SlotFillProvider } from '@wordpress/components';
5
+ import { UnsavedChangesWarning } from '@wordpress/editor';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { Routes } from '../routes';
11
+ import Editor from '../editor';
12
+ import List from '../list';
13
+ import NavigationSidebar from '../navigation-sidebar';
14
+ import getIsListPage from '../../utils/get-is-list-page';
15
+
16
+ export default function EditSiteApp( { reboot } ) {
17
+ return (
18
+ <SlotFillProvider>
19
+ <UnsavedChangesWarning />
20
+
21
+ <Routes>
22
+ { ( { params } ) => {
23
+ const isListPage = getIsListPage( params );
24
+
25
+ return (
26
+ <>
27
+ { isListPage ? (
28
+ <List />
29
+ ) : (
30
+ <Editor onError={ reboot } />
31
+ ) }
32
+ { /* Keep the instance of the sidebar to ensure focus will not be lost
33
+ * when navigating to other pages. */ }
34
+ <NavigationSidebar
35
+ // Open the navigation sidebar by default when in the list page.
36
+ isDefaultOpen={ !! isListPage }
37
+ activeTemplateType={
38
+ isListPage ? params.postType : undefined
39
+ }
40
+ />
41
+ </>
42
+ );
43
+ } }
44
+ </Routes>
45
+ </SlotFillProvider>
46
+ );
47
+ }
@@ -3,26 +3,18 @@
3
3
  */
4
4
  import { Button } from '@wordpress/components';
5
5
  import { arrowLeft } from '@wordpress/icons';
6
- import { useSelect, useDispatch } from '@wordpress/data';
7
6
  import { __ } from '@wordpress/i18n';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import { store as editSiteStore } from '../../store';
11
+ import { useLocation, useHistory } from '../routes';
13
12
 
14
13
  function BackButton() {
15
- const { isTemplatePart, previousTemplateId } = useSelect( ( select ) => {
16
- const { getEditedPostType, getPreviousEditedPostId } = select(
17
- editSiteStore
18
- );
19
-
20
- return {
21
- isTemplatePart: getEditedPostType() === 'wp_template_part',
22
- previousTemplateId: getPreviousEditedPostId(),
23
- };
24
- }, [] );
25
- const { goBack } = useDispatch( editSiteStore );
14
+ const location = useLocation();
15
+ const history = useHistory();
16
+ const isTemplatePart = location.params.postType === 'wp_template_part';
17
+ const previousTemplateId = location.state?.fromTemplateId;
26
18
 
27
19
  if ( ! isTemplatePart || ! previousTemplateId ) {
28
20
  return null;
@@ -33,7 +25,7 @@ function BackButton() {
33
25
  className="edit-site-visual-editor__back-button"
34
26
  icon={ arrowLeft }
35
27
  onClick={ () => {
36
- goBack();
28
+ history.back();
37
29
  } }
38
30
  >
39
31
  { __( 'Back' ) }
@@ -124,6 +124,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
124
124
  <BlockList
125
125
  className="edit-site-block-editor__block-list wp-site-blocks"
126
126
  __experimentalLayout={ LAYOUT }
127
+ renderAppender={ isTemplatePart ? false : undefined }
127
128
  />
128
129
  </ResizableEditor>
129
130
 
@@ -52,8 +52,6 @@ export default function CreateTemplatePartModal( { closeModal, onCreate } ) {
52
52
  }
53
53
  setIsSubmitting( true );
54
54
  await onCreate( { title, area } );
55
- setIsSubmitting( false );
56
- closeModal();
57
55
  } }
58
56
  >
59
57
  <TextControl
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useSelect, useDispatch } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
5
5
  import {
6
6
  store as blockEditorStore,
7
7
  BlockSettingsMenuControls,
@@ -14,7 +14,8 @@ import { __, sprintf } from '@wordpress/i18n';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import { store as editSiteStore } from '../../store';
17
+ import { useLocation } from '../routes';
18
+ import { useLink } from '../routes/link';
18
19
 
19
20
  export default function EditTemplatePartMenuButton() {
20
21
  return (
@@ -30,6 +31,7 @@ export default function EditTemplatePartMenuButton() {
30
31
  }
31
32
 
32
33
  function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
34
+ const { params } = useLocation();
33
35
  const selectedTemplatePart = useSelect(
34
36
  ( select ) => {
35
37
  const block = select( blockEditorStore ).getBlock(
@@ -50,7 +52,15 @@ function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
50
52
  [ selectedClientId ]
51
53
  );
52
54
 
53
- const { pushTemplatePart } = useDispatch( editSiteStore );
55
+ const linkProps = useLink(
56
+ {
57
+ postId: selectedTemplatePart?.id,
58
+ postType: selectedTemplatePart?.type,
59
+ },
60
+ {
61
+ fromTemplateId: params.postId,
62
+ }
63
+ );
54
64
 
55
65
  if ( ! selectedTemplatePart ) {
56
66
  return null;
@@ -58,8 +68,9 @@ function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
58
68
 
59
69
  return (
60
70
  <MenuItem
61
- onClick={ () => {
62
- pushTemplatePart( selectedTemplatePart.id );
71
+ { ...linkProps }
72
+ onClick={ ( event ) => {
73
+ linkProps.onClick( event );
63
74
  onClose();
64
75
  } }
65
76
  >